Пример #1
0
 def query_transfer_from_event(self, tx_hash: str):
     event = self._sdk.default_network.get_contract_event_by_tx_hash(
         tx_hash)
     notify = Event.get_notify_by_contract_address(event,
                                                   self._contract_address)
     notify = NeoData.parse_addr_addr_int_notify(notify)
     return notify
Пример #2
0
 async def query_approve_event(self, tx_hash: str):
     event = await self._sdk.default_aio_network.get_contract_event_by_tx_hash(
         tx_hash)
     notify = Event.get_notify_by_contract_address(event,
                                                   self._contract_address)
     notify = NeoData.parse_addr_addr_int_notify(notify)
     return notify
Пример #3
0
 async def test_subscribe(self):
     hex_contract_address = '1ddbb682743e9d9e2b71ff419e97a9358c5c4ee9'
     oep4 = sdk.neo_vm.aio_oep4(hex_contract_address)
     response = await sdk.websocket.subscribe(hex_contract_address, True,
                                              False, False, False)
     self.assertEqual([hex_contract_address], response['ContractsFilter'])
     self.assertEqual(True, response['SubscribeEvent'])
     self.assertEqual(False, response['SubscribeJsonBlock'])
     self.assertEqual(False, response['SubscribeRawBlock'])
     b58_to_address = acct2.get_address_base58()
     value = 10
     tx_hash = await oep4.transfer(acct1, b58_to_address, value, acct3, 500,
                                   20000)
     self.assertEqual(64, len(tx_hash))
     try:
         event = await asyncio.wait_for(sdk.websocket.recv_subscribe_info(),
                                        timeout=10)
         self.assertEqual(False, response['SubscribeBlockTxHashs'])
         self.assertEqual(64, len(event['TxHash']))
         notify = Event.get_notify_by_contract_address(
             event, hex_contract_address)
         notify = NeoData.parse_addr_addr_int_notify(notify)
         self.assertEqual(hex_contract_address, notify['ContractAddress'])
         self.assertEqual('transfer', notify['States'][0])
         self.assertEqual(acct1.get_address_base58(), notify['States'][1])
         self.assertEqual(b58_to_address, notify['States'][2])
         self.assertEqual(value, notify['States'][3])
     except asyncio.TimeoutError:
         pass
     finally:
         await sdk.websocket.close_connect()
Пример #4
0
 def _parse_multi_transfer_event(self, event: dict):
     notify_list = Event.get_notify_by_contract_address(
         event, self._contract_address)
     for index, notify in enumerate(notify_list):
         if notify.get('ContractAddress', '') == self._contract_address:
             notify_list[index] = NeoData.parse_addr_addr_int_notify(
                 notify_list[index])
     return notify_list