@polkadot/rpc-core 7.4.2-9 → 7.5.2-10

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 CHANGED
@@ -278,10 +278,16 @@ class RpcCore {
278
278
  observer.complete();
279
279
  });
280
280
  return () => {
281
- var _memoized;
282
-
283
281
  // delete old results from cache
284
- (_memoized = memoized) === null || _memoized === void 0 ? void 0 : _memoized.unmemoize(...values);
282
+ if (isScale) {
283
+ var _memoized;
284
+
285
+ (_memoized = memoized) === null || _memoized === void 0 ? void 0 : _memoized.unmemoize(...values);
286
+ } else {
287
+ var _memoized2;
288
+
289
+ (_memoized2 = memoized) === null || _memoized2 === void 0 ? void 0 : _memoized2.raw.unmemoize(...values);
290
+ }
285
291
  };
286
292
  }).pipe((0, _rxjs.publishReplay)(1), // create a Replay(1)
287
293
  isDelayed ? (0, _index.refCountDelay)() // Unsubscribe after delay
@@ -363,10 +369,17 @@ class RpcCore {
363
369
 
364
370
 
365
371
  return () => {
366
- var _memoized2;
367
-
368
372
  // Delete from cache, so old results don't hang around
369
- (_memoized2 = memoized) === null || _memoized2 === void 0 ? void 0 : _memoized2.unmemoize(...values); // Unsubscribe from provider
373
+ if (isScale) {
374
+ var _memoized3;
375
+
376
+ (_memoized3 = memoized) === null || _memoized3 === void 0 ? void 0 : _memoized3.unmemoize(...values);
377
+ } else {
378
+ var _memoized4;
379
+
380
+ (_memoized4 = memoized) === null || _memoized4 === void 0 ? void 0 : _memoized4.raw.unmemoize(...values);
381
+ } // Unsubscribe from provider
382
+
370
383
 
371
384
  subscriptionPromise.then(subscriptionId => (0, _util.isNull)(subscriptionId) ? Promise.resolve(false) : _this.provider.unsubscribe(subType, unsubName, subscriptionId)).catch(error => logErrorMessage(method, def, error));
372
385
  };
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
- _classPrivateFieldLooseBase(this, _instanceId)[_instanceId] = instanceId;
108
- _classPrivateFieldLooseBase(this, _registryDefault)[_registryDefault] = registry;
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
- _classPrivateFieldLooseBase(this, _getBlockRegistry)[_getBlockRegistry] = memoize(registrySwap, {
147
- getInstanceId: () => _classPrivateFieldLooseBase(this, _instanceId)[_instanceId]
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: () => _classPrivateFieldLooseBase(this, _instanceId)[_instanceId]
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 && _classPrivateFieldLooseBase(this, _getBlockRegistry)[_getBlockRegistry] ? await _classPrivateFieldLooseBase(this, _getBlockRegistry)[_getBlockRegistry](u8aToU8a(blockHash)) : {
210
- registry: _classPrivateFieldLooseBase(this, _registryDefault)[_registryDefault]
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
@@ -229,10 +207,16 @@ export class RpcCore {
229
207
  observer.complete();
230
208
  });
231
209
  return () => {
232
- var _memoized;
233
-
234
210
  // delete old results from cache
235
- (_memoized = memoized) === null || _memoized === void 0 ? void 0 : _memoized.unmemoize(...values);
211
+ if (isScale) {
212
+ var _memoized;
213
+
214
+ (_memoized = memoized) === null || _memoized === void 0 ? void 0 : _memoized.unmemoize(...values);
215
+ } else {
216
+ var _memoized2;
217
+
218
+ (_memoized2 = memoized) === null || _memoized2 === void 0 ? void 0 : _memoized2.raw.unmemoize(...values);
219
+ }
236
220
  };
237
221
  }).pipe(publishReplay(1), // create a Replay(1)
238
222
  isDelayed ? refCountDelay() // Unsubscribe after delay
@@ -269,8 +253,7 @@ export class RpcCore {
269
253
  return new Observable(observer => {
270
254
  // Have at least an empty promise, as used in the unsubscribe
271
255
  let subscriptionPromise = Promise.resolve(null);
272
-
273
- const registry = _classPrivateFieldLooseBase(this, _registryDefault)[_registryDefault];
256
+ const registry = this.#registryDefault;
274
257
 
275
258
  const errorHandler = error => {
276
259
  logErrorMessage(method, def, error);
@@ -307,10 +290,17 @@ export class RpcCore {
307
290
 
308
291
 
309
292
  return () => {
310
- var _memoized2;
311
-
312
293
  // Delete from cache, so old results don't hang around
313
- (_memoized2 = memoized) === null || _memoized2 === void 0 ? void 0 : _memoized2.unmemoize(...values); // Unsubscribe from provider
294
+ if (isScale) {
295
+ var _memoized3;
296
+
297
+ (_memoized3 = memoized) === null || _memoized3 === void 0 ? void 0 : _memoized3.unmemoize(...values);
298
+ } else {
299
+ var _memoized4;
300
+
301
+ (_memoized4 = memoized) === null || _memoized4 === void 0 ? void 0 : _memoized4.raw.unmemoize(...values);
302
+ } // Unsubscribe from provider
303
+
314
304
 
315
305
  subscriptionPromise.then(subscriptionId => isNull(subscriptionId) ? Promise.resolve(false) : this.provider.unsubscribe(subType, unsubName, subscriptionId)).catch(error => logErrorMessage(method, def, error));
316
306
  };
@@ -381,14 +371,13 @@ export class RpcCore {
381
371
  // - if a single result value, don't fill - it is not an update hole
382
372
  // - fallback to an empty option in all cases
383
373
 
384
- const value = isUndefined(found) ? witCache && _classPrivateFieldLooseBase(this, _storageCache)[_storageCache].get(hexKey) || null : found[1];
374
+ const value = isUndefined(found) ? witCache && this.#storageCache.get(hexKey) || null : found[1];
385
375
  const isEmpty = isNull(value);
386
376
  const input = isEmpty || isTreatAsHex(key) ? value : u8aToU8a(value); // store the retrieved result - the only issue with this cache is that there is no
387
377
  // clearing of it, so very long running processes (not just a couple of hours, longer)
388
378
  // will increase memory beyond what is allowed.
389
379
 
390
- _classPrivateFieldLooseBase(this, _storageCache)[_storageCache].set(hexKey, value);
391
-
380
+ this.#storageCache.set(hexKey, value);
392
381
  return this._newType(registry, blockHash, key, input, isEmpty, entryIndex);
393
382
  }
394
383
 
package/package.json CHANGED
@@ -20,7 +20,7 @@
20
20
  "./detectPackage.cjs"
21
21
  ],
22
22
  "type": "module",
23
- "version": "7.4.2-9",
23
+ "version": "7.5.2-10",
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.4.2-9",
95
- "@polkadot/rpc-provider": "7.4.2-9",
96
- "@polkadot/types": "7.4.2-9",
97
- "@polkadot/util": "^8.3.2",
94
+ "@polkadot/rpc-augment": "7.5.2-10",
95
+ "@polkadot/rpc-provider": "7.5.2-10",
96
+ "@polkadot/types": "7.5.2-10",
97
+ "@polkadot/util": "^8.3.3",
98
98
  "rxjs": "^7.5.2"
99
99
  }
100
100
  }
package/packageInfo.cjs CHANGED
@@ -11,6 +11,6 @@ const packageInfo = {
11
11
  name: '@polkadot/rpc-core',
12
12
  path: typeof __dirname === 'string' ? __dirname : 'auto',
13
13
  type: 'cjs',
14
- version: '7.4.2-9'
14
+ version: '7.5.2-10'
15
15
  };
16
16
  exports.packageInfo = packageInfo;
package/packageInfo.js CHANGED
@@ -5,5 +5,5 @@ export const packageInfo = {
5
5
  name: '@polkadot/rpc-core',
6
6
  path: new URL('.', import.meta.url).pathname,
7
7
  type: 'esm',
8
- version: '7.4.2-9'
8
+ version: '7.5.2-10'
9
9
  };