@acala-network/chopsticks-core 1.0.6 → 1.1.0

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.
@@ -5,23 +5,23 @@ Object.defineProperty(exports, "__esModule", {
5
5
  function _export(target, all) {
6
6
  for(var name in all)Object.defineProperty(target, name, {
7
7
  enumerable: true,
8
- get: all[name]
8
+ get: Object.getOwnPropertyDescriptor(all, name).get
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- buildBlock: function() {
12
+ get buildBlock () {
13
13
  return buildBlock;
14
14
  },
15
- dryRunExtrinsic: function() {
15
+ get dryRunExtrinsic () {
16
16
  return dryRunExtrinsic;
17
17
  },
18
- dryRunInherents: function() {
18
+ get dryRunInherents () {
19
19
  return dryRunInherents;
20
20
  },
21
- genesisDigestLogs: function() {
21
+ get genesisDigestLogs () {
22
22
  return genesisDigestLogs;
23
23
  },
24
- newHeader: function() {
24
+ get newHeader () {
25
25
  return newHeader;
26
26
  }
27
27
  });
@@ -5,14 +5,14 @@ Object.defineProperty(exports, "__esModule", {
5
5
  function _export(target, all) {
6
6
  for(var name in all)Object.defineProperty(target, name, {
7
7
  enumerable: true,
8
- get: all[name]
8
+ get: Object.getOwnPropertyDescriptor(all, name).get
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- HeadState: function() {
12
+ get HeadState () {
13
13
  return HeadState;
14
14
  },
15
- randomId: function() {
15
+ get randomId () {
16
16
  return randomId;
17
17
  }
18
18
  });
@@ -5,17 +5,17 @@ Object.defineProperty(exports, "__esModule", {
5
5
  function _export(target, all) {
6
6
  for(var name in all)Object.defineProperty(target, name, {
7
7
  enumerable: true,
8
- get: all[name]
8
+ get: Object.getOwnPropertyDescriptor(all, name).get
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- RemoteStorageLayer: function() {
12
+ get RemoteStorageLayer () {
13
13
  return RemoteStorageLayer;
14
14
  },
15
- StorageLayer: function() {
15
+ get StorageLayer () {
16
16
  return StorageLayer;
17
17
  },
18
- StorageValueKind: function() {
18
+ get StorageValueKind () {
19
19
  return StorageValueKind;
20
20
  }
21
21
  });
@@ -5,17 +5,17 @@ Object.defineProperty(exports, "__esModule", {
5
5
  function _export(target, all) {
6
6
  for(var name in all)Object.defineProperty(target, name, {
7
7
  enumerable: true,
8
- get: all[name]
8
+ get: Object.getOwnPropertyDescriptor(all, name).get
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- APPLY_EXTRINSIC_ERROR: function() {
12
+ get APPLY_EXTRINSIC_ERROR () {
13
13
  return APPLY_EXTRINSIC_ERROR;
14
14
  },
15
- BuildBlockMode: function() {
15
+ get BuildBlockMode () {
16
16
  return BuildBlockMode;
17
17
  },
18
- TxPool: function() {
18
+ get TxPool () {
19
19
  return TxPool;
20
20
  }
21
21
  });
package/dist/cjs/env.js CHANGED
@@ -5,14 +5,14 @@ Object.defineProperty(exports, "__esModule", {
5
5
  function _export(target, all) {
6
6
  for(var name in all)Object.defineProperty(target, name, {
7
7
  enumerable: true,
8
- get: all[name]
8
+ get: Object.getOwnPropertyDescriptor(all, name).get
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- environment: function() {
12
+ get environment () {
13
13
  return environment;
14
14
  },
15
- environmentSchema: function() {
15
+ get environmentSchema () {
16
16
  return environmentSchema;
17
17
  }
18
18
  });
@@ -5,17 +5,17 @@ Object.defineProperty(exports, "__esModule", {
5
5
  function _export(target, all) {
6
6
  for(var name in all)Object.defineProperty(target, name, {
7
7
  enumerable: true,
8
- get: all[name]
8
+ get: Object.getOwnPropertyDescriptor(all, name).get
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- defaultLogger: function() {
12
+ get defaultLogger () {
13
13
  return defaultLogger;
14
14
  },
15
- pinoLogger: function() {
15
+ get pinoLogger () {
16
16
  return pinoLogger;
17
17
  },
18
- truncate: function() {
18
+ get truncate () {
19
19
  return truncate;
20
20
  }
21
21
  });
@@ -5,20 +5,20 @@ Object.defineProperty(exports, "__esModule", {
5
5
  function _export(target, all) {
6
6
  for(var name in all)Object.defineProperty(target, name, {
7
7
  enumerable: true,
8
- get: all[name]
8
+ get: Object.getOwnPropertyDescriptor(all, name).get
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- ResponseError: function() {
12
+ get ResponseError () {
13
13
  return _shared.ResponseError;
14
14
  },
15
- allHandlers: function() {
15
+ get allHandlers () {
16
16
  return allHandlers;
17
17
  },
18
- dev: function() {
18
+ get dev () {
19
19
  return _index.default;
20
20
  },
21
- substrate: function() {
21
+ get substrate () {
22
22
  return _index2.default;
23
23
  }
24
24
  });
@@ -5,38 +5,39 @@ Object.defineProperty(exports, "__esModule", {
5
5
  function _export(target, all) {
6
6
  for(var name in all)Object.defineProperty(target, name, {
7
7
  enumerable: true,
8
- get: all[name]
8
+ get: Object.getOwnPropertyDescriptor(all, name).get
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- chainHead_v1_body: function() {
12
+ get chainHead_v1_body () {
13
13
  return chainHead_v1_body;
14
14
  },
15
- chainHead_v1_call: function() {
15
+ get chainHead_v1_call () {
16
16
  return chainHead_v1_call;
17
17
  },
18
- chainHead_v1_continue: function() {
18
+ get chainHead_v1_continue () {
19
19
  return chainHead_v1_continue;
20
20
  },
21
- chainHead_v1_follow: function() {
21
+ get chainHead_v1_follow () {
22
22
  return chainHead_v1_follow;
23
23
  },
24
- chainHead_v1_header: function() {
24
+ get chainHead_v1_header () {
25
25
  return chainHead_v1_header;
26
26
  },
27
- chainHead_v1_stopOperation: function() {
27
+ get chainHead_v1_stopOperation () {
28
28
  return chainHead_v1_stopOperation;
29
29
  },
30
- chainHead_v1_storage: function() {
30
+ get chainHead_v1_storage () {
31
31
  return chainHead_v1_storage;
32
32
  },
33
- chainHead_v1_unfollow: function() {
33
+ get chainHead_v1_unfollow () {
34
34
  return chainHead_v1_unfollow;
35
35
  },
36
- chainHead_v1_unpin: function() {
36
+ get chainHead_v1_unpin () {
37
37
  return chainHead_v1_unpin;
38
38
  }
39
39
  });
40
+ const _utilcrypto = require("@polkadot/util-crypto");
40
41
  const _logger = require("../../logger.js");
41
42
  const _shared = require("../shared.js");
42
43
  const logger = _logger.defaultLogger.child({
@@ -211,6 +212,23 @@ const chainHead_v1_storage = async (context, [followSubscription, hash, items, _
211
212
  }
212
213
  return null;
213
214
  }
215
+ case 'hash':
216
+ {
217
+ const value = await block.get(sir.key);
218
+ if (value) {
219
+ following.get(followSubscription)?.callback({
220
+ event: 'operationStorageItems',
221
+ operationId,
222
+ items: [
223
+ {
224
+ key: sir.key,
225
+ hash: (0, _utilcrypto.blake2AsHex)(value)
226
+ }
227
+ ]
228
+ });
229
+ }
230
+ return null;
231
+ }
214
232
  case 'descendantsValues':
215
233
  {
216
234
  const { items, next } = await getDescendantValues(block, {
@@ -224,6 +242,25 @@ const chainHead_v1_storage = async (context, [followSubscription, hash, items, _
224
242
  });
225
243
  return next;
226
244
  }
245
+ case 'descendantsHashes':
246
+ {
247
+ const { items, next } = await getDescendantValues(block, {
248
+ prefix: sir.key,
249
+ startKey: '0x'
250
+ });
251
+ following.get(followSubscription)?.callback({
252
+ event: 'operationStorageItems',
253
+ operationId,
254
+ items: items.map(({ key, value })=>({
255
+ key,
256
+ hash: value !== undefined ? (0, _utilcrypto.blake2AsHex)(value) : undefined
257
+ }))
258
+ });
259
+ return next ? {
260
+ ...next,
261
+ isDescendantHashes: true
262
+ } : null;
263
+ }
227
264
  case 'closestDescendantMerkleValue':
228
265
  {
229
266
  const followingSubscription = following.get(followSubscription);
@@ -244,10 +281,6 @@ const chainHead_v1_storage = async (context, [followSubscription, hash, items, _
244
281
  });
245
282
  return null;
246
283
  }
247
- default:
248
- // TODO
249
- console.warn(`Storage type not implemented ${sir.type}`);
250
- return null;
251
284
  }
252
285
  };
253
286
  const listResult = await Promise.all(items.map(handleStorageItemRequest));
@@ -312,7 +345,10 @@ const chainHead_v1_continue = async (context, [followSubscription, operationId])
312
345
  follower.callback({
313
346
  event: 'operationStorageItems',
314
347
  operationId,
315
- items
348
+ items: params.isDescendantHashes ? items.map(({ key, value })=>({
349
+ key,
350
+ hash: value !== undefined ? (0, _utilcrypto.blake2AsHex)(value) : value
351
+ })) : items
316
352
  });
317
353
  return next;
318
354
  };
@@ -5,17 +5,17 @@ Object.defineProperty(exports, "__esModule", {
5
5
  function _export(target, all) {
6
6
  for(var name in all)Object.defineProperty(target, name, {
7
7
  enumerable: true,
8
- get: all[name]
8
+ get: Object.getOwnPropertyDescriptor(all, name).get
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- chainSpec_v1_chainName: function() {
12
+ get chainSpec_v1_chainName () {
13
13
  return chainSpec_v1_chainName;
14
14
  },
15
- chainSpec_v1_genesisHash: function() {
15
+ get chainSpec_v1_genesisHash () {
16
16
  return chainSpec_v1_genesisHash;
17
17
  },
18
- chainSpec_v1_properties: function() {
18
+ get chainSpec_v1_properties () {
19
19
  return chainSpec_v1_properties;
20
20
  }
21
21
  });
@@ -5,20 +5,20 @@ Object.defineProperty(exports, "__esModule", {
5
5
  function _export(target, all) {
6
6
  for(var name in all)Object.defineProperty(target, name, {
7
7
  enumerable: true,
8
- get: all[name]
8
+ get: Object.getOwnPropertyDescriptor(all, name).get
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- ChainHeadV1RPC: function() {
12
+ get ChainHeadV1RPC () {
13
13
  return _chainHead_v1;
14
14
  },
15
- ChainSpecV1RPC: function() {
15
+ get ChainSpecV1RPC () {
16
16
  return _chainSpec_v1;
17
17
  },
18
- TransactionV1RPC: function() {
18
+ get TransactionV1RPC () {
19
19
  return _transaction_v1;
20
20
  },
21
- default: function() {
21
+ get default () {
22
22
  return _default;
23
23
  }
24
24
  });
@@ -5,14 +5,14 @@ Object.defineProperty(exports, "__esModule", {
5
5
  function _export(target, all) {
6
6
  for(var name in all)Object.defineProperty(target, name, {
7
7
  enumerable: true,
8
- get: all[name]
8
+ get: Object.getOwnPropertyDescriptor(all, name).get
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- transaction_v1_broadcast: function() {
12
+ get transaction_v1_broadcast () {
13
13
  return transaction_v1_broadcast;
14
14
  },
15
- transaction_v1_stop: function() {
15
+ get transaction_v1_stop () {
16
16
  return transaction_v1_stop;
17
17
  }
18
18
  });
@@ -5,20 +5,20 @@ Object.defineProperty(exports, "__esModule", {
5
5
  function _export(target, all) {
6
6
  for(var name in all)Object.defineProperty(target, name, {
7
7
  enumerable: true,
8
- get: all[name]
8
+ get: Object.getOwnPropertyDescriptor(all, name).get
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- ResponseError: function() {
12
+ get ResponseError () {
13
13
  return ResponseError;
14
14
  },
15
- logger: function() {
15
+ get logger () {
16
16
  return logger;
17
17
  },
18
- zHash: function() {
18
+ get zHash () {
19
19
  return zHash;
20
20
  },
21
- zHex: function() {
21
+ get zHex () {
22
22
  return zHex;
23
23
  }
24
24
  });
@@ -5,17 +5,17 @@ Object.defineProperty(exports, "__esModule", {
5
5
  function _export(target, all) {
6
6
  for(var name in all)Object.defineProperty(target, name, {
7
7
  enumerable: true,
8
- get: all[name]
8
+ get: Object.getOwnPropertyDescriptor(all, name).get
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- archive_unstable_body: function() {
12
+ get archive_unstable_body () {
13
13
  return archive_unstable_body;
14
14
  },
15
- archive_unstable_call: function() {
15
+ get archive_unstable_call () {
16
16
  return archive_unstable_call;
17
17
  },
18
- archive_unstable_hashByHeight: function() {
18
+ get archive_unstable_hashByHeight () {
19
19
  return archive_unstable_hashByHeight;
20
20
  }
21
21
  });
@@ -5,20 +5,20 @@ Object.defineProperty(exports, "__esModule", {
5
5
  function _export(target, all) {
6
6
  for(var name in all)Object.defineProperty(target, name, {
7
7
  enumerable: true,
8
- get: all[name]
8
+ get: Object.getOwnPropertyDescriptor(all, name).get
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- author_pendingExtrinsics: function() {
12
+ get author_pendingExtrinsics () {
13
13
  return author_pendingExtrinsics;
14
14
  },
15
- author_submitAndWatchExtrinsic: function() {
15
+ get author_submitAndWatchExtrinsic () {
16
16
  return author_submitAndWatchExtrinsic;
17
17
  },
18
- author_submitExtrinsic: function() {
18
+ get author_submitExtrinsic () {
19
19
  return author_submitExtrinsic;
20
20
  },
21
- author_unwatchExtrinsic: function() {
21
+ get author_unwatchExtrinsic () {
22
22
  return author_unwatchExtrinsic;
23
23
  }
24
24
  });
@@ -5,41 +5,41 @@ Object.defineProperty(exports, "__esModule", {
5
5
  function _export(target, all) {
6
6
  for(var name in all)Object.defineProperty(target, name, {
7
7
  enumerable: true,
8
- get: all[name]
8
+ get: Object.getOwnPropertyDescriptor(all, name).get
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- chain_getBlock: function() {
12
+ get chain_getBlock () {
13
13
  return chain_getBlock;
14
14
  },
15
- chain_getBlockHash: function() {
15
+ get chain_getBlockHash () {
16
16
  return chain_getBlockHash;
17
17
  },
18
- chain_getFinalizedHead: function() {
18
+ get chain_getFinalizedHead () {
19
19
  return chain_getFinalizedHead;
20
20
  },
21
- chain_getHead: function() {
21
+ get chain_getHead () {
22
22
  return chain_getHead;
23
23
  },
24
- chain_getHeader: function() {
24
+ get chain_getHeader () {
25
25
  return chain_getHeader;
26
26
  },
27
- chain_subscribeFinalizedHeads: function() {
27
+ get chain_subscribeFinalizedHeads () {
28
28
  return chain_subscribeFinalizedHeads;
29
29
  },
30
- chain_subscribeNewHead: function() {
30
+ get chain_subscribeNewHead () {
31
31
  return chain_subscribeNewHead;
32
32
  },
33
- chain_subscribeNewHeads: function() {
33
+ get chain_subscribeNewHeads () {
34
34
  return chain_subscribeNewHeads;
35
35
  },
36
- chain_unsubscribeFinalizedHeads: function() {
36
+ get chain_unsubscribeFinalizedHeads () {
37
37
  return chain_unsubscribeFinalizedHeads;
38
38
  },
39
- chain_unsubscribeNewHead: function() {
39
+ get chain_unsubscribeNewHead () {
40
40
  return chain_unsubscribeNewHead;
41
41
  },
42
- chain_unsubscribeNewHeads: function() {
42
+ get chain_unsubscribeNewHeads () {
43
43
  return chain_unsubscribeNewHeads;
44
44
  }
45
45
  });
@@ -5,29 +5,29 @@ Object.defineProperty(exports, "__esModule", {
5
5
  function _export(target, all) {
6
6
  for(var name in all)Object.defineProperty(target, name, {
7
7
  enumerable: true,
8
- get: all[name]
8
+ get: Object.getOwnPropertyDescriptor(all, name).get
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- ArchiveRPC: function() {
12
+ get ArchiveRPC () {
13
13
  return _archive;
14
14
  },
15
- AuthorRPC: function() {
15
+ get AuthorRPC () {
16
16
  return _author;
17
17
  },
18
- ChainRPC: function() {
18
+ get ChainRPC () {
19
19
  return _chain;
20
20
  },
21
- PaymentRPC: function() {
21
+ get PaymentRPC () {
22
22
  return _payment;
23
23
  },
24
- StateRPC: function() {
24
+ get StateRPC () {
25
25
  return _state;
26
26
  },
27
- SystemRPC: function() {
27
+ get SystemRPC () {
28
28
  return _system;
29
29
  },
30
- default: function() {
30
+ get default () {
31
31
  return _default;
32
32
  }
33
33
  });
@@ -5,14 +5,14 @@ Object.defineProperty(exports, "__esModule", {
5
5
  function _export(target, all) {
6
6
  for(var name in all)Object.defineProperty(target, name, {
7
7
  enumerable: true,
8
- get: all[name]
8
+ get: Object.getOwnPropertyDescriptor(all, name).get
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- payment_queryFeeDetails: function() {
12
+ get payment_queryFeeDetails () {
13
13
  return payment_queryFeeDetails;
14
14
  },
15
- payment_queryInfo: function() {
15
+ get payment_queryInfo () {
16
16
  return payment_queryInfo;
17
17
  }
18
18
  });
@@ -5,47 +5,47 @@ Object.defineProperty(exports, "__esModule", {
5
5
  function _export(target, all) {
6
6
  for(var name in all)Object.defineProperty(target, name, {
7
7
  enumerable: true,
8
- get: all[name]
8
+ get: Object.getOwnPropertyDescriptor(all, name).get
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- childstate_getKeysPaged: function() {
12
+ get childstate_getKeysPaged () {
13
13
  return childstate_getKeysPaged;
14
14
  },
15
- childstate_getStorage: function() {
15
+ get childstate_getStorage () {
16
16
  return childstate_getStorage;
17
17
  },
18
- state_call: function() {
18
+ get state_call () {
19
19
  return state_call;
20
20
  },
21
- state_getKeysPaged: function() {
21
+ get state_getKeysPaged () {
22
22
  return state_getKeysPaged;
23
23
  },
24
- state_getMetadata: function() {
24
+ get state_getMetadata () {
25
25
  return state_getMetadata;
26
26
  },
27
- state_getRuntimeVersion: function() {
27
+ get state_getRuntimeVersion () {
28
28
  return state_getRuntimeVersion;
29
29
  },
30
- state_getStorage: function() {
30
+ get state_getStorage () {
31
31
  return state_getStorage;
32
32
  },
33
- state_getStorageAt: function() {
33
+ get state_getStorageAt () {
34
34
  return state_getStorageAt;
35
35
  },
36
- state_queryStorageAt: function() {
36
+ get state_queryStorageAt () {
37
37
  return state_queryStorageAt;
38
38
  },
39
- state_subscribeRuntimeVersion: function() {
39
+ get state_subscribeRuntimeVersion () {
40
40
  return state_subscribeRuntimeVersion;
41
41
  },
42
- state_subscribeStorage: function() {
42
+ get state_subscribeStorage () {
43
43
  return state_subscribeStorage;
44
44
  },
45
- state_unsubscribeRuntimeVersion: function() {
45
+ get state_unsubscribeRuntimeVersion () {
46
46
  return state_unsubscribeRuntimeVersion;
47
47
  },
48
- state_unsubscribeStorage: function() {
48
+ get state_unsubscribeStorage () {
49
49
  return state_unsubscribeStorage;
50
50
  }
51
51
  });
@@ -5,41 +5,41 @@ Object.defineProperty(exports, "__esModule", {
5
5
  function _export(target, all) {
6
6
  for(var name in all)Object.defineProperty(target, name, {
7
7
  enumerable: true,
8
- get: all[name]
8
+ get: Object.getOwnPropertyDescriptor(all, name).get
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- system_accountNextIndex: function() {
12
+ get system_accountNextIndex () {
13
13
  return system_accountNextIndex;
14
14
  },
15
- system_chain: function() {
15
+ get system_chain () {
16
16
  return system_chain;
17
17
  },
18
- system_chainType: function() {
18
+ get system_chainType () {
19
19
  return system_chainType;
20
20
  },
21
- system_dryRun: function() {
21
+ get system_dryRun () {
22
22
  return system_dryRun;
23
23
  },
24
- system_health: function() {
24
+ get system_health () {
25
25
  return system_health;
26
26
  },
27
- system_localListenAddresses: function() {
27
+ get system_localListenAddresses () {
28
28
  return system_localListenAddresses;
29
29
  },
30
- system_localPeerId: function() {
30
+ get system_localPeerId () {
31
31
  return system_localPeerId;
32
32
  },
33
- system_name: function() {
33
+ get system_name () {
34
34
  return system_name;
35
35
  },
36
- system_nodeRoles: function() {
36
+ get system_nodeRoles () {
37
37
  return system_nodeRoles;
38
38
  },
39
- system_properties: function() {
39
+ get system_properties () {
40
40
  return system_properties;
41
41
  },
42
- system_version: function() {
42
+ get system_version () {
43
43
  return system_version;
44
44
  }
45
45
  });
package/dist/cjs/setup.js CHANGED
@@ -5,14 +5,14 @@ Object.defineProperty(exports, "__esModule", {
5
5
  function _export(target, all) {
6
6
  for(var name in all)Object.defineProperty(target, name, {
7
7
  enumerable: true,
8
- get: all[name]
8
+ get: Object.getOwnPropertyDescriptor(all, name).get
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- processOptions: function() {
12
+ get processOptions () {
13
13
  return processOptions;
14
14
  },
15
- setup: function() {
15
+ get setup () {
16
16
  return setup;
17
17
  }
18
18
  });
@@ -5,20 +5,20 @@ Object.defineProperty(exports, "__esModule", {
5
5
  function _export(target, all) {
6
6
  for(var name in all)Object.defineProperty(target, name, {
7
7
  enumerable: true,
8
- get: all[name]
8
+ get: Object.getOwnPropertyDescriptor(all, name).get
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- decodeBlockStorageDiff: function() {
12
+ get decodeBlockStorageDiff () {
13
13
  return decodeBlockStorageDiff;
14
14
  },
15
- decodeKey: function() {
15
+ get decodeKey () {
16
16
  return decodeKey;
17
17
  },
18
- decodeKeyValue: function() {
18
+ get decodeKeyValue () {
19
19
  return decodeKeyValue;
20
20
  },
21
- toStorageObject: function() {
21
+ get toStorageObject () {
22
22
  return toStorageObject;
23
23
  }
24
24
  });
@@ -5,53 +5,53 @@ Object.defineProperty(exports, "__esModule", {
5
5
  function _export(target, all) {
6
6
  for(var name in all)Object.defineProperty(target, name, {
7
7
  enumerable: true,
8
- get: all[name]
8
+ get: Object.getOwnPropertyDescriptor(all, name).get
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- CHILD_PREFIX_LENGTH: function() {
12
+ get CHILD_PREFIX_LENGTH () {
13
13
  return CHILD_PREFIX_LENGTH;
14
14
  },
15
- PREFIX_LENGTH: function() {
15
+ get PREFIX_LENGTH () {
16
16
  return PREFIX_LENGTH;
17
17
  },
18
- compactHex: function() {
18
+ get compactHex () {
19
19
  return compactHex;
20
20
  },
21
- defer: function() {
21
+ get defer () {
22
22
  return defer;
23
23
  },
24
- fetchKeys: function() {
24
+ get fetchKeys () {
25
25
  return fetchKeys;
26
26
  },
27
- fetchKeysToArray: function() {
27
+ get fetchKeysToArray () {
28
28
  return fetchKeysToArray;
29
29
  },
30
- getCurrentSlot: function() {
30
+ get getCurrentSlot () {
31
31
  return getCurrentSlot;
32
32
  },
33
- getCurrentTimestamp: function() {
33
+ get getCurrentTimestamp () {
34
34
  return getCurrentTimestamp;
35
35
  },
36
- getParaId: function() {
36
+ get getParaId () {
37
37
  return getParaId;
38
38
  },
39
- getSlotDuration: function() {
39
+ get getSlotDuration () {
40
40
  return getSlotDuration;
41
41
  },
42
- isPrefixedChildKey: function() {
42
+ get isPrefixedChildKey () {
43
43
  return isPrefixedChildKey;
44
44
  },
45
- isUrl: function() {
45
+ get isUrl () {
46
46
  return isUrl;
47
47
  },
48
- prefixedChildKey: function() {
48
+ get prefixedChildKey () {
49
49
  return prefixedChildKey;
50
50
  },
51
- splitChildKey: function() {
51
+ get splitChildKey () {
52
52
  return splitChildKey;
53
53
  },
54
- stripChildPrefix: function() {
54
+ get stripChildPrefix () {
55
55
  return stripChildPrefix;
56
56
  }
57
57
  });
@@ -5,32 +5,32 @@ Object.defineProperty(exports, "__esModule", {
5
5
  function _export(target, all) {
6
6
  for(var name in all)Object.defineProperty(target, name, {
7
7
  enumerable: true,
8
- get: all[name]
8
+ get: Object.getOwnPropertyDescriptor(all, name).get
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- WELL_KNOWN_KEYS: function() {
12
+ get WELL_KNOWN_KEYS () {
13
13
  return WELL_KNOWN_KEYS;
14
14
  },
15
- dmqMqcHead: function() {
15
+ get dmqMqcHead () {
16
16
  return dmqMqcHead;
17
17
  },
18
- hrmpChannels: function() {
18
+ get hrmpChannels () {
19
19
  return hrmpChannels;
20
20
  },
21
- hrmpEgressChannelIndex: function() {
21
+ get hrmpEgressChannelIndex () {
22
22
  return hrmpEgressChannelIndex;
23
23
  },
24
- hrmpIngressChannelIndex: function() {
24
+ get hrmpIngressChannelIndex () {
25
25
  return hrmpIngressChannelIndex;
26
26
  },
27
- paraHead: function() {
27
+ get paraHead () {
28
28
  return paraHead;
29
29
  },
30
- upgradeGoAheadSignal: function() {
30
+ get upgradeGoAheadSignal () {
31
31
  return upgradeGoAheadSignal;
32
32
  },
33
- upgradeRestrictionSignal: function() {
33
+ get upgradeRestrictionSignal () {
34
34
  return upgradeRestrictionSignal;
35
35
  }
36
36
  });
@@ -5,38 +5,38 @@ Object.defineProperty(exports, "__esModule", {
5
5
  function _export(target, all) {
6
6
  for(var name in all)Object.defineProperty(target, name, {
7
7
  enumerable: true,
8
- get: all[name]
8
+ get: Object.getOwnPropertyDescriptor(all, name).get
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- calculateStateRoot: function() {
12
+ get calculateStateRoot () {
13
13
  return calculateStateRoot;
14
14
  },
15
- createProof: function() {
15
+ get createProof () {
16
16
  return createProof;
17
17
  },
18
- decodeProof: function() {
18
+ get decodeProof () {
19
19
  return decodeProof;
20
20
  },
21
- destroyWorker: function() {
21
+ get destroyWorker () {
22
22
  return destroyWorker;
23
23
  },
24
- emptyTaskHandler: function() {
24
+ get emptyTaskHandler () {
25
25
  return emptyTaskHandler;
26
26
  },
27
- getAuraSlotDuration: function() {
27
+ get getAuraSlotDuration () {
28
28
  return getAuraSlotDuration;
29
29
  },
30
- getRuntimeVersion: function() {
30
+ get getRuntimeVersion () {
31
31
  return getRuntimeVersion;
32
32
  },
33
- getWorker: function() {
33
+ get getWorker () {
34
34
  return getWorker;
35
35
  },
36
- runTask: function() {
36
+ get runTask () {
37
37
  return runTask;
38
38
  },
39
- taskHandler: function() {
39
+ get taskHandler () {
40
40
  return taskHandler;
41
41
  }
42
42
  });
@@ -5,17 +5,17 @@ Object.defineProperty(exports, "__esModule", {
5
5
  function _export(target, all) {
6
6
  for(var name in all)Object.defineProperty(target, name, {
7
7
  enumerable: true,
8
- get: all[name]
8
+ get: Object.getOwnPropertyDescriptor(all, name).get
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- connectParachains: function() {
12
+ get connectParachains () {
13
13
  return connectParachains;
14
14
  },
15
- connectVertical: function() {
15
+ get connectVertical () {
16
16
  return connectVertical;
17
17
  },
18
- xcmLogger: function() {
18
+ get xcmLogger () {
19
19
  return xcmLogger;
20
20
  }
21
21
  });
@@ -12,101 +12,12 @@ const logger = defaultLogger.child({
12
12
  * Provider for local chopsticks chain
13
13
  */ export class ChopsticksProvider {
14
14
  chain;
15
- #isConnected;
16
- #eventemitter;
15
+ #isConnected = false;
16
+ #eventemitter = new EventEmitter();
17
17
  #isReadyPromise;
18
- #subscriptions;
18
+ #subscriptions = {};
19
19
  constructor(chain){
20
20
  this.chain = chain;
21
- this.#isConnected = false;
22
- this.#eventemitter = new EventEmitter();
23
- this.#subscriptions = {};
24
- this.clone = ()=>{
25
- return new ChopsticksProvider(this.chain);
26
- };
27
- this.connect = async ()=>{
28
- this.#isConnected = true;
29
- this.#eventemitter.emit('connected');
30
- };
31
- this.disconnect = async ()=>{
32
- this.#isConnected = false;
33
- this.#eventemitter.emit('disconnected');
34
- };
35
- this.on = (type, sub)=>{
36
- this.#eventemitter.on(type, sub);
37
- return ()=>{
38
- this.#eventemitter.removeListener(type, sub);
39
- };
40
- };
41
- this.subscriptionManager = {
42
- subscribe: (method, subid, onCancel = ()=>{})=>{
43
- const sub = this.#subscriptions[subid];
44
- if (sub) {
45
- sub.onCancel = onCancel;
46
- }
47
- return (data)=>{
48
- logger.debug('subscribe-callback', method, subid, data);
49
- const sub = this.#subscriptions[subid];
50
- if (sub) {
51
- sub.callback(null, data);
52
- } else {
53
- logger.trace(`Unable to find active subscription=${subid}`);
54
- }
55
- };
56
- },
57
- unsubscribe: (subid)=>{
58
- logger.debug('unsubscribe-callback', subid);
59
- const sub = this.#subscriptions[subid];
60
- if (sub) {
61
- sub.onCancel?.();
62
- delete this.#subscriptions[subid];
63
- } else {
64
- logger.trace(`Unable to find active subscription=${subid}`);
65
- }
66
- }
67
- };
68
- this.send = async (method, params, _isCacheable, subscription)=>{
69
- try {
70
- logger.debug('send', {
71
- method,
72
- params
73
- });
74
- const rpcHandler = providerHandlers[method];
75
- if (!rpcHandler) {
76
- logger.error(`Unable to find rpc handler=${method}`);
77
- throw new Error(`Unable to find rpc handler=${method}`);
78
- }
79
- if (subscription) {
80
- logger.debug('subscribe', {
81
- method,
82
- params
83
- });
84
- const subid = await rpcHandler({
85
- chain: this.chain
86
- }, params, this.subscriptionManager);
87
- if (!subid) {
88
- throw new Error(`Unable to subscribe=${method}`);
89
- }
90
- this.#subscriptions[subid] = {
91
- callback: subscription.callback,
92
- method,
93
- params,
94
- type: subscription.type
95
- };
96
- return subid;
97
- }
98
- logger.debug('call', {
99
- method,
100
- params
101
- });
102
- return rpcHandler({
103
- chain: this.chain
104
- }, params, this.subscriptionManager);
105
- } catch (e) {
106
- logger.error('send error.', e);
107
- throw e;
108
- }
109
- };
110
21
  this.#isReadyPromise = new Promise((resolve, reject)=>{
111
22
  this.#eventemitter.once('connected', resolve);
112
23
  this.#eventemitter.once('error', reject);
@@ -133,12 +44,92 @@ const logger = defaultLogger.child({
133
44
  get isReady() {
134
45
  return this.#isReadyPromise;
135
46
  }
136
- clone;
137
- connect;
138
- disconnect;
139
- on;
140
- subscriptionManager;
141
- send;
47
+ clone = ()=>{
48
+ return new ChopsticksProvider(this.chain);
49
+ };
50
+ connect = async ()=>{
51
+ this.#isConnected = true;
52
+ this.#eventemitter.emit('connected');
53
+ };
54
+ disconnect = async ()=>{
55
+ this.#isConnected = false;
56
+ this.#eventemitter.emit('disconnected');
57
+ };
58
+ on = (type, sub)=>{
59
+ this.#eventemitter.on(type, sub);
60
+ return ()=>{
61
+ this.#eventemitter.removeListener(type, sub);
62
+ };
63
+ };
64
+ subscriptionManager = {
65
+ subscribe: (method, subid, onCancel = ()=>{})=>{
66
+ const sub = this.#subscriptions[subid];
67
+ if (sub) {
68
+ sub.onCancel = onCancel;
69
+ }
70
+ return (data)=>{
71
+ logger.debug('subscribe-callback', method, subid, data);
72
+ const sub = this.#subscriptions[subid];
73
+ if (sub) {
74
+ sub.callback(null, data);
75
+ } else {
76
+ logger.trace(`Unable to find active subscription=${subid}`);
77
+ }
78
+ };
79
+ },
80
+ unsubscribe: (subid)=>{
81
+ logger.debug('unsubscribe-callback', subid);
82
+ const sub = this.#subscriptions[subid];
83
+ if (sub) {
84
+ sub.onCancel?.();
85
+ delete this.#subscriptions[subid];
86
+ } else {
87
+ logger.trace(`Unable to find active subscription=${subid}`);
88
+ }
89
+ }
90
+ };
91
+ send = async (method, params, _isCacheable, subscription)=>{
92
+ try {
93
+ logger.debug('send', {
94
+ method,
95
+ params
96
+ });
97
+ const rpcHandler = providerHandlers[method];
98
+ if (!rpcHandler) {
99
+ logger.error(`Unable to find rpc handler=${method}`);
100
+ throw new Error(`Unable to find rpc handler=${method}`);
101
+ }
102
+ if (subscription) {
103
+ logger.debug('subscribe', {
104
+ method,
105
+ params
106
+ });
107
+ const subid = await rpcHandler({
108
+ chain: this.chain
109
+ }, params, this.subscriptionManager);
110
+ if (!subid) {
111
+ throw new Error(`Unable to subscribe=${method}`);
112
+ }
113
+ this.#subscriptions[subid] = {
114
+ callback: subscription.callback,
115
+ method,
116
+ params,
117
+ type: subscription.type
118
+ };
119
+ return subid;
120
+ }
121
+ logger.debug('call', {
122
+ method,
123
+ params
124
+ });
125
+ return rpcHandler({
126
+ chain: this.chain
127
+ }, params, this.subscriptionManager);
128
+ } catch (e) {
129
+ logger.error('send error.', e);
130
+ throw e;
131
+ }
132
+ };
142
133
  subscribe(type, method, params, callback) {
143
134
  return this.send(method, params, false, {
144
135
  callback,
@@ -1,3 +1,4 @@
1
+ import { blake2AsHex } from '@polkadot/util-crypto';
1
2
  import { defaultLogger } from '../../logger.js';
2
3
  import { ResponseError } from '../shared.js';
3
4
  const logger = defaultLogger.child({
@@ -216,6 +217,23 @@ async function getDescendantValues(block, params) {
216
217
  }
217
218
  return null;
218
219
  }
220
+ case 'hash':
221
+ {
222
+ const value = await block.get(sir.key);
223
+ if (value) {
224
+ following.get(followSubscription)?.callback({
225
+ event: 'operationStorageItems',
226
+ operationId,
227
+ items: [
228
+ {
229
+ key: sir.key,
230
+ hash: blake2AsHex(value)
231
+ }
232
+ ]
233
+ });
234
+ }
235
+ return null;
236
+ }
219
237
  case 'descendantsValues':
220
238
  {
221
239
  const { items, next } = await getDescendantValues(block, {
@@ -229,6 +247,25 @@ async function getDescendantValues(block, params) {
229
247
  });
230
248
  return next;
231
249
  }
250
+ case 'descendantsHashes':
251
+ {
252
+ const { items, next } = await getDescendantValues(block, {
253
+ prefix: sir.key,
254
+ startKey: '0x'
255
+ });
256
+ following.get(followSubscription)?.callback({
257
+ event: 'operationStorageItems',
258
+ operationId,
259
+ items: items.map(({ key, value })=>({
260
+ key,
261
+ hash: value !== undefined ? blake2AsHex(value) : undefined
262
+ }))
263
+ });
264
+ return next ? {
265
+ ...next,
266
+ isDescendantHashes: true
267
+ } : null;
268
+ }
232
269
  case 'closestDescendantMerkleValue':
233
270
  {
234
271
  const followingSubscription = following.get(followSubscription);
@@ -249,10 +286,6 @@ async function getDescendantValues(block, params) {
249
286
  });
250
287
  return null;
251
288
  }
252
- default:
253
- // TODO
254
- console.warn(`Storage type not implemented ${sir.type}`);
255
- return null;
256
289
  }
257
290
  };
258
291
  const listResult = await Promise.all(items.map(handleStorageItemRequest));
@@ -329,7 +362,10 @@ const limitReached = {
329
362
  follower.callback({
330
363
  event: 'operationStorageItems',
331
364
  operationId,
332
- items
365
+ items: params.isDescendantHashes ? items.map(({ key, value })=>({
366
+ key,
367
+ hash: value !== undefined ? blake2AsHex(value) : value
368
+ })) : items
333
369
  });
334
370
  return next;
335
371
  };
@@ -3,9 +3,8 @@ export default class KeyCache {
3
3
  prefixLength;
4
4
  constructor(prefixLength){
5
5
  this.prefixLength = prefixLength;
6
- this.ranges = [];
7
6
  }
8
- ranges;
7
+ ranges = [];
9
8
  feed(keys) {
10
9
  const _keys = keys.filter((key)=>key.length >= this.prefixLength);
11
10
  if (_keys.length === 0) return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@acala-network/chopsticks-core",
3
- "version": "1.0.6",
3
+ "version": "1.1.0",
4
4
  "author": "Acala Developers <hello@acala.network>",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -14,28 +14,28 @@
14
14
  "depcheck": "npx depcheck"
15
15
  },
16
16
  "dependencies": {
17
- "@acala-network/chopsticks-executor": "1.0.6",
18
- "@polkadot/rpc-provider": "^15.7.1",
19
- "@polkadot/types": "^15.7.1",
20
- "@polkadot/types-codec": "^15.7.1",
21
- "@polkadot/types-known": "^15.7.1",
22
- "@polkadot/util": "^13.4.3",
23
- "@polkadot/util-crypto": "^13.4.3",
17
+ "@acala-network/chopsticks-executor": "1.1.0",
18
+ "@polkadot/rpc-provider": "^16.2.1",
19
+ "@polkadot/types": "^16.2.1",
20
+ "@polkadot/types-codec": "^16.2.1",
21
+ "@polkadot/types-known": "^16.2.1",
22
+ "@polkadot/util": "^13.5.1",
23
+ "@polkadot/util-crypto": "^13.5.1",
24
24
  "comlink": "^4.4.2",
25
25
  "eventemitter3": "^5.0.1",
26
26
  "lodash": "^4.17.21",
27
- "lru-cache": "^11.0.2",
28
- "pino": "^9.6.0",
27
+ "lru-cache": "^11.1.0",
28
+ "pino": "^9.7.0",
29
29
  "pino-pretty": "^13.0.0",
30
30
  "rxjs": "^7.8.2",
31
- "zod": "^3.24.2"
31
+ "zod": "^3.25.64"
32
32
  },
33
33
  "devDependencies": {
34
- "@swc/cli": "0.6.0",
35
- "@swc/core": "^1.11.1",
36
- "@types/lodash": "^4.17.15",
37
- "typescript": "^5.7.3",
38
- "vitest": "^3.0.7"
34
+ "@swc/cli": "0.7.7",
35
+ "@swc/core": "^1.12.1",
36
+ "@types/lodash": "^4.17.17",
37
+ "typescript": "^5.8.3",
38
+ "vitest": "^3.2.3"
39
39
  },
40
40
  "files": [
41
41
  "dist/esm/**",