@polkadot/rpc-core 7.4.2-7 → 7.5.2-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.js +17 -41
- package/package.json +5 -5
- package/packageInfo.cjs +1 -1
- package/packageInfo.js +1 -1
package/bundle.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import _classPrivateFieldLooseBase from "@babel/runtime/helpers/esm/classPrivateFieldLooseBase";
|
|
2
|
-
import _classPrivateFieldLooseKey from "@babel/runtime/helpers/esm/classPrivateFieldLooseKey";
|
|
3
1
|
// Copyright 2017-2022 @polkadot/rpc-core authors & contributors
|
|
4
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
5
3
|
import { Observable, publishReplay, refCount } from 'rxjs';
|
|
@@ -68,44 +66,24 @@ function isTreatAsHex(key) {
|
|
|
68
66
|
*/
|
|
69
67
|
|
|
70
68
|
|
|
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
|
-
|
|
79
69
|
export class RpcCore {
|
|
70
|
+
#instanceId;
|
|
71
|
+
#registryDefault;
|
|
72
|
+
#getBlockRegistry;
|
|
73
|
+
#storageCache = new Map();
|
|
74
|
+
mapping = new Map();
|
|
75
|
+
sections = [];
|
|
80
76
|
/**
|
|
81
77
|
* @constructor
|
|
82
78
|
* Default constructor for the Api Object
|
|
83
79
|
* @param {ProviderInterface} provider An API provider using HTTP or WebSocket
|
|
84
80
|
*/
|
|
81
|
+
|
|
85
82
|
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 = [];
|
|
105
83
|
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
106
84
|
assert(provider && isFunction(provider.send), 'Expected Provider to API create');
|
|
107
|
-
|
|
108
|
-
|
|
85
|
+
this.#instanceId = instanceId;
|
|
86
|
+
this.#registryDefault = registry;
|
|
109
87
|
this.provider = provider;
|
|
110
88
|
const sectionNames = Object.keys(rpcDefinitions); // these are the base keys (i.e. part of jsonrpc)
|
|
111
89
|
|
|
@@ -143,8 +121,8 @@ export class RpcCore {
|
|
|
143
121
|
|
|
144
122
|
|
|
145
123
|
setRegistrySwap(registrySwap) {
|
|
146
|
-
|
|
147
|
-
getInstanceId: () =>
|
|
124
|
+
this.#getBlockRegistry = memoize(registrySwap, {
|
|
125
|
+
getInstanceId: () => this.#instanceId
|
|
148
126
|
});
|
|
149
127
|
}
|
|
150
128
|
|
|
@@ -183,7 +161,7 @@ export class RpcCore {
|
|
|
183
161
|
|
|
184
162
|
_memomize(creator, def) {
|
|
185
163
|
const memoOpts = {
|
|
186
|
-
getInstanceId: () =>
|
|
164
|
+
getInstanceId: () => this.#instanceId
|
|
187
165
|
};
|
|
188
166
|
const memoized = memoize(creator(true), memoOpts);
|
|
189
167
|
memoized.raw = memoize(creator(false), memoOpts);
|
|
@@ -206,8 +184,8 @@ export class RpcCore {
|
|
|
206
184
|
const blockHash = hashIndex === -1 ? null : values[hashIndex];
|
|
207
185
|
const {
|
|
208
186
|
registry
|
|
209
|
-
} = isScale && blockHash &&
|
|
210
|
-
registry:
|
|
187
|
+
} = isScale && blockHash && this.#getBlockRegistry ? await this.#getBlockRegistry(u8aToU8a(blockHash)) : {
|
|
188
|
+
registry: this.#registryDefault
|
|
211
189
|
};
|
|
212
190
|
|
|
213
191
|
const params = this._formatInputs(registry, null, def, values); // only cache .at(<blockHash>) queries, e.g. where valid blockHash was supplied
|
|
@@ -269,8 +247,7 @@ export class RpcCore {
|
|
|
269
247
|
return new Observable(observer => {
|
|
270
248
|
// Have at least an empty promise, as used in the unsubscribe
|
|
271
249
|
let subscriptionPromise = Promise.resolve(null);
|
|
272
|
-
|
|
273
|
-
const registry = _classPrivateFieldLooseBase(this, _registryDefault)[_registryDefault];
|
|
250
|
+
const registry = this.#registryDefault;
|
|
274
251
|
|
|
275
252
|
const errorHandler = error => {
|
|
276
253
|
logErrorMessage(method, def, error);
|
|
@@ -381,14 +358,13 @@ export class RpcCore {
|
|
|
381
358
|
// - if a single result value, don't fill - it is not an update hole
|
|
382
359
|
// - fallback to an empty option in all cases
|
|
383
360
|
|
|
384
|
-
const value = isUndefined(found) ? witCache &&
|
|
361
|
+
const value = isUndefined(found) ? witCache && this.#storageCache.get(hexKey) || null : found[1];
|
|
385
362
|
const isEmpty = isNull(value);
|
|
386
363
|
const input = isEmpty || isTreatAsHex(key) ? value : u8aToU8a(value); // store the retrieved result - the only issue with this cache is that there is no
|
|
387
364
|
// clearing of it, so very long running processes (not just a couple of hours, longer)
|
|
388
365
|
// will increase memory beyond what is allowed.
|
|
389
366
|
|
|
390
|
-
|
|
391
|
-
|
|
367
|
+
this.#storageCache.set(hexKey, value);
|
|
392
368
|
return this._newType(registry, blockHash, key, input, isEmpty, entryIndex);
|
|
393
369
|
}
|
|
394
370
|
|
package/package.json
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"./detectPackage.cjs"
|
|
21
21
|
],
|
|
22
22
|
"type": "module",
|
|
23
|
-
"version": "7.
|
|
23
|
+
"version": "7.5.2-0",
|
|
24
24
|
"main": "index.cjs",
|
|
25
25
|
"module": "index.js",
|
|
26
26
|
"types": "index.d.ts",
|
|
@@ -91,10 +91,10 @@
|
|
|
91
91
|
},
|
|
92
92
|
"dependencies": {
|
|
93
93
|
"@babel/runtime": "^7.16.7",
|
|
94
|
-
"@polkadot/rpc-augment": "7.
|
|
95
|
-
"@polkadot/rpc-provider": "7.
|
|
96
|
-
"@polkadot/types": "7.
|
|
97
|
-
"@polkadot/util": "^8.3.
|
|
94
|
+
"@polkadot/rpc-augment": "7.5.2-0",
|
|
95
|
+
"@polkadot/rpc-provider": "7.5.2-0",
|
|
96
|
+
"@polkadot/types": "7.5.2-0",
|
|
97
|
+
"@polkadot/util": "^8.3.3",
|
|
98
98
|
"rxjs": "^7.5.2"
|
|
99
99
|
}
|
|
100
100
|
}
|
package/packageInfo.cjs
CHANGED
package/packageInfo.js
CHANGED