polkascan / py-substrate-interface

Python Substrate Interface
https://polkascan.github.io/py-substrate-interface/
Apache License 2.0
240 stars 114 forks source link

Events not correctly fetched in receipt #194

Closed johnuopini closed 2 years ago

johnuopini commented 2 years ago

I am trying to get events in this extrinsic: https://moonbeam.subscan.io/extrinsic/413415-0

I do this by using: substrate.retrieve_extrinsic_by_identifier("413415-0")

Problem is that result has just one event and not hundreds like the one in Subscan. Is this a library limitation?

arjanz commented 2 years ago

No on the contrary, Subscan is showing incorrect results.. As you can see in PolkadotJS/apps, which is showing pure on-chain data, the extrinsic should only have triggered one event directly.

The other events seem to be triggered by other extrinsics in the same block or are system events.

Trust but verify :)

johnuopini commented 2 years ago

You are right, those are not related to the extrinsic but to the block itself, JS lists them inside the "System events" for the block, does the library support fetching system events?

johnuopini commented 2 years ago

Sorry just found a storage query System.events() that accepts an hash, will use that, closing this!

arjanz commented 2 years ago

You can retrieve all the events for a block with:

events = substrate.get_events(block_hash="0x88f5fb3ff6384c127d16408dcfad626fe63081a856c303bf3423b5421a2ced65")

johnuopini commented 2 years ago

Found that, great stuff!!!