@cartesi/cli 2.0.0-alpha.11 → 2.0.0-alpha.13
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 +2 -2
- package/dist/base.d.ts.map +1 -1
- package/dist/base.js +9 -13
- 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/build.js +2 -2
- package/dist/commands/create.d.ts +5 -1
- package/dist/commands/create.d.ts.map +1 -1
- package/dist/commands/create.js +31 -4
- package/dist/commands/deploy.d.ts +16 -1
- package/dist/commands/deploy.d.ts.map +1 -1
- package/dist/commands/deploy.js +267 -8
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +3 -9
- package/dist/commands/{rollups/logs.d.ts → logs.d.ts} +2 -3
- package/dist/commands/logs.d.ts.map +1 -0
- package/dist/commands/{rollups/logs.js → logs.js} +4 -3
- package/dist/commands/run.js +2 -2
- 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/erc721.d.ts.map +1 -1
- package/dist/commands/send/erc721.js +1 -1
- package/dist/commands/send/generic.d.ts +2 -0
- package/dist/commands/send/generic.d.ts.map +1 -1
- package/dist/commands/send/generic.js +18 -10
- package/dist/commands/send.d.ts +1 -1
- package/dist/commands/send.d.ts.map +1 -1
- package/dist/commands/send.js +4 -4
- package/dist/commands/shell.js +1 -1
- package/dist/commands/{rollups/start.d.ts → start.d.ts} +3 -3
- package/dist/commands/start.d.ts.map +1 -0
- package/dist/commands/{rollups/start.js → start.js} +25 -16
- package/dist/commands/{rollups/status.d.ts → status.d.ts} +2 -3
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/{rollups/status.js → status.js} +7 -6
- package/dist/commands/stop.d.ts +5 -0
- package/dist/commands/stop.d.ts.map +1 -0
- package/dist/commands/{rollups/stop.js → stop.js} +4 -3
- package/dist/compose/{rollups/default.env → default.env} +5 -3
- package/dist/compose/docker-compose-anvil.yaml +39 -0
- package/dist/compose/{rollups/docker-compose-bundler.yaml → docker-compose-bundler.yaml} +36 -8
- package/dist/compose/docker-compose-espresso.yaml +81 -0
- package/dist/compose/docker-compose-explorer.yaml +92 -0
- package/dist/compose/docker-compose-graphql.yaml +38 -0
- package/dist/compose/docker-compose-node.yaml +53 -0
- package/dist/compose/docker-compose-passkey-server.yaml +37 -0
- package/dist/compose/docker-compose-paymaster.yaml +40 -0
- package/dist/compose/{rollups/docker-compose-proxy.yaml → docker-compose-proxy.yaml} +1 -1
- package/dist/config.d.ts +5 -4
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +23 -22
- package/dist/contracts.d.ts +22 -22
- package/dist/contracts.js +11 -11
- 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 +3 -3
- 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 +1 -1
- package/dist/exec/rollups.d.ts.map +1 -1
- package/dist/exec/util.d.ts +2 -2
- package/dist/exec/util.d.ts.map +1 -1
- package/dist/exec/util.js +6 -10
- package/dist/index.js +10 -4
- 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 +2 -2
- package/dist/template.d.ts.map +1 -1
- package/dist/template.js +2 -2
- package/dist/wallet.d.ts +1 -1
- package/dist/wallet.d.ts.map +1 -1
- package/dist/wallet.js +77 -93
- package/package.json +5 -6
- package/dist/commands/rollups/create.d.ts +0 -7
- package/dist/commands/rollups/create.d.ts.map +0 -1
- package/dist/commands/rollups/create.js +0 -36
- package/dist/commands/rollups/deploy.d.ts +0 -16
- package/dist/commands/rollups/deploy.d.ts.map +0 -1
- package/dist/commands/rollups/deploy.js +0 -237
- package/dist/commands/rollups/logs.d.ts.map +0 -1
- package/dist/commands/rollups/start.d.ts.map +0 -1
- package/dist/commands/rollups/status.d.ts.map +0 -1
- package/dist/commands/rollups/stop.d.ts +0 -5
- package/dist/commands/rollups/stop.d.ts.map +0 -1
- package/dist/commands/rollups.d.ts +0 -6
- package/dist/commands/rollups.d.ts.map +0 -1
- package/dist/commands/rollups.js +0 -21
- package/dist/compose/rollups/docker-compose-anvil.yaml +0 -17
- package/dist/compose/rollups/docker-compose-espresso.yaml +0 -68
- package/dist/compose/rollups/docker-compose-explorer.yaml +0 -57
- package/dist/compose/rollups/docker-compose-graphql.yaml +0 -23
- package/dist/compose/rollups/docker-compose-node.yaml +0 -26
- package/dist/compose/rollups/docker-compose-paymaster.yaml +0 -18
- package/dist/compose/rollups/proxy/anvil.yaml +0 -17
- package/dist/compose/rollups/proxy/bundler.yaml +0 -17
- package/dist/compose/rollups/proxy/espresso.yaml +0 -17
- package/dist/compose/rollups/proxy/explorer-api.yaml +0 -17
- package/dist/compose/rollups/proxy/explorer.yaml +0 -10
- package/dist/compose/rollups/proxy/graphql.yaml +0 -10
- package/dist/compose/rollups/proxy/paymaster.yaml +0 -17
- package/dist/compose/rollups/proxy/rollups-node.yaml +0 -17
- /package/dist/compose/{rollups/docker-compose-database.yaml → docker-compose-database.yaml} +0 -0
- /package/dist/compose/{rollups/docker-compose-node-cpus.yaml → docker-compose-node-cpus.yaml} +0 -0
- /package/dist/compose/{rollups/docker-compose-node-memory.yaml → docker-compose-node-memory.yaml} +0 -0
package/dist/wallet.js
CHANGED
|
@@ -5,21 +5,17 @@ import { mnemonicToAccount, privateKeyToAccount } from "viem/accounts";
|
|
|
5
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 (
|
|
12
|
+
if (includeDevnet) {
|
|
17
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;
|
|
@@ -75,44 +71,40 @@ const selectChain = async (options) => {
|
|
|
75
71
|
}
|
|
76
72
|
throw new Error(`Unsupported chainId ${options.chain.id}`);
|
|
77
73
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
});
|
|
90
|
-
}
|
|
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
|
+
});
|
|
91
85
|
};
|
|
92
86
|
const selectTransport = async (options, chain) => {
|
|
93
87
|
// use user provided url (in args) or try to use default one from chain, or ask for one
|
|
94
88
|
if (options.rpcUrl) {
|
|
95
89
|
return http(options.rpcUrl);
|
|
96
90
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
return http(defaultUrl);
|
|
108
|
-
}
|
|
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 = 6751; // 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);
|
|
109
101
|
}
|
|
110
|
-
const url = await input({
|
|
111
|
-
message: "RPC URL",
|
|
112
|
-
default: defaultUrl,
|
|
113
|
-
});
|
|
114
|
-
return http(url);
|
|
115
102
|
}
|
|
103
|
+
const url = await input({
|
|
104
|
+
message: "RPC URL",
|
|
105
|
+
default: defaultUrl,
|
|
106
|
+
});
|
|
107
|
+
return http(url);
|
|
116
108
|
};
|
|
117
109
|
const createPublicClient = async (chain, transport) => {
|
|
118
110
|
const publicClient = viemCreatePublicClient({ transport, chain });
|
|
@@ -144,9 +136,7 @@ const addressBalanceLabel = async (address, publicClient) => {
|
|
|
144
136
|
}
|
|
145
137
|
return `${address} ${balanceLabel}`;
|
|
146
138
|
}
|
|
147
|
-
|
|
148
|
-
return address;
|
|
149
|
-
}
|
|
139
|
+
return address;
|
|
150
140
|
};
|
|
151
141
|
const createWalletClient = async (options, chain, publicClient, publicTransport) => {
|
|
152
142
|
if (options.privateKey) {
|
|
@@ -158,7 +148,7 @@ const createWalletClient = async (options, chain, publicClient, publicTransport)
|
|
|
158
148
|
chain,
|
|
159
149
|
});
|
|
160
150
|
}
|
|
161
|
-
|
|
151
|
+
if (options.mnemonicPassphrase) {
|
|
162
152
|
// mnemonic specified
|
|
163
153
|
const account = mnemonicToAccount(options.mnemonicPassphrase, {
|
|
164
154
|
addressIndex: options.mnemonicIndex,
|
|
@@ -170,62 +160,56 @@ const createWalletClient = async (options, chain, publicClient, publicTransport)
|
|
|
170
160
|
chain,
|
|
171
161
|
});
|
|
172
162
|
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
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,
|
|
179
174
|
});
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
const mnemonic = await input({
|
|
183
|
-
message: "Mnemonic",
|
|
184
|
-
default: chain.id === cannon.id
|
|
185
|
-
? DEFAULT_DEVNET_MNEMONIC
|
|
186
|
-
: undefined,
|
|
187
|
-
});
|
|
188
|
-
// select account from mnemonic
|
|
189
|
-
if (options.mnemonicIndex) {
|
|
190
|
-
return viemCreateWalletClient({
|
|
191
|
-
transport: publicTransport,
|
|
192
|
-
chain,
|
|
193
|
-
account: mnemonicToAccount(mnemonic, {
|
|
194
|
-
addressIndex: options.mnemonicIndex,
|
|
195
|
-
}),
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
else {
|
|
199
|
-
const choices = await Promise.all([...Array(10)].map(async (_, addressIndex) => {
|
|
200
|
-
const account = mnemonicToAccount(mnemonic, {
|
|
201
|
-
addressIndex,
|
|
202
|
-
});
|
|
203
|
-
const name = await addressBalanceLabel(account.address, publicClient);
|
|
204
|
-
return { name, value: account };
|
|
205
|
-
}));
|
|
206
|
-
const account = await selectAuto({
|
|
207
|
-
message: "Account",
|
|
208
|
-
choices,
|
|
209
|
-
pageSize: choices.length,
|
|
210
|
-
});
|
|
211
|
-
return viemCreateWalletClient({
|
|
212
|
-
transport: publicTransport,
|
|
213
|
-
chain,
|
|
214
|
-
account,
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
else if (wallet === "private-key") {
|
|
219
|
-
const privateKey = await hexInput({ message: "Private Key" });
|
|
220
|
-
const account = privateKeyToAccount(privateKey);
|
|
175
|
+
// select account from mnemonic
|
|
176
|
+
if (options.mnemonicIndex) {
|
|
221
177
|
return viemCreateWalletClient({
|
|
222
178
|
transport: publicTransport,
|
|
223
179
|
chain,
|
|
224
|
-
account,
|
|
180
|
+
account: mnemonicToAccount(mnemonic, {
|
|
181
|
+
addressIndex: options.mnemonicIndex,
|
|
182
|
+
}),
|
|
225
183
|
});
|
|
226
184
|
}
|
|
227
|
-
|
|
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
|
+
});
|
|
228
211
|
}
|
|
212
|
+
throw new Error(`Unsupported wallet ${wallet}`);
|
|
229
213
|
};
|
|
230
214
|
const createClients = async (options) => {
|
|
231
215
|
// select chain
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cartesi/cli",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.13",
|
|
4
4
|
"description": "Cartesi CLI",
|
|
5
5
|
"author": "Danilo Tuler <tuler@pobox.com>",
|
|
6
6
|
"bin": {
|
|
@@ -42,8 +42,9 @@
|
|
|
42
42
|
"viem": "^2.23.6"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@
|
|
46
|
-
"@cartesi/
|
|
45
|
+
"@biomejs/biome": "^1.9.4",
|
|
46
|
+
"@cartesi/devnet": "2.0.0-alpha.7",
|
|
47
|
+
"@cartesi/rollups": "2.0.0",
|
|
47
48
|
"@types/bytes": "^3.1.5",
|
|
48
49
|
"@types/fs-extra": "^11.0.4",
|
|
49
50
|
"@types/inquirer": "^9.0.7",
|
|
@@ -56,14 +57,12 @@
|
|
|
56
57
|
"@vitest/coverage-istanbul": "^2.1.3",
|
|
57
58
|
"@wagmi/cli": "^2.2.0",
|
|
58
59
|
"copyfiles": "^2.4.1",
|
|
59
|
-
"eslint": "^8.57.0",
|
|
60
60
|
"npm-run-all": "^4.1.5",
|
|
61
61
|
"rimraf": "^6.0.1",
|
|
62
62
|
"ts-node": "^10.9.2",
|
|
63
63
|
"tslib": "^2.8.1",
|
|
64
64
|
"typescript": "^5.8.2",
|
|
65
65
|
"vitest": "^2.1.3",
|
|
66
|
-
"@cartesi/eslint-config": "0.0.0",
|
|
67
66
|
"tsconfig": "0.0.0"
|
|
68
67
|
},
|
|
69
68
|
"engines": {
|
|
@@ -79,7 +78,7 @@
|
|
|
79
78
|
"compile": "tsc -p tsconfig.build.json",
|
|
80
79
|
"postcompile": "chmod +x dist/index.js",
|
|
81
80
|
"copy-files": "copyfiles -u 1 \"src/**/*.yaml\" \"src/**/*.env\" \"src/**/*.txt\" dist",
|
|
82
|
-
"lint": "
|
|
81
|
+
"lint": "biome lint",
|
|
83
82
|
"posttest": "pnpm lint",
|
|
84
83
|
"test": "vitest"
|
|
85
84
|
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Command } from "@commander-js/extra-typings";
|
|
2
|
-
export declare const DEFAULT_TEMPLATES_BRANCH = "prerelease/sdk-12";
|
|
3
|
-
export declare const createCreateCommand: () => Command<[string], {
|
|
4
|
-
template: "cpp" | "cpp-low-level" | "go" | "javascript" | "lua" | "python" | "ruby" | "rust" | "typescript";
|
|
5
|
-
branch: string;
|
|
6
|
-
}, {}>;
|
|
7
|
-
//# sourceMappingURL=create.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/commands/rollups/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAU,MAAM,6BAA6B,CAAC;AAK9D,eAAO,MAAM,wBAAwB,sBAAsB,CAAC;AAc5D,eAAO,MAAM,mBAAmB;;;MA+B/B,CAAC"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { Command, Option } from "@commander-js/extra-typings";
|
|
2
|
-
import chalk from "chalk";
|
|
3
|
-
import ora from "ora";
|
|
4
|
-
import { download } from "../../template.js";
|
|
5
|
-
export const DEFAULT_TEMPLATES_BRANCH = "prerelease/sdk-12";
|
|
6
|
-
const TEMPLATES = [
|
|
7
|
-
"cpp",
|
|
8
|
-
"cpp-low-level",
|
|
9
|
-
"go",
|
|
10
|
-
"javascript",
|
|
11
|
-
"lua",
|
|
12
|
-
"python",
|
|
13
|
-
"ruby",
|
|
14
|
-
"rust",
|
|
15
|
-
"typescript",
|
|
16
|
-
];
|
|
17
|
-
export const createCreateCommand = () => {
|
|
18
|
-
return new Command("create")
|
|
19
|
-
.argument("<name>", "application and directory name")
|
|
20
|
-
.addOption(new Option("-t, --template <template>", "template name to use")
|
|
21
|
-
.choices(TEMPLATES)
|
|
22
|
-
.makeOptionMandatory())
|
|
23
|
-
.option("-b, --branch <branch>", "cartesi/application-templates repository branch name to use", DEFAULT_TEMPLATES_BRANCH)
|
|
24
|
-
.action(async (name, { branch, template }) => {
|
|
25
|
-
const spinner = ora("Creating application...").start();
|
|
26
|
-
try {
|
|
27
|
-
const { dir } = await download("rollups", template, branch, name);
|
|
28
|
-
spinner.succeed(`Application created at ${chalk.cyan(dir)}`);
|
|
29
|
-
}
|
|
30
|
-
catch (e) {
|
|
31
|
-
spinner.fail(e instanceof Error
|
|
32
|
-
? `Error creating application: ${chalk.red(e.message)}`
|
|
33
|
-
: String(e));
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Command } from "@commander-js/extra-typings";
|
|
2
|
-
export declare const createDeployCommand: () => Command<[], {
|
|
3
|
-
chainId: number;
|
|
4
|
-
rpcUrl?: string | undefined;
|
|
5
|
-
mnemonic?: string | undefined;
|
|
6
|
-
mnemonicIndex: number;
|
|
7
|
-
name?: string | undefined;
|
|
8
|
-
authorityOwner?: `0x${string}` | undefined;
|
|
9
|
-
applicationOwner?: `0x${string}` | undefined;
|
|
10
|
-
epochLength: number;
|
|
11
|
-
salt: `0x${string}`;
|
|
12
|
-
json?: true | undefined;
|
|
13
|
-
}, {
|
|
14
|
-
environmentName: string;
|
|
15
|
-
}>;
|
|
16
|
-
//# sourceMappingURL=deploy.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../../src/commands/rollups/deploy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAU,MAAM,6BAA6B,CAAC;AAoP9D,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;EAqG/B,CAAC"}
|
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
import { Command, Option } from "@commander-js/extra-typings";
|
|
2
|
-
import input from "@inquirer/input";
|
|
3
|
-
import chalk from "chalk";
|
|
4
|
-
import { execa } from "execa";
|
|
5
|
-
import ora from "ora";
|
|
6
|
-
import { encodeFunctionData, zeroHash, } from "viem";
|
|
7
|
-
import { cannon } from "viem/chains";
|
|
8
|
-
import { getContextPath, getMachineHash, parseAddress, parseHash, } from "../../base.js";
|
|
9
|
-
import { applicationFactoryAbi, applicationFactoryAddress, authorityFactoryAbi, authorityFactoryAddress, dataAvailabilityAbi, inputBoxAddress, } from "../../contracts.js";
|
|
10
|
-
import { addressInput } from "../../prompts.js";
|
|
11
|
-
import { connect } from "../send.js";
|
|
12
|
-
/**
|
|
13
|
-
* Deploy authority contract (if not already deployed)
|
|
14
|
-
* @param options
|
|
15
|
-
* @returns address of the authority
|
|
16
|
-
*/
|
|
17
|
-
const deployAuthority = async (publicClient, walletClient, options) => {
|
|
18
|
-
const { epochLength, progress, salt } = options;
|
|
19
|
-
// deploy authority contract (if not already deployed)
|
|
20
|
-
const authorityOwner = options.authorityOwner ||
|
|
21
|
-
(await addressInput({
|
|
22
|
-
message: "Authority Owner",
|
|
23
|
-
default: walletClient.account?.address,
|
|
24
|
-
}));
|
|
25
|
-
const authorityAddress = await publicClient.readContract({
|
|
26
|
-
abi: authorityFactoryAbi,
|
|
27
|
-
address: authorityFactoryAddress,
|
|
28
|
-
functionName: "calculateAuthorityAddress",
|
|
29
|
-
args: [authorityOwner, BigInt(epochLength), salt],
|
|
30
|
-
});
|
|
31
|
-
// check if authority is already deployed
|
|
32
|
-
const authorityCode = await publicClient.getCode({
|
|
33
|
-
address: authorityAddress,
|
|
34
|
-
});
|
|
35
|
-
if (authorityCode === undefined) {
|
|
36
|
-
// deploy authority
|
|
37
|
-
const { request } = await publicClient.simulateContract({
|
|
38
|
-
abi: authorityFactoryAbi,
|
|
39
|
-
address: authorityFactoryAddress,
|
|
40
|
-
account: walletClient.account,
|
|
41
|
-
functionName: "newAuthority",
|
|
42
|
-
args: [authorityOwner, BigInt(epochLength), salt],
|
|
43
|
-
});
|
|
44
|
-
progress.start("Deploying authority...");
|
|
45
|
-
const hash = await walletClient.writeContract(request);
|
|
46
|
-
await publicClient.waitForTransactionReceipt({ hash });
|
|
47
|
-
progress.succeed(`Authority ${chalk.cyan(authorityAddress)}`);
|
|
48
|
-
}
|
|
49
|
-
return authorityAddress;
|
|
50
|
-
};
|
|
51
|
-
/**
|
|
52
|
-
* Deploy application contract
|
|
53
|
-
* @param options
|
|
54
|
-
* @returns address of the application
|
|
55
|
-
*/
|
|
56
|
-
const deployApplication = async (publicClient, walletClient, options) => {
|
|
57
|
-
const { authorityAddress, progress, salt, templateHash } = options;
|
|
58
|
-
const applicationOwner = options.applicationOwner ||
|
|
59
|
-
(await addressInput({
|
|
60
|
-
message: "Application Owner",
|
|
61
|
-
default: walletClient.account?.address,
|
|
62
|
-
}));
|
|
63
|
-
// create data availability descriptor for InputBox only
|
|
64
|
-
const dataAvailability = encodeFunctionData({
|
|
65
|
-
abi: dataAvailabilityAbi,
|
|
66
|
-
functionName: "InputBox",
|
|
67
|
-
args: [inputBoxAddress],
|
|
68
|
-
});
|
|
69
|
-
const applicationAddress = await publicClient.readContract({
|
|
70
|
-
abi: applicationFactoryAbi,
|
|
71
|
-
address: applicationFactoryAddress,
|
|
72
|
-
functionName: "calculateApplicationAddress",
|
|
73
|
-
args: [
|
|
74
|
-
authorityAddress,
|
|
75
|
-
applicationOwner,
|
|
76
|
-
templateHash,
|
|
77
|
-
dataAvailability,
|
|
78
|
-
salt,
|
|
79
|
-
],
|
|
80
|
-
});
|
|
81
|
-
// check if application is already deployed
|
|
82
|
-
const applicationCode = await publicClient.getCode({
|
|
83
|
-
address: applicationAddress,
|
|
84
|
-
});
|
|
85
|
-
if (applicationCode === undefined) {
|
|
86
|
-
// deploy application
|
|
87
|
-
const { request } = await publicClient.simulateContract({
|
|
88
|
-
abi: applicationFactoryAbi,
|
|
89
|
-
address: applicationFactoryAddress,
|
|
90
|
-
account: walletClient.account,
|
|
91
|
-
functionName: "newApplication",
|
|
92
|
-
args: [
|
|
93
|
-
authorityAddress,
|
|
94
|
-
applicationOwner,
|
|
95
|
-
templateHash,
|
|
96
|
-
dataAvailability,
|
|
97
|
-
salt,
|
|
98
|
-
],
|
|
99
|
-
});
|
|
100
|
-
progress.start("Deploying application...");
|
|
101
|
-
const hash = await walletClient.writeContract(request);
|
|
102
|
-
await publicClient.waitForTransactionReceipt({ hash });
|
|
103
|
-
progress.succeed(`Application ${chalk.cyan(applicationAddress)}`);
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
// abort, because application is already deployed
|
|
107
|
-
throw new Error(`Application ${chalk.cyan(templateHash)} already deployed to ${chalk.cyan(applicationAddress)}`);
|
|
108
|
-
}
|
|
109
|
-
return applicationAddress;
|
|
110
|
-
};
|
|
111
|
-
/**
|
|
112
|
-
* Publish machine snapshot to rollups node by copying it to the rollups node container
|
|
113
|
-
* @param options
|
|
114
|
-
* @returns path to the snapshot in the rollups node
|
|
115
|
-
*/
|
|
116
|
-
const publishMachine = async (options) => {
|
|
117
|
-
const { progress, environmentName, templateHash } = options;
|
|
118
|
-
const snapshotPath = getContextPath("image");
|
|
119
|
-
const containerSnapshotPath = `/var/lib/cartesi-rollups-node/snapshots/${templateHash}/`;
|
|
120
|
-
progress.start("Publishing machine snapshot...");
|
|
121
|
-
await execa("docker", [
|
|
122
|
-
"compose",
|
|
123
|
-
"--project-name",
|
|
124
|
-
environmentName,
|
|
125
|
-
"cp",
|
|
126
|
-
snapshotPath,
|
|
127
|
-
`rollups-node:${containerSnapshotPath}`,
|
|
128
|
-
]);
|
|
129
|
-
progress.succeed(`Machine snapshot ${chalk.cyan(containerSnapshotPath)}`);
|
|
130
|
-
return containerSnapshotPath;
|
|
131
|
-
};
|
|
132
|
-
/**
|
|
133
|
-
* Register application in rollups node
|
|
134
|
-
* @param options
|
|
135
|
-
* @returns name of the application
|
|
136
|
-
*/
|
|
137
|
-
const registerApplication = async (options) => {
|
|
138
|
-
const { applicationAddress, progress, environmentName, snapshotPath } = options;
|
|
139
|
-
// use template hash as the name of the deployment
|
|
140
|
-
const name = options.name ??
|
|
141
|
-
(await input({
|
|
142
|
-
message: "Application Name",
|
|
143
|
-
default: applicationAddress.toLowerCase(),
|
|
144
|
-
}));
|
|
145
|
-
// deploy application
|
|
146
|
-
progress.start("Registering application...");
|
|
147
|
-
const { stdout } = await execa("docker", [
|
|
148
|
-
"compose",
|
|
149
|
-
"--project-name",
|
|
150
|
-
environmentName,
|
|
151
|
-
"exec",
|
|
152
|
-
"rollups-node",
|
|
153
|
-
"cartesi-rollups-cli",
|
|
154
|
-
"app",
|
|
155
|
-
"register",
|
|
156
|
-
"--name",
|
|
157
|
-
name,
|
|
158
|
-
"--address",
|
|
159
|
-
applicationAddress,
|
|
160
|
-
"--template-path",
|
|
161
|
-
snapshotPath,
|
|
162
|
-
"--print-json",
|
|
163
|
-
]);
|
|
164
|
-
const registration = stdout ? JSON.parse(stdout) : undefined;
|
|
165
|
-
if (registration) {
|
|
166
|
-
if (registration.state !== "ENABLED") {
|
|
167
|
-
throw new Error(registration.reason);
|
|
168
|
-
}
|
|
169
|
-
progress.succeed(`Registration ${chalk.cyan(name)}`);
|
|
170
|
-
}
|
|
171
|
-
else {
|
|
172
|
-
throw new Error("Failed to deploy application");
|
|
173
|
-
}
|
|
174
|
-
return name;
|
|
175
|
-
};
|
|
176
|
-
export const createDeployCommand = () => {
|
|
177
|
-
return new Command("deploy")
|
|
178
|
-
.description("Deploy a rollups application to a rollups node.")
|
|
179
|
-
.configureHelp({ showGlobalOptions: true })
|
|
180
|
-
.option("--chain-id <id>", "Chain ID", parseInt, 13370)
|
|
181
|
-
.option("--rpc-url <url>", "RPC URL")
|
|
182
|
-
.option("--mnemonic <phrase>", "Mnemonic passphrase")
|
|
183
|
-
.option("--mnemonic-index <index>", "Mnemonic account index", parseInt, 0)
|
|
184
|
-
.option("--name <string>", "application name")
|
|
185
|
-
.option("--authority-owner <address>", "authority owner", parseAddress, undefined)
|
|
186
|
-
.option("--application-owner <address>", "application owner", parseAddress, undefined)
|
|
187
|
-
.addOption(new Option("--epoch-length <number>", "length of an epoch (in blocks)")
|
|
188
|
-
.argParser(Number)
|
|
189
|
-
.default(720))
|
|
190
|
-
.option("--salt <hash>", "salt for deployment", parseHash, zeroHash)
|
|
191
|
-
.option("--json", "output in JSON format")
|
|
192
|
-
.action(async (options, command) => {
|
|
193
|
-
const rollupsOptions = command.optsWithGlobals();
|
|
194
|
-
const { environmentName } = rollupsOptions;
|
|
195
|
-
const { json } = options;
|
|
196
|
-
// XXX: json support is not implemented yet
|
|
197
|
-
// if case of json maybe we should not support interactive mode
|
|
198
|
-
const progress = ora();
|
|
199
|
-
// get cartesi machine snapshot hash, produced by 'build'
|
|
200
|
-
const templateHash = getMachineHash();
|
|
201
|
-
if (!templateHash) {
|
|
202
|
-
progress.fail(`Cartesi machine snapshot not found, run 'build'`);
|
|
203
|
-
return;
|
|
204
|
-
}
|
|
205
|
-
progress.succeed(`Cartesi machine template hash ${chalk.cyan(templateHash)}`);
|
|
206
|
-
// connect to some chain
|
|
207
|
-
const { publicClient, walletClient } = await connect(options);
|
|
208
|
-
try {
|
|
209
|
-
// deploy authority contract (if not already deployed)
|
|
210
|
-
const authorityAddress = await deployAuthority(publicClient, walletClient, { progress, ...options });
|
|
211
|
-
// deploy application contract
|
|
212
|
-
const applicationAddress = await deployApplication(publicClient, walletClient, { authorityAddress, progress, templateHash, ...options });
|
|
213
|
-
if (publicClient.chain?.id === cannon.id) {
|
|
214
|
-
// copy machine snapshot to rollups node container
|
|
215
|
-
const containerSnapshotPath = await publishMachine({
|
|
216
|
-
progress,
|
|
217
|
-
templateHash,
|
|
218
|
-
environmentName,
|
|
219
|
-
});
|
|
220
|
-
const name = await registerApplication({
|
|
221
|
-
applicationAddress,
|
|
222
|
-
progress,
|
|
223
|
-
snapshotPath: containerSnapshotPath,
|
|
224
|
-
...options,
|
|
225
|
-
...rollupsOptions,
|
|
226
|
-
});
|
|
227
|
-
}
|
|
228
|
-
else {
|
|
229
|
-
const snapshotPath = getContextPath("image");
|
|
230
|
-
progress.succeed(`Done. Manually copy machine to rollups node ${chalk.cyan(snapshotPath)}`);
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
catch (e) {
|
|
234
|
-
progress.fail(e instanceof Error ? e.message : "Unknown error");
|
|
235
|
-
}
|
|
236
|
-
});
|
|
237
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logs.d.ts","sourceRoot":"","sources":["../../../src/commands/rollups/logs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAItD,eAAO,MAAM,iBAAiB;;;;;;;;EAuC7B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../../../src/commands/rollups/start.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAU,MAAM,6BAA6B,CAAC;AA4I9D,eAAO,MAAM,kBAAkB;;;;;;;;;;;EAkK9B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../src/commands/rollups/status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAOtD,eAAO,MAAM,mBAAmB;;;;EA8C/B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stop.d.ts","sourceRoot":"","sources":["../../../src/commands/rollups/stop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAMtD,eAAO,MAAM,iBAAiB;;EAwB7B,CAAC"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { Command } from "@commander-js/extra-typings";
|
|
2
|
-
export declare const createRollupsCommand: () => Command<[], {
|
|
3
|
-
environmentName: string;
|
|
4
|
-
}, {}>;
|
|
5
|
-
export type RollupsCommandOpts = ReturnType<ReturnType<typeof createRollupsCommand>["opts"]>;
|
|
6
|
-
//# sourceMappingURL=rollups.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rollups.d.ts","sourceRoot":"","sources":["../../src/commands/rollups.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAQtD,eAAO,MAAM,oBAAoB;;MAiBhC,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,UAAU,CACvC,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAClD,CAAC"}
|
package/dist/commands/rollups.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Command } from "@commander-js/extra-typings";
|
|
2
|
-
import { createCreateCommand } from "./rollups/create.js";
|
|
3
|
-
import { createDeployCommand } from "./rollups/deploy.js";
|
|
4
|
-
import { createLogsCommand } from "./rollups/logs.js";
|
|
5
|
-
import { createStartCommand } from "./rollups/start.js";
|
|
6
|
-
import { createStatusCommand } from "./rollups/status.js";
|
|
7
|
-
import { createStopCommand } from "./rollups/stop.js";
|
|
8
|
-
export const createRollupsCommand = () => {
|
|
9
|
-
const command = new Command("rollups")
|
|
10
|
-
.option("--environment-name <string>", "name of environment", "cartesi-rollups")
|
|
11
|
-
.action(async (_options, program) => {
|
|
12
|
-
program.help();
|
|
13
|
-
});
|
|
14
|
-
command.addCommand(createLogsCommand());
|
|
15
|
-
command.addCommand(createStartCommand());
|
|
16
|
-
command.addCommand(createStatusCommand());
|
|
17
|
-
command.addCommand(createStopCommand());
|
|
18
|
-
command.addCommand(createDeployCommand());
|
|
19
|
-
command.addCommand(createCreateCommand());
|
|
20
|
-
return command;
|
|
21
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
services:
|
|
2
|
-
anvil:
|
|
3
|
-
image: ${CARTESI_SDK_IMAGE}
|
|
4
|
-
command: ["devnet", "--block-time", "${BLOCK_TIME:-5}"]
|
|
5
|
-
healthcheck:
|
|
6
|
-
test: ["CMD", "eth_isready"]
|
|
7
|
-
start_period: 10s
|
|
8
|
-
start_interval: 200ms
|
|
9
|
-
interval: 10s
|
|
10
|
-
timeout: 1s
|
|
11
|
-
retries: 5
|
|
12
|
-
environment:
|
|
13
|
-
ANVIL_IP_ADDR: 0.0.0.0
|
|
14
|
-
|
|
15
|
-
proxy:
|
|
16
|
-
volumes:
|
|
17
|
-
- ./proxy/anvil.yaml:/etc/traefik/conf.d/anvil.yaml
|