@cartesi/cli 2.0.0-alpha.2 → 2.0.0-alpha.20
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 +28 -0
- package/dist/base.d.ts.map +1 -0
- package/dist/base.js +109 -0
- package/dist/builder/directory.d.ts +2 -2
- package/dist/builder/directory.d.ts.map +1 -1
- package/dist/builder/directory.js +5 -3
- package/dist/builder/docker.d.ts +2 -2
- package/dist/builder/docker.d.ts.map +1 -1
- package/dist/builder/docker.js +39 -37
- package/dist/builder/empty.d.ts +1 -1
- package/dist/builder/empty.d.ts.map +1 -1
- package/dist/builder/empty.js +1 -1
- package/dist/builder/none.d.ts +1 -1
- package/dist/builder/none.d.ts.map +1 -1
- package/dist/builder/none.js +1 -1
- package/dist/builder/tar.d.ts +1 -1
- package/dist/builder/tar.d.ts.map +1 -1
- package/dist/builder/tar.js +1 -1
- package/dist/commands/address-book.d.ts +5 -8
- package/dist/commands/address-book.d.ts.map +1 -1
- package/dist/commands/address-book.js +18 -14
- package/dist/commands/build.d.ts +7 -11
- package/dist/commands/build.d.ts.map +1 -1
- package/dist/commands/build.js +82 -58
- 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 +25 -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 +3 -0
- package/dist/commands/deploy.d.ts.map +1 -0
- package/dist/commands/deploy.js +12 -0
- package/dist/commands/deposit/erc1155.d.ts +18 -0
- package/dist/commands/deposit/erc1155.d.ts.map +1 -0
- package/dist/commands/deposit/erc1155.js +254 -0
- package/dist/commands/deposit/erc20.d.ts +10 -0
- package/dist/commands/deposit/erc20.d.ts.map +1 -0
- package/dist/commands/deposit/erc20.js +125 -0
- package/dist/commands/deposit/erc721.d.ts +10 -0
- package/dist/commands/deposit/erc721.d.ts.map +1 -0
- package/dist/commands/deposit/erc721.js +143 -0
- package/dist/commands/deposit/ether.d.ts +10 -0
- package/dist/commands/deposit/ether.d.ts.map +1 -0
- package/dist/commands/deposit/ether.js +65 -0
- package/dist/commands/deposit.d.ts +9 -0
- package/dist/commands/deposit.d.ts.map +1 -0
- package/dist/commands/deposit.js +37 -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 +9 -0
- package/dist/commands/logs.d.ts.map +1 -0
- package/dist/commands/logs.js +34 -0
- package/dist/commands/run.d.ts +14 -20
- package/dist/commands/run.d.ts.map +1 -1
- package/dist/commands/run.js +193 -182
- package/dist/commands/send.d.ts +10 -0
- package/dist/commands/send.d.ts.map +1 -0
- package/dist/commands/send.js +130 -0
- package/dist/commands/shell.d.ts +6 -14
- package/dist/commands/shell.d.ts.map +1 -1
- package/dist/commands/shell.js +34 -51
- package/dist/commands/status.d.ts +6 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +50 -0
- package/dist/compose/default.env +36 -0
- package/dist/compose/docker-compose-anvil.yaml +39 -0
- package/dist/compose/docker-compose-bundler.yaml +71 -0
- package/dist/{node → compose}/docker-compose-database.yaml +4 -2
- package/dist/compose/docker-compose-explorer.yaml +96 -0
- package/dist/compose/docker-compose-graphql.yaml +38 -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 +50 -0
- package/dist/compose/docker-compose-passkey-server.yaml +37 -0
- package/dist/compose/docker-compose-paymaster.yaml +40 -0
- package/dist/compose/docker-compose-proxy.yaml +24 -0
- package/dist/config.d.ts +30 -9
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +93 -53
- 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 +3 -5
- package/dist/exec/genext2fs.d.ts +6 -3
- package/dist/exec/genext2fs.d.ts.map +1 -1
- package/dist/exec/genext2fs.js +5 -5
- package/dist/exec/index.d.ts +0 -1
- package/dist/exec/index.d.ts.map +1 -1
- package/dist/exec/index.js +0 -1
- package/dist/exec/mksquashfs.d.ts +2 -2
- package/dist/exec/mksquashfs.d.ts.map +1 -1
- package/dist/exec/mksquashfs.js +4 -2
- package/dist/exec/rollups.d.ts +105 -0
- package/dist/exec/rollups.d.ts.map +1 -0
- package/dist/exec/rollups.js +383 -0
- package/dist/exec/util.d.ts +1 -16
- package/dist/exec/util.d.ts.map +1 -1
- package/dist/exec/util.js +3 -50
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +57 -1
- package/dist/machine.d.ts +8 -2
- package/dist/machine.d.ts.map +1 -1
- package/dist/machine.js +26 -16
- package/dist/prompts.d.ts +13 -2
- package/dist/prompts.d.ts.map +1 -1
- package/dist/prompts.js +60 -26
- 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 +9222 -21
- package/dist/wallet.d.ts.map +1 -1
- package/dist/wallet.js +35 -198
- package/package.json +39 -57
- 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/erc20.d.ts +0 -14
- package/dist/commands/send/erc20.d.ts.map +0 -1
- package/dist/commands/send/erc20.js +0 -70
- package/dist/commands/send/erc721.d.ts +0 -14
- package/dist/commands/send/erc721.d.ts.map +0 -1
- package/dist/commands/send/erc721.js +0 -73
- package/dist/commands/send/ether.d.ts +0 -13
- package/dist/commands/send/ether.d.ts.map +0 -1
- package/dist/commands/send/ether.js +0 -32
- package/dist/commands/send/generic.d.ts +0 -15
- package/dist/commands/send/generic.d.ts.map +0 -1
- package/dist/commands/send/generic.js +0 -119
- 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/exec/crane.d.ts +0 -15
- package/dist/exec/crane.d.ts.map +0 -1
- package/dist/exec/crane.js +0 -17
- 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
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
configs:
|
|
2
|
+
rollups_node_proxy:
|
|
3
|
+
content: |
|
|
4
|
+
http:
|
|
5
|
+
routers:
|
|
6
|
+
inspect_server:
|
|
7
|
+
rule: "PathPrefix(`/inspect`)"
|
|
8
|
+
service: inspect_server
|
|
9
|
+
rpc_server:
|
|
10
|
+
rule: "PathPrefix(`/rpc`)"
|
|
11
|
+
service: rpc_server
|
|
12
|
+
services:
|
|
13
|
+
inspect_server:
|
|
14
|
+
loadBalancer:
|
|
15
|
+
servers:
|
|
16
|
+
- url: "http://rollups-node:10012"
|
|
17
|
+
rpc_server:
|
|
18
|
+
loadBalancer:
|
|
19
|
+
servers:
|
|
20
|
+
- url: "http://rollups-node:10011"
|
|
21
|
+
|
|
22
|
+
services:
|
|
23
|
+
rollups-node:
|
|
24
|
+
image: cartesi/rollups-runtime:${CARTESI_SDK_VERSION}
|
|
25
|
+
depends_on:
|
|
26
|
+
database:
|
|
27
|
+
condition: service_healthy
|
|
28
|
+
anvil:
|
|
29
|
+
condition: service_healthy
|
|
30
|
+
expose:
|
|
31
|
+
- "10000"
|
|
32
|
+
- "10011"
|
|
33
|
+
- "10012"
|
|
34
|
+
healthcheck:
|
|
35
|
+
test: ["CMD", "curl", "-fsS", "http://127.0.0.1:10000/livez"]
|
|
36
|
+
start_period: 10s
|
|
37
|
+
start_interval: 200ms
|
|
38
|
+
interval: 10s
|
|
39
|
+
timeout: 1s
|
|
40
|
+
retries: 5
|
|
41
|
+
command: ["cartesi-rollups-node"]
|
|
42
|
+
env_file:
|
|
43
|
+
- ${CARTESI_BIN_PATH}/compose/default.env
|
|
44
|
+
volumes:
|
|
45
|
+
- ./.cartesi:/var/lib/cartesi-rollups-node/snapshots:ro
|
|
46
|
+
|
|
47
|
+
proxy:
|
|
48
|
+
configs:
|
|
49
|
+
- source: rollups_node_proxy
|
|
50
|
+
target: /etc/traefik/conf.d/rollups-node.yaml
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
configs:
|
|
2
|
+
passkey_server_proxy:
|
|
3
|
+
content: |
|
|
4
|
+
http:
|
|
5
|
+
routers:
|
|
6
|
+
passkey-server:
|
|
7
|
+
rule: "PathPrefix(`/passkey`)"
|
|
8
|
+
middlewares:
|
|
9
|
+
- "remove-passkey-server-prefix"
|
|
10
|
+
service: passkey-server
|
|
11
|
+
middlewares:
|
|
12
|
+
remove-passkey-server-prefix:
|
|
13
|
+
replacePathRegex:
|
|
14
|
+
regex: "^/passkey/(.*)"
|
|
15
|
+
replacement: "/$1"
|
|
16
|
+
services:
|
|
17
|
+
passkey-server:
|
|
18
|
+
loadBalancer:
|
|
19
|
+
servers:
|
|
20
|
+
- url: "http://passkey-server:3000"
|
|
21
|
+
|
|
22
|
+
services:
|
|
23
|
+
passkey-server:
|
|
24
|
+
image: ${CARTESI_SDK_IMAGE}
|
|
25
|
+
command: ["passkey-server"]
|
|
26
|
+
healthcheck:
|
|
27
|
+
test: ["CMD", "curl", "-fsS", "http://127.0.0.1:3000/health"]
|
|
28
|
+
start_period: 10s
|
|
29
|
+
start_interval: 200ms
|
|
30
|
+
interval: 10s
|
|
31
|
+
timeout: 1s
|
|
32
|
+
retries: 5
|
|
33
|
+
|
|
34
|
+
proxy:
|
|
35
|
+
configs:
|
|
36
|
+
- source: passkey_server_proxy
|
|
37
|
+
target: /etc/traefik/conf.d/passkey-server.yaml
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
configs:
|
|
2
|
+
paymaster_proxy:
|
|
3
|
+
content: |
|
|
4
|
+
http:
|
|
5
|
+
routers:
|
|
6
|
+
paymaster:
|
|
7
|
+
rule: "PathPrefix(`/paymaster`)"
|
|
8
|
+
middlewares:
|
|
9
|
+
- "remove-paymaster-prefix"
|
|
10
|
+
service: paymaster
|
|
11
|
+
middlewares:
|
|
12
|
+
remove-paymaster-prefix:
|
|
13
|
+
replacePathRegex:
|
|
14
|
+
regex: "^/paymaster/(.*)"
|
|
15
|
+
replacement: "/$1"
|
|
16
|
+
services:
|
|
17
|
+
paymaster:
|
|
18
|
+
loadBalancer:
|
|
19
|
+
servers:
|
|
20
|
+
- url: "http://paymaster:3000"
|
|
21
|
+
|
|
22
|
+
services:
|
|
23
|
+
paymaster:
|
|
24
|
+
image: ${CARTESI_SDK_IMAGE}
|
|
25
|
+
command: "mock-verifying-paymaster"
|
|
26
|
+
environment:
|
|
27
|
+
- ALTO_RPC=http://bundler:4337
|
|
28
|
+
- ANVIL_RPC=http://anvil:8545
|
|
29
|
+
healthcheck:
|
|
30
|
+
test: ["CMD", "curl", "-fsS", "http://127.0.0.1:3000/ping"]
|
|
31
|
+
start_period: 10s
|
|
32
|
+
start_interval: 200ms
|
|
33
|
+
interval: 10s
|
|
34
|
+
timeout: 1s
|
|
35
|
+
retries: 5
|
|
36
|
+
|
|
37
|
+
proxy:
|
|
38
|
+
configs:
|
|
39
|
+
- source: paymaster_proxy
|
|
40
|
+
target: /etc/traefik/conf.d/paymaster.yaml
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
services:
|
|
2
|
+
proxy:
|
|
3
|
+
image: traefik:v3.3.4
|
|
4
|
+
healthcheck:
|
|
5
|
+
test: ["CMD", "traefik", "healthcheck", "--ping"]
|
|
6
|
+
start_period: 10s
|
|
7
|
+
start_interval: 200ms
|
|
8
|
+
interval: 10s
|
|
9
|
+
timeout: 1s
|
|
10
|
+
retries: 5
|
|
11
|
+
command:
|
|
12
|
+
[
|
|
13
|
+
"--ping=true",
|
|
14
|
+
"--entryPoints.web.address=:8088",
|
|
15
|
+
"--entryPoints.traefik.address=:8080",
|
|
16
|
+
"--metrics.prometheus=true",
|
|
17
|
+
"--metrics.prometheus.addServicesLabels=true",
|
|
18
|
+
"--providers.file.directory=/etc/traefik/conf.d",
|
|
19
|
+
"--providers.file.watch=true",
|
|
20
|
+
"--log",
|
|
21
|
+
"--log.level=INFO",
|
|
22
|
+
]
|
|
23
|
+
ports:
|
|
24
|
+
- ${CARTESI_LISTEN_PORT:-6751}:8088
|
package/dist/config.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TomlPrimitive } from "smol-toml";
|
|
1
|
+
import { type TomlPrimitive } from "smol-toml";
|
|
2
2
|
/**
|
|
3
3
|
* Typed Errors
|
|
4
4
|
*/
|
|
@@ -29,7 +29,9 @@ export declare class RequiredFieldError extends Error {
|
|
|
29
29
|
export declare class InvalidStringArrayError extends Error {
|
|
30
30
|
constructor();
|
|
31
31
|
}
|
|
32
|
-
export declare const
|
|
32
|
+
export declare const DEFAULT_SDK_VERSION = "0.12.0-alpha.24";
|
|
33
|
+
export declare const DEFAULT_SDK_IMAGE = "cartesi/sdk";
|
|
34
|
+
export declare const PREFERRED_PORT = 6751;
|
|
33
35
|
type DriveFormat = "ext2" | "sqfs";
|
|
34
36
|
export type ImageInfo = {
|
|
35
37
|
cmd: string[];
|
|
@@ -37,7 +39,7 @@ export type ImageInfo = {
|
|
|
37
39
|
env: string[];
|
|
38
40
|
workdir: string;
|
|
39
41
|
};
|
|
40
|
-
export type DriveResult = ImageInfo | undefined
|
|
42
|
+
export type DriveResult = ImageInfo | undefined;
|
|
41
43
|
export type DirectoryDriveConfig = {
|
|
42
44
|
builder: "directory";
|
|
43
45
|
extraSize: number;
|
|
@@ -46,6 +48,7 @@ export type DirectoryDriveConfig = {
|
|
|
46
48
|
};
|
|
47
49
|
export type DockerDriveConfig = {
|
|
48
50
|
builder: "docker";
|
|
51
|
+
buildArgs: string[];
|
|
49
52
|
context: string;
|
|
50
53
|
dockerfile: string;
|
|
51
54
|
extraSize: number;
|
|
@@ -79,13 +82,12 @@ export type MachineConfig = {
|
|
|
79
82
|
assertRollingTemplate?: boolean;
|
|
80
83
|
bootargs: string[];
|
|
81
84
|
entrypoint?: string;
|
|
82
|
-
finalHash: boolean;
|
|
83
|
-
interactive?: boolean;
|
|
84
85
|
maxMCycle?: bigint;
|
|
85
86
|
noRollup?: boolean;
|
|
86
87
|
ramLength: string;
|
|
87
|
-
ramImage
|
|
88
|
-
|
|
88
|
+
ramImage?: string;
|
|
89
|
+
useDockerEnv: boolean;
|
|
90
|
+
useDockerWorkdir: boolean;
|
|
89
91
|
user?: string;
|
|
90
92
|
};
|
|
91
93
|
export type Config = {
|
|
@@ -93,11 +95,30 @@ export type Config = {
|
|
|
93
95
|
machine: MachineConfig;
|
|
94
96
|
sdk: string;
|
|
95
97
|
};
|
|
98
|
+
type TomlTable = {
|
|
99
|
+
[key: string]: TomlPrimitive;
|
|
100
|
+
};
|
|
96
101
|
export declare const defaultRootDriveConfig: () => DriveConfig;
|
|
97
|
-
export declare const defaultRamImage: () => string;
|
|
98
102
|
export declare const defaultMachineConfig: () => MachineConfig;
|
|
99
103
|
export declare const defaultConfig: () => Config;
|
|
100
104
|
export declare const getDriveFormat: (filename: string) => DriveFormat;
|
|
101
|
-
export declare const parse: (str: string) => Config;
|
|
105
|
+
export declare const parse: (str: string[]) => Config;
|
|
106
|
+
/**
|
|
107
|
+
* Recursively merges two TOML table objects
|
|
108
|
+
* Values from 'other' take precedence over 'base'
|
|
109
|
+
*
|
|
110
|
+
* @param base - The base TOML table
|
|
111
|
+
* @param other - The TOML table to merge into base (takes precedence)
|
|
112
|
+
* @returns A new merged TOML table
|
|
113
|
+
*/
|
|
114
|
+
export declare function mergeTomlTables(base: TomlTable, other: TomlTable): TomlTable;
|
|
115
|
+
/**
|
|
116
|
+
* Merges two TOML values of any type
|
|
117
|
+
*
|
|
118
|
+
* @param base - The base TOML value
|
|
119
|
+
* @param other - The TOML value to merge into base (takes precedence)
|
|
120
|
+
* @returns The merged TOML value
|
|
121
|
+
*/
|
|
122
|
+
export declare function mergeTomlValues(base: TomlPrimitive, other: TomlPrimitive): TomlPrimitive;
|
|
102
123
|
export {};
|
|
103
124
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAEA,OAAO,EAAsB,KAAK,aAAa,EAAE,MAAM,WAAW,CAAC;AAEnE;;GAEG;AACH,qBAAa,mBAAoB,SAA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BAAgB,EAAE,OAAO,CAAC;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACpC,OAAO,EAAE,aAAa,CAAC;IACvB,GAAG,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,KAAK,SAAS,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,CAAA;CAAE,CAAC;AAElD,eAAO,MAAM,sBAAsB,QAAO,WAQxC,CAAC;AAEH,eAAO,MAAM,oBAAoB,QAAO,aAUtC,CAAC;AAEH,eAAO,MAAM,aAAa,QAAO,MAI/B,CAAC;AA+LH,eAAO,MAAM,cAAc,GAAI,UAAU,MAAM,KAAG,WAUjD,CAAC;AA4GF,eAAO,MAAM,KAAK,GAAI,KAAK,MAAM,EAAE,KAAG,MAgBrC,CAAC;AAcF;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,GAAG,SAAS,CAgB5E;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC3B,IAAI,EAAE,aAAa,EACnB,KAAK,EAAE,aAAa,GACrB,aAAa,CAQf"}
|
package/dist/config.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import bytes from "bytes";
|
|
2
|
-
import
|
|
3
|
-
import { extname } from "path";
|
|
2
|
+
import { extname } from "node:path";
|
|
4
3
|
import { parse as parseToml } from "smol-toml";
|
|
5
4
|
/**
|
|
6
5
|
* Typed Errors
|
|
@@ -55,7 +54,7 @@ export class RequiredFieldError extends Error {
|
|
|
55
54
|
}
|
|
56
55
|
export class InvalidStringArrayError extends Error {
|
|
57
56
|
constructor() {
|
|
58
|
-
super(
|
|
57
|
+
super("Invalid string array");
|
|
59
58
|
this.name = "InvalidStringArrayError";
|
|
60
59
|
}
|
|
61
60
|
}
|
|
@@ -64,49 +63,39 @@ export class InvalidStringArrayError extends Error {
|
|
|
64
63
|
*/
|
|
65
64
|
const DEFAULT_FORMAT = "ext2";
|
|
66
65
|
const DEFAULT_RAM = "128Mi";
|
|
67
|
-
const
|
|
68
|
-
const
|
|
69
|
-
const
|
|
70
|
-
export const DEFAULT_SDK = "cartesi/sdk:0.12.0-alpha.1";
|
|
66
|
+
export const DEFAULT_SDK_VERSION = "0.12.0-alpha.24";
|
|
67
|
+
export const DEFAULT_SDK_IMAGE = "cartesi/sdk";
|
|
68
|
+
export const PREFERRED_PORT = 6751;
|
|
71
69
|
export const defaultRootDriveConfig = () => ({
|
|
72
70
|
builder: "docker",
|
|
71
|
+
buildArgs: [],
|
|
73
72
|
context: ".",
|
|
74
73
|
dockerfile: "Dockerfile", // file on current working directory
|
|
75
74
|
extraSize: 0,
|
|
76
75
|
format: DEFAULT_FORMAT,
|
|
77
76
|
tags: [],
|
|
78
77
|
});
|
|
79
|
-
export const defaultRamImage = () => {
|
|
80
|
-
switch (os.platform()) {
|
|
81
|
-
case "darwin":
|
|
82
|
-
return DEFAULT_RAM_IMAGE_MAC;
|
|
83
|
-
default:
|
|
84
|
-
return DEFAULT_RAM_IMAGE_LINUX;
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
78
|
export const defaultMachineConfig = () => ({
|
|
88
79
|
assertRollingTemplate: undefined,
|
|
89
80
|
bootargs: [],
|
|
90
81
|
entrypoint: undefined,
|
|
91
|
-
finalHash: true,
|
|
92
|
-
interactive: undefined,
|
|
93
82
|
maxMCycle: undefined,
|
|
94
83
|
noRollup: undefined,
|
|
95
84
|
ramLength: DEFAULT_RAM,
|
|
96
|
-
|
|
97
|
-
|
|
85
|
+
useDockerEnv: true,
|
|
86
|
+
useDockerWorkdir: true,
|
|
98
87
|
user: undefined,
|
|
99
88
|
});
|
|
100
89
|
export const defaultConfig = () => ({
|
|
101
90
|
drives: { root: defaultRootDriveConfig() },
|
|
102
91
|
machine: defaultMachineConfig(),
|
|
103
|
-
sdk:
|
|
92
|
+
sdk: `${DEFAULT_SDK_IMAGE}:${DEFAULT_SDK_VERSION}`,
|
|
104
93
|
});
|
|
105
94
|
const parseBoolean = (value, defaultValue) => {
|
|
106
95
|
if (value === undefined) {
|
|
107
96
|
return defaultValue;
|
|
108
97
|
}
|
|
109
|
-
|
|
98
|
+
if (typeof value === "boolean") {
|
|
110
99
|
return value;
|
|
111
100
|
}
|
|
112
101
|
throw new InvalidBooleanValueError(value);
|
|
@@ -115,7 +104,7 @@ const parseOptionalBoolean = (value) => {
|
|
|
115
104
|
if (value === undefined) {
|
|
116
105
|
return undefined;
|
|
117
106
|
}
|
|
118
|
-
|
|
107
|
+
if (typeof value === "boolean") {
|
|
119
108
|
return value;
|
|
120
109
|
}
|
|
121
110
|
throw new InvalidBooleanValueError(value);
|
|
@@ -124,7 +113,7 @@ const parseString = (value, defaultValue) => {
|
|
|
124
113
|
if (value === undefined) {
|
|
125
114
|
return defaultValue;
|
|
126
115
|
}
|
|
127
|
-
|
|
116
|
+
if (typeof value === "string") {
|
|
128
117
|
return value;
|
|
129
118
|
}
|
|
130
119
|
throw new InvalidStringValueError(value);
|
|
@@ -133,10 +122,10 @@ const parseStringArray = (value) => {
|
|
|
133
122
|
if (value === undefined) {
|
|
134
123
|
return [];
|
|
135
124
|
}
|
|
136
|
-
|
|
125
|
+
if (typeof value === "string") {
|
|
137
126
|
return [value];
|
|
138
127
|
}
|
|
139
|
-
|
|
128
|
+
if (typeof value === "object" && Array.isArray(value)) {
|
|
140
129
|
return value.map((v) => {
|
|
141
130
|
if (typeof v === "string") {
|
|
142
131
|
return v;
|
|
@@ -150,7 +139,7 @@ const parseRequiredString = (value, key) => {
|
|
|
150
139
|
if (value === undefined) {
|
|
151
140
|
throw new RequiredFieldError(key);
|
|
152
141
|
}
|
|
153
|
-
|
|
142
|
+
if (typeof value === "string") {
|
|
154
143
|
return value;
|
|
155
144
|
}
|
|
156
145
|
throw new InvalidStringValueError(value);
|
|
@@ -159,7 +148,7 @@ const parseOptionalString = (value) => {
|
|
|
159
148
|
if (value === undefined) {
|
|
160
149
|
return undefined;
|
|
161
150
|
}
|
|
162
|
-
|
|
151
|
+
if (typeof value === "string") {
|
|
163
152
|
return value;
|
|
164
153
|
}
|
|
165
154
|
throw new InvalidStringValueError(value);
|
|
@@ -168,10 +157,10 @@ const parseOptionalStringBoolean = (value) => {
|
|
|
168
157
|
if (value === undefined) {
|
|
169
158
|
return undefined;
|
|
170
159
|
}
|
|
171
|
-
|
|
160
|
+
if (typeof value === "string") {
|
|
172
161
|
return value;
|
|
173
162
|
}
|
|
174
|
-
|
|
163
|
+
if (typeof value === "boolean") {
|
|
175
164
|
return value;
|
|
176
165
|
}
|
|
177
166
|
throw new InvalidStringValueError(value);
|
|
@@ -180,10 +169,10 @@ const parseOptionalNumber = (value) => {
|
|
|
180
169
|
if (value === undefined) {
|
|
181
170
|
return undefined;
|
|
182
171
|
}
|
|
183
|
-
|
|
172
|
+
if (typeof value === "bigint") {
|
|
184
173
|
return value;
|
|
185
174
|
}
|
|
186
|
-
|
|
175
|
+
if (typeof value === "number") {
|
|
187
176
|
return BigInt(value);
|
|
188
177
|
}
|
|
189
178
|
throw new InvalidNumberValueError(value);
|
|
@@ -192,10 +181,10 @@ const parseBytes = (value, defaultValue) => {
|
|
|
192
181
|
if (value === undefined) {
|
|
193
182
|
return defaultValue;
|
|
194
183
|
}
|
|
195
|
-
|
|
184
|
+
if (typeof value === "bigint") {
|
|
196
185
|
return Number(value);
|
|
197
186
|
}
|
|
198
|
-
|
|
187
|
+
if (typeof value === "number" || typeof value === "string") {
|
|
199
188
|
const output = bytes.parse(value);
|
|
200
189
|
if (output !== null) {
|
|
201
190
|
return output;
|
|
@@ -207,7 +196,7 @@ const parseBuilder = (value) => {
|
|
|
207
196
|
if (value === undefined) {
|
|
208
197
|
return "docker";
|
|
209
198
|
}
|
|
210
|
-
|
|
199
|
+
if (typeof value === "string") {
|
|
211
200
|
switch (value) {
|
|
212
201
|
case "directory":
|
|
213
202
|
return "directory";
|
|
@@ -227,7 +216,7 @@ const parseFormat = (value) => {
|
|
|
227
216
|
if (value === undefined) {
|
|
228
217
|
return DEFAULT_FORMAT;
|
|
229
218
|
}
|
|
230
|
-
|
|
219
|
+
if (typeof value === "string") {
|
|
231
220
|
switch (value) {
|
|
232
221
|
case "ext2":
|
|
233
222
|
return "ext2";
|
|
@@ -241,7 +230,7 @@ const parseEmptyFormat = (value) => {
|
|
|
241
230
|
if (value === undefined) {
|
|
242
231
|
return DEFAULT_FORMAT;
|
|
243
232
|
}
|
|
244
|
-
|
|
233
|
+
if (typeof value === "string") {
|
|
245
234
|
switch (value) {
|
|
246
235
|
case "ext2":
|
|
247
236
|
return "ext2";
|
|
@@ -261,15 +250,15 @@ const parseMachine = (value) => {
|
|
|
261
250
|
}
|
|
262
251
|
const toml = value;
|
|
263
252
|
return {
|
|
264
|
-
assertRollingTemplate: parseOptionalBoolean(toml
|
|
265
|
-
bootargs: parseStringArray(toml.
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
253
|
+
assertRollingTemplate: parseOptionalBoolean(toml.assert_rolling_template),
|
|
254
|
+
bootargs: parseStringArray(toml.boot_args),
|
|
255
|
+
entrypoint: parseOptionalString(toml.entrypoint),
|
|
256
|
+
maxMCycle: parseOptionalNumber(toml.max_mcycle),
|
|
257
|
+
noRollup: parseBoolean(toml.no_rollup, false),
|
|
258
|
+
ramLength: parseString(toml.ram_length, DEFAULT_RAM),
|
|
259
|
+
ramImage: parseOptionalString(toml.ram_image),
|
|
260
|
+
useDockerEnv: parseBoolean(toml.use_docker_env, true),
|
|
261
|
+
useDockerWorkdir: parseBoolean(toml.use_docker_workdir, true),
|
|
273
262
|
user: parseOptionalString(toml.user),
|
|
274
263
|
};
|
|
275
264
|
};
|
|
@@ -288,10 +277,10 @@ const parseDrive = (drive) => {
|
|
|
288
277
|
const builder = parseBuilder(drive.builder);
|
|
289
278
|
switch (builder) {
|
|
290
279
|
case "directory": {
|
|
291
|
-
const {
|
|
280
|
+
const { extra_size, format, mount, directory, shared, user } = drive;
|
|
292
281
|
return {
|
|
293
282
|
builder: "directory",
|
|
294
|
-
extraSize: parseBytes(
|
|
283
|
+
extraSize: parseBytes(extra_size, 0),
|
|
295
284
|
format: parseFormat(format),
|
|
296
285
|
mount: parseOptionalStringBoolean(mount),
|
|
297
286
|
directory: parseRequiredString(directory, "directory"),
|
|
@@ -300,13 +289,14 @@ const parseDrive = (drive) => {
|
|
|
300
289
|
};
|
|
301
290
|
}
|
|
302
291
|
case "docker": {
|
|
303
|
-
const { context, dockerfile,
|
|
292
|
+
const { build_args, context, dockerfile, extra_size, format, image, mount, shared, tags, target, user, } = drive;
|
|
304
293
|
return {
|
|
305
294
|
builder: "docker",
|
|
295
|
+
buildArgs: parseStringArray(build_args),
|
|
306
296
|
image: parseOptionalString(image),
|
|
307
297
|
context: parseString(context, "."),
|
|
308
298
|
dockerfile: parseString(dockerfile, "Dockerfile"),
|
|
309
|
-
extraSize: parseBytes(
|
|
299
|
+
extraSize: parseBytes(extra_size, 0),
|
|
310
300
|
format: parseFormat(format),
|
|
311
301
|
mount: parseOptionalStringBoolean(mount),
|
|
312
302
|
shared: parseOptionalBoolean(shared),
|
|
@@ -327,10 +317,10 @@ const parseDrive = (drive) => {
|
|
|
327
317
|
};
|
|
328
318
|
}
|
|
329
319
|
case "tar": {
|
|
330
|
-
const {
|
|
320
|
+
const { extra_size, filename, format, mount, shared, user } = drive;
|
|
331
321
|
return {
|
|
332
322
|
builder: "tar",
|
|
333
|
-
extraSize: parseBytes(
|
|
323
|
+
extraSize: parseBytes(extra_size, 0),
|
|
334
324
|
filename: parseRequiredString(filename, "filename"),
|
|
335
325
|
format: parseFormat(format),
|
|
336
326
|
mount: parseOptionalStringBoolean(mount),
|
|
@@ -368,11 +358,61 @@ const parseDrives = (config) => {
|
|
|
368
358
|
return drives;
|
|
369
359
|
};
|
|
370
360
|
export const parse = (str) => {
|
|
371
|
-
|
|
361
|
+
let toml = {};
|
|
362
|
+
for (const s of str) {
|
|
363
|
+
toml = mergeTomlTables(toml, parseToml(s));
|
|
364
|
+
}
|
|
372
365
|
const config = {
|
|
373
366
|
drives: parseDrives(toml.drives),
|
|
374
367
|
machine: parseMachine(toml.machine),
|
|
375
|
-
sdk: parseString(toml.sdk,
|
|
368
|
+
sdk: parseString(toml.sdk, `${DEFAULT_SDK_IMAGE}:${DEFAULT_SDK_VERSION}`),
|
|
376
369
|
};
|
|
377
370
|
return config;
|
|
378
371
|
};
|
|
372
|
+
/**
|
|
373
|
+
* Checks if a value is a plain object (TOML table)
|
|
374
|
+
*/
|
|
375
|
+
function isTomlTable(value) {
|
|
376
|
+
return (typeof value === "object" &&
|
|
377
|
+
value !== null &&
|
|
378
|
+
!Array.isArray(value) &&
|
|
379
|
+
!("toISOString" in value)); // Check for TomlDate (has toISOString method)
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* Recursively merges two TOML table objects
|
|
383
|
+
* Values from 'other' take precedence over 'base'
|
|
384
|
+
*
|
|
385
|
+
* @param base - The base TOML table
|
|
386
|
+
* @param other - The TOML table to merge into base (takes precedence)
|
|
387
|
+
* @returns A new merged TOML table
|
|
388
|
+
*/
|
|
389
|
+
export function mergeTomlTables(base, other) {
|
|
390
|
+
const result = { ...base };
|
|
391
|
+
for (const [key, otherValue] of Object.entries(other)) {
|
|
392
|
+
const baseValue = result[key];
|
|
393
|
+
// If both values are tables, merge them recursively
|
|
394
|
+
if (isTomlTable(baseValue) && isTomlTable(otherValue)) {
|
|
395
|
+
result[key] = mergeTomlTables(baseValue, otherValue);
|
|
396
|
+
}
|
|
397
|
+
else {
|
|
398
|
+
// For all other cases, other value takes precedence
|
|
399
|
+
result[key] = otherValue;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
return result;
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* Merges two TOML values of any type
|
|
406
|
+
*
|
|
407
|
+
* @param base - The base TOML value
|
|
408
|
+
* @param other - The TOML value to merge into base (takes precedence)
|
|
409
|
+
* @returns The merged TOML value
|
|
410
|
+
*/
|
|
411
|
+
export function mergeTomlValues(base, other) {
|
|
412
|
+
// If both are tables, merge recursively
|
|
413
|
+
if (isTomlTable(base) && isTomlTable(other)) {
|
|
414
|
+
return mergeTomlTables(base, other);
|
|
415
|
+
}
|
|
416
|
+
// For arrays, replaces entirely
|
|
417
|
+
return other;
|
|
418
|
+
}
|