@polkadot/rpc-core 7.8.2-9 → 7.9.2-2

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
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
@@ -17,10 +15,6 @@ Object.defineProperty(exports, "packageInfo", {
17
15
  }
18
16
  });
19
17
 
20
- var _classPrivateFieldLooseBase2 = _interopRequireDefault(require("@babel/runtime/helpers/classPrivateFieldLooseBase"));
21
-
22
- var _classPrivateFieldLooseKey2 = _interopRequireDefault(require("@babel/runtime/helpers/classPrivateFieldLooseKey"));
23
-
24
18
  var _rxjs = require("rxjs");
25
19
 
26
20
  var _types = require("@polkadot/types");
@@ -109,51 +103,26 @@ function isTreatAsHex(key) {
109
103
  */
110
104
 
111
105
 
112
- var _instanceId = /*#__PURE__*/(0, _classPrivateFieldLooseKey2.default)("instanceId");
113
-
114
- var _registryDefault = /*#__PURE__*/(0, _classPrivateFieldLooseKey2.default)("registryDefault");
115
-
116
- var _getBlockRegistry = /*#__PURE__*/(0, _classPrivateFieldLooseKey2.default)("getBlockRegistry");
117
-
118
- var _getBlockHash = /*#__PURE__*/(0, _classPrivateFieldLooseKey2.default)("getBlockHash");
119
-
120
- var _storageCache = /*#__PURE__*/(0, _classPrivateFieldLooseKey2.default)("storageCache");
121
-
122
106
  class RpcCore {
107
+ #instanceId;
108
+ #registryDefault;
109
+ #getBlockRegistry;
110
+ #getBlockHash;
111
+ #storageCache = new Map();
112
+ mapping = new Map();
113
+ sections = [];
123
114
  /**
124
115
  * @constructor
125
116
  * Default constructor for the Api Object
126
117
  * @param {ProviderInterface} provider An API provider using HTTP or WebSocket
127
118
  */
119
+
128
120
  constructor(instanceId, registry, provider) {
129
121
  let userRpc = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
130
- Object.defineProperty(this, _instanceId, {
131
- writable: true,
132
- value: void 0
133
- });
134
- Object.defineProperty(this, _registryDefault, {
135
- writable: true,
136
- value: void 0
137
- });
138
- Object.defineProperty(this, _getBlockRegistry, {
139
- writable: true,
140
- value: void 0
141
- });
142
- Object.defineProperty(this, _getBlockHash, {
143
- writable: true,
144
- value: void 0
145
- });
146
- Object.defineProperty(this, _storageCache, {
147
- writable: true,
148
- value: new Map()
149
- });
150
- this.mapping = new Map();
151
- this.provider = void 0;
152
- this.sections = [];
153
122
  // eslint-disable-next-line @typescript-eslint/unbound-method
154
123
  (0, _util.assert)(provider && (0, _util.isFunction)(provider.send), 'Expected Provider to API create');
155
- (0, _classPrivateFieldLooseBase2.default)(this, _instanceId)[_instanceId] = instanceId;
156
- (0, _classPrivateFieldLooseBase2.default)(this, _registryDefault)[_registryDefault] = registry;
124
+ this.#instanceId = instanceId;
125
+ this.#registryDefault = registry;
157
126
  this.provider = provider;
158
127
  const sectionNames = Object.keys(_types.rpcDefinitions); // these are the base keys (i.e. part of jsonrpc)
159
128
 
@@ -191,8 +160,8 @@ class RpcCore {
191
160
 
192
161
 
193
162
  setRegistrySwap(registrySwap) {
194
- (0, _classPrivateFieldLooseBase2.default)(this, _getBlockRegistry)[_getBlockRegistry] = (0, _util.memoize)(registrySwap, {
195
- getInstanceId: () => (0, _classPrivateFieldLooseBase2.default)(this, _instanceId)[_instanceId]
163
+ this.#getBlockRegistry = (0, _util.memoize)(registrySwap, {
164
+ getInstanceId: () => this.#instanceId
196
165
  });
197
166
  }
198
167
  /**
@@ -201,8 +170,8 @@ class RpcCore {
201
170
 
202
171
 
203
172
  setResolveBlockHash(resolveBlockHash) {
204
- (0, _classPrivateFieldLooseBase2.default)(this, _getBlockHash)[_getBlockHash] = (0, _util.memoize)(resolveBlockHash, {
205
- getInstanceId: () => (0, _classPrivateFieldLooseBase2.default)(this, _instanceId)[_instanceId]
173
+ this.#getBlockHash = (0, _util.memoize)(resolveBlockHash, {
174
+ getInstanceId: () => this.#instanceId
206
175
  });
207
176
  }
208
177
 
@@ -241,7 +210,7 @@ class RpcCore {
241
210
 
242
211
  _memomize(creator, def) {
243
212
  const memoOpts = {
244
- getInstanceId: () => (0, _classPrivateFieldLooseBase2.default)(this, _instanceId)[_instanceId]
213
+ getInstanceId: () => this.#instanceId
245
214
  };
246
215
  const memoized = (0, _util.memoize)(creator(true), memoOpts);
247
216
  memoized.raw = (0, _util.memoize)(creator(false), memoOpts);
@@ -264,14 +233,14 @@ class RpcCore {
264
233
  let memoized = null; // execute the RPC call, doing a registry swap for historic as applicable
265
234
 
266
235
  const callWithRegistry = async (isScale, values) => {
267
- var _classPrivateFieldLoo, _classPrivateFieldLoo2;
236
+ var _this$getBlockHash;
268
237
 
269
238
  const blockId = hashIndex === -1 ? null : values[hashIndex];
270
- const blockHash = blockId && def.params[hashIndex].type === 'BlockNumber' ? await ((_classPrivateFieldLoo = (_classPrivateFieldLoo2 = (0, _classPrivateFieldLooseBase2.default)(this, _getBlockHash))[_getBlockHash]) === null || _classPrivateFieldLoo === void 0 ? void 0 : _classPrivateFieldLoo.call(_classPrivateFieldLoo2, blockId)) : blockId;
239
+ const blockHash = blockId && def.params[hashIndex].type === 'BlockNumber' ? await ((_this$getBlockHash = this.#getBlockHash) === null || _this$getBlockHash === void 0 ? void 0 : _this$getBlockHash.call(this, blockId)) : blockId;
271
240
  const {
272
241
  registry
273
- } = isScale && blockHash && (0, _classPrivateFieldLooseBase2.default)(this, _getBlockRegistry)[_getBlockRegistry] ? await (0, _classPrivateFieldLooseBase2.default)(this, _getBlockRegistry)[_getBlockRegistry]((0, _util.u8aToU8a)(blockHash)) : {
274
- registry: (0, _classPrivateFieldLooseBase2.default)(this, _registryDefault)[_registryDefault]
242
+ } = isScale && blockHash && this.#getBlockRegistry ? await this.#getBlockRegistry((0, _util.u8aToU8a)(blockHash)) : {
243
+ registry: this.#registryDefault
275
244
  };
276
245
 
277
246
  const params = this._formatInputs(registry, null, def, values); // only cache .at(<blockHash>) queries, e.g. where valid blockHash was supplied
@@ -350,8 +319,7 @@ class RpcCore {
350
319
  return new _rxjs.Observable(observer => {
351
320
  // Have at least an empty promise, as used in the unsubscribe
352
321
  let subscriptionPromise = Promise.resolve(null);
353
-
354
- const registry = (0, _classPrivateFieldLooseBase2.default)(_this, _registryDefault)[_registryDefault];
322
+ const registry = _this.#registryDefault;
355
323
 
356
324
  const errorHandler = error => {
357
325
  logErrorMessage(method, def, error);
@@ -478,14 +446,13 @@ class RpcCore {
478
446
  // - if a single result value, don't fill - it is not an update hole
479
447
  // - fallback to an empty option in all cases
480
448
 
481
- const value = (0, _util.isUndefined)(found) ? witCache && (0, _classPrivateFieldLooseBase2.default)(this, _storageCache)[_storageCache].get(hexKey) || null : found[1];
449
+ const value = (0, _util.isUndefined)(found) ? witCache && this.#storageCache.get(hexKey) || null : found[1];
482
450
  const isEmpty = (0, _util.isNull)(value);
483
451
  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
484
452
  // clearing of it, so very long running processes (not just a couple of hours, longer)
485
453
  // will increase memory beyond what is allowed.
486
454
 
487
- (0, _classPrivateFieldLooseBase2.default)(this, _storageCache)[_storageCache].set(hexKey, value);
488
-
455
+ this.#storageCache.set(hexKey, value);
489
456
  return this._newType(registry, blockHash, key, input, isEmpty, entryIndex);
490
457
  }
491
458
 
package/package.json CHANGED
@@ -20,7 +20,7 @@
20
20
  "./detectPackage.cjs"
21
21
  ],
22
22
  "type": "module",
23
- "version": "7.8.2-9",
23
+ "version": "7.9.2-2",
24
24
  "main": "index.cjs",
25
25
  "module": "index.js",
26
26
  "types": "index.d.ts",
@@ -91,9 +91,9 @@
91
91
  },
92
92
  "dependencies": {
93
93
  "@babel/runtime": "^7.17.2",
94
- "@polkadot/rpc-augment": "7.8.2-9",
95
- "@polkadot/rpc-provider": "7.8.2-9",
96
- "@polkadot/types": "7.8.2-9",
94
+ "@polkadot/rpc-augment": "7.9.2-2",
95
+ "@polkadot/rpc-provider": "7.9.2-2",
96
+ "@polkadot/types": "7.9.2-2",
97
97
  "@polkadot/util": "^8.4.1",
98
98
  "rxjs": "^7.5.4"
99
99
  }
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.8.2-9'
14
+ version: '7.9.2-2'
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.8.2-9'
8
+ version: '7.9.2-2'
9
9
  };