Skip to content

Commit

Permalink
fix: ignore extrinsicIndex in multiBlockMigrations event (#1541)
Browse files Browse the repository at this point in the history
  • Loading branch information
Imod7 authored Nov 10, 2024
1 parent 7f161d5 commit 45c4b1f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/services/blocks/BlocksService.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ describe('BlocksService', () => {
});

it('throws when an extrinsic is undefined', async () => {
// Create a block with undefined as the first extrinisic and the last extrinsic removed
// Create a block with undefined as the first extrinsic and the last extrinsic removed
const mockBlock789629BadExt = polkadotRegistry.createType('Block', block789629);

mockBlock789629BadExt.extrinsics.pop();
Expand Down Expand Up @@ -377,7 +377,7 @@ describe('BlocksService', () => {
paraId: undefined,
};

it('Returns the correct extrinisics object for block 789629', async () => {
it('Returns the correct extrinsics object for block 789629', async () => {
const block = await blocksService.fetchBlock(blockHash789629, mockHistoricApi, options);

/**
Expand Down
10 changes: 6 additions & 4 deletions src/services/blocks/BlocksService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ export class BlocksService extends AbstractService {

/**
* Retrieve the blockHash for the previous block to the one getting queried.
* If the block is the geneisis hash it will return the same blockHash.
* If the block is the genesis hash it will return the same blockHash.
*
* @param blockNumber The blockId being queried
*/
Expand Down Expand Up @@ -590,7 +590,7 @@ export class BlocksService extends AbstractService {
const extrinsicIdx = phase.asApplyExtrinsic.toNumber();
const extrinsic = extrinsics[extrinsicIdx];

if (!extrinsic) {
if (!extrinsic && event.section != 'multiBlockMigrations') {
throw new Error(`Missing extrinsic ${extrinsicIdx} in block ${hash.toString()}`);
}

Expand All @@ -610,7 +610,9 @@ export class BlocksService extends AbstractService {
}
}

extrinsic.events.push(sanitizedEvent);
if (extrinsic) {
extrinsic.events.push(sanitizedEvent);
}
} else if (phase.isFinalization) {
onFinalize.events.push(sanitizedEvent);
} else if (phase.isInitialization) {
Expand Down Expand Up @@ -789,7 +791,7 @@ export class BlocksService extends AbstractService {
}

/**
* Fetch a block with raw extrinics values.
* Fetch a block with raw extrinsics values.
*
* @param hash `BlockHash` of the block to fetch.
*/
Expand Down

0 comments on commit 45c4b1f

Please sign in to comment.