@polkadot/rpc-core 14.2.3 → 15.0.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.d.ts CHANGED
@@ -6,6 +6,10 @@ export * from './util/index.js';
6
6
  interface Options {
7
7
  isPedantic?: boolean;
8
8
  provider: ProviderInterface;
9
+ /**
10
+ * Custom size of the rpc LRUCache capacity. Defaults to `RPC_CORE_DEFAULT_CAPACITY` (1024 * 10 * 10)
11
+ */
12
+ rpcCacheCapacity?: number;
9
13
  userRpc?: Record<string, Record<string, DefinitionRpc | DefinitionRpcSub>>;
10
14
  }
11
15
  /**
@@ -39,9 +43,11 @@ export declare class RpcCore {
39
43
  /**
40
44
  * @constructor
41
45
  * Default constructor for the core RPC handler
42
- * @param {ProviderInterface} provider An API provider using any of the supported providers (HTTP, SC or WebSocket)
46
+ * @param {Registry} registry Type Registry
47
+ * @param {ProviderInterface} options.provider An API provider using any of the supported providers (HTTP, SC or WebSocket)
48
+ * @param {number} [options.rpcCacheCapacity] Custom size of the rpc LRUCache capacity. Defaults to `RPC_CORE_DEFAULT_CAPACITY` (1024 * 10 * 10)
43
49
  */
44
- constructor(instanceId: string, registry: Registry, { isPedantic, provider, userRpc }: Options);
50
+ constructor(instanceId: string, registry: Registry, { isPedantic, provider, rpcCacheCapacity, userRpc }: Options);
45
51
  /**
46
52
  * @description Returns the connected status of a provider
47
53
  */
package/bundle.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Observable, publishReplay, refCount } from 'rxjs';
2
- import { DEFAULT_CAPACITY, LRUCache } from '@polkadot/rpc-provider';
2
+ import { LRUCache } from '@polkadot/rpc-provider';
3
3
  import { rpcDefinitions } from '@polkadot/types';
4
4
  import { hexToU8a, isFunction, isNull, isUndefined, lazyMethod, logger, memoize, objectSpread, u8aConcat, u8aToU8a } from '@polkadot/util';
5
5
  import { drr, refCountDelay } from './util/index.js';
@@ -14,6 +14,7 @@ const EMPTY_META = {
14
14
  isMap: false
15
15
  }
16
16
  };
17
+ const RPC_CORE_DEFAULT_CAPACITY = 1024 * 10 * 10;
17
18
  /** @internal */
18
19
  function logErrorMessage(method, { noErrorLog, params, type }, error) {
19
20
  if (noErrorLog) {
@@ -63,9 +64,11 @@ export class RpcCore {
63
64
  /**
64
65
  * @constructor
65
66
  * Default constructor for the core RPC handler
66
- * @param {ProviderInterface} provider An API provider using any of the supported providers (HTTP, SC or WebSocket)
67
+ * @param {Registry} registry Type Registry
68
+ * @param {ProviderInterface} options.provider An API provider using any of the supported providers (HTTP, SC or WebSocket)
69
+ * @param {number} [options.rpcCacheCapacity] Custom size of the rpc LRUCache capacity. Defaults to `RPC_CORE_DEFAULT_CAPACITY` (1024 * 10 * 10)
67
70
  */
68
- constructor(instanceId, registry, { isPedantic = true, provider, userRpc = {} }) {
71
+ constructor(instanceId, registry, { isPedantic = true, provider, rpcCacheCapacity, userRpc = {} }) {
69
72
  if (!provider || !isFunction(provider.send)) {
70
73
  throw new Error('Expected Provider to API create');
71
74
  }
@@ -76,7 +79,7 @@ export class RpcCore {
76
79
  const sectionNames = Object.keys(rpcDefinitions);
77
80
  // these are the base keys (i.e. part of jsonrpc)
78
81
  this.sections.push(...sectionNames);
79
- this.__internal__storageCache = new LRUCache(DEFAULT_CAPACITY * 10 * 10);
82
+ this.__internal__storageCache = new LRUCache(rpcCacheCapacity || RPC_CORE_DEFAULT_CAPACITY);
80
83
  // decorate all interfaces, defined and user on this instance
81
84
  this.addUserInterfaces(userRpc);
82
85
  }
package/cjs/bundle.d.ts CHANGED
@@ -6,6 +6,10 @@ export * from './util/index.js';
6
6
  interface Options {
7
7
  isPedantic?: boolean;
8
8
  provider: ProviderInterface;
9
+ /**
10
+ * Custom size of the rpc LRUCache capacity. Defaults to `RPC_CORE_DEFAULT_CAPACITY` (1024 * 10 * 10)
11
+ */
12
+ rpcCacheCapacity?: number;
9
13
  userRpc?: Record<string, Record<string, DefinitionRpc | DefinitionRpcSub>>;
10
14
  }
11
15
  /**
@@ -39,9 +43,11 @@ export declare class RpcCore {
39
43
  /**
40
44
  * @constructor
41
45
  * Default constructor for the core RPC handler
42
- * @param {ProviderInterface} provider An API provider using any of the supported providers (HTTP, SC or WebSocket)
46
+ * @param {Registry} registry Type Registry
47
+ * @param {ProviderInterface} options.provider An API provider using any of the supported providers (HTTP, SC or WebSocket)
48
+ * @param {number} [options.rpcCacheCapacity] Custom size of the rpc LRUCache capacity. Defaults to `RPC_CORE_DEFAULT_CAPACITY` (1024 * 10 * 10)
43
49
  */
44
- constructor(instanceId: string, registry: Registry, { isPedantic, provider, userRpc }: Options);
50
+ constructor(instanceId: string, registry: Registry, { isPedantic, provider, rpcCacheCapacity, userRpc }: Options);
45
51
  /**
46
52
  * @description Returns the connected status of a provider
47
53
  */
package/cjs/bundle.js CHANGED
@@ -19,6 +19,7 @@ const EMPTY_META = {
19
19
  isMap: false
20
20
  }
21
21
  };
22
+ const RPC_CORE_DEFAULT_CAPACITY = 1024 * 10 * 10;
22
23
  /** @internal */
23
24
  function logErrorMessage(method, { noErrorLog, params, type }, error) {
24
25
  if (noErrorLog) {
@@ -68,9 +69,11 @@ class RpcCore {
68
69
  /**
69
70
  * @constructor
70
71
  * Default constructor for the core RPC handler
71
- * @param {ProviderInterface} provider An API provider using any of the supported providers (HTTP, SC or WebSocket)
72
+ * @param {Registry} registry Type Registry
73
+ * @param {ProviderInterface} options.provider An API provider using any of the supported providers (HTTP, SC or WebSocket)
74
+ * @param {number} [options.rpcCacheCapacity] Custom size of the rpc LRUCache capacity. Defaults to `RPC_CORE_DEFAULT_CAPACITY` (1024 * 10 * 10)
72
75
  */
73
- constructor(instanceId, registry, { isPedantic = true, provider, userRpc = {} }) {
76
+ constructor(instanceId, registry, { isPedantic = true, provider, rpcCacheCapacity, userRpc = {} }) {
74
77
  if (!provider || !(0, util_1.isFunction)(provider.send)) {
75
78
  throw new Error('Expected Provider to API create');
76
79
  }
@@ -81,7 +84,7 @@ class RpcCore {
81
84
  const sectionNames = Object.keys(types_1.rpcDefinitions);
82
85
  // these are the base keys (i.e. part of jsonrpc)
83
86
  this.sections.push(...sectionNames);
84
- this.__internal__storageCache = new rpc_provider_1.LRUCache(rpc_provider_1.DEFAULT_CAPACITY * 10 * 10);
87
+ this.__internal__storageCache = new rpc_provider_1.LRUCache(rpcCacheCapacity || RPC_CORE_DEFAULT_CAPACITY);
85
88
  // decorate all interfaces, defined and user on this instance
86
89
  this.addUserInterfaces(userRpc);
87
90
  }
@@ -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: '14.2.3' };
4
+ exports.packageInfo = { name: '@polkadot/rpc-core', path: typeof __dirname === 'string' ? __dirname : 'auto', type: 'cjs', version: '15.0.1' };
package/package.json CHANGED
@@ -18,7 +18,7 @@
18
18
  "./cjs/packageDetect.js"
19
19
  ],
20
20
  "type": "module",
21
- "version": "14.2.3",
21
+ "version": "15.0.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": "14.2.3",
203
- "@polkadot/rpc-provider": "14.2.3",
204
- "@polkadot/types": "14.2.3",
205
- "@polkadot/util": "^13.2.2",
202
+ "@polkadot/rpc-augment": "15.0.1",
203
+ "@polkadot/rpc-provider": "15.0.1",
204
+ "@polkadot/types": "15.0.1",
205
+ "@polkadot/util": "^13.2.3",
206
206
  "rxjs": "^7.8.1",
207
207
  "tslib": "^2.8.0"
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: '14.2.3' };
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: '15.0.1' };