@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
@@ -8,9 +8,9 @@ Object.defineProperty(exports, "startWorker", {
8
8
  return startWorker;
9
9
  }
10
10
  });
11
+ const _nodeworker_threads = /*#__PURE__*/ _interop_require_default(require("node:worker_threads"));
11
12
  const _comlink = require("comlink");
12
13
  const _nodeadapter = /*#__PURE__*/ _interop_require_default(require("comlink/dist/umd/node-adapter.js"));
13
- const _nodeworker_threads = /*#__PURE__*/ _interop_require_default(require("node:worker_threads"));
14
14
  function _interop_require_default(obj) {
15
15
  return obj && obj.__esModule ? obj : {
16
16
  default: obj
@@ -1,2 +1,2 @@
1
- import { Blockchain } from '../blockchain/index.js';
1
+ import type { Blockchain } from '../blockchain/index.js';
2
2
  export declare const connectDownward: (relaychain: Blockchain, parachain: Blockchain) => Promise<void>;
@@ -1,2 +1,2 @@
1
- import { Blockchain } from '../blockchain/index.js';
1
+ import type { Blockchain } from '../blockchain/index.js';
2
2
  export declare const connectHorizontal: (parachains: Record<number, Blockchain>, disableAutoHrmp?: boolean) => Promise<void>;
@@ -1,4 +1,4 @@
1
- import { Blockchain } from '../blockchain/index.js';
1
+ import type { Blockchain } from '../blockchain/index.js';
2
2
  export declare const xcmLogger: import("pino").default.Logger<never, boolean>;
3
3
  export declare const connectVertical: (relaychain: Blockchain, parachain: Blockchain) => Promise<void>;
4
4
  export declare const connectParachains: (parachains: Blockchain[], disableAutoHrmp?: boolean) => Promise<void>;
@@ -19,11 +19,11 @@ _export(exports, {
19
19
  return xcmLogger;
20
20
  }
21
21
  });
22
+ const _logger = require("../logger.js");
23
+ const _index = require("../utils/index.js");
22
24
  const _downward = require("./downward.js");
23
25
  const _horizontal = require("./horizontal.js");
24
26
  const _upward = require("./upward.js");
25
- const _logger = require("../logger.js");
26
- const _index = require("../utils/index.js");
27
27
  const xcmLogger = _logger.defaultLogger.child({
28
28
  name: 'xcm'
29
29
  });
@@ -1,2 +1,2 @@
1
- import { Blockchain } from '../blockchain/index.js';
1
+ import type { Blockchain } from '../blockchain/index.js';
2
2
  export declare const connectUpward: (parachain: Blockchain, relaychain: Blockchain) => Promise<void>;
package/dist/esm/api.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { ExtDef } from '@polkadot/types/extrinsic/signedExtensions/types';
2
- import { HexString } from '@polkadot/util/types';
3
- import { ProviderInterface, ProviderInterfaceCallback } from '@polkadot/rpc-provider/types';
4
- import { ChainProperties, Header, SignedBlock } from './index.js';
1
+ import type { ProviderInterface, ProviderInterfaceCallback } from '@polkadot/rpc-provider/types';
2
+ import type { ExtDef } from '@polkadot/types/extrinsic/signedExtensions/types';
3
+ import type { HexString } from '@polkadot/util/types';
4
+ import type { ChainProperties, Header, SignedBlock } from './index.js';
5
5
  /**
6
6
  * API class. Calls provider to get on-chain data.
7
7
  * Either `endpoint` or `genesis` porvider must be provided.
package/dist/esm/api.js CHANGED
@@ -96,14 +96,13 @@ import { prefixedChildKey, splitChildKey, stripChildPrefix } from './utils/index
96
96
  ];
97
97
  if (hash) params.push(hash);
98
98
  return this.send('childstate_getStorage', params, !!hash);
99
- } else {
100
- // main storage key, use state_getStorage
101
- const params = [
102
- key
103
- ];
104
- if (hash) params.push(hash);
105
- return this.send('state_getStorage', params, !!hash);
106
99
  }
100
+ // main storage key, use state_getStorage
101
+ const params = [
102
+ key
103
+ ];
104
+ if (hash) params.push(hash);
105
+ return this.send('state_getStorage', params, !!hash);
107
106
  }
108
107
  async getKeysPaged(prefix, pageSize, startKey, hash) {
109
108
  const [child, storageKey] = splitChildKey(prefix);
@@ -118,16 +117,15 @@ import { prefixedChildKey, splitChildKey, stripChildPrefix } from './utils/index
118
117
  ];
119
118
  if (hash) params.push(hash);
120
119
  return this.#provider.send('childstate_getKeysPaged', params, !!hash).then((keys)=>keys.map((key)=>prefixedChildKey(child, key)));
121
- } else {
122
- // main storage key, use state_getKeysPaged
123
- const params = [
124
- prefix,
125
- pageSize,
126
- startKey
127
- ];
128
- if (hash) params.push(hash);
129
- return this.send('state_getKeysPaged', params, !!hash);
130
120
  }
121
+ // main storage key, use state_getKeysPaged
122
+ const params = [
123
+ prefix,
124
+ pageSize,
125
+ startKey
126
+ ];
127
+ if (hash) params.push(hash);
128
+ return this.send('state_getKeysPaged', params, !!hash);
131
129
  }
132
130
  async getStorageBatch(prefix, keys, hash) {
133
131
  const [child] = splitChildKey(prefix);
@@ -140,14 +138,13 @@ import { prefixedChildKey, splitChildKey, stripChildPrefix } from './utils/index
140
138
  ];
141
139
  if (hash) params.push(hash);
142
140
  return this.#provider.send('childstate_getStorageEntries', params, !!hash).then((values)=>_.zip(keys, values));
143
- } else {
144
- // main storage key, use state_getStorageAt
145
- const params = [
146
- keys
147
- ];
148
- if (hash) params.push(hash);
149
- return this.#provider.send('state_queryStorageAt', params, !!hash).then((result)=>result[0]?.['changes'] || []);
150
141
  }
142
+ // main storage key, use state_getStorageAt
143
+ const params = [
144
+ keys
145
+ ];
146
+ if (hash) params.push(hash);
147
+ return this.#provider.send('state_queryStorageAt', params, !!hash).then((result)=>result[0]?.['changes'] || []);
151
148
  }
152
149
  async subscribeRemoteNewHeads(cb) {
153
150
  if (!this.#provider.hasSubscriptions) {
@@ -1,9 +1,9 @@
1
- import { DigestItem, Header, TransactionValidityError } from '@polkadot/types/interfaces';
1
+ import type { DigestItem, Header, TransactionValidityError } from '@polkadot/types/interfaces';
2
+ import type { HexString } from '@polkadot/util/types';
3
+ import type { TaskCallResponse } from '../wasm-executor/index.js';
2
4
  import { Block } from './block.js';
3
- import { BuildBlockParams } from './txpool.js';
4
- import { HexString } from '@polkadot/util/types';
5
- import { InherentProvider } from './inherent/index.js';
6
- import { TaskCallResponse } from '../wasm-executor/index.js';
5
+ import type { InherentProvider } from './inherent/index.js';
6
+ import type { BuildBlockParams } from './txpool.js';
7
7
  export declare const genesisDigestLogs: (head: Block) => Promise<DigestItem[]>;
8
8
  export declare const newHeader: (head: Block, unsafeBlockHeight?: number) => Promise<Header>;
9
9
  export type BuildBlockCallbacks = {
@@ -1,9 +1,9 @@
1
- import { Block } from './block.js';
2
- import { StorageLayer, StorageValueKind } from './storage-layer.js';
3
- import { blake2AsU8a } from '@polkadot/util-crypto';
4
1
  import { compactAddLength, hexToU8a, stringToHex, u8aConcat } from '@polkadot/util';
5
- import { compactHex, getCurrentSlot } from '../utils/index.js';
2
+ import { blake2AsU8a } from '@polkadot/util-crypto';
6
3
  import { defaultLogger, truncate } from '../logger.js';
4
+ import { compactHex, getCurrentSlot } from '../utils/index.js';
5
+ import { Block } from './block.js';
6
+ import { StorageLayer, StorageValueKind } from './storage-layer.js';
7
7
  const logger = defaultLogger.child({
8
8
  name: 'block-builder'
9
9
  });
@@ -30,19 +30,18 @@ export const genesisDigestLogs = async (head)=>{
30
30
  return [
31
31
  digest
32
32
  ];
33
- } else {
34
- const newSlot = meta.registry.createType('Slot', currentSlot + 1);
35
- const consensusEngine = meta.registry.createType('ConsensusEngineId', 'aura');
36
- const digest = meta.registry.createType('DigestItem', {
37
- PreRuntime: [
38
- consensusEngine,
39
- compactAddLength(newSlot.toU8a())
40
- ]
41
- });
42
- return [
43
- digest
44
- ];
45
33
  }
34
+ const newSlot = meta.registry.createType('Slot', currentSlot + 1);
35
+ const consensusEngine = meta.registry.createType('ConsensusEngineId', 'aura');
36
+ const digest = meta.registry.createType('DigestItem', {
37
+ PreRuntime: [
38
+ consensusEngine,
39
+ compactAddLength(newSlot.toU8a())
40
+ ]
41
+ });
42
+ return [
43
+ digest
44
+ ];
46
45
  };
47
46
  const getConsensus = (header)=>{
48
47
  if (header.digest.logs.length === 0) return;
@@ -110,14 +109,14 @@ export const newHeader = async (head, unsafeBlockHeight)=>{
110
109
  }),
111
110
  ...consensus.rest
112
111
  ];
113
- } else if (consensus?.consensusEngine?.toString() == 'nmbs') {
112
+ } else if (consensus?.consensusEngine?.toString() === 'nmbs') {
114
113
  const nmbsKey = stringToHex('nmbs');
115
114
  newLogs = [
116
115
  meta.registry.createType('DigestItem', {
117
116
  // Using previous block author
118
117
  PreRuntime: [
119
118
  consensus.consensusEngine,
120
- parentHeader.digest.logs.find((log)=>log.isPreRuntime && log.asPreRuntime[0].toHex() == nmbsKey)?.asPreRuntime[1].toHex()
119
+ parentHeader.digest.logs.find((log)=>log.isPreRuntime && log.asPreRuntime[0].toHex() === nmbsKey)?.asPreRuntime[1].toHex()
121
120
  ]
122
121
  }),
123
122
  ...consensus.rest
@@ -1,11 +1,11 @@
1
- import { DecoratedMeta } from '@polkadot/types/metadata/decorate/types';
2
- import { Header } from '@polkadot/types/interfaces';
3
- import { TypeRegistry } from '@polkadot/types';
4
- import { StorageEntry } from '@polkadot/types/primitive/types';
1
+ import { type TypeRegistry } from '@polkadot/types';
2
+ import type { Header } from '@polkadot/types/interfaces';
3
+ import type { DecoratedMeta } from '@polkadot/types/metadata/decorate/types';
4
+ import type { StorageEntry } from '@polkadot/types/primitive/types';
5
5
  import type { HexString } from '@polkadot/util/types';
6
- import { Blockchain } from './index.js';
7
- import { StorageLayer, StorageLayerProvider, StorageValue } from './storage-layer.js';
8
6
  import type { RuntimeVersion, TaskCallResponse } from '../wasm-executor/index.js';
7
+ import type { Blockchain } from './index.js';
8
+ import { StorageLayer, type StorageLayerProvider, type StorageValue } from './storage-layer.js';
9
9
  /**
10
10
  * Block class.
11
11
  *
@@ -1,9 +1,9 @@
1
1
  import { Metadata } from '@polkadot/types';
2
2
  import { expandMetadata } from '@polkadot/types/metadata';
3
3
  import { hexToU8a, stringToHex } from '@polkadot/util';
4
- import { RemoteStorageLayer, StorageLayer, StorageValueKind } from './storage-layer.js';
5
4
  import { compactHex } from '../utils/index.js';
6
5
  import { getRuntimeVersion, runTask, taskHandler } from '../wasm-executor/index.js';
6
+ import { RemoteStorageLayer, StorageLayer, StorageValueKind } from './storage-layer.js';
7
7
  /**
8
8
  * Block class.
9
9
  *
@@ -1,4 +1,4 @@
1
- import { Block } from './block.js';
1
+ import type { Block } from './block.js';
2
2
  type Callback = (block: Block, pairs: [string, string | null][]) => void | Promise<void>;
3
3
  export declare const randomId: () => string;
4
4
  export declare class HeadState {
@@ -1,16 +1,16 @@
1
- import { ApplyExtrinsicResult } from '@polkadot/types/interfaces';
2
- import { HexString } from '@polkadot/util/types';
3
1
  import { TypeRegistry } from '@polkadot/types';
4
- import { RegisteredTypes } from '@polkadot/types/types';
2
+ import type { ApplyExtrinsicResult } from '@polkadot/types/interfaces';
5
3
  import type { TransactionValidity } from '@polkadot/types/interfaces/txqueue';
6
- import { Api } from '../api.js';
4
+ import type { RegisteredTypes } from '@polkadot/types/types';
5
+ import type { HexString } from '@polkadot/util/types';
6
+ import type { Api } from '../api.js';
7
+ import type { Database } from '../database.js';
8
+ import { OffchainWorker } from '../offchain.js';
9
+ import type { RuntimeVersion } from '../wasm-executor/index.js';
7
10
  import { Block } from './block.js';
8
- import { BuildBlockMode, BuildBlockParams, DownwardMessage, HorizontalMessage, TxPool } from './txpool.js';
9
- import { Database } from '../database.js';
10
11
  import { HeadState } from './head-state.js';
11
- import { InherentProvider } from './inherent/index.js';
12
- import { OffchainWorker } from '../offchain.js';
13
- import { RuntimeVersion } from '../wasm-executor/index.js';
12
+ import type { InherentProvider } from './inherent/index.js';
13
+ import { type BuildBlockMode, type BuildBlockParams, type DownwardMessage, type HorizontalMessage, TxPool } from './txpool.js';
14
14
  export interface Options {
15
15
  /** API instance, for getting on-chain data. */
16
16
  api: Api;
@@ -1,15 +1,15 @@
1
1
  import { Metadata, TypeRegistry } from '@polkadot/types';
2
- import { blake2AsHex, xxhashAsHex } from '@polkadot/util-crypto';
3
2
  import { getSpecExtensions, getSpecHasher, getSpecTypes } from '@polkadot/types-known/util';
4
3
  import { objectSpread, u8aConcat, u8aToHex } from '@polkadot/util';
4
+ import { blake2AsHex, xxhashAsHex } from '@polkadot/util-crypto';
5
5
  import _ from 'lodash';
6
- import { Block } from './block.js';
7
- import { TxPool } from './txpool.js';
8
- import { HeadState } from './head-state.js';
6
+ import { defaultLogger } from '../logger.js';
9
7
  import { OffchainWorker } from '../offchain.js';
10
8
  import { compactHex } from '../utils/index.js';
11
- import { defaultLogger } from '../logger.js';
12
9
  import { dryRunExtrinsic, dryRunInherents } from './block-builder.js';
10
+ import { Block } from './block.js';
11
+ import { HeadState } from './head-state.js';
12
+ import { TxPool } from './txpool.js';
13
13
  const logger = defaultLogger.child({
14
14
  name: 'blockchain'
15
15
  });
@@ -1,12 +1,12 @@
1
- import { Block } from '../block.js';
2
- import { BuildBlockParams } from '../txpool.js';
3
- import { HexString } from '@polkadot/util/types';
1
+ import type { HexString } from '@polkadot/util/types';
2
+ import type { Block } from '../block.js';
3
+ import type { BuildBlockParams } from '../txpool.js';
4
4
  import { ParaInherentEnter } from './para-enter.js';
5
5
  import { SetBabeRandomness } from './parachain/babe-randomness.js';
6
6
  import { SetNimbusAuthorInherent } from './parachain/nimbus-author-inherent.js';
7
- import { SetTimestamp } from './timestamp.js';
8
7
  import { SetValidationData } from './parachain/validation-data.js';
8
+ import { SetTimestamp } from './timestamp.js';
9
9
  export interface InherentProvider {
10
10
  createInherents(newBlock: Block, params: BuildBlockParams): Promise<HexString[]>;
11
11
  }
12
- export declare const inherentProviders: (ParaInherentEnter | SetBabeRandomness | SetNimbusAuthorInherent | SetTimestamp | SetValidationData)[];
12
+ export declare const inherentProviders: (ParaInherentEnter | SetBabeRandomness | SetNimbusAuthorInherent | SetValidationData | SetTimestamp)[];
@@ -1,8 +1,8 @@
1
1
  import { ParaInherentEnter } from './para-enter.js';
2
2
  import { SetBabeRandomness } from './parachain/babe-randomness.js';
3
3
  import { SetNimbusAuthorInherent } from './parachain/nimbus-author-inherent.js';
4
- import { SetTimestamp } from './timestamp.js';
5
4
  import { SetValidationData } from './parachain/validation-data.js';
5
+ import { SetTimestamp } from './timestamp.js';
6
6
  export const inherentProviders = [
7
7
  new SetTimestamp(),
8
8
  new SetValidationData(),
@@ -1,7 +1,7 @@
1
- import { HexString } from '@polkadot/util/types';
2
- import { Block } from '../block.js';
3
- import { BuildBlockParams } from '../txpool.js';
4
- import { InherentProvider } from './index.js';
1
+ import type { HexString } from '@polkadot/util/types';
2
+ import type { Block } from '../block.js';
3
+ import type { BuildBlockParams } from '../txpool.js';
4
+ import type { InherentProvider } from './index.js';
5
5
  export declare class ParaInherentEnter implements InherentProvider {
6
6
  createInherents(newBlock: Block, _params: BuildBlockParams): Promise<HexString[]>;
7
7
  }
@@ -1,7 +1,7 @@
1
- import { HexString } from '@polkadot/util/types';
2
- import { Block } from '../../block.js';
3
- import { BuildBlockParams } from '../../txpool.js';
4
- import { InherentProvider } from '../index.js';
1
+ import type { HexString } from '@polkadot/util/types';
2
+ import type { Block } from '../../block.js';
3
+ import type { BuildBlockParams } from '../../txpool.js';
4
+ import type { InherentProvider } from '../index.js';
5
5
  export declare class SetBabeRandomness implements InherentProvider {
6
6
  createInherents(newBlock: Block, _params: BuildBlockParams): Promise<HexString[]>;
7
7
  }
@@ -1,7 +1,7 @@
1
- import { Block } from '../../block.js';
2
- import { BuildBlockParams } from '../../txpool.js';
3
- import { HexString } from '@polkadot/util/types';
4
- import { InherentProvider } from '../index.js';
1
+ import type { HexString } from '@polkadot/util/types';
2
+ import type { Block } from '../../block.js';
3
+ import type { BuildBlockParams } from '../../txpool.js';
4
+ import type { InherentProvider } from '../index.js';
5
5
  export declare class SetNimbusAuthorInherent implements InherentProvider {
6
6
  createInherents(newBlock: Block, _params: BuildBlockParams): Promise<HexString[]>;
7
7
  }
@@ -1,7 +1,7 @@
1
- import { HexString } from '@polkadot/util/types';
2
- import { Block } from '../../block.js';
3
- import { BuildBlockParams, DownwardMessage, HorizontalMessage } from '../../txpool.js';
4
- import { InherentProvider } from '../index.js';
1
+ import type { HexString } from '@polkadot/util/types';
2
+ import type { Block } from '../../block.js';
3
+ import type { BuildBlockParams, DownwardMessage, HorizontalMessage } from '../../txpool.js';
4
+ import type { InherentProvider } from '../index.js';
5
5
  export type ValidationData = {
6
6
  downwardMessages: DownwardMessage[];
7
7
  horizontalMessages: Record<number, HorizontalMessage[]>;
@@ -1,9 +1,9 @@
1
- import { hexToU8a, u8aConcat, u8aToHex } from '@polkadot/util';
2
1
  import { GenericExtrinsic } from '@polkadot/types';
2
+ import { hexToU8a, u8aConcat, u8aToHex } from '@polkadot/util';
3
3
  import _ from 'lodash';
4
- import { WELL_KNOWN_KEYS, dmqMqcHead, hrmpChannels, hrmpEgressChannelIndex, hrmpIngressChannelIndex, paraHead, upgradeGoAheadSignal } from '../../../utils/proof.js';
5
4
  import { blake2AsHex, blake2AsU8a } from '@polkadot/util-crypto';
6
5
  import { compactHex, getCurrentSlot, getParaId } from '../../../utils/index.js';
6
+ import { WELL_KNOWN_KEYS, dmqMqcHead, hrmpChannels, hrmpEgressChannelIndex, hrmpIngressChannelIndex, paraHead, upgradeGoAheadSignal } from '../../../utils/proof.js';
7
7
  import { createProof, decodeProof } from '../../../wasm-executor/index.js';
8
8
  const MOCK_VALIDATION_DATA = {
9
9
  validationData: {
@@ -218,7 +218,7 @@ export class SetValidationData {
218
218
  if (params.relayChainStateOverrides) {
219
219
  for (const [key, value] of params.relayChainStateOverrides){
220
220
  // Remove any entry that matches the key being overridden
221
- newEntries = newEntries.filter(([k, _])=>k != key);
221
+ newEntries = newEntries.filter(([k, _])=>k !== key);
222
222
  // Push override
223
223
  newEntries.push([
224
224
  key,
@@ -1,6 +1,6 @@
1
- import { Block } from '../block.js';
2
- import { HexString } from '@polkadot/util/types';
3
- import { InherentProvider } from './index.js';
1
+ import type { HexString } from '@polkadot/util/types';
2
+ import type { Block } from '../block.js';
3
+ import type { InherentProvider } from './index.js';
4
4
  export declare class SetTimestamp implements InherentProvider {
5
5
  createInherents(newBlock: Block): Promise<HexString[]>;
6
6
  }
@@ -1,6 +1,6 @@
1
- import { Api } from '../api.js';
2
- import { Database } from '../database.js';
3
- export declare const enum StorageValueKind {
1
+ import type { Api } from '../api.js';
2
+ import type { Database } from '../database.js';
3
+ export declare enum StorageValueKind {
4
4
  Deleted = "Deleted",
5
5
  DeletedPrefix = "DeletedPrefix"
6
6
  }
@@ -1,6 +1,6 @@
1
1
  import _ from 'lodash';
2
- import { CHILD_PREFIX_LENGTH, PREFIX_LENGTH, isPrefixedChildKey } from '../utils/index.js';
3
2
  import { defaultLogger } from '../logger.js';
3
+ import { CHILD_PREFIX_LENGTH, PREFIX_LENGTH, isPrefixedChildKey } from '../utils/index.js';
4
4
  import KeyCache from '../utils/key-cache.js';
5
5
  const logger = defaultLogger.child({
6
6
  name: 'layer'
@@ -92,7 +92,7 @@ export class RemoteStorageLayer {
92
92
  // batch fetch storage values and save to db, they may be used later
93
93
  this.#api.getStorageBatch(prefix, batch, this.#at).then((storage)=>{
94
94
  for (const [key, value] of storage){
95
- this.#db.saveStorage(this.#at, key, value);
95
+ this.#db?.saveStorage(this.#at, key, value);
96
96
  }
97
97
  });
98
98
  }
@@ -184,7 +184,8 @@ export class StorageLayer {
184
184
  if (parentBest) {
185
185
  if (!maybeBest) {
186
186
  return parentBest;
187
- } else if (parentBest < maybeBest) {
187
+ }
188
+ if (parentBest < maybeBest) {
188
189
  return parentBest;
189
190
  }
190
191
  }
@@ -200,7 +201,7 @@ export class StorageLayer {
200
201
  const next = await this.findNextKey(prefix, startKey, undefined);
201
202
  if (!next) break;
202
203
  startKey = next;
203
- if (await this.get(next, false) == "Deleted") continue;
204
+ if (await this.get(next, false) === "Deleted") continue;
204
205
  keys.push(next);
205
206
  }
206
207
  return keys;
@@ -1,7 +1,7 @@
1
+ import type { HexString } from '@polkadot/util/types';
1
2
  import { EventEmitter } from 'eventemitter3';
2
- import { HexString } from '@polkadot/util/types';
3
- import { Blockchain } from './index.js';
4
- import { InherentProvider } from './inherent/index.js';
3
+ import type { Blockchain } from './index.js';
4
+ import type { InherentProvider } from './inherent/index.js';
5
5
  export declare const APPLY_EXTRINSIC_ERROR = "TxPool::ApplyExtrinsicError";
6
6
  export declare enum BuildBlockMode {
7
7
  /** One block per batch (default) */
@@ -1,9 +1,9 @@
1
- import { EventEmitter } from 'eventemitter3';
2
1
  import { hexToU8a } from '@polkadot/util/hex/toU8a';
2
+ import { EventEmitter } from 'eventemitter3';
3
3
  import _ from 'lodash';
4
+ import { defaultLogger, truncate } from '../logger.js';
4
5
  import { defer } from '../utils/index.js';
5
6
  import { buildBlock } from './block-builder.js';
6
- import { defaultLogger, truncate } from '../logger.js';
7
7
  const logger = defaultLogger.child({
8
8
  name: 'txpool'
9
9
  });
@@ -1,6 +1,6 @@
1
- import { ProviderInterface, ProviderInterfaceCallback, ProviderInterfaceEmitCb, ProviderInterfaceEmitted } from '@polkadot/rpc-provider/types';
2
- import { Blockchain } from './blockchain/index.js';
3
- import { Database } from './database.js';
1
+ import type { ProviderInterface, ProviderInterfaceCallback, ProviderInterfaceEmitCb, ProviderInterfaceEmitted } from '@polkadot/rpc-provider/types';
2
+ import type { Blockchain } from './blockchain/index.js';
3
+ import type { Database } from './database.js';
4
4
  interface SubscriptionHandler {
5
5
  callback: ProviderInterfaceCallback;
6
6
  type: string;
@@ -1,6 +1,6 @@
1
1
  import { EventEmitter } from 'eventemitter3';
2
- import { allHandlers } from './rpc/index.js';
3
2
  import { defaultLogger } from './logger.js';
3
+ import { allHandlers } from './rpc/index.js';
4
4
  import { setup } from './setup.js';
5
5
  const providerHandlers = {
6
6
  ...allHandlers
@@ -94,15 +94,14 @@ const logger = defaultLogger.child({
94
94
  type: subscription.type
95
95
  };
96
96
  return subid;
97
- } else {
98
- logger.debug('call', {
99
- method,
100
- params
101
- });
102
- return rpcHandler({
103
- chain: this.chain
104
- }, params, this.subscriptionManager);
105
97
  }
98
+ logger.debug('call', {
99
+ method,
100
+ params
101
+ });
102
+ return rpcHandler({
103
+ chain: this.chain
104
+ }, params, this.subscriptionManager);
106
105
  } catch (e) {
107
106
  logger.error('send error.', e);
108
107
  throw e;
@@ -1,4 +1,4 @@
1
- import { HexString } from '@polkadot/util/types';
1
+ import type { HexString } from '@polkadot/util/types';
2
2
  export interface BlockEntry {
3
3
  hash: HexString;
4
4
  number: number;
@@ -1,7 +1,7 @@
1
- import { HexString } from '@polkadot/util/types';
2
- import { ProviderInterface, ProviderInterfaceCallback, ProviderInterfaceEmitCb, ProviderInterfaceEmitted } from '@polkadot/rpc-provider/types';
3
- import { Genesis } from './schema/index.js';
4
- import { JsCallback } from './wasm-executor/index.js';
1
+ import type { ProviderInterface, ProviderInterfaceCallback, ProviderInterfaceEmitCb, ProviderInterfaceEmitted } from '@polkadot/rpc-provider/types';
2
+ import type { HexString } from '@polkadot/util/types';
3
+ import { type Genesis } from './schema/index.js';
4
+ import { type JsCallback } from './wasm-executor/index.js';
5
5
  /**
6
6
  * Provider to start a chain from genesis
7
7
  */
@@ -1,7 +1,7 @@
1
1
  import { EventEmitter } from 'eventemitter3';
2
+ import { defaultLogger, isPrefixedChildKey } from './index.js';
2
3
  import { genesisSchema } from './schema/index.js';
3
4
  import { calculateStateRoot, emptyTaskHandler } from './wasm-executor/index.js';
4
- import { defaultLogger, isPrefixedChildKey } from './index.js';
5
5
  /**
6
6
  * Provider to start a chain from genesis
7
7
  */ export class GenesisProvider {
@@ -86,7 +86,7 @@ import { defaultLogger, isPrefixedChildKey } from './index.js';
86
86
  const storage = this.#genesis.genesis.raw.top;
87
87
  return {
88
88
  ...emptyTaskHandler,
89
- getStorage: async function(key) {
89
+ getStorage: async (key)=>{
90
90
  if (isPrefixedChildKey(key)) {
91
91
  defaultLogger.warn({
92
92
  key
@@ -95,7 +95,7 @@ import { defaultLogger, isPrefixedChildKey } from './index.js';
95
95
  }
96
96
  return storage[key];
97
97
  },
98
- getNextKey: async function(prefix, key) {
98
+ getNextKey: async (prefix, key)=>{
99
99
  if (isPrefixedChildKey(key)) {
100
100
  defaultLogger.warn({
101
101
  prefix,
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * @packageDocumentation
9
9
  */
10
- import { HexString } from '@polkadot/util/types';
10
+ import type { HexString } from '@polkadot/util/types';
11
11
  export type ChainProperties = {
12
12
  ss58Format?: number;
13
13
  tokenDecimals?: number[];
@@ -25,10 +25,9 @@ const innerTruncate = (level = 0)=>(val)=>{
25
25
  switch(typeof val){
26
26
  case 'string':
27
27
  if (val.length > 66 && !verboseLog) {
28
- return val.slice(0, 34) + '…' + val.slice(-32);
29
- } else {
30
- return val;
28
+ return `${val.slice(0, 34)}…${val.slice(-32)}`;
31
29
  }
30
+ return val;
32
31
  case 'object':
33
32
  if (Array.isArray(val)) {
34
33
  return val.map(innerTruncate(level + 1));
@@ -1,5 +1,5 @@
1
- import { Block } from './blockchain/block.js';
2
- import { HexString } from '@polkadot/util/types';
1
+ import type { HexString } from '@polkadot/util/types';
2
+ import type { Block } from './blockchain/block.js';
3
3
  export declare class OffchainWorker {
4
4
  readonly pendingExtrinsics: HexString[];
5
5
  readonly offchainStorage: Map<string, string | null | undefined>;
@@ -1,6 +1,6 @@
1
1
  import { blake2AsHex } from '@polkadot/util-crypto';
2
- import { defaultLogger } from './logger.js';
3
2
  import { queueScheduler } from 'rxjs';
3
+ import { defaultLogger } from './logger.js';
4
4
  const logger = defaultLogger.child({
5
5
  name: 'offchain'
6
6
  });