Skip to content

Commit

Permalink
ignore migration events while parsing calls (#319)
Browse files Browse the repository at this point in the history
* ignore migration events while parsing calls

* add comment
  • Loading branch information
tmcgroul committed Jul 24, 2024
1 parent a664d3a commit cbae638
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
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"
}
24 changes: 23 additions & 1 deletion substrate/substrate-data/src/parsing/call/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,12 +326,34 @@ export class CallParser {
while (this.eventPos >= 0) {
let event = this.events[this.eventPos]
if (event.phase === 'ApplyExtrinsic') {
if (event.extrinsicIndex !== this.extrinsic.index) return
if (event.extrinsicIndex !== this.extrinsic.index) {
if (event.name.startsWith('Migrations.')) {
let index = assertNotNull(event.extrinsicIndex)
// Besides `Migrations.*` events there can be more parachain-defined events,
// so we skip all events related to the "phantom" extrinsic.
this.skipExtrinsicEvents(index)
continue
} else {
return
}
}

this.eventPos -= 1
return event
} else {
this.eventPos -= 1
}
}
}

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 cbae638

Please sign in to comment.