@polkadot/rpc-core 6.6.2-1 → 6.6.2-13

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
@@ -19,9 +19,9 @@ Object.defineProperty(exports, "packageInfo", {
19
19
 
20
20
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
21
21
 
22
- var _classPrivateFieldLooseBase2 = _interopRequireDefault(require("@babel/runtime/helpers/classPrivateFieldLooseBase"));
22
+ var _classPrivateFieldGet2 = _interopRequireDefault(require("@babel/runtime/helpers/classPrivateFieldGet"));
23
23
 
24
- var _classPrivateFieldLooseKey2 = _interopRequireDefault(require("@babel/runtime/helpers/classPrivateFieldLooseKey"));
24
+ var _classPrivateFieldSet2 = _interopRequireDefault(require("@babel/runtime/helpers/classPrivateFieldSet"));
25
25
 
26
26
  var _rxjs = require("rxjs");
27
27
 
@@ -45,9 +45,9 @@ Object.keys(_index).forEach(function (key) {
45
45
 
46
46
  var _packageInfo = require("./packageInfo.cjs");
47
47
 
48
- 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; }
48
+ function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
49
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; }
50
+ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
51
51
 
52
52
  const l = (0, _util.logger)('rpc-core');
53
53
  const EMPTY_META = {
@@ -67,15 +67,19 @@ const EMPTY_META = {
67
67
 
68
68
  /** @internal */
69
69
 
70
- function logErrorMessage(method, {
71
- params,
72
- type
73
- }, error) {
74
- const inputs = params.map(({
75
- isOptional,
76
- name,
70
+ function logErrorMessage(method, _ref, error) {
71
+ let {
72
+ params,
77
73
  type
78
- }) => `${name}${isOptional ? '?' : ''}: ${type}`).join(', ');
74
+ } = _ref;
75
+ const inputs = params.map(_ref2 => {
76
+ let {
77
+ isOptional,
78
+ name,
79
+ type
80
+ } = _ref2;
81
+ return `${name}${isOptional ? '?' : ''}: ${type}`;
82
+ }).join(', ');
79
83
  l.error(`${method}(${inputs}): ${type}:: ${error.message}`);
80
84
  }
81
85
 
@@ -109,13 +113,13 @@ function isTreatAsHex(key) {
109
113
  */
110
114
 
111
115
 
112
- var _instanceId = /*#__PURE__*/(0, _classPrivateFieldLooseKey2.default)("instanceId");
116
+ var _instanceId = /*#__PURE__*/new WeakMap();
113
117
 
114
- var _registryDefault = /*#__PURE__*/(0, _classPrivateFieldLooseKey2.default)("registryDefault");
118
+ var _registryDefault = /*#__PURE__*/new WeakMap();
115
119
 
116
- var _getBlockRegistry = /*#__PURE__*/(0, _classPrivateFieldLooseKey2.default)("getBlockRegistry");
120
+ var _getBlockRegistry = /*#__PURE__*/new WeakMap();
117
121
 
118
- var _storageCache = /*#__PURE__*/(0, _classPrivateFieldLooseKey2.default)("storageCache");
122
+ var _storageCache = /*#__PURE__*/new WeakMap();
119
123
 
120
124
  class RpcCore {
121
125
  /**
@@ -123,30 +127,36 @@ class RpcCore {
123
127
  * Default constructor for the Api Object
124
128
  * @param {ProviderInterface} provider An API provider using HTTP or WebSocket
125
129
  */
126
- constructor(instanceId, registry, provider, userRpc = {}) {
127
- Object.defineProperty(this, _instanceId, {
130
+ constructor(instanceId, registry, provider) {
131
+ let userRpc = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
132
+
133
+ _classPrivateFieldInitSpec(this, _instanceId, {
128
134
  writable: true,
129
135
  value: void 0
130
136
  });
131
- Object.defineProperty(this, _registryDefault, {
137
+
138
+ _classPrivateFieldInitSpec(this, _registryDefault, {
132
139
  writable: true,
133
140
  value: void 0
134
141
  });
135
- Object.defineProperty(this, _getBlockRegistry, {
142
+
143
+ _classPrivateFieldInitSpec(this, _getBlockRegistry, {
136
144
  writable: true,
137
145
  value: void 0
138
146
  });
139
- Object.defineProperty(this, _storageCache, {
147
+
148
+ _classPrivateFieldInitSpec(this, _storageCache, {
140
149
  writable: true,
141
150
  value: new Map()
142
151
  });
143
- this.mapping = new Map();
144
- this.provider = void 0;
145
- this.sections = [];
152
+
153
+ (0, _defineProperty2.default)(this, "mapping", new Map());
154
+ (0, _defineProperty2.default)(this, "provider", void 0);
155
+ (0, _defineProperty2.default)(this, "sections", []);
146
156
  // eslint-disable-next-line @typescript-eslint/unbound-method
147
157
  (0, _util.assert)(provider && (0, _util.isFunction)(provider.send), 'Expected Provider to API create');
148
- (0, _classPrivateFieldLooseBase2.default)(this, _instanceId)[_instanceId] = instanceId;
149
- (0, _classPrivateFieldLooseBase2.default)(this, _registryDefault)[_registryDefault] = registry;
158
+ (0, _classPrivateFieldSet2.default)(this, _instanceId, instanceId);
159
+ (0, _classPrivateFieldSet2.default)(this, _registryDefault, registry);
150
160
  this.provider = provider;
151
161
  const sectionNames = Object.keys(_types.rpcDefinitions); // these are the base keys (i.e. part of jsonrpc)
152
162
 
@@ -184,9 +194,9 @@ class RpcCore {
184
194
 
185
195
 
186
196
  setRegistrySwap(registrySwap) {
187
- (0, _classPrivateFieldLooseBase2.default)(this, _getBlockRegistry)[_getBlockRegistry] = (0, _util.memoize)(registrySwap, {
188
- getInstanceId: () => (0, _classPrivateFieldLooseBase2.default)(this, _instanceId)[_instanceId]
189
- });
197
+ (0, _classPrivateFieldSet2.default)(this, _getBlockRegistry, (0, _util.memoize)(registrySwap, {
198
+ getInstanceId: () => (0, _classPrivateFieldGet2.default)(this, _instanceId)
199
+ }));
190
200
  }
191
201
 
192
202
  addUserInterfaces(userRpc) {
@@ -194,31 +204,38 @@ class RpcCore {
194
204
  this.sections.push(...Object.keys(userRpc).filter(key => !this.sections.includes(key))); // decorate the sections with base and user methods
195
205
 
196
206
  this.sections.forEach(sectionName => {
197
- var _ref, _ref2;
207
+ var _ref3, _ref4;
198
208
 
199
- (_ref = this)[_ref2 = sectionName] || (_ref[_ref2] = {});
209
+ (_ref3 = this)[_ref4 = sectionName] || (_ref3[_ref4] = {});
200
210
  const section = this[sectionName];
201
- Object.entries(_objectSpread(_objectSpread({}, this._createInterface(sectionName, _types.rpcDefinitions[sectionName] || {})), this._createInterface(sectionName, userRpc[sectionName] || {}))).forEach(([key, value]) => {
211
+ Object.entries({ ...this._createInterface(sectionName, _types.rpcDefinitions[sectionName] || {}),
212
+ ...this._createInterface(sectionName, userRpc[sectionName] || {})
213
+ }).forEach(_ref5 => {
214
+ let [key, value] = _ref5;
202
215
  section[key] || (section[key] = value);
203
216
  });
204
217
  });
205
218
  }
206
219
 
207
220
  _createInterface(section, methods) {
208
- return Object.entries(methods).filter(([method, {
209
- endpoint
210
- }]) => !this.mapping.has(endpoint || `${section}_${method}`)).reduce((exposed, [method, {
211
- endpoint
212
- }]) => {
221
+ return Object.entries(methods).filter(_ref6 => {
222
+ let [method, {
223
+ endpoint
224
+ }] = _ref6;
225
+ return !this.mapping.has(endpoint || `${section}_${method}`);
226
+ }).reduce((exposed, _ref7) => {
227
+ let [method, {
228
+ endpoint
229
+ }] = _ref7;
213
230
  const def = methods[method];
214
231
  const isSubscription = !!def.pubsub;
215
232
  const jsonrpc = endpoint || `${section}_${method}`;
216
- this.mapping.set(jsonrpc, _objectSpread(_objectSpread({}, def), {}, {
233
+ this.mapping.set(jsonrpc, { ...def,
217
234
  isSubscription,
218
235
  jsonrpc,
219
236
  method,
220
237
  section
221
- }));
238
+ });
222
239
  exposed[method] = isSubscription ? this._createMethodSubscribe(section, method, def) : this._createMethodSend(section, method, def);
223
240
  return exposed;
224
241
  }, {});
@@ -226,7 +243,7 @@ class RpcCore {
226
243
 
227
244
  _memomize(creator, def) {
228
245
  const memoOpts = {
229
- getInstanceId: () => (0, _classPrivateFieldLooseBase2.default)(this, _instanceId)[_instanceId]
246
+ getInstanceId: () => (0, _classPrivateFieldGet2.default)(this, _instanceId)
230
247
  };
231
248
  const memoized = (0, _util.memoize)(creator(true), memoOpts);
232
249
  memoized.raw = (0, _util.memoize)(creator(false), memoOpts);
@@ -240,17 +257,20 @@ class RpcCore {
240
257
 
241
258
  _createMethodSend(section, method, def) {
242
259
  const rpcName = def.endpoint || `${section}_${method}`;
243
- const hashIndex = def.params.findIndex(({
244
- isHistoric
245
- }) => isHistoric);
260
+ const hashIndex = def.params.findIndex(_ref8 => {
261
+ let {
262
+ isHistoric
263
+ } = _ref8;
264
+ return isHistoric;
265
+ });
246
266
  let memoized = null; // execute the RPC call, doing a registry swap for historic as applicable
247
267
 
248
268
  const callWithRegistry = async (isScale, values) => {
249
269
  const blockHash = hashIndex === -1 ? null : values[hashIndex];
250
270
  const {
251
271
  registry
252
- } = isScale && blockHash && (0, _classPrivateFieldLooseBase2.default)(this, _getBlockRegistry)[_getBlockRegistry] ? await (0, _classPrivateFieldLooseBase2.default)(this, _getBlockRegistry)[_getBlockRegistry]((0, _util.u8aToU8a)(blockHash)) : {
253
- registry: (0, _classPrivateFieldLooseBase2.default)(this, _registryDefault)[_registryDefault]
272
+ } = isScale && blockHash && (0, _classPrivateFieldGet2.default)(this, _getBlockRegistry) ? await (0, _classPrivateFieldGet2.default)(this, _getBlockRegistry).call(this, (0, _util.u8aToU8a)(blockHash)) : {
273
+ registry: (0, _classPrivateFieldGet2.default)(this, _registryDefault)
254
274
  };
255
275
 
256
276
  const params = this._formatInputs(registry, null, def, values);
@@ -259,7 +279,11 @@ class RpcCore {
259
279
  return this._formatResult(isScale, registry, blockHash, method, def, params, result);
260
280
  };
261
281
 
262
- const creator = isScale => (...values) => {
282
+ const creator = isScale => function () {
283
+ for (var _len = arguments.length, values = new Array(_len), _key = 0; _key < _len; _key++) {
284
+ values[_key] = arguments[_key];
285
+ }
286
+
263
287
  const isDelayed = isScale && hashIndex !== -1 && !!values[hashIndex];
264
288
  return new _rxjs.Observable(observer => {
265
289
  callWithRegistry(isScale, values).then(value => {
@@ -286,12 +310,13 @@ class RpcCore {
286
310
  } // create a subscriptor, it subscribes once and resolves with the id as subscribe
287
311
 
288
312
 
289
- _createSubscriber({
290
- paramsJson,
291
- subName,
292
- subType,
293
- update
294
- }, errorHandler) {
313
+ _createSubscriber(_ref9, errorHandler) {
314
+ let {
315
+ paramsJson,
316
+ subName,
317
+ subType,
318
+ update
319
+ } = _ref9;
295
320
  return new Promise((resolve, reject) => {
296
321
  this.provider.subscribe(subType, subName, paramsJson, update).then(resolve).catch(error => {
297
322
  errorHandler(error);
@@ -301,18 +326,23 @@ class RpcCore {
301
326
  }
302
327
 
303
328
  _createMethodSubscribe(section, method, def) {
329
+ var _this = this;
330
+
304
331
  const [updateType, subMethod, unsubMethod] = def.pubsub;
305
332
  const subName = `${section}_${subMethod}`;
306
333
  const unsubName = `${section}_${unsubMethod}`;
307
334
  const subType = `${section}_${updateType}`;
308
335
  let memoized = null;
309
336
 
310
- const creator = isScale => (...values) => {
337
+ const creator = isScale => function () {
338
+ for (var _len2 = arguments.length, values = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
339
+ values[_key2] = arguments[_key2];
340
+ }
341
+
311
342
  return new _rxjs.Observable(observer => {
312
343
  // Have at least an empty promise, as used in the unsubscribe
313
344
  let subscriptionPromise = Promise.resolve(null);
314
-
315
- const registry = (0, _classPrivateFieldLooseBase2.default)(this, _registryDefault)[_registryDefault];
345
+ const registry = (0, _classPrivateFieldGet2.default)(_this, _registryDefault);
316
346
 
317
347
  const errorHandler = error => {
318
348
  logErrorMessage(method, def, error);
@@ -320,7 +350,7 @@ class RpcCore {
320
350
  };
321
351
 
322
352
  try {
323
- const params = this._formatInputs(registry, null, def, values);
353
+ const params = _this._formatInputs(registry, null, def, values);
324
354
 
325
355
  const paramsJson = params.map(p => p.toJSON());
326
356
 
@@ -331,13 +361,13 @@ class RpcCore {
331
361
  }
332
362
 
333
363
  try {
334
- observer.next(this._formatResult(isScale, registry, null, method, def, params, result));
364
+ observer.next(_this._formatResult(isScale, registry, null, method, def, params, result));
335
365
  } catch (error) {
336
366
  observer.error(error);
337
367
  }
338
368
  };
339
369
 
340
- subscriptionPromise = this._createSubscriber({
370
+ subscriptionPromise = _this._createSubscriber({
341
371
  paramsJson,
342
372
  subName,
343
373
  subType,
@@ -354,7 +384,7 @@ class RpcCore {
354
384
  // Delete from cache, so old results don't hang around
355
385
  (_memoized2 = memoized) === null || _memoized2 === void 0 ? void 0 : _memoized2.unmemoize(...values); // Unsubscribe from provider
356
386
 
357
- subscriptionPromise.then(subscriptionId => (0, _util.isNull)(subscriptionId) ? Promise.resolve(false) : this.provider.unsubscribe(subType, unsubName, subscriptionId)).catch(error => logErrorMessage(method, def, error));
387
+ subscriptionPromise.then(subscriptionId => (0, _util.isNull)(subscriptionId) ? Promise.resolve(false) : _this.provider.unsubscribe(subType, unsubName, subscriptionId)).catch(error => logErrorMessage(method, def, error));
358
388
  };
359
389
  }).pipe((0, _index.drr)());
360
390
  };
@@ -364,9 +394,12 @@ class RpcCore {
364
394
  }
365
395
 
366
396
  _formatInputs(registry, blockHash, def, inputs) {
367
- const reqArgCount = def.params.filter(({
368
- isOptional
369
- }) => !isOptional).length;
397
+ const reqArgCount = def.params.filter(_ref10 => {
398
+ let {
399
+ isOptional
400
+ } = _ref10;
401
+ return !isOptional;
402
+ }).length;
370
403
  const optText = reqArgCount === def.params.length ? '' : ` (${def.params.length - reqArgCount} optional)`;
371
404
  (0, _util.assert)(inputs.length >= reqArgCount && inputs.length <= def.params.length, () => `Expected ${def.params.length} parameters${optText}, ${inputs.length} found instead`);
372
405
  return inputs.map((input, index) => registry.createTypeUnsafe(def.params[index].type, [input], {
@@ -382,10 +415,13 @@ class RpcCore {
382
415
  const keys = params[0];
383
416
  return keys ? this._formatStorageSet(registry, result.block, keys, result.changes) : registry.createType('StorageChangeSet', result);
384
417
  } else if (rpc.type === 'Vec<StorageChangeSet>') {
385
- const mapped = result.map(({
386
- block,
387
- changes
388
- }) => [registry.createType('Hash', block), this._formatStorageSet(registry, block, params[0], changes)]); // we only query at a specific block, not a range - flatten
418
+ const mapped = result.map(_ref11 => {
419
+ let {
420
+ block,
421
+ changes
422
+ } = _ref11;
423
+ return [registry.createType('Hash', block), this._formatStorageSet(registry, block, params[0], changes)];
424
+ }); // we only query at a specific block, not a range - flatten
389
425
 
390
426
  return method === 'queryStorageAt' ? mapped[0][1] : mapped;
391
427
  }
@@ -418,23 +454,26 @@ class RpcCore {
418
454
 
419
455
  _formatStorageSetEntry(registry, blockHash, key, changes, witCache, entryIndex) {
420
456
  const hexKey = key.toHex();
421
- const found = changes.find(([key]) => key === hexKey); // if we don't find the value, this is our fallback
457
+ const found = changes.find(_ref12 => {
458
+ let [key] = _ref12;
459
+ return key === hexKey;
460
+ }); // if we don't find the value, this is our fallback
422
461
  // - in the case of an array of values, fill the hole from the cache
423
462
  // - if a single result value, don't fill - it is not an update hole
424
463
  // - fallback to an empty option in all cases
425
464
 
426
- const value = (0, _util.isUndefined)(found) ? witCache && (0, _classPrivateFieldLooseBase2.default)(this, _storageCache)[_storageCache].get(hexKey) || null : found[1];
465
+ const value = (0, _util.isUndefined)(found) ? witCache && (0, _classPrivateFieldGet2.default)(this, _storageCache).get(hexKey) || null : found[1];
427
466
  const isEmpty = (0, _util.isNull)(value);
428
467
  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
429
468
  // clearing of it, so very long running processes (not just a couple of hours, longer)
430
469
  // will increase memory beyond what is allowed.
431
470
 
432
- (0, _classPrivateFieldLooseBase2.default)(this, _storageCache)[_storageCache].set(hexKey, value);
433
-
471
+ (0, _classPrivateFieldGet2.default)(this, _storageCache).set(hexKey, value);
434
472
  return this._newType(registry, blockHash, key, input, isEmpty, entryIndex);
435
473
  }
436
474
 
437
- _newType(registry, blockHash, key, input, isEmpty, entryIndex = -1) {
475
+ _newType(registry, blockHash, key, input, isEmpty) {
476
+ let entryIndex = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : -1;
438
477
  // single return value (via state.getStorage), decode the value based on the
439
478
  // outputType that we have specified. Fallback to Raw on nothing
440
479
  const type = key.outputType || 'Raw';
package/bundle.js CHANGED
@@ -1,11 +1,3 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
- import _classPrivateFieldLooseBase from "@babel/runtime/helpers/esm/classPrivateFieldLooseBase";
3
- 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
1
  // Copyright 2017-2021 @polkadot/rpc-core authors & contributors
10
2
  // SPDX-License-Identifier: Apache-2.0
11
3
  import { Observable, publishReplay, refCount } from 'rxjs';
@@ -74,44 +66,24 @@ function isTreatAsHex(key) {
74
66
  */
75
67
 
76
68
 
77
- var _instanceId = /*#__PURE__*/_classPrivateFieldLooseKey("instanceId");
78
-
79
- var _registryDefault = /*#__PURE__*/_classPrivateFieldLooseKey("registryDefault");
80
-
81
- var _getBlockRegistry = /*#__PURE__*/_classPrivateFieldLooseKey("getBlockRegistry");
82
-
83
- var _storageCache = /*#__PURE__*/_classPrivateFieldLooseKey("storageCache");
84
-
85
69
  export class RpcCore {
70
+ #instanceId;
71
+ #registryDefault;
72
+ #getBlockRegistry;
73
+ #storageCache = new Map();
74
+ mapping = new Map();
75
+ sections = [];
86
76
  /**
87
77
  * @constructor
88
78
  * Default constructor for the Api Object
89
79
  * @param {ProviderInterface} provider An API provider using HTTP or WebSocket
90
80
  */
81
+
91
82
  constructor(instanceId, registry, provider, userRpc = {}) {
92
- Object.defineProperty(this, _instanceId, {
93
- writable: true,
94
- value: void 0
95
- });
96
- Object.defineProperty(this, _registryDefault, {
97
- writable: true,
98
- value: void 0
99
- });
100
- Object.defineProperty(this, _getBlockRegistry, {
101
- writable: true,
102
- value: void 0
103
- });
104
- Object.defineProperty(this, _storageCache, {
105
- writable: true,
106
- value: new Map()
107
- });
108
- this.mapping = new Map();
109
- this.provider = void 0;
110
- this.sections = [];
111
83
  // eslint-disable-next-line @typescript-eslint/unbound-method
112
84
  assert(provider && isFunction(provider.send), 'Expected Provider to API create');
113
- _classPrivateFieldLooseBase(this, _instanceId)[_instanceId] = instanceId;
114
- _classPrivateFieldLooseBase(this, _registryDefault)[_registryDefault] = registry;
85
+ this.#instanceId = instanceId;
86
+ this.#registryDefault = registry;
115
87
  this.provider = provider;
116
88
  const sectionNames = Object.keys(rpcDefinitions); // these are the base keys (i.e. part of jsonrpc)
117
89
 
@@ -149,8 +121,8 @@ export class RpcCore {
149
121
 
150
122
 
151
123
  setRegistrySwap(registrySwap) {
152
- _classPrivateFieldLooseBase(this, _getBlockRegistry)[_getBlockRegistry] = memoize(registrySwap, {
153
- getInstanceId: () => _classPrivateFieldLooseBase(this, _instanceId)[_instanceId]
124
+ this.#getBlockRegistry = memoize(registrySwap, {
125
+ getInstanceId: () => this.#instanceId
154
126
  });
155
127
  }
156
128
 
@@ -163,7 +135,9 @@ export class RpcCore {
163
135
 
164
136
  (_ref = this)[_ref2 = sectionName] || (_ref[_ref2] = {});
165
137
  const section = this[sectionName];
166
- Object.entries(_objectSpread(_objectSpread({}, this._createInterface(sectionName, rpcDefinitions[sectionName] || {})), this._createInterface(sectionName, userRpc[sectionName] || {}))).forEach(([key, value]) => {
138
+ Object.entries({ ...this._createInterface(sectionName, rpcDefinitions[sectionName] || {}),
139
+ ...this._createInterface(sectionName, userRpc[sectionName] || {})
140
+ }).forEach(([key, value]) => {
167
141
  section[key] || (section[key] = value);
168
142
  });
169
143
  });
@@ -178,12 +152,12 @@ export class RpcCore {
178
152
  const def = methods[method];
179
153
  const isSubscription = !!def.pubsub;
180
154
  const jsonrpc = endpoint || `${section}_${method}`;
181
- this.mapping.set(jsonrpc, _objectSpread(_objectSpread({}, def), {}, {
155
+ this.mapping.set(jsonrpc, { ...def,
182
156
  isSubscription,
183
157
  jsonrpc,
184
158
  method,
185
159
  section
186
- }));
160
+ });
187
161
  exposed[method] = isSubscription ? this._createMethodSubscribe(section, method, def) : this._createMethodSend(section, method, def);
188
162
  return exposed;
189
163
  }, {});
@@ -191,7 +165,7 @@ export class RpcCore {
191
165
 
192
166
  _memomize(creator, def) {
193
167
  const memoOpts = {
194
- getInstanceId: () => _classPrivateFieldLooseBase(this, _instanceId)[_instanceId]
168
+ getInstanceId: () => this.#instanceId
195
169
  };
196
170
  const memoized = memoize(creator(true), memoOpts);
197
171
  memoized.raw = memoize(creator(false), memoOpts);
@@ -214,8 +188,8 @@ export class RpcCore {
214
188
  const blockHash = hashIndex === -1 ? null : values[hashIndex];
215
189
  const {
216
190
  registry
217
- } = isScale && blockHash && _classPrivateFieldLooseBase(this, _getBlockRegistry)[_getBlockRegistry] ? await _classPrivateFieldLooseBase(this, _getBlockRegistry)[_getBlockRegistry](u8aToU8a(blockHash)) : {
218
- registry: _classPrivateFieldLooseBase(this, _registryDefault)[_registryDefault]
191
+ } = isScale && blockHash && this.#getBlockRegistry ? await this.#getBlockRegistry(u8aToU8a(blockHash)) : {
192
+ registry: this.#registryDefault
219
193
  };
220
194
 
221
195
  const params = this._formatInputs(registry, null, def, values);
@@ -276,8 +250,7 @@ export class RpcCore {
276
250
  return new Observable(observer => {
277
251
  // Have at least an empty promise, as used in the unsubscribe
278
252
  let subscriptionPromise = Promise.resolve(null);
279
-
280
- const registry = _classPrivateFieldLooseBase(this, _registryDefault)[_registryDefault];
253
+ const registry = this.#registryDefault;
281
254
 
282
255
  const errorHandler = error => {
283
256
  logErrorMessage(method, def, error);
@@ -388,14 +361,13 @@ export class RpcCore {
388
361
  // - if a single result value, don't fill - it is not an update hole
389
362
  // - fallback to an empty option in all cases
390
363
 
391
- const value = isUndefined(found) ? witCache && _classPrivateFieldLooseBase(this, _storageCache)[_storageCache].get(hexKey) || null : found[1];
364
+ const value = isUndefined(found) ? witCache && this.#storageCache.get(hexKey) || null : found[1];
392
365
  const isEmpty = isNull(value);
393
366
  const input = isEmpty || isTreatAsHex(key) ? value : u8aToU8a(value); // store the retrieved result - the only issue with this cache is that there is no
394
367
  // clearing of it, so very long running processes (not just a couple of hours, longer)
395
368
  // will increase memory beyond what is allowed.
396
369
 
397
- _classPrivateFieldLooseBase(this, _storageCache)[_storageCache].set(hexKey, value);
398
-
370
+ this.#storageCache.set(hexKey, value);
399
371
  return this._newType(registry, blockHash, key, input, isEmpty, entryIndex);
400
372
  }
401
373
 
package/package.json CHANGED
@@ -20,17 +20,17 @@
20
20
  "./detectPackage.cjs"
21
21
  ],
22
22
  "type": "module",
23
- "version": "6.6.2-1",
23
+ "version": "6.6.2-13",
24
24
  "main": "index.js",
25
25
  "dependencies": {
26
- "@babel/runtime": "^7.15.4",
27
- "@polkadot/rpc-provider": "6.6.2-1",
28
- "@polkadot/types": "6.6.2-1",
29
- "@polkadot/util": "^7.7.1",
26
+ "@babel/runtime": "^7.16.0",
27
+ "@polkadot/rpc-provider": "6.6.2-13",
28
+ "@polkadot/types": "6.6.2-13",
29
+ "@polkadot/util": "^7.7.2-5",
30
30
  "rxjs": "^7.4.0"
31
31
  },
32
32
  "devDependencies": {
33
- "@polkadot/keyring": "^7.7.1"
33
+ "@polkadot/keyring": "^7.7.2-5"
34
34
  },
35
35
  "exports": {
36
36
  ".": {
package/packageInfo.cjs CHANGED
@@ -9,6 +9,6 @@ exports.packageInfo = void 0;
9
9
  // Auto-generated by @polkadot/dev, do not edit
10
10
  const packageInfo = {
11
11
  name: '@polkadot/rpc-core',
12
- version: '6.6.2-1'
12
+ version: '6.6.2-13'
13
13
  };
14
14
  exports.packageInfo = packageInfo;
package/packageInfo.js CHANGED
@@ -3,5 +3,5 @@
3
3
  // Auto-generated by @polkadot/dev, do not edit
4
4
  export const packageInfo = {
5
5
  name: '@polkadot/rpc-core',
6
- version: '6.6.2-1'
6
+ version: '6.6.2-13'
7
7
  };
package/util/drr.cjs CHANGED
@@ -35,10 +35,13 @@ const NOOP = () => undefined;
35
35
  */
36
36
 
37
37
 
38
- const drr = ({
39
- delay,
40
- skipChange = false,
41
- skipTimeout = false
42
- } = {}) => source$ => source$.pipe((0, _rxjs.catchError)(ERR), skipChange ? (0, _rxjs.tap)(NOOP) : (0, _rxjs.distinctUntilChanged)(CMP), (0, _rxjs.publishReplay)(1), skipTimeout ? (0, _rxjs.refCount)() : (0, _refCountDelay.refCountDelay)(delay));
38
+ const drr = function () {
39
+ let {
40
+ delay,
41
+ skipChange = false,
42
+ skipTimeout = false
43
+ } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
44
+ return source$ => source$.pipe((0, _rxjs.catchError)(ERR), skipChange ? (0, _rxjs.tap)(NOOP) : (0, _rxjs.distinctUntilChanged)(CMP), (0, _rxjs.publishReplay)(1), skipTimeout ? (0, _rxjs.refCount)() : (0, _refCountDelay.refCountDelay)(delay));
45
+ };
43
46
 
44
47
  exports.drr = drr;
package/util/memo.cjs CHANGED
@@ -23,12 +23,18 @@ function memo(instanceId, inner) {
23
23
  const options = {
24
24
  getInstanceId: () => instanceId
25
25
  };
26
- const cached = (0, _util.memoize)((...params) => new _rxjs.Observable(observer => {
27
- const subscription = inner(...params).subscribe(observer);
28
- return () => {
29
- cached.unmemoize(...params);
30
- subscription.unsubscribe();
31
- };
32
- }).pipe((0, _drr.drr)()), options);
26
+ const cached = (0, _util.memoize)(function () {
27
+ for (var _len = arguments.length, params = new Array(_len), _key = 0; _key < _len; _key++) {
28
+ params[_key] = arguments[_key];
29
+ }
30
+
31
+ return new _rxjs.Observable(observer => {
32
+ const subscription = inner(...params).subscribe(observer);
33
+ return () => {
34
+ cached.unmemoize(...params);
35
+ subscription.unsubscribe();
36
+ };
37
+ }).pipe((0, _drr.drr)());
38
+ }, options);
33
39
  return cached;
34
40
  }
@@ -11,7 +11,8 @@ var _rxjs = require("rxjs");
11
11
  // SPDX-License-Identifier: Apache-2.0
12
12
 
13
13
  /** @internal */
14
- function refCountDelay(delay = 1750) {
14
+ function refCountDelay() {
15
+ let delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1750;
15
16
  return source => {
16
17
  // state: 0 = disconnected, 1 = disconnecting, 2 = connecting, 3 = connected
17
18
  let [state, refCount, connection, scheduler] = [0, 0, _rxjs.Subscription.EMPTY, _rxjs.Subscription.EMPTY];