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

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 +5 -4
  2. package/dist/cjs/api.js +23 -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 +10 -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 +13 -12
  27. package/dist/cjs/index.d.ts +1 -1
  28. package/dist/cjs/logger.js +5 -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 +2 -2
  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 +5 -4
  81. package/dist/esm/api.js +23 -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 +10 -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 +4 -3
  106. package/dist/esm/index.d.ts +1 -1
  107. package/dist/esm/logger.js +5 -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 +2 -2
  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 +16 -16
package/dist/cjs/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.
@@ -29,6 +29,7 @@ export declare class Api {
29
29
  getSystemChain(): Promise<string>;
30
30
  getBlockHash(blockNumber?: number): Promise<`0x${string}` | null>;
31
31
  getHeader(hash?: string): Promise<Header | null>;
32
+ getFinalizedHead(): Promise<string>;
32
33
  getBlock(hash?: string): Promise<SignedBlock | null>;
33
34
  getStorage(key: string, hash?: string): Promise<`0x${string}` | null>;
34
35
  getKeysPaged(prefix: string, pageSize: number, startKey: string, hash?: string): Promise<string[]>;
package/dist/cjs/api.js CHANGED
@@ -129,6 +129,9 @@ class Api {
129
129
  hash
130
130
  ] : [], !!hash);
131
131
  }
132
+ async getFinalizedHead() {
133
+ return this.send('chain_getFinalizedHead', []);
134
+ }
132
135
  async getBlock(hash) {
133
136
  return this.send('chain_getBlock', hash ? [
134
137
  hash
@@ -144,14 +147,13 @@ class Api {
144
147
  ];
145
148
  if (hash) params.push(hash);
146
149
  return this.send('childstate_getStorage', params, !!hash);
147
- } else {
148
- // main storage key, use state_getStorage
149
- const params = [
150
- key
151
- ];
152
- if (hash) params.push(hash);
153
- return this.send('state_getStorage', params, !!hash);
154
150
  }
151
+ // main storage key, use state_getStorage
152
+ const params = [
153
+ key
154
+ ];
155
+ if (hash) params.push(hash);
156
+ return this.send('state_getStorage', params, !!hash);
155
157
  }
156
158
  async getKeysPaged(prefix, pageSize, startKey, hash) {
157
159
  const [child, storageKey] = (0, _index.splitChildKey)(prefix);
@@ -166,16 +168,15 @@ class Api {
166
168
  ];
167
169
  if (hash) params.push(hash);
168
170
  return _class_private_field_get(this, _provider).send('childstate_getKeysPaged', params, !!hash).then((keys)=>keys.map((key)=>(0, _index.prefixedChildKey)(child, key)));
169
- } else {
170
- // main storage key, use state_getKeysPaged
171
- const params = [
172
- prefix,
173
- pageSize,
174
- startKey
175
- ];
176
- if (hash) params.push(hash);
177
- return this.send('state_getKeysPaged', params, !!hash);
178
171
  }
172
+ // main storage key, use state_getKeysPaged
173
+ const params = [
174
+ prefix,
175
+ pageSize,
176
+ startKey
177
+ ];
178
+ if (hash) params.push(hash);
179
+ return this.send('state_getKeysPaged', params, !!hash);
179
180
  }
180
181
  async getStorageBatch(prefix, keys, hash) {
181
182
  const [child] = (0, _index.splitChildKey)(prefix);
@@ -188,14 +189,13 @@ class Api {
188
189
  ];
189
190
  if (hash) params.push(hash);
190
191
  return _class_private_field_get(this, _provider).send('childstate_getStorageEntries', params, !!hash).then((values)=>_lodash.default.zip(keys, values));
191
- } else {
192
- // main storage key, use state_getStorageAt
193
- const params = [
194
- keys
195
- ];
196
- if (hash) params.push(hash);
197
- return _class_private_field_get(this, _provider).send('state_queryStorageAt', params, !!hash).then((result)=>result[0]?.['changes'] || []);
198
192
  }
193
+ // main storage key, use state_getStorageAt
194
+ const params = [
195
+ keys
196
+ ];
197
+ if (hash) params.push(hash);
198
+ return _class_private_field_get(this, _provider).send('state_queryStorageAt', params, !!hash).then((result)=>result[0]?.['changes'] || []);
199
199
  }
200
200
  async subscribeRemoteNewHeads(cb) {
201
201
  if (!_class_private_field_get(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 = {
@@ -25,12 +25,12 @@ _export(exports, {
25
25
  return newHeader;
26
26
  }
27
27
  });
28
- const _block = require("./block.js");
29
- const _storagelayer = require("./storage-layer.js");
30
- const _utilcrypto = require("@polkadot/util-crypto");
31
28
  const _util = require("@polkadot/util");
32
- const _index = require("../utils/index.js");
29
+ const _utilcrypto = require("@polkadot/util-crypto");
33
30
  const _logger = require("../logger.js");
31
+ const _index = require("../utils/index.js");
32
+ const _block = require("./block.js");
33
+ const _storagelayer = require("./storage-layer.js");
34
34
  const logger = _logger.defaultLogger.child({
35
35
  name: 'block-builder'
36
36
  });
@@ -57,19 +57,18 @@ const genesisDigestLogs = async (head)=>{
57
57
  return [
58
58
  digest
59
59
  ];
60
- } else {
61
- const newSlot = meta.registry.createType('Slot', currentSlot + 1);
62
- const consensusEngine = meta.registry.createType('ConsensusEngineId', 'aura');
63
- const digest = meta.registry.createType('DigestItem', {
64
- PreRuntime: [
65
- consensusEngine,
66
- (0, _util.compactAddLength)(newSlot.toU8a())
67
- ]
68
- });
69
- return [
70
- digest
71
- ];
72
60
  }
61
+ const newSlot = meta.registry.createType('Slot', currentSlot + 1);
62
+ const consensusEngine = meta.registry.createType('ConsensusEngineId', 'aura');
63
+ const digest = meta.registry.createType('DigestItem', {
64
+ PreRuntime: [
65
+ consensusEngine,
66
+ (0, _util.compactAddLength)(newSlot.toU8a())
67
+ ]
68
+ });
69
+ return [
70
+ digest
71
+ ];
73
72
  };
74
73
  const getConsensus = (header)=>{
75
74
  if (header.digest.logs.length === 0) return;
@@ -137,14 +136,14 @@ const newHeader = async (head, unsafeBlockHeight)=>{
137
136
  }),
138
137
  ...consensus.rest
139
138
  ];
140
- } else if (consensus?.consensusEngine?.toString() == 'nmbs') {
139
+ } else if (consensus?.consensusEngine?.toString() === 'nmbs') {
141
140
  const nmbsKey = (0, _util.stringToHex)('nmbs');
142
141
  newLogs = [
143
142
  meta.registry.createType('DigestItem', {
144
143
  // Using previous block author
145
144
  PreRuntime: [
146
145
  consensus.consensusEngine,
147
- parentHeader.digest.logs.find((log)=>log.isPreRuntime && log.asPreRuntime[0].toHex() == nmbsKey)?.asPreRuntime[1].toHex()
146
+ parentHeader.digest.logs.find((log)=>log.isPreRuntime && log.asPreRuntime[0].toHex() === nmbsKey)?.asPreRuntime[1].toHex()
148
147
  ]
149
148
  }),
150
149
  ...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
  *
@@ -11,9 +11,9 @@ Object.defineProperty(exports, "Block", {
11
11
  const _types = require("@polkadot/types");
12
12
  const _metadata = require("@polkadot/types/metadata");
13
13
  const _util = require("@polkadot/util");
14
- const _storagelayer = require("./storage-layer.js");
15
14
  const _index = require("../utils/index.js");
16
15
  const _index1 = require("../wasm-executor/index.js");
16
+ const _storagelayer = require("./storage-layer.js");
17
17
  function _check_private_redeclaration(obj, privateCollection) {
18
18
  if (privateCollection.has(obj)) {
19
19
  throw new TypeError("Cannot initialize the same private elements twice on an object");
@@ -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;
@@ -9,17 +9,17 @@ Object.defineProperty(exports, "Blockchain", {
9
9
  }
10
10
  });
11
11
  const _types = require("@polkadot/types");
12
- const _utilcrypto = require("@polkadot/util-crypto");
13
12
  const _util = require("@polkadot/types-known/util");
14
13
  const _util1 = require("@polkadot/util");
14
+ const _utilcrypto = require("@polkadot/util-crypto");
15
15
  const _lodash = /*#__PURE__*/ _interop_require_default(require("lodash"));
16
- const _block = require("./block.js");
17
- const _txpool = require("./txpool.js");
18
- const _headstate = require("./head-state.js");
16
+ const _logger = require("../logger.js");
19
17
  const _offchain = require("../offchain.js");
20
18
  const _index = require("../utils/index.js");
21
- const _logger = require("../logger.js");
22
19
  const _blockbuilder = require("./block-builder.js");
20
+ const _block = require("./block.js");
21
+ const _headstate = require("./head-state.js");
22
+ const _txpool = require("./txpool.js");
23
23
  function _check_private_redeclaration(obj, privateCollection) {
24
24
  if (privateCollection.has(obj)) {
25
25
  throw new TypeError("Cannot initialize the same private elements twice on an object");
@@ -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)[];
@@ -11,8 +11,8 @@ Object.defineProperty(exports, "inherentProviders", {
11
11
  const _paraenter = require("./para-enter.js");
12
12
  const _baberandomness = require("./parachain/babe-randomness.js");
13
13
  const _nimbusauthorinherent = require("./parachain/nimbus-author-inherent.js");
14
- const _timestamp = require("./timestamp.js");
15
14
  const _validationdata = require("./parachain/validation-data.js");
15
+ const _timestamp = require("./timestamp.js");
16
16
  const inherentProviders = [
17
17
  new _timestamp.SetTimestamp(),
18
18
  new _validationdata.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[]>;
@@ -8,12 +8,12 @@ Object.defineProperty(exports, "SetValidationData", {
8
8
  return SetValidationData;
9
9
  }
10
10
  });
11
- const _util = require("@polkadot/util");
12
11
  const _types = require("@polkadot/types");
12
+ const _util = require("@polkadot/util");
13
13
  const _lodash = /*#__PURE__*/ _interop_require_default(require("lodash"));
14
- const _proof = require("../../../utils/proof.js");
15
14
  const _utilcrypto = require("@polkadot/util-crypto");
16
15
  const _index = require("../../../utils/index.js");
16
+ const _proof = require("../../../utils/proof.js");
17
17
  const _index1 = require("../../../wasm-executor/index.js");
18
18
  function _interop_require_default(obj) {
19
19
  return obj && obj.__esModule ? obj : {
@@ -233,7 +233,7 @@ class SetValidationData {
233
233
  if (params.relayChainStateOverrides) {
234
234
  for (const [key, value] of params.relayChainStateOverrides){
235
235
  // Remove any entry that matches the key being overridden
236
- newEntries = newEntries.filter(([k, _])=>k != key);
236
+ newEntries = newEntries.filter(([k, _])=>k !== key);
237
237
  // Push override
238
238
  newEntries.push([
239
239
  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
  }
@@ -20,8 +20,8 @@ _export(exports, {
20
20
  }
21
21
  });
22
22
  const _lodash = /*#__PURE__*/ _interop_require_default(require("lodash"));
23
- const _index = require("../utils/index.js");
24
23
  const _logger = require("../logger.js");
24
+ const _index = require("../utils/index.js");
25
25
  const _keycache = /*#__PURE__*/ _interop_require_default(require("../utils/key-cache.js"));
26
26
  function _check_private_redeclaration(obj, privateCollection) {
27
27
  if (privateCollection.has(obj)) {
@@ -159,7 +159,7 @@ class RemoteStorageLayer {
159
159
  // batch fetch storage values and save to db, they may be used later
160
160
  _class_private_field_get(this, _api).getStorageBatch(prefix, batch, _class_private_field_get(this, _at)).then((storage)=>{
161
161
  for (const [key, value] of storage){
162
- _class_private_field_get(this, _db).saveStorage(_class_private_field_get(this, _at), key, value);
162
+ _class_private_field_get(this, _db)?.saveStorage(_class_private_field_get(this, _at), key, value);
163
163
  }
164
164
  });
165
165
  }
@@ -255,7 +255,8 @@ class StorageLayer {
255
255
  if (parentBest) {
256
256
  if (!maybeBest) {
257
257
  return parentBest;
258
- } else if (parentBest < maybeBest) {
258
+ }
259
+ if (parentBest < maybeBest) {
259
260
  return parentBest;
260
261
  }
261
262
  }
@@ -271,7 +272,7 @@ class StorageLayer {
271
272
  const next = await this.findNextKey(prefix, startKey, undefined);
272
273
  if (!next) break;
273
274
  startKey = next;
274
- if (await this.get(next, false) == "Deleted") continue;
275
+ if (await this.get(next, false) === "Deleted") continue;
275
276
  keys.push(next);
276
277
  }
277
278
  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) */
@@ -19,12 +19,12 @@ _export(exports, {
19
19
  return TxPool;
20
20
  }
21
21
  });
22
- const _eventemitter3 = require("eventemitter3");
23
22
  const _toU8a = require("@polkadot/util/hex/toU8a");
23
+ const _eventemitter3 = require("eventemitter3");
24
24
  const _lodash = /*#__PURE__*/ _interop_require_default(require("lodash"));
25
+ const _logger = require("../logger.js");
25
26
  const _index = require("../utils/index.js");
26
27
  const _blockbuilder = require("./block-builder.js");
27
- const _logger = require("../logger.js");
28
28
  function _check_private_redeclaration(obj, privateCollection) {
29
29
  if (privateCollection.has(obj)) {
30
30
  throw new TypeError("Cannot initialize the same private elements twice on an object");
@@ -326,6 +326,14 @@ async function buildBlockIfNeeded() {
326
326
  _class_private_field_set(this, _isBuilding, true);
327
327
  try {
328
328
  await _class_private_method_get(this, _buildBlock, buildBlock).call(this);
329
+ } catch (error) {
330
+ logger.error({
331
+ error
332
+ }, 'build block failed');
333
+ for (const { deferred } of _class_private_field_get(this, _pendingBlocks)){
334
+ deferred.reject(error);
335
+ }
336
+ _class_private_field_get(this, _pendingBlocks).length = 0;
329
337
  } finally{
330
338
  _class_private_field_set(this, _isBuilding, false);
331
339
  }
@@ -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;
@@ -9,8 +9,8 @@ Object.defineProperty(exports, "ChopsticksProvider", {
9
9
  }
10
10
  });
11
11
  const _eventemitter3 = require("eventemitter3");
12
- const _index = require("./rpc/index.js");
13
12
  const _logger = require("./logger.js");
13
+ const _index = require("./rpc/index.js");
14
14
  const _setup = require("./setup.js");
15
15
  function _check_private_redeclaration(obj, privateCollection) {
16
16
  if (privateCollection.has(obj)) {
@@ -205,15 +205,14 @@ class ChopsticksProvider {
205
205
  type: subscription.type
206
206
  };
207
207
  return subid;
208
- } else {
209
- logger.debug('call', {
210
- method,
211
- params
212
- });
213
- return rpcHandler({
214
- chain: this.chain
215
- }, params, this.subscriptionManager);
216
208
  }
209
+ logger.debug('call', {
210
+ method,
211
+ params
212
+ });
213
+ return rpcHandler({
214
+ chain: this.chain
215
+ }, params, this.subscriptionManager);
217
216
  } catch (e) {
218
217
  logger.error('send error.', e);
219
218
  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
  */
@@ -9,9 +9,9 @@ Object.defineProperty(exports, "GenesisProvider", {
9
9
  }
10
10
  });
11
11
  const _eventemitter3 = require("eventemitter3");
12
- const _index = require("./schema/index.js");
13
- const _index1 = require("./wasm-executor/index.js");
14
- const _index2 = require("./index.js");
12
+ const _index = require("./index.js");
13
+ const _index1 = require("./schema/index.js");
14
+ const _index2 = require("./wasm-executor/index.js");
15
15
  function _check_private_redeclaration(obj, privateCollection) {
16
16
  if (privateCollection.has(obj)) {
17
17
  throw new TypeError("Cannot initialize the same private elements twice on an object");
@@ -85,19 +85,19 @@ class GenesisProvider {
85
85
  get _jsCallback() {
86
86
  const storage = _class_private_field_get(this, _genesis).genesis.raw.top;
87
87
  return {
88
- ..._index1.emptyTaskHandler,
89
- getStorage: async function(key) {
90
- if ((0, _index2.isPrefixedChildKey)(key)) {
91
- _index2.defaultLogger.warn({
88
+ ..._index2.emptyTaskHandler,
89
+ getStorage: async (key)=>{
90
+ if ((0, _index.isPrefixedChildKey)(key)) {
91
+ _index.defaultLogger.warn({
92
92
  key
93
93
  }, 'genesis child storage not supported');
94
94
  return undefined;
95
95
  }
96
96
  return storage[key];
97
97
  },
98
- getNextKey: async function(prefix, key) {
99
- if ((0, _index2.isPrefixedChildKey)(key)) {
100
- _index2.defaultLogger.warn({
98
+ getNextKey: async (prefix, key)=>{
99
+ if ((0, _index.isPrefixedChildKey)(key)) {
100
+ _index.defaultLogger.warn({
101
101
  prefix,
102
102
  key
103
103
  }, 'genesis child storage not supported');
@@ -191,6 +191,7 @@ class GenesisProvider {
191
191
  case 'chain_getBlock':
192
192
  return this.getBlock();
193
193
  case 'chain_getBlockHash':
194
+ case 'chain_getFinalizedHead':
194
195
  return this.blockHash;
195
196
  case 'state_getKeysPaged':
196
197
  case 'state_getKeysPagedAt':
@@ -239,8 +240,8 @@ class GenesisProvider {
239
240
  _define_property(this, "unsubscribe", async (_type, _method, _id)=>{
240
241
  throw Error('unimplemented');
241
242
  });
242
- _class_private_field_set(this, _genesis, _index.genesisSchema.parse(genesis));
243
- _class_private_field_set(this, _stateRoot, (0, _index1.calculateStateRoot)(Object.entries(_class_private_field_get(this, _genesis).genesis.raw.top).reduce((accu, item)=>{
243
+ _class_private_field_set(this, _genesis, _index1.genesisSchema.parse(genesis));
244
+ _class_private_field_set(this, _stateRoot, (0, _index2.calculateStateRoot)(Object.entries(_class_private_field_get(this, _genesis).genesis.raw.top).reduce((accu, item)=>{
244
245
  accu.push(item);
245
246
  return accu;
246
247
  }, []), 1));
@@ -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[];
@@ -45,9 +45,11 @@ const innerTruncate = (level = 0)=>(val)=>{
45
45
  }
46
46
  switch(typeof val){
47
47
  case 'string':
48
- if (val.length > 66 && !verboseLog) {
49
- return val.slice(0, 34) + '…' + val.slice(-32);
50
- } else {
48
+ {
49
+ const maxLength = verboseLog ? 10 * 1024 : 66;
50
+ if (val.length > maxLength) {
51
+ return `${val.slice(0, 34)}…${val.slice(-32)}`;
52
+ }
51
53
  return val;
52
54
  }
53
55
  case 'object':
@@ -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>;