Created
May 30, 2022 14:36
-
-
Save yornaath/ba5eedc4d1ca82654e117f459efba6de to your computer and use it in GitHub Desktop.
Substrate/Polkadot.js - get extrinsics at event
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const extrinsicsAtEvent = ( | |
events: Vec<EventRecord>, | |
block: SignedBlock, | |
filter?: { | |
method?: string; | |
} | |
) => { | |
return block.block.extrinsics.filter((ex, index) => | |
Boolean( | |
events.find( | |
(event) => | |
event.phase.isApplyExtrinsic && | |
event.phase.asApplyExtrinsic.eq(index) && | |
(!filter?.method || ex.method.method.toString() === filter.method) | |
) | |
) | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment