Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update polkadot 9 #1234

Merged
merged 2 commits into from
Aug 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"typescript": "^4.4.4"
},
"resolutions": {
"@polkadot/api": "8.12.2",
"@polkadot/util": "10.0.2",
"@polkadot/api": "9.1.1",
"@polkadot/util": "10.1.3",
"@terra-money/terra.js": "^3.0.11",
"node-fetch": "2.6.7"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"@nestjs/event-emitter": "^1.3.0",
"@nestjs/platform-express": "^8.2.6",
"@nestjs/schedule": "^1.0.2",
"@polkadot/api": "8.12.2",
"@polkadot/api": "9.1.1",
"@subql/common": "workspace:*",
"@subql/common-substrate": "workspace:*",
"@subql/types": "workspace:*",
Expand Down
1 change: 1 addition & 0 deletions packages/node/src/indexer/api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export class ApiService implements OnApplicationShutdown {
this.apiOption = {
provider,
throwOnConnect,
noInitWarn: true,
...chainTypes,
};
this.api = await ApiPromise.create(this.apiOption);
Expand Down
12 changes: 1 addition & 11 deletions packages/node/src/utils/substrate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

import { ApiPromise, WsProvider } from '@polkadot/api';
import { fetchBlocks, fetchBlocksViaRangeQuery } from './substrate';
import { fetchBlocks } from './substrate';

const endpoint = 'wss://polkadot.api.onfinality.io/public-ws';

Expand Down Expand Up @@ -35,14 +35,4 @@ describe('substrate utils', () => {
/Unable to retrieve header and parent from supplied hash/,
);
});

it.skip('query range of blocks via range query', async () => {
const blocks = await fetchBlocksViaRangeQuery(api, 100000, 100019);
expect(blocks).toHaveLength(20);
for (const block of blocks) {
expect(block).toHaveProperty('block');
expect(block).toHaveProperty('extrinsics');
expect(block).toHaveProperty('events');
}
});
});
36 changes: 0 additions & 36 deletions packages/node/src/utils/substrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,42 +252,6 @@ export async function fetchBlocks(
});
}

export async function fetchBlocksViaRangeQuery(
api: ApiPromise,
startHeight: number,
endHeight: number,
): Promise<BlockContent[]> {
const blocks = await fetchBlocksRange(api, startHeight, endHeight);
const firstBlockHash = blocks[0].block.header.hash;
const endBlockHash = last(blocks).block.header.hash;
const [blockEvents, runtimeUpgrades] = await Promise.all([
api.query.system.events.range([firstBlockHash, endBlockHash]),
api.query.system.lastRuntimeUpgrade.range([firstBlockHash, endBlockHash]),
]);

let lastEvents: Vec<EventRecord>;
let lastRuntimeUpgrade: Option<LastRuntimeUpgradeInfo>;
return blocks.map((block, idx) => {
const [, events = lastEvents] = blockEvents[idx] ?? [];
const [, runtimeUpgrade = lastRuntimeUpgrade] = runtimeUpgrades[idx] ?? [];
lastEvents = events;
lastRuntimeUpgrade = runtimeUpgrade;

const wrappedBlock = wrapBlock(
block,
events,
runtimeUpgrade.unwrap()?.specVersion.toNumber(),
);
const wrappedExtrinsics = wrapExtrinsics(wrappedBlock, events);
const wrappedEvents = wrapEvents(wrappedExtrinsics, events, wrappedBlock);
return {
block: wrappedBlock,
extrinsics: wrappedExtrinsics,
events: wrappedEvents,
};
});
}

async function getBlockByHeight(
api: ApiPromise,
height: number,
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"main": "dist/index.js",
"license": "Apache-2.0",
"dependencies": {
"@polkadot/util": "^9",
"@polkadot/util": "^10",
"ansi-styles": "^6.1.0",
"axios": "^0.27.1",
"chalk": "^4.1.2",
Expand Down
Loading