@cartesi/cli 2.0.0-alpha.3 → 2.0.0-alpha.5
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 +14 -0
- package/dist/base.d.ts.map +1 -0
- package/dist/base.js +77 -0
- package/dist/commands/address-book.d.ts +2 -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 +2 -11
- package/dist/commands/build.d.ts.map +1 -1
- package/dist/commands/build.js +16 -28
- 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 +2 -14
- package/dist/commands/create.d.ts.map +1 -1
- package/dist/commands/create.js +37 -51
- 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 +41 -47
- package/dist/commands/deploy.d.ts +3 -0
- package/dist/commands/deploy.d.ts.map +1 -0
- package/dist/commands/{deploy/index.js → deploy.js} +26 -28
- package/dist/commands/doctor.d.ts +2 -12
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +83 -90
- package/dist/commands/hash.d.ts +2 -9
- package/dist/commands/hash.d.ts.map +1 -1
- package/dist/commands/hash.js +14 -14
- package/dist/commands/run.d.ts +2 -20
- package/dist/commands/run.d.ts.map +1 -1
- package/dist/commands/run.js +49 -82
- package/dist/commands/send/erc20.d.ts +2 -13
- package/dist/commands/send/erc20.d.ts.map +1 -1
- package/dist/commands/send/erc20.js +55 -52
- package/dist/commands/send/erc721.d.ts +2 -13
- package/dist/commands/send/erc721.d.ts.map +1 -1
- package/dist/commands/send/erc721.js +49 -46
- package/dist/commands/send/ether.d.ts +2 -12
- package/dist/commands/send/ether.d.ts.map +1 -1
- package/dist/commands/send/ether.js +23 -21
- package/dist/commands/send/generic.d.ts +2 -14
- package/dist/commands/send/generic.d.ts.map +1 -1
- package/dist/commands/send/generic.js +91 -97
- 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 +2 -14
- package/dist/commands/shell.d.ts.map +1 -1
- package/dist/commands/shell.js +21 -43
- package/dist/config.d.ts +1 -1
- package/dist/config.js +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +51 -1
- package/dist/node/docker-compose-anvil.yaml +2 -2
- package/dist/node/docker-compose-bundler.yaml +1 -1
- package/dist/node/docker-compose-database.yaml +1 -1
- package/dist/node/docker-compose-espresso.yaml +127 -0
- package/dist/node/docker-compose-explorer.yaml +1 -1
- package/dist/node/docker-compose-paymaster.yaml +1 -1
- package/package.json +8 -27
- 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/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/oclif.manifest.json +0 -876
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,28 +0,0 @@
|
|
|
1
|
-
import { Command, Interfaces } from "@oclif/core";
|
|
2
|
-
import { Address, PublicClient, WalletClient } from "viem";
|
|
3
|
-
import { BaseCommand } from "../../baseCommand.js";
|
|
4
|
-
export type Flags<T extends typeof Command> = Interfaces.InferredFlags<(typeof SendBaseCommand)["baseFlags"] & T["flags"]>;
|
|
5
|
-
export type Args<T extends typeof Command> = Interfaces.InferredArgs<T["args"]>;
|
|
6
|
-
export declare abstract class SendBaseCommand<T extends typeof Command> extends BaseCommand<typeof SendBaseCommand> {
|
|
7
|
-
static baseFlags: {
|
|
8
|
-
dapp: Interfaces.OptionFlag<`0x${string}` | undefined, Interfaces.CustomOptions>;
|
|
9
|
-
"chain-id": Interfaces.OptionFlag<number | undefined, Interfaces.CustomOptions>;
|
|
10
|
-
"rpc-url": Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
|
|
11
|
-
"mnemonic-passphrase": Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
|
|
12
|
-
"mnemonic-index": Interfaces.OptionFlag<number, Interfaces.CustomOptions>;
|
|
13
|
-
};
|
|
14
|
-
protected flags: Flags<T>;
|
|
15
|
-
protected args: Args<T>;
|
|
16
|
-
private connect;
|
|
17
|
-
protected getApplicationAddress(): Promise<Address>;
|
|
18
|
-
init(): Promise<void>;
|
|
19
|
-
protected abstract send(publicClient: PublicClient, walletClient: WalletClient): Promise<Address>;
|
|
20
|
-
run(): Promise<void>;
|
|
21
|
-
}
|
|
22
|
-
export default class Send extends Command {
|
|
23
|
-
static summary: string;
|
|
24
|
-
static description: string;
|
|
25
|
-
static examples: string[];
|
|
26
|
-
run(): Promise<void>;
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/send/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,UAAU,EAA0B,MAAM,aAAa,CAAC;AAE1E,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAa,MAAM,MAAM,CAAC;AAEtE,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAInD,MAAM,MAAM,KAAK,CAAC,CAAC,SAAS,OAAO,OAAO,IAAI,UAAU,CAAC,aAAa,CAClE,CAAC,OAAO,eAAe,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CACrD,CAAC;AACF,MAAM,MAAM,IAAI,CAAC,CAAC,SAAS,OAAO,OAAO,IAAI,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAGhF,8BAAsB,eAAe,CACjC,CAAC,SAAS,OAAO,OAAO,CAC1B,SAAQ,WAAW,CAAC,OAAO,eAAe,CAAC;IACzC,MAAM,CAAC,SAAS;;;;;;MA8Bd;IAEF,SAAS,CAAC,KAAK,EAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IAC3B,SAAS,CAAC,IAAI,EAAG,IAAI,CAAC,CAAC,CAAC,CAAC;YAEX,OAAO;cAeL,qBAAqB,IAAI,OAAO,CAAC,OAAO,CAAC;IAmB5C,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAYlC,SAAS,CAAC,QAAQ,CAAC,IAAI,CACnB,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,YAAY,GAC3B,OAAO,CAAC,OAAO,CAAC;IAEN,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAOpC;AAED,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,OAAO;IACrC,MAAM,CAAC,OAAO,SAAoC;IAElD,MAAM,CAAC,WAAW,SAC2D;IAE7E,MAAM,CAAC,QAAQ,WAA2C;IAE7C,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAmBpC"}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import input from "@inquirer/input";
|
|
2
|
-
import select from "@inquirer/select";
|
|
3
|
-
import { Command, Flags as StandardFlags } from "@oclif/core";
|
|
4
|
-
import ora from "ora";
|
|
5
|
-
import { isAddress } from "viem";
|
|
6
|
-
import { BaseCommand } from "../../baseCommand.js";
|
|
7
|
-
import * as CustomFlags from "../../flags.js";
|
|
8
|
-
import createClients, { supportedChains } from "../../wallet.js";
|
|
9
|
-
// base command for sending input to the application
|
|
10
|
-
export class SendBaseCommand extends BaseCommand {
|
|
11
|
-
async connect() {
|
|
12
|
-
// create viem clients
|
|
13
|
-
return createClients({
|
|
14
|
-
chain: supportedChains({ includeDevnet: true }).find((c) => c.id == this.flags["chain-id"]),
|
|
15
|
-
rpcUrl: this.flags["rpc-url"],
|
|
16
|
-
mnemonicPassphrase: this.flags["mnemonic-passphrase"],
|
|
17
|
-
mnemonicIndex: this.flags["mnemonic-index"],
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
async getApplicationAddress() {
|
|
21
|
-
if (this.flags.dapp) {
|
|
22
|
-
// honor the flag
|
|
23
|
-
return this.flags.dapp;
|
|
24
|
-
}
|
|
25
|
-
// get the running container dapp address
|
|
26
|
-
const nodeAddress = await super.getApplicationAddress();
|
|
27
|
-
// query for the address
|
|
28
|
-
const applicationAddress = await input({
|
|
29
|
-
message: "Application address",
|
|
30
|
-
validate: (value) => isAddress(value) || "Invalid address",
|
|
31
|
-
default: nodeAddress,
|
|
32
|
-
});
|
|
33
|
-
return applicationAddress;
|
|
34
|
-
}
|
|
35
|
-
async init() {
|
|
36
|
-
await super.init();
|
|
37
|
-
const { args, flags } = await this.parse({
|
|
38
|
-
flags: this.ctor.flags,
|
|
39
|
-
baseFlags: super.ctor.baseFlags,
|
|
40
|
-
args: this.ctor.args,
|
|
41
|
-
strict: this.ctor.strict,
|
|
42
|
-
});
|
|
43
|
-
this.flags = flags;
|
|
44
|
-
this.args = args;
|
|
45
|
-
}
|
|
46
|
-
async run() {
|
|
47
|
-
const { publicClient, walletClient } = await this.connect();
|
|
48
|
-
const hash = await this.send(publicClient, walletClient);
|
|
49
|
-
const progress = ora("Sending input...").start();
|
|
50
|
-
await publicClient.waitForTransactionReceipt({ hash });
|
|
51
|
-
progress.succeed(`Input sent: ${hash}`);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
SendBaseCommand.baseFlags = {
|
|
55
|
-
dapp: CustomFlags.address({
|
|
56
|
-
summary: "dapp address.",
|
|
57
|
-
description: "the address of the DApp, defaults to the deployed DApp address if application is running.",
|
|
58
|
-
}),
|
|
59
|
-
"chain-id": StandardFlags.integer({
|
|
60
|
-
description: "The EIP-155 chain ID.",
|
|
61
|
-
char: "c",
|
|
62
|
-
env: "CHAIN",
|
|
63
|
-
helpGroup: "Ethereum",
|
|
64
|
-
options: supportedChains({ includeDevnet: true }).map((c) => c.id.toString()),
|
|
65
|
-
}),
|
|
66
|
-
"rpc-url": StandardFlags.string({
|
|
67
|
-
description: "The RPC endpoint.",
|
|
68
|
-
char: "r",
|
|
69
|
-
env: "ETH_RPC_URL",
|
|
70
|
-
helpGroup: "Ethereum",
|
|
71
|
-
}),
|
|
72
|
-
"mnemonic-passphrase": StandardFlags.string({
|
|
73
|
-
description: "Use a BIP39 passphrase for the mnemonic.",
|
|
74
|
-
helpGroup: "Wallet",
|
|
75
|
-
}),
|
|
76
|
-
"mnemonic-index": StandardFlags.integer({
|
|
77
|
-
description: "Use the private key from the given mnemonic index.",
|
|
78
|
-
helpGroup: "Wallet",
|
|
79
|
-
default: 0,
|
|
80
|
-
}),
|
|
81
|
-
};
|
|
82
|
-
class Send extends Command {
|
|
83
|
-
async run() {
|
|
84
|
-
// get all send sub-commands
|
|
85
|
-
const sendCommands = this.config.commands.filter((command) => command.id.startsWith("send:"));
|
|
86
|
-
// select the send sub-command
|
|
87
|
-
const commandId = await select({
|
|
88
|
-
message: "Select send sub-command",
|
|
89
|
-
choices: sendCommands.map((command) => ({
|
|
90
|
-
value: command.id,
|
|
91
|
-
name: command.summary,
|
|
92
|
-
description: command.description,
|
|
93
|
-
})),
|
|
94
|
-
});
|
|
95
|
-
// invoke the sub-command
|
|
96
|
-
await this.config.runCommand(commandId, this.argv);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
Send.summary = "Send input to the application.";
|
|
100
|
-
Send.description = "Sends different kinds of input to the application in interactive mode.";
|
|
101
|
-
Send.examples = ["<%= config.bin %> <%= command.id %>"];
|
|
102
|
-
export default Send;
|
package/dist/flags.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export declare const address: import("@oclif/core/lib/interfaces").FlagDefinition<`0x${string}`, import("@oclif/core/lib/interfaces").CustomOptions, {
|
|
2
|
-
multiple: false;
|
|
3
|
-
requiredOrDefaulted: false;
|
|
4
|
-
}>;
|
|
5
|
-
export declare const bigint: import("@oclif/core/lib/interfaces").FlagDefinition<bigint, import("@oclif/core/lib/interfaces").CustomOptions, {
|
|
6
|
-
multiple: false;
|
|
7
|
-
requiredOrDefaulted: false;
|
|
8
|
-
}>;
|
|
9
|
-
export declare const number: import("@oclif/core/lib/interfaces").FlagDefinition<`${number}`, import("@oclif/core/lib/interfaces").CustomOptions, {
|
|
10
|
-
multiple: false;
|
|
11
|
-
requiredOrDefaulted: false;
|
|
12
|
-
}>;
|
|
13
|
-
export declare const hex: import("@oclif/core/lib/interfaces").FlagDefinition<`0x${string}`, import("@oclif/core/lib/interfaces").CustomOptions, {
|
|
14
|
-
multiple: false;
|
|
15
|
-
requiredOrDefaulted: false;
|
|
16
|
-
}>;
|
|
17
|
-
//# sourceMappingURL=flags.d.ts.map
|
package/dist/flags.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"flags.d.ts","sourceRoot":"","sources":["../src/flags.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,OAAO;;;EAOlB,CAAC;AAGH,eAAO,MAAM,MAAM;;;EAEjB,CAAC;AAGH,eAAO,MAAM,MAAM;;;EAEjB,CAAC;AAGH,eAAO,MAAM,GAAG;;;EAOd,CAAC"}
|
package/dist/flags.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { Flags } from "@oclif/core";
|
|
2
|
-
import { isAddress, isHex } from "viem";
|
|
3
|
-
// custom flag for Address, does validation
|
|
4
|
-
export const address = Flags.custom({
|
|
5
|
-
parse: async (input) => {
|
|
6
|
-
if (isAddress(input)) {
|
|
7
|
-
return input;
|
|
8
|
-
}
|
|
9
|
-
throw new Error("Invalid address");
|
|
10
|
-
},
|
|
11
|
-
});
|
|
12
|
-
// custom flag for bigint
|
|
13
|
-
export const bigint = Flags.custom({
|
|
14
|
-
parse: async (input) => BigInt(input),
|
|
15
|
-
});
|
|
16
|
-
// custom flag for string number
|
|
17
|
-
export const number = Flags.custom({
|
|
18
|
-
parse: async (input) => input,
|
|
19
|
-
});
|
|
20
|
-
// custom flag for hex string
|
|
21
|
-
export const hex = Flags.custom({
|
|
22
|
-
parse: async (input) => {
|
|
23
|
-
if (isHex(input)) {
|
|
24
|
-
return input;
|
|
25
|
-
}
|
|
26
|
-
throw new Error("Invalid hex string");
|
|
27
|
-
},
|
|
28
|
-
});
|