@acala-network/chopsticks 0.9.6-1 → 0.9.6-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.
- package/dist/cjs/plugins/dry-run/cli.js +1 -1
- package/dist/cjs/plugins/dry-run/dry-run-extrinsic.js +3 -0
- package/dist/cjs/plugins/dry-run/index.d.ts +3 -3
- package/dist/cjs/plugins/dry-run/index.js +1 -1
- package/dist/cjs/plugins/run-block/__snapshots__/index.test.ts.snap +2872 -162
- package/dist/cjs/plugins/run-block/rpc.d.ts +2 -0
- package/dist/cjs/plugins/run-block/rpc.js +15 -3
- package/dist/cjs/schema/index.js +3 -1
- package/dist/cjs/setup-with-server.js +0 -4
- package/dist/esm/plugins/dry-run/cli.js +1 -1
- package/dist/esm/plugins/dry-run/dry-run-extrinsic.js +3 -0
- package/dist/esm/plugins/dry-run/index.d.ts +3 -3
- package/dist/esm/plugins/dry-run/index.js +1 -1
- package/dist/esm/plugins/run-block/__snapshots__/index.test.ts.snap +2872 -162
- package/dist/esm/plugins/run-block/rpc.d.ts +2 -0
- package/dist/esm/plugins/run-block/rpc.js +15 -3
- package/dist/esm/schema/index.js +3 -1
- package/dist/esm/setup-with-server.js +0 -4
- package/package.json +3 -3
|
@@ -114,6 +114,7 @@ export interface RunBlockResponse {
|
|
|
114
114
|
section: string;
|
|
115
115
|
method: string;
|
|
116
116
|
args: any[];
|
|
117
|
+
argObj: Record<string, any>;
|
|
117
118
|
}[];
|
|
118
119
|
/**
|
|
119
120
|
* Parsed extrinsics in this block.
|
|
@@ -122,6 +123,7 @@ export interface RunBlockResponse {
|
|
|
122
123
|
section: string;
|
|
123
124
|
method: string;
|
|
124
125
|
args: any[];
|
|
126
|
+
argObj: Record<string, any>;
|
|
125
127
|
success: boolean;
|
|
126
128
|
signer: string | null;
|
|
127
129
|
}[];
|
|
@@ -139,12 +139,20 @@ const rpc = async ({ chain }, [params])=>{
|
|
|
139
139
|
const registry = await newBlock.registry;
|
|
140
140
|
const timestamp = await newBlock.read('u64', meta.query.timestamp.now);
|
|
141
141
|
const events = await newBlock.read('Vec<EventRecord>', meta.query.system.events);
|
|
142
|
-
const parsedEvents = events?.map((event)=>
|
|
142
|
+
const parsedEvents = events?.map((event)=>{
|
|
143
|
+
const argObj = {};
|
|
144
|
+
const len = event.event.data.names?.length ?? 0;
|
|
145
|
+
for(let i = 0; i < len; i++){
|
|
146
|
+
argObj[event.event.data.names[i]] = event.event.data[i].toJSON();
|
|
147
|
+
}
|
|
148
|
+
return {
|
|
143
149
|
phase: event.phase.isApplyExtrinsic ? event.phase.asApplyExtrinsic.toNumber() : event.phase.toString(),
|
|
144
150
|
section: event.event.section,
|
|
145
151
|
method: event.event.method,
|
|
146
|
-
args: event.event.data.map((arg)=>arg.toJSON())
|
|
147
|
-
|
|
152
|
+
args: event.event.data.map((arg)=>arg.toJSON()),
|
|
153
|
+
argObj
|
|
154
|
+
};
|
|
155
|
+
});
|
|
148
156
|
const extrinsics = block.extrinsics.map((extrinsic, idx)=>{
|
|
149
157
|
const parsed = registry.createType('GenericExtrinsic', extrinsic);
|
|
150
158
|
const resultEvent = events?.find(({ event, phase })=>event.section === 'system' && (event.method === 'ExtrinsicSuccess' || event.method === 'ExtrinsicFailed') && phase.isApplyExtrinsic && phase.asApplyExtrinsic.eq(idx));
|
|
@@ -153,6 +161,10 @@ const rpc = async ({ chain }, [params])=>{
|
|
|
153
161
|
section: parsed.method.section,
|
|
154
162
|
method: parsed.method.method,
|
|
155
163
|
args: parsed.method.args.map((arg)=>arg.toJSON()),
|
|
164
|
+
argObj: parsed.method?.argsEntries ? Object.fromEntries(parsed.method.argsEntries.map(([key, value])=>[
|
|
165
|
+
key,
|
|
166
|
+
value.toJSON()
|
|
167
|
+
])) : {},
|
|
156
168
|
success: resultEvent?.event.method === 'ExtrinsicSuccess',
|
|
157
169
|
signer
|
|
158
170
|
};
|
package/dist/cjs/schema/index.js
CHANGED
|
@@ -74,7 +74,9 @@ const configSchema = _zod.z.object({
|
|
|
74
74
|
genesis: _zod.z.union([
|
|
75
75
|
_zod.z.string(),
|
|
76
76
|
_chopstickscore.genesisSchema
|
|
77
|
-
]
|
|
77
|
+
], {
|
|
78
|
+
description: 'URL to genesis config file. NOTE: Only parachains with AURA consensus are supported!'
|
|
79
|
+
}).optional(),
|
|
78
80
|
timestamp: _zod.z.number().optional(),
|
|
79
81
|
'registered-types': _zod.z.any().optional(),
|
|
80
82
|
'runtime-log-level': _zod.z.number({
|
|
@@ -14,10 +14,6 @@ const _index = require("./rpc/index.js");
|
|
|
14
14
|
const _context = require("./context.js");
|
|
15
15
|
const setupWithServer = async (argv)=>{
|
|
16
16
|
const context = await (0, _context.setupContext)(argv);
|
|
17
|
-
if (argv.genesis) {
|
|
18
|
-
// mine 1st block when starting from genesis to set some mock validation data
|
|
19
|
-
await context.chain.newBlock();
|
|
20
|
-
}
|
|
21
17
|
const { close, port: listenPort } = await (0, _server.createServer)((0, _index.handler)(context), argv.port);
|
|
22
18
|
_chopstickscore.defaultLogger.info(`${await context.chain.api.getSystemChain()} RPC listening on port ${listenPort}`);
|
|
23
19
|
return {
|
|
@@ -6,7 +6,7 @@ const schema = z.object({
|
|
|
6
6
|
...configSchema.shape,
|
|
7
7
|
extrinsic: z.string({
|
|
8
8
|
description: 'Extrinsic or call to dry run. If you pass call here then address is required to fake signature'
|
|
9
|
-
}),
|
|
9
|
+
}).optional(),
|
|
10
10
|
address: z.string({
|
|
11
11
|
description: 'Address to fake sign extrinsic'
|
|
12
12
|
}).optional(),
|
|
@@ -6,6 +6,9 @@ import { openHtml } from '../../utils/open-html.js';
|
|
|
6
6
|
import { setupContext } from '../../context.js';
|
|
7
7
|
export const dryRunExtrinsic = async (argv)=>{
|
|
8
8
|
const context = await setupContext(argv);
|
|
9
|
+
if (!argv.extrinsic) {
|
|
10
|
+
throw new Error('Extrinsic is required');
|
|
11
|
+
}
|
|
9
12
|
const input = argv['address'] ? {
|
|
10
13
|
call: argv['extrinsic'],
|
|
11
14
|
address: argv['address']
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
export declare const dryRunSchema: z.ZodObject<{
|
|
3
|
-
extrinsic: z.ZodString
|
|
3
|
+
extrinsic: z.ZodOptional<z.ZodString>;
|
|
4
4
|
address: z.ZodOptional<z.ZodString>;
|
|
5
5
|
preimage: z.ZodOptional<z.ZodString>;
|
|
6
6
|
at: z.ZodOptional<z.ZodString>;
|
|
@@ -85,7 +85,7 @@ export declare const dryRunSchema: z.ZodObject<{
|
|
|
85
85
|
}, "strip", z.ZodTypeAny, {
|
|
86
86
|
port: number;
|
|
87
87
|
'build-block-mode': import("@acala-network/chopsticks-core").BuildBlockMode;
|
|
88
|
-
extrinsic
|
|
88
|
+
extrinsic?: string | undefined;
|
|
89
89
|
address?: string | undefined;
|
|
90
90
|
preimage?: string | undefined;
|
|
91
91
|
at?: string | undefined;
|
|
@@ -120,7 +120,7 @@ export declare const dryRunSchema: z.ZodObject<{
|
|
|
120
120
|
'offchain-worker'?: boolean | undefined;
|
|
121
121
|
resume?: number | boolean | `0x${string}` | undefined;
|
|
122
122
|
}, {
|
|
123
|
-
extrinsic
|
|
123
|
+
extrinsic?: string | undefined;
|
|
124
124
|
address?: string | undefined;
|
|
125
125
|
preimage?: string | undefined;
|
|
126
126
|
at?: string | undefined;
|
|
@@ -4,7 +4,7 @@ export const dryRunSchema = z.object({
|
|
|
4
4
|
...configSchema.shape,
|
|
5
5
|
extrinsic: z.string({
|
|
6
6
|
description: 'Extrinsic or call to dry run. If you pass call here then address is required to fake signature'
|
|
7
|
-
}),
|
|
7
|
+
}).optional(),
|
|
8
8
|
address: z.string({
|
|
9
9
|
description: 'Address to fake sign extrinsic'
|
|
10
10
|
}).optional(),
|