@0xobelisk/sui-cli 1.2.0-pre.12 → 1.2.0-pre.120
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/README.md +7 -7
- package/dist/dubhe.js +152 -51
- package/dist/dubhe.js.map +1 -1
- package/package.json +31 -19
- package/src/commands/build.ts +61 -18
- package/src/commands/call.ts +83 -83
- package/src/commands/checkBalance.ts +27 -12
- package/src/commands/convertJson.ts +84 -0
- package/src/commands/doctor.ts +1515 -0
- package/src/commands/faucet.ts +20 -10
- package/src/commands/generate.ts +61 -0
- package/src/commands/generateKey.ts +3 -2
- package/src/commands/index.ts +20 -11
- package/src/commands/info.ts +61 -0
- package/src/commands/loadMetadata.ts +68 -0
- package/src/commands/localnode.ts +22 -6
- package/src/commands/publish.ts +55 -7
- package/src/commands/query.ts +101 -101
- package/src/commands/shell.ts +208 -0
- package/src/commands/{configStore.ts → storeConfig.ts} +13 -5
- package/src/commands/switchEnv.ts +33 -0
- package/src/commands/test.ts +143 -31
- package/src/commands/upgrade.ts +46 -6
- package/src/commands/wait.ts +333 -22
- package/src/commands/watch.ts +9 -8
- package/src/dubhe.ts +12 -4
- package/src/utils/axios-downloader.ts +116 -0
- package/src/utils/callHandler.ts +118 -118
- package/src/utils/checkBalance.ts +6 -2
- package/src/utils/constants.ts +9 -0
- package/src/utils/generateAccount.ts +1 -1
- package/src/utils/index.ts +4 -3
- package/src/utils/metadataHandler.ts +17 -0
- package/src/utils/publishHandler.ts +404 -289
- package/src/utils/queryStorage.ts +141 -141
- package/src/utils/startNode.ts +115 -16
- package/src/utils/storeConfig.ts +50 -10
- package/src/utils/upgradeHandler.ts +210 -86
- package/src/utils/utils.ts +1025 -63
- package/src/commands/schemagen.ts +0 -40
package/src/commands/query.ts
CHANGED
|
@@ -1,108 +1,108 @@
|
|
|
1
|
-
import type { CommandModule } from 'yargs';
|
|
2
|
-
import { logError } from '../utils/errors';
|
|
3
|
-
import { queryStorage } from '../utils';
|
|
4
|
-
import { loadConfig, DubheConfig } from '@0xobelisk/sui-common';
|
|
1
|
+
// import type { CommandModule } from 'yargs';
|
|
2
|
+
// import { logError } from '../utils/errors';
|
|
3
|
+
// import { queryStorage } from '../utils';
|
|
4
|
+
// import { loadConfig, DubheConfig } from '@0xobelisk/sui-common';
|
|
5
5
|
|
|
6
|
-
type Options = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
};
|
|
6
|
+
// type Options = {
|
|
7
|
+
// network: 'mainnet' | 'testnet' | 'devnet' | 'localnet';
|
|
8
|
+
// 'config-path'?: string;
|
|
9
|
+
// schema: string;
|
|
10
|
+
// 'object-id'?: string;
|
|
11
|
+
// 'package-id'?: string;
|
|
12
|
+
// 'metadata-path'?: string;
|
|
13
|
+
// params?: any[];
|
|
14
|
+
// };
|
|
15
15
|
|
|
16
|
-
/**
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const commandModule: CommandModule<Options, Options> = {
|
|
39
|
-
|
|
16
|
+
// /**
|
|
17
|
+
// * CLI command module for querying schema struct state
|
|
18
|
+
// *
|
|
19
|
+
// * Examples:
|
|
20
|
+
// *
|
|
21
|
+
// * 1. Query StorageValue (no params required):
|
|
22
|
+
// * ```bash
|
|
23
|
+
// * dubhe query --config-path dubhe.config.ts --network devnet --schema counter --field value
|
|
24
|
+
// * ```
|
|
25
|
+
// *
|
|
26
|
+
// * 2. Query StorageMap (one param required):
|
|
27
|
+
// * ```bash
|
|
28
|
+
// * dubhe query --config-path dubhe.config.ts --network devnet --schema token --field balances \
|
|
29
|
+
// * --params "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"
|
|
30
|
+
// * ```
|
|
31
|
+
// *
|
|
32
|
+
// * 3. Query StorageDoubleMap (two params required):
|
|
33
|
+
// * ```bash
|
|
34
|
+
// * dubhe query --config-path dubhe.config.ts --network devnet --schema game --field player_relations \
|
|
35
|
+
// * --params "0x123...456" "0x789...abc"
|
|
36
|
+
// * ```
|
|
37
|
+
// */
|
|
38
|
+
// const commandModule: CommandModule<Options, Options> = {
|
|
39
|
+
// command: 'query',
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
// describe: 'Query dubhe schema struct state',
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
43
|
+
// builder: {
|
|
44
|
+
// network: {
|
|
45
|
+
// type: 'string',
|
|
46
|
+
// choices: ['mainnet', 'testnet', 'devnet', 'localnet'],
|
|
47
|
+
// default: 'localnet',
|
|
48
|
+
// desc: 'Node network (mainnet/testnet/devnet/localnet)'
|
|
49
|
+
// },
|
|
50
|
+
// 'config-path': {
|
|
51
|
+
// type: 'string',
|
|
52
|
+
// default: 'dubhe.config.ts',
|
|
53
|
+
// desc: 'Configuration file path'
|
|
54
|
+
// },
|
|
55
|
+
// schema: {
|
|
56
|
+
// type: 'string',
|
|
57
|
+
// desc: 'Schema name',
|
|
58
|
+
// demandOption: true
|
|
59
|
+
// },
|
|
60
|
+
// 'object-id': {
|
|
61
|
+
// type: 'string',
|
|
62
|
+
// desc: 'Object ID (optional)'
|
|
63
|
+
// },
|
|
64
|
+
// 'package-id': {
|
|
65
|
+
// type: 'string',
|
|
66
|
+
// desc: 'Package ID (optional)'
|
|
67
|
+
// },
|
|
68
|
+
// 'metadata-path': {
|
|
69
|
+
// type: 'string',
|
|
70
|
+
// desc: 'Path to metadata JSON file (optional)'
|
|
71
|
+
// },
|
|
72
|
+
// params: {
|
|
73
|
+
// type: 'array',
|
|
74
|
+
// desc: 'Params for storage type: StorageValue(no params), StorageMap(1 param), StorageDoubleMap(2 params)',
|
|
75
|
+
// string: true
|
|
76
|
+
// }
|
|
77
|
+
// },
|
|
78
78
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
79
|
+
// async handler({
|
|
80
|
+
// network,
|
|
81
|
+
// 'config-path': configPath,
|
|
82
|
+
// schema,
|
|
83
|
+
// 'object-id': objectId,
|
|
84
|
+
// 'package-id': packageId,
|
|
85
|
+
// 'metadata-path': metadataPath,
|
|
86
|
+
// params
|
|
87
|
+
// }) {
|
|
88
|
+
// try {
|
|
89
|
+
// const dubheConfig = (await loadConfig(configPath)) as DubheConfig;
|
|
90
90
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
};
|
|
91
|
+
// await queryStorage({
|
|
92
|
+
// dubheConfig,
|
|
93
|
+
// schema,
|
|
94
|
+
// objectId,
|
|
95
|
+
// network,
|
|
96
|
+
// packageId,
|
|
97
|
+
// metadataFilePath: metadataPath,
|
|
98
|
+
// params
|
|
99
|
+
// });
|
|
100
|
+
// } catch (error: any) {
|
|
101
|
+
// logError(error);
|
|
102
|
+
// process.exit(1);
|
|
103
|
+
// }
|
|
104
|
+
// process.exit(0);
|
|
105
|
+
// }
|
|
106
|
+
// };
|
|
107
107
|
|
|
108
|
-
export default commandModule;
|
|
108
|
+
// export default commandModule;
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import readline from 'readline';
|
|
2
|
+
|
|
3
|
+
import yargs, { CommandModule } from 'yargs';
|
|
4
|
+
import { commands } from '.';
|
|
5
|
+
import chalk from 'chalk';
|
|
6
|
+
import { getDefaultNetwork, printDubhe } from '../utils';
|
|
7
|
+
import dotenv from 'dotenv';
|
|
8
|
+
import { spawn } from 'child_process';
|
|
9
|
+
|
|
10
|
+
dotenv.config();
|
|
11
|
+
|
|
12
|
+
let shouldHandlerExit = true;
|
|
13
|
+
|
|
14
|
+
// Blacklist of commands not available inside shell
|
|
15
|
+
const SHELL_BLACKLIST_COMMANDS = ['shell', 'wait'];
|
|
16
|
+
|
|
17
|
+
export const handlerExit = (status: number = 0) => {
|
|
18
|
+
if (shouldHandlerExit) process.exit(status);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
type Options = {
|
|
22
|
+
network: any;
|
|
23
|
+
'rpc-url'?: string;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const parseCommandNames = () => {
|
|
27
|
+
return commands
|
|
28
|
+
.filter((command) => !SHELL_BLACKLIST_COMMANDS.includes(command.command as string))
|
|
29
|
+
.map((command) => command.command);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const ShellCommand: CommandModule<Options, Options> = {
|
|
33
|
+
command: 'shell',
|
|
34
|
+
describe: 'Open a shell to interact with the Dubhe System',
|
|
35
|
+
builder(yargs) {
|
|
36
|
+
return yargs.options({
|
|
37
|
+
network: {
|
|
38
|
+
type: 'string',
|
|
39
|
+
choices: ['mainnet', 'testnet', 'devnet', 'localnet', 'default'],
|
|
40
|
+
default: 'default',
|
|
41
|
+
desc: 'Node network (mainnet/testnet/devnet/localnet)'
|
|
42
|
+
},
|
|
43
|
+
'rpc-url': {
|
|
44
|
+
type: 'string',
|
|
45
|
+
desc: 'Custom RPC endpoint URL injected into every sub-command (overrides the default for the selected network)'
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
},
|
|
49
|
+
handler: async ({ network, 'rpc-url': rpcUrl }) => {
|
|
50
|
+
if (network == 'default') {
|
|
51
|
+
network = await getDefaultNetwork();
|
|
52
|
+
console.log(chalk.yellow(`Use default network: [${network}]`));
|
|
53
|
+
}
|
|
54
|
+
shouldHandlerExit = false;
|
|
55
|
+
const commandHistory: string[] = [];
|
|
56
|
+
|
|
57
|
+
function completer(line: string) {
|
|
58
|
+
const hits = parseCommandNames().filter((c) => {
|
|
59
|
+
if (!c) return false;
|
|
60
|
+
return (c as string).startsWith(line.toLowerCase());
|
|
61
|
+
});
|
|
62
|
+
return [hits.length ? hits : parseCommandNames(), line];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const rl = readline.createInterface({
|
|
66
|
+
input: process.stdin,
|
|
67
|
+
output: process.stdout,
|
|
68
|
+
prompt: `dubhe(${chalk.green(network)}${
|
|
69
|
+
rpcUrl ? chalk.gray('[custom-rpc]') : ''
|
|
70
|
+
}) ${chalk.bold('>')} `,
|
|
71
|
+
completer: completer,
|
|
72
|
+
historySize: 200
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
rl.on('line', async (line) => {
|
|
76
|
+
const fullCommand = line.trim();
|
|
77
|
+
if (!fullCommand) {
|
|
78
|
+
rl.prompt();
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Add command to history
|
|
83
|
+
commandHistory.push(fullCommand);
|
|
84
|
+
|
|
85
|
+
const parts = fullCommand.split(/\s+/);
|
|
86
|
+
const commandName = parts[0].toLowerCase();
|
|
87
|
+
|
|
88
|
+
const command = commands.find(
|
|
89
|
+
(c) => c.command === commandName && !SHELL_BLACKLIST_COMMANDS.includes(commandName)
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
// Check if user is asking for help
|
|
93
|
+
if (parts.includes('--help') || parts.includes('-h')) {
|
|
94
|
+
if (command) {
|
|
95
|
+
try {
|
|
96
|
+
// Use spawn to call dubhe help externally to avoid validation issues
|
|
97
|
+
const dubheProcess = spawn('node', [process.argv[1], commandName, '--help'], {
|
|
98
|
+
stdio: 'inherit',
|
|
99
|
+
env: { ...process.env }
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
dubheProcess.on('exit', () => {
|
|
103
|
+
rl.prompt();
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
dubheProcess.on('error', () => {
|
|
107
|
+
// Fallback: show basic help information
|
|
108
|
+
console.log(`\n${command.describe || `${commandName} command`}`);
|
|
109
|
+
console.log(`\nUsage: ${commandName} [options]`);
|
|
110
|
+
console.log('\nFor complete help with all options, please exit shell and run:');
|
|
111
|
+
console.log(chalk.cyan(` dubhe ${commandName} --help`));
|
|
112
|
+
rl.prompt();
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
return; // Don't call rl.prompt() here as it's handled in the callbacks
|
|
116
|
+
} catch {
|
|
117
|
+
// Fallback: show basic help information
|
|
118
|
+
console.log(`\n${command.describe || `${commandName} command`}`);
|
|
119
|
+
console.log(`\nUsage: ${commandName} [options]`);
|
|
120
|
+
console.log('\nFor complete help with all options, please exit shell and run:');
|
|
121
|
+
console.log(chalk.cyan(` dubhe ${commandName} --help`));
|
|
122
|
+
}
|
|
123
|
+
} else {
|
|
124
|
+
console.log(
|
|
125
|
+
`🤷 Unknown command: "${commandName}". Type 'help' to see available commands.`
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
rl.prompt();
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (command) {
|
|
133
|
+
try {
|
|
134
|
+
const { builder, handler } = command;
|
|
135
|
+
const yargsInstance = yargs().exitProcess(false);
|
|
136
|
+
if (builder) {
|
|
137
|
+
if (typeof builder === 'function') {
|
|
138
|
+
builder(yargsInstance);
|
|
139
|
+
} else {
|
|
140
|
+
yargsInstance.options(builder);
|
|
141
|
+
}
|
|
142
|
+
const userArgs = parts.slice(1);
|
|
143
|
+
const hasNetworkFlag = userArgs.includes('--network') || userArgs.includes('-n');
|
|
144
|
+
const hasRpcUrlFlag = userArgs.includes('--rpc-url');
|
|
145
|
+
const argv = yargsInstance.parseSync([
|
|
146
|
+
commandName,
|
|
147
|
+
...(hasNetworkFlag ? [] : ['--network', network]),
|
|
148
|
+
...(hasRpcUrlFlag || !rpcUrl ? [] : ['--rpc-url', rpcUrl]),
|
|
149
|
+
...userArgs
|
|
150
|
+
]);
|
|
151
|
+
if (handler) {
|
|
152
|
+
await handler(argv);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
} catch (error) {
|
|
156
|
+
console.log(chalk.red(error));
|
|
157
|
+
}
|
|
158
|
+
} else if (commandName == 'help') {
|
|
159
|
+
console.log('Available dubhe commands:');
|
|
160
|
+
|
|
161
|
+
// Find the longest command name for alignment (excluding blacklisted commands)
|
|
162
|
+
const availableCommands = commands.filter(
|
|
163
|
+
(c) => !SHELL_BLACKLIST_COMMANDS.includes(c.command as string)
|
|
164
|
+
);
|
|
165
|
+
const maxCommandLength = Math.max(
|
|
166
|
+
...availableCommands.map((c) => {
|
|
167
|
+
const command =
|
|
168
|
+
typeof c.command === 'string'
|
|
169
|
+
? c.command
|
|
170
|
+
: Array.isArray(c.command)
|
|
171
|
+
? c.command[0]
|
|
172
|
+
: '';
|
|
173
|
+
return command.length;
|
|
174
|
+
})
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
availableCommands.forEach((c) => {
|
|
178
|
+
const command =
|
|
179
|
+
typeof c.command === 'string'
|
|
180
|
+
? c.command
|
|
181
|
+
: Array.isArray(c.command)
|
|
182
|
+
? c.command[0]
|
|
183
|
+
: '';
|
|
184
|
+
const paddedCommand = command.padEnd(maxCommandLength);
|
|
185
|
+
console.log(` ${chalk.green(paddedCommand)} ${c.describe}`);
|
|
186
|
+
});
|
|
187
|
+
rl.prompt();
|
|
188
|
+
return;
|
|
189
|
+
} else if (['exit', 'quit'].indexOf(commandName) !== -1) {
|
|
190
|
+
console.log('Goodbye You will have a nice day! 👋');
|
|
191
|
+
rl.close();
|
|
192
|
+
return;
|
|
193
|
+
} else {
|
|
194
|
+
console.log(`🤷 Unknown command: "${fullCommand}". Type 'help' to see available commands.`);
|
|
195
|
+
}
|
|
196
|
+
rl.prompt();
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
rl.on('close', () => {
|
|
200
|
+
process.exit(0);
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
printDubhe();
|
|
204
|
+
rl.prompt();
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
export default ShellCommand;
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import type { CommandModule } from 'yargs';
|
|
2
2
|
import { storeConfigHandler } from '../utils/storeConfig';
|
|
3
3
|
import { loadConfig, DubheConfig } from '@0xobelisk/sui-common';
|
|
4
|
+
import { handlerExit } from './shell';
|
|
5
|
+
import chalk from 'chalk';
|
|
6
|
+
import { getDefaultNetwork } from '../utils';
|
|
4
7
|
|
|
5
8
|
type Options = {
|
|
6
9
|
'config-path': string;
|
|
7
|
-
network: 'mainnet' | 'testnet' | 'devnet' | 'localnet';
|
|
10
|
+
network: 'mainnet' | 'testnet' | 'devnet' | 'localnet' | 'default';
|
|
8
11
|
'output-ts-path': string;
|
|
9
12
|
};
|
|
10
13
|
|
|
11
14
|
const commandModule: CommandModule<Options, Options> = {
|
|
12
|
-
command: 'config
|
|
15
|
+
command: 'store-config',
|
|
13
16
|
|
|
14
17
|
describe: 'Store configuration for the Dubhe project',
|
|
15
18
|
|
|
@@ -21,7 +24,8 @@ const commandModule: CommandModule<Options, Options> = {
|
|
|
21
24
|
},
|
|
22
25
|
network: {
|
|
23
26
|
type: 'string',
|
|
24
|
-
choices: ['mainnet', 'testnet', 'devnet', 'localnet'],
|
|
27
|
+
choices: ['mainnet', 'testnet', 'devnet', 'localnet', 'default'],
|
|
28
|
+
default: 'default',
|
|
25
29
|
desc: 'Network to store config for'
|
|
26
30
|
},
|
|
27
31
|
'output-ts-path': {
|
|
@@ -31,13 +35,17 @@ const commandModule: CommandModule<Options, Options> = {
|
|
|
31
35
|
},
|
|
32
36
|
async handler({ 'config-path': configPath, network, 'output-ts-path': outputTsPath }) {
|
|
33
37
|
try {
|
|
38
|
+
if (network == 'default') {
|
|
39
|
+
network = await getDefaultNetwork();
|
|
40
|
+
console.log(chalk.yellow(`Use default network: [${network}]`));
|
|
41
|
+
}
|
|
34
42
|
const dubheConfig = (await loadConfig(configPath)) as DubheConfig;
|
|
35
43
|
await storeConfigHandler(dubheConfig, network, outputTsPath);
|
|
36
44
|
} catch (error) {
|
|
37
45
|
console.error('Error storing config:', error);
|
|
38
|
-
|
|
46
|
+
handlerExit(1);
|
|
39
47
|
}
|
|
40
|
-
|
|
48
|
+
handlerExit();
|
|
41
49
|
}
|
|
42
50
|
};
|
|
43
51
|
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { CommandModule, ArgumentsCamelCase } from 'yargs';
|
|
2
|
+
import { switchEnv } from '../utils';
|
|
3
|
+
import { handlerExit } from './shell';
|
|
4
|
+
|
|
5
|
+
type Options = {
|
|
6
|
+
network: 'mainnet' | 'testnet' | 'devnet' | 'localnet' | 'default';
|
|
7
|
+
'rpc-url'?: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const commandModule: CommandModule<Options, Options> = {
|
|
11
|
+
command: 'switch-env',
|
|
12
|
+
describe: 'Switch environment',
|
|
13
|
+
builder(yargs) {
|
|
14
|
+
return yargs.options({
|
|
15
|
+
network: {
|
|
16
|
+
type: 'string',
|
|
17
|
+
choices: ['mainnet', 'testnet', 'devnet', 'localnet'] as const,
|
|
18
|
+
default: 'localnet',
|
|
19
|
+
desc: 'Switch to node network (mainnet/testnet/devnet/localnet)'
|
|
20
|
+
},
|
|
21
|
+
'rpc-url': {
|
|
22
|
+
type: 'string',
|
|
23
|
+
desc: 'Custom RPC endpoint URL (overrides the default for the selected network)'
|
|
24
|
+
}
|
|
25
|
+
}) as any;
|
|
26
|
+
},
|
|
27
|
+
async handler(argv: ArgumentsCamelCase<Options>) {
|
|
28
|
+
await switchEnv(argv.network as 'mainnet' | 'testnet' | 'devnet' | 'localnet', argv['rpc-url']);
|
|
29
|
+
handlerExit();
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export default commandModule;
|