clanker-sdk 4.2.10 → 4.2.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -9
- package/dist/{deploy-BvFgwMVl.d.ts → clankerTokenV4-DoIzm6GW.d.ts} +1822 -9
- package/dist/cli/cli.js +10456 -7324
- 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 +9883 -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 +29 -2
- 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 +25 -16
- package/dist/index.js +36 -2
- package/dist/legacyFeeClaims/index.js +25 -1
- package/dist/merkleTree-BNYdIOkH.d.ts +15 -0
- package/dist/v3/index.d.ts +4 -4
- package/dist/v3/index.js +28 -1
- package/dist/v4/extensions/index.d.ts +2 -1
- package/dist/v4/extensions/index.js +28 -1
- package/dist/v4/index.d.ts +5 -4
- package/dist/v4/index.js +28 -1
- package/package.json +2 -1
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
// src/cli/commands/setup.ts
|
|
2
|
+
import inquirer from "inquirer";
|
|
3
|
+
import { generatePrivateKey, privateKeyToAccount } from "viem/accounts";
|
|
4
|
+
|
|
5
|
+
// src/cli/utils/chains.ts
|
|
6
|
+
import { arbitrum, base, baseSepolia, bsc, mainnet, unichain } from "viem/chains";
|
|
7
|
+
|
|
8
|
+
// src/utils/chains/monad.ts
|
|
9
|
+
import { defineChain } from "viem";
|
|
10
|
+
var monad = /* @__PURE__ */ defineChain({
|
|
11
|
+
id: 143,
|
|
12
|
+
name: "Monad",
|
|
13
|
+
blockTime: 400,
|
|
14
|
+
nativeCurrency: {
|
|
15
|
+
name: "MON",
|
|
16
|
+
symbol: "MON",
|
|
17
|
+
decimals: 18
|
|
18
|
+
},
|
|
19
|
+
rpcUrls: {
|
|
20
|
+
default: {
|
|
21
|
+
http: ["https://rpc.monad.xyz"]
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
blockExplorers: {
|
|
25
|
+
default: {
|
|
26
|
+
name: "Monad explorer",
|
|
27
|
+
url: "TODO"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
contracts: {},
|
|
31
|
+
testnet: false
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
// src/cli/utils/chains.ts
|
|
35
|
+
var CHAIN_MAP = {
|
|
36
|
+
base,
|
|
37
|
+
"base-sepolia": baseSepolia,
|
|
38
|
+
arbitrum,
|
|
39
|
+
ethereum: mainnet,
|
|
40
|
+
bsc,
|
|
41
|
+
unichain,
|
|
42
|
+
monad
|
|
43
|
+
};
|
|
44
|
+
var CHAIN_NAMES = Object.keys(CHAIN_MAP);
|
|
45
|
+
|
|
46
|
+
// src/cli/utils/config.ts
|
|
47
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
48
|
+
import { homedir } from "node:os";
|
|
49
|
+
import { join } from "node:path";
|
|
50
|
+
var CONFIG_DIR = join(homedir(), ".clanker");
|
|
51
|
+
var CONFIG_PATH = join(CONFIG_DIR, "config.json");
|
|
52
|
+
function ensureDir() {
|
|
53
|
+
if (!existsSync(CONFIG_DIR)) {
|
|
54
|
+
mkdirSync(CONFIG_DIR, { recursive: true });
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function loadConfig() {
|
|
58
|
+
try {
|
|
59
|
+
if (!existsSync(CONFIG_PATH)) return {};
|
|
60
|
+
return JSON.parse(readFileSync(CONFIG_PATH, "utf-8"));
|
|
61
|
+
} catch {
|
|
62
|
+
return {};
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function saveConfig(config) {
|
|
66
|
+
ensureDir();
|
|
67
|
+
writeFileSync(CONFIG_PATH, JSON.stringify(config, null, 2), { mode: 384 });
|
|
68
|
+
}
|
|
69
|
+
function getConfigPath() {
|
|
70
|
+
return CONFIG_PATH;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// src/cli/utils/style.ts
|
|
74
|
+
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);
|
|
75
|
+
var ESC = "\x1B[";
|
|
76
|
+
var RST = `${ESC}0m`;
|
|
77
|
+
function wrap(code, text) {
|
|
78
|
+
if (!isColorSupported) return text;
|
|
79
|
+
return `${ESC}${code}m${text}${RST}`;
|
|
80
|
+
}
|
|
81
|
+
var bold = (s) => wrap("1", s);
|
|
82
|
+
var dim = (s) => wrap("2", s);
|
|
83
|
+
var red = (s) => wrap("31", s);
|
|
84
|
+
var green = (s) => wrap("32", s);
|
|
85
|
+
var yellow = (s) => wrap("33", s);
|
|
86
|
+
var cyan = (s) => wrap("36", s);
|
|
87
|
+
var gray = (s) => wrap("90", s);
|
|
88
|
+
var brightCyan = (s) => wrap("96", s);
|
|
89
|
+
var SYM = {
|
|
90
|
+
check: isColorSupported ? "\u2714" : "+",
|
|
91
|
+
cross: isColorSupported ? "\u2716" : "x",
|
|
92
|
+
arrow: isColorSupported ? "\u25B8" : ">",
|
|
93
|
+
dot: isColorSupported ? "\u25CF" : "*",
|
|
94
|
+
star: isColorSupported ? "\u2605" : "*",
|
|
95
|
+
info: isColorSupported ? "\u2139" : "i",
|
|
96
|
+
warn: isColorSupported ? "\u26A0" : "!",
|
|
97
|
+
rocket: isColorSupported ? "\u{1F680}" : "^"
|
|
98
|
+
};
|
|
99
|
+
var BOX = {
|
|
100
|
+
tl: "\u256D",
|
|
101
|
+
tr: "\u256E",
|
|
102
|
+
bl: "\u2570",
|
|
103
|
+
br: "\u256F",
|
|
104
|
+
h: "\u2500",
|
|
105
|
+
v: "\u2502",
|
|
106
|
+
lt: "\u251C",
|
|
107
|
+
rt: "\u2524"
|
|
108
|
+
};
|
|
109
|
+
function stripAnsi(str) {
|
|
110
|
+
return str.replace(/\x1b\[[0-9;]*m/g, "");
|
|
111
|
+
}
|
|
112
|
+
function drawBox(lines, options) {
|
|
113
|
+
const color = options?.color || cyan;
|
|
114
|
+
const pad = options?.padding ?? 1;
|
|
115
|
+
const contentWidth = Math.max(
|
|
116
|
+
...lines.map((l) => stripAnsi(l).length),
|
|
117
|
+
options?.title ? stripAnsi(options.title).length : 0,
|
|
118
|
+
20
|
|
119
|
+
);
|
|
120
|
+
const innerWidth = contentWidth + pad * 2;
|
|
121
|
+
const out = [];
|
|
122
|
+
out.push(color(`${BOX.tl}${BOX.h.repeat(innerWidth)}${BOX.tr}`));
|
|
123
|
+
if (options?.title) {
|
|
124
|
+
const titleLen = stripAnsi(options.title).length;
|
|
125
|
+
const titlePad = innerWidth - titleLen - pad;
|
|
126
|
+
out.push(
|
|
127
|
+
`${color(BOX.v)}${" ".repeat(pad)}${options.title}${" ".repeat(Math.max(0, titlePad))}${color(BOX.v)}`
|
|
128
|
+
);
|
|
129
|
+
out.push(color(`${BOX.lt}${BOX.h.repeat(innerWidth)}${BOX.rt}`));
|
|
130
|
+
}
|
|
131
|
+
for (const line of lines) {
|
|
132
|
+
const lineLen = stripAnsi(line).length;
|
|
133
|
+
const linePad = innerWidth - lineLen - pad;
|
|
134
|
+
out.push(
|
|
135
|
+
`${color(BOX.v)}${" ".repeat(pad)}${line}${" ".repeat(Math.max(0, linePad))}${color(BOX.v)}`
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
out.push(color(`${BOX.bl}${BOX.h.repeat(innerWidth)}${BOX.br}`));
|
|
139
|
+
return out.join("\n");
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// src/cli/utils/output.ts
|
|
143
|
+
function printSuccess(message, jsonMode, data) {
|
|
144
|
+
if (jsonMode) {
|
|
145
|
+
console.log(JSON.stringify({ success: true, message, ...data }, bigintReplacer, 2));
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
const title = `${green(bold(SYM.check))} ${green(bold(message))}`;
|
|
149
|
+
if (data) {
|
|
150
|
+
const lines = Object.entries(data).map(([key, value]) => {
|
|
151
|
+
return `${brightCyan(key)} ${dim(BOX.v)} ${formatValue(value)}`;
|
|
152
|
+
});
|
|
153
|
+
console.log("");
|
|
154
|
+
console.log(drawBox(lines, { title, color: green }));
|
|
155
|
+
console.log("");
|
|
156
|
+
} else {
|
|
157
|
+
console.log(`
|
|
158
|
+
${title}
|
|
159
|
+
`);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
function printStep(message, jsonMode) {
|
|
163
|
+
if (jsonMode) return;
|
|
164
|
+
console.log(` ${cyan(SYM.arrow)} ${message}`);
|
|
165
|
+
}
|
|
166
|
+
function formatValue(value) {
|
|
167
|
+
if (typeof value === "bigint") return value.toString();
|
|
168
|
+
if (typeof value === "object" && value !== null) return JSON.stringify(value, bigintReplacer);
|
|
169
|
+
return String(value);
|
|
170
|
+
}
|
|
171
|
+
function bigintReplacer(_key, value) {
|
|
172
|
+
return typeof value === "bigint" ? value.toString() : value;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// src/cli/commands/setup.ts
|
|
176
|
+
var PUBLIC_RPCS = {
|
|
177
|
+
base: "https://mainnet.base.org",
|
|
178
|
+
"base-sepolia": "https://sepolia.base.org",
|
|
179
|
+
arbitrum: "https://arb1.arbitrum.io/rpc",
|
|
180
|
+
ethereum: "https://eth.llamarpc.com",
|
|
181
|
+
bsc: "https://bsc-dataseed.binance.org",
|
|
182
|
+
unichain: "https://mainnet.unichain.org"
|
|
183
|
+
};
|
|
184
|
+
function registerSetupCommand(program) {
|
|
185
|
+
program.command("setup").description("Configure wallet and RPC settings").action(async (_opts, command) => {
|
|
186
|
+
const jsonMode = command.parent?.opts()?.json ?? false;
|
|
187
|
+
try {
|
|
188
|
+
await runSetup(jsonMode);
|
|
189
|
+
} catch (err) {
|
|
190
|
+
if (err instanceof Error && err.message === "prompt-cancelled") {
|
|
191
|
+
console.log(`
|
|
192
|
+
${dim(gray("Setup cancelled."))}
|
|
193
|
+
`);
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
throw err;
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
async function runSetup(jsonMode) {
|
|
201
|
+
const existing = loadConfig();
|
|
202
|
+
const hasExisting = !!(existing.privateKey || existing.rpc);
|
|
203
|
+
if (hasExisting) {
|
|
204
|
+
const account = existing.privateKey ? privateKeyToAccount(existing.privateKey) : null;
|
|
205
|
+
printStep(`Existing config found at ${dim(getConfigPath())}`, jsonMode);
|
|
206
|
+
if (account) {
|
|
207
|
+
printStep(`Wallet: ${cyan(account.address)}`, jsonMode);
|
|
208
|
+
}
|
|
209
|
+
if (existing.rpc) {
|
|
210
|
+
for (const [chain, url] of Object.entries(existing.rpc)) {
|
|
211
|
+
printStep(`RPC ${chain}: ${dim(url)}`, jsonMode);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
console.log("");
|
|
215
|
+
}
|
|
216
|
+
const { walletAction } = await inquirer.prompt([
|
|
217
|
+
{
|
|
218
|
+
type: "list",
|
|
219
|
+
name: "walletAction",
|
|
220
|
+
message: "Wallet setup:",
|
|
221
|
+
choices: [
|
|
222
|
+
{ name: "Create a new wallet", value: "create" },
|
|
223
|
+
{ name: "Import existing private key", value: "import" },
|
|
224
|
+
...existing.privateKey ? [{ name: "Keep current wallet", value: "keep" }] : [],
|
|
225
|
+
{ name: "Skip (use --private-key or PRIVATE_KEY env)", value: "skip" }
|
|
226
|
+
]
|
|
227
|
+
}
|
|
228
|
+
]);
|
|
229
|
+
let privateKey = existing.privateKey;
|
|
230
|
+
if (walletAction === "create") {
|
|
231
|
+
privateKey = generatePrivateKey();
|
|
232
|
+
const account = privateKeyToAccount(privateKey);
|
|
233
|
+
console.log("");
|
|
234
|
+
console.log(` ${green(bold("New wallet created"))}`);
|
|
235
|
+
console.log(` ${cyan("Address:")} ${account.address}`);
|
|
236
|
+
console.log("");
|
|
237
|
+
console.log(` ${red(bold("IMPORTANT:"))} Fund this address with ETH before deploying.`);
|
|
238
|
+
console.log(
|
|
239
|
+
` ${yellow("Your private key is saved locally.")} Back up ${dim(getConfigPath())} securely.`
|
|
240
|
+
);
|
|
241
|
+
console.log("");
|
|
242
|
+
} else if (walletAction === "import") {
|
|
243
|
+
const { key } = await inquirer.prompt([
|
|
244
|
+
{
|
|
245
|
+
type: "password",
|
|
246
|
+
name: "key",
|
|
247
|
+
message: "Enter your private key (0x...):",
|
|
248
|
+
mask: "*",
|
|
249
|
+
validate: (v) => /^0x[a-fA-F0-9]{64}$/.test(v) || "Must be a 0x-prefixed 64-char hex string"
|
|
250
|
+
}
|
|
251
|
+
]);
|
|
252
|
+
privateKey = key;
|
|
253
|
+
const account = privateKeyToAccount(key);
|
|
254
|
+
console.log(`
|
|
255
|
+
${green("Imported:")} ${account.address}
|
|
256
|
+
`);
|
|
257
|
+
}
|
|
258
|
+
const { defaultChain } = await inquirer.prompt([
|
|
259
|
+
{
|
|
260
|
+
type: "list",
|
|
261
|
+
name: "defaultChain",
|
|
262
|
+
message: "Default chain:",
|
|
263
|
+
choices: CHAIN_NAMES,
|
|
264
|
+
default: existing.defaultChain || "base"
|
|
265
|
+
}
|
|
266
|
+
]);
|
|
267
|
+
const { rpcAction } = await inquirer.prompt([
|
|
268
|
+
{
|
|
269
|
+
type: "list",
|
|
270
|
+
name: "rpcAction",
|
|
271
|
+
message: `RPC for ${bold(defaultChain)}:`,
|
|
272
|
+
choices: [
|
|
273
|
+
...PUBLIC_RPCS[defaultChain] ? [{ name: `Use public RPC (${dim(PUBLIC_RPCS[defaultChain])})`, value: "public" }] : [],
|
|
274
|
+
{ name: "Enter a private RPC URL", value: "custom" },
|
|
275
|
+
...existing.rpc?.[defaultChain] ? [{ name: `Keep current (${dim(existing.rpc[defaultChain])})`, value: "keep" }] : []
|
|
276
|
+
]
|
|
277
|
+
}
|
|
278
|
+
]);
|
|
279
|
+
const rpcMap = { ...existing.rpc };
|
|
280
|
+
if (rpcAction === "public" && PUBLIC_RPCS[defaultChain]) {
|
|
281
|
+
rpcMap[defaultChain] = PUBLIC_RPCS[defaultChain];
|
|
282
|
+
} else if (rpcAction === "custom") {
|
|
283
|
+
const { customRpc } = await inquirer.prompt([
|
|
284
|
+
{
|
|
285
|
+
type: "input",
|
|
286
|
+
name: "customRpc",
|
|
287
|
+
message: "RPC URL:",
|
|
288
|
+
validate: (v) => {
|
|
289
|
+
try {
|
|
290
|
+
new URL(v);
|
|
291
|
+
return true;
|
|
292
|
+
} catch {
|
|
293
|
+
return "Must be a valid URL";
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
]);
|
|
298
|
+
rpcMap[defaultChain] = customRpc;
|
|
299
|
+
}
|
|
300
|
+
saveConfig({
|
|
301
|
+
...privateKey ? { privateKey } : {},
|
|
302
|
+
rpc: Object.keys(rpcMap).length > 0 ? rpcMap : void 0,
|
|
303
|
+
defaultChain
|
|
304
|
+
});
|
|
305
|
+
printSuccess("Configuration saved!", jsonMode, {
|
|
306
|
+
config: getConfigPath(),
|
|
307
|
+
chain: defaultChain,
|
|
308
|
+
rpc: rpcMap[defaultChain] || "default",
|
|
309
|
+
wallet: privateKey ? privateKeyToAccount(privateKey).address : "not configured"
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
export {
|
|
313
|
+
registerSetupCommand
|
|
314
|
+
};
|