@polkadot/rpc-core 6.6.2-11 → 6.6.2-15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundle.cjs +39 -48
- package/bundle.d.ts +1 -3
- package/bundle.js +30 -34
- package/package.json +5 -5
- package/packageInfo.cjs +1 -1
- package/packageInfo.js +1 -1
- package/types.jsonrpc.d.ts +2 -1
package/bundle.cjs
CHANGED
|
@@ -201,44 +201,35 @@ class RpcCore {
|
|
|
201
201
|
|
|
202
202
|
addUserInterfaces(userRpc) {
|
|
203
203
|
// add any extra user-defined sections
|
|
204
|
-
this.sections.push(...Object.keys(userRpc).filter(
|
|
205
|
-
|
|
206
|
-
this.sections.
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
this.mapping.set(jsonrpc, { ...def,
|
|
234
|
-
isSubscription,
|
|
235
|
-
jsonrpc,
|
|
236
|
-
method,
|
|
237
|
-
section
|
|
238
|
-
});
|
|
239
|
-
exposed[method] = isSubscription ? this._createMethodSubscribe(section, method, def) : this._createMethodSend(section, method, def);
|
|
240
|
-
return exposed;
|
|
241
|
-
}, {});
|
|
204
|
+
this.sections.push(...Object.keys(userRpc).filter(k => !this.sections.includes(k)));
|
|
205
|
+
|
|
206
|
+
for (let s = 0; s < this.sections.length; s++) {
|
|
207
|
+
const section = this.sections[s];
|
|
208
|
+
const defs = (0, _util.objectSpread)({}, _types.rpcDefinitions[section], userRpc[section]);
|
|
209
|
+
const methods = Object.keys(defs);
|
|
210
|
+
|
|
211
|
+
for (let m = 0; m < methods.length; m++) {
|
|
212
|
+
const method = methods[m];
|
|
213
|
+
const def = defs[method];
|
|
214
|
+
const jsonrpc = def.endpoint || `${section}_${method}`;
|
|
215
|
+
|
|
216
|
+
if (!this.mapping.has(jsonrpc)) {
|
|
217
|
+
const isSubscription = !!def.pubsub;
|
|
218
|
+
|
|
219
|
+
if (!this[section]) {
|
|
220
|
+
this[section] = {};
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
this.mapping.set(jsonrpc, (0, _util.objectSpread)({}, def, {
|
|
224
|
+
isSubscription,
|
|
225
|
+
jsonrpc,
|
|
226
|
+
method,
|
|
227
|
+
section
|
|
228
|
+
}));
|
|
229
|
+
(0, _util.lazyMethod)(this[section], method, () => isSubscription ? this._createMethodSubscribe(section, method, def) : this._createMethodSend(section, method, def));
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
242
233
|
}
|
|
243
234
|
|
|
244
235
|
_memomize(creator, def) {
|
|
@@ -257,10 +248,10 @@ class RpcCore {
|
|
|
257
248
|
|
|
258
249
|
_createMethodSend(section, method, def) {
|
|
259
250
|
const rpcName = def.endpoint || `${section}_${method}`;
|
|
260
|
-
const hashIndex = def.params.findIndex(
|
|
251
|
+
const hashIndex = def.params.findIndex(_ref3 => {
|
|
261
252
|
let {
|
|
262
253
|
isHistoric
|
|
263
|
-
} =
|
|
254
|
+
} = _ref3;
|
|
264
255
|
return isHistoric;
|
|
265
256
|
});
|
|
266
257
|
let memoized = null; // execute the RPC call, doing a registry swap for historic as applicable
|
|
@@ -310,13 +301,13 @@ class RpcCore {
|
|
|
310
301
|
} // create a subscriptor, it subscribes once and resolves with the id as subscribe
|
|
311
302
|
|
|
312
303
|
|
|
313
|
-
_createSubscriber(
|
|
304
|
+
_createSubscriber(_ref4, errorHandler) {
|
|
314
305
|
let {
|
|
315
306
|
paramsJson,
|
|
316
307
|
subName,
|
|
317
308
|
subType,
|
|
318
309
|
update
|
|
319
|
-
} =
|
|
310
|
+
} = _ref4;
|
|
320
311
|
return new Promise((resolve, reject) => {
|
|
321
312
|
this.provider.subscribe(subType, subName, paramsJson, update).then(resolve).catch(error => {
|
|
322
313
|
errorHandler(error);
|
|
@@ -394,10 +385,10 @@ class RpcCore {
|
|
|
394
385
|
}
|
|
395
386
|
|
|
396
387
|
_formatInputs(registry, blockHash, def, inputs) {
|
|
397
|
-
const reqArgCount = def.params.filter(
|
|
388
|
+
const reqArgCount = def.params.filter(_ref5 => {
|
|
398
389
|
let {
|
|
399
390
|
isOptional
|
|
400
|
-
} =
|
|
391
|
+
} = _ref5;
|
|
401
392
|
return !isOptional;
|
|
402
393
|
}).length;
|
|
403
394
|
const optText = reqArgCount === def.params.length ? '' : ` (${def.params.length - reqArgCount} optional)`;
|
|
@@ -415,11 +406,11 @@ class RpcCore {
|
|
|
415
406
|
const keys = params[0];
|
|
416
407
|
return keys ? this._formatStorageSet(registry, result.block, keys, result.changes) : registry.createType('StorageChangeSet', result);
|
|
417
408
|
} else if (rpc.type === 'Vec<StorageChangeSet>') {
|
|
418
|
-
const mapped = result.map(
|
|
409
|
+
const mapped = result.map(_ref6 => {
|
|
419
410
|
let {
|
|
420
411
|
block,
|
|
421
412
|
changes
|
|
422
|
-
} =
|
|
413
|
+
} = _ref6;
|
|
423
414
|
return [registry.createType('Hash', block), this._formatStorageSet(registry, block, params[0], changes)];
|
|
424
415
|
}); // we only query at a specific block, not a range - flatten
|
|
425
416
|
|
|
@@ -454,8 +445,8 @@ class RpcCore {
|
|
|
454
445
|
|
|
455
446
|
_formatStorageSetEntry(registry, blockHash, key, changes, witCache, entryIndex) {
|
|
456
447
|
const hexKey = key.toHex();
|
|
457
|
-
const found = changes.find(
|
|
458
|
-
let [key] =
|
|
448
|
+
const found = changes.find(_ref7 => {
|
|
449
|
+
let [key] = _ref7;
|
|
459
450
|
return key === hexKey;
|
|
460
451
|
}); // if we don't find the value, this is our fallback
|
|
461
452
|
// - in the case of an array of values, fill the hole from the cache
|
package/bundle.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { ProviderInterface } from '@polkadot/rpc-provider/types';
|
|
2
2
|
import type { DefinitionRpc, DefinitionRpcExt, DefinitionRpcSub, Registry } from '@polkadot/types/types';
|
|
3
|
-
import type { RpcInterface } from './types';
|
|
4
3
|
export { packageInfo } from './packageInfo';
|
|
5
4
|
export * from './util';
|
|
6
5
|
/**
|
|
@@ -55,8 +54,7 @@ export declare class RpcCore {
|
|
|
55
54
|
setRegistrySwap(registrySwap: (blockHash: Uint8Array) => Promise<{
|
|
56
55
|
registry: Registry;
|
|
57
56
|
}>): void;
|
|
58
|
-
addUserInterfaces
|
|
59
|
-
private _createInterface;
|
|
57
|
+
addUserInterfaces(userRpc: Record<string, Record<string, DefinitionRpc | DefinitionRpcSub>>): void;
|
|
60
58
|
private _memomize;
|
|
61
59
|
private _formatResult;
|
|
62
60
|
private _createMethodSend;
|
package/bundle.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
import { Observable, publishReplay, refCount } from 'rxjs';
|
|
4
4
|
import { rpcDefinitions } from '@polkadot/types';
|
|
5
|
-
import { assert, hexToU8a, isFunction, isNull, isUndefined, logger, memoize, u8aToU8a } from '@polkadot/util';
|
|
5
|
+
import { assert, hexToU8a, isFunction, isNull, isUndefined, lazyMethod, logger, memoize, objectSpread, u8aToU8a } from '@polkadot/util';
|
|
6
6
|
import { drr, refCountDelay } from "./util/index.js";
|
|
7
7
|
export { packageInfo } from "./packageInfo.js";
|
|
8
8
|
export * from "./util/index.js";
|
|
@@ -128,39 +128,35 @@ export class RpcCore {
|
|
|
128
128
|
|
|
129
129
|
addUserInterfaces(userRpc) {
|
|
130
130
|
// add any extra user-defined sections
|
|
131
|
-
this.sections.push(...Object.keys(userRpc).filter(
|
|
132
|
-
|
|
133
|
-
this.sections.
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
});
|
|
161
|
-
exposed[method] = isSubscription ? this._createMethodSubscribe(section, method, def) : this._createMethodSend(section, method, def);
|
|
162
|
-
return exposed;
|
|
163
|
-
}, {});
|
|
131
|
+
this.sections.push(...Object.keys(userRpc).filter(k => !this.sections.includes(k)));
|
|
132
|
+
|
|
133
|
+
for (let s = 0; s < this.sections.length; s++) {
|
|
134
|
+
const section = this.sections[s];
|
|
135
|
+
const defs = objectSpread({}, rpcDefinitions[section], userRpc[section]);
|
|
136
|
+
const methods = Object.keys(defs);
|
|
137
|
+
|
|
138
|
+
for (let m = 0; m < methods.length; m++) {
|
|
139
|
+
const method = methods[m];
|
|
140
|
+
const def = defs[method];
|
|
141
|
+
const jsonrpc = def.endpoint || `${section}_${method}`;
|
|
142
|
+
|
|
143
|
+
if (!this.mapping.has(jsonrpc)) {
|
|
144
|
+
const isSubscription = !!def.pubsub;
|
|
145
|
+
|
|
146
|
+
if (!this[section]) {
|
|
147
|
+
this[section] = {};
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
this.mapping.set(jsonrpc, objectSpread({}, def, {
|
|
151
|
+
isSubscription,
|
|
152
|
+
jsonrpc,
|
|
153
|
+
method,
|
|
154
|
+
section
|
|
155
|
+
}));
|
|
156
|
+
lazyMethod(this[section], method, () => isSubscription ? this._createMethodSubscribe(section, method, def) : this._createMethodSend(section, method, def));
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
164
160
|
}
|
|
165
161
|
|
|
166
162
|
_memomize(creator, def) {
|
package/package.json
CHANGED
|
@@ -20,17 +20,17 @@
|
|
|
20
20
|
"./detectPackage.cjs"
|
|
21
21
|
],
|
|
22
22
|
"type": "module",
|
|
23
|
-
"version": "6.6.2-
|
|
23
|
+
"version": "6.6.2-15",
|
|
24
24
|
"main": "index.js",
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@babel/runtime": "^7.16.0",
|
|
27
|
-
"@polkadot/rpc-provider": "6.6.2-
|
|
28
|
-
"@polkadot/types": "6.6.2-
|
|
29
|
-
"@polkadot/util": "^7.7.2-
|
|
27
|
+
"@polkadot/rpc-provider": "6.6.2-15",
|
|
28
|
+
"@polkadot/types": "6.6.2-15",
|
|
29
|
+
"@polkadot/util": "^7.7.2-6",
|
|
30
30
|
"rxjs": "^7.4.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@polkadot/keyring": "^7.7.2-
|
|
33
|
+
"@polkadot/keyring": "^7.7.2-6"
|
|
34
34
|
},
|
|
35
35
|
"exports": {
|
|
36
36
|
".": {
|
package/packageInfo.cjs
CHANGED
package/packageInfo.js
CHANGED
package/types.jsonrpc.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { Observable } from 'rxjs';
|
|
2
|
-
import type { AnyFunction } from '@polkadot/types/types';
|
|
2
|
+
import type { AnyFunction, DefinitionRpc } from '@polkadot/types/types';
|
|
3
3
|
export interface RpcInterface {
|
|
4
4
|
}
|
|
5
5
|
export declare type AugmentedRpc<F extends AnyFunction> = F & {
|
|
6
6
|
raw: <T>(...params: Parameters<F>) => Observable<T>;
|
|
7
|
+
meta: DefinitionRpc;
|
|
7
8
|
};
|