@cartesi/cli 2.0.0-alpha.1 → 2.0.0-alpha.12
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/base.d.ts +18 -0
- package/dist/base.d.ts.map +1 -0
- package/dist/base.js +99 -0
- package/dist/builder/directory.d.ts +2 -2
- package/dist/builder/directory.d.ts.map +1 -1
- package/dist/builder/directory.js +1 -1
- package/dist/builder/docker.d.ts +1 -1
- package/dist/builder/docker.d.ts.map +1 -1
- package/dist/builder/docker.js +8 -8
- package/dist/builder/empty.d.ts +2 -2
- package/dist/builder/empty.d.ts.map +1 -1
- package/dist/builder/empty.js +1 -1
- package/dist/builder/none.d.ts +2 -2
- package/dist/builder/none.d.ts.map +1 -1
- package/dist/builder/none.js +1 -1
- package/dist/builder/tar.d.ts +2 -2
- package/dist/builder/tar.d.ts.map +1 -1
- package/dist/builder/tar.js +1 -1
- package/dist/commands/address-book.d.ts +4 -8
- package/dist/commands/address-book.d.ts.map +1 -1
- package/dist/commands/address-book.js +15 -14
- package/dist/commands/build.d.ts +5 -11
- package/dist/commands/build.d.ts.map +1 -1
- package/dist/commands/build.js +18 -30
- package/dist/commands/clean.d.ts +2 -7
- package/dist/commands/clean.d.ts.map +1 -1
- package/dist/commands/clean.js +9 -10
- package/dist/commands/create.d.ts +6 -15
- package/dist/commands/create.d.ts.map +1 -1
- package/dist/commands/create.js +24 -54
- package/dist/commands/deploy/build.d.ts +2 -14
- package/dist/commands/deploy/build.d.ts.map +1 -1
- package/dist/commands/deploy/build.js +8 -61
- package/dist/commands/deploy.d.ts +18 -0
- package/dist/commands/deploy.d.ts.map +1 -0
- package/dist/commands/deploy.js +271 -0
- package/dist/commands/doctor.d.ts +2 -12
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +90 -91
- package/dist/commands/hash.d.ts +4 -9
- package/dist/commands/hash.d.ts.map +1 -1
- package/dist/commands/hash.js +14 -14
- package/dist/commands/logs.d.ts +10 -0
- package/dist/commands/logs.d.ts.map +1 -0
- package/dist/commands/logs.js +33 -0
- package/dist/commands/run.d.ts +2 -20
- package/dist/commands/run.d.ts.map +1 -1
- package/dist/commands/run.js +9 -190
- package/dist/commands/send/eip712.d.ts +34 -0
- package/dist/commands/send/eip712.d.ts.map +1 -0
- package/dist/commands/send/eip712.js +81 -0
- package/dist/commands/send/erc20.d.ts +11 -13
- package/dist/commands/send/erc20.d.ts.map +1 -1
- package/dist/commands/send/erc20.js +57 -52
- package/dist/commands/send/erc721.d.ts +11 -13
- package/dist/commands/send/erc721.d.ts.map +1 -1
- package/dist/commands/send/erc721.js +51 -46
- package/dist/commands/send/ether.d.ts +11 -12
- package/dist/commands/send/ether.d.ts.map +1 -1
- package/dist/commands/send/ether.js +25 -21
- package/dist/commands/send/generic.d.ts +14 -14
- package/dist/commands/send/generic.d.ts.map +1 -1
- package/dist/commands/send/generic.js +102 -99
- package/dist/commands/send.d.ts +21 -0
- package/dist/commands/send.d.ts.map +1 -0
- package/dist/commands/send.js +67 -0
- package/dist/commands/shell.d.ts +6 -14
- package/dist/commands/shell.d.ts.map +1 -1
- package/dist/commands/shell.js +22 -44
- package/dist/commands/start.d.ts +14 -0
- package/dist/commands/start.d.ts.map +1 -0
- package/dist/commands/start.js +220 -0
- package/dist/commands/status.d.ts +6 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +47 -0
- package/dist/commands/stop.d.ts +5 -0
- package/dist/commands/stop.d.ts.map +1 -0
- package/dist/commands/stop.js +27 -0
- package/dist/compose/default.env +35 -0
- package/dist/compose/docker-compose-anvil.yaml +17 -0
- package/dist/compose/docker-compose-bundler.yaml +37 -0
- package/dist/{node → compose}/docker-compose-database.yaml +4 -2
- package/dist/compose/docker-compose-espresso.yaml +59 -0
- package/dist/compose/docker-compose-explorer.yaml +57 -0
- package/dist/compose/docker-compose-graphql.yaml +23 -0
- package/dist/compose/docker-compose-node-cpus.yaml +6 -0
- package/dist/compose/docker-compose-node-memory.yaml +6 -0
- package/dist/compose/docker-compose-node.yaml +31 -0
- package/dist/compose/docker-compose-passkey-server.yaml +15 -0
- package/dist/compose/docker-compose-paymaster.yaml +18 -0
- package/dist/compose/docker-compose-proxy.yaml +24 -0
- package/dist/compose/proxy/anvil.yaml +17 -0
- package/dist/compose/proxy/bundler.yaml +29 -0
- package/dist/compose/proxy/espresso.yaml +17 -0
- package/dist/compose/proxy/explorer-api.yaml +17 -0
- package/dist/compose/proxy/explorer.yaml +10 -0
- package/dist/compose/proxy/graphql.yaml +10 -0
- package/dist/compose/proxy/passkey-server.yaml +17 -0
- package/dist/compose/proxy/paymaster.yaml +17 -0
- package/dist/compose/proxy/rollups-node.yaml +17 -0
- package/dist/config.d.ts +5 -4
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +26 -35
- package/dist/contracts.d.ts +1695 -1636
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js +632 -592
- package/dist/exec/cartesi-machine.d.ts +2 -2
- package/dist/exec/cartesi-machine.d.ts.map +1 -1
- package/dist/exec/cartesi-machine.js +1 -1
- package/dist/exec/crane.d.ts +4 -4
- package/dist/exec/crane.d.ts.map +1 -1
- package/dist/exec/crane.js +1 -1
- package/dist/exec/genext2fs.d.ts +2 -2
- package/dist/exec/genext2fs.d.ts.map +1 -1
- package/dist/exec/genext2fs.js +2 -2
- package/dist/exec/mksquashfs.d.ts +2 -2
- package/dist/exec/mksquashfs.d.ts.map +1 -1
- package/dist/exec/mksquashfs.js +2 -2
- package/dist/exec/rollups.d.ts +16 -0
- package/dist/exec/rollups.d.ts.map +1 -0
- package/dist/exec/rollups.js +39 -0
- package/dist/exec/util.d.ts +3 -3
- package/dist/exec/util.d.ts.map +1 -1
- package/dist/exec/util.js +8 -10
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +59 -1
- package/dist/machine.d.ts +1 -1
- package/dist/machine.d.ts.map +1 -1
- package/dist/prompts.d.ts +3 -3
- package/dist/prompts.d.ts.map +1 -1
- package/dist/prompts.js +1 -1
- package/dist/template.d.ts +3 -0
- package/dist/template.d.ts.map +1 -0
- package/dist/template.js +16 -0
- package/dist/wallet.d.ts +1 -1
- package/dist/wallet.d.ts.map +1 -1
- package/dist/wallet.js +109 -84
- package/package.json +32 -50
- package/bin/dev.cmd +0 -3
- package/bin/dev.js +0 -25
- package/bin/run.cmd +0 -3
- package/bin/run.js +0 -8
- package/dist/baseCommand.d.ts +0 -22
- package/dist/baseCommand.d.ts.map +0 -1
- package/dist/baseCommand.js +0 -92
- package/dist/commands/deploy/index.d.ts +0 -12
- package/dist/commands/deploy/index.d.ts.map +0 -1
- package/dist/commands/deploy/index.js +0 -78
- package/dist/commands/send/index.d.ts +0 -28
- package/dist/commands/send/index.d.ts.map +0 -1
- package/dist/commands/send/index.js +0 -102
- package/dist/flags.d.ts +0 -17
- package/dist/flags.d.ts.map +0 -1
- package/dist/flags.js +0 -28
- package/dist/node/DockerfileDeploy.txt +0 -4
- package/dist/node/default.env +0 -27
- package/dist/node/docker-compose-anvil.yaml +0 -50
- package/dist/node/docker-compose-bundler.yaml +0 -57
- package/dist/node/docker-compose-envfile.yaml +0 -4
- package/dist/node/docker-compose-explorer.yaml +0 -88
- package/dist/node/docker-compose-host.yaml +0 -30
- package/dist/node/docker-compose-paymaster.yaml +0 -33
- package/dist/node/docker-compose-prompt.yaml +0 -17
- package/dist/node/docker-compose-proxy.yaml +0 -48
- package/dist/node/docker-compose-snapshot-volume.yaml +0 -8
- package/dist/node/docker-compose-validator-cpus.yaml +0 -6
- package/dist/node/docker-compose-validator-memory.yaml +0 -6
- package/dist/node/docker-compose-validator.yaml +0 -59
- package/oclif.manifest.json +0 -876
package/dist/wallet.js
CHANGED
|
@@ -2,31 +2,27 @@ import input from "@inquirer/input";
|
|
|
2
2
|
import chalk from "chalk";
|
|
3
3
|
import { formatUnits, http, createPublicClient as viemCreatePublicClient, createWalletClient as viemCreateWalletClient, } from "viem";
|
|
4
4
|
import { mnemonicToAccount, privateKeyToAccount } from "viem/accounts";
|
|
5
|
-
import { arbitrum, arbitrumSepolia, base, baseSepolia,
|
|
5
|
+
import { arbitrum, arbitrumSepolia, base, baseSepolia, cannon, mainnet, optimism, optimismSepolia, sepolia, } from "viem/chains";
|
|
6
6
|
import { hexInput, selectAuto } from "./prompts.js";
|
|
7
7
|
export const supportedChains = (options) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
includeTestnets: true,
|
|
12
|
-
};
|
|
13
|
-
options.includeTestnets = options.includeTestnets ?? true; // default is true if not specified
|
|
14
|
-
options.includeMainnets = options.includeMainnets ?? true; // default is true if not specified
|
|
8
|
+
const includeDevnet = options?.includeDevnet ?? false; // default is not to show devnet
|
|
9
|
+
const includeMainnets = options?.includeMainnets ?? true; // default is true if not specified
|
|
10
|
+
const includeTestnets = options?.includeTestnets ?? true; // default is true if not specified
|
|
15
11
|
const chains = [];
|
|
16
|
-
if (
|
|
17
|
-
chains.push(
|
|
12
|
+
if (includeDevnet) {
|
|
13
|
+
chains.push(cannon);
|
|
18
14
|
}
|
|
19
|
-
if (
|
|
15
|
+
if (includeTestnets) {
|
|
20
16
|
chains.push(arbitrumSepolia, baseSepolia, optimismSepolia, sepolia);
|
|
21
17
|
}
|
|
22
|
-
if (
|
|
18
|
+
if (includeMainnets) {
|
|
23
19
|
chains.push(arbitrum, base, mainnet, optimism);
|
|
24
20
|
}
|
|
25
21
|
return chains;
|
|
26
22
|
};
|
|
27
23
|
export const DEFAULT_DEVNET_MNEMONIC = "test test test test test test test test test test test junk";
|
|
28
24
|
const walletChoices = (chain) => {
|
|
29
|
-
const dev = chain.id ===
|
|
25
|
+
const dev = chain.id === cannon.id;
|
|
30
26
|
return [
|
|
31
27
|
{
|
|
32
28
|
name: `Mnemonic${dev ? "" : chalk.red(" (UNSAFE)")}`,
|
|
@@ -38,8 +34,35 @@ const walletChoices = (chain) => {
|
|
|
38
34
|
},
|
|
39
35
|
];
|
|
40
36
|
};
|
|
37
|
+
/**
|
|
38
|
+
* Test if a RPC URL for a chain is working
|
|
39
|
+
* @param chain chain to test
|
|
40
|
+
* @param url url to test
|
|
41
|
+
* @returns true if the RPC URL is valid and chainId matches, false otherwise
|
|
42
|
+
*/
|
|
43
|
+
const testChainUrl = async (chain, url) => {
|
|
44
|
+
try {
|
|
45
|
+
const publicClient = viemCreatePublicClient({
|
|
46
|
+
transport: http(url),
|
|
47
|
+
chain,
|
|
48
|
+
});
|
|
49
|
+
const chainId = await publicClient.getChainId();
|
|
50
|
+
return chainId === chain.id;
|
|
51
|
+
}
|
|
52
|
+
catch (e) {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Test if the default RPC URL for a chain is working
|
|
58
|
+
* @param chain chain to test
|
|
59
|
+
* @returns true if the default RPC URL is valid, false otherwise
|
|
60
|
+
*/
|
|
61
|
+
const testDefaultPublicClient = async (chain) => {
|
|
62
|
+
return testChainUrl(chain, chain.rpcUrls.default.http[0]);
|
|
63
|
+
};
|
|
41
64
|
const selectChain = async (options) => {
|
|
42
|
-
// if development mode, include
|
|
65
|
+
// if development mode, include anvil as an option
|
|
43
66
|
const chains = supportedChains({ includeDevnet: true });
|
|
44
67
|
if (options.chain) {
|
|
45
68
|
const chain = options.chain;
|
|
@@ -48,32 +71,40 @@ const selectChain = async (options) => {
|
|
|
48
71
|
}
|
|
49
72
|
throw new Error(`Unsupported chainId ${options.chain.id}`);
|
|
50
73
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
});
|
|
63
|
-
}
|
|
74
|
+
// allow user to select from list
|
|
75
|
+
const choices = chains.map((chain) => ({
|
|
76
|
+
name: chain.name,
|
|
77
|
+
value: chain,
|
|
78
|
+
}));
|
|
79
|
+
return await selectAuto({
|
|
80
|
+
message: "Chain",
|
|
81
|
+
choices,
|
|
82
|
+
pageSize: choices.length,
|
|
83
|
+
discardDisabled: true,
|
|
84
|
+
});
|
|
64
85
|
};
|
|
65
86
|
const selectTransport = async (options, chain) => {
|
|
66
87
|
// use user provided url (in args) or try to use default one from chain, or ask for one
|
|
67
88
|
if (options.rpcUrl) {
|
|
68
89
|
return http(options.rpcUrl);
|
|
69
90
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
|
|
91
|
+
const defaultUrl = chain.rpcUrls.default.http[0];
|
|
92
|
+
// if the chain is cannon and URL is valid, use it without asking the user
|
|
93
|
+
if (chain.id === cannon.id) {
|
|
94
|
+
const port = 8080; // XXX: how to get environment port?
|
|
95
|
+
const url = `http://127.0.0.1:${port}/anvil`;
|
|
96
|
+
if (await testChainUrl(chain, url)) {
|
|
97
|
+
return http(url);
|
|
98
|
+
}
|
|
99
|
+
if (await testDefaultPublicClient(chain)) {
|
|
100
|
+
return http(defaultUrl);
|
|
101
|
+
}
|
|
76
102
|
}
|
|
103
|
+
const url = await input({
|
|
104
|
+
message: "RPC URL",
|
|
105
|
+
default: defaultUrl,
|
|
106
|
+
});
|
|
107
|
+
return http(url);
|
|
77
108
|
};
|
|
78
109
|
const createPublicClient = async (chain, transport) => {
|
|
79
110
|
const publicClient = viemCreatePublicClient({ transport, chain });
|
|
@@ -105,9 +136,7 @@ const addressBalanceLabel = async (address, publicClient) => {
|
|
|
105
136
|
}
|
|
106
137
|
return `${address} ${balanceLabel}`;
|
|
107
138
|
}
|
|
108
|
-
|
|
109
|
-
return address;
|
|
110
|
-
}
|
|
139
|
+
return address;
|
|
111
140
|
};
|
|
112
141
|
const createWalletClient = async (options, chain, publicClient, publicTransport) => {
|
|
113
142
|
if (options.privateKey) {
|
|
@@ -119,7 +148,7 @@ const createWalletClient = async (options, chain, publicClient, publicTransport)
|
|
|
119
148
|
chain,
|
|
120
149
|
});
|
|
121
150
|
}
|
|
122
|
-
|
|
151
|
+
if (options.mnemonicPassphrase) {
|
|
123
152
|
// mnemonic specified
|
|
124
153
|
const account = mnemonicToAccount(options.mnemonicPassphrase, {
|
|
125
154
|
addressIndex: options.mnemonicIndex,
|
|
@@ -131,60 +160,56 @@ const createWalletClient = async (options, chain, publicClient, publicTransport)
|
|
|
131
160
|
chain,
|
|
132
161
|
});
|
|
133
162
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
163
|
+
const wallets = walletChoices(chain);
|
|
164
|
+
const wallet = await selectAuto({
|
|
165
|
+
message: "Wallet",
|
|
166
|
+
choices: wallets,
|
|
167
|
+
discardDisabled: true,
|
|
168
|
+
});
|
|
169
|
+
if (wallet === "mnemonic") {
|
|
170
|
+
// use the publicClient transport
|
|
171
|
+
const mnemonic = await input({
|
|
172
|
+
message: "Mnemonic",
|
|
173
|
+
default: chain.id === cannon.id ? DEFAULT_DEVNET_MNEMONIC : undefined,
|
|
140
174
|
});
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
const mnemonic = await input({
|
|
144
|
-
message: "Mnemonic",
|
|
145
|
-
default: chain.id === 31337 ? DEFAULT_DEVNET_MNEMONIC : undefined,
|
|
146
|
-
});
|
|
147
|
-
// select account from mnemonic
|
|
148
|
-
if (options.mnemonicIndex) {
|
|
149
|
-
return viemCreateWalletClient({
|
|
150
|
-
transport: publicTransport,
|
|
151
|
-
chain,
|
|
152
|
-
account: mnemonicToAccount(mnemonic, {
|
|
153
|
-
addressIndex: options.mnemonicIndex,
|
|
154
|
-
}),
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
else {
|
|
158
|
-
const choices = await Promise.all([...Array(10)].map(async (_, addressIndex) => {
|
|
159
|
-
const account = mnemonicToAccount(mnemonic, {
|
|
160
|
-
addressIndex,
|
|
161
|
-
});
|
|
162
|
-
const name = await addressBalanceLabel(account.address, publicClient);
|
|
163
|
-
return { name, value: account };
|
|
164
|
-
}));
|
|
165
|
-
const account = await selectAuto({
|
|
166
|
-
message: "Account",
|
|
167
|
-
choices,
|
|
168
|
-
pageSize: choices.length,
|
|
169
|
-
});
|
|
170
|
-
return viemCreateWalletClient({
|
|
171
|
-
transport: publicTransport,
|
|
172
|
-
chain,
|
|
173
|
-
account,
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
else if (wallet === "private-key") {
|
|
178
|
-
const privateKey = await hexInput({ message: "Private Key" });
|
|
179
|
-
const account = privateKeyToAccount(privateKey);
|
|
175
|
+
// select account from mnemonic
|
|
176
|
+
if (options.mnemonicIndex) {
|
|
180
177
|
return viemCreateWalletClient({
|
|
181
178
|
transport: publicTransport,
|
|
182
179
|
chain,
|
|
183
|
-
account,
|
|
180
|
+
account: mnemonicToAccount(mnemonic, {
|
|
181
|
+
addressIndex: options.mnemonicIndex,
|
|
182
|
+
}),
|
|
184
183
|
});
|
|
185
184
|
}
|
|
186
|
-
|
|
185
|
+
const choices = await Promise.all([...Array(10)].map(async (_, addressIndex) => {
|
|
186
|
+
const account = mnemonicToAccount(mnemonic, {
|
|
187
|
+
addressIndex,
|
|
188
|
+
});
|
|
189
|
+
const name = await addressBalanceLabel(account.address, publicClient);
|
|
190
|
+
return { name, value: account };
|
|
191
|
+
}));
|
|
192
|
+
const account = await selectAuto({
|
|
193
|
+
message: "Account",
|
|
194
|
+
choices,
|
|
195
|
+
pageSize: choices.length,
|
|
196
|
+
});
|
|
197
|
+
return viemCreateWalletClient({
|
|
198
|
+
transport: publicTransport,
|
|
199
|
+
chain,
|
|
200
|
+
account,
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
if (wallet === "private-key") {
|
|
204
|
+
const privateKey = await hexInput({ message: "Private Key" });
|
|
205
|
+
const account = privateKeyToAccount(privateKey);
|
|
206
|
+
return viemCreateWalletClient({
|
|
207
|
+
transport: publicTransport,
|
|
208
|
+
chain,
|
|
209
|
+
account,
|
|
210
|
+
});
|
|
187
211
|
}
|
|
212
|
+
throw new Error(`Unsupported wallet ${wallet}`);
|
|
188
213
|
};
|
|
189
214
|
const createClients = async (options) => {
|
|
190
215
|
// select chain
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cartesi/cli",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.12",
|
|
4
4
|
"description": "Cartesi CLI",
|
|
5
5
|
"author": "Danilo Tuler <tuler@pobox.com>",
|
|
6
6
|
"bin": {
|
|
7
|
-
"cartesi": "./
|
|
7
|
+
"cartesi": "./dist/index.js"
|
|
8
8
|
},
|
|
9
9
|
"type": "module",
|
|
10
10
|
"homepage": "https://github.com/cartesi/cli",
|
|
@@ -14,80 +14,61 @@
|
|
|
14
14
|
"files": [
|
|
15
15
|
"/bin",
|
|
16
16
|
"/dist",
|
|
17
|
-
"/npm-shrinkwrap.json"
|
|
18
|
-
"/oclif.manifest.json"
|
|
17
|
+
"/npm-shrinkwrap.json"
|
|
19
18
|
],
|
|
20
19
|
"dependencies": {
|
|
21
|
-
"@
|
|
22
|
-
"@inquirer/
|
|
23
|
-
"@inquirer/
|
|
24
|
-
"@inquirer/
|
|
25
|
-
"@inquirer/
|
|
26
|
-
"@
|
|
27
|
-
"@oclif/plugin-help": "^6.2.15",
|
|
28
|
-
"@oclif/plugin-plugins": "^5.4.15",
|
|
20
|
+
"@commander-js/extra-typings": "^13.1.0",
|
|
21
|
+
"@inquirer/confirm": "^5.1.6",
|
|
22
|
+
"@inquirer/core": "^10.1.7",
|
|
23
|
+
"@inquirer/input": "^4.1.6",
|
|
24
|
+
"@inquirer/select": "^4.0.9",
|
|
25
|
+
"@inquirer/type": "^3.0.4",
|
|
29
26
|
"bytes": "^3.1.2",
|
|
30
|
-
"chalk": "^5.
|
|
27
|
+
"chalk": "^5.4.1",
|
|
31
28
|
"cli-table3": "^0.6.5",
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
29
|
+
"commander": "^13.1.0",
|
|
30
|
+
"execa": "^9.5.2",
|
|
31
|
+
"fs-extra": "^11.3.0",
|
|
32
|
+
"giget": "^2.0.0",
|
|
33
|
+
"listr2": "^8.2.5",
|
|
34
|
+
"lookpath": "^1.2.3",
|
|
36
35
|
"open": "^10.1.0",
|
|
37
|
-
"ora": "^8.
|
|
36
|
+
"ora": "^8.2.0",
|
|
37
|
+
"p-retry": "^6.2.1",
|
|
38
38
|
"progress-stream": "^2.0.0",
|
|
39
|
-
"semver": "^7.
|
|
40
|
-
"smol-toml": "^1.3.
|
|
39
|
+
"semver": "^7.7.1",
|
|
40
|
+
"smol-toml": "^1.3.1",
|
|
41
41
|
"tmp": "^0.2.3",
|
|
42
|
-
"viem": "^2.
|
|
42
|
+
"viem": "^2.23.6"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@
|
|
46
|
-
"@
|
|
45
|
+
"@biomejs/biome": "^1.9.4",
|
|
46
|
+
"@cartesi/devnet": "2.0.0-alpha.6",
|
|
47
|
+
"@cartesi/rollups": "2.0.0",
|
|
48
|
+
"@types/bytes": "^3.1.5",
|
|
47
49
|
"@types/fs-extra": "^11.0.4",
|
|
48
50
|
"@types/inquirer": "^9.0.7",
|
|
49
|
-
"@types/node": "^22.
|
|
50
|
-
"@types/node-fetch": "^2.6.
|
|
51
|
+
"@types/node": "^22.13.9",
|
|
52
|
+
"@types/node-fetch": "^2.6.12",
|
|
51
53
|
"@types/progress-stream": "^2.0.5",
|
|
52
54
|
"@types/prompts": "^2.4.9",
|
|
53
55
|
"@types/semver": "^7.5.8",
|
|
54
56
|
"@types/tmp": "^0.2.6",
|
|
55
57
|
"@vitest/coverage-istanbul": "^2.1.3",
|
|
56
|
-
"@wagmi/cli": "^2.
|
|
58
|
+
"@wagmi/cli": "^2.2.0",
|
|
57
59
|
"copyfiles": "^2.4.1",
|
|
58
|
-
"eslint": "^8.57.0",
|
|
59
|
-
"eslint-config-oclif": "^5.2.1",
|
|
60
|
-
"eslint-config-oclif-typescript": "^3.1.12",
|
|
61
60
|
"npm-run-all": "^4.1.5",
|
|
62
|
-
"oclif": "^4.15.9",
|
|
63
61
|
"rimraf": "^6.0.1",
|
|
64
62
|
"ts-node": "^10.9.2",
|
|
65
|
-
"tslib": "^2.8.
|
|
66
|
-
"typescript": "^5.
|
|
63
|
+
"tslib": "^2.8.1",
|
|
64
|
+
"typescript": "^5.8.2",
|
|
67
65
|
"vitest": "^2.1.3",
|
|
68
|
-
"@cartesi/devnet": "2.0.0-alpha.0",
|
|
69
|
-
"@cartesi/eslint-config": "0.0.0",
|
|
70
66
|
"tsconfig": "0.0.0"
|
|
71
67
|
},
|
|
72
|
-
"oclif": {
|
|
73
|
-
"bin": "cartesi",
|
|
74
|
-
"dirname": "cartesi",
|
|
75
|
-
"commands": "./dist/commands",
|
|
76
|
-
"plugins": [
|
|
77
|
-
"@oclif/plugin-help"
|
|
78
|
-
],
|
|
79
|
-
"topicSeparator": " ",
|
|
80
|
-
"macos": {
|
|
81
|
-
"identifier": "io.cartesi.cli"
|
|
82
|
-
}
|
|
83
|
-
},
|
|
84
68
|
"engines": {
|
|
85
69
|
"node": ">=18.0.0"
|
|
86
70
|
},
|
|
87
71
|
"bugs": "https://github.com/cartesi/cli/issues",
|
|
88
|
-
"keywords": [
|
|
89
|
-
"oclif"
|
|
90
|
-
],
|
|
91
72
|
"types": "dist/index.d.ts",
|
|
92
73
|
"scripts": {
|
|
93
74
|
"build": "run-s clean codegen compile copy-files",
|
|
@@ -95,8 +76,9 @@
|
|
|
95
76
|
"codegen": "run-p codegen:wagmi",
|
|
96
77
|
"codegen:wagmi": "wagmi generate",
|
|
97
78
|
"compile": "tsc -p tsconfig.build.json",
|
|
79
|
+
"postcompile": "chmod +x dist/index.js",
|
|
98
80
|
"copy-files": "copyfiles -u 1 \"src/**/*.yaml\" \"src/**/*.env\" \"src/**/*.txt\" dist",
|
|
99
|
-
"lint": "
|
|
81
|
+
"lint": "biome lint",
|
|
100
82
|
"posttest": "pnpm lint",
|
|
101
83
|
"test": "vitest"
|
|
102
84
|
}
|
package/bin/dev.cmd
DELETED
package/bin/dev.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node --no-warnings=ExperimentalWarning --loader ts-node/esm
|
|
2
|
-
|
|
3
|
-
import oclif from "@oclif/core";
|
|
4
|
-
import path from "node:path";
|
|
5
|
-
import url from "node:url";
|
|
6
|
-
import { register } from "ts-node";
|
|
7
|
-
|
|
8
|
-
// In dev mode -> use ts-node and dev plugins
|
|
9
|
-
process.env.NODE_ENV = "development";
|
|
10
|
-
|
|
11
|
-
const project = path.join(
|
|
12
|
-
path.dirname(url.fileURLToPath(import.meta.url)),
|
|
13
|
-
"..",
|
|
14
|
-
"tsconfig.json"
|
|
15
|
-
);
|
|
16
|
-
register({ project });
|
|
17
|
-
|
|
18
|
-
// In dev mode, always show stack traces
|
|
19
|
-
oclif.settings.debug = true;
|
|
20
|
-
|
|
21
|
-
// Start the CLI
|
|
22
|
-
oclif
|
|
23
|
-
.run(process.argv.slice(2), import.meta.url)
|
|
24
|
-
.then(oclif.flush)
|
|
25
|
-
.catch(oclif.Errors.handle);
|
package/bin/run.cmd
DELETED
package/bin/run.js
DELETED
package/dist/baseCommand.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Command, Interfaces } from "@oclif/core";
|
|
2
|
-
import { Address, Hash } from "viem";
|
|
3
|
-
import { Config } from "./config.js";
|
|
4
|
-
export type Flags<T extends typeof Command> = Interfaces.InferredFlags<(typeof BaseCommand)["baseFlags"] & T["flags"]>;
|
|
5
|
-
export type Args<T extends typeof Command> = Interfaces.InferredArgs<T["args"]>;
|
|
6
|
-
export type AddressBook = Record<string, Address>;
|
|
7
|
-
export declare abstract class BaseCommand<T extends typeof Command> extends Command {
|
|
8
|
-
protected flags: Flags<T>;
|
|
9
|
-
protected args: Args<T>;
|
|
10
|
-
protected getServiceState(projectName: string, serviceName: string): Promise<string | undefined>;
|
|
11
|
-
protected getContextPath(...paths: string[]): string;
|
|
12
|
-
protected getApplicationConfig(configPath: string): Config;
|
|
13
|
-
protected getMachineHash(): Hash | undefined;
|
|
14
|
-
protected logPrompt({ title, value }: {
|
|
15
|
-
title: string;
|
|
16
|
-
value: string;
|
|
17
|
-
}): void;
|
|
18
|
-
protected getApplicationAddress(): Promise<Address>;
|
|
19
|
-
protected getAddressBook(): Promise<AddressBook>;
|
|
20
|
-
init(): Promise<void>;
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=baseCommand.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"baseCommand.d.ts","sourceRoot":"","sources":["../src/baseCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAKlD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAsB,MAAM,MAAM,CAAC;AAEzD,OAAO,EAAE,MAAM,EAAS,MAAM,aAAa,CAAC;AAiB5C,MAAM,MAAM,KAAK,CAAC,CAAC,SAAS,OAAO,OAAO,IAAI,UAAU,CAAC,aAAa,CAClE,CAAC,OAAO,WAAW,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CACjD,CAAC;AACF,MAAM,MAAM,IAAI,CAAC,CAAC,SAAS,OAAO,OAAO,IAAI,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAChF,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAElD,8BAAsB,WAAW,CAAC,CAAC,SAAS,OAAO,OAAO,CAAE,SAAQ,OAAO;IACvE,SAAS,CAAC,KAAK,EAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IAC3B,SAAS,CAAC,IAAI,EAAG,IAAI,CAAC,CAAC,CAAC,CAAC;cAET,eAAe,CAC3B,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,GACpB,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAe9B,SAAS,CAAC,cAAc,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM;IAIpD,SAAS,CAAC,oBAAoB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM;IAM1D,SAAS,CAAC,cAAc,IAAI,IAAI,GAAG,SAAS;IAY5C,SAAS,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE;cAItD,qBAAqB,IAAI,OAAO,CAAC,OAAO,CAAC;cAKzC,cAAc,IAAI,OAAO,CAAC,WAAW,CAAC;IAiCzC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAYrC"}
|
package/dist/baseCommand.js
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { Command } from "@oclif/core";
|
|
2
|
-
import chalk from "chalk";
|
|
3
|
-
import { execa } from "execa";
|
|
4
|
-
import fs from "fs";
|
|
5
|
-
import path from "path";
|
|
6
|
-
import { getAddress, isHash } from "viem";
|
|
7
|
-
import { parse } from "./config.js";
|
|
8
|
-
import { applicationFactoryAddress, authorityFactoryAddress, erc1155BatchPortalAddress, erc1155SinglePortalAddress, erc20PortalAddress, erc721PortalAddress, etherPortalAddress, inputBoxAddress, selfHostedApplicationFactoryAddress, testMultiTokenAddress, testNftAddress, testTokenAddress, } from "./contracts.js";
|
|
9
|
-
export class BaseCommand extends Command {
|
|
10
|
-
async getServiceState(projectName, serviceName) {
|
|
11
|
-
// get service information
|
|
12
|
-
const { stdout } = await execa("docker", [
|
|
13
|
-
"compose",
|
|
14
|
-
"--project-name",
|
|
15
|
-
projectName,
|
|
16
|
-
"ps",
|
|
17
|
-
serviceName,
|
|
18
|
-
"--format",
|
|
19
|
-
"json",
|
|
20
|
-
]);
|
|
21
|
-
const ps = stdout ? JSON.parse(stdout) : undefined;
|
|
22
|
-
return ps?.State;
|
|
23
|
-
}
|
|
24
|
-
getContextPath(...paths) {
|
|
25
|
-
return path.join(".cartesi", ...paths);
|
|
26
|
-
}
|
|
27
|
-
getApplicationConfig(configPath) {
|
|
28
|
-
return fs.existsSync(configPath)
|
|
29
|
-
? parse(fs.readFileSync(configPath).toString())
|
|
30
|
-
: parse("");
|
|
31
|
-
}
|
|
32
|
-
getMachineHash() {
|
|
33
|
-
// read hash of the cartesi machine snapshot, if one exists
|
|
34
|
-
const hashPath = this.getContextPath("image", "hash");
|
|
35
|
-
if (fs.existsSync(hashPath)) {
|
|
36
|
-
const hash = fs.readFileSync(hashPath).toString("hex");
|
|
37
|
-
if (isHash(`0x${hash}`)) {
|
|
38
|
-
return `0x${hash}`;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return undefined;
|
|
42
|
-
}
|
|
43
|
-
logPrompt({ title, value }) {
|
|
44
|
-
this.log(`${chalk.green("?")} ${title} ${chalk.cyan(value)}`);
|
|
45
|
-
}
|
|
46
|
-
async getApplicationAddress() {
|
|
47
|
-
// fixed value, as we do deterministic deployment with a zero hash
|
|
48
|
-
return getAddress("0xab7528bb862fb57e8a2bcd567a2e929a0be56a5e");
|
|
49
|
-
}
|
|
50
|
-
async getAddressBook() {
|
|
51
|
-
const applicationAddress = await this.getApplicationAddress();
|
|
52
|
-
// build rollups contracts address book
|
|
53
|
-
const contracts = {
|
|
54
|
-
Application: applicationAddress,
|
|
55
|
-
ApplicationFactory: applicationFactoryAddress,
|
|
56
|
-
AuthorityFactory: authorityFactoryAddress,
|
|
57
|
-
EntryPointV06: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
|
|
58
|
-
EntryPointV07: "0x0000000071727De22E5E9d8BAf0edAc6f37da032",
|
|
59
|
-
ERC1155BatchPortal: erc1155BatchPortalAddress,
|
|
60
|
-
ERC1155SinglePortal: erc1155SinglePortalAddress,
|
|
61
|
-
ERC20Portal: erc20PortalAddress,
|
|
62
|
-
ERC721Portal: erc721PortalAddress,
|
|
63
|
-
EtherPortal: etherPortalAddress,
|
|
64
|
-
InputBox: inputBoxAddress,
|
|
65
|
-
LightAccountFactory: "0x00004EC70002a32400f8ae005A26081065620D20",
|
|
66
|
-
SelfHostedApplicationFactory: selfHostedApplicationFactoryAddress,
|
|
67
|
-
SimpleAccountFactory: "0x9406Cc6185a346906296840746125a0E44976454",
|
|
68
|
-
SmartAccountFactory: "0x000000a56Aaca3e9a4C479ea6b6CD0DbcB6634F5",
|
|
69
|
-
KernelFactoryV2: "0x5de4839a76cf55d0c90e2061ef4386d962E15ae3",
|
|
70
|
-
KernelFactoryV3: "0x6723b44Abeec4E71eBE3232BD5B455805baDD22f",
|
|
71
|
-
KernelFactoryV3_1: "0xaac5D4240AF87249B3f71BC8E4A2cae074A3E419",
|
|
72
|
-
TestToken: testTokenAddress,
|
|
73
|
-
TestNFT: testNftAddress,
|
|
74
|
-
TestMultiToken: testMultiTokenAddress,
|
|
75
|
-
VerifyingPaymasterV06: "0x28ec0633192d0cBd9E1156CE05D5FdACAcB93947",
|
|
76
|
-
VerifyingPaymasterV07: "0xc5c97885C67F7361aBAfD2B95067a5bBdA603608",
|
|
77
|
-
};
|
|
78
|
-
return contracts;
|
|
79
|
-
}
|
|
80
|
-
async init() {
|
|
81
|
-
await super.init();
|
|
82
|
-
const { args, flags } = await this.parse({
|
|
83
|
-
flags: this.ctor.flags,
|
|
84
|
-
baseFlags: super.ctor.baseFlags,
|
|
85
|
-
args: this.ctor.args,
|
|
86
|
-
enableJsonFlag: this.ctor.enableJsonFlag,
|
|
87
|
-
strict: this.ctor.strict,
|
|
88
|
-
});
|
|
89
|
-
this.flags = flags;
|
|
90
|
-
this.args = args;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { BaseCommand } from "../../baseCommand.js";
|
|
2
|
-
export default class Deploy extends BaseCommand<typeof Deploy> {
|
|
3
|
-
static summary: string;
|
|
4
|
-
static description: string;
|
|
5
|
-
static examples: string[];
|
|
6
|
-
static flags: {
|
|
7
|
-
hosting: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
8
|
-
webapp: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<import("url").URL, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
9
|
-
};
|
|
10
|
-
run(): Promise<void>;
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/deploy/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,MAAM,CAAC,OAAO,OAAO,MAAO,SAAQ,WAAW,CAAC,OAAO,MAAM,CAAC;IAC1D,MAAM,CAAC,OAAO,SAA2C;IAEzD,MAAM,CAAC,WAAW,SACoD;IAEtE,MAAM,CAAC,QAAQ,WAA2C;IAE1D,MAAM,CAAC,KAAK;;;MAWV;IAEW,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAiEpC"}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import confirm from "@inquirer/confirm";
|
|
2
|
-
import select from "@inquirer/select";
|
|
3
|
-
import { Flags } from "@oclif/core";
|
|
4
|
-
import chalk from "chalk";
|
|
5
|
-
import open, { apps } from "open";
|
|
6
|
-
import { BaseCommand } from "../../baseCommand.js";
|
|
7
|
-
class Deploy extends BaseCommand {
|
|
8
|
-
async run() {
|
|
9
|
-
const { flags } = await this.parse(Deploy);
|
|
10
|
-
// print machine hash
|
|
11
|
-
const templateHash = this.getMachineHash();
|
|
12
|
-
if (!templateHash) {
|
|
13
|
-
this.error(`Cartesi machine snapshot not found, run '${this.config.bin} build'`);
|
|
14
|
-
}
|
|
15
|
-
this.logPrompt({
|
|
16
|
-
title: "Cartesi machine templateHash",
|
|
17
|
-
value: templateHash,
|
|
18
|
-
});
|
|
19
|
-
// ask for deployment type
|
|
20
|
-
const hosting = flags.hosting ||
|
|
21
|
-
(await select({
|
|
22
|
-
message: "Select hosting type",
|
|
23
|
-
choices: [
|
|
24
|
-
{
|
|
25
|
-
name: "Self-hosting",
|
|
26
|
-
description: `Select this option if you want to run the node for your application.
|
|
27
|
-
You will need the following infrastructure:
|
|
28
|
-
|
|
29
|
-
- a cloud server for the application node
|
|
30
|
-
- a postgres database
|
|
31
|
-
- a web3 node provider
|
|
32
|
-
- a funded wallet
|
|
33
|
-
`,
|
|
34
|
-
value: "self-hosted",
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
name: "Use third-party provider",
|
|
38
|
-
description: "Select this option to use a third-party service provider to run a node for your application.",
|
|
39
|
-
value: "third-party",
|
|
40
|
-
disabled: "(coming soon)",
|
|
41
|
-
},
|
|
42
|
-
],
|
|
43
|
-
}));
|
|
44
|
-
let queryString = "";
|
|
45
|
-
switch (hosting) {
|
|
46
|
-
case "self-hosted": {
|
|
47
|
-
// build docker image
|
|
48
|
-
await this.config.runCommand("deploy:build");
|
|
49
|
-
queryString = `?templateHash=${templateHash}`;
|
|
50
|
-
break;
|
|
51
|
-
}
|
|
52
|
-
case "third-party": {
|
|
53
|
-
this.error("Third-party provider deployment not supported yet");
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
// prompt user to open webapp for onchain deployment
|
|
57
|
-
const deployUrl = `${flags.webapp}${queryString}`;
|
|
58
|
-
if (await confirm({ message: `Open ${chalk.cyan(deployUrl)}?` })) {
|
|
59
|
-
open(deployUrl, { app: { name: apps.chrome } });
|
|
60
|
-
}
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
Deploy.summary = "Deploy application to a live network.";
|
|
65
|
-
Deploy.description = "Package and deploy the application to a supported live network.";
|
|
66
|
-
Deploy.examples = ["<%= config.bin %> <%= command.id %>"];
|
|
67
|
-
Deploy.flags = {
|
|
68
|
-
hosting: Flags.string({
|
|
69
|
-
options: ["self-hosted", "third-party"],
|
|
70
|
-
summary: "hosting type",
|
|
71
|
-
description: "Select wheather the user will host an application node himself, or use a third-party node provider",
|
|
72
|
-
}),
|
|
73
|
-
webapp: Flags.url({
|
|
74
|
-
description: "address of deploy webapp",
|
|
75
|
-
required: true,
|
|
76
|
-
}),
|
|
77
|
-
};
|
|
78
|
-
export default Deploy;
|