@acala-network/chopsticks 0.9.4-2 → 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 (87) hide show
  1. package/dist/esm/cli-options.d.ts +40 -0
  2. package/dist/esm/cli.d.ts +1 -0
  3. package/dist/esm/context.d.ts +7 -0
  4. package/dist/esm/index.d.ts +4 -0
  5. package/dist/esm/logger.d.ts +1 -0
  6. package/dist/esm/plugins/decode-key/cli.d.ts +2 -0
  7. package/dist/esm/plugins/decode-key/index.d.ts +1 -0
  8. package/dist/esm/plugins/dry-run/cli.d.ts +2 -0
  9. package/dist/esm/plugins/dry-run/dry-run-extrinsic.d.ts +2 -0
  10. package/dist/esm/plugins/dry-run/dry-run-preimage.d.ts +2 -0
  11. package/dist/esm/plugins/dry-run/index.d.ts +2 -0
  12. package/dist/esm/plugins/dry-run/rpc.d.ts +139 -0
  13. package/dist/esm/plugins/follow-chain/cli.d.ts +2 -0
  14. package/dist/esm/plugins/follow-chain/index.d.ts +1 -0
  15. package/dist/esm/plugins/index.d.ts +6 -0
  16. package/dist/esm/plugins/new-block/index.d.ts +1 -0
  17. package/dist/esm/plugins/new-block/rpc.d.ts +128 -0
  18. package/dist/esm/plugins/run-block/cli.d.ts +2 -0
  19. package/dist/esm/plugins/run-block/index.d.ts +2 -0
  20. package/dist/esm/plugins/run-block/rpc.d.ts +140 -0
  21. package/dist/esm/plugins/set-block-build-mode/index.d.ts +1 -0
  22. package/dist/esm/plugins/set-block-build-mode/rpc.d.ts +20 -0
  23. package/dist/esm/plugins/set-head/index.d.ts +1 -0
  24. package/dist/esm/plugins/set-head/rpc.d.ts +21 -0
  25. package/dist/esm/plugins/set-runtime-log-level/index.d.ts +1 -0
  26. package/dist/esm/plugins/set-runtime-log-level/rpc.d.ts +17 -0
  27. package/dist/esm/plugins/set-storage/index.d.ts +1 -0
  28. package/dist/esm/plugins/set-storage/rpc.d.ts +28 -0
  29. package/dist/esm/plugins/time-travel/index.d.ts +1 -0
  30. package/dist/esm/plugins/time-travel/rpc.d.ts +17 -0
  31. package/dist/esm/plugins/try-runtime/index.d.ts +2 -0
  32. package/dist/esm/plugins/types.d.ts +11 -0
  33. package/dist/esm/rpc/index.d.ts +5 -0
  34. package/dist/esm/schema/index.d.ts +140 -0
  35. package/dist/esm/server.d.ts +9 -0
  36. package/dist/esm/setup-with-server.d.ts +6 -0
  37. package/dist/esm/types.d.ts +15 -0
  38. package/dist/esm/utils/decoder.d.ts +7 -0
  39. package/dist/esm/utils/generate-html-diff.d.ts +4 -0
  40. package/dist/esm/utils/index.d.ts +4 -0
  41. package/dist/esm/utils/open-html.d.ts +1 -0
  42. package/dist/esm/utils/override.d.ts +4 -0
  43. package/dist/esm/utils/tunnel.d.ts +1 -0
  44. package/package.json +8 -17
  45. /package/dist/{types → cjs}/cli-options.d.ts +0 -0
  46. /package/dist/{types → cjs}/cli.d.ts +0 -0
  47. /package/dist/{types → cjs}/context.d.ts +0 -0
  48. /package/dist/{types → cjs}/index.d.ts +0 -0
  49. /package/dist/{types → cjs}/logger.d.ts +0 -0
  50. /package/dist/{types → cjs}/plugins/decode-key/cli.d.ts +0 -0
  51. /package/dist/{types → cjs}/plugins/decode-key/index.d.ts +0 -0
  52. /package/dist/{types → cjs}/plugins/dry-run/cli.d.ts +0 -0
  53. /package/dist/{types → cjs}/plugins/dry-run/dry-run-extrinsic.d.ts +0 -0
  54. /package/dist/{types → cjs}/plugins/dry-run/dry-run-preimage.d.ts +0 -0
  55. /package/dist/{types → cjs}/plugins/dry-run/index.d.ts +0 -0
  56. /package/dist/{types → cjs}/plugins/dry-run/rpc.d.ts +0 -0
  57. /package/dist/{types → cjs}/plugins/follow-chain/cli.d.ts +0 -0
  58. /package/dist/{types → cjs}/plugins/follow-chain/index.d.ts +0 -0
  59. /package/dist/{types → cjs}/plugins/index.d.ts +0 -0
  60. /package/dist/{types → cjs}/plugins/new-block/index.d.ts +0 -0
  61. /package/dist/{types → cjs}/plugins/new-block/rpc.d.ts +0 -0
  62. /package/dist/{types → cjs}/plugins/run-block/cli.d.ts +0 -0
  63. /package/dist/{types → cjs}/plugins/run-block/index.d.ts +0 -0
  64. /package/dist/{types → cjs}/plugins/run-block/rpc.d.ts +0 -0
  65. /package/dist/{types → cjs}/plugins/set-block-build-mode/index.d.ts +0 -0
  66. /package/dist/{types → cjs}/plugins/set-block-build-mode/rpc.d.ts +0 -0
  67. /package/dist/{types → cjs}/plugins/set-head/index.d.ts +0 -0
  68. /package/dist/{types → cjs}/plugins/set-head/rpc.d.ts +0 -0
  69. /package/dist/{types → cjs}/plugins/set-runtime-log-level/index.d.ts +0 -0
  70. /package/dist/{types → cjs}/plugins/set-runtime-log-level/rpc.d.ts +0 -0
  71. /package/dist/{types → cjs}/plugins/set-storage/index.d.ts +0 -0
  72. /package/dist/{types → cjs}/plugins/set-storage/rpc.d.ts +0 -0
  73. /package/dist/{types → cjs}/plugins/time-travel/index.d.ts +0 -0
  74. /package/dist/{types → cjs}/plugins/time-travel/rpc.d.ts +0 -0
  75. /package/dist/{types → cjs}/plugins/try-runtime/index.d.ts +0 -0
  76. /package/dist/{types → cjs}/plugins/types.d.ts +0 -0
  77. /package/dist/{types → cjs}/rpc/index.d.ts +0 -0
  78. /package/dist/{types → cjs}/schema/index.d.ts +0 -0
  79. /package/dist/{types → cjs}/server.d.ts +0 -0
  80. /package/dist/{types → cjs}/setup-with-server.d.ts +0 -0
  81. /package/dist/{types → cjs}/types.d.ts +0 -0
  82. /package/dist/{types → cjs}/utils/decoder.d.ts +0 -0
  83. /package/dist/{types → cjs}/utils/generate-html-diff.d.ts +0 -0
  84. /package/dist/{types → cjs}/utils/index.d.ts +0 -0
  85. /package/dist/{types → cjs}/utils/open-html.d.ts +0 -0
  86. /package/dist/{types → cjs}/utils/override.d.ts +0 -0
  87. /package/dist/{types → cjs}/utils/tunnel.d.ts +0 -0
@@ -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 {};
@@ -0,0 +1,2 @@
1
+ import type { Argv } from 'yargs';
2
+ export declare const cli: (y: Argv) => void;
@@ -0,0 +1,2 @@
1
+ export * from './cli.js';
2
+ export * from './rpc.js';
@@ -0,0 +1,140 @@
1
+ import { HexString } from '@polkadot/util/types';
2
+ import { z } from 'zod';
3
+ import { Context, RuntimeLog } from '@acala-network/chopsticks-core';
4
+ declare const schema: z.ZodObject<{
5
+ includeRaw: z.ZodOptional<z.ZodBoolean>;
6
+ includeParsed: z.ZodOptional<z.ZodBoolean>;
7
+ includeBlockDetails: z.ZodOptional<z.ZodBoolean>;
8
+ parent: z.ZodOptional<z.ZodIntersection<z.ZodString, z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>>>;
9
+ block: z.ZodObject<{
10
+ header: z.ZodAny;
11
+ extrinsics: z.ZodArray<z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, "many">;
12
+ }, "strip", z.ZodTypeAny, {
13
+ extrinsics: `0x${string}`[];
14
+ header?: any;
15
+ }, {
16
+ extrinsics: `0x${string}`[];
17
+ header?: any;
18
+ }>;
19
+ }, "strip", z.ZodTypeAny, {
20
+ block: {
21
+ extrinsics: `0x${string}`[];
22
+ header?: any;
23
+ };
24
+ includeRaw?: boolean | undefined;
25
+ includeParsed?: boolean | undefined;
26
+ includeBlockDetails?: boolean | undefined;
27
+ parent?: `0x${string}` | undefined;
28
+ }, {
29
+ block: {
30
+ extrinsics: `0x${string}`[];
31
+ header?: any;
32
+ };
33
+ includeRaw?: boolean | undefined;
34
+ includeParsed?: boolean | undefined;
35
+ includeBlockDetails?: boolean | undefined;
36
+ parent?: `0x${string}` | undefined;
37
+ }>;
38
+ type Params = z.infer<typeof schema>;
39
+ export interface RunBlockParams {
40
+ /**
41
+ * Include raw storage diff. Default to true
42
+ */
43
+ includeRaw: Params['includeRaw'];
44
+ /**
45
+ * Include parsed storage diff in json format
46
+ */
47
+ includeParsed: Params['includeParsed'];
48
+ /**
49
+ * Include block details such as parsed extrinsics in json format
50
+ */
51
+ includeBlockDetails: Params['includeBlockDetails'];
52
+ /**
53
+ * The parent block hash to run on top of. Default to chain head.
54
+ */
55
+ parent: Params['parent'];
56
+ /**
57
+ * Block to run
58
+ */
59
+ block: Params['block'];
60
+ }
61
+ /**
62
+ * The phase of an execution.
63
+ * `number` means the phase is ApplyExtrinsic and the value is the extrinsic index.
64
+ */
65
+ export type Phase = 'Initialization' | 'Finalization' | number;
66
+ export interface RunBlockResponse {
67
+ /**
68
+ * The storage diff of each phase.
69
+ */
70
+ phases: {
71
+ /**
72
+ * The phase of the execution. See {@link Phase}.
73
+ */
74
+ phase: Phase;
75
+ /**
76
+ * The modified storages of this phase.
77
+ */
78
+ storageDiff: {
79
+ /**
80
+ * Raw storage diff in bytes. Only available when `includeRaw` is true.
81
+ */
82
+ raw?: {
83
+ key: HexString;
84
+ value: HexString | null;
85
+ };
86
+ /**
87
+ * Decoded storage diff. Only available when `includeParsed` is true.
88
+ */
89
+ parsed?: {
90
+ method: string;
91
+ section: string;
92
+ key: any[];
93
+ value: any;
94
+ };
95
+ }[];
96
+ /**
97
+ * Runtime logs.
98
+ */
99
+ logs?: RuntimeLog[];
100
+ }[];
101
+ /**
102
+ * Block details. Only available when `includeBlockDetails` is true.
103
+ */
104
+ blockDetails?: {
105
+ /**
106
+ * Block timestamp in ms
107
+ */
108
+ timestamp?: string;
109
+ /**
110
+ * Parsed events in this block.
111
+ */
112
+ events?: {
113
+ phase: Phase;
114
+ section: string;
115
+ method: string;
116
+ args: any[];
117
+ }[];
118
+ /**
119
+ * Parsed extrinsics in this block.
120
+ */
121
+ extrinsics: {
122
+ section: string;
123
+ method: string;
124
+ args: any[];
125
+ success: boolean;
126
+ signer: string | null;
127
+ }[];
128
+ };
129
+ }
130
+ export declare const name = "runBlock";
131
+ /**
132
+ * Run a set of extrinsics on top of a block and get the storage diff
133
+ * and optionally the parsed storage diff and block details.
134
+ * NOTE: The extrinsics should include inherents or tranasctions may have unexpected results.
135
+ * NOTE: system.events and system.extrinsicData are excluded from storage diff to reduce size.
136
+ *
137
+ * This function is a dev rpc handler. Use `dev_runBlock` as the method name when calling it.
138
+ */
139
+ export declare const rpc: ({ chain }: Context, [params]: [RunBlockParams]) => Promise<RunBlockResponse>;
140
+ export {};
@@ -0,0 +1 @@
1
+ export * from './rpc.js';
@@ -0,0 +1,20 @@
1
+ import { BuildBlockMode, Context } from '@acala-network/chopsticks-core';
2
+ /**
3
+ * Set a build block mode. See [BuildBlockMode](../core/enums/BuildBlockMode).
4
+ *
5
+ * 1 - Batch, 2 - Instant, 3 - Manual
6
+ *
7
+ * This function is a dev rpc handler. Use `dev_setBlockBuildMode` as the method name when calling it.
8
+ *
9
+ * @param context - The context object of the rpc handler
10
+ * @param params - The parameters of the rpc handler
11
+ *
12
+ * @example Set build block mode to instant
13
+ * ```ts
14
+ * import { WsProvider } from '@polkadot/rpc-provider'
15
+ * import { BuildBlockMode } from '@acala-network/chopsticks-core'
16
+ * const ws = new WsProvider(`ws://localhost:8000`)
17
+ * await ws.send('dev_setBlockBuildMode', [BuildBlockMode.Instant])
18
+ * ```
19
+ */
20
+ export declare const rpc: (context: Context, [mode]: [BuildBlockMode]) => Promise<void>;
@@ -0,0 +1 @@
1
+ export * from './rpc.js';
@@ -0,0 +1,21 @@
1
+ import { Context } from '@acala-network/chopsticks-core';
2
+ import { z } from 'zod';
3
+ declare const schema: z.ZodUnion<[z.ZodIntersection<z.ZodString, z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>>, z.ZodNumber]>;
4
+ type Params = z.infer<typeof schema>;
5
+ /**
6
+ * Set head.
7
+ *
8
+ * This function is a dev rpc handler. Use `dev_setHead` as the method name when calling it.
9
+ *
10
+ * @param context - The context object of the rpc handler
11
+ * @param hashOrNumber - The block hash or number to set as head
12
+ *
13
+ * @example Set head to block 1000000
14
+ * ```ts
15
+ * import { WsProvider } from '@polkadot/rpc-provider'
16
+ * const ws = new WsProvider(`ws://localhost:8000`)
17
+ * await ws.send('dev_setHead', [1000000])
18
+ * ```
19
+ */
20
+ export declare const rpc: (context: Context, [params]: [Params]) => Promise<`0x${string}`>;
21
+ export {};
@@ -0,0 +1 @@
1
+ export * from './rpc.js';
@@ -0,0 +1,17 @@
1
+ import { Context } from '@acala-network/chopsticks-core';
2
+ /**
3
+ * Set runtime log level.
4
+ *
5
+ * This function is a dev rpc handler. Use `dev_setRuntimeLogLevel` as the method name when calling it.
6
+ *
7
+ * @param context - The context object of the rpc handler
8
+ * @param runtimeLogLevel - The runtime log level to set
9
+ *
10
+ * @example Set runtime log level to 1
11
+ * ```ts
12
+ * import { WsProvider } from '@polkadot/rpc-provider'
13
+ * const ws = new WsProvider(`ws://localhost:8000`)
14
+ * await ws.send('dev_setRuntimeLogLevel', [1])
15
+ * ```
16
+ */
17
+ export declare const rpc: (context: Context, [runtimeLogLevel]: [number]) => Promise<void>;
@@ -0,0 +1 @@
1
+ export * from './rpc.js';
@@ -0,0 +1,28 @@
1
+ import { Context, StorageValues } from '@acala-network/chopsticks-core';
2
+ import { HexString } from '@polkadot/util/types';
3
+ /**
4
+ * Set storage values.
5
+ *
6
+ * This function is a dev rpc handler. Use `dev_setStorage` as the method name when calling it.
7
+ *
8
+ * @param context - The context object of the rpc handler
9
+ * @param params - The parameters of the rpc handler
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * import { WsProvider } from '@polkadot/rpc-provider'
14
+ * import { Keyring } from '@polkadot/keyring'
15
+ *
16
+ * const ws = new WsProvider(`ws://localhost:8000`)
17
+ * const keyring = new Keyring({ type: 'ed25519' })
18
+ * const bob = keyring.addFromUri('//Bob')
19
+ *
20
+ * const storage = {
21
+ * System: {
22
+ * Account: [[[bob.address], { data: { free: 100000 }, nonce: 1 }]],
23
+ * },
24
+ * }
25
+ * await ws.send('dev_setStorage', [storage])
26
+ * ```
27
+ */
28
+ export declare const rpc: (context: Context, params: [StorageValues, HexString?]) => Promise<`0x${string}`>;
@@ -0,0 +1 @@
1
+ export * from './rpc.js';
@@ -0,0 +1,17 @@
1
+ import { Context } from '@acala-network/chopsticks-core';
2
+ /**
3
+ * Travel to a specific time.
4
+ *
5
+ * This function is a dev rpc handler. Use `dev_timeTravel` as the method name when calling it.
6
+ *
7
+ * @param context - The context object of the rpc handler
8
+ * @param date - Timestamp or date string to set
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * import { WsProvider } from '@polkadot/rpc-provider'
13
+ * const ws = new WsProvider(`ws://localhost:8000`)
14
+ * await ws.send('dev_timeTravel', ['Jan 1, 2023'])
15
+ * ```
16
+ */
17
+ export declare const rpc: (context: Context, [date]: [string | number]) => Promise<number>;
@@ -0,0 +1,2 @@
1
+ import type { Argv } from 'yargs';
2
+ export declare const cli: (y: Argv) => void;
@@ -0,0 +1,11 @@
1
+ export { rpc as newBlock } from './new-block/index.js';
2
+ export { rpc as dryRun } from './dry-run/index.js';
3
+ export { rpc as setBlockBuildMode } from './set-block-build-mode/index.js';
4
+ export { rpc as setHead } from './set-head/index.js';
5
+ export { rpc as setRuntimeLogLevel } from './set-runtime-log-level/index.js';
6
+ export { rpc as setStorage } from './set-storage/index.js';
7
+ export { rpc as timeTravel } from './time-travel/index.js';
8
+ export { rpc as runBlock } from './run-block/index.js';
9
+ export type { NewBlockParams } from './new-block/index.js';
10
+ export type { DryRunParams } from './dry-run/index.js';
11
+ export type { RunBlockParams } from './run-block/index.js';
@@ -0,0 +1,5 @@
1
+ import { Context, SubscriptionManager } from '@acala-network/chopsticks-core';
2
+ export declare const handler: (context: Context) => ({ method, params }: {
3
+ method: string;
4
+ params: any[];
5
+ }, subscriptionManager: SubscriptionManager) => Promise<any>;
@@ -0,0 +1,140 @@
1
+ import { BuildBlockMode } from '@acala-network/chopsticks-core';
2
+ import { z } from 'zod';
3
+ export declare const zHex: z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>;
4
+ export declare const zHash: z.ZodIntersection<z.ZodString, z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>>;
5
+ export declare const configSchema: z.ZodObject<{
6
+ port: z.ZodOptional<z.ZodNumber>;
7
+ endpoint: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
8
+ block: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodNull]>>;
9
+ 'build-block-mode': z.ZodOptional<z.ZodNativeEnum<typeof BuildBlockMode>>;
10
+ 'import-storage': z.ZodOptional<z.ZodAny>;
11
+ 'mock-signature-host': z.ZodOptional<z.ZodBoolean>;
12
+ 'max-memory-block-count': z.ZodOptional<z.ZodNumber>;
13
+ db: z.ZodOptional<z.ZodString>;
14
+ 'wasm-override': z.ZodOptional<z.ZodString>;
15
+ genesis: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodObject<{
16
+ id: z.ZodString;
17
+ name: z.ZodString;
18
+ properties: z.ZodObject<{
19
+ ss58Format: z.ZodOptional<z.ZodNumber>;
20
+ tokenDecimals: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodArray<z.ZodNumber, "many">]>>;
21
+ tokenSymbol: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
22
+ }, "strip", z.ZodTypeAny, {
23
+ ss58Format?: number | undefined;
24
+ tokenDecimals?: number | number[] | undefined;
25
+ tokenSymbol?: string | string[] | undefined;
26
+ }, {
27
+ ss58Format?: number | undefined;
28
+ tokenDecimals?: number | number[] | undefined;
29
+ tokenSymbol?: string | string[] | undefined;
30
+ }>;
31
+ genesis: z.ZodObject<{
32
+ raw: z.ZodObject<{
33
+ top: z.ZodRecord<z.ZodString, z.ZodString>;
34
+ }, "strip", z.ZodTypeAny, {
35
+ top: Record<string, string>;
36
+ }, {
37
+ top: Record<string, string>;
38
+ }>;
39
+ }, "strip", z.ZodTypeAny, {
40
+ raw: {
41
+ top: Record<string, string>;
42
+ };
43
+ }, {
44
+ raw: {
45
+ top: Record<string, string>;
46
+ };
47
+ }>;
48
+ }, "strip", z.ZodTypeAny, {
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
+ }, {
62
+ name: string;
63
+ id: string;
64
+ properties: {
65
+ ss58Format?: number | undefined;
66
+ tokenDecimals?: number | number[] | undefined;
67
+ tokenSymbol?: string | string[] | undefined;
68
+ };
69
+ genesis: {
70
+ raw: {
71
+ top: Record<string, string>;
72
+ };
73
+ };
74
+ }>]>>;
75
+ timestamp: z.ZodOptional<z.ZodNumber>;
76
+ 'registered-types': z.ZodOptional<z.ZodAny>;
77
+ 'runtime-log-level': z.ZodOptional<z.ZodNumber>;
78
+ 'offchain-worker': z.ZodOptional<z.ZodBoolean>;
79
+ resume: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
80
+ }, "strict", z.ZodTypeAny, {
81
+ port?: number | undefined;
82
+ endpoint?: string | string[] | undefined;
83
+ block?: string | number | null | undefined;
84
+ 'build-block-mode'?: BuildBlockMode | undefined;
85
+ 'import-storage'?: any;
86
+ 'mock-signature-host'?: boolean | undefined;
87
+ 'max-memory-block-count'?: number | undefined;
88
+ db?: string | undefined;
89
+ 'wasm-override'?: string | undefined;
90
+ genesis?: string | {
91
+ name: string;
92
+ id: string;
93
+ properties: {
94
+ ss58Format?: number | undefined;
95
+ tokenDecimals?: number | number[] | undefined;
96
+ tokenSymbol?: string | string[] | undefined;
97
+ };
98
+ genesis: {
99
+ raw: {
100
+ top: Record<string, string>;
101
+ };
102
+ };
103
+ } | undefined;
104
+ timestamp?: number | undefined;
105
+ 'registered-types'?: any;
106
+ 'runtime-log-level'?: number | undefined;
107
+ 'offchain-worker'?: boolean | undefined;
108
+ resume?: string | number | boolean | undefined;
109
+ }, {
110
+ port?: number | undefined;
111
+ endpoint?: string | string[] | undefined;
112
+ block?: string | number | null | undefined;
113
+ 'build-block-mode'?: BuildBlockMode | undefined;
114
+ 'import-storage'?: any;
115
+ 'mock-signature-host'?: boolean | undefined;
116
+ 'max-memory-block-count'?: number | undefined;
117
+ db?: string | undefined;
118
+ 'wasm-override'?: string | undefined;
119
+ genesis?: string | {
120
+ name: string;
121
+ id: string;
122
+ properties: {
123
+ ss58Format?: number | undefined;
124
+ tokenDecimals?: number | number[] | undefined;
125
+ tokenSymbol?: string | string[] | undefined;
126
+ };
127
+ genesis: {
128
+ raw: {
129
+ top: Record<string, string>;
130
+ };
131
+ };
132
+ } | undefined;
133
+ timestamp?: number | undefined;
134
+ 'registered-types'?: any;
135
+ 'runtime-log-level'?: number | undefined;
136
+ 'offchain-worker'?: boolean | undefined;
137
+ resume?: string | number | boolean | undefined;
138
+ }>;
139
+ export type Config = z.infer<typeof configSchema>;
140
+ export declare const fetchConfig: (path: string) => Promise<Config>;
@@ -0,0 +1,9 @@
1
+ import { SubscriptionManager } from '@acala-network/chopsticks-core';
2
+ export type Handler = (data: {
3
+ method: string;
4
+ params: string[];
5
+ }, subscriptionManager: SubscriptionManager) => Promise<any>;
6
+ export declare const createServer: (handler: Handler, port?: number) => Promise<{
7
+ port: number;
8
+ close: () => Promise<void>;
9
+ }>;
@@ -0,0 +1,6 @@
1
+ import { Config } from './schema/index.js';
2
+ export declare const setupWithServer: (argv: Config) => Promise<{
3
+ listenPort: number;
4
+ close(): Promise<void>;
5
+ chain: import("@acala-network/chopsticks-core").Blockchain;
6
+ }>;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Chopsticks JSON RPC and CLI.
3
+ *
4
+ * @remarks
5
+ * This package extends the `@acala-network/chopsticks-core` package a with JSON RPC server and CLI support.
6
+ *
7
+ * @privateRemarks
8
+ * Above is the package documentation for 'chopsticks' package.
9
+ * `export` below is for tsdoc.
10
+ *
11
+ * @packageDocumentation
12
+ */
13
+ export type { ChainProperties, RuntimeVersion, Context, SubscriptionManager, Handler, } from '@acala-network/chopsticks-core';
14
+ export * from '@acala-network/chopsticks-core/rpc/substrate/index.js';
15
+ export * from './plugins/types.js';
@@ -0,0 +1,7 @@
1
+ import { Block } from '@acala-network/chopsticks-core';
2
+ import { HexString } from '@polkadot/util/types';
3
+ export declare const decodeStorageDiff: (block: Block, diff: [HexString, HexString | null][]) => Promise<{
4
+ oldState: {};
5
+ newState: {};
6
+ delta: import("jsondiffpatch").Delta | undefined;
7
+ }>;
@@ -0,0 +1,4 @@
1
+ import { Block } from '@acala-network/chopsticks-core';
2
+ import { HexString } from '@polkadot/util/types';
3
+ export declare const generateHtmlDiff: (block: Block, diff: [HexString, HexString | null][]) => Promise<string>;
4
+ export declare const generateHtmlDiffPreviewFile: (block: Block, diff: [HexString, HexString | null][], filename: string) => Promise<string>;
@@ -0,0 +1,4 @@
1
+ export * from './decoder.js';
2
+ export * from './generate-html-diff.js';
3
+ export * from './open-html.js';
4
+ export * from './override.js';
@@ -0,0 +1 @@
1
+ export declare const openHtml: (filePath: string) => void;
@@ -0,0 +1,4 @@
1
+ import { Blockchain, StorageValues } from '@acala-network/chopsticks-core';
2
+ import { HexString } from '@polkadot/util/types';
3
+ export declare const overrideStorage: (chain: Blockchain, storage?: string | StorageValues, at?: HexString) => Promise<void>;
4
+ export declare const overrideWasm: (chain: Blockchain, wasmPath?: string, at?: HexString) => Promise<void>;
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,21 +1,20 @@
1
1
  {
2
2
  "name": "@acala-network/chopsticks",
3
- "version": "0.9.4-2",
3
+ "version": "0.9.4-3",
4
4
  "author": "Acala Developers <hello@acala.network>",
5
5
  "license": "Apache-2.0",
6
6
  "bin": "./chopsticks.cjs",
7
7
  "type": "module",
8
8
  "scripts": {
9
- "clean": "rm -rf dist",
10
- "build": "yarn clean && yarn build:cjs && yarn build:esm && yarn build:types",
11
- "build:cjs": "swc ./src --config-file ../../.cjsswcrc -d dist/cjs --copy-files && echo '{\"type\": \"commonjs\"}' > dist/cjs/package.json",
12
- "build:esm": "swc ./src --config-file ../../.esmswcrc -d dist/esm --copy-files",
13
- "build:types": "tsc -p tsconfig.json --emitDeclarationOnly --outDir dist/types",
9
+ "clean": "rm -rf dist tsconfig.tsbuildinfo",
10
+ "build": "yarn clean && yarn build:cjs && yarn build:esm",
11
+ "build:cjs": "swc ./src --config-file ../../.cjsswcrc -d dist/cjs --copy-files && tsc -p tsconfig.json --declarationDir dist/cjs && echo '{\"type\": \"commonjs\"}' > dist/cjs/package.json",
12
+ "build:esm": "swc ./src --config-file ../../.esmswcrc -d dist/esm --copy-files && tsc -p tsconfig.json --declarationDir dist/esm",
14
13
  "docs:prep": "typedoc"
15
14
  },
16
15
  "dependencies": {
17
- "@acala-network/chopsticks-core": "0.9.4-2",
18
- "@acala-network/chopsticks-db": "0.9.4-2",
16
+ "@acala-network/chopsticks-core": "0.9.4-3",
17
+ "@acala-network/chopsticks-db": "0.9.4-3",
19
18
  "@pnpm/npm-conf": "^2.2.2",
20
19
  "@polkadot/api-augment": "^10.10.1",
21
20
  "@polkadot/types": "^10.10.1",
@@ -46,38 +45,30 @@
46
45
  "files": [
47
46
  "dist/esm/**",
48
47
  "dist/cjs/**",
49
- "dist/types/**",
50
48
  "chopsticks.cjs"
51
49
  ],
52
50
  "main": "./dist/cjs/index.js",
53
51
  "module": "./dist/esm/index.js",
54
- "types": "./dist/types/index.d.ts",
55
52
  "exports": {
56
53
  ".": {
57
- "types": "./dist/types/index.d.ts",
58
54
  "require": "./dist/cjs/index.js",
59
55
  "import": "./dist/esm/index.js",
60
56
  "default": "./dist/esm/index.js"
61
57
  },
62
58
  "./*": {
63
- "types": "./dist/types/*.d.ts",
64
59
  "require": "./dist/cjs/*.js",
65
60
  "import": "./dist/esm/*.js",
66
61
  "default": "./dist/esm/*.js"
67
62
  },
68
63
  "./plugins/*": {
69
- "types": "./dist/types/plugins/*.d.ts",
70
64
  "require": "./dist/cjs/plugins/*.js",
71
65
  "import": "./dist/esm/plugins/*.js",
72
66
  "default": "./dist/esm/plugins/*.js"
73
67
  },
74
68
  "./utils/*": {
75
- "types": "./dist/types/utils/*.d.ts",
76
69
  "require": "./dist/cjs/utils/*.js",
77
70
  "import": "./dist/esm/utils/*.js",
78
71
  "default": "./dist/esm/utils/*.js"
79
- },
80
- "./package.json": "./package.json",
81
- "./package.cjs.json": "./dist/cjs/package.json"
72
+ }
82
73
  }
83
74
  }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes