@acala-network/chopsticks-core 1.0.2-2 → 1.0.2

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.
Files changed (159) hide show
  1. package/dist/cjs/api.d.ts +4 -4
  2. package/dist/cjs/api.js +20 -23
  3. package/dist/cjs/blockchain/block-builder.d.ts +5 -5
  4. package/dist/cjs/blockchain/block-builder.js +17 -18
  5. package/dist/cjs/blockchain/block.d.ts +6 -6
  6. package/dist/cjs/blockchain/block.js +1 -1
  7. package/dist/cjs/blockchain/head-state.d.ts +1 -1
  8. package/dist/cjs/blockchain/index.d.ts +9 -9
  9. package/dist/cjs/blockchain/index.js +5 -5
  10. package/dist/cjs/blockchain/inherent/index.d.ts +5 -5
  11. package/dist/cjs/blockchain/inherent/index.js +1 -1
  12. package/dist/cjs/blockchain/inherent/para-enter.d.ts +4 -4
  13. package/dist/cjs/blockchain/inherent/parachain/babe-randomness.d.ts +4 -4
  14. package/dist/cjs/blockchain/inherent/parachain/nimbus-author-inherent.d.ts +4 -4
  15. package/dist/cjs/blockchain/inherent/parachain/validation-data.d.ts +4 -4
  16. package/dist/cjs/blockchain/inherent/parachain/validation-data.js +3 -3
  17. package/dist/cjs/blockchain/inherent/timestamp.d.ts +3 -3
  18. package/dist/cjs/blockchain/storage-layer.d.ts +3 -3
  19. package/dist/cjs/blockchain/storage-layer.js +5 -4
  20. package/dist/cjs/blockchain/txpool.d.ts +3 -3
  21. package/dist/cjs/blockchain/txpool.js +2 -2
  22. package/dist/cjs/chopsticks-provider.d.ts +3 -3
  23. package/dist/cjs/chopsticks-provider.js +8 -9
  24. package/dist/cjs/database.d.ts +1 -1
  25. package/dist/cjs/genesis-provider.d.ts +4 -4
  26. package/dist/cjs/genesis-provider.js +12 -12
  27. package/dist/cjs/index.d.ts +1 -1
  28. package/dist/cjs/logger.js +2 -3
  29. package/dist/cjs/offchain.d.ts +2 -2
  30. package/dist/cjs/offchain.js +1 -1
  31. package/dist/cjs/rpc/dev/new-block.d.ts +5 -5
  32. package/dist/cjs/rpc/dev/new-block.js +1 -1
  33. package/dist/cjs/rpc/dev/set-block-build-mode.d.ts +1 -1
  34. package/dist/cjs/rpc/dev/set-block-build-mode.js +1 -1
  35. package/dist/cjs/rpc/dev/set-head.d.ts +1 -1
  36. package/dist/cjs/rpc/dev/set-head.js +1 -1
  37. package/dist/cjs/rpc/dev/set-runtime-log-level.d.ts +1 -1
  38. package/dist/cjs/rpc/dev/set-runtime-log-level.js +1 -1
  39. package/dist/cjs/rpc/dev/set-storage.d.ts +3 -3
  40. package/dist/cjs/rpc/dev/set-storage.js +1 -1
  41. package/dist/cjs/rpc/dev/time-travel.d.ts +1 -1
  42. package/dist/cjs/rpc/dev/time-travel.js +1 -1
  43. package/dist/cjs/rpc/index.d.ts +1 -1
  44. package/dist/cjs/rpc/rpc-spec/chainHead_v1.d.ts +11 -2
  45. package/dist/cjs/rpc/rpc-spec/chainHead_v1.js +33 -2
  46. package/dist/cjs/rpc/rpc-spec/chainSpec_v1.d.ts +3 -3
  47. package/dist/cjs/rpc/rpc-spec/transaction_v1.d.ts +2 -2
  48. package/dist/cjs/rpc/shared.d.ts +1 -1
  49. package/dist/cjs/rpc/substrate/archive.d.ts +2 -2
  50. package/dist/cjs/rpc/substrate/author.d.ts +2 -2
  51. package/dist/cjs/rpc/substrate/author.js +1 -1
  52. package/dist/cjs/rpc/substrate/chain.d.ts +2 -2
  53. package/dist/cjs/rpc/substrate/payment.d.ts +2 -2
  54. package/dist/cjs/rpc/substrate/state.d.ts +3 -3
  55. package/dist/cjs/rpc/substrate/state.js +1 -1
  56. package/dist/cjs/rpc/substrate/system.d.ts +3 -3
  57. package/dist/cjs/setup.d.ts +4 -4
  58. package/dist/cjs/setup.js +1 -1
  59. package/dist/cjs/utils/decoder.d.ts +5 -5
  60. package/dist/cjs/utils/decoder.js +2 -2
  61. package/dist/cjs/utils/index.d.ts +4 -4
  62. package/dist/cjs/utils/index.js +1 -1
  63. package/dist/cjs/utils/key-cache.d.ts +1 -1
  64. package/dist/cjs/utils/proof.d.ts +3 -3
  65. package/dist/cjs/utils/set-storage.d.ts +2 -2
  66. package/dist/cjs/utils/set-storage.js +1 -1
  67. package/dist/cjs/utils/time-travel.d.ts +1 -1
  68. package/dist/cjs/utils/well-known-keys.d.ts +2 -2
  69. package/dist/cjs/utils/well-known-keys.js +2 -2
  70. package/dist/cjs/wasm-executor/browser-wasm-executor.js +1 -1
  71. package/dist/cjs/wasm-executor/index.d.ts +3 -3
  72. package/dist/cjs/wasm-executor/index.js +14 -20
  73. package/dist/cjs/wasm-executor/node-wasm-executor.js +1 -1
  74. package/dist/cjs/wasm-executor/node-worker.js +1 -1
  75. package/dist/cjs/xcm/downward.d.ts +1 -1
  76. package/dist/cjs/xcm/horizontal.d.ts +1 -1
  77. package/dist/cjs/xcm/index.d.ts +1 -1
  78. package/dist/cjs/xcm/index.js +2 -2
  79. package/dist/cjs/xcm/upward.d.ts +1 -1
  80. package/dist/esm/api.d.ts +4 -4
  81. package/dist/esm/api.js +20 -23
  82. package/dist/esm/blockchain/block-builder.d.ts +5 -5
  83. package/dist/esm/blockchain/block-builder.js +17 -18
  84. package/dist/esm/blockchain/block.d.ts +6 -6
  85. package/dist/esm/blockchain/block.js +1 -1
  86. package/dist/esm/blockchain/head-state.d.ts +1 -1
  87. package/dist/esm/blockchain/index.d.ts +9 -9
  88. package/dist/esm/blockchain/index.js +5 -5
  89. package/dist/esm/blockchain/inherent/index.d.ts +5 -5
  90. package/dist/esm/blockchain/inherent/index.js +1 -1
  91. package/dist/esm/blockchain/inherent/para-enter.d.ts +4 -4
  92. package/dist/esm/blockchain/inherent/parachain/babe-randomness.d.ts +4 -4
  93. package/dist/esm/blockchain/inherent/parachain/nimbus-author-inherent.d.ts +4 -4
  94. package/dist/esm/blockchain/inherent/parachain/validation-data.d.ts +4 -4
  95. package/dist/esm/blockchain/inherent/parachain/validation-data.js +3 -3
  96. package/dist/esm/blockchain/inherent/timestamp.d.ts +3 -3
  97. package/dist/esm/blockchain/storage-layer.d.ts +3 -3
  98. package/dist/esm/blockchain/storage-layer.js +5 -4
  99. package/dist/esm/blockchain/txpool.d.ts +3 -3
  100. package/dist/esm/blockchain/txpool.js +2 -2
  101. package/dist/esm/chopsticks-provider.d.ts +3 -3
  102. package/dist/esm/chopsticks-provider.js +8 -9
  103. package/dist/esm/database.d.ts +1 -1
  104. package/dist/esm/genesis-provider.d.ts +4 -4
  105. package/dist/esm/genesis-provider.js +3 -3
  106. package/dist/esm/index.d.ts +1 -1
  107. package/dist/esm/logger.js +2 -3
  108. package/dist/esm/offchain.d.ts +2 -2
  109. package/dist/esm/offchain.js +1 -1
  110. package/dist/esm/rpc/dev/new-block.d.ts +5 -5
  111. package/dist/esm/rpc/dev/new-block.js +1 -1
  112. package/dist/esm/rpc/dev/set-block-build-mode.d.ts +1 -1
  113. package/dist/esm/rpc/dev/set-block-build-mode.js +1 -1
  114. package/dist/esm/rpc/dev/set-head.d.ts +1 -1
  115. package/dist/esm/rpc/dev/set-head.js +1 -1
  116. package/dist/esm/rpc/dev/set-runtime-log-level.d.ts +1 -1
  117. package/dist/esm/rpc/dev/set-runtime-log-level.js +1 -1
  118. package/dist/esm/rpc/dev/set-storage.d.ts +3 -3
  119. package/dist/esm/rpc/dev/set-storage.js +1 -1
  120. package/dist/esm/rpc/dev/time-travel.d.ts +1 -1
  121. package/dist/esm/rpc/dev/time-travel.js +1 -1
  122. package/dist/esm/rpc/index.d.ts +1 -1
  123. package/dist/esm/rpc/rpc-spec/chainHead_v1.d.ts +11 -2
  124. package/dist/esm/rpc/rpc-spec/chainHead_v1.js +42 -2
  125. package/dist/esm/rpc/rpc-spec/chainSpec_v1.d.ts +3 -3
  126. package/dist/esm/rpc/rpc-spec/transaction_v1.d.ts +2 -2
  127. package/dist/esm/rpc/shared.d.ts +1 -1
  128. package/dist/esm/rpc/substrate/archive.d.ts +2 -2
  129. package/dist/esm/rpc/substrate/author.d.ts +2 -2
  130. package/dist/esm/rpc/substrate/author.js +1 -1
  131. package/dist/esm/rpc/substrate/chain.d.ts +2 -2
  132. package/dist/esm/rpc/substrate/payment.d.ts +2 -2
  133. package/dist/esm/rpc/substrate/state.d.ts +3 -3
  134. package/dist/esm/rpc/substrate/state.js +1 -1
  135. package/dist/esm/rpc/substrate/system.d.ts +3 -3
  136. package/dist/esm/setup.d.ts +4 -4
  137. package/dist/esm/setup.js +1 -1
  138. package/dist/esm/utils/decoder.d.ts +5 -5
  139. package/dist/esm/utils/decoder.js +2 -2
  140. package/dist/esm/utils/index.d.ts +4 -4
  141. package/dist/esm/utils/index.js +1 -1
  142. package/dist/esm/utils/key-cache.d.ts +1 -1
  143. package/dist/esm/utils/proof.d.ts +3 -3
  144. package/dist/esm/utils/set-storage.d.ts +2 -2
  145. package/dist/esm/utils/set-storage.js +1 -1
  146. package/dist/esm/utils/time-travel.d.ts +1 -1
  147. package/dist/esm/utils/well-known-keys.d.ts +2 -2
  148. package/dist/esm/utils/well-known-keys.js +2 -2
  149. package/dist/esm/wasm-executor/browser-wasm-executor.js +1 -1
  150. package/dist/esm/wasm-executor/index.d.ts +3 -3
  151. package/dist/esm/wasm-executor/index.js +14 -20
  152. package/dist/esm/wasm-executor/node-wasm-executor.js +1 -1
  153. package/dist/esm/wasm-executor/node-worker.js +1 -1
  154. package/dist/esm/xcm/downward.d.ts +1 -1
  155. package/dist/esm/xcm/horizontal.d.ts +1 -1
  156. package/dist/esm/xcm/index.d.ts +1 -1
  157. package/dist/esm/xcm/index.js +2 -2
  158. package/dist/esm/xcm/upward.d.ts +1 -1
  159. package/package.json +2 -2
@@ -1,5 +1,5 @@
1
- import { Context } from '../shared.js';
2
1
  import { z } from 'zod';
2
+ import { type Context } from '../shared.js';
3
3
  declare const schema: z.ZodObject<{
4
4
  count: z.ZodOptional<z.ZodNumber>;
5
5
  to: z.ZodOptional<z.ZodNumber>;
@@ -31,6 +31,8 @@ declare const schema: z.ZodObject<{
31
31
  }, "strip", z.ZodTypeAny, {
32
32
  transactions?: `0x${string}`[] | undefined;
33
33
  unsafeBlockHeight?: number | undefined;
34
+ relayChainStateOverrides?: [`0x${string}`, `0x${string}` | null][] | undefined;
35
+ relayParentNumber?: number | undefined;
34
36
  ump?: Record<number, `0x${string}`[]> | undefined;
35
37
  dmp?: {
36
38
  msg: `0x${string}`;
@@ -40,13 +42,13 @@ declare const schema: z.ZodObject<{
40
42
  data: `0x${string}`;
41
43
  sentAt: number;
42
44
  }[]> | undefined;
43
- relayChainStateOverrides?: [`0x${string}`, `0x${string}` | null][] | undefined;
44
- relayParentNumber?: number | undefined;
45
45
  count?: number | undefined;
46
46
  to?: number | undefined;
47
47
  }, {
48
48
  transactions?: `0x${string}`[] | undefined;
49
49
  unsafeBlockHeight?: number | undefined;
50
+ relayChainStateOverrides?: [`0x${string}`, `0x${string}` | null][] | undefined;
51
+ relayParentNumber?: number | undefined;
50
52
  ump?: Record<number, `0x${string}`[]> | undefined;
51
53
  dmp?: {
52
54
  msg: `0x${string}`;
@@ -56,8 +58,6 @@ declare const schema: z.ZodObject<{
56
58
  data: `0x${string}`;
57
59
  sentAt: number;
58
60
  }[]> | undefined;
59
- relayChainStateOverrides?: [`0x${string}`, `0x${string}` | null][] | undefined;
60
- relayParentNumber?: number | undefined;
61
61
  count?: number | undefined;
62
62
  to?: number | undefined;
63
63
  }>;
@@ -8,8 +8,8 @@ Object.defineProperty(exports, "dev_newBlock", {
8
8
  return dev_newBlock;
9
9
  }
10
10
  });
11
- const _shared = require("../shared.js");
12
11
  const _zod = require("zod");
12
+ const _shared = require("../shared.js");
13
13
  const _logger = require("../../logger.js");
14
14
  const schema = _zod.z.object({
15
15
  count: _zod.z.number().optional(),
@@ -1,5 +1,5 @@
1
1
  import { BuildBlockMode } from '../../blockchain/txpool.js';
2
- import { Context } from '../shared.js';
2
+ import { type Context } from '../shared.js';
3
3
  /**
4
4
  * Set block build mode.
5
5
  *
@@ -9,8 +9,8 @@ Object.defineProperty(exports, "dev_setBlockBuildMode", {
9
9
  }
10
10
  });
11
11
  const _txpool = require("../../blockchain/txpool.js");
12
- const _shared = require("../shared.js");
13
12
  const _logger = require("../../logger.js");
13
+ const _shared = require("../shared.js");
14
14
  const dev_setBlockBuildMode = async (context, [mode])=>{
15
15
  _logger.defaultLogger.debug({
16
16
  mode: _txpool.BuildBlockMode[mode]
@@ -1,5 +1,5 @@
1
- import { Context } from '../shared.js';
2
1
  import { z } from 'zod';
2
+ import { type Context } from '../shared.js';
3
3
  declare const schema: z.ZodUnion<[z.ZodIntersection<z.ZodString, z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>>, z.ZodNumber]>;
4
4
  type Params = z.infer<typeof schema>;
5
5
  /**
@@ -8,8 +8,8 @@ Object.defineProperty(exports, "dev_setHead", {
8
8
  return dev_setHead;
9
9
  }
10
10
  });
11
- const _shared = require("../shared.js");
12
11
  const _zod = require("zod");
12
+ const _shared = require("../shared.js");
13
13
  const schema = _shared.zHash.or(_zod.z.number());
14
14
  const dev_setHead = async (context, [params])=>{
15
15
  const hashOrNumber = schema.parse(params);
@@ -1,4 +1,4 @@
1
- import { Context } from '../shared.js';
1
+ import { type Context } from '../shared.js';
2
2
  /**
3
3
  * Set runtime log level.
4
4
  *
@@ -8,8 +8,8 @@ Object.defineProperty(exports, "dev_setRuntimeLogLevel", {
8
8
  return dev_setRuntimeLogLevel;
9
9
  }
10
10
  });
11
- const _shared = require("../shared.js");
12
11
  const _logger = require("../../logger.js");
12
+ const _shared = require("../shared.js");
13
13
  const dev_setRuntimeLogLevel = async (context, [runtimeLogLevel])=>{
14
14
  _logger.defaultLogger.debug({
15
15
  runtimeLogLevel
@@ -1,6 +1,6 @@
1
- import { Context } from '../shared.js';
2
- import { HexString } from '@polkadot/util/types';
3
- import { StorageValues } from '../../utils/set-storage.js';
1
+ import type { HexString } from '@polkadot/util/types';
2
+ import { type Context } from '../shared.js';
3
+ import { type StorageValues } from '../../utils/set-storage.js';
4
4
  /**
5
5
  * Set storage values.
6
6
  *
@@ -9,8 +9,8 @@ Object.defineProperty(exports, "dev_setStorage", {
9
9
  }
10
10
  });
11
11
  const _shared = require("../shared.js");
12
- const _setstorage = require("../../utils/set-storage.js");
13
12
  const _logger = require("../../logger.js");
13
+ const _setstorage = require("../../utils/set-storage.js");
14
14
  const dev_setStorage = async (context, params)=>{
15
15
  const [values, blockHash] = params;
16
16
  const hash = await (0, _setstorage.setStorage)(context.chain, values, blockHash).catch((error)=>{
@@ -1,4 +1,4 @@
1
- import { Context } from '../shared.js';
1
+ import { type Context } from '../shared.js';
2
2
  /**
3
3
  * Travel to a specific time.
4
4
  *
@@ -8,8 +8,8 @@ Object.defineProperty(exports, "dev_timeTravel", {
8
8
  return dev_timeTravel;
9
9
  }
10
10
  });
11
- const _shared = require("../shared.js");
12
11
  const _timetravel = require("../../utils/time-travel.js");
12
+ const _shared = require("../shared.js");
13
13
  const dev_timeTravel = async (context, [date])=>{
14
14
  const timestamp = typeof date === 'string' ? Date.parse(date) : date;
15
15
  if (Number.isNaN(timestamp)) throw new _shared.ResponseError(1, 'Invalid date');
@@ -1,5 +1,5 @@
1
- import { Handlers } from './shared.js';
2
1
  import dev from './dev/index.js';
2
+ import type { Handlers } from './shared.js';
3
3
  import substrate from './substrate/index.js';
4
4
  export declare const allHandlers: Handlers;
5
5
  export { substrate, dev };
@@ -1,5 +1,5 @@
1
- import { Handler } from '../shared.js';
2
- import { HexString } from '@polkadot/util/types';
1
+ import type { HexString } from '@polkadot/util/types';
2
+ import { type Handler } from '../shared.js';
3
3
  /**
4
4
  * Start a chainHead follow subscription
5
5
  *
@@ -54,6 +54,15 @@ export interface StorageItemRequest {
54
54
  * @param params - [`followSubscription`, `hash`, `items`, `childTrie`]
55
55
  *
56
56
  * @return OperationStarted event with operationId to receive the result on the follow subscription
57
+ *
58
+ * The query type `closestDescendantMerkleValue` is not up to spec.
59
+ * According to the spec, the result should be the Merkle value of the key or
60
+ * the closest descendant of the key.
61
+ * As chopsticks doesn't have direct access to the Merkle tree, it will return
62
+ * a string that will change every time that one of the descendant changes, but
63
+ * it won't be the actual Merkle value.
64
+ * This should be enough for applications that don't rely on the actual Merkle
65
+ * value, but just use it to detect for storage changes.
57
66
  */
58
67
  export declare const chainHead_v1_storage: Handler<[
59
68
  string,
@@ -37,8 +37,8 @@ _export(exports, {
37
37
  return chainHead_v1_unpin;
38
38
  }
39
39
  });
40
- const _shared = require("../shared.js");
41
40
  const _logger = require("../../logger.js");
41
+ const _shared = require("../shared.js");
42
42
  const logger = _logger.defaultLogger.child({
43
43
  name: 'rpc-chainHead_v1'
44
44
  });
@@ -78,6 +78,16 @@ const chainHead_v1_follow = async (context, [withRuntime], { subscribe })=>{
78
78
  ],
79
79
  prunedBlockHashes: []
80
80
  });
81
+ const storageDiffs = following.get(id)?.storageDiffs;
82
+ if (storageDiffs?.size) {
83
+ // Fetch the storage diffs and update the `closestDescendantMerkleValue` for those that changed
84
+ const diffKeys = Object.keys(await block.storageDiff());
85
+ for (const [prefix, value] of storageDiffs.entries()){
86
+ if (diffKeys.some((key)=>key.startsWith(prefix))) {
87
+ storageDiffs.set(prefix, value + 1);
88
+ }
89
+ }
90
+ }
81
91
  };
82
92
  const id = context.chain.headState.subscribeHead(update);
83
93
  const cleanup = ()=>{
@@ -87,7 +97,8 @@ const chainHead_v1_follow = async (context, [withRuntime], { subscribe })=>{
87
97
  const callback = subscribe('chainHead_v1_followEvent', id, cleanup);
88
98
  following.set(id, {
89
99
  callback,
90
- pendingDescendantValues: new Map()
100
+ pendingDescendantValues: new Map(),
101
+ storageDiffs: new Map()
91
102
  });
92
103
  afterResponse(async ()=>{
93
104
  callback({
@@ -213,6 +224,26 @@ const chainHead_v1_storage = async (context, [followSubscription, hash, items, _
213
224
  });
214
225
  return next;
215
226
  }
227
+ case 'closestDescendantMerkleValue':
228
+ {
229
+ const followingSubscription = following.get(followSubscription);
230
+ if (!followingSubscription) return null;
231
+ if (!followingSubscription.storageDiffs.has(sir.key)) {
232
+ // Set up a diff watch for this key
233
+ followingSubscription.storageDiffs.set(sir.key, 0);
234
+ }
235
+ followingSubscription.callback({
236
+ event: 'operationStorageItems',
237
+ operationId,
238
+ items: [
239
+ {
240
+ key: sir.key,
241
+ closestDescendantMerkleValue: String(followingSubscription.storageDiffs.get(sir.key))
242
+ }
243
+ ]
244
+ });
245
+ return null;
246
+ }
216
247
  default:
217
248
  // TODO
218
249
  console.warn(`Storage type not implemented ${sir.type}`);
@@ -1,6 +1,6 @@
1
- import { ChainProperties } from '../../index.js';
2
- import { Handler } from '../shared.js';
3
- import { HexString } from '@polkadot/util/types';
1
+ import type { HexString } from '@polkadot/util/types';
2
+ import type { ChainProperties } from '../../index.js';
3
+ import { type Handler } from '../shared.js';
4
4
  export declare const chainSpec_v1_chainName: Handler<[], string>;
5
5
  export declare const chainSpec_v1_genesisHash: Handler<[], HexString>;
6
6
  export declare const chainSpec_v1_properties: Handler<[], ChainProperties>;
@@ -1,5 +1,5 @@
1
- import { Handler } from '../shared.js';
2
- import { HexString } from '@polkadot/util/types';
1
+ import type { HexString } from '@polkadot/util/types';
2
+ import type { Handler } from '../shared.js';
3
3
  /**
4
4
  * Submit the extrinsic to the transaction pool
5
5
  *
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { Blockchain } from '../blockchain/index.js';
2
+ import type { Blockchain } from '../blockchain/index.js';
3
3
  export declare const logger: import("pino").default.Logger<never, boolean>;
4
4
  export declare const zHex: z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>;
5
5
  export declare const zHash: z.ZodIntersection<z.ZodString, z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>>;
@@ -1,5 +1,5 @@
1
- import { HexString } from '@polkadot/util/types';
2
- import { Handler } from '../shared.js';
1
+ import type { HexString } from '@polkadot/util/types';
2
+ import { type Handler } from '../shared.js';
3
3
  /**
4
4
  * @param context
5
5
  * @param params - [`blockhash`]
@@ -1,5 +1,5 @@
1
- import { HexString } from '@polkadot/util/types';
2
- import { Handler } from '../shared.js';
1
+ import type { HexString } from '@polkadot/util/types';
2
+ import { type Handler } from '../shared.js';
3
3
  /**
4
4
  * @param context
5
5
  * @param params - [`extrinsic`]
@@ -23,8 +23,8 @@ _export(exports, {
23
23
  }
24
24
  });
25
25
  const _txpool = require("../../blockchain/txpool.js");
26
- const _shared = require("../shared.js");
27
26
  const _logger = require("../../logger.js");
27
+ const _shared = require("../shared.js");
28
28
  const logger = _logger.defaultLogger.child({
29
29
  name: 'rpc-author'
30
30
  });
@@ -1,6 +1,6 @@
1
- import { HexString } from '@polkadot/util/types';
2
- import { Handler } from '../shared.js';
1
+ import type { HexString } from '@polkadot/util/types';
3
2
  import type { Header } from '../../index.js';
3
+ import { type Handler } from '../shared.js';
4
4
  /**
5
5
  * @param context
6
6
  * @param params - [`blockNumber` | `blockNumber[]` | null]
@@ -1,5 +1,5 @@
1
- import { HexString } from '@polkadot/util/types';
2
- import { Handler } from '../shared.js';
1
+ import type { HexString } from '@polkadot/util/types';
2
+ import { type Handler } from '../shared.js';
3
3
  /**
4
4
  * @param context
5
5
  * @param params - [`extrinsic`, `blockhash`]
@@ -1,6 +1,6 @@
1
- import { HexString } from '@polkadot/util/types';
2
- import { Handler } from '../shared.js';
3
- import { RuntimeVersion } from '../../wasm-executor/index.js';
1
+ import type { HexString } from '@polkadot/util/types';
2
+ import type { RuntimeVersion } from '../../wasm-executor/index.js';
3
+ import { type Handler } from '../shared.js';
4
4
  /**
5
5
  * @param context
6
6
  * @param params - [`blockhash`]
@@ -50,9 +50,9 @@ _export(exports, {
50
50
  }
51
51
  });
52
52
  const _util = require("@polkadot/util");
53
- const _shared = require("../shared.js");
54
53
  const _logger = require("../../logger.js");
55
54
  const _index = require("../../utils/index.js");
55
+ const _shared = require("../shared.js");
56
56
  const logger = _logger.defaultLogger.child({
57
57
  name: 'rpc-state'
58
58
  });
@@ -1,6 +1,6 @@
1
- import { HexString } from '@polkadot/util/types';
2
- import { ChainProperties } from '../../index.js';
3
- import { Handler } from '../shared.js';
1
+ import type { HexString } from '@polkadot/util/types';
2
+ import type { ChainProperties } from '../../index.js';
3
+ import type { Handler } from '../shared.js';
4
4
  export declare const system_localPeerId: () => Promise<string>;
5
5
  export declare const system_nodeRoles: () => Promise<string[]>;
6
6
  export declare const system_localListenAddresses: () => Promise<never[]>;
@@ -1,10 +1,10 @@
1
1
  import '@polkadot/types-codec';
2
- import { RegisteredTypes } from '@polkadot/types/types';
2
+ import type { RegisteredTypes } from '@polkadot/types/types';
3
3
  import { Api } from './api.js';
4
4
  import { Blockchain } from './blockchain/index.js';
5
- import { BuildBlockMode } from './blockchain/txpool.js';
6
- import { Database } from './database.js';
7
- import { GenesisProvider } from './genesis-provider.js';
5
+ import type { BuildBlockMode } from './blockchain/txpool.js';
6
+ import type { Database } from './database.js';
7
+ import type { GenesisProvider } from './genesis-provider.js';
8
8
  export type SetupOptions = {
9
9
  endpoint?: string | string[];
10
10
  block?: string | number | null;
package/dist/cjs/setup.js CHANGED
@@ -20,8 +20,8 @@ require("@polkadot/types-codec");
20
20
  const _rpcprovider = require("@polkadot/rpc-provider");
21
21
  const _api = require("./api.js");
22
22
  const _index = require("./blockchain/index.js");
23
- const _logger = require("./logger.js");
24
23
  const _index1 = require("./blockchain/inherent/index.js");
24
+ const _logger = require("./logger.js");
25
25
  const processOptions = async (options)=>{
26
26
  _logger.defaultLogger.debug(options, 'Setup options');
27
27
  let provider;
@@ -1,9 +1,9 @@
1
1
  import '@polkadot/types-codec';
2
- import { Block } from '../blockchain/block.js';
3
- import { DecoratedMeta } from '@polkadot/types/metadata/decorate/types';
4
- import { HexString } from '@polkadot/util/types';
5
- import { StorageEntry } from '@polkadot/types/primitive/types';
6
- import { StorageKey } from '@polkadot/types';
2
+ import type { StorageKey } from '@polkadot/types';
3
+ import type { DecoratedMeta } from '@polkadot/types/metadata/decorate/types';
4
+ import type { StorageEntry } from '@polkadot/types/primitive/types';
5
+ import type { HexString } from '@polkadot/util/types';
6
+ import type { Block } from '../blockchain/block.js';
7
7
  export declare const decodeKey: (meta: DecoratedMeta, key: HexString) => {
8
8
  storage?: StorageEntry;
9
9
  decodedKey?: StorageKey;
@@ -23,11 +23,11 @@ _export(exports, {
23
23
  }
24
24
  });
25
25
  require("@polkadot/types-codec");
26
- const _lrucache = require("lru-cache");
27
26
  const _util = require("@polkadot/util");
28
27
  const _lodash = /*#__PURE__*/ _interop_require_default(require("lodash"));
29
- const _wellknownkeys = require("./well-known-keys.js");
28
+ const _lrucache = require("lru-cache");
30
29
  const _logger = require("../logger.js");
30
+ const _wellknownkeys = require("./well-known-keys.js");
31
31
  function _interop_require_default(obj) {
32
32
  return obj && obj.__esModule ? obj : {
33
33
  default: obj
@@ -1,7 +1,7 @@
1
- import { HexString } from '@polkadot/util/types';
2
- import { StorageKey } from '@polkadot/types';
3
- import { Block } from '../blockchain/block.js';
4
- import { Blockchain } from '../blockchain/index.js';
1
+ import type { StorageKey } from '@polkadot/types';
2
+ import type { HexString } from '@polkadot/util/types';
3
+ import type { Block } from '../blockchain/block.js';
4
+ import type { Blockchain } from '../blockchain/index.js';
5
5
  export * from './set-storage.js';
6
6
  export * from './time-travel.js';
7
7
  export * from './decoder.js';
@@ -56,8 +56,8 @@ _export(exports, {
56
56
  }
57
57
  });
58
58
  const _util = require("@polkadot/util");
59
- const _index = require("../wasm-executor/index.js");
60
59
  const _hex = require("@polkadot/util/hex");
60
+ const _index = require("../wasm-executor/index.js");
61
61
  _export_star(require("./set-storage.js"), exports);
62
62
  _export_star(require("./time-travel.js"), exports);
63
63
  _export_star(require("./decoder.js"), exports);
@@ -1,4 +1,4 @@
1
- import { HexString } from '@polkadot/util/types';
1
+ import type { HexString } from '@polkadot/util/types';
2
2
  export default class KeyCache {
3
3
  readonly prefixLength: number;
4
4
  constructor(prefixLength: number);
@@ -1,6 +1,6 @@
1
- import { HexString } from '@polkadot/util/types';
2
- import { HrmpChannelId } from '@polkadot/types/interfaces';
3
- import { u32 } from '@polkadot/types';
1
+ import type { u32 } from '@polkadot/types';
2
+ import type { HrmpChannelId } from '@polkadot/types/interfaces';
3
+ import type { HexString } from '@polkadot/util/types';
4
4
  export declare const WELL_KNOWN_KEYS: {
5
5
  EPOCH_INDEX: HexString;
6
6
  CURRENT_BLOCK_RANDOMNESS: HexString;
@@ -1,5 +1,5 @@
1
- import { HexString } from '@polkadot/util/types';
2
- import { Blockchain } from '../blockchain/index.js';
1
+ import type { HexString } from '@polkadot/util/types';
2
+ import type { Blockchain } from '../blockchain/index.js';
3
3
  type RawStorageValues = [string, string | null][];
4
4
  type StorageConfig = Record<string, Record<string, any>>;
5
5
  export type StorageValues = RawStorageValues | StorageConfig;
@@ -9,8 +9,8 @@ Object.defineProperty(exports, "setStorage", {
9
9
  }
10
10
  });
11
11
  const _types = require("@polkadot/types");
12
- const _string = require("@polkadot/util/string");
13
12
  const _util = require("@polkadot/util");
13
+ const _string = require("@polkadot/util/string");
14
14
  const _storagelayer = require("../blockchain/storage-layer.js");
15
15
  function objectToStorageItems(meta, storage) {
16
16
  const storageItems = [];
@@ -1,2 +1,2 @@
1
- import { Blockchain } from '../blockchain/index.js';
1
+ import type { Blockchain } from '../blockchain/index.js';
2
2
  export declare const timeTravel: (chain: Blockchain, timestamp: number) => Promise<void>;
@@ -1,5 +1,5 @@
1
- import { HexString } from '@polkadot/util/types';
2
- import { Registry } from '@polkadot/types-codec/types';
1
+ import type { Registry } from '@polkadot/types-codec/types';
2
+ import type { HexString } from '@polkadot/util/types';
3
3
  export declare const decodeWellKnownKey: (registry: Registry, key: HexString, value?: HexString | null) => {
4
4
  name: string;
5
5
  key: any[];
@@ -8,8 +8,8 @@ Object.defineProperty(exports, "decodeWellKnownKey", {
8
8
  return decodeWellKnownKey;
9
9
  }
10
10
  });
11
- const _utilcrypto = require("@polkadot/util-crypto");
12
11
  const _util = require("@polkadot/util");
12
+ const _utilcrypto = require("@polkadot/util-crypto");
13
13
  const decodeValue = (type)=>(registry, value)=>{
14
14
  return registry.createType(type, (0, _util.hexToU8a)(value)).toJSON();
15
15
  };
@@ -62,7 +62,7 @@ const wellKnownKeys = [
62
62
  prefixHex: '0xf5207f03cfdce586301014700e2c2593fad157e461d71fd4c1f936839a5f1f3e',
63
63
  decodeKey: (registry, key)=>{
64
64
  // get last 4 bytes
65
- const last4Bytes = '0x' + key.slice(-8);
65
+ const last4Bytes = `0x${key.slice(-8)}`;
66
66
  return [
67
67
  registry.createType('u32', (0, _util.hexToU8a)(last4Bytes)).toJSON()
68
68
  ];
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- const _comlink = /*#__PURE__*/ _interop_require_wildcard(require("comlink"));
6
5
  const _chopsticksexecutor = /*#__PURE__*/ _interop_require_wildcard(require("@acala-network/chopsticks-executor"));
6
+ const _comlink = /*#__PURE__*/ _interop_require_wildcard(require("comlink"));
7
7
  function _getRequireWildcardCache(nodeInterop) {
8
8
  if (typeof WeakMap !== "function") return null;
9
9
  var cacheBabelInterop = new WeakMap();
@@ -1,9 +1,9 @@
1
+ import type { HexString } from '@polkadot/util/types';
1
2
  import * as Comlink from 'comlink';
2
- import { HexString } from '@polkadot/util/types';
3
3
  import _ from 'lodash';
4
- import { Block } from '../blockchain/block.js';
4
+ import type { Block } from '../blockchain/block.js';
5
5
  import type { JsCallback } from '@acala-network/chopsticks-executor';
6
- export { JsCallback };
6
+ export type { JsCallback };
7
7
  export type RuntimeVersion = {
8
8
  specName: string;
9
9
  implName: string;
@@ -40,12 +40,12 @@ _export(exports, {
40
40
  return taskHandler;
41
41
  }
42
42
  });
43
- const _comlink = /*#__PURE__*/ _interop_require_wildcard(require("comlink"));
44
43
  const _util = require("@polkadot/util");
45
44
  const _utilcrypto = require("@polkadot/util-crypto");
45
+ const _comlink = /*#__PURE__*/ _interop_require_wildcard(require("comlink"));
46
46
  const _lodash = /*#__PURE__*/ _interop_require_default(require("lodash"));
47
- const _index = require("../utils/index.js");
48
47
  const _logger = require("../logger.js");
48
+ const _index = require("../utils/index.js");
49
49
  function _interop_require_default(obj) {
50
50
  return obj && obj.__esModule ? obj : {
51
51
  default: obj
@@ -154,10 +154,8 @@ const runTask = async (task, callback = emptyTaskHandler)=>{
154
154
  };
155
155
  const taskHandler = (block)=>{
156
156
  return {
157
- getStorage: async function(key) {
158
- return block.get(key);
159
- },
160
- getNextKey: async function(prefix, key) {
157
+ getStorage: async (key)=>block.get(key),
158
+ getNextKey: async (prefix, key)=>{
161
159
  const [nextKey] = await block.getKeysPaged({
162
160
  prefix: prefix.length === 2 /** 0x */ ? key.slice(0, _index.PREFIX_LENGTH) : prefix,
163
161
  pageSize: 1,
@@ -165,17 +163,13 @@ const taskHandler = (block)=>{
165
163
  });
166
164
  return nextKey && (0, _index.stripChildPrefix)(nextKey);
167
165
  },
168
- offchainGetStorage: async function(key) {
166
+ offchainGetStorage: async (key)=>{
169
167
  if (!block.chain.offchainWorker) throw new Error('offchain worker not found');
170
168
  return block.chain.offchainWorker.get(key);
171
169
  },
172
- offchainTimestamp: async function() {
173
- return Date.now();
174
- },
175
- offchainRandomSeed: async function() {
176
- return (0, _utilcrypto.randomAsHex)(32);
177
- },
178
- offchainSubmitTransaction: async function(tx) {
170
+ offchainTimestamp: async ()=>Date.now(),
171
+ offchainRandomSeed: async ()=>(0, _utilcrypto.randomAsHex)(32),
172
+ offchainSubmitTransaction: async (tx)=>{
179
173
  if (!block.chain.offchainWorker) throw new Error('offchain worker not found');
180
174
  try {
181
175
  const hash = await block.chain.offchainWorker.pushExtrinsic(block, tx);
@@ -193,22 +187,22 @@ const taskHandler = (block)=>{
193
187
  };
194
188
  };
195
189
  const emptyTaskHandler = {
196
- getStorage: async function(_key) {
190
+ getStorage: async (_key)=>{
197
191
  throw new Error('Method not implemented');
198
192
  },
199
- getNextKey: async function(_prefix, _key) {
193
+ getNextKey: async (_prefix, _key)=>{
200
194
  throw new Error('Method not implemented');
201
195
  },
202
- offchainGetStorage: async function(_key) {
196
+ offchainGetStorage: async (_key)=>{
203
197
  throw new Error('Method not implemented');
204
198
  },
205
- offchainTimestamp: async function() {
199
+ offchainTimestamp: async ()=>{
206
200
  throw new Error('Method not implemented');
207
201
  },
208
- offchainRandomSeed: async function() {
202
+ offchainRandomSeed: async ()=>{
209
203
  throw new Error('Method not implemented');
210
204
  },
211
- offchainSubmitTransaction: async function(_tx) {
205
+ offchainSubmitTransaction: async (_tx)=>{
212
206
  throw new Error('Method not implemented');
213
207
  }
214
208
  };
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- const _comlink = /*#__PURE__*/ _interop_require_wildcard(require("comlink"));
6
5
  const _chopsticksexecutor = /*#__PURE__*/ _interop_require_wildcard(require("@acala-network/chopsticks-executor"));
6
+ const _comlink = /*#__PURE__*/ _interop_require_wildcard(require("comlink"));
7
7
  const _nodeworker_threads = require("node:worker_threads");
8
8
  const _nodeadapter = /*#__PURE__*/ _interop_require_default(require("comlink/dist/umd/node-adapter.js"));
9
9
  function _interop_require_default(obj) {