Skip to content

Commit 53d1ec5

Browse files
authored
Merge pull request #12 from paritytech/mh-block-error
Temporary fix for block 461694
2 parents 9a70ca2 + b7c1760 commit 53d1ec5

File tree

3 files changed

+140
-298
lines changed

3 files changed

+140
-298
lines changed

package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "polkadot-rpc-proxy",
3-
"version": "0.1.3",
3+
"version": "0.1.4",
44
"description": "",
55
"main": "index.js",
66
"scripts": {
@@ -11,10 +11,10 @@
1111
"author": "",
1212
"license": "GPL-3.0-or-later",
1313
"dependencies": {
14-
"@polkadot/api": "^1.1.1",
15-
"@polkadot/metadata": "^1.1.1",
16-
"@polkadot/rpc-provider": "^1.1.1",
17-
"@polkadot/types": "^1.1.1",
14+
"@polkadot/api": "^1.3.1",
15+
"@polkadot/metadata": "^1.3.1",
16+
"@polkadot/rpc-provider": "^1.3.1",
17+
"@polkadot/types": "^1.3.1",
1818
"@types/express": "^4.17.2",
1919
"express": "^4.17.1",
2020
"typescript": "^3.7.4"

src/ApiHandler.ts

+14-9
Original file line numberDiff line numberDiff line change
@@ -157,17 +157,22 @@ export default class ApiHandler {
157157
async ensureMeta(hash: BlockHash) {
158158
const { api } = this;
159159

160-
const runtimeVersion = await api.rpc.state.getRuntimeVersion(hash);
161-
const blockSpecVersion = runtimeVersion.specVersion;
160+
try {
161+
const runtimeVersion = await api.rpc.state.getRuntimeVersion(hash);
162+
const blockSpecVersion = runtimeVersion.specVersion;
162163

163-
// swap metadata if spec version is different
164-
if (!this.specVersion.eq(blockSpecVersion)) {
165-
this.specVersion = blockSpecVersion;
166-
const meta = await api.rpc.state.getMetadata(hash);
167-
const chain = await api.rpc.system.chain();
164+
// swap metadata if spec version is different
165+
if (!this.specVersion.eq(blockSpecVersion)) {
166+
this.specVersion = blockSpecVersion;
167+
const meta = await api.rpc.state.getMetadata(hash);
168+
const chain = await api.rpc.system.chain();
168169

169-
api.registry.register(getChainTypes(chain, runtimeVersion));
170-
api.registry.setMetadata(meta);
170+
api.registry.register(getChainTypes(chain, runtimeVersion));
171+
api.registry.setMetadata(meta);
172+
}
173+
} catch (err) {
174+
console.error(`Failed to get Metadata for block ${hash}, using latest.`);
175+
console.error(err);
171176
}
172177
}
173178
}

0 commit comments

Comments
 (0)