clanker-sdk 4.2.11 → 4.2.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/README.md +42 -9
- package/dist/{deploy-ydUPEH-J.d.ts → clankerTokenV4-DoIzm6GW.d.ts} +1 -6
- package/dist/cli/cli.js +10486 -7347
- package/dist/cli/commands/airdrop.d.ts +8 -0
- package/dist/cli/commands/airdrop.js +8524 -0
- package/dist/cli/commands/deploy.d.ts +14 -0
- package/dist/cli/commands/deploy.js +9917 -0
- package/dist/cli/commands/presale.d.ts +5 -0
- package/dist/cli/commands/presale.js +9340 -0
- package/dist/cli/commands/rewards.d.ts +5 -0
- package/dist/cli/commands/rewards.js +8235 -0
- package/dist/cli/commands/setup.d.ts +5 -0
- package/dist/cli/commands/setup.js +314 -0
- package/dist/cli/commands/token.d.ts +5 -0
- package/dist/cli/commands/token.js +8120 -0
- package/dist/cli/commands/vault.d.ts +5 -0
- package/dist/cli/commands/vault.js +8128 -0
- package/dist/cli/create-clanker.js +1 -1
- package/dist/cli/utils/chains.d.ts +6 -0
- package/dist/cli/utils/chains.js +51 -0
- package/dist/cli/utils/config.d.ts +10 -0
- package/dist/cli/utils/config.js +31 -0
- package/dist/cli/utils/output.d.ts +14 -0
- package/dist/cli/utils/output.js +209 -0
- package/dist/cli/utils/style.d.ts +49 -0
- package/dist/cli/utils/style.js +129 -0
- package/dist/cli/utils/wallet.d.ts +22 -0
- package/dist/cli/utils/wallet.js +108 -0
- package/dist/deploy-BUDlDPzt.d.ts +6 -0
- package/dist/index.d.ts +5 -15
- package/dist/index.js +1 -1
- package/dist/legacyFeeClaims/index.js +1 -1
- package/dist/merkleTree-BNYdIOkH.d.ts +15 -0
- package/dist/v3/index.d.ts +2 -2
- package/dist/v3/index.js +1 -1
- package/dist/v4/extensions/index.d.ts +2 -1
- package/dist/v4/extensions/index.js +1 -1
- package/dist/v4/index.d.ts +5 -4
- package/dist/v4/index.js +1 -1
- package/package.json +2 -1
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// src/cli/utils/chains.ts
|
|
2
|
+
import { arbitrum, base, baseSepolia, bsc, mainnet, unichain } from "viem/chains";
|
|
3
|
+
|
|
4
|
+
// src/utils/chains/monad.ts
|
|
5
|
+
import { defineChain } from "viem";
|
|
6
|
+
var monad = /* @__PURE__ */ defineChain({
|
|
7
|
+
id: 143,
|
|
8
|
+
name: "Monad",
|
|
9
|
+
blockTime: 400,
|
|
10
|
+
nativeCurrency: {
|
|
11
|
+
name: "MON",
|
|
12
|
+
symbol: "MON",
|
|
13
|
+
decimals: 18
|
|
14
|
+
},
|
|
15
|
+
rpcUrls: {
|
|
16
|
+
default: {
|
|
17
|
+
http: ["https://rpc.monad.xyz"]
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
blockExplorers: {
|
|
21
|
+
default: {
|
|
22
|
+
name: "Monad explorer",
|
|
23
|
+
url: "TODO"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
contracts: {},
|
|
27
|
+
testnet: false
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// src/cli/utils/chains.ts
|
|
31
|
+
var CHAIN_MAP = {
|
|
32
|
+
base,
|
|
33
|
+
"base-sepolia": baseSepolia,
|
|
34
|
+
arbitrum,
|
|
35
|
+
ethereum: mainnet,
|
|
36
|
+
bsc,
|
|
37
|
+
unichain,
|
|
38
|
+
monad
|
|
39
|
+
};
|
|
40
|
+
var CHAIN_NAMES = Object.keys(CHAIN_MAP);
|
|
41
|
+
function resolveChain(name) {
|
|
42
|
+
const chain = CHAIN_MAP[name];
|
|
43
|
+
if (!chain) {
|
|
44
|
+
throw new Error(`Unknown chain "${name}". Supported: ${CHAIN_NAMES.join(", ")}`);
|
|
45
|
+
}
|
|
46
|
+
return chain;
|
|
47
|
+
}
|
|
48
|
+
export {
|
|
49
|
+
CHAIN_NAMES,
|
|
50
|
+
resolveChain
|
|
51
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
interface ClankerConfig {
|
|
2
|
+
privateKey?: string;
|
|
3
|
+
rpc?: Record<string, string>;
|
|
4
|
+
defaultChain?: string;
|
|
5
|
+
}
|
|
6
|
+
declare function loadConfig(): ClankerConfig;
|
|
7
|
+
declare function saveConfig(config: ClankerConfig): void;
|
|
8
|
+
declare function getConfigPath(): string;
|
|
9
|
+
|
|
10
|
+
export { type ClankerConfig, getConfigPath, loadConfig, saveConfig };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// src/cli/utils/config.ts
|
|
2
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { homedir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
var CONFIG_DIR = join(homedir(), ".clanker");
|
|
6
|
+
var CONFIG_PATH = join(CONFIG_DIR, "config.json");
|
|
7
|
+
function ensureDir() {
|
|
8
|
+
if (!existsSync(CONFIG_DIR)) {
|
|
9
|
+
mkdirSync(CONFIG_DIR, { recursive: true });
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function loadConfig() {
|
|
13
|
+
try {
|
|
14
|
+
if (!existsSync(CONFIG_PATH)) return {};
|
|
15
|
+
return JSON.parse(readFileSync(CONFIG_PATH, "utf-8"));
|
|
16
|
+
} catch {
|
|
17
|
+
return {};
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function saveConfig(config) {
|
|
21
|
+
ensureDir();
|
|
22
|
+
writeFileSync(CONFIG_PATH, JSON.stringify(config, null, 2), { mode: 384 });
|
|
23
|
+
}
|
|
24
|
+
function getConfigPath() {
|
|
25
|
+
return CONFIG_PATH;
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
getConfigPath,
|
|
29
|
+
loadConfig,
|
|
30
|
+
saveConfig
|
|
31
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Chain } from 'viem';
|
|
2
|
+
|
|
3
|
+
declare function getBanner(version: string): string;
|
|
4
|
+
declare function printBanner(version: string): void;
|
|
5
|
+
declare function blockExplorerUrl(chain: Chain, hash: string, type?: 'tx' | 'token'): string;
|
|
6
|
+
declare function printResult(data: Record<string, unknown>, jsonMode: boolean): void;
|
|
7
|
+
declare function printSuccess(message: string, jsonMode: boolean, data?: Record<string, unknown>): void;
|
|
8
|
+
declare function printError(error: unknown, jsonMode: boolean): void;
|
|
9
|
+
declare function printStep(message: string, jsonMode?: boolean): void;
|
|
10
|
+
declare function printInfo(label: string, value: string, jsonMode?: boolean): void;
|
|
11
|
+
declare function printWarning(message: string, jsonMode?: boolean): void;
|
|
12
|
+
declare function printKeyValue(data: Record<string, unknown>, jsonMode: boolean, title?: string): void;
|
|
13
|
+
|
|
14
|
+
export { blockExplorerUrl, getBanner, printBanner, printError, printInfo, printKeyValue, printResult, printStep, printSuccess, printWarning };
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
// src/cli/utils/style.ts
|
|
2
|
+
var isColorSupported = process.env.NO_COLOR === void 0 && process.env.FORCE_COLOR !== "0" && process.env.TERM !== "dumb" && (process.env.FORCE_COLOR !== void 0 || process.stdout.isTTY === true);
|
|
3
|
+
var ESC = "\x1B[";
|
|
4
|
+
var RST = `${ESC}0m`;
|
|
5
|
+
function wrap(code, text) {
|
|
6
|
+
if (!isColorSupported) return text;
|
|
7
|
+
return `${ESC}${code}m${text}${RST}`;
|
|
8
|
+
}
|
|
9
|
+
var bold = (s) => wrap("1", s);
|
|
10
|
+
var dim = (s) => wrap("2", s);
|
|
11
|
+
var red = (s) => wrap("31", s);
|
|
12
|
+
var green = (s) => wrap("32", s);
|
|
13
|
+
var yellow = (s) => wrap("33", s);
|
|
14
|
+
var cyan = (s) => wrap("36", s);
|
|
15
|
+
var gray = (s) => wrap("90", s);
|
|
16
|
+
var brightCyan = (s) => wrap("96", s);
|
|
17
|
+
function gradient(text, from, to) {
|
|
18
|
+
if (!isColorSupported) return text;
|
|
19
|
+
const chars = [...text];
|
|
20
|
+
const total = chars.length;
|
|
21
|
+
if (total === 0) return "";
|
|
22
|
+
return chars.map((ch, i) => {
|
|
23
|
+
if (ch === " ") return ch;
|
|
24
|
+
const t = total > 1 ? i / (total - 1) : 0;
|
|
25
|
+
const r = Math.round(from[0] + (to[0] - from[0]) * t);
|
|
26
|
+
const g = Math.round(from[1] + (to[1] - from[1]) * t);
|
|
27
|
+
const b = Math.round(from[2] + (to[2] - from[2]) * t);
|
|
28
|
+
return `${ESC}38;2;${r};${g};${b}m${ch}`;
|
|
29
|
+
}).join("") + RST;
|
|
30
|
+
}
|
|
31
|
+
var BRAND_FROM = [6, 182, 212];
|
|
32
|
+
var BRAND_TO = [168, 85, 247];
|
|
33
|
+
var SYM = {
|
|
34
|
+
check: isColorSupported ? "\u2714" : "+",
|
|
35
|
+
cross: isColorSupported ? "\u2716" : "x",
|
|
36
|
+
arrow: isColorSupported ? "\u25B8" : ">",
|
|
37
|
+
dot: isColorSupported ? "\u25CF" : "*",
|
|
38
|
+
star: isColorSupported ? "\u2605" : "*",
|
|
39
|
+
info: isColorSupported ? "\u2139" : "i",
|
|
40
|
+
warn: isColorSupported ? "\u26A0" : "!",
|
|
41
|
+
rocket: isColorSupported ? "\u{1F680}" : "^"
|
|
42
|
+
};
|
|
43
|
+
var BOX = {
|
|
44
|
+
tl: "\u256D",
|
|
45
|
+
tr: "\u256E",
|
|
46
|
+
bl: "\u2570",
|
|
47
|
+
br: "\u256F",
|
|
48
|
+
h: "\u2500",
|
|
49
|
+
v: "\u2502",
|
|
50
|
+
lt: "\u251C",
|
|
51
|
+
rt: "\u2524"
|
|
52
|
+
};
|
|
53
|
+
function stripAnsi(str) {
|
|
54
|
+
return str.replace(/\x1b\[[0-9;]*m/g, "");
|
|
55
|
+
}
|
|
56
|
+
function drawBox(lines, options) {
|
|
57
|
+
const color = options?.color || cyan;
|
|
58
|
+
const pad = options?.padding ?? 1;
|
|
59
|
+
const contentWidth = Math.max(
|
|
60
|
+
...lines.map((l) => stripAnsi(l).length),
|
|
61
|
+
options?.title ? stripAnsi(options.title).length : 0,
|
|
62
|
+
20
|
|
63
|
+
);
|
|
64
|
+
const innerWidth = contentWidth + pad * 2;
|
|
65
|
+
const out = [];
|
|
66
|
+
out.push(color(`${BOX.tl}${BOX.h.repeat(innerWidth)}${BOX.tr}`));
|
|
67
|
+
if (options?.title) {
|
|
68
|
+
const titleLen = stripAnsi(options.title).length;
|
|
69
|
+
const titlePad = innerWidth - titleLen - pad;
|
|
70
|
+
out.push(
|
|
71
|
+
`${color(BOX.v)}${" ".repeat(pad)}${options.title}${" ".repeat(Math.max(0, titlePad))}${color(BOX.v)}`
|
|
72
|
+
);
|
|
73
|
+
out.push(color(`${BOX.lt}${BOX.h.repeat(innerWidth)}${BOX.rt}`));
|
|
74
|
+
}
|
|
75
|
+
for (const line of lines) {
|
|
76
|
+
const lineLen = stripAnsi(line).length;
|
|
77
|
+
const linePad = innerWidth - lineLen - pad;
|
|
78
|
+
out.push(
|
|
79
|
+
`${color(BOX.v)}${" ".repeat(pad)}${line}${" ".repeat(Math.max(0, linePad))}${color(BOX.v)}`
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
out.push(color(`${BOX.bl}${BOX.h.repeat(innerWidth)}${BOX.br}`));
|
|
83
|
+
return out.join("\n");
|
|
84
|
+
}
|
|
85
|
+
function separator(width = 50) {
|
|
86
|
+
if (!isColorSupported) return BOX.h.repeat(width);
|
|
87
|
+
return dim(gray(BOX.h.repeat(width)));
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// src/cli/utils/output.ts
|
|
91
|
+
var BANNER_ART = [
|
|
92
|
+
" ____ _ _ _ _ _ _______ ____ ",
|
|
93
|
+
" / ___| | / \\ | \\ | | |/ / ____| _ \\ ",
|
|
94
|
+
" | | | | / _ \\ | \\| | ' /| _| | |_) |",
|
|
95
|
+
" | |___| |___/ ___ \\| |\\ | . \\| |___| _ < ",
|
|
96
|
+
" \\____|_____/_/ \\_\\_| \\_|_|\\_\\_____|_| \\_\\"
|
|
97
|
+
];
|
|
98
|
+
function getBanner(version) {
|
|
99
|
+
const lines = [""];
|
|
100
|
+
for (const line of BANNER_ART) {
|
|
101
|
+
lines.push(` ${gradient(line, BRAND_FROM, BRAND_TO)}`);
|
|
102
|
+
}
|
|
103
|
+
lines.push("");
|
|
104
|
+
lines.push(` ${dim(gray("Deploy tokens on the Superchain"))} ${dim(cyan(`v${version}`))}`);
|
|
105
|
+
lines.push(` ${separator(48)}`);
|
|
106
|
+
lines.push("");
|
|
107
|
+
return lines.join("\n");
|
|
108
|
+
}
|
|
109
|
+
function printBanner(version) {
|
|
110
|
+
console.log(getBanner(version));
|
|
111
|
+
}
|
|
112
|
+
function blockExplorerUrl(chain, hash, type = "tx") {
|
|
113
|
+
const explorer = chain.blockExplorers?.default?.url;
|
|
114
|
+
if (!explorer) return hash;
|
|
115
|
+
return `${explorer}/${type}/${hash}`;
|
|
116
|
+
}
|
|
117
|
+
function printResult(data, jsonMode) {
|
|
118
|
+
if (jsonMode) {
|
|
119
|
+
console.log(JSON.stringify(data, bigintReplacer, 2));
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
const lines = Object.entries(data).map(([key, value]) => {
|
|
123
|
+
return `${cyan(key)} ${dim(BOX.v)} ${formatValue(value)}`;
|
|
124
|
+
});
|
|
125
|
+
console.log("");
|
|
126
|
+
console.log(drawBox(lines, { color: cyan }));
|
|
127
|
+
console.log("");
|
|
128
|
+
}
|
|
129
|
+
function printSuccess(message, jsonMode, data) {
|
|
130
|
+
if (jsonMode) {
|
|
131
|
+
console.log(JSON.stringify({ success: true, message, ...data }, bigintReplacer, 2));
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
const title = `${green(bold(SYM.check))} ${green(bold(message))}`;
|
|
135
|
+
if (data) {
|
|
136
|
+
const lines = Object.entries(data).map(([key, value]) => {
|
|
137
|
+
return `${brightCyan(key)} ${dim(BOX.v)} ${formatValue(value)}`;
|
|
138
|
+
});
|
|
139
|
+
console.log("");
|
|
140
|
+
console.log(drawBox(lines, { title, color: green }));
|
|
141
|
+
console.log("");
|
|
142
|
+
} else {
|
|
143
|
+
console.log(`
|
|
144
|
+
${title}
|
|
145
|
+
`);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
function printError(error, jsonMode) {
|
|
149
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
150
|
+
if (jsonMode) {
|
|
151
|
+
console.error(JSON.stringify({ success: false, error: message }));
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
console.error(`
|
|
155
|
+
${red(bold(SYM.cross))} ${red(bold("Error:"))} ${message}
|
|
156
|
+
`);
|
|
157
|
+
}
|
|
158
|
+
function printStep(message, jsonMode) {
|
|
159
|
+
if (jsonMode) return;
|
|
160
|
+
console.log(` ${cyan(SYM.arrow)} ${message}`);
|
|
161
|
+
}
|
|
162
|
+
function printInfo(label, value, jsonMode) {
|
|
163
|
+
if (jsonMode) return;
|
|
164
|
+
console.log(` ${dim(gray(SYM.dot))} ${dim(label)} ${value}`);
|
|
165
|
+
}
|
|
166
|
+
function printWarning(message, jsonMode) {
|
|
167
|
+
if (jsonMode) return;
|
|
168
|
+
console.log(` ${yellow(SYM.warn)} ${yellow(message)}`);
|
|
169
|
+
}
|
|
170
|
+
function printKeyValue(data, jsonMode, title) {
|
|
171
|
+
if (jsonMode) {
|
|
172
|
+
console.log(JSON.stringify(data, bigintReplacer, 2));
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
const lines = [];
|
|
176
|
+
for (const [key, value] of Object.entries(data)) {
|
|
177
|
+
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
|
|
178
|
+
lines.push(bold(cyan(key)));
|
|
179
|
+
for (const [subKey, subVal] of Object.entries(value)) {
|
|
180
|
+
lines.push(` ${gray(subKey)} ${dim(BOX.v)} ${formatValue(subVal)}`);
|
|
181
|
+
}
|
|
182
|
+
} else {
|
|
183
|
+
lines.push(`${cyan(key)} ${dim(BOX.v)} ${formatValue(value)}`);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
console.log("");
|
|
187
|
+
console.log(drawBox(lines, { color: cyan, title }));
|
|
188
|
+
console.log("");
|
|
189
|
+
}
|
|
190
|
+
function formatValue(value) {
|
|
191
|
+
if (typeof value === "bigint") return value.toString();
|
|
192
|
+
if (typeof value === "object" && value !== null) return JSON.stringify(value, bigintReplacer);
|
|
193
|
+
return String(value);
|
|
194
|
+
}
|
|
195
|
+
function bigintReplacer(_key, value) {
|
|
196
|
+
return typeof value === "bigint" ? value.toString() : value;
|
|
197
|
+
}
|
|
198
|
+
export {
|
|
199
|
+
blockExplorerUrl,
|
|
200
|
+
getBanner,
|
|
201
|
+
printBanner,
|
|
202
|
+
printError,
|
|
203
|
+
printInfo,
|
|
204
|
+
printKeyValue,
|
|
205
|
+
printResult,
|
|
206
|
+
printStep,
|
|
207
|
+
printSuccess,
|
|
208
|
+
printWarning
|
|
209
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
declare const bold: (s: string) => string;
|
|
2
|
+
declare const dim: (s: string) => string;
|
|
3
|
+
declare const italic: (s: string) => string;
|
|
4
|
+
declare const underline: (s: string) => string;
|
|
5
|
+
declare const red: (s: string) => string;
|
|
6
|
+
declare const green: (s: string) => string;
|
|
7
|
+
declare const yellow: (s: string) => string;
|
|
8
|
+
declare const blue: (s: string) => string;
|
|
9
|
+
declare const magenta: (s: string) => string;
|
|
10
|
+
declare const cyan: (s: string) => string;
|
|
11
|
+
declare const white: (s: string) => string;
|
|
12
|
+
declare const gray: (s: string) => string;
|
|
13
|
+
declare const brightCyan: (s: string) => string;
|
|
14
|
+
declare const brightGreen: (s: string) => string;
|
|
15
|
+
declare const brightMagenta: (s: string) => string;
|
|
16
|
+
declare function rgb(r: number, g: number, b: number, text: string): string;
|
|
17
|
+
declare function gradient(text: string, from: [number, number, number], to: [number, number, number]): string;
|
|
18
|
+
declare const BRAND_FROM: [number, number, number];
|
|
19
|
+
declare const BRAND_TO: [number, number, number];
|
|
20
|
+
declare function brandGradient(text: string): string;
|
|
21
|
+
declare const SYM: {
|
|
22
|
+
readonly check: "✔" | "+";
|
|
23
|
+
readonly cross: "✖" | "x";
|
|
24
|
+
readonly arrow: "▸" | ">";
|
|
25
|
+
readonly dot: "●" | "*";
|
|
26
|
+
readonly star: "*" | "★";
|
|
27
|
+
readonly info: "i" | "ℹ";
|
|
28
|
+
readonly warn: "⚠" | "!";
|
|
29
|
+
readonly rocket: "🚀" | "^";
|
|
30
|
+
};
|
|
31
|
+
declare const BOX: {
|
|
32
|
+
readonly tl: "╭";
|
|
33
|
+
readonly tr: "╮";
|
|
34
|
+
readonly bl: "╰";
|
|
35
|
+
readonly br: "╯";
|
|
36
|
+
readonly h: "─";
|
|
37
|
+
readonly v: "│";
|
|
38
|
+
readonly lt: "├";
|
|
39
|
+
readonly rt: "┤";
|
|
40
|
+
};
|
|
41
|
+
declare function stripAnsi(str: string): string;
|
|
42
|
+
declare function drawBox(lines: string[], options?: {
|
|
43
|
+
title?: string;
|
|
44
|
+
color?: (s: string) => string;
|
|
45
|
+
padding?: number;
|
|
46
|
+
}): string;
|
|
47
|
+
declare function separator(width?: number): string;
|
|
48
|
+
|
|
49
|
+
export { BOX, BRAND_FROM, BRAND_TO, SYM, blue, bold, brandGradient, brightCyan, brightGreen, brightMagenta, cyan, dim, drawBox, gradient, gray, green, italic, magenta, red, rgb, separator, stripAnsi, underline, white, yellow };
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
// src/cli/utils/style.ts
|
|
2
|
+
var isColorSupported = process.env.NO_COLOR === void 0 && process.env.FORCE_COLOR !== "0" && process.env.TERM !== "dumb" && (process.env.FORCE_COLOR !== void 0 || process.stdout.isTTY === true);
|
|
3
|
+
var ESC = "\x1B[";
|
|
4
|
+
var RST = `${ESC}0m`;
|
|
5
|
+
function wrap(code, text) {
|
|
6
|
+
if (!isColorSupported) return text;
|
|
7
|
+
return `${ESC}${code}m${text}${RST}`;
|
|
8
|
+
}
|
|
9
|
+
var bold = (s) => wrap("1", s);
|
|
10
|
+
var dim = (s) => wrap("2", s);
|
|
11
|
+
var italic = (s) => wrap("3", s);
|
|
12
|
+
var underline = (s) => wrap("4", s);
|
|
13
|
+
var red = (s) => wrap("31", s);
|
|
14
|
+
var green = (s) => wrap("32", s);
|
|
15
|
+
var yellow = (s) => wrap("33", s);
|
|
16
|
+
var blue = (s) => wrap("34", s);
|
|
17
|
+
var magenta = (s) => wrap("35", s);
|
|
18
|
+
var cyan = (s) => wrap("36", s);
|
|
19
|
+
var white = (s) => wrap("37", s);
|
|
20
|
+
var gray = (s) => wrap("90", s);
|
|
21
|
+
var brightCyan = (s) => wrap("96", s);
|
|
22
|
+
var brightGreen = (s) => wrap("92", s);
|
|
23
|
+
var brightMagenta = (s) => wrap("95", s);
|
|
24
|
+
function rgb(r, g, b, text) {
|
|
25
|
+
if (!isColorSupported) return text;
|
|
26
|
+
return `${ESC}38;2;${r};${g};${b}m${text}${RST}`;
|
|
27
|
+
}
|
|
28
|
+
function gradient(text, from, to) {
|
|
29
|
+
if (!isColorSupported) return text;
|
|
30
|
+
const chars = [...text];
|
|
31
|
+
const total = chars.length;
|
|
32
|
+
if (total === 0) return "";
|
|
33
|
+
return chars.map((ch, i) => {
|
|
34
|
+
if (ch === " ") return ch;
|
|
35
|
+
const t = total > 1 ? i / (total - 1) : 0;
|
|
36
|
+
const r = Math.round(from[0] + (to[0] - from[0]) * t);
|
|
37
|
+
const g = Math.round(from[1] + (to[1] - from[1]) * t);
|
|
38
|
+
const b = Math.round(from[2] + (to[2] - from[2]) * t);
|
|
39
|
+
return `${ESC}38;2;${r};${g};${b}m${ch}`;
|
|
40
|
+
}).join("") + RST;
|
|
41
|
+
}
|
|
42
|
+
var BRAND_FROM = [6, 182, 212];
|
|
43
|
+
var BRAND_TO = [168, 85, 247];
|
|
44
|
+
function brandGradient(text) {
|
|
45
|
+
return gradient(text, BRAND_FROM, BRAND_TO);
|
|
46
|
+
}
|
|
47
|
+
var SYM = {
|
|
48
|
+
check: isColorSupported ? "\u2714" : "+",
|
|
49
|
+
cross: isColorSupported ? "\u2716" : "x",
|
|
50
|
+
arrow: isColorSupported ? "\u25B8" : ">",
|
|
51
|
+
dot: isColorSupported ? "\u25CF" : "*",
|
|
52
|
+
star: isColorSupported ? "\u2605" : "*",
|
|
53
|
+
info: isColorSupported ? "\u2139" : "i",
|
|
54
|
+
warn: isColorSupported ? "\u26A0" : "!",
|
|
55
|
+
rocket: isColorSupported ? "\u{1F680}" : "^"
|
|
56
|
+
};
|
|
57
|
+
var BOX = {
|
|
58
|
+
tl: "\u256D",
|
|
59
|
+
tr: "\u256E",
|
|
60
|
+
bl: "\u2570",
|
|
61
|
+
br: "\u256F",
|
|
62
|
+
h: "\u2500",
|
|
63
|
+
v: "\u2502",
|
|
64
|
+
lt: "\u251C",
|
|
65
|
+
rt: "\u2524"
|
|
66
|
+
};
|
|
67
|
+
function stripAnsi(str) {
|
|
68
|
+
return str.replace(/\x1b\[[0-9;]*m/g, "");
|
|
69
|
+
}
|
|
70
|
+
function drawBox(lines, options) {
|
|
71
|
+
const color = options?.color || cyan;
|
|
72
|
+
const pad = options?.padding ?? 1;
|
|
73
|
+
const contentWidth = Math.max(
|
|
74
|
+
...lines.map((l) => stripAnsi(l).length),
|
|
75
|
+
options?.title ? stripAnsi(options.title).length : 0,
|
|
76
|
+
20
|
|
77
|
+
);
|
|
78
|
+
const innerWidth = contentWidth + pad * 2;
|
|
79
|
+
const out = [];
|
|
80
|
+
out.push(color(`${BOX.tl}${BOX.h.repeat(innerWidth)}${BOX.tr}`));
|
|
81
|
+
if (options?.title) {
|
|
82
|
+
const titleLen = stripAnsi(options.title).length;
|
|
83
|
+
const titlePad = innerWidth - titleLen - pad;
|
|
84
|
+
out.push(
|
|
85
|
+
`${color(BOX.v)}${" ".repeat(pad)}${options.title}${" ".repeat(Math.max(0, titlePad))}${color(BOX.v)}`
|
|
86
|
+
);
|
|
87
|
+
out.push(color(`${BOX.lt}${BOX.h.repeat(innerWidth)}${BOX.rt}`));
|
|
88
|
+
}
|
|
89
|
+
for (const line of lines) {
|
|
90
|
+
const lineLen = stripAnsi(line).length;
|
|
91
|
+
const linePad = innerWidth - lineLen - pad;
|
|
92
|
+
out.push(
|
|
93
|
+
`${color(BOX.v)}${" ".repeat(pad)}${line}${" ".repeat(Math.max(0, linePad))}${color(BOX.v)}`
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
out.push(color(`${BOX.bl}${BOX.h.repeat(innerWidth)}${BOX.br}`));
|
|
97
|
+
return out.join("\n");
|
|
98
|
+
}
|
|
99
|
+
function separator(width = 50) {
|
|
100
|
+
if (!isColorSupported) return BOX.h.repeat(width);
|
|
101
|
+
return dim(gray(BOX.h.repeat(width)));
|
|
102
|
+
}
|
|
103
|
+
export {
|
|
104
|
+
BOX,
|
|
105
|
+
BRAND_FROM,
|
|
106
|
+
BRAND_TO,
|
|
107
|
+
SYM,
|
|
108
|
+
blue,
|
|
109
|
+
bold,
|
|
110
|
+
brandGradient,
|
|
111
|
+
brightCyan,
|
|
112
|
+
brightGreen,
|
|
113
|
+
brightMagenta,
|
|
114
|
+
cyan,
|
|
115
|
+
dim,
|
|
116
|
+
drawBox,
|
|
117
|
+
gradient,
|
|
118
|
+
gray,
|
|
119
|
+
green,
|
|
120
|
+
italic,
|
|
121
|
+
magenta,
|
|
122
|
+
red,
|
|
123
|
+
rgb,
|
|
124
|
+
separator,
|
|
125
|
+
stripAnsi,
|
|
126
|
+
underline,
|
|
127
|
+
white,
|
|
128
|
+
yellow
|
|
129
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Chain, WalletClient, Transport, Account, PublicClient } from 'viem';
|
|
2
|
+
import { privateKeyToAccount } from 'viem/accounts';
|
|
3
|
+
|
|
4
|
+
interface GlobalOpts {
|
|
5
|
+
chain?: string;
|
|
6
|
+
rpc?: string;
|
|
7
|
+
privateKey?: string;
|
|
8
|
+
json?: boolean;
|
|
9
|
+
dryRun?: boolean;
|
|
10
|
+
}
|
|
11
|
+
declare function resolveClients(opts: GlobalOpts): {
|
|
12
|
+
chain: Chain;
|
|
13
|
+
account: ReturnType<typeof privateKeyToAccount>;
|
|
14
|
+
walletClient: WalletClient<Transport, Chain, Account>;
|
|
15
|
+
publicClient: PublicClient;
|
|
16
|
+
};
|
|
17
|
+
declare function resolvePublicClient(opts: GlobalOpts): {
|
|
18
|
+
chain: Chain;
|
|
19
|
+
publicClient: PublicClient;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export { type GlobalOpts, resolveClients, resolvePublicClient };
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
// src/cli/utils/wallet.ts
|
|
2
|
+
import {
|
|
3
|
+
createPublicClient,
|
|
4
|
+
createWalletClient,
|
|
5
|
+
http
|
|
6
|
+
} from "viem";
|
|
7
|
+
import { privateKeyToAccount } from "viem/accounts";
|
|
8
|
+
|
|
9
|
+
// src/cli/utils/chains.ts
|
|
10
|
+
import { arbitrum, base, baseSepolia, bsc, mainnet, unichain } from "viem/chains";
|
|
11
|
+
|
|
12
|
+
// src/utils/chains/monad.ts
|
|
13
|
+
import { defineChain } from "viem";
|
|
14
|
+
var monad = /* @__PURE__ */ defineChain({
|
|
15
|
+
id: 143,
|
|
16
|
+
name: "Monad",
|
|
17
|
+
blockTime: 400,
|
|
18
|
+
nativeCurrency: {
|
|
19
|
+
name: "MON",
|
|
20
|
+
symbol: "MON",
|
|
21
|
+
decimals: 18
|
|
22
|
+
},
|
|
23
|
+
rpcUrls: {
|
|
24
|
+
default: {
|
|
25
|
+
http: ["https://rpc.monad.xyz"]
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
blockExplorers: {
|
|
29
|
+
default: {
|
|
30
|
+
name: "Monad explorer",
|
|
31
|
+
url: "TODO"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
contracts: {},
|
|
35
|
+
testnet: false
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
// src/cli/utils/chains.ts
|
|
39
|
+
var CHAIN_MAP = {
|
|
40
|
+
base,
|
|
41
|
+
"base-sepolia": baseSepolia,
|
|
42
|
+
arbitrum,
|
|
43
|
+
ethereum: mainnet,
|
|
44
|
+
bsc,
|
|
45
|
+
unichain,
|
|
46
|
+
monad
|
|
47
|
+
};
|
|
48
|
+
var CHAIN_NAMES = Object.keys(CHAIN_MAP);
|
|
49
|
+
function resolveChain(name) {
|
|
50
|
+
const chain = CHAIN_MAP[name];
|
|
51
|
+
if (!chain) {
|
|
52
|
+
throw new Error(`Unknown chain "${name}". Supported: ${CHAIN_NAMES.join(", ")}`);
|
|
53
|
+
}
|
|
54
|
+
return chain;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// src/cli/utils/config.ts
|
|
58
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
59
|
+
import { homedir } from "node:os";
|
|
60
|
+
import { join } from "node:path";
|
|
61
|
+
var CONFIG_DIR = join(homedir(), ".clanker");
|
|
62
|
+
var CONFIG_PATH = join(CONFIG_DIR, "config.json");
|
|
63
|
+
function loadConfig() {
|
|
64
|
+
try {
|
|
65
|
+
if (!existsSync(CONFIG_PATH)) return {};
|
|
66
|
+
return JSON.parse(readFileSync(CONFIG_PATH, "utf-8"));
|
|
67
|
+
} catch {
|
|
68
|
+
return {};
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// src/cli/utils/wallet.ts
|
|
73
|
+
function resolvePrivateKey(opts) {
|
|
74
|
+
const key = opts.privateKey || process.env.PRIVATE_KEY || loadConfig().privateKey;
|
|
75
|
+
if (!key) {
|
|
76
|
+
throw new Error(
|
|
77
|
+
"Private key required. Run `clanker setup`, pass --private-key, or set PRIVATE_KEY env var."
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
return key;
|
|
81
|
+
}
|
|
82
|
+
function resolveRpcUrl(opts, chainName) {
|
|
83
|
+
if (opts.rpc) return opts.rpc;
|
|
84
|
+
const config = loadConfig();
|
|
85
|
+
return config.rpc?.[chainName];
|
|
86
|
+
}
|
|
87
|
+
function resolveClients(opts) {
|
|
88
|
+
const chainName = opts.chain || loadConfig().defaultChain || "base";
|
|
89
|
+
const chain = resolveChain(chainName);
|
|
90
|
+
const rpcUrl = resolveRpcUrl(opts, chainName);
|
|
91
|
+
const transport = rpcUrl ? http(rpcUrl) : http();
|
|
92
|
+
const account = privateKeyToAccount(resolvePrivateKey(opts));
|
|
93
|
+
const walletClient = createWalletClient({ account, chain, transport });
|
|
94
|
+
const publicClient = createPublicClient({ chain, transport });
|
|
95
|
+
return { chain, account, walletClient, publicClient };
|
|
96
|
+
}
|
|
97
|
+
function resolvePublicClient(opts) {
|
|
98
|
+
const chainName = opts.chain || loadConfig().defaultChain || "base";
|
|
99
|
+
const chain = resolveChain(chainName);
|
|
100
|
+
const rpcUrl = resolveRpcUrl(opts, chainName);
|
|
101
|
+
const transport = rpcUrl ? http(rpcUrl) : http();
|
|
102
|
+
const publicClient = createPublicClient({ chain, transport });
|
|
103
|
+
return { chain, publicClient };
|
|
104
|
+
}
|
|
105
|
+
export {
|
|
106
|
+
resolveClients,
|
|
107
|
+
resolvePublicClient
|
|
108
|
+
};
|