@polkadot/rpc-core 6.6.2-26 → 6.6.2-27
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 +28 -35
- package/bundle.js +41 -17
- package/package.json +5 -5
- package/packageInfo.cjs +1 -1
- package/packageInfo.js +1 -1
package/bundle.cjs
CHANGED
|
@@ -17,11 +17,9 @@ Object.defineProperty(exports, "packageInfo", {
|
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
19
|
|
|
20
|
-
var
|
|
20
|
+
var _classPrivateFieldLooseBase2 = _interopRequireDefault(require("@babel/runtime/helpers/classPrivateFieldLooseBase"));
|
|
21
21
|
|
|
22
|
-
var
|
|
23
|
-
|
|
24
|
-
var _classPrivateFieldSet2 = _interopRequireDefault(require("@babel/runtime/helpers/classPrivateFieldSet"));
|
|
22
|
+
var _classPrivateFieldLooseKey2 = _interopRequireDefault(require("@babel/runtime/helpers/classPrivateFieldLooseKey"));
|
|
25
23
|
|
|
26
24
|
var _rxjs = require("rxjs");
|
|
27
25
|
|
|
@@ -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 _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
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,
|
|
@@ -113,13 +109,13 @@ function isTreatAsHex(key) {
|
|
|
113
109
|
*/
|
|
114
110
|
|
|
115
111
|
|
|
116
|
-
var _instanceId = /*#__PURE__*/
|
|
112
|
+
var _instanceId = /*#__PURE__*/(0, _classPrivateFieldLooseKey2.default)("instanceId");
|
|
117
113
|
|
|
118
|
-
var _registryDefault = /*#__PURE__*/
|
|
114
|
+
var _registryDefault = /*#__PURE__*/(0, _classPrivateFieldLooseKey2.default)("registryDefault");
|
|
119
115
|
|
|
120
|
-
var _getBlockRegistry = /*#__PURE__*/
|
|
116
|
+
var _getBlockRegistry = /*#__PURE__*/(0, _classPrivateFieldLooseKey2.default)("getBlockRegistry");
|
|
121
117
|
|
|
122
|
-
var _storageCache = /*#__PURE__*/
|
|
118
|
+
var _storageCache = /*#__PURE__*/(0, _classPrivateFieldLooseKey2.default)("storageCache");
|
|
123
119
|
|
|
124
120
|
class RpcCore {
|
|
125
121
|
/**
|
|
@@ -129,34 +125,29 @@ class RpcCore {
|
|
|
129
125
|
*/
|
|
130
126
|
constructor(instanceId, registry, provider) {
|
|
131
127
|
let userRpc = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
132
|
-
|
|
133
|
-
_classPrivateFieldInitSpec(this, _instanceId, {
|
|
128
|
+
Object.defineProperty(this, _instanceId, {
|
|
134
129
|
writable: true,
|
|
135
130
|
value: void 0
|
|
136
131
|
});
|
|
137
|
-
|
|
138
|
-
_classPrivateFieldInitSpec(this, _registryDefault, {
|
|
132
|
+
Object.defineProperty(this, _registryDefault, {
|
|
139
133
|
writable: true,
|
|
140
134
|
value: void 0
|
|
141
135
|
});
|
|
142
|
-
|
|
143
|
-
_classPrivateFieldInitSpec(this, _getBlockRegistry, {
|
|
136
|
+
Object.defineProperty(this, _getBlockRegistry, {
|
|
144
137
|
writable: true,
|
|
145
138
|
value: void 0
|
|
146
139
|
});
|
|
147
|
-
|
|
148
|
-
_classPrivateFieldInitSpec(this, _storageCache, {
|
|
140
|
+
Object.defineProperty(this, _storageCache, {
|
|
149
141
|
writable: true,
|
|
150
142
|
value: new Map()
|
|
151
143
|
});
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
(0, _defineProperty2.default)(this, "sections", []);
|
|
144
|
+
this.mapping = new Map();
|
|
145
|
+
this.provider = void 0;
|
|
146
|
+
this.sections = [];
|
|
156
147
|
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
157
148
|
(0, _util.assert)(provider && (0, _util.isFunction)(provider.send), 'Expected Provider to API create');
|
|
158
|
-
(0,
|
|
159
|
-
(0,
|
|
149
|
+
(0, _classPrivateFieldLooseBase2.default)(this, _instanceId)[_instanceId] = instanceId;
|
|
150
|
+
(0, _classPrivateFieldLooseBase2.default)(this, _registryDefault)[_registryDefault] = registry;
|
|
160
151
|
this.provider = provider;
|
|
161
152
|
const sectionNames = Object.keys(_types.rpcDefinitions); // these are the base keys (i.e. part of jsonrpc)
|
|
162
153
|
|
|
@@ -194,9 +185,9 @@ class RpcCore {
|
|
|
194
185
|
|
|
195
186
|
|
|
196
187
|
setRegistrySwap(registrySwap) {
|
|
197
|
-
(0,
|
|
198
|
-
getInstanceId: () => (0,
|
|
199
|
-
})
|
|
188
|
+
(0, _classPrivateFieldLooseBase2.default)(this, _getBlockRegistry)[_getBlockRegistry] = (0, _util.memoize)(registrySwap, {
|
|
189
|
+
getInstanceId: () => (0, _classPrivateFieldLooseBase2.default)(this, _instanceId)[_instanceId]
|
|
190
|
+
});
|
|
200
191
|
}
|
|
201
192
|
|
|
202
193
|
addUserInterfaces(userRpc) {
|
|
@@ -234,7 +225,7 @@ class RpcCore {
|
|
|
234
225
|
|
|
235
226
|
_memomize(creator, def) {
|
|
236
227
|
const memoOpts = {
|
|
237
|
-
getInstanceId: () => (0,
|
|
228
|
+
getInstanceId: () => (0, _classPrivateFieldLooseBase2.default)(this, _instanceId)[_instanceId]
|
|
238
229
|
};
|
|
239
230
|
const memoized = (0, _util.memoize)(creator(true), memoOpts);
|
|
240
231
|
memoized.raw = (0, _util.memoize)(creator(false), memoOpts);
|
|
@@ -260,8 +251,8 @@ class RpcCore {
|
|
|
260
251
|
const blockHash = hashIndex === -1 ? null : values[hashIndex];
|
|
261
252
|
const {
|
|
262
253
|
registry
|
|
263
|
-
} = isScale && blockHash && (0,
|
|
264
|
-
registry: (0,
|
|
254
|
+
} = isScale && blockHash && (0, _classPrivateFieldLooseBase2.default)(this, _getBlockRegistry)[_getBlockRegistry] ? await (0, _classPrivateFieldLooseBase2.default)(this, _getBlockRegistry)[_getBlockRegistry]((0, _util.u8aToU8a)(blockHash)) : {
|
|
255
|
+
registry: (0, _classPrivateFieldLooseBase2.default)(this, _registryDefault)[_registryDefault]
|
|
265
256
|
};
|
|
266
257
|
|
|
267
258
|
const params = this._formatInputs(registry, null, def, values);
|
|
@@ -333,7 +324,8 @@ class RpcCore {
|
|
|
333
324
|
return new _rxjs.Observable(observer => {
|
|
334
325
|
// Have at least an empty promise, as used in the unsubscribe
|
|
335
326
|
let subscriptionPromise = Promise.resolve(null);
|
|
336
|
-
|
|
327
|
+
|
|
328
|
+
const registry = (0, _classPrivateFieldLooseBase2.default)(_this, _registryDefault)[_registryDefault];
|
|
337
329
|
|
|
338
330
|
const errorHandler = error => {
|
|
339
331
|
logErrorMessage(method, def, error);
|
|
@@ -453,13 +445,14 @@ class RpcCore {
|
|
|
453
445
|
// - if a single result value, don't fill - it is not an update hole
|
|
454
446
|
// - fallback to an empty option in all cases
|
|
455
447
|
|
|
456
|
-
const value = (0, _util.isUndefined)(found) ? witCache && (0,
|
|
448
|
+
const value = (0, _util.isUndefined)(found) ? witCache && (0, _classPrivateFieldLooseBase2.default)(this, _storageCache)[_storageCache].get(hexKey) || null : found[1];
|
|
457
449
|
const isEmpty = (0, _util.isNull)(value);
|
|
458
450
|
const input = isEmpty || isTreatAsHex(key) ? value : (0, _util.u8aToU8a)(value); // store the retrieved result - the only issue with this cache is that there is no
|
|
459
451
|
// clearing of it, so very long running processes (not just a couple of hours, longer)
|
|
460
452
|
// will increase memory beyond what is allowed.
|
|
461
453
|
|
|
462
|
-
(0,
|
|
454
|
+
(0, _classPrivateFieldLooseBase2.default)(this, _storageCache)[_storageCache].set(hexKey, value);
|
|
455
|
+
|
|
463
456
|
return this._newType(registry, blockHash, key, input, isEmpty, entryIndex);
|
|
464
457
|
}
|
|
465
458
|
|
package/bundle.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import _classPrivateFieldLooseBase from "@babel/runtime/helpers/esm/classPrivateFieldLooseBase";
|
|
2
|
+
import _classPrivateFieldLooseKey from "@babel/runtime/helpers/esm/classPrivateFieldLooseKey";
|
|
1
3
|
// Copyright 2017-2021 @polkadot/rpc-core authors & contributors
|
|
2
4
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
5
|
import { Observable, publishReplay, refCount } from 'rxjs';
|
|
@@ -66,24 +68,44 @@ function isTreatAsHex(key) {
|
|
|
66
68
|
*/
|
|
67
69
|
|
|
68
70
|
|
|
71
|
+
var _instanceId = /*#__PURE__*/_classPrivateFieldLooseKey("instanceId");
|
|
72
|
+
|
|
73
|
+
var _registryDefault = /*#__PURE__*/_classPrivateFieldLooseKey("registryDefault");
|
|
74
|
+
|
|
75
|
+
var _getBlockRegistry = /*#__PURE__*/_classPrivateFieldLooseKey("getBlockRegistry");
|
|
76
|
+
|
|
77
|
+
var _storageCache = /*#__PURE__*/_classPrivateFieldLooseKey("storageCache");
|
|
78
|
+
|
|
69
79
|
export class RpcCore {
|
|
70
|
-
#instanceId;
|
|
71
|
-
#registryDefault;
|
|
72
|
-
#getBlockRegistry;
|
|
73
|
-
#storageCache = new Map();
|
|
74
|
-
mapping = new Map();
|
|
75
|
-
sections = [];
|
|
76
80
|
/**
|
|
77
81
|
* @constructor
|
|
78
82
|
* Default constructor for the Api Object
|
|
79
83
|
* @param {ProviderInterface} provider An API provider using HTTP or WebSocket
|
|
80
84
|
*/
|
|
81
|
-
|
|
82
85
|
constructor(instanceId, registry, provider, userRpc = {}) {
|
|
86
|
+
Object.defineProperty(this, _instanceId, {
|
|
87
|
+
writable: true,
|
|
88
|
+
value: void 0
|
|
89
|
+
});
|
|
90
|
+
Object.defineProperty(this, _registryDefault, {
|
|
91
|
+
writable: true,
|
|
92
|
+
value: void 0
|
|
93
|
+
});
|
|
94
|
+
Object.defineProperty(this, _getBlockRegistry, {
|
|
95
|
+
writable: true,
|
|
96
|
+
value: void 0
|
|
97
|
+
});
|
|
98
|
+
Object.defineProperty(this, _storageCache, {
|
|
99
|
+
writable: true,
|
|
100
|
+
value: new Map()
|
|
101
|
+
});
|
|
102
|
+
this.mapping = new Map();
|
|
103
|
+
this.provider = void 0;
|
|
104
|
+
this.sections = [];
|
|
83
105
|
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
84
106
|
assert(provider && isFunction(provider.send), 'Expected Provider to API create');
|
|
85
|
-
this
|
|
86
|
-
this
|
|
107
|
+
_classPrivateFieldLooseBase(this, _instanceId)[_instanceId] = instanceId;
|
|
108
|
+
_classPrivateFieldLooseBase(this, _registryDefault)[_registryDefault] = registry;
|
|
87
109
|
this.provider = provider;
|
|
88
110
|
const sectionNames = Object.keys(rpcDefinitions); // these are the base keys (i.e. part of jsonrpc)
|
|
89
111
|
|
|
@@ -121,8 +143,8 @@ export class RpcCore {
|
|
|
121
143
|
|
|
122
144
|
|
|
123
145
|
setRegistrySwap(registrySwap) {
|
|
124
|
-
this
|
|
125
|
-
getInstanceId: () => this
|
|
146
|
+
_classPrivateFieldLooseBase(this, _getBlockRegistry)[_getBlockRegistry] = memoize(registrySwap, {
|
|
147
|
+
getInstanceId: () => _classPrivateFieldLooseBase(this, _instanceId)[_instanceId]
|
|
126
148
|
});
|
|
127
149
|
}
|
|
128
150
|
|
|
@@ -161,7 +183,7 @@ export class RpcCore {
|
|
|
161
183
|
|
|
162
184
|
_memomize(creator, def) {
|
|
163
185
|
const memoOpts = {
|
|
164
|
-
getInstanceId: () => this
|
|
186
|
+
getInstanceId: () => _classPrivateFieldLooseBase(this, _instanceId)[_instanceId]
|
|
165
187
|
};
|
|
166
188
|
const memoized = memoize(creator(true), memoOpts);
|
|
167
189
|
memoized.raw = memoize(creator(false), memoOpts);
|
|
@@ -184,8 +206,8 @@ export class RpcCore {
|
|
|
184
206
|
const blockHash = hashIndex === -1 ? null : values[hashIndex];
|
|
185
207
|
const {
|
|
186
208
|
registry
|
|
187
|
-
} = isScale && blockHash && this
|
|
188
|
-
registry: this
|
|
209
|
+
} = isScale && blockHash && _classPrivateFieldLooseBase(this, _getBlockRegistry)[_getBlockRegistry] ? await _classPrivateFieldLooseBase(this, _getBlockRegistry)[_getBlockRegistry](u8aToU8a(blockHash)) : {
|
|
210
|
+
registry: _classPrivateFieldLooseBase(this, _registryDefault)[_registryDefault]
|
|
189
211
|
};
|
|
190
212
|
|
|
191
213
|
const params = this._formatInputs(registry, null, def, values);
|
|
@@ -246,7 +268,8 @@ export class RpcCore {
|
|
|
246
268
|
return new Observable(observer => {
|
|
247
269
|
// Have at least an empty promise, as used in the unsubscribe
|
|
248
270
|
let subscriptionPromise = Promise.resolve(null);
|
|
249
|
-
|
|
271
|
+
|
|
272
|
+
const registry = _classPrivateFieldLooseBase(this, _registryDefault)[_registryDefault];
|
|
250
273
|
|
|
251
274
|
const errorHandler = error => {
|
|
252
275
|
logErrorMessage(method, def, error);
|
|
@@ -357,13 +380,14 @@ export class RpcCore {
|
|
|
357
380
|
// - if a single result value, don't fill - it is not an update hole
|
|
358
381
|
// - fallback to an empty option in all cases
|
|
359
382
|
|
|
360
|
-
const value = isUndefined(found) ? witCache && this
|
|
383
|
+
const value = isUndefined(found) ? witCache && _classPrivateFieldLooseBase(this, _storageCache)[_storageCache].get(hexKey) || null : found[1];
|
|
361
384
|
const isEmpty = isNull(value);
|
|
362
385
|
const input = isEmpty || isTreatAsHex(key) ? value : u8aToU8a(value); // store the retrieved result - the only issue with this cache is that there is no
|
|
363
386
|
// clearing of it, so very long running processes (not just a couple of hours, longer)
|
|
364
387
|
// will increase memory beyond what is allowed.
|
|
365
388
|
|
|
366
|
-
this
|
|
389
|
+
_classPrivateFieldLooseBase(this, _storageCache)[_storageCache].set(hexKey, value);
|
|
390
|
+
|
|
367
391
|
return this._newType(registry, blockHash, key, input, isEmpty, entryIndex);
|
|
368
392
|
}
|
|
369
393
|
|
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-27",
|
|
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.8.
|
|
27
|
+
"@polkadot/rpc-provider": "6.6.2-27",
|
|
28
|
+
"@polkadot/types": "6.6.2-27",
|
|
29
|
+
"@polkadot/util": "^7.8.2",
|
|
30
30
|
"rxjs": "^7.4.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@polkadot/keyring": "^7.8.
|
|
33
|
+
"@polkadot/keyring": "^7.8.2"
|
|
34
34
|
},
|
|
35
35
|
"exports": {
|
|
36
36
|
".": {
|
package/packageInfo.cjs
CHANGED
package/packageInfo.js
CHANGED