Skip to content

Commit

Permalink
ignore migration events while parsing calls
Browse files Browse the repository at this point in the history
  • Loading branch information
tmcgroul committed Jul 23, 2024
1 parent b87ffb6 commit c768fcd
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@subsquid/substrate-data",
"comment": "ignore events from `Migrations` pallet while parsing calls",
"type": "patch"
}
],
"packageName": "@subsquid/substrate-data"
}
19 changes: 19 additions & 0 deletions substrate/substrate-data/src/parsing/call/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,14 @@ export class CallParser {
while (this.eventPos >= 0) {
let event = this.events[this.eventPos]
if (event.phase === 'ApplyExtrinsic') {
if (event.name.startsWith('Migrations.')) {
let index = assertNotNull(event.extrinsicIndex)
let ex = this.extrinsics[index]
assert(ex == null, 'extrinsic for a migration event is unexpected')
this.skipExtrinsicEvents(index)
continue
}

if (event.extrinsicIndex !== this.extrinsic.index) return
this.eventPos -= 1
return event
Expand All @@ -334,4 +342,15 @@ export class CallParser {
}
}
}

private skipExtrinsicEvents(extrinsicIndex: number) {
while (true) {
let event = this.events[this.eventPos]
if (event.extrinsicIndex == extrinsicIndex) {
this.eventPos -= 1
} else {
break
}
}
}
}

0 comments on commit c768fcd

Please sign in to comment.