@polkadot/rpc-core 6.4.3-4 → 6.4.3-8
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 +18 -14
- package/bundle.d.ts +1 -0
- package/bundle.js +18 -14
- package/package.json +3 -3
- package/packageInfo.cjs +1 -1
- package/packageInfo.js +1 -1
- package/types.d.ts +1 -3
- package/types.jsonrpc.d.ts +4 -1
package/bundle.cjs
CHANGED
|
@@ -225,15 +225,19 @@ class RpcCore {
|
|
|
225
225
|
}
|
|
226
226
|
|
|
227
227
|
_memomize(creator, def) {
|
|
228
|
-
const
|
|
228
|
+
const memoOpts = {
|
|
229
229
|
getInstanceId: () => (0, _classPrivateFieldLooseBase2.default)(this, _instanceId)[_instanceId]
|
|
230
|
-
}
|
|
231
|
-
memoized
|
|
232
|
-
memoized.raw = creator(
|
|
230
|
+
};
|
|
231
|
+
const memoized = (0, _util.memoize)(creator(true), memoOpts);
|
|
232
|
+
memoized.raw = (0, _util.memoize)(creator(false), memoOpts);
|
|
233
233
|
memoized.meta = def;
|
|
234
234
|
return memoized;
|
|
235
235
|
}
|
|
236
236
|
|
|
237
|
+
_formatResult(isScale, registry, blockHash, method, def, params, result) {
|
|
238
|
+
return isScale ? this._formatOutput(registry, blockHash, method, def, params, result) : result;
|
|
239
|
+
}
|
|
240
|
+
|
|
237
241
|
_createMethodSend(section, method, def) {
|
|
238
242
|
const rpcName = def.endpoint || `${section}_${method}`;
|
|
239
243
|
const hashIndex = def.params.findIndex(({
|
|
@@ -241,24 +245,24 @@ class RpcCore {
|
|
|
241
245
|
}) => isHistoric);
|
|
242
246
|
let memoized = null; // execute the RPC call, doing a registry swap for historic as applicable
|
|
243
247
|
|
|
244
|
-
const callWithRegistry = async (
|
|
248
|
+
const callWithRegistry = async (isScale, values) => {
|
|
245
249
|
const blockHash = hashIndex === -1 ? null : values[hashIndex];
|
|
246
250
|
const {
|
|
247
251
|
registry
|
|
248
|
-
} =
|
|
252
|
+
} = isScale && blockHash && (0, _classPrivateFieldLooseBase2.default)(this, _getBlockRegistry)[_getBlockRegistry] ? await (0, _classPrivateFieldLooseBase2.default)(this, _getBlockRegistry)[_getBlockRegistry]((0, _util.u8aToU8a)(blockHash)) : {
|
|
249
253
|
registry: (0, _classPrivateFieldLooseBase2.default)(this, _registryDefault)[_registryDefault]
|
|
250
254
|
};
|
|
251
255
|
|
|
252
256
|
const params = this._formatInputs(registry, null, def, values);
|
|
253
257
|
|
|
254
|
-
const
|
|
255
|
-
return
|
|
258
|
+
const result = await this.provider.send(rpcName, params.map(p => p.toJSON()));
|
|
259
|
+
return this._formatResult(isScale, registry, blockHash, method, def, params, result);
|
|
256
260
|
};
|
|
257
261
|
|
|
258
|
-
const creator =
|
|
259
|
-
const isDelayed =
|
|
262
|
+
const creator = isScale => (...values) => {
|
|
263
|
+
const isDelayed = isScale && hashIndex !== -1 && !!values[hashIndex];
|
|
260
264
|
return new _rxjs.Observable(observer => {
|
|
261
|
-
callWithRegistry(
|
|
265
|
+
callWithRegistry(isScale, values).then(value => {
|
|
262
266
|
observer.next(value);
|
|
263
267
|
observer.complete();
|
|
264
268
|
}).catch(error => {
|
|
@@ -303,7 +307,7 @@ class RpcCore {
|
|
|
303
307
|
const subType = `${section}_${updateType}`;
|
|
304
308
|
let memoized = null;
|
|
305
309
|
|
|
306
|
-
const creator =
|
|
310
|
+
const creator = isScale => (...values) => {
|
|
307
311
|
return new _rxjs.Observable(observer => {
|
|
308
312
|
// Have at least an empty promise, as used in the unsubscribe
|
|
309
313
|
let subscriptionPromise = Promise.resolve(null);
|
|
@@ -318,7 +322,7 @@ class RpcCore {
|
|
|
318
322
|
try {
|
|
319
323
|
const params = this._formatInputs(registry, null, def, values);
|
|
320
324
|
|
|
321
|
-
const paramsJson = params.map(
|
|
325
|
+
const paramsJson = params.map(p => p.toJSON());
|
|
322
326
|
|
|
323
327
|
const update = (error, result) => {
|
|
324
328
|
if (error) {
|
|
@@ -327,7 +331,7 @@ class RpcCore {
|
|
|
327
331
|
}
|
|
328
332
|
|
|
329
333
|
try {
|
|
330
|
-
observer.next(
|
|
334
|
+
observer.next(this._formatResult(isScale, registry, null, method, def, params, result));
|
|
331
335
|
} catch (error) {
|
|
332
336
|
observer.error(error);
|
|
333
337
|
}
|
package/bundle.d.ts
CHANGED
|
@@ -58,6 +58,7 @@ export declare class RpcCore {
|
|
|
58
58
|
addUserInterfaces<Section extends keyof RpcInterface>(userRpc: Record<string, Record<string, DefinitionRpc | DefinitionRpcSub>>): void;
|
|
59
59
|
private _createInterface;
|
|
60
60
|
private _memomize;
|
|
61
|
+
private _formatResult;
|
|
61
62
|
private _createMethodSend;
|
|
62
63
|
private _createSubscriber;
|
|
63
64
|
private _createMethodSubscribe;
|
package/bundle.js
CHANGED
|
@@ -190,15 +190,19 @@ export class RpcCore {
|
|
|
190
190
|
}
|
|
191
191
|
|
|
192
192
|
_memomize(creator, def) {
|
|
193
|
-
const
|
|
193
|
+
const memoOpts = {
|
|
194
194
|
getInstanceId: () => _classPrivateFieldLooseBase(this, _instanceId)[_instanceId]
|
|
195
|
-
}
|
|
196
|
-
memoized
|
|
197
|
-
memoized.raw = creator(
|
|
195
|
+
};
|
|
196
|
+
const memoized = memoize(creator(true), memoOpts);
|
|
197
|
+
memoized.raw = memoize(creator(false), memoOpts);
|
|
198
198
|
memoized.meta = def;
|
|
199
199
|
return memoized;
|
|
200
200
|
}
|
|
201
201
|
|
|
202
|
+
_formatResult(isScale, registry, blockHash, method, def, params, result) {
|
|
203
|
+
return isScale ? this._formatOutput(registry, blockHash, method, def, params, result) : result;
|
|
204
|
+
}
|
|
205
|
+
|
|
202
206
|
_createMethodSend(section, method, def) {
|
|
203
207
|
const rpcName = def.endpoint || `${section}_${method}`;
|
|
204
208
|
const hashIndex = def.params.findIndex(({
|
|
@@ -206,24 +210,24 @@ export class RpcCore {
|
|
|
206
210
|
}) => isHistoric);
|
|
207
211
|
let memoized = null; // execute the RPC call, doing a registry swap for historic as applicable
|
|
208
212
|
|
|
209
|
-
const callWithRegistry = async (
|
|
213
|
+
const callWithRegistry = async (isScale, values) => {
|
|
210
214
|
const blockHash = hashIndex === -1 ? null : values[hashIndex];
|
|
211
215
|
const {
|
|
212
216
|
registry
|
|
213
|
-
} =
|
|
217
|
+
} = isScale && blockHash && _classPrivateFieldLooseBase(this, _getBlockRegistry)[_getBlockRegistry] ? await _classPrivateFieldLooseBase(this, _getBlockRegistry)[_getBlockRegistry](u8aToU8a(blockHash)) : {
|
|
214
218
|
registry: _classPrivateFieldLooseBase(this, _registryDefault)[_registryDefault]
|
|
215
219
|
};
|
|
216
220
|
|
|
217
221
|
const params = this._formatInputs(registry, null, def, values);
|
|
218
222
|
|
|
219
|
-
const
|
|
220
|
-
return
|
|
223
|
+
const result = await this.provider.send(rpcName, params.map(p => p.toJSON()));
|
|
224
|
+
return this._formatResult(isScale, registry, blockHash, method, def, params, result);
|
|
221
225
|
};
|
|
222
226
|
|
|
223
|
-
const creator =
|
|
224
|
-
const isDelayed =
|
|
227
|
+
const creator = isScale => (...values) => {
|
|
228
|
+
const isDelayed = isScale && hashIndex !== -1 && !!values[hashIndex];
|
|
225
229
|
return new Observable(observer => {
|
|
226
|
-
callWithRegistry(
|
|
230
|
+
callWithRegistry(isScale, values).then(value => {
|
|
227
231
|
observer.next(value);
|
|
228
232
|
observer.complete();
|
|
229
233
|
}).catch(error => {
|
|
@@ -268,7 +272,7 @@ export class RpcCore {
|
|
|
268
272
|
const subType = `${section}_${updateType}`;
|
|
269
273
|
let memoized = null;
|
|
270
274
|
|
|
271
|
-
const creator =
|
|
275
|
+
const creator = isScale => (...values) => {
|
|
272
276
|
return new Observable(observer => {
|
|
273
277
|
// Have at least an empty promise, as used in the unsubscribe
|
|
274
278
|
let subscriptionPromise = Promise.resolve(null);
|
|
@@ -283,7 +287,7 @@ export class RpcCore {
|
|
|
283
287
|
try {
|
|
284
288
|
const params = this._formatInputs(registry, null, def, values);
|
|
285
289
|
|
|
286
|
-
const paramsJson = params.map(
|
|
290
|
+
const paramsJson = params.map(p => p.toJSON());
|
|
287
291
|
|
|
288
292
|
const update = (error, result) => {
|
|
289
293
|
if (error) {
|
|
@@ -292,7 +296,7 @@ export class RpcCore {
|
|
|
292
296
|
}
|
|
293
297
|
|
|
294
298
|
try {
|
|
295
|
-
observer.next(
|
|
299
|
+
observer.next(this._formatResult(isScale, registry, null, method, def, params, result));
|
|
296
300
|
} catch (error) {
|
|
297
301
|
observer.error(error);
|
|
298
302
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@polkadot/rpc-core",
|
|
3
|
-
"version": "6.4.3-
|
|
3
|
+
"version": "6.4.3-8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
|
|
6
6
|
"main": "index.js",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-core#readme",
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@babel/runtime": "^7.15.4",
|
|
23
|
-
"@polkadot/rpc-provider": "6.4.3-
|
|
24
|
-
"@polkadot/types": "6.4.3-
|
|
23
|
+
"@polkadot/rpc-provider": "6.4.3-8",
|
|
24
|
+
"@polkadot/types": "6.4.3-8",
|
|
25
25
|
"@polkadot/util": "^7.5.1",
|
|
26
26
|
"rxjs": "^7.4.0"
|
|
27
27
|
},
|
package/packageInfo.cjs
CHANGED
package/packageInfo.js
CHANGED
package/types.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import type { Observable } from 'rxjs';
|
|
2
|
-
import type { Json, Raw } from '@polkadot/types';
|
|
3
2
|
import type { Codec, DefinitionRpc } from '@polkadot/types/types';
|
|
4
3
|
export * from './types.jsonrpc';
|
|
5
4
|
export interface RpcInterfaceMethod {
|
|
6
5
|
<T extends Codec>(...params: unknown[]): Observable<T>;
|
|
7
|
-
|
|
8
|
-
raw(...params: unknown[]): Observable<Raw>;
|
|
6
|
+
raw(...params: unknown[]): Observable<unknown>;
|
|
9
7
|
meta: DefinitionRpc;
|
|
10
8
|
}
|
package/types.jsonrpc.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import type { Observable } from 'rxjs';
|
|
1
2
|
import type { AnyFunction } from '@polkadot/types/types';
|
|
2
3
|
export interface RpcInterface {
|
|
3
4
|
}
|
|
4
|
-
export declare type AugmentedRpc<F extends AnyFunction> = F
|
|
5
|
+
export declare type AugmentedRpc<F extends AnyFunction> = F & {
|
|
6
|
+
raw: <T>(...params: Parameters<F>) => Observable<T>;
|
|
7
|
+
};
|