@acala-network/chopsticks 0.9.4-1 → 0.9.4-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 (91) hide show
  1. package/dist/cjs/plugins/run-block/__snapshots__/index.test.ts.snap +2995 -2629
  2. package/dist/{types → cjs}/plugins/run-block/rpc.d.ts +1 -0
  3. package/dist/cjs/plugins/run-block/rpc.js +3 -1
  4. package/dist/esm/cli-options.d.ts +40 -0
  5. package/dist/esm/cli.d.ts +1 -0
  6. package/dist/esm/context.d.ts +7 -0
  7. package/dist/esm/index.d.ts +4 -0
  8. package/dist/esm/logger.d.ts +1 -0
  9. package/dist/esm/plugins/decode-key/cli.d.ts +2 -0
  10. package/dist/esm/plugins/decode-key/index.d.ts +1 -0
  11. package/dist/esm/plugins/dry-run/cli.d.ts +2 -0
  12. package/dist/esm/plugins/dry-run/dry-run-extrinsic.d.ts +2 -0
  13. package/dist/esm/plugins/dry-run/dry-run-preimage.d.ts +2 -0
  14. package/dist/esm/plugins/dry-run/index.d.ts +2 -0
  15. package/dist/esm/plugins/dry-run/rpc.d.ts +139 -0
  16. package/dist/esm/plugins/follow-chain/cli.d.ts +2 -0
  17. package/dist/esm/plugins/follow-chain/index.d.ts +1 -0
  18. package/dist/esm/plugins/index.d.ts +6 -0
  19. package/dist/esm/plugins/new-block/index.d.ts +1 -0
  20. package/dist/esm/plugins/new-block/rpc.d.ts +128 -0
  21. package/dist/esm/plugins/run-block/__snapshots__/index.test.ts.snap +2995 -2629
  22. package/dist/esm/plugins/run-block/cli.d.ts +2 -0
  23. package/dist/esm/plugins/run-block/index.d.ts +2 -0
  24. package/dist/esm/plugins/run-block/rpc.d.ts +140 -0
  25. package/dist/esm/plugins/run-block/rpc.js +3 -1
  26. package/dist/esm/plugins/set-block-build-mode/index.d.ts +1 -0
  27. package/dist/esm/plugins/set-block-build-mode/rpc.d.ts +20 -0
  28. package/dist/esm/plugins/set-head/index.d.ts +1 -0
  29. package/dist/esm/plugins/set-head/rpc.d.ts +21 -0
  30. package/dist/esm/plugins/set-runtime-log-level/index.d.ts +1 -0
  31. package/dist/esm/plugins/set-runtime-log-level/rpc.d.ts +17 -0
  32. package/dist/esm/plugins/set-storage/index.d.ts +1 -0
  33. package/dist/esm/plugins/set-storage/rpc.d.ts +28 -0
  34. package/dist/esm/plugins/time-travel/index.d.ts +1 -0
  35. package/dist/esm/plugins/time-travel/rpc.d.ts +17 -0
  36. package/dist/esm/plugins/try-runtime/index.d.ts +2 -0
  37. package/dist/esm/plugins/types.d.ts +11 -0
  38. package/dist/esm/rpc/index.d.ts +5 -0
  39. package/dist/esm/schema/index.d.ts +140 -0
  40. package/dist/esm/server.d.ts +9 -0
  41. package/dist/esm/setup-with-server.d.ts +6 -0
  42. package/dist/esm/types.d.ts +15 -0
  43. package/dist/esm/utils/decoder.d.ts +7 -0
  44. package/dist/esm/utils/generate-html-diff.d.ts +4 -0
  45. package/dist/esm/utils/index.d.ts +4 -0
  46. package/dist/esm/utils/open-html.d.ts +1 -0
  47. package/dist/esm/utils/override.d.ts +4 -0
  48. package/dist/esm/utils/tunnel.d.ts +1 -0
  49. package/package.json +8 -17
  50. /package/dist/{types → cjs}/cli-options.d.ts +0 -0
  51. /package/dist/{types → cjs}/cli.d.ts +0 -0
  52. /package/dist/{types → cjs}/context.d.ts +0 -0
  53. /package/dist/{types → cjs}/index.d.ts +0 -0
  54. /package/dist/{types → cjs}/logger.d.ts +0 -0
  55. /package/dist/{types → cjs}/plugins/decode-key/cli.d.ts +0 -0
  56. /package/dist/{types → cjs}/plugins/decode-key/index.d.ts +0 -0
  57. /package/dist/{types → cjs}/plugins/dry-run/cli.d.ts +0 -0
  58. /package/dist/{types → cjs}/plugins/dry-run/dry-run-extrinsic.d.ts +0 -0
  59. /package/dist/{types → cjs}/plugins/dry-run/dry-run-preimage.d.ts +0 -0
  60. /package/dist/{types → cjs}/plugins/dry-run/index.d.ts +0 -0
  61. /package/dist/{types → cjs}/plugins/dry-run/rpc.d.ts +0 -0
  62. /package/dist/{types → cjs}/plugins/follow-chain/cli.d.ts +0 -0
  63. /package/dist/{types → cjs}/plugins/follow-chain/index.d.ts +0 -0
  64. /package/dist/{types → cjs}/plugins/index.d.ts +0 -0
  65. /package/dist/{types → cjs}/plugins/new-block/index.d.ts +0 -0
  66. /package/dist/{types → cjs}/plugins/new-block/rpc.d.ts +0 -0
  67. /package/dist/{types → cjs}/plugins/run-block/cli.d.ts +0 -0
  68. /package/dist/{types → cjs}/plugins/run-block/index.d.ts +0 -0
  69. /package/dist/{types → cjs}/plugins/set-block-build-mode/index.d.ts +0 -0
  70. /package/dist/{types → cjs}/plugins/set-block-build-mode/rpc.d.ts +0 -0
  71. /package/dist/{types → cjs}/plugins/set-head/index.d.ts +0 -0
  72. /package/dist/{types → cjs}/plugins/set-head/rpc.d.ts +0 -0
  73. /package/dist/{types → cjs}/plugins/set-runtime-log-level/index.d.ts +0 -0
  74. /package/dist/{types → cjs}/plugins/set-runtime-log-level/rpc.d.ts +0 -0
  75. /package/dist/{types → cjs}/plugins/set-storage/index.d.ts +0 -0
  76. /package/dist/{types → cjs}/plugins/set-storage/rpc.d.ts +0 -0
  77. /package/dist/{types → cjs}/plugins/time-travel/index.d.ts +0 -0
  78. /package/dist/{types → cjs}/plugins/time-travel/rpc.d.ts +0 -0
  79. /package/dist/{types → cjs}/plugins/try-runtime/index.d.ts +0 -0
  80. /package/dist/{types → cjs}/plugins/types.d.ts +0 -0
  81. /package/dist/{types → cjs}/rpc/index.d.ts +0 -0
  82. /package/dist/{types → cjs}/schema/index.d.ts +0 -0
  83. /package/dist/{types → cjs}/server.d.ts +0 -0
  84. /package/dist/{types → cjs}/setup-with-server.d.ts +0 -0
  85. /package/dist/{types → cjs}/types.d.ts +0 -0
  86. /package/dist/{types → cjs}/utils/decoder.d.ts +0 -0
  87. /package/dist/{types → cjs}/utils/generate-html-diff.d.ts +0 -0
  88. /package/dist/{types → cjs}/utils/index.d.ts +0 -0
  89. /package/dist/{types → cjs}/utils/open-html.d.ts +0 -0
  90. /package/dist/{types → cjs}/utils/override.d.ts +0 -0
  91. /package/dist/{types → cjs}/utils/tunnel.d.ts +0 -0
@@ -123,6 +123,7 @@ export interface RunBlockResponse {
123
123
  method: string;
124
124
  args: any[];
125
125
  success: boolean;
126
+ signer: string | null;
126
127
  }[];
127
128
  };
128
129
  }
@@ -142,11 +142,13 @@ const rpc = async ({ chain }, [params])=>{
142
142
  const extrinsics = block.extrinsics.map((extrinsic, idx)=>{
143
143
  const parsed = registry.createType('GenericExtrinsic', extrinsic);
144
144
  const resultEvent = events?.find(({ event, phase })=>event.section === 'system' && (event.method === 'ExtrinsicSuccess' || event.method === 'ExtrinsicFailed') && phase.isApplyExtrinsic && phase.asApplyExtrinsic.eq(idx));
145
+ const signer = parsed.signer.isEmpty ? null : parsed.signer.toHex();
145
146
  return {
146
147
  section: parsed.method.section,
147
148
  method: parsed.method.method,
148
149
  args: parsed.method.args.map((arg)=>arg.toJSON()),
149
- success: resultEvent?.event.method === 'ExtrinsicSuccess'
150
+ success: resultEvent?.event.method === 'ExtrinsicSuccess',
151
+ signer
150
152
  };
151
153
  });
152
154
  resp.blockDetails = {
@@ -0,0 +1,40 @@
1
+ export declare const defaultOptions: {
2
+ endpoint: {
3
+ desc: string;
4
+ string: boolean;
5
+ };
6
+ block: {
7
+ desc: string;
8
+ string: boolean;
9
+ };
10
+ 'wasm-override': {
11
+ desc: string;
12
+ string: boolean;
13
+ };
14
+ db: {
15
+ desc: string;
16
+ string: boolean;
17
+ };
18
+ config: {
19
+ desc: string;
20
+ string: boolean;
21
+ };
22
+ 'runtime-log-level': {
23
+ desc: string;
24
+ number: boolean;
25
+ };
26
+ 'offchain-worker': {
27
+ desc: string;
28
+ boolean: boolean;
29
+ };
30
+ };
31
+ export declare const mockOptions: {
32
+ 'import-storage': {
33
+ desc: string;
34
+ string: boolean;
35
+ };
36
+ 'mock-signature-host': {
37
+ desc: string;
38
+ boolean: boolean;
39
+ };
40
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ import './utils/tunnel.js';
2
+ import { GenesisProvider } from '@acala-network/chopsticks-core';
3
+ import { Config } from './schema/index.js';
4
+ export declare const genesisFromUrl: (url: string) => Promise<GenesisProvider>;
5
+ export declare const setupContext: (argv: Config, overrideParent?: boolean) => Promise<{
6
+ chain: import("@acala-network/chopsticks-core").Blockchain;
7
+ }>;
@@ -0,0 +1,4 @@
1
+ import '@polkadot/api-augment';
2
+ export * from '@acala-network/chopsticks-core';
3
+ export { setupWithServer } from './setup-with-server.js';
4
+ export { fetchConfig } from './schema/index.js';
@@ -0,0 +1 @@
1
+ export { defaultLogger, truncate } from '@acala-network/chopsticks-core';
@@ -0,0 +1,2 @@
1
+ import type { Argv } from 'yargs';
2
+ export declare const cli: (y: Argv) => void;
@@ -0,0 +1 @@
1
+ export * from './cli.js';
@@ -0,0 +1,2 @@
1
+ import type { Argv } from 'yargs';
2
+ export declare const cli: (y: Argv) => void;
@@ -0,0 +1,2 @@
1
+ import { Config } from '../../schema/index.js';
2
+ export declare const dryRunExtrinsic: (argv: Config) => Promise<never>;
@@ -0,0 +1,2 @@
1
+ import { Config } from '../../schema/index.js';
2
+ export declare const dryRunPreimage: (argv: Config) => Promise<never>;
@@ -0,0 +1,2 @@
1
+ export * from './cli.js';
2
+ export * from './rpc.js';
@@ -0,0 +1,139 @@
1
+ import { z } from 'zod';
2
+ import { Context } from '@acala-network/chopsticks-core';
3
+ declare const schema: z.ZodObject<{
4
+ raw: z.ZodOptional<z.ZodBoolean>;
5
+ html: z.ZodOptional<z.ZodBoolean>;
6
+ extrinsic: z.ZodOptional<z.ZodUnion<[z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, z.ZodObject<{
7
+ call: z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>;
8
+ address: z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>;
9
+ }, "strip", z.ZodTypeAny, {
10
+ address: `0x${string}`;
11
+ call: `0x${string}`;
12
+ }, {
13
+ address: `0x${string}`;
14
+ call: `0x${string}`;
15
+ }>]>>;
16
+ hrmp: z.ZodOptional<z.ZodRecord<z.ZodEffects<z.ZodString, number, string>, z.ZodArray<z.ZodObject<{
17
+ sentAt: z.ZodNumber;
18
+ data: z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>;
19
+ }, "strip", z.ZodTypeAny, {
20
+ data: `0x${string}`;
21
+ sentAt: number;
22
+ }, {
23
+ data: `0x${string}`;
24
+ sentAt: number;
25
+ }>, "many">>>;
26
+ dmp: z.ZodOptional<z.ZodArray<z.ZodObject<{
27
+ sentAt: z.ZodNumber;
28
+ msg: z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>;
29
+ }, "strip", z.ZodTypeAny, {
30
+ sentAt: number;
31
+ msg: `0x${string}`;
32
+ }, {
33
+ sentAt: number;
34
+ msg: `0x${string}`;
35
+ }>, "many">>;
36
+ ump: z.ZodOptional<z.ZodRecord<z.ZodEffects<z.ZodString, number, string>, z.ZodArray<z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, "many">>>;
37
+ at: z.ZodOptional<z.ZodIntersection<z.ZodString, z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>>>;
38
+ }, "strip", z.ZodTypeAny, {
39
+ raw?: boolean | undefined;
40
+ html?: boolean | undefined;
41
+ extrinsic?: `0x${string}` | {
42
+ address: `0x${string}`;
43
+ call: `0x${string}`;
44
+ } | undefined;
45
+ hrmp?: Record<number, {
46
+ data: `0x${string}`;
47
+ sentAt: number;
48
+ }[]> | undefined;
49
+ dmp?: {
50
+ sentAt: number;
51
+ msg: `0x${string}`;
52
+ }[] | undefined;
53
+ ump?: Record<number, `0x${string}`[]> | undefined;
54
+ at?: `0x${string}` | undefined;
55
+ }, {
56
+ raw?: boolean | undefined;
57
+ html?: boolean | undefined;
58
+ extrinsic?: `0x${string}` | {
59
+ address: `0x${string}`;
60
+ call: `0x${string}`;
61
+ } | undefined;
62
+ hrmp?: Record<string, {
63
+ data: `0x${string}`;
64
+ sentAt: number;
65
+ }[]> | undefined;
66
+ dmp?: {
67
+ sentAt: number;
68
+ msg: `0x${string}`;
69
+ }[] | undefined;
70
+ ump?: Record<string, `0x${string}`[]> | undefined;
71
+ at?: `0x${string}` | undefined;
72
+ }>;
73
+ type Params = z.infer<typeof schema>;
74
+ export interface DryRunParams {
75
+ /**
76
+ * Return the raw storage diff
77
+ */
78
+ raw: Params['raw'];
79
+ /**
80
+ * Return the html storage diff
81
+ */
82
+ html: Params['html'];
83
+ /**
84
+ * The extrinsic to run
85
+ */
86
+ extrinsic: Params['extrinsic'];
87
+ /**
88
+ * The horizontal messages to run
89
+ */
90
+ hrmp: Params['hrmp'];
91
+ /**
92
+ * The downward messages to run
93
+ */
94
+ dmp: Params['dmp'];
95
+ /**
96
+ * The upward messages to run
97
+ */
98
+ ump: Params['ump'];
99
+ /**
100
+ * The block hash or number to run the extrinsic at
101
+ */
102
+ at: Params['at'];
103
+ }
104
+ /**
105
+ * Dry run an extrinsic or messages.
106
+ * If `html` is true, return the generated storage diff html string.
107
+ * If `raw` is true, return the raw storage diff.
108
+ * Otherwise, return `{ oldState, newState, delta }`.
109
+ *
110
+ * This function is a dev rpc handler. Use `dev_dryRun` as the method name when calling it.
111
+ *
112
+ * @param context - The context object of the rpc handler
113
+ * @param params - The parameters of the rpc handler
114
+ *
115
+ * @example Dry run an dmp
116
+ * ```ts
117
+ * import { WsProvider } from '@polkadot/rpc-provider'
118
+ * const ws = new WsProvider(`ws://localhost:8000`)
119
+ * const params = [
120
+ {
121
+ raw: false,
122
+ dmp: [
123
+ // https://acala.subscan.io/xcm_message/polkadot-2ab22918c567455af3563989d852f307f4cc1250
124
+ {
125
+ sentAt: 14471353,
126
+ msg: '0x02100104000100000b00280b9bba030a13000100000b00280b9bba03010300286bee0d0100040001010070c53d8e216f9c0f2e3b11c53f5f4bf3e078b995d5f0ed590f889f41e20e6531',
127
+ },
128
+ ],
129
+ },
130
+ ]
131
+ * await ws.send('dev_dryRun', params)
132
+ * ```
133
+ */
134
+ export declare const rpc: (context: Context, [params]: [DryRunParams]) => Promise<string | [`0x${string}`, `0x${string}` | null][] | {
135
+ old: {};
136
+ new: {};
137
+ delta: import("jsondiffpatch").Delta | undefined;
138
+ }>;
139
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { Argv } from 'yargs';
2
+ export declare const cli: (y: Argv) => void;
@@ -0,0 +1 @@
1
+ export * from './cli.js';
@@ -0,0 +1,6 @@
1
+ import { Handlers } from '@acala-network/chopsticks-core';
2
+ import type { Argv } from 'yargs';
3
+ export declare const rpcPluginHandlers: Handlers;
4
+ export declare const rpcPluginMethods: string[];
5
+ export declare const loadRpcPlugin: (method: string) => Promise<any>;
6
+ export declare const pluginExtendCli: (y: Argv) => Promise<void>;
@@ -0,0 +1 @@
1
+ export * from './rpc.js';
@@ -0,0 +1,128 @@
1
+ import { Context } from '@acala-network/chopsticks-core';
2
+ import { z } from 'zod';
3
+ declare const schema: z.ZodObject<{
4
+ count: z.ZodOptional<z.ZodNumber>;
5
+ to: z.ZodOptional<z.ZodNumber>;
6
+ dmp: z.ZodOptional<z.ZodArray<z.ZodObject<{
7
+ sentAt: z.ZodNumber;
8
+ msg: z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>;
9
+ }, "strip", z.ZodTypeAny, {
10
+ sentAt: number;
11
+ msg: `0x${string}`;
12
+ }, {
13
+ sentAt: number;
14
+ msg: `0x${string}`;
15
+ }>, "many">>;
16
+ ump: z.ZodOptional<z.ZodRecord<z.ZodNumber, z.ZodArray<z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, "many">>>;
17
+ hrmp: z.ZodOptional<z.ZodRecord<z.ZodNumber, z.ZodArray<z.ZodObject<{
18
+ sentAt: z.ZodNumber;
19
+ data: z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>;
20
+ }, "strip", z.ZodTypeAny, {
21
+ data: `0x${string}`;
22
+ sentAt: number;
23
+ }, {
24
+ data: `0x${string}`;
25
+ sentAt: number;
26
+ }>, "many">>>;
27
+ transactions: z.ZodOptional<z.ZodArray<z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, "many">>;
28
+ unsafeBlockHeight: z.ZodOptional<z.ZodNumber>;
29
+ }, "strip", z.ZodTypeAny, {
30
+ count?: number | undefined;
31
+ to?: number | undefined;
32
+ dmp?: {
33
+ sentAt: number;
34
+ msg: `0x${string}`;
35
+ }[] | undefined;
36
+ ump?: Record<number, `0x${string}`[]> | undefined;
37
+ hrmp?: Record<number, {
38
+ data: `0x${string}`;
39
+ sentAt: number;
40
+ }[]> | undefined;
41
+ transactions?: `0x${string}`[] | undefined;
42
+ unsafeBlockHeight?: number | undefined;
43
+ }, {
44
+ count?: number | undefined;
45
+ to?: number | undefined;
46
+ dmp?: {
47
+ sentAt: number;
48
+ msg: `0x${string}`;
49
+ }[] | undefined;
50
+ ump?: Record<number, `0x${string}`[]> | undefined;
51
+ hrmp?: Record<number, {
52
+ data: `0x${string}`;
53
+ sentAt: number;
54
+ }[]> | undefined;
55
+ transactions?: `0x${string}`[] | undefined;
56
+ unsafeBlockHeight?: number | undefined;
57
+ }>;
58
+ type Params = z.infer<typeof schema>;
59
+ export interface NewBlockParams {
60
+ /**
61
+ * The number of blocks to build
62
+ */
63
+ count: Params['count'];
64
+ /**
65
+ * The block number to build to
66
+ */
67
+ to: Params['to'];
68
+ /**
69
+ * The downward messages to include in the block
70
+ */
71
+ dmp: Params['dmp'];
72
+ /**
73
+ * The upward messages to include in the block
74
+ */
75
+ ump: Params['ump'];
76
+ /**
77
+ * The horizontal messages to include in the block
78
+ */
79
+ hrmp: Params['hrmp'];
80
+ /**
81
+ * The transactions to include in the block
82
+ */
83
+ transactions: Params['transactions'];
84
+ /**
85
+ * Build block using a specific block height (unsafe)
86
+ */
87
+ unsafeBlockHeight: Params['unsafeBlockHeight'];
88
+ }
89
+ /**
90
+ * Build new blocks.
91
+ *
92
+ * This function is a dev rpc handler. Use `dev_newBlock` as the method name when calling it.
93
+ *
94
+ * @param context - The context object of the rpc handler
95
+ * @param params - The parameters of the rpc handler
96
+ *
97
+ * @example Build 2 blocks
98
+ * ```ts
99
+ * import { WsProvider } from '@polkadot/rpc-provider'
100
+ * const ws = new WsProvider(`ws://localhost:8000`)
101
+ * await ws.send('dev_newBlock', [{ count: 2 }])
102
+ * ```
103
+ * @example Build a block with upward messages
104
+ * ```ts
105
+ * import { WsProvider } from '@polkadot/rpc-provider'
106
+ * const ws = new WsProvider(`ws://localhost:8000`)
107
+ * await ws.send('dev_newBlock', [
108
+ * {
109
+ * ump: {
110
+ * // https://acala.subscan.io/xcm_message/polkadot-ff66f28818d0b74573e62db8317e354b253fbc80
111
+ * 2000: [
112
+ * '0x021000040000000007903fc4db080a130000000007903fc4db08000d010004000101009c4b11a0974cba4a395c94832fba812868a6cb0ba09e8519b3521093ea359905',
113
+ * ],
114
+ * }
115
+ * }
116
+ * ])
117
+ * ```
118
+ *
119
+ * @example Build two blocks with unsafeBlockHeight
120
+ * ```ts
121
+ * import { WsProvider } from '@polkadot/rpc-provider'
122
+ * const ws = new WsProvider(`ws://localhost:8000`)
123
+ * // this will create two blocks with block height 100000001 and 100000002
124
+ * await ws.send('dev_newBlock', [{ count: 2, unsafeBlockHeight: 100000001 }])
125
+ * ```
126
+ */
127
+ export declare const rpc: (context: Context, [params]: [NewBlockParams]) => Promise<string | undefined>;
128
+ export {};