@polkadot/rpc-core 10.0.1 → 10.1.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 +2 -2
- package/bundle.js +27 -25
- package/cjs/bundle.js +6 -6
- package/cjs/detectPackage.js +3 -3
- package/cjs/index.js +2 -2
- package/cjs/packageInfo.js +1 -1
- package/cjs/types/index.js +1 -1
- package/cjs/util/drr.js +2 -2
- package/cjs/util/index.js +3 -3
- package/cjs/util/memo.js +2 -2
- package/index.d.ts +2 -2
- package/package.json +5 -5
- package/packageInfo.js +1 -1
- package/types/index.d.ts +1 -1
- package/util/index.d.ts +3 -3
package/bundle.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ProviderInterface } from '@polkadot/rpc-provider/types';
|
|
2
2
|
import type { AnyNumber, DefinitionRpc, DefinitionRpcExt, DefinitionRpcSub, Registry } from '@polkadot/types/types';
|
|
3
|
-
export { packageInfo } from './packageInfo';
|
|
4
|
-
export * from './util';
|
|
3
|
+
export { packageInfo } from './packageInfo.js';
|
|
4
|
+
export * from './util/index.js';
|
|
5
5
|
/**
|
|
6
6
|
* @name Rpc
|
|
7
7
|
* @summary The API may use a HTTP or WebSockets provider.
|
package/bundle.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
var _RpcCore_instanceId, _RpcCore_registryDefault, _RpcCore_getBlockRegistry, _RpcCore_getBlockHash, _RpcCore_storageCache;
|
|
2
|
+
import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
|
|
1
3
|
import { Observable, publishReplay, refCount } from 'rxjs';
|
|
2
4
|
import { rpcDefinitions } from '@polkadot/types';
|
|
3
5
|
import { hexToU8a, isFunction, isNull, isUndefined, lazyMethod, logger, memoize, objectSpread, u8aConcat, u8aToU8a } from '@polkadot/util';
|
|
@@ -50,26 +52,25 @@ function isTreatAsHex(key) {
|
|
|
50
52
|
* ```
|
|
51
53
|
*/
|
|
52
54
|
export class RpcCore {
|
|
53
|
-
#instanceId;
|
|
54
|
-
#registryDefault;
|
|
55
|
-
#getBlockRegistry;
|
|
56
|
-
#getBlockHash;
|
|
57
|
-
#storageCache = new Map();
|
|
58
|
-
mapping = new Map();
|
|
59
|
-
provider;
|
|
60
|
-
sections = [];
|
|
61
55
|
/**
|
|
62
56
|
* @constructor
|
|
63
57
|
* Default constructor for the Api Object
|
|
64
58
|
* @param {ProviderInterface} provider An API provider using HTTP or WebSocket
|
|
65
59
|
*/
|
|
66
60
|
constructor(instanceId, registry, provider, userRpc = {}) {
|
|
61
|
+
_RpcCore_instanceId.set(this, void 0);
|
|
62
|
+
_RpcCore_registryDefault.set(this, void 0);
|
|
63
|
+
_RpcCore_getBlockRegistry.set(this, void 0);
|
|
64
|
+
_RpcCore_getBlockHash.set(this, void 0);
|
|
65
|
+
_RpcCore_storageCache.set(this, new Map());
|
|
66
|
+
this.mapping = new Map();
|
|
67
|
+
this.sections = [];
|
|
67
68
|
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
68
69
|
if (!provider || !isFunction(provider.send)) {
|
|
69
70
|
throw new Error('Expected Provider to API create');
|
|
70
71
|
}
|
|
71
|
-
this
|
|
72
|
-
this
|
|
72
|
+
__classPrivateFieldSet(this, _RpcCore_instanceId, instanceId, "f");
|
|
73
|
+
__classPrivateFieldSet(this, _RpcCore_registryDefault, registry, "f");
|
|
73
74
|
this.provider = provider;
|
|
74
75
|
const sectionNames = Object.keys(rpcDefinitions);
|
|
75
76
|
// these are the base keys (i.e. part of jsonrpc)
|
|
@@ -99,17 +100,17 @@ export class RpcCore {
|
|
|
99
100
|
* @description Sets a registry swap (typically from Api)
|
|
100
101
|
*/
|
|
101
102
|
setRegistrySwap(registrySwap) {
|
|
102
|
-
this
|
|
103
|
-
getInstanceId: () => this
|
|
104
|
-
});
|
|
103
|
+
__classPrivateFieldSet(this, _RpcCore_getBlockRegistry, memoize(registrySwap, {
|
|
104
|
+
getInstanceId: () => __classPrivateFieldGet(this, _RpcCore_instanceId, "f")
|
|
105
|
+
}), "f");
|
|
105
106
|
}
|
|
106
107
|
/**
|
|
107
108
|
* @description Sets a function to resolve block hash from block number
|
|
108
109
|
*/
|
|
109
110
|
setResolveBlockHash(resolveBlockHash) {
|
|
110
|
-
this
|
|
111
|
-
getInstanceId: () => this
|
|
112
|
-
});
|
|
111
|
+
__classPrivateFieldSet(this, _RpcCore_getBlockHash, memoize(resolveBlockHash, {
|
|
112
|
+
getInstanceId: () => __classPrivateFieldGet(this, _RpcCore_instanceId, "f")
|
|
113
|
+
}), "f");
|
|
113
114
|
}
|
|
114
115
|
addUserInterfaces(userRpc) {
|
|
115
116
|
// add any extra user-defined sections
|
|
@@ -136,7 +137,7 @@ export class RpcCore {
|
|
|
136
137
|
}
|
|
137
138
|
}
|
|
138
139
|
_memomize(creator, def) {
|
|
139
|
-
const memoOpts = { getInstanceId: () => this
|
|
140
|
+
const memoOpts = { getInstanceId: () => __classPrivateFieldGet(this, _RpcCore_instanceId, "f") };
|
|
140
141
|
const memoized = memoize(creator(true), memoOpts);
|
|
141
142
|
memoized.raw = memoize(creator(false), memoOpts);
|
|
142
143
|
memoized.meta = def;
|
|
@@ -157,11 +158,11 @@ export class RpcCore {
|
|
|
157
158
|
? null
|
|
158
159
|
: values[hashIndex];
|
|
159
160
|
const blockHash = blockId && def.params[hashIndex].type === 'BlockNumber'
|
|
160
|
-
? await this
|
|
161
|
+
? await __classPrivateFieldGet(this, _RpcCore_getBlockHash, "f")?.call(this, blockId)
|
|
161
162
|
: blockId;
|
|
162
|
-
const { registry } = isScale && blockHash && this
|
|
163
|
-
? await this
|
|
164
|
-
: { registry: this
|
|
163
|
+
const { registry } = isScale && blockHash && __classPrivateFieldGet(this, _RpcCore_getBlockRegistry, "f")
|
|
164
|
+
? await __classPrivateFieldGet(this, _RpcCore_getBlockRegistry, "f").call(this, u8aToU8a(blockHash))
|
|
165
|
+
: { registry: __classPrivateFieldGet(this, _RpcCore_registryDefault, "f") };
|
|
165
166
|
const params = this._formatInputs(registry, null, def, values);
|
|
166
167
|
// only cache .at(<blockHash>) queries, e.g. where valid blockHash was supplied
|
|
167
168
|
const result = await this.provider.send(rpcName, params.map((p) => p.toJSON()), !!blockHash);
|
|
@@ -222,7 +223,7 @@ export class RpcCore {
|
|
|
222
223
|
return new Observable((observer) => {
|
|
223
224
|
// Have at least an empty promise, as used in the unsubscribe
|
|
224
225
|
let subscriptionPromise = Promise.resolve(null);
|
|
225
|
-
const registry = this
|
|
226
|
+
const registry = __classPrivateFieldGet(this, _RpcCore_registryDefault, "f");
|
|
226
227
|
const errorHandler = (error) => {
|
|
227
228
|
logErrorMessage(method, def, error);
|
|
228
229
|
observer.error(error);
|
|
@@ -333,7 +334,7 @@ export class RpcCore {
|
|
|
333
334
|
// - if a single result value, don't fill - it is not an update hole
|
|
334
335
|
// - fallback to an empty option in all cases
|
|
335
336
|
if (isNotFound && withCache) {
|
|
336
|
-
const cached = this
|
|
337
|
+
const cached = __classPrivateFieldGet(this, _RpcCore_storageCache, "f").get(hexKey);
|
|
337
338
|
if (cached) {
|
|
338
339
|
return cached;
|
|
339
340
|
}
|
|
@@ -349,7 +350,7 @@ export class RpcCore {
|
|
|
349
350
|
// store the retrieved result - the only issue with this cache is that there is no
|
|
350
351
|
// clearing of it, so very long running processes (not just a couple of hours, longer)
|
|
351
352
|
// will increase memory beyond what is allowed.
|
|
352
|
-
this
|
|
353
|
+
__classPrivateFieldGet(this, _RpcCore_storageCache, "f").set(hexKey, codec);
|
|
353
354
|
return codec;
|
|
354
355
|
}
|
|
355
356
|
_newType(registry, blockHash, key, input, isEmpty, entryIndex = -1) {
|
|
@@ -378,4 +379,5 @@ export class RpcCore {
|
|
|
378
379
|
throw new Error(`Unable to decode storage ${key.section || 'unknown'}.${key.method || 'unknown'}:${entryNum}: ${error.message}`);
|
|
379
380
|
}
|
|
380
381
|
}
|
|
381
|
-
}
|
|
382
|
+
}
|
|
383
|
+
_RpcCore_instanceId = new WeakMap(), _RpcCore_registryDefault = new WeakMap(), _RpcCore_getBlockRegistry = new WeakMap(), _RpcCore_getBlockHash = new WeakMap(), _RpcCore_storageCache = new WeakMap();
|
package/cjs/bundle.js
CHANGED
|
@@ -6,10 +6,10 @@ const tslib_1 = require("tslib");
|
|
|
6
6
|
const rxjs_1 = require("rxjs");
|
|
7
7
|
const types_1 = require("@polkadot/types");
|
|
8
8
|
const util_1 = require("@polkadot/util");
|
|
9
|
-
const
|
|
10
|
-
var
|
|
11
|
-
Object.defineProperty(exports, "packageInfo", { enumerable: true, get: function () { return
|
|
12
|
-
tslib_1.__exportStar(require("./util"), exports);
|
|
9
|
+
const index_js_1 = require("./util/index.js");
|
|
10
|
+
var packageInfo_js_1 = require("./packageInfo.js");
|
|
11
|
+
Object.defineProperty(exports, "packageInfo", { enumerable: true, get: function () { return packageInfo_js_1.packageInfo; } });
|
|
12
|
+
tslib_1.__exportStar(require("./util/index.js"), exports);
|
|
13
13
|
const l = (0, util_1.logger)('rpc-core');
|
|
14
14
|
const EMPTY_META = {
|
|
15
15
|
fallback: undefined,
|
|
@@ -198,7 +198,7 @@ class RpcCore {
|
|
|
198
198
|
// eslint-disable-next-line deprecation/deprecation
|
|
199
199
|
(0, rxjs_1.publishReplay)(1), // create a Replay(1)
|
|
200
200
|
isDelayed
|
|
201
|
-
? (0,
|
|
201
|
+
? (0, index_js_1.refCountDelay)() // Unsubscribe after delay
|
|
202
202
|
// eslint-disable-next-line deprecation/deprecation
|
|
203
203
|
: (0, rxjs_1.refCount)());
|
|
204
204
|
};
|
|
@@ -268,7 +268,7 @@ class RpcCore {
|
|
|
268
268
|
: this.provider.unsubscribe(subType, unsubName, subscriptionId))
|
|
269
269
|
.catch((error) => logErrorMessage(method, def, error));
|
|
270
270
|
};
|
|
271
|
-
}).pipe((0,
|
|
271
|
+
}).pipe((0, index_js_1.drr)());
|
|
272
272
|
};
|
|
273
273
|
memoized = this._memomize(creator, def);
|
|
274
274
|
return memoized;
|
package/cjs/detectPackage.js
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const util_1 = require("@polkadot/util");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
(0, util_1.detectPackage)(
|
|
5
|
+
const detectOther_js_1 = tslib_1.__importDefault(require("./detectOther.js"));
|
|
6
|
+
const packageInfo_js_1 = require("./packageInfo.js");
|
|
7
|
+
(0, util_1.detectPackage)(packageInfo_js_1.packageInfo, null, detectOther_js_1.default);
|
package/cjs/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
require("./detectPackage");
|
|
5
|
-
tslib_1.__exportStar(require("./bundle"), exports);
|
|
4
|
+
require("./detectPackage.js");
|
|
5
|
+
tslib_1.__exportStar(require("./bundle.js"), exports);
|
package/cjs/packageInfo.js
CHANGED
|
@@ -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: '10.
|
|
4
|
+
exports.packageInfo = { name: '@polkadot/rpc-core', path: typeof __dirname === 'string' ? __dirname : 'auto', type: 'cjs', version: '10.1.1' };
|
package/cjs/types/index.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
tslib_1.__exportStar(require("@polkadot/rpc-core/types/jsonrpc"), exports);
|
|
5
|
-
tslib_1.__exportStar(require("./base"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./base.js"), exports);
|
package/cjs/util/drr.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.drr = void 0;
|
|
4
4
|
const rxjs_1 = require("rxjs");
|
|
5
5
|
const util_1 = require("@polkadot/util");
|
|
6
|
-
const
|
|
6
|
+
const refCountDelay_js_1 = require("./refCountDelay.js");
|
|
7
7
|
function CMP(a, b) {
|
|
8
8
|
return (0, util_1.stringify)({ t: a }) === (0, util_1.stringify)({ t: b });
|
|
9
9
|
}
|
|
@@ -27,6 +27,6 @@ function drr({ delay, skipChange = false, skipTimeout = false } = {}) {
|
|
|
27
27
|
(0, rxjs_1.publishReplay)(1), skipTimeout
|
|
28
28
|
// eslint-disable-next-line deprecation/deprecation
|
|
29
29
|
? (0, rxjs_1.refCount)()
|
|
30
|
-
: (0,
|
|
30
|
+
: (0, refCountDelay_js_1.refCountDelay)(delay));
|
|
31
31
|
}
|
|
32
32
|
exports.drr = drr;
|
package/cjs/util/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
tslib_1.__exportStar(require("./drr"), exports);
|
|
5
|
-
tslib_1.__exportStar(require("./memo"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./refCountDelay"), exports);
|
|
4
|
+
tslib_1.__exportStar(require("./drr.js"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./memo.js"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./refCountDelay.js"), exports);
|
package/cjs/util/memo.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.memo = void 0;
|
|
4
4
|
const rxjs_1 = require("rxjs");
|
|
5
5
|
const util_1 = require("@polkadot/util");
|
|
6
|
-
const
|
|
6
|
+
const drr_js_1 = require("./drr.js");
|
|
7
7
|
/** @internal */
|
|
8
8
|
function memo(instanceId, inner) {
|
|
9
9
|
const options = { getInstanceId: () => instanceId };
|
|
@@ -13,7 +13,7 @@ function memo(instanceId, inner) {
|
|
|
13
13
|
cached.unmemoize(...params);
|
|
14
14
|
subscription.unsubscribe();
|
|
15
15
|
};
|
|
16
|
-
}).pipe((0,
|
|
16
|
+
}).pipe((0, drr_js_1.drr)()), options);
|
|
17
17
|
return cached;
|
|
18
18
|
}
|
|
19
19
|
exports.memo = memo;
|
package/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import './detectPackage';
|
|
2
|
-
export * from './bundle';
|
|
1
|
+
import './detectPackage.js';
|
|
2
|
+
export * from './bundle.js';
|
package/package.json
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"./cjs/detectPackage.js"
|
|
21
21
|
],
|
|
22
22
|
"type": "module",
|
|
23
|
-
"version": "10.
|
|
23
|
+
"version": "10.1.1",
|
|
24
24
|
"main": "./cjs/index.js",
|
|
25
25
|
"module": "./index.js",
|
|
26
26
|
"types": "./index.d.ts",
|
|
@@ -98,10 +98,10 @@
|
|
|
98
98
|
}
|
|
99
99
|
},
|
|
100
100
|
"dependencies": {
|
|
101
|
-
"@polkadot/rpc-augment": "10.
|
|
102
|
-
"@polkadot/rpc-provider": "10.
|
|
103
|
-
"@polkadot/types": "10.
|
|
104
|
-
"@polkadot/util": "^11.0.
|
|
101
|
+
"@polkadot/rpc-augment": "10.1.1",
|
|
102
|
+
"@polkadot/rpc-provider": "10.1.1",
|
|
103
|
+
"@polkadot/types": "10.1.1",
|
|
104
|
+
"@polkadot/util": "^11.0.2",
|
|
105
105
|
"rxjs": "^7.8.0",
|
|
106
106
|
"tslib": "^2.5.0"
|
|
107
107
|
}
|
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: '10.
|
|
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: '10.1.1' };
|
package/types/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from '@polkadot/rpc-core/types/jsonrpc';
|
|
2
|
-
export * from './base';
|
|
2
|
+
export * from './base.js';
|
package/util/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './drr';
|
|
2
|
-
export * from './memo';
|
|
3
|
-
export * from './refCountDelay';
|
|
1
|
+
export * from './drr.js';
|
|
2
|
+
export * from './memo.js';
|
|
3
|
+
export * from './refCountDelay.js';
|