@polkadot/rpc-core 6.6.2-9 → 6.7.3-0
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 +41 -52
- package/bundle.d.ts +1 -3
- package/bundle.js +30 -38
- 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
|
@@ -17,8 +17,6 @@ Object.defineProperty(exports, "packageInfo", {
|
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
19
|
|
|
20
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
21
|
-
|
|
22
20
|
var _classPrivateFieldLooseBase2 = _interopRequireDefault(require("@babel/runtime/helpers/classPrivateFieldLooseBase"));
|
|
23
21
|
|
|
24
22
|
var _classPrivateFieldLooseKey2 = _interopRequireDefault(require("@babel/runtime/helpers/classPrivateFieldLooseKey"));
|
|
@@ -45,10 +43,8 @@ Object.keys(_index).forEach(function (key) {
|
|
|
45
43
|
|
|
46
44
|
var _packageInfo = require("./packageInfo.cjs");
|
|
47
45
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
51
|
-
|
|
46
|
+
// Copyright 2017-2021 @polkadot/rpc-core authors & contributors
|
|
47
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
52
48
|
const l = (0, _util.logger)('rpc-core');
|
|
53
49
|
const EMPTY_META = {
|
|
54
50
|
fallback: undefined,
|
|
@@ -196,42 +192,35 @@ class RpcCore {
|
|
|
196
192
|
|
|
197
193
|
addUserInterfaces(userRpc) {
|
|
198
194
|
// add any extra user-defined sections
|
|
199
|
-
this.sections.push(...Object.keys(userRpc).filter(
|
|
200
|
-
|
|
201
|
-
this.sections.
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
jsonrpc,
|
|
229
|
-
method,
|
|
230
|
-
section
|
|
231
|
-
}));
|
|
232
|
-
exposed[method] = isSubscription ? this._createMethodSubscribe(section, method, def) : this._createMethodSend(section, method, def);
|
|
233
|
-
return exposed;
|
|
234
|
-
}, {});
|
|
195
|
+
this.sections.push(...Object.keys(userRpc).filter(k => !this.sections.includes(k)));
|
|
196
|
+
|
|
197
|
+
for (let s = 0; s < this.sections.length; s++) {
|
|
198
|
+
const section = this.sections[s];
|
|
199
|
+
const defs = (0, _util.objectSpread)({}, _types.rpcDefinitions[section], userRpc[section]);
|
|
200
|
+
const methods = Object.keys(defs);
|
|
201
|
+
|
|
202
|
+
for (let m = 0; m < methods.length; m++) {
|
|
203
|
+
const method = methods[m];
|
|
204
|
+
const def = defs[method];
|
|
205
|
+
const jsonrpc = def.endpoint || `${section}_${method}`;
|
|
206
|
+
|
|
207
|
+
if (!this.mapping.has(jsonrpc)) {
|
|
208
|
+
const isSubscription = !!def.pubsub;
|
|
209
|
+
|
|
210
|
+
if (!this[section]) {
|
|
211
|
+
this[section] = {};
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
this.mapping.set(jsonrpc, (0, _util.objectSpread)({}, def, {
|
|
215
|
+
isSubscription,
|
|
216
|
+
jsonrpc,
|
|
217
|
+
method,
|
|
218
|
+
section
|
|
219
|
+
}));
|
|
220
|
+
(0, _util.lazyMethod)(this[section], method, () => isSubscription ? this._createMethodSubscribe(section, method, def) : this._createMethodSend(section, method, def));
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
235
224
|
}
|
|
236
225
|
|
|
237
226
|
_memomize(creator, def) {
|
|
@@ -250,10 +239,10 @@ class RpcCore {
|
|
|
250
239
|
|
|
251
240
|
_createMethodSend(section, method, def) {
|
|
252
241
|
const rpcName = def.endpoint || `${section}_${method}`;
|
|
253
|
-
const hashIndex = def.params.findIndex(
|
|
242
|
+
const hashIndex = def.params.findIndex(_ref3 => {
|
|
254
243
|
let {
|
|
255
244
|
isHistoric
|
|
256
|
-
} =
|
|
245
|
+
} = _ref3;
|
|
257
246
|
return isHistoric;
|
|
258
247
|
});
|
|
259
248
|
let memoized = null; // execute the RPC call, doing a registry swap for historic as applicable
|
|
@@ -303,13 +292,13 @@ class RpcCore {
|
|
|
303
292
|
} // create a subscriptor, it subscribes once and resolves with the id as subscribe
|
|
304
293
|
|
|
305
294
|
|
|
306
|
-
_createSubscriber(
|
|
295
|
+
_createSubscriber(_ref4, errorHandler) {
|
|
307
296
|
let {
|
|
308
297
|
paramsJson,
|
|
309
298
|
subName,
|
|
310
299
|
subType,
|
|
311
300
|
update
|
|
312
|
-
} =
|
|
301
|
+
} = _ref4;
|
|
313
302
|
return new Promise((resolve, reject) => {
|
|
314
303
|
this.provider.subscribe(subType, subName, paramsJson, update).then(resolve).catch(error => {
|
|
315
304
|
errorHandler(error);
|
|
@@ -388,10 +377,10 @@ class RpcCore {
|
|
|
388
377
|
}
|
|
389
378
|
|
|
390
379
|
_formatInputs(registry, blockHash, def, inputs) {
|
|
391
|
-
const reqArgCount = def.params.filter(
|
|
380
|
+
const reqArgCount = def.params.filter(_ref5 => {
|
|
392
381
|
let {
|
|
393
382
|
isOptional
|
|
394
|
-
} =
|
|
383
|
+
} = _ref5;
|
|
395
384
|
return !isOptional;
|
|
396
385
|
}).length;
|
|
397
386
|
const optText = reqArgCount === def.params.length ? '' : ` (${def.params.length - reqArgCount} optional)`;
|
|
@@ -409,11 +398,11 @@ class RpcCore {
|
|
|
409
398
|
const keys = params[0];
|
|
410
399
|
return keys ? this._formatStorageSet(registry, result.block, keys, result.changes) : registry.createType('StorageChangeSet', result);
|
|
411
400
|
} else if (rpc.type === 'Vec<StorageChangeSet>') {
|
|
412
|
-
const mapped = result.map(
|
|
401
|
+
const mapped = result.map(_ref6 => {
|
|
413
402
|
let {
|
|
414
403
|
block,
|
|
415
404
|
changes
|
|
416
|
-
} =
|
|
405
|
+
} = _ref6;
|
|
417
406
|
return [registry.createType('Hash', block), this._formatStorageSet(registry, block, params[0], changes)];
|
|
418
407
|
}); // we only query at a specific block, not a range - flatten
|
|
419
408
|
|
|
@@ -448,8 +437,8 @@ class RpcCore {
|
|
|
448
437
|
|
|
449
438
|
_formatStorageSetEntry(registry, blockHash, key, changes, witCache, entryIndex) {
|
|
450
439
|
const hexKey = key.toHex();
|
|
451
|
-
const found = changes.find(
|
|
452
|
-
let [key] =
|
|
440
|
+
const found = changes.find(_ref7 => {
|
|
441
|
+
let [key] = _ref7;
|
|
453
442
|
return key === hexKey;
|
|
454
443
|
}); // if we don't find the value, this is our fallback
|
|
455
444
|
// - 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
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
1
|
import _classPrivateFieldLooseBase from "@babel/runtime/helpers/esm/classPrivateFieldLooseBase";
|
|
3
2
|
import _classPrivateFieldLooseKey from "@babel/runtime/helpers/esm/classPrivateFieldLooseKey";
|
|
4
|
-
|
|
5
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
6
|
-
|
|
7
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
8
|
-
|
|
9
3
|
// Copyright 2017-2021 @polkadot/rpc-core authors & contributors
|
|
10
4
|
// SPDX-License-Identifier: Apache-2.0
|
|
11
5
|
import { Observable, publishReplay, refCount } from 'rxjs';
|
|
12
6
|
import { rpcDefinitions } from '@polkadot/types';
|
|
13
|
-
import { assert, hexToU8a, isFunction, isNull, isUndefined, logger, memoize, u8aToU8a } from '@polkadot/util';
|
|
7
|
+
import { assert, hexToU8a, isFunction, isNull, isUndefined, lazyMethod, logger, memoize, objectSpread, u8aToU8a } from '@polkadot/util';
|
|
14
8
|
import { drr, refCountDelay } from "./util/index.js";
|
|
15
9
|
export { packageInfo } from "./packageInfo.js";
|
|
16
10
|
export * from "./util/index.js";
|
|
@@ -156,37 +150,35 @@ export class RpcCore {
|
|
|
156
150
|
|
|
157
151
|
addUserInterfaces(userRpc) {
|
|
158
152
|
// add any extra user-defined sections
|
|
159
|
-
this.sections.push(...Object.keys(userRpc).filter(
|
|
160
|
-
|
|
161
|
-
this.sections.
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
return exposed;
|
|
189
|
-
}, {});
|
|
153
|
+
this.sections.push(...Object.keys(userRpc).filter(k => !this.sections.includes(k)));
|
|
154
|
+
|
|
155
|
+
for (let s = 0; s < this.sections.length; s++) {
|
|
156
|
+
const section = this.sections[s];
|
|
157
|
+
const defs = objectSpread({}, rpcDefinitions[section], userRpc[section]);
|
|
158
|
+
const methods = Object.keys(defs);
|
|
159
|
+
|
|
160
|
+
for (let m = 0; m < methods.length; m++) {
|
|
161
|
+
const method = methods[m];
|
|
162
|
+
const def = defs[method];
|
|
163
|
+
const jsonrpc = def.endpoint || `${section}_${method}`;
|
|
164
|
+
|
|
165
|
+
if (!this.mapping.has(jsonrpc)) {
|
|
166
|
+
const isSubscription = !!def.pubsub;
|
|
167
|
+
|
|
168
|
+
if (!this[section]) {
|
|
169
|
+
this[section] = {};
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
this.mapping.set(jsonrpc, objectSpread({}, def, {
|
|
173
|
+
isSubscription,
|
|
174
|
+
jsonrpc,
|
|
175
|
+
method,
|
|
176
|
+
section
|
|
177
|
+
}));
|
|
178
|
+
lazyMethod(this[section], method, () => isSubscription ? this._createMethodSubscribe(section, method, def) : this._createMethodSend(section, method, def));
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
190
182
|
}
|
|
191
183
|
|
|
192
184
|
_memomize(creator, def) {
|
package/package.json
CHANGED
|
@@ -20,17 +20,17 @@
|
|
|
20
20
|
"./detectPackage.cjs"
|
|
21
21
|
],
|
|
22
22
|
"type": "module",
|
|
23
|
-
"version": "6.
|
|
23
|
+
"version": "6.7.3-0",
|
|
24
24
|
"main": "index.js",
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@babel/runtime": "^7.16.0",
|
|
27
|
-
"@polkadot/rpc-provider": "6.
|
|
28
|
-
"@polkadot/types": "6.
|
|
29
|
-
"@polkadot/util": "^7.
|
|
27
|
+
"@polkadot/rpc-provider": "6.7.3-0",
|
|
28
|
+
"@polkadot/types": "6.7.3-0",
|
|
29
|
+
"@polkadot/util": "^7.8.2",
|
|
30
30
|
"rxjs": "^7.4.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@polkadot/keyring": "^7.
|
|
33
|
+
"@polkadot/keyring": "^7.8.2"
|
|
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
|
};
|