@acala-network/chopsticks-core 1.5.1 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/dist/cjs/api.js +6 -15
  2. package/dist/cjs/blockchain/block-builder.js +3 -1
  3. package/dist/cjs/blockchain/block.js +5 -12
  4. package/dist/cjs/blockchain/head-state.js +4 -9
  5. package/dist/cjs/blockchain/index.js +6 -15
  6. package/dist/cjs/blockchain/storage-layer.js +5 -12
  7. package/dist/cjs/blockchain/txpool.js +17 -17
  8. package/dist/cjs/chopsticks-provider.js +5 -12
  9. package/dist/cjs/env.d.ts +25 -47
  10. package/dist/cjs/env.js +8 -19
  11. package/dist/cjs/genesis-provider.js +5 -12
  12. package/dist/cjs/logger.d.ts +3 -2
  13. package/dist/cjs/offchain.js +1 -3
  14. package/dist/cjs/rpc/dev/new-block.d.ts +9 -53
  15. package/dist/cjs/rpc/dev/set-head.d.ts +1 -1
  16. package/dist/cjs/rpc/index.d.ts +1 -1
  17. package/dist/cjs/rpc/rpc-spec/chainHead_v1.js +33 -7
  18. package/dist/cjs/rpc/rpc-spec/index.d.ts +1 -1
  19. package/dist/cjs/rpc/rpc-spec/index.js +8 -19
  20. package/dist/cjs/rpc/shared.d.ts +2 -2
  21. package/dist/cjs/rpc/shared.js +1 -3
  22. package/dist/cjs/rpc/substrate/index.d.ts +1 -6
  23. package/dist/cjs/rpc/substrate/index.js +8 -19
  24. package/dist/cjs/rpc/substrate/payment.js +7 -4
  25. package/dist/cjs/schema/index.d.ts +6 -52
  26. package/dist/cjs/schema/index.js +1 -1
  27. package/dist/cjs/utils/index.d.ts +5 -0
  28. package/dist/cjs/utils/index.js +9 -0
  29. package/dist/cjs/utils/key-cache.js +1 -3
  30. package/dist/cjs/wasm-executor/browser-wasm-executor.js +8 -19
  31. package/dist/cjs/wasm-executor/index.js +8 -19
  32. package/dist/cjs/wasm-executor/node-wasm-executor.js +8 -19
  33. package/dist/esm/blockchain/block-builder.js +4 -2
  34. package/dist/esm/blockchain/txpool.js +12 -3
  35. package/dist/esm/env.d.ts +25 -47
  36. package/dist/esm/logger.d.ts +3 -2
  37. package/dist/esm/rpc/dev/new-block.d.ts +9 -53
  38. package/dist/esm/rpc/dev/set-head.d.ts +1 -1
  39. package/dist/esm/rpc/index.d.ts +1 -1
  40. package/dist/esm/rpc/index.js +1 -1
  41. package/dist/esm/rpc/rpc-spec/chainHead_v1.js +33 -7
  42. package/dist/esm/rpc/rpc-spec/index.d.ts +1 -1
  43. package/dist/esm/rpc/rpc-spec/index.js +1 -1
  44. package/dist/esm/rpc/shared.d.ts +2 -2
  45. package/dist/esm/rpc/substrate/index.d.ts +1 -6
  46. package/dist/esm/rpc/substrate/index.js +1 -6
  47. package/dist/esm/rpc/substrate/payment.js +8 -5
  48. package/dist/esm/schema/index.d.ts +6 -52
  49. package/dist/esm/schema/index.js +1 -1
  50. package/dist/esm/utils/index.d.ts +5 -0
  51. package/dist/esm/utils/index.js +10 -1
  52. package/package.json +65 -61
@@ -45,18 +45,44 @@ const logger = _logger.defaultLogger.child({
45
45
  name: 'rpc-chainHead_v1'
46
46
  });
47
47
  const following = new Map();
48
+ const runtimeSpec = (runtime)=>({
49
+ type: 'valid',
50
+ spec: {
51
+ specName: runtime.specName,
52
+ implName: runtime.implName,
53
+ specVersion: runtime.specVersion,
54
+ implVersion: runtime.implVersion,
55
+ transactionVersion: runtime.transactionVersion,
56
+ apis: Object.fromEntries(runtime.apis)
57
+ }
58
+ });
59
+ const invalidRuntimeSpec = (error)=>({
60
+ type: 'invalid',
61
+ error: error instanceof Error ? error.message : String(error)
62
+ });
63
+ const getRuntimeSpec = async (runtime)=>{
64
+ try {
65
+ return runtimeSpec(await runtime);
66
+ } catch (error) {
67
+ return invalidRuntimeSpec(error);
68
+ }
69
+ };
48
70
  const chainHead_v1_follow = async (context, [withRuntime], { subscribe })=>{
49
71
  const update = async (block)=>{
50
72
  logger.trace({
51
73
  hash: block.hash
52
74
  }, 'chainHead_v1_follow');
53
75
  const getNewRuntime = async ()=>{
54
- const [runtime, previousRuntime] = await Promise.all([
55
- block.runtimeVersion,
56
- block.parentBlock.then((b)=>b?.runtimeVersion)
57
- ]);
58
- const hasNewRuntime = runtime.implVersion !== previousRuntime?.implVersion || runtime.specVersion !== previousRuntime.specVersion;
59
- return hasNewRuntime ? runtime : null;
76
+ try {
77
+ const [runtime, previousRuntime] = await Promise.all([
78
+ block.runtimeVersion,
79
+ block.parentBlock.then((b)=>b?.runtimeVersion)
80
+ ]);
81
+ const hasNewRuntime = runtime.implVersion !== previousRuntime?.implVersion || runtime.specVersion !== previousRuntime.specVersion;
82
+ return hasNewRuntime ? runtimeSpec(runtime) : null;
83
+ } catch (error) {
84
+ return invalidRuntimeSpec(error);
85
+ }
60
86
  };
61
87
  const newRuntime = withRuntime ? await getNewRuntime() : null;
62
88
  callback({
@@ -104,7 +130,7 @@ const chainHead_v1_follow = async (context, [withRuntime], { subscribe })=>{
104
130
  finalizedBlockHashes: [
105
131
  context.chain.head.hash
106
132
  ],
107
- finalizedBlockRuntime: withRuntime ? await context.chain.head.runtimeVersion : null
133
+ finalizedBlockRuntime: withRuntime ? await getRuntimeSpec(context.chain.head.runtimeVersion) : null
108
134
  });
109
135
  callback({
110
136
  event: 'bestBlockChanged',
@@ -2,7 +2,7 @@ import * as ArchiveV1RPC from './archive_v1.js';
2
2
  import * as ChainHeadV1RPC from './chainHead_v1.js';
3
3
  import * as ChainSpecV1RPC from './chainSpec_v1.js';
4
4
  import * as TransactionV1RPC from './transaction_v1.js';
5
- export { ChainHeadV1RPC, TransactionV1RPC, ChainSpecV1RPC };
5
+ export { ChainHeadV1RPC, ChainSpecV1RPC, TransactionV1RPC };
6
6
  declare const handlers: {
7
7
  chainSpec_v1_chainName: import("../shared.js").Handler<[], string>;
8
8
  chainSpec_v1_genesisHash: import("../shared.js").Handler<[], import("@polkadot/util/types").HexString>;
@@ -35,18 +35,12 @@ function _getRequireWildcardCache(nodeInterop) {
35
35
  })(nodeInterop);
36
36
  }
37
37
  function _interop_require_wildcard(obj, nodeInterop) {
38
- if (!nodeInterop && obj && obj.__esModule) {
39
- return obj;
40
- }
41
- if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
42
- return {
43
- default: obj
44
- };
45
- }
38
+ if (!nodeInterop && obj && obj.__esModule) return obj;
39
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") return {
40
+ default: obj
41
+ };
46
42
  var cache = _getRequireWildcardCache(nodeInterop);
47
- if (cache && cache.has(obj)) {
48
- return cache.get(obj);
49
- }
43
+ if (cache && cache.has(obj)) return cache.get(obj);
50
44
  var newObj = {
51
45
  __proto__: null
52
46
  };
@@ -54,17 +48,12 @@ function _interop_require_wildcard(obj, nodeInterop) {
54
48
  for(var key in obj){
55
49
  if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
56
50
  var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
57
- if (desc && (desc.get || desc.set)) {
58
- Object.defineProperty(newObj, key, desc);
59
- } else {
60
- newObj[key] = obj[key];
61
- }
51
+ if (desc && (desc.get || desc.set)) Object.defineProperty(newObj, key, desc);
52
+ else newObj[key] = obj[key];
62
53
  }
63
54
  }
64
55
  newObj.default = obj;
65
- if (cache) {
66
- cache.set(obj, newObj);
67
- }
56
+ if (cache) cache.set(obj, newObj);
68
57
  return newObj;
69
58
  }
70
59
  const handlers = {
@@ -1,8 +1,8 @@
1
1
  import { z } from 'zod';
2
2
  import type { Blockchain } from '../blockchain/index.js';
3
3
  export declare const logger: import("pino").Logger<never, boolean>;
4
- export declare const zHex: z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>;
5
- export declare const zHash: z.ZodIntersection<z.ZodString, z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>>;
4
+ export declare const zHex: z.ZodCustom<`0x${string}`, `0x${string}`>;
5
+ export declare const zHash: z.ZodIntersection<z.ZodString, z.ZodCustom<`0x${string}`, `0x${string}`>>;
6
6
  export declare class ResponseError extends Error {
7
7
  code: number;
8
8
  constructor(code: number, message: string);
@@ -32,9 +32,7 @@ function _define_property(obj, key, value) {
32
32
  configurable: true,
33
33
  writable: true
34
34
  });
35
- } else {
36
- obj[key] = value;
37
- }
35
+ } else obj[key] = value;
38
36
  return obj;
39
37
  }
40
38
  const logger = _logger.defaultLogger.child({
@@ -4,12 +4,7 @@ import * as ChainRPC from './chain.js';
4
4
  import * as PaymentRPC from './payment.js';
5
5
  import * as StateRPC from './state.js';
6
6
  import * as SystemRPC from './system.js';
7
- export { ArchiveRPC };
8
- export { AuthorRPC };
9
- export { ChainRPC };
10
- export { PaymentRPC };
11
- export { StateRPC };
12
- export { SystemRPC };
7
+ export { ArchiveRPC, AuthorRPC, ChainRPC, PaymentRPC, StateRPC, SystemRPC };
13
8
  declare const handlers: {
14
9
  system_localPeerId: () => Promise<string>;
15
10
  system_nodeRoles: () => Promise<string[]>;
@@ -46,18 +46,12 @@ function _getRequireWildcardCache(nodeInterop) {
46
46
  })(nodeInterop);
47
47
  }
48
48
  function _interop_require_wildcard(obj, nodeInterop) {
49
- if (!nodeInterop && obj && obj.__esModule) {
50
- return obj;
51
- }
52
- if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
53
- return {
54
- default: obj
55
- };
56
- }
49
+ if (!nodeInterop && obj && obj.__esModule) return obj;
50
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") return {
51
+ default: obj
52
+ };
57
53
  var cache = _getRequireWildcardCache(nodeInterop);
58
- if (cache && cache.has(obj)) {
59
- return cache.get(obj);
60
- }
54
+ if (cache && cache.has(obj)) return cache.get(obj);
61
55
  var newObj = {
62
56
  __proto__: null
63
57
  };
@@ -65,17 +59,12 @@ function _interop_require_wildcard(obj, nodeInterop) {
65
59
  for(var key in obj){
66
60
  if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
67
61
  var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
68
- if (desc && (desc.get || desc.set)) {
69
- Object.defineProperty(newObj, key, desc);
70
- } else {
71
- newObj[key] = obj[key];
72
- }
62
+ if (desc && (desc.get || desc.set)) Object.defineProperty(newObj, key, desc);
63
+ else newObj[key] = obj[key];
73
64
  }
74
65
  }
75
66
  newObj.default = obj;
76
- if (cache) {
77
- cache.set(obj, newObj);
78
- }
67
+ if (cache) cache.set(obj, newObj);
79
68
  return newObj;
80
69
  }
81
70
  const handlers = {
@@ -17,6 +17,7 @@ _export(exports, {
17
17
  }
18
18
  });
19
19
  const _util = require("@polkadot/util");
20
+ const _index = require("../../utils/index.js");
20
21
  const _shared = require("../shared.js");
21
22
  const payment_queryFeeDetails = async (context, [extrinsic, hash])=>{
22
23
  const block = await context.chain.getBlock(hash);
@@ -26,8 +27,9 @@ const payment_queryFeeDetails = async (context, [extrinsic, hash])=>{
26
27
  const registry = await block.registry;
27
28
  const tx = (0, _util.hexToU8a)(extrinsic);
28
29
  const resp = await block.call('TransactionPaymentApi_query_fee_details', [
29
- registry.createType('Extrinsic', tx).toHex(),
30
- registry.createType('u32', tx.byteLength).toHex()
30
+ // polkadot.js cannot always decode a general (v5) extrinsic; the runtime takes its bytes as they are
31
+ (0, _index.isGeneralExtrinsic)(tx) ? extrinsic : registry.createType('Extrinsic', tx).toHex(),
32
+ (0, _util.u8aToHex)(registry.createType('u32', tx.byteLength).toU8a())
31
33
  ]);
32
34
  return resp.result;
33
35
  };
@@ -39,8 +41,9 @@ const payment_queryInfo = async (context, [extrinsic, hash])=>{
39
41
  const registry = await block.registry;
40
42
  const tx = (0, _util.hexToU8a)(extrinsic);
41
43
  const resp = await block.call('TransactionPaymentApi_query_info', [
42
- registry.createType('Extrinsic', tx).toHex(),
43
- registry.createType('u32', tx.byteLength).toHex()
44
+ // polkadot.js cannot always decode a general (v5) extrinsic; the runtime takes its bytes as they are
45
+ (0, _index.isGeneralExtrinsic)(tx) ? extrinsic : registry.createType('Extrinsic', tx).toHex(),
46
+ (0, _util.u8aToHex)(registry.createType('u32', tx.byteLength).toU8a())
44
47
  ]);
45
48
  return resp.result;
46
49
  };
@@ -4,59 +4,13 @@ export declare const genesisSchema: z.ZodObject<{
4
4
  name: z.ZodString;
5
5
  properties: z.ZodObject<{
6
6
  ss58Format: z.ZodOptional<z.ZodNumber>;
7
- tokenDecimals: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodArray<z.ZodNumber, "many">]>>;
8
- tokenSymbol: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
9
- }, "strip", z.ZodTypeAny, {
10
- ss58Format?: number | undefined;
11
- tokenDecimals?: number | number[] | undefined;
12
- tokenSymbol?: string | string[] | undefined;
13
- }, {
14
- ss58Format?: number | undefined;
15
- tokenDecimals?: number | number[] | undefined;
16
- tokenSymbol?: string | string[] | undefined;
17
- }>;
7
+ tokenDecimals: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodArray<z.ZodNumber>]>>;
8
+ tokenSymbol: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
9
+ }, z.core.$strip>;
18
10
  genesis: z.ZodObject<{
19
11
  raw: z.ZodObject<{
20
12
  top: z.ZodRecord<z.ZodString, z.ZodString>;
21
- }, "strip", z.ZodTypeAny, {
22
- top: Record<string, string>;
23
- }, {
24
- top: Record<string, string>;
25
- }>;
26
- }, "strip", z.ZodTypeAny, {
27
- raw: {
28
- top: Record<string, string>;
29
- };
30
- }, {
31
- raw: {
32
- top: Record<string, string>;
33
- };
34
- }>;
35
- }, "strip", z.ZodTypeAny, {
36
- name: string;
37
- id: string;
38
- properties: {
39
- ss58Format?: number | undefined;
40
- tokenDecimals?: number | number[] | undefined;
41
- tokenSymbol?: string | string[] | undefined;
42
- };
43
- genesis: {
44
- raw: {
45
- top: Record<string, string>;
46
- };
47
- };
48
- }, {
49
- name: string;
50
- id: string;
51
- properties: {
52
- ss58Format?: number | undefined;
53
- tokenDecimals?: number | number[] | undefined;
54
- tokenSymbol?: string | string[] | undefined;
55
- };
56
- genesis: {
57
- raw: {
58
- top: Record<string, string>;
59
- };
60
- };
61
- }>;
13
+ }, z.core.$strip>;
14
+ }, z.core.$strip>;
15
+ }, z.core.$strip>;
62
16
  export type Genesis = z.infer<typeof genesisSchema>;
@@ -25,7 +25,7 @@ const genesisSchema = _zod.z.object({
25
25
  }),
26
26
  genesis: _zod.z.object({
27
27
  raw: _zod.z.object({
28
- top: _zod.z.record(_zod.z.string())
28
+ top: _zod.z.record(_zod.z.string(), _zod.z.string())
29
29
  })
30
30
  })
31
31
  });
@@ -10,6 +10,11 @@ export type ProcessKey = (key: StorageKey<any>) => any;
10
10
  export declare function fetchKeys(getKeys: GetKeys, processKey: ProcessKey): Promise<void>;
11
11
  export declare function fetchKeysToArray(getKeys: GetKeys): Promise<StorageKey<any>[]>;
12
12
  export declare const compactHex: (value: Uint8Array) => HexString;
13
+ /**
14
+ * Whether `extrinsic` is a general (v5) extrinsic, read from its preamble byte. polkadot.js cannot always decode one: it
15
+ * skips the payload of a transaction extension it does not know, such as VerifySignature.
16
+ */
17
+ export declare const isGeneralExtrinsic: (extrinsic: HexString | Uint8Array) => boolean;
13
18
  export declare const getParaId: (chain: Blockchain) => Promise<import("@polkadot/types").U32>;
14
19
  export declare const isUrl: (url: string) => boolean;
15
20
  export type Deferred<T> = {
@@ -39,6 +39,9 @@ _export(exports, {
39
39
  get getSlotDuration () {
40
40
  return getSlotDuration;
41
41
  },
42
+ get isGeneralExtrinsic () {
43
+ return isGeneralExtrinsic;
44
+ },
42
45
  get isPrefixedChildKey () {
43
46
  return isPrefixedChildKey;
44
47
  },
@@ -55,6 +58,7 @@ _export(exports, {
55
58
  return stripChildPrefix;
56
59
  }
57
60
  });
61
+ const _constants = require("@polkadot/types/extrinsic/constants");
58
62
  const _util = require("@polkadot/util");
59
63
  const _hex = require("@polkadot/util/hex");
60
64
  const _index = require("../wasm-executor/index.js");
@@ -99,6 +103,11 @@ async function fetchKeysToArray(getKeys) {
99
103
  const compactHex = (value)=>{
100
104
  return (0, _util.u8aToHex)((0, _util.compactStripLength)(value)[1]);
101
105
  };
106
+ const isGeneralExtrinsic = (extrinsic)=>{
107
+ const u8a = (0, _util.u8aToU8a)(extrinsic);
108
+ const [offset] = (0, _util.compactFromU8a)(u8a);
109
+ return (u8a[offset] & _constants.TYPE_MASK) === _constants.GENERAL_EXTRINSIC;
110
+ };
102
111
  const getParaId = async (chain)=>{
103
112
  const meta = await chain.head.meta;
104
113
  const id = await chain.head.read('u32', meta.query.parachainInfo.parachainId);
@@ -17,9 +17,7 @@ function _define_property(obj, key, value) {
17
17
  configurable: true,
18
18
  writable: true
19
19
  });
20
- } else {
21
- obj[key] = value;
22
- }
20
+ } else obj[key] = value;
23
21
  return obj;
24
22
  }
25
23
  function _interop_require_default(obj) {
@@ -13,18 +13,12 @@ function _getRequireWildcardCache(nodeInterop) {
13
13
  })(nodeInterop);
14
14
  }
15
15
  function _interop_require_wildcard(obj, nodeInterop) {
16
- if (!nodeInterop && obj && obj.__esModule) {
17
- return obj;
18
- }
19
- if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
20
- return {
21
- default: obj
22
- };
23
- }
16
+ if (!nodeInterop && obj && obj.__esModule) return obj;
17
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") return {
18
+ default: obj
19
+ };
24
20
  var cache = _getRequireWildcardCache(nodeInterop);
25
- if (cache && cache.has(obj)) {
26
- return cache.get(obj);
27
- }
21
+ if (cache && cache.has(obj)) return cache.get(obj);
28
22
  var newObj = {
29
23
  __proto__: null
30
24
  };
@@ -32,17 +26,12 @@ function _interop_require_wildcard(obj, nodeInterop) {
32
26
  for(var key in obj){
33
27
  if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
34
28
  var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
35
- if (desc && (desc.get || desc.set)) {
36
- Object.defineProperty(newObj, key, desc);
37
- } else {
38
- newObj[key] = obj[key];
39
- }
29
+ if (desc && (desc.get || desc.set)) Object.defineProperty(newObj, key, desc);
30
+ else newObj[key] = obj[key];
40
31
  }
41
32
  }
42
33
  newObj.default = obj;
43
- if (cache) {
44
- cache.set(obj, newObj);
45
- }
34
+ if (cache) cache.set(obj, newObj);
46
35
  return newObj;
47
36
  }
48
37
  const getRuntimeVersion = async (code)=>{
@@ -60,18 +60,12 @@ function _getRequireWildcardCache(nodeInterop) {
60
60
  })(nodeInterop);
61
61
  }
62
62
  function _interop_require_wildcard(obj, nodeInterop) {
63
- if (!nodeInterop && obj && obj.__esModule) {
64
- return obj;
65
- }
66
- if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
67
- return {
68
- default: obj
69
- };
70
- }
63
+ if (!nodeInterop && obj && obj.__esModule) return obj;
64
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") return {
65
+ default: obj
66
+ };
71
67
  var cache = _getRequireWildcardCache(nodeInterop);
72
- if (cache && cache.has(obj)) {
73
- return cache.get(obj);
74
- }
68
+ if (cache && cache.has(obj)) return cache.get(obj);
75
69
  var newObj = {
76
70
  __proto__: null
77
71
  };
@@ -79,17 +73,12 @@ function _interop_require_wildcard(obj, nodeInterop) {
79
73
  for(var key in obj){
80
74
  if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
81
75
  var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
82
- if (desc && (desc.get || desc.set)) {
83
- Object.defineProperty(newObj, key, desc);
84
- } else {
85
- newObj[key] = obj[key];
86
- }
76
+ if (desc && (desc.get || desc.set)) Object.defineProperty(newObj, key, desc);
77
+ else newObj[key] = obj[key];
87
78
  }
88
79
  }
89
80
  newObj.default = obj;
90
- if (cache) {
91
- cache.set(obj, newObj);
92
- }
81
+ if (cache) cache.set(obj, newObj);
93
82
  return newObj;
94
83
  }
95
84
  const logger = _logger.defaultLogger.child({
@@ -20,18 +20,12 @@ function _getRequireWildcardCache(nodeInterop) {
20
20
  })(nodeInterop);
21
21
  }
22
22
  function _interop_require_wildcard(obj, nodeInterop) {
23
- if (!nodeInterop && obj && obj.__esModule) {
24
- return obj;
25
- }
26
- if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
27
- return {
28
- default: obj
29
- };
30
- }
23
+ if (!nodeInterop && obj && obj.__esModule) return obj;
24
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") return {
25
+ default: obj
26
+ };
31
27
  var cache = _getRequireWildcardCache(nodeInterop);
32
- if (cache && cache.has(obj)) {
33
- return cache.get(obj);
34
- }
28
+ if (cache && cache.has(obj)) return cache.get(obj);
35
29
  var newObj = {
36
30
  __proto__: null
37
31
  };
@@ -39,17 +33,12 @@ function _interop_require_wildcard(obj, nodeInterop) {
39
33
  for(var key in obj){
40
34
  if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
41
35
  var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
42
- if (desc && (desc.get || desc.set)) {
43
- Object.defineProperty(newObj, key, desc);
44
- } else {
45
- newObj[key] = obj[key];
46
- }
36
+ if (desc && (desc.get || desc.set)) Object.defineProperty(newObj, key, desc);
37
+ else newObj[key] = obj[key];
47
38
  }
48
39
  }
49
40
  newObj.default = obj;
50
- if (cache) {
51
- cache.set(obj, newObj);
52
- }
41
+ if (cache) cache.set(obj, newObj);
53
42
  return newObj;
54
43
  }
55
44
  const getRuntimeVersion = async (code)=>{
@@ -1,7 +1,7 @@
1
1
  import { compactAddLength, hexToU8a, stringToHex, u8aConcat, u8aToHex } from '@polkadot/util';
2
2
  import { blake2AsU8a } from '@polkadot/util-crypto';
3
3
  import { defaultLogger, truncate } from '../logger.js';
4
- import { compactHex, getCurrentSlot } from '../utils/index.js';
4
+ import { compactHex, getCurrentSlot, isGeneralExtrinsic } from '../utils/index.js';
5
5
  import { Block } from './block.js';
6
6
  import { StorageLayer, StorageValueKind } from './storage-layer.js';
7
7
  const logger = defaultLogger.child({
@@ -417,7 +417,9 @@ export const dryRunExtrinsic = async (head, inherentProviders, extrinsic, params
417
417
  generic.toHex()
418
418
  ]);
419
419
  }
420
- logger.debug({
420
+ logger.debug(isGeneralExtrinsic(extrinsic) ? {
421
+ extrinsic: truncate(extrinsic)
422
+ } : {
421
423
  call: registry.createType('GenericExtrinsic', hexToU8a(extrinsic)).toJSON()
422
424
  }, 'dry_run_extrinsic');
423
425
  return newBlock.call('BlockBuilder_apply_extrinsic', [
@@ -2,7 +2,7 @@ import { hexToU8a } from '@polkadot/util/hex/toU8a';
2
2
  import { EventEmitter } from 'eventemitter3';
3
3
  import _ from 'lodash';
4
4
  import { defaultLogger, truncate } from '../logger.js';
5
- import { defer } from '../utils/index.js';
5
+ import { defer, isGeneralExtrinsic } from '../utils/index.js';
6
6
  import { buildBlock } from './block-builder.js';
7
7
  const logger = defaultLogger.child({
8
8
  name: 'txpool'
@@ -73,8 +73,17 @@ export class TxPool {
73
73
  }
74
74
  async #getSigner(extrinsic) {
75
75
  const registry = await this.#chain.head.registry;
76
- const tx = registry.createType('GenericExtrinsic', extrinsic);
77
- return tx.signer.toString();
76
+ if (!isGeneralExtrinsic(extrinsic)) {
77
+ return registry.createType('GenericExtrinsic', extrinsic).signer.toString();
78
+ }
79
+ // A general (v5) extrinsic has no signer field, and `signer` throws for it. Its account, if any, is the one
80
+ // frame_system's CheckNonce tags it with: `provides: [(account, nonce)]`.
81
+ const validity = await this.#chain.validateExtrinsic(extrinsic);
82
+ if (!validity.isOk) return undefined;
83
+ const length = registry.createType('AccountId').encodedLength + registry.createType('Index').encodedLength;
84
+ const tags = validity.asOk.provides.filter((tag)=>tag.length === length);
85
+ if (tags.length !== 1) return undefined;
86
+ return registry.createType('(AccountId, Index)', tags[0].toU8a(true))[0].toString();
78
87
  }
79
88
  submitUpwardMessages(id, ump) {
80
89
  logger.debug({
package/dist/esm/env.d.ts CHANGED
@@ -1,57 +1,35 @@
1
1
  import * as z from 'zod';
2
2
  export declare const environmentSchema: z.ZodObject<{
3
- /**
4
- * Disable auto HRMP on setup. Default is `false`.
5
- */
6
- DISABLE_AUTO_HRMP: z.ZodEffects<z.ZodDefault<z.ZodEnum<["true", "false"]>>, boolean, "true" | "false" | undefined>;
7
- /**
8
- * Set port for Chopsticks to listen on, default is `8000`.
9
- */
3
+ DISABLE_AUTO_HRMP: z.ZodPipe<z.ZodDefault<z.ZodEnum<{
4
+ true: "true";
5
+ false: "false";
6
+ }>>, z.ZodTransform<boolean, "true" | "false">>;
10
7
  PORT: z.ZodOptional<z.ZodString>;
11
- /**
12
- * Disable plugins for faster startup. Default is `false`.
13
- */
14
- DISABLE_PLUGINS: z.ZodEffects<z.ZodDefault<z.ZodEnum<["true", "false"]>>, boolean, "true" | "false" | undefined>;
8
+ DISABLE_PLUGINS: z.ZodPipe<z.ZodDefault<z.ZodEnum<{
9
+ true: "true";
10
+ false: "false";
11
+ }>>, z.ZodTransform<boolean, "true" | "false">>;
15
12
  HTTP_PROXY: z.ZodOptional<z.ZodString>;
16
13
  http_proxy: z.ZodOptional<z.ZodString>;
17
14
  HTTPS_PROXY: z.ZodOptional<z.ZodString>;
18
15
  https_proxy: z.ZodOptional<z.ZodString>;
19
- /**
20
- * Chopsticks log level, "fatal" | "error" | "warn" | "info" | "debug" | "trace".
21
- * Default is "info".
22
- */
23
- LOG_LEVEL: z.ZodDefault<z.ZodEnum<["fatal", "error", "warn", "info", "debug", "trace"]>>;
24
- /**
25
- * Don't truncate log messages, show full log output. Default is `false`.
26
- */
27
- VERBOSE_LOG: z.ZodEffects<z.ZodDefault<z.ZodEnum<["true", "false"]>>, boolean, "true" | "false" | undefined>;
28
- /**
29
- * Don't log objects. Default is `false`.
30
- */
31
- LOG_COMPACT: z.ZodEffects<z.ZodDefault<z.ZodEnum<["true", "false"]>>, boolean, "true" | "false" | undefined>;
32
- }, "strip", z.ZodTypeAny, {
33
- DISABLE_AUTO_HRMP: boolean;
34
- DISABLE_PLUGINS: boolean;
35
- LOG_LEVEL: "fatal" | "error" | "warn" | "info" | "debug" | "trace";
36
- VERBOSE_LOG: boolean;
37
- LOG_COMPACT: boolean;
38
- PORT?: string | undefined;
39
- HTTP_PROXY?: string | undefined;
40
- http_proxy?: string | undefined;
41
- HTTPS_PROXY?: string | undefined;
42
- https_proxy?: string | undefined;
43
- }, {
44
- DISABLE_AUTO_HRMP?: "true" | "false" | undefined;
45
- PORT?: string | undefined;
46
- DISABLE_PLUGINS?: "true" | "false" | undefined;
47
- HTTP_PROXY?: string | undefined;
48
- http_proxy?: string | undefined;
49
- HTTPS_PROXY?: string | undefined;
50
- https_proxy?: string | undefined;
51
- LOG_LEVEL?: "fatal" | "error" | "warn" | "info" | "debug" | "trace" | undefined;
52
- VERBOSE_LOG?: "true" | "false" | undefined;
53
- LOG_COMPACT?: "true" | "false" | undefined;
54
- }>;
16
+ LOG_LEVEL: z.ZodDefault<z.ZodEnum<{
17
+ fatal: "fatal";
18
+ error: "error";
19
+ warn: "warn";
20
+ info: "info";
21
+ debug: "debug";
22
+ trace: "trace";
23
+ }>>;
24
+ VERBOSE_LOG: z.ZodPipe<z.ZodDefault<z.ZodEnum<{
25
+ true: "true";
26
+ false: "false";
27
+ }>>, z.ZodTransform<boolean, "true" | "false">>;
28
+ LOG_COMPACT: z.ZodPipe<z.ZodDefault<z.ZodEnum<{
29
+ true: "true";
30
+ false: "false";
31
+ }>>, z.ZodTransform<boolean, "true" | "false">>;
32
+ }, z.core.$strip>;
55
33
  /**
56
34
  * Environment variables available for users
57
35
  */
@@ -1,3 +1,4 @@
1
- export declare const pinoLogger: import("pino").Logger<never, boolean>;
2
- export declare const defaultLogger: import("pino").Logger<never, boolean>;
1
+ import { pino } from 'pino';
2
+ export declare const pinoLogger: pino.Logger<never, boolean>;
3
+ export declare const defaultLogger: pino.Logger<never, boolean>;
3
4
  export declare const truncate: (val: any) => any;