File tree 3 files changed +140
-298
lines changed
3 files changed +140
-298
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " polkadot-rpc-proxy" ,
3
- "version" : " 0.1.3 " ,
3
+ "version" : " 0.1.4 " ,
4
4
"description" : " " ,
5
5
"main" : " index.js" ,
6
6
"scripts" : {
11
11
"author" : " " ,
12
12
"license" : " GPL-3.0-or-later" ,
13
13
"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" ,
18
18
"@types/express" : " ^4.17.2" ,
19
19
"express" : " ^4.17.1" ,
20
20
"typescript" : " ^3.7.4"
Original file line number Diff line number Diff line change @@ -157,17 +157,22 @@ export default class ApiHandler {
157
157
async ensureMeta ( hash : BlockHash ) {
158
158
const { api } = this ;
159
159
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 ;
162
163
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 ( ) ;
168
169
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 ) ;
171
176
}
172
177
}
173
178
}
You can’t perform that action at this time.
0 commit comments