@polkadot/rpc-core 16.2.1 → 16.3.1

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 CHANGED
@@ -51,13 +51,13 @@ function isTreatAsHex(key) {
51
51
  * ```
52
52
  */
53
53
  export class RpcCore {
54
- __internal__instanceId;
55
- __internal__isPedantic;
56
- __internal__registryDefault;
57
- __internal__storageCache;
58
- __internal__storageCacheHits = 0;
59
- __internal__getBlockRegistry;
60
- __internal__getBlockHash;
54
+ #instanceId;
55
+ #isPedantic;
56
+ #registryDefault;
57
+ #storageCache;
58
+ #storageCacheHits = 0;
59
+ #getBlockRegistry;
60
+ #getBlockHash;
61
61
  mapping = new Map();
62
62
  provider;
63
63
  sections = [];
@@ -72,14 +72,14 @@ export class RpcCore {
72
72
  if (!provider || !isFunction(provider.send)) {
73
73
  throw new Error('Expected Provider to API create');
74
74
  }
75
- this.__internal__instanceId = instanceId;
76
- this.__internal__isPedantic = isPedantic;
77
- this.__internal__registryDefault = registry;
75
+ this.#instanceId = instanceId;
76
+ this.#isPedantic = isPedantic;
77
+ this.#registryDefault = registry;
78
78
  this.provider = provider;
79
79
  const sectionNames = Object.keys(rpcDefinitions);
80
80
  // these are the base keys (i.e. part of jsonrpc)
81
81
  this.sections.push(...sectionNames);
82
- this.__internal__storageCache = new LRUCache(rpcCacheCapacity || RPC_CORE_DEFAULT_CAPACITY, ttl);
82
+ this.#storageCache = new LRUCache(rpcCacheCapacity || RPC_CORE_DEFAULT_CAPACITY, ttl);
83
83
  // decorate all interfaces, defined and user on this instance
84
84
  this.addUserInterfaces(userRpc);
85
85
  }
@@ -110,8 +110,8 @@ export class RpcCore {
110
110
  ? {
111
111
  ...stats,
112
112
  core: {
113
- cacheHits: this.__internal__storageCacheHits,
114
- cacheSize: this.__internal__storageCache.length
113
+ cacheHits: this.#storageCacheHits,
114
+ cacheSize: this.#storageCache.length
115
115
  }
116
116
  }
117
117
  : undefined;
@@ -120,16 +120,16 @@ export class RpcCore {
120
120
  * @description Sets a registry swap (typically from Api)
121
121
  */
122
122
  setRegistrySwap(registrySwap) {
123
- this.__internal__getBlockRegistry = memoize(registrySwap, {
124
- getInstanceId: () => this.__internal__instanceId
123
+ this.#getBlockRegistry = memoize(registrySwap, {
124
+ getInstanceId: () => this.#instanceId
125
125
  });
126
126
  }
127
127
  /**
128
128
  * @description Sets a function to resolve block hash from block number
129
129
  */
130
130
  setResolveBlockHash(resolveBlockHash) {
131
- this.__internal__getBlockHash = memoize(resolveBlockHash, {
132
- getInstanceId: () => this.__internal__instanceId
131
+ this.#getBlockHash = memoize(resolveBlockHash, {
132
+ getInstanceId: () => this.#instanceId
133
133
  });
134
134
  }
135
135
  addUserInterfaces(userRpc) {
@@ -157,7 +157,7 @@ export class RpcCore {
157
157
  }
158
158
  }
159
159
  _memomize(creator, def) {
160
- const memoOpts = { getInstanceId: () => this.__internal__instanceId };
160
+ const memoOpts = { getInstanceId: () => this.#instanceId };
161
161
  const memoized = memoize(creator(true), memoOpts);
162
162
  memoized.raw = memoize(creator(false), memoOpts);
163
163
  memoized.meta = def;
@@ -178,11 +178,11 @@ export class RpcCore {
178
178
  ? null
179
179
  : values[hashIndex];
180
180
  const blockHash = blockId && def.params[hashIndex].type === 'BlockNumber'
181
- ? await this.__internal__getBlockHash?.(blockId)
181
+ ? await this.#getBlockHash?.(blockId)
182
182
  : blockId;
183
- const { registry } = isScale && blockHash && this.__internal__getBlockRegistry
184
- ? await this.__internal__getBlockRegistry(u8aToU8a(blockHash))
185
- : { registry: this.__internal__registryDefault };
183
+ const { registry } = isScale && blockHash && this.#getBlockRegistry
184
+ ? await this.#getBlockRegistry(u8aToU8a(blockHash))
185
+ : { registry: this.#registryDefault };
186
186
  const params = this._formatParams(registry, null, def, values);
187
187
  // only cache .at(<blockHash>) queries, e.g. where valid blockHash was supplied
188
188
  const result = await this.provider.send(rpcName, params.map((p) => p.toJSON()), !!blockHash);
@@ -243,7 +243,7 @@ export class RpcCore {
243
243
  return new Observable((observer) => {
244
244
  // Have at least an empty promise, as used in the unsubscribe
245
245
  let subscriptionPromise = Promise.resolve(null);
246
- const registry = this.__internal__registryDefault;
246
+ const registry = this.#registryDefault;
247
247
  const errorHandler = (error) => {
248
248
  logErrorMessage(method, def, error);
249
249
  observer.error(error);
@@ -361,9 +361,9 @@ export class RpcCore {
361
361
  // - if a single result value, don't fill - it is not an update hole
362
362
  // - fallback to an empty option in all cases
363
363
  if (isNotFound && withCache) {
364
- const cached = this.__internal__storageCache.get(hexKey);
364
+ const cached = this.#storageCache.get(hexKey);
365
365
  if (cached) {
366
- this.__internal__storageCacheHits++;
366
+ this.#storageCacheHits++;
367
367
  return cached;
368
368
  }
369
369
  }
@@ -379,7 +379,7 @@ export class RpcCore {
379
379
  return codec;
380
380
  }
381
381
  _setToCache(key, value) {
382
- this.__internal__storageCache.set(key, value);
382
+ this.#storageCache.set(key, value);
383
383
  }
384
384
  _newType(registry, blockHash, key, input, isEmpty, entryIndex = -1) {
385
385
  // single return value (via state.getStorage), decode the value based on the
@@ -399,9 +399,9 @@ export class RpcCore {
399
399
  : hexToU8a(meta.fallback.toHex())
400
400
  : undefined
401
401
  : meta.modifier.isOptional
402
- ? registry.createTypeUnsafe(type, [input], { blockHash, isPedantic: this.__internal__isPedantic })
402
+ ? registry.createTypeUnsafe(type, [input], { blockHash, isPedantic: this.#isPedantic })
403
403
  : input
404
- ], { blockHash, isFallback: isEmpty && !!meta.fallback, isOptional: meta.modifier.isOptional, isPedantic: this.__internal__isPedantic && !meta.modifier.isOptional });
404
+ ], { blockHash, isFallback: isEmpty && !!meta.fallback, isOptional: meta.modifier.isOptional, isPedantic: this.#isPedantic && !meta.modifier.isOptional });
405
405
  }
406
406
  catch (error) {
407
407
  throw new Error(`Unable to decode storage ${key.section || 'unknown'}.${key.method || 'unknown'}:${entryNum}: ${error.message}`);
package/cjs/bundle.js CHANGED
@@ -56,13 +56,13 @@ function isTreatAsHex(key) {
56
56
  * ```
57
57
  */
58
58
  class RpcCore {
59
- __internal__instanceId;
60
- __internal__isPedantic;
61
- __internal__registryDefault;
62
- __internal__storageCache;
63
- __internal__storageCacheHits = 0;
64
- __internal__getBlockRegistry;
65
- __internal__getBlockHash;
59
+ #instanceId;
60
+ #isPedantic;
61
+ #registryDefault;
62
+ #storageCache;
63
+ #storageCacheHits = 0;
64
+ #getBlockRegistry;
65
+ #getBlockHash;
66
66
  mapping = new Map();
67
67
  provider;
68
68
  sections = [];
@@ -77,14 +77,14 @@ class RpcCore {
77
77
  if (!provider || !(0, util_1.isFunction)(provider.send)) {
78
78
  throw new Error('Expected Provider to API create');
79
79
  }
80
- this.__internal__instanceId = instanceId;
81
- this.__internal__isPedantic = isPedantic;
82
- this.__internal__registryDefault = registry;
80
+ this.#instanceId = instanceId;
81
+ this.#isPedantic = isPedantic;
82
+ this.#registryDefault = registry;
83
83
  this.provider = provider;
84
84
  const sectionNames = Object.keys(types_1.rpcDefinitions);
85
85
  // these are the base keys (i.e. part of jsonrpc)
86
86
  this.sections.push(...sectionNames);
87
- this.__internal__storageCache = new rpc_provider_1.LRUCache(rpcCacheCapacity || RPC_CORE_DEFAULT_CAPACITY, ttl);
87
+ this.#storageCache = new rpc_provider_1.LRUCache(rpcCacheCapacity || RPC_CORE_DEFAULT_CAPACITY, ttl);
88
88
  // decorate all interfaces, defined and user on this instance
89
89
  this.addUserInterfaces(userRpc);
90
90
  }
@@ -115,8 +115,8 @@ class RpcCore {
115
115
  ? {
116
116
  ...stats,
117
117
  core: {
118
- cacheHits: this.__internal__storageCacheHits,
119
- cacheSize: this.__internal__storageCache.length
118
+ cacheHits: this.#storageCacheHits,
119
+ cacheSize: this.#storageCache.length
120
120
  }
121
121
  }
122
122
  : undefined;
@@ -125,16 +125,16 @@ class RpcCore {
125
125
  * @description Sets a registry swap (typically from Api)
126
126
  */
127
127
  setRegistrySwap(registrySwap) {
128
- this.__internal__getBlockRegistry = (0, util_1.memoize)(registrySwap, {
129
- getInstanceId: () => this.__internal__instanceId
128
+ this.#getBlockRegistry = (0, util_1.memoize)(registrySwap, {
129
+ getInstanceId: () => this.#instanceId
130
130
  });
131
131
  }
132
132
  /**
133
133
  * @description Sets a function to resolve block hash from block number
134
134
  */
135
135
  setResolveBlockHash(resolveBlockHash) {
136
- this.__internal__getBlockHash = (0, util_1.memoize)(resolveBlockHash, {
137
- getInstanceId: () => this.__internal__instanceId
136
+ this.#getBlockHash = (0, util_1.memoize)(resolveBlockHash, {
137
+ getInstanceId: () => this.#instanceId
138
138
  });
139
139
  }
140
140
  addUserInterfaces(userRpc) {
@@ -162,7 +162,7 @@ class RpcCore {
162
162
  }
163
163
  }
164
164
  _memomize(creator, def) {
165
- const memoOpts = { getInstanceId: () => this.__internal__instanceId };
165
+ const memoOpts = { getInstanceId: () => this.#instanceId };
166
166
  const memoized = (0, util_1.memoize)(creator(true), memoOpts);
167
167
  memoized.raw = (0, util_1.memoize)(creator(false), memoOpts);
168
168
  memoized.meta = def;
@@ -183,11 +183,11 @@ class RpcCore {
183
183
  ? null
184
184
  : values[hashIndex];
185
185
  const blockHash = blockId && def.params[hashIndex].type === 'BlockNumber'
186
- ? await this.__internal__getBlockHash?.(blockId)
186
+ ? await this.#getBlockHash?.(blockId)
187
187
  : blockId;
188
- const { registry } = isScale && blockHash && this.__internal__getBlockRegistry
189
- ? await this.__internal__getBlockRegistry((0, util_1.u8aToU8a)(blockHash))
190
- : { registry: this.__internal__registryDefault };
188
+ const { registry } = isScale && blockHash && this.#getBlockRegistry
189
+ ? await this.#getBlockRegistry((0, util_1.u8aToU8a)(blockHash))
190
+ : { registry: this.#registryDefault };
191
191
  const params = this._formatParams(registry, null, def, values);
192
192
  // only cache .at(<blockHash>) queries, e.g. where valid blockHash was supplied
193
193
  const result = await this.provider.send(rpcName, params.map((p) => p.toJSON()), !!blockHash);
@@ -248,7 +248,7 @@ class RpcCore {
248
248
  return new rxjs_1.Observable((observer) => {
249
249
  // Have at least an empty promise, as used in the unsubscribe
250
250
  let subscriptionPromise = Promise.resolve(null);
251
- const registry = this.__internal__registryDefault;
251
+ const registry = this.#registryDefault;
252
252
  const errorHandler = (error) => {
253
253
  logErrorMessage(method, def, error);
254
254
  observer.error(error);
@@ -366,9 +366,9 @@ class RpcCore {
366
366
  // - if a single result value, don't fill - it is not an update hole
367
367
  // - fallback to an empty option in all cases
368
368
  if (isNotFound && withCache) {
369
- const cached = this.__internal__storageCache.get(hexKey);
369
+ const cached = this.#storageCache.get(hexKey);
370
370
  if (cached) {
371
- this.__internal__storageCacheHits++;
371
+ this.#storageCacheHits++;
372
372
  return cached;
373
373
  }
374
374
  }
@@ -384,7 +384,7 @@ class RpcCore {
384
384
  return codec;
385
385
  }
386
386
  _setToCache(key, value) {
387
- this.__internal__storageCache.set(key, value);
387
+ this.#storageCache.set(key, value);
388
388
  }
389
389
  _newType(registry, blockHash, key, input, isEmpty, entryIndex = -1) {
390
390
  // single return value (via state.getStorage), decode the value based on the
@@ -404,9 +404,9 @@ class RpcCore {
404
404
  : (0, util_1.hexToU8a)(meta.fallback.toHex())
405
405
  : undefined
406
406
  : meta.modifier.isOptional
407
- ? registry.createTypeUnsafe(type, [input], { blockHash, isPedantic: this.__internal__isPedantic })
407
+ ? registry.createTypeUnsafe(type, [input], { blockHash, isPedantic: this.#isPedantic })
408
408
  : input
409
- ], { blockHash, isFallback: isEmpty && !!meta.fallback, isOptional: meta.modifier.isOptional, isPedantic: this.__internal__isPedantic && !meta.modifier.isOptional });
409
+ ], { blockHash, isFallback: isEmpty && !!meta.fallback, isOptional: meta.modifier.isOptional, isPedantic: this.#isPedantic && !meta.modifier.isOptional });
410
410
  }
411
411
  catch (error) {
412
412
  throw new Error(`Unable to decode storage ${key.section || 'unknown'}.${key.method || 'unknown'}:${entryNum}: ${error.message}`);
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.packageInfo = void 0;
4
- exports.packageInfo = { name: '@polkadot/rpc-core', path: typeof __dirname === 'string' ? __dirname : 'auto', type: 'cjs', version: '16.2.1' };
4
+ exports.packageInfo = { name: '@polkadot/rpc-core', path: typeof __dirname === 'string' ? __dirname : 'auto', type: 'cjs', version: '16.3.1' };
package/package.json CHANGED
@@ -18,7 +18,7 @@
18
18
  "./cjs/packageDetect.js"
19
19
  ],
20
20
  "type": "module",
21
- "version": "16.2.1",
21
+ "version": "16.3.1",
22
22
  "main": "./cjs/index.js",
23
23
  "module": "./index.js",
24
24
  "types": "./index.d.ts",
@@ -199,10 +199,10 @@
199
199
  }
200
200
  },
201
201
  "dependencies": {
202
- "@polkadot/rpc-augment": "16.2.1",
203
- "@polkadot/rpc-provider": "16.2.1",
204
- "@polkadot/types": "16.2.1",
205
- "@polkadot/util": "^13.5.1",
202
+ "@polkadot/rpc-augment": "16.3.1",
203
+ "@polkadot/rpc-provider": "16.3.1",
204
+ "@polkadot/types": "16.3.1",
205
+ "@polkadot/util": "^13.5.3",
206
206
  "rxjs": "^7.8.1",
207
207
  "tslib": "^2.8.1"
208
208
  }
package/packageInfo.js CHANGED
@@ -1 +1 @@
1
- export const packageInfo = { name: '@polkadot/rpc-core', path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto', type: 'esm', version: '16.2.1' };
1
+ export const packageInfo = { name: '@polkadot/rpc-core', path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto', type: 'esm', version: '16.3.1' };