arc402-cli 0.4.0 → 0.4.2
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/commands/arbitrator.d.ts.map +1 -1
- package/dist/commands/arbitrator.js +62 -13
- package/dist/commands/arbitrator.js.map +1 -1
- package/dist/commands/arena.d.ts.map +1 -1
- package/dist/commands/arena.js +4 -3
- package/dist/commands/arena.js.map +1 -1
- package/dist/commands/cancel.d.ts.map +1 -1
- package/dist/commands/cancel.js +20 -10
- package/dist/commands/cancel.js.map +1 -1
- package/dist/commands/config.d.ts.map +1 -1
- package/dist/commands/config.js +1 -0
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/deliver.d.ts.map +1 -1
- package/dist/commands/deliver.js +16 -3
- package/dist/commands/deliver.js.map +1 -1
- package/dist/commands/discover.d.ts.map +1 -1
- package/dist/commands/discover.js +2 -0
- package/dist/commands/discover.js.map +1 -1
- package/dist/commands/dispute.d.ts.map +1 -1
- package/dist/commands/dispute.js +11 -10
- package/dist/commands/dispute.js.map +1 -1
- package/dist/commands/hire.d.ts.map +1 -1
- package/dist/commands/hire.js +12 -2
- package/dist/commands/hire.js.map +1 -1
- package/dist/commands/migrate.d.ts.map +1 -1
- package/dist/commands/migrate.js +29 -29
- package/dist/commands/migrate.js.map +1 -1
- package/dist/commands/negotiate.d.ts.map +1 -1
- package/dist/commands/negotiate.js +8 -7
- package/dist/commands/negotiate.js.map +1 -1
- package/dist/commands/openshell.d.ts.map +1 -1
- package/dist/commands/openshell.js +6 -5
- package/dist/commands/openshell.js.map +1 -1
- package/dist/commands/owner.d.ts.map +1 -1
- package/dist/commands/owner.js +2 -1
- package/dist/commands/owner.js.map +1 -1
- package/dist/commands/policy.d.ts.map +1 -1
- package/dist/commands/policy.js +22 -10
- package/dist/commands/policy.js.map +1 -1
- package/dist/commands/relay.js +6 -5
- package/dist/commands/relay.js.map +1 -1
- package/dist/commands/remediate.js +3 -2
- package/dist/commands/remediate.js.map +1 -1
- package/dist/commands/reputation.d.ts.map +1 -1
- package/dist/commands/reputation.js +12 -5
- package/dist/commands/reputation.js.map +1 -1
- package/dist/commands/trust.d.ts.map +1 -1
- package/dist/commands/trust.js +16 -1
- package/dist/commands/trust.js.map +1 -1
- package/dist/commands/verify.d.ts.map +1 -1
- package/dist/commands/verify.js +6 -4
- package/dist/commands/verify.js.map +1 -1
- package/dist/commands/wallet.d.ts.map +1 -1
- package/dist/commands/wallet.js +202 -165
- package/dist/commands/wallet.js.map +1 -1
- package/dist/commands/watchtower.d.ts.map +1 -1
- package/dist/commands/watchtower.js +30 -13
- package/dist/commands/watchtower.js.map +1 -1
- package/dist/commands/workroom.d.ts.map +1 -1
- package/dist/commands/workroom.js +123 -95
- package/dist/commands/workroom.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -0
- package/dist/config.js.map +1 -1
- package/package.json +1 -1
- package/src/commands/arbitrator.ts +45 -10
- package/src/commands/arena.ts +4 -3
- package/src/commands/cancel.ts +19 -10
- package/src/commands/config.ts +1 -0
- package/src/commands/deliver.ts +16 -3
- package/src/commands/discover.ts +2 -0
- package/src/commands/dispute.ts +12 -10
- package/src/commands/hire.ts +9 -2
- package/src/commands/migrate.ts +28 -26
- package/src/commands/negotiate.ts +8 -7
- package/src/commands/openshell.ts +7 -5
- package/src/commands/owner.ts +2 -1
- package/src/commands/policy.ts +18 -10
- package/src/commands/relay.ts +5 -5
- package/src/commands/remediate.ts +2 -2
- package/src/commands/reputation.ts +9 -5
- package/src/commands/trust.ts +10 -1
- package/src/commands/verify.ts +5 -4
- package/src/commands/wallet.ts +203 -165
- package/src/commands/watchtower.ts +25 -13
- package/src/commands/workroom.ts +121 -95
- package/src/config.ts +2 -1
package/dist/commands/wallet.js
CHANGED
|
@@ -64,9 +64,9 @@ async function runWalletOnboardingCeremony(walletAddress, ownerAddress, config,
|
|
|
64
64
|
alreadyDefiEnabled = await policyGov.defiAccessEnabled(walletAddress);
|
|
65
65
|
}
|
|
66
66
|
catch { /* assume not enabled */ }
|
|
67
|
-
console.log("\n── Onboarding ceremony ────────────────────────────────────────");
|
|
68
|
-
console.log(
|
|
69
|
-
console.log(
|
|
67
|
+
console.log("\n" + colors_1.c.dim("── Onboarding ceremony ────────────────────────────────────────"));
|
|
68
|
+
console.log(" " + colors_1.c.dim("PolicyEngine:") + " " + colors_1.c.white(policyAddress));
|
|
69
|
+
console.log(" " + colors_1.c.dim("Wallet: ") + " " + colors_1.c.white(walletAddress));
|
|
70
70
|
// Step 1: registerWallet (if not already done)
|
|
71
71
|
if (!alreadyRegistered) {
|
|
72
72
|
const registerCalldata = govIface.encodeFunctionData("registerWallet", [walletAddress, ownerAddress]);
|
|
@@ -84,7 +84,7 @@ async function runWalletOnboardingCeremony(walletAddress, ownerAddress, config,
|
|
|
84
84
|
}, "registerWallet on PolicyEngine");
|
|
85
85
|
}
|
|
86
86
|
else {
|
|
87
|
-
console.log("
|
|
87
|
+
console.log(" " + colors_1.c.success + colors_1.c.dim(" registerWallet — already done by constructor"));
|
|
88
88
|
}
|
|
89
89
|
// Step 2: enableDefiAccess (if not already done)
|
|
90
90
|
if (!alreadyDefiEnabled) {
|
|
@@ -95,7 +95,7 @@ async function runWalletOnboardingCeremony(walletAddress, ownerAddress, config,
|
|
|
95
95
|
}, "enableDefiAccess on PolicyEngine");
|
|
96
96
|
}
|
|
97
97
|
else {
|
|
98
|
-
console.log("
|
|
98
|
+
console.log(" " + colors_1.c.success + colors_1.c.dim(" enableDefiAccess — already done by constructor"));
|
|
99
99
|
}
|
|
100
100
|
// Steps 3–6: category limits (always set — idempotent)
|
|
101
101
|
for (const { name, amountEth } of ONBOARDING_CATEGORIES) {
|
|
@@ -109,10 +109,10 @@ async function runWalletOnboardingCeremony(walletAddress, ownerAddress, config,
|
|
|
109
109
|
value: "0x0",
|
|
110
110
|
}, `setCategoryLimitFor: ${name} → ${amountEth} ETH`);
|
|
111
111
|
}
|
|
112
|
-
console.log("── Onboarding complete ─────────────────────────────────────────");
|
|
113
|
-
console.log("
|
|
114
|
-
console.log("
|
|
115
|
-
console.log("
|
|
112
|
+
console.log(colors_1.c.dim("── Onboarding complete ─────────────────────────────────────────"));
|
|
113
|
+
console.log(colors_1.c.dim("Tip: For production security, also configure:"));
|
|
114
|
+
console.log(" " + colors_1.c.dim("arc402 wallet set-velocity-limit <eth> — wallet-level hourly ETH cap"));
|
|
115
|
+
console.log(" " + colors_1.c.dim("arc402 wallet policy set-daily-limit --category general --amount <eth> — daily per-category cap"));
|
|
116
116
|
}
|
|
117
117
|
function printOpenShellHint() {
|
|
118
118
|
const r = (0, child_process_1.spawnSync)("which", ["openshell"], { encoding: "utf-8" });
|
|
@@ -168,13 +168,21 @@ function registerWalletCommands(program) {
|
|
|
168
168
|
console.log(JSON.stringify(payload, null, 2));
|
|
169
169
|
}
|
|
170
170
|
else {
|
|
171
|
-
|
|
171
|
+
const treeItems = [
|
|
172
|
+
{ label: "Address", value: payload.address },
|
|
173
|
+
{ label: "Network", value: payload.network },
|
|
174
|
+
{ label: "ETH", value: payload.ethBalance + " ETH" },
|
|
175
|
+
{ label: "USDC", value: payload.usdcBalance + " USDC" },
|
|
176
|
+
{ label: "Trust", value: `${payload.trustScore} ${payload.trustTier}` },
|
|
177
|
+
];
|
|
172
178
|
if (payload.walletContractAddress)
|
|
173
|
-
|
|
179
|
+
treeItems.push({ label: "Contract", value: payload.walletContractAddress });
|
|
174
180
|
if (contractFrozen !== null)
|
|
175
|
-
|
|
181
|
+
treeItems.push({ label: "Frozen", value: contractFrozen ? colors_1.c.red("YES") : colors_1.c.green("no") });
|
|
176
182
|
if (contractGuardian && contractGuardian !== ethers_1.ethers.ZeroAddress)
|
|
177
|
-
|
|
183
|
+
treeItems.push({ label: "Guardian", value: contractGuardian });
|
|
184
|
+
treeItems[treeItems.length - 1].last = true;
|
|
185
|
+
(0, tree_1.renderTree)(treeItems);
|
|
178
186
|
}
|
|
179
187
|
});
|
|
180
188
|
// ─── wc-reset ──────────────────────────────────────────────────────────────
|
|
@@ -206,7 +214,7 @@ function registerWalletCommands(program) {
|
|
|
206
214
|
console.log(JSON.stringify({ ok: false, error: `Could not delete ${wcStoragePath}: ${msg}` }));
|
|
207
215
|
}
|
|
208
216
|
else {
|
|
209
|
-
console.warn(
|
|
217
|
+
console.warn(" " + colors_1.c.warning + " " + colors_1.c.yellow(`Could not delete ${wcStoragePath}: ${msg}`));
|
|
210
218
|
console.warn(" You may need to delete it manually.");
|
|
211
219
|
}
|
|
212
220
|
return;
|
|
@@ -215,12 +223,12 @@ function registerWalletCommands(program) {
|
|
|
215
223
|
console.log(JSON.stringify({ ok: true, hadSession, storageWiped }));
|
|
216
224
|
}
|
|
217
225
|
else {
|
|
218
|
-
console.log("
|
|
226
|
+
console.log(" " + colors_1.c.success + colors_1.c.white(" WalletConnect session cleared"));
|
|
219
227
|
if (storageWiped)
|
|
220
|
-
console.log(
|
|
228
|
+
console.log(" " + colors_1.c.dim("Storage wiped:") + " " + colors_1.c.white(wcStoragePath));
|
|
221
229
|
else
|
|
222
|
-
console.log("
|
|
223
|
-
console.log("\
|
|
230
|
+
console.log(" " + colors_1.c.dim("(No storage file found — already clean)"));
|
|
231
|
+
console.log("\n" + colors_1.c.dim("Next: run any wallet command and scan the fresh QR code."));
|
|
224
232
|
}
|
|
225
233
|
});
|
|
226
234
|
// ─── new ───────────────────────────────────────────────────────────────────
|
|
@@ -243,9 +251,11 @@ function registerWalletCommands(program) {
|
|
|
243
251
|
walletFactoryAddress: defaults.walletFactoryAddress,
|
|
244
252
|
};
|
|
245
253
|
(0, config_1.saveConfig)(config);
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
254
|
+
(0, tree_1.renderTree)([
|
|
255
|
+
{ label: "Address", value: generated.address },
|
|
256
|
+
{ label: "Config", value: (0, config_1.getConfigPath)(), last: true },
|
|
257
|
+
]);
|
|
258
|
+
console.log(colors_1.c.dim("Next: fund your wallet with ETH, then run: arc402 wallet deploy"));
|
|
249
259
|
});
|
|
250
260
|
// ─── import ────────────────────────────────────────────────────────────────
|
|
251
261
|
wallet.command("import <privateKey>")
|
|
@@ -274,9 +284,11 @@ function registerWalletCommands(program) {
|
|
|
274
284
|
walletFactoryAddress: defaults.walletFactoryAddress,
|
|
275
285
|
};
|
|
276
286
|
(0, config_1.saveConfig)(config);
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
287
|
+
(0, tree_1.renderTree)([
|
|
288
|
+
{ label: "Address", value: imported.address },
|
|
289
|
+
{ label: "Config", value: (0, config_1.getConfigPath)(), last: true },
|
|
290
|
+
]);
|
|
291
|
+
console.warn(" " + colors_1.c.warning + " " + colors_1.c.yellow("Store your private key safely — anyone with it controls your wallet"));
|
|
280
292
|
});
|
|
281
293
|
// ─── fund ──────────────────────────────────────────────────────────────────
|
|
282
294
|
wallet.command("fund")
|
|
@@ -485,16 +497,19 @@ function registerWalletCommands(program) {
|
|
|
485
497
|
config.walletContractAddress = senderAddress;
|
|
486
498
|
config.ownerAddress = ownerAddress;
|
|
487
499
|
(0, config_1.saveConfig)(config);
|
|
488
|
-
console.log(
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
console.log(
|
|
495
|
-
console.log(
|
|
496
|
-
console.log(
|
|
497
|
-
console.log(
|
|
500
|
+
console.log("\n" + colors_1.c.success + colors_1.c.white(" ARC402Wallet deployed (sponsored)"));
|
|
501
|
+
(0, tree_1.renderTree)([
|
|
502
|
+
{ label: "Wallet", value: senderAddress },
|
|
503
|
+
{ label: "Owner", value: ownerAddress },
|
|
504
|
+
{ label: "Gas", value: "Sponsorship active — initial setup ops are free", last: true },
|
|
505
|
+
]);
|
|
506
|
+
console.log(" " + colors_1.c.warning + " " + colors_1.c.yellow("IMPORTANT: Onboarding ceremony was not run on this wallet."));
|
|
507
|
+
console.log(colors_1.c.dim(" Category spend limits have NOT been configured. All executeSpend and"));
|
|
508
|
+
console.log(colors_1.c.dim(` executeTokenSpend calls will fail with "PolicyEngine: category not configured"`));
|
|
509
|
+
console.log(colors_1.c.dim(" until you run governance setup manually via WalletConnect:"));
|
|
510
|
+
console.log("\n" + colors_1.c.dim(" arc402 wallet governance setup"));
|
|
511
|
+
console.log("\n" + colors_1.c.dim(" This must be done before making any spend from this wallet."));
|
|
512
|
+
console.log("\n" + colors_1.c.dim("Next: arc402 wallet set-passkey <x> <y> --sponsored"));
|
|
498
513
|
printOpenShellHint();
|
|
499
514
|
}
|
|
500
515
|
else if (opts.smartWallet) {
|
|
@@ -529,10 +544,13 @@ function registerWalletCommands(program) {
|
|
|
529
544
|
config.walletContractAddress = walletAddress;
|
|
530
545
|
config.ownerAddress = account;
|
|
531
546
|
(0, config_1.saveConfig)(config);
|
|
532
|
-
console.log(
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
547
|
+
console.log("\n" + colors_1.c.success + colors_1.c.white(" ARC402Wallet deployed"));
|
|
548
|
+
(0, tree_1.renderTree)([
|
|
549
|
+
{ label: "Wallet", value: walletAddress },
|
|
550
|
+
{ label: "Owner", value: account + colors_1.c.dim(" (Base Smart Wallet)"), last: true },
|
|
551
|
+
]);
|
|
552
|
+
console.log(colors_1.c.dim("Your wallet contract is ready for policy enforcement"));
|
|
553
|
+
console.log(colors_1.c.dim("\nNext: run 'arc402 wallet set-guardian' to configure the emergency guardian key."));
|
|
536
554
|
printOpenShellHint();
|
|
537
555
|
}
|
|
538
556
|
else if (config.walletConnectProjectId) {
|
|
@@ -543,7 +561,7 @@ function registerWalletCommands(program) {
|
|
|
543
561
|
const { client, session, account } = await (0, walletconnect_1.connectPhoneWallet)(config.walletConnectProjectId, chainId, config, { telegramOpts, prompt: "Approve ARC402Wallet deployment — you will be set as owner", hardware: !!opts.hardware });
|
|
544
562
|
const networkName = chainId === 8453 ? "Base" : "Base Sepolia";
|
|
545
563
|
const shortAddr = `${account.slice(0, 6)}...${account.slice(-5)}`;
|
|
546
|
-
console.log(
|
|
564
|
+
console.log("\n" + colors_1.c.success + colors_1.c.white(` Connected: ${shortAddr} on ${networkName}`));
|
|
547
565
|
if (telegramOpts) {
|
|
548
566
|
// Send "connected" message with a deploy confirmation button.
|
|
549
567
|
// TODO: wire up full callback_data round-trip when a persistent bot process is available.
|
|
@@ -589,24 +607,27 @@ function registerWalletCommands(program) {
|
|
|
589
607
|
config.walletContractAddress = walletAddress;
|
|
590
608
|
config.ownerAddress = account;
|
|
591
609
|
(0, config_1.saveConfig)(config);
|
|
592
|
-
console.log(
|
|
593
|
-
|
|
610
|
+
console.log("\n" + colors_1.c.success + colors_1.c.white(" ARC402Wallet deployed"));
|
|
611
|
+
(0, tree_1.renderTree)([
|
|
612
|
+
{ label: "Wallet", value: walletAddress },
|
|
613
|
+
{ label: "Owner", value: account + colors_1.c.dim(" (phone wallet)"), last: true },
|
|
614
|
+
]);
|
|
594
615
|
// ── Mandatory onboarding ceremony (same WalletConnect session) ────────
|
|
595
616
|
console.log("\nStarting mandatory onboarding ceremony in this WalletConnect session...");
|
|
596
617
|
await runWalletOnboardingCeremony(walletAddress, account, config, provider, async (call, description) => {
|
|
597
|
-
console.log(`
|
|
618
|
+
console.log(" " + colors_1.c.dim(`Sending: ${description}`));
|
|
598
619
|
const hash = await (0, walletconnect_1.sendTransactionWithSession)(client, session, account, chainId, call);
|
|
599
620
|
await provider.waitForTransaction(hash, 1);
|
|
600
|
-
console.log(
|
|
621
|
+
console.log(" " + colors_1.c.success + " " + colors_1.c.dim(description) + " " + colors_1.c.dim(hash));
|
|
601
622
|
return hash;
|
|
602
623
|
});
|
|
603
|
-
console.log(
|
|
624
|
+
console.log(colors_1.c.dim("Your wallet contract is ready for policy enforcement"));
|
|
604
625
|
const paymasterUrl2 = config.paymasterUrl ?? config_1.NETWORK_DEFAULTS[config.network]?.paymasterUrl;
|
|
605
626
|
const deployedBalance = await provider.getBalance(walletAddress);
|
|
606
627
|
if (paymasterUrl2 && deployedBalance < BigInt(1000000000000000)) {
|
|
607
|
-
console.log("Gas sponsorship active — initial setup ops are free");
|
|
628
|
+
console.log(colors_1.c.dim("Gas sponsorship active — initial setup ops are free"));
|
|
608
629
|
}
|
|
609
|
-
console.log(
|
|
630
|
+
console.log(colors_1.c.dim("\nNext: run 'arc402 wallet set-guardian' to configure the emergency guardian key."));
|
|
610
631
|
printOpenShellHint();
|
|
611
632
|
}
|
|
612
633
|
else {
|
|
@@ -647,10 +668,10 @@ function registerWalletCommands(program) {
|
|
|
647
668
|
console.log("\nRunning mandatory onboarding ceremony...");
|
|
648
669
|
const provider2 = new ethers_1.ethers.JsonRpcProvider(config.rpcUrl);
|
|
649
670
|
await runWalletOnboardingCeremony(walletAddress, address, config, provider2, async (call, description) => {
|
|
650
|
-
console.log(`
|
|
671
|
+
console.log(" " + colors_1.c.dim(`Sending: ${description}`));
|
|
651
672
|
const tx2 = await signer.sendTransaction({ to: call.to, data: call.data, value: call.value === "0x0" ? 0n : BigInt(call.value) });
|
|
652
673
|
await tx2.wait(1);
|
|
653
|
-
console.log(
|
|
674
|
+
console.log(" " + colors_1.c.success + " " + colors_1.c.dim(description) + " " + colors_1.c.dim(tx2.hash));
|
|
654
675
|
return tx2.hash;
|
|
655
676
|
});
|
|
656
677
|
console.log(` ${colors_1.c.success} ARC402Wallet deployed`);
|
|
@@ -836,9 +857,9 @@ function registerWalletCommands(program) {
|
|
|
836
857
|
value: "0x0",
|
|
837
858
|
}), `Approve: update policy to ${policyIdHex}`, telegramOpts, config);
|
|
838
859
|
await provider.waitForTransaction(txHash);
|
|
839
|
-
console.log(
|
|
840
|
-
console.log(
|
|
841
|
-
console.log(
|
|
860
|
+
console.log("\n" + colors_1.c.success + colors_1.c.white(" Active policy updated"));
|
|
861
|
+
console.log(" " + colors_1.c.dim("Tx:") + " " + colors_1.c.white(txHash));
|
|
862
|
+
console.log(" " + colors_1.c.dim("Policy:") + " " + colors_1.c.white(policyIdHex));
|
|
842
863
|
});
|
|
843
864
|
// ─── freeze (guardian key — emergency wallet freeze) ──────────────────────
|
|
844
865
|
//
|
|
@@ -910,10 +931,10 @@ function registerWalletCommands(program) {
|
|
|
910
931
|
const { client, session, account } = await (0, walletconnect_1.connectPhoneWallet)(config.walletConnectProjectId, chainId, config, { telegramOpts, prompt: "Approve: unfreeze ARC402Wallet", hardware: !!opts.hardware });
|
|
911
932
|
const networkName = chainId === 8453 ? "Base" : "Base Sepolia";
|
|
912
933
|
const shortAddr = `${account.slice(0, 6)}...${account.slice(-5)}`;
|
|
913
|
-
console.log(
|
|
914
|
-
console.log(
|
|
934
|
+
console.log("\n" + colors_1.c.success + colors_1.c.white(` Connected: ${shortAddr} on ${networkName}`));
|
|
935
|
+
console.log("\n" + colors_1.c.dim("Wallet to unfreeze:") + " " + colors_1.c.white(config.walletContractAddress ?? ""));
|
|
915
936
|
// WalletConnect approval already confirmed intent — sending automatically
|
|
916
|
-
console.log("Sending transaction...");
|
|
937
|
+
console.log(colors_1.c.dim("Sending transaction..."));
|
|
917
938
|
const txHash = await (0, walletconnect_1.sendTransactionWithSession)(client, session, account, chainId, {
|
|
918
939
|
to: config.walletContractAddress,
|
|
919
940
|
data: walletInterface.encodeFunctionData("unfreeze", []),
|
|
@@ -924,8 +945,8 @@ function registerWalletCommands(program) {
|
|
|
924
945
|
console.log(JSON.stringify({ txHash, walletAddress: config.walletContractAddress }));
|
|
925
946
|
}
|
|
926
947
|
else {
|
|
927
|
-
console.log(
|
|
928
|
-
console.log(
|
|
948
|
+
console.log("\n" + colors_1.c.success + colors_1.c.white(` Wallet ${config.walletContractAddress} unfrozen`));
|
|
949
|
+
console.log(" " + colors_1.c.dim("Tx:") + " " + colors_1.c.white(txHash));
|
|
929
950
|
}
|
|
930
951
|
});
|
|
931
952
|
// ─── set-guardian ──────────────────────────────────────────────────────────
|
|
@@ -971,9 +992,9 @@ function registerWalletCommands(program) {
|
|
|
971
992
|
const { client, session, account } = await (0, walletconnect_1.connectPhoneWallet)(config.walletConnectProjectId, chainId, config, { telegramOpts, prompt: `Approve: set guardian to ${guardianWallet.address}`, hardware: !!opts.hardware });
|
|
972
993
|
const networkName = chainId === 8453 ? "Base" : "Base Sepolia";
|
|
973
994
|
const shortAddr = `${account.slice(0, 6)}...${account.slice(-5)}`;
|
|
974
|
-
console.log(
|
|
995
|
+
console.log("\n" + colors_1.c.success + colors_1.c.white(` Connected: ${shortAddr} on ${networkName}`));
|
|
975
996
|
// WalletConnect approval already confirmed intent — sending automatically
|
|
976
|
-
console.log("Sending transaction...");
|
|
997
|
+
console.log(colors_1.c.dim("Sending transaction..."));
|
|
977
998
|
const txHash = await (0, walletconnect_1.sendTransactionWithSession)(client, session, account, chainId, {
|
|
978
999
|
to: config.walletContractAddress,
|
|
979
1000
|
data: walletInterface.encodeFunctionData("setGuardian", [guardianWallet.address]),
|
|
@@ -983,10 +1004,10 @@ function registerWalletCommands(program) {
|
|
|
983
1004
|
config.guardianPrivateKey = guardianWallet.privateKey;
|
|
984
1005
|
config.guardianAddress = guardianWallet.address;
|
|
985
1006
|
(0, config_1.saveConfig)(config);
|
|
986
|
-
console.log(
|
|
987
|
-
console.log(
|
|
988
|
-
console.log(
|
|
989
|
-
console.log(
|
|
1007
|
+
console.log("\n" + colors_1.c.success + colors_1.c.white(` Guardian set to: ${guardianWallet.address}`));
|
|
1008
|
+
console.log(" " + colors_1.c.dim("Tx:") + " " + colors_1.c.white(txHash));
|
|
1009
|
+
console.log(" " + colors_1.c.dim("Guardian private key saved to config."));
|
|
1010
|
+
console.log(" " + colors_1.c.warning + " " + colors_1.c.yellow("The guardian key can freeze your wallet. Store it separately from your hot key."));
|
|
990
1011
|
});
|
|
991
1012
|
// ─── policy-engine freeze / unfreeze (legacy — for PolicyEngine-level freeze) ──
|
|
992
1013
|
wallet.command("freeze-policy <walletAddress>")
|
|
@@ -1068,18 +1089,18 @@ function registerWalletCommands(program) {
|
|
|
1068
1089
|
const { client, session, account } = await (0, walletconnect_1.connectPhoneWallet)(config.walletConnectProjectId, chainId, config, { telegramOpts, prompt: "Approve registry upgrade proposal on ARC402Wallet", hardware: !!opts.hardware });
|
|
1069
1090
|
const networkName = chainId === 8453 ? "Base" : "Base Sepolia";
|
|
1070
1091
|
const shortAddr = `${account.slice(0, 6)}...${account.slice(-5)}`;
|
|
1071
|
-
console.log(
|
|
1092
|
+
console.log("\n" + colors_1.c.success + colors_1.c.white(` Connected: ${shortAddr} on ${networkName}`));
|
|
1072
1093
|
// WalletConnect approval already confirmed intent — sending automatically
|
|
1073
|
-
console.log("Sending transaction...");
|
|
1094
|
+
console.log(colors_1.c.dim("Sending transaction..."));
|
|
1074
1095
|
const txHash = await (0, walletconnect_1.sendTransactionWithSession)(client, session, account, chainId, {
|
|
1075
1096
|
to: config.walletContractAddress,
|
|
1076
1097
|
data: calldata,
|
|
1077
1098
|
value: "0x0",
|
|
1078
1099
|
});
|
|
1079
1100
|
const unlockAt = new Date(Date.now() + 2 * 24 * 60 * 60 * 1000);
|
|
1080
|
-
console.log(
|
|
1081
|
-
console.log(
|
|
1082
|
-
console.log(
|
|
1101
|
+
console.log("\n" + colors_1.c.success + colors_1.c.white(" Registry upgrade proposed"));
|
|
1102
|
+
console.log(" " + colors_1.c.dim("Tx:") + " " + colors_1.c.white(txHash));
|
|
1103
|
+
console.log(" " + colors_1.c.dim("Unlock at:") + " " + colors_1.c.white(unlockAt.toISOString()) + colors_1.c.dim(" (approximately)"));
|
|
1083
1104
|
console.log(`\nNext steps:`);
|
|
1084
1105
|
console.log(` Wait 2 days, then run:`);
|
|
1085
1106
|
console.log(` arc402 wallet execute-registry-upgrade`);
|
|
@@ -1147,9 +1168,9 @@ function registerWalletCommands(program) {
|
|
|
1147
1168
|
confirmedRegistry = await walletContract.registry();
|
|
1148
1169
|
}
|
|
1149
1170
|
catch { /* use pendingRegistry as fallback */ }
|
|
1150
|
-
console.log(
|
|
1151
|
-
console.log(
|
|
1152
|
-
console.log(
|
|
1171
|
+
console.log("\n" + colors_1.c.success + colors_1.c.white(" Registry upgrade executed"));
|
|
1172
|
+
console.log(" " + colors_1.c.dim("Tx:") + " " + colors_1.c.white(txHash));
|
|
1173
|
+
console.log(" " + colors_1.c.dim("New registry:") + " " + colors_1.c.white(confirmedRegistry));
|
|
1153
1174
|
if (confirmedRegistry.toLowerCase() === pendingRegistry.toLowerCase()) {
|
|
1154
1175
|
console.log(` Registry updated successfully — addresses now resolve through new registry.`);
|
|
1155
1176
|
}
|
|
@@ -1200,7 +1221,7 @@ function registerWalletCommands(program) {
|
|
|
1200
1221
|
}
|
|
1201
1222
|
catch { /* ignore */ }
|
|
1202
1223
|
if (alreadyWhitelisted) {
|
|
1203
|
-
console.log(
|
|
1224
|
+
console.log(" " + colors_1.c.success + " " + colors_1.c.white(checksumTarget) + colors_1.c.dim(` is already whitelisted for ${config.walletContractAddress}`));
|
|
1204
1225
|
process.exit(0);
|
|
1205
1226
|
}
|
|
1206
1227
|
console.log(`\nWallet: ${config.walletContractAddress}`);
|
|
@@ -1223,10 +1244,12 @@ function registerWalletCommands(program) {
|
|
|
1223
1244
|
console.log(JSON.stringify({ ok: true, txHash, wallet: config.walletContractAddress, target: checksumTarget }));
|
|
1224
1245
|
}
|
|
1225
1246
|
else {
|
|
1226
|
-
console.log(
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1247
|
+
console.log("\n" + colors_1.c.success + colors_1.c.white(" Contract whitelisted"));
|
|
1248
|
+
(0, tree_1.renderTree)([
|
|
1249
|
+
{ label: "Tx", value: txHash },
|
|
1250
|
+
{ label: "Wallet", value: config.walletContractAddress ?? "" },
|
|
1251
|
+
{ label: "Target", value: checksumTarget, last: true },
|
|
1252
|
+
]);
|
|
1230
1253
|
}
|
|
1231
1254
|
});
|
|
1232
1255
|
// ─── set-interceptor ───────────────────────────────────────────────────────
|
|
@@ -1271,9 +1294,9 @@ function registerWalletCommands(program) {
|
|
|
1271
1294
|
value: "0x0",
|
|
1272
1295
|
}), `Approve: set X402 interceptor to ${checksumAddress}`, telegramOpts, config);
|
|
1273
1296
|
await provider.waitForTransaction(txHash);
|
|
1274
|
-
console.log(
|
|
1275
|
-
console.log(
|
|
1276
|
-
console.log(
|
|
1297
|
+
console.log("\n" + colors_1.c.success + colors_1.c.white(" X402 interceptor updated"));
|
|
1298
|
+
console.log(" " + colors_1.c.dim("Tx:") + " " + colors_1.c.white(txHash));
|
|
1299
|
+
console.log(" " + colors_1.c.dim("Interceptor:") + " " + colors_1.c.white(checksumAddress));
|
|
1277
1300
|
});
|
|
1278
1301
|
// ─── set-velocity-limit ────────────────────────────────────────────────────
|
|
1279
1302
|
wallet.command("set-velocity-limit <limit>")
|
|
@@ -1322,9 +1345,9 @@ function registerWalletCommands(program) {
|
|
|
1322
1345
|
value: "0x0",
|
|
1323
1346
|
}), `Approve: set velocity limit to ${limitEth} ETH`, telegramOpts, config);
|
|
1324
1347
|
await provider.waitForTransaction(txHash);
|
|
1325
|
-
console.log(
|
|
1326
|
-
console.log(
|
|
1327
|
-
console.log(
|
|
1348
|
+
console.log("\n" + colors_1.c.success + colors_1.c.white(" Velocity limit updated"));
|
|
1349
|
+
console.log(" " + colors_1.c.dim("Tx:") + " " + colors_1.c.white(txHash));
|
|
1350
|
+
console.log(" " + colors_1.c.dim("New limit:") + " " + colors_1.c.white(`${limitEth} ETH per rolling window`));
|
|
1328
1351
|
});
|
|
1329
1352
|
// ─── register-policy ───────────────────────────────────────────────────────
|
|
1330
1353
|
//
|
|
@@ -1380,9 +1403,9 @@ function registerWalletCommands(program) {
|
|
|
1380
1403
|
value: "0x0",
|
|
1381
1404
|
}), `Approve: register wallet on PolicyEngine`, telegramOpts, config);
|
|
1382
1405
|
await provider.waitForTransaction(txHash);
|
|
1383
|
-
console.log(
|
|
1384
|
-
console.log(
|
|
1385
|
-
console.log(
|
|
1406
|
+
console.log("\n" + colors_1.c.success + colors_1.c.white(" Wallet registered on PolicyEngine"));
|
|
1407
|
+
console.log(" " + colors_1.c.dim("Tx:") + " " + colors_1.c.white(txHash));
|
|
1408
|
+
console.log(colors_1.c.dim("\nNext: run 'arc402 wallet policy set-limit' to configure spending limits."));
|
|
1386
1409
|
});
|
|
1387
1410
|
// ─── cancel-registry-upgrade ───────────────────────────────────────────────
|
|
1388
1411
|
wallet.command("cancel-registry-upgrade")
|
|
@@ -1436,8 +1459,8 @@ function registerWalletCommands(program) {
|
|
|
1436
1459
|
data: walletInterface.encodeFunctionData("cancelRegistryUpdate", []),
|
|
1437
1460
|
value: "0x0",
|
|
1438
1461
|
}), "Approve registry upgrade cancellation on ARC402Wallet", telegramOpts, config);
|
|
1439
|
-
console.log(
|
|
1440
|
-
console.log(
|
|
1462
|
+
console.log("\n" + colors_1.c.success + colors_1.c.white(" Registry upgrade cancelled"));
|
|
1463
|
+
console.log(" " + colors_1.c.dim("Tx:") + " " + colors_1.c.white(txHash));
|
|
1441
1464
|
});
|
|
1442
1465
|
// ─── governance setup ──────────────────────────────────────────────────────
|
|
1443
1466
|
//
|
|
@@ -1685,18 +1708,18 @@ function registerWalletCommands(program) {
|
|
|
1685
1708
|
config.guardianAddress = guardianWallet.address;
|
|
1686
1709
|
(0, config_1.saveConfig)(config);
|
|
1687
1710
|
}
|
|
1688
|
-
console.log(
|
|
1711
|
+
console.log("\n" + colors_1.c.success + colors_1.c.white(" Governance setup complete"));
|
|
1689
1712
|
if (usedBatch) {
|
|
1690
|
-
console.log(
|
|
1713
|
+
console.log(" " + colors_1.c.dim("Batch tx:") + " " + colors_1.c.white(txHashes[0]));
|
|
1691
1714
|
}
|
|
1692
1715
|
else {
|
|
1693
|
-
txHashes.forEach((h, i) => console.log(`
|
|
1716
|
+
txHashes.forEach((h, i) => console.log(" " + colors_1.c.dim(`Tx ${i + 1}:`) + " " + colors_1.c.white(h)));
|
|
1694
1717
|
}
|
|
1695
1718
|
if (guardianWallet) {
|
|
1696
|
-
console.log(`
|
|
1697
|
-
console.log(
|
|
1719
|
+
console.log(" " + colors_1.c.success + colors_1.c.dim(` Guardian key saved to config — address: ${guardianWallet.address}`));
|
|
1720
|
+
console.log(" " + colors_1.c.warning + " " + colors_1.c.yellow("Store the guardian private key separately from your hot key."));
|
|
1698
1721
|
}
|
|
1699
|
-
console.log(
|
|
1722
|
+
console.log(colors_1.c.dim("\nVerify with: arc402 wallet status && arc402 wallet policy show"));
|
|
1700
1723
|
});
|
|
1701
1724
|
// ─── authorize-machine-key ─────────────────────────────────────────────────
|
|
1702
1725
|
wallet.command("authorize-machine-key <key>")
|
|
@@ -1729,7 +1752,7 @@ function registerWalletCommands(program) {
|
|
|
1729
1752
|
}
|
|
1730
1753
|
catch { /* ignore */ }
|
|
1731
1754
|
if (alreadyAuthorized) {
|
|
1732
|
-
console.log(
|
|
1755
|
+
console.log("\n" + colors_1.c.success + " " + colors_1.c.white(checksumKey) + colors_1.c.dim(` is already authorized as a machine key on ${config.walletContractAddress}`));
|
|
1733
1756
|
process.exit(0);
|
|
1734
1757
|
}
|
|
1735
1758
|
console.log(`\nWallet: ${config.walletContractAddress}`);
|
|
@@ -1747,21 +1770,23 @@ function registerWalletCommands(program) {
|
|
|
1747
1770
|
telegramOpts,
|
|
1748
1771
|
prompt: `Authorize machine key ${checksumKey} on ARC402Wallet — allows autonomous protocol ops`,
|
|
1749
1772
|
});
|
|
1750
|
-
console.log(
|
|
1751
|
-
console.log("Sending authorizeMachineKey transaction...");
|
|
1773
|
+
console.log("\n" + colors_1.c.success + colors_1.c.white(` Connected: ${account}`));
|
|
1774
|
+
console.log(colors_1.c.dim("Sending authorizeMachineKey transaction..."));
|
|
1752
1775
|
const hash = await (0, walletconnect_1.sendTransactionWithSession)(client, session, account, chainId, txData);
|
|
1753
|
-
console.log(
|
|
1754
|
-
console.log("Waiting for confirmation...");
|
|
1776
|
+
console.log("\n" + colors_1.c.dim("Transaction submitted:") + " " + colors_1.c.white(hash));
|
|
1777
|
+
console.log(colors_1.c.dim("Waiting for confirmation..."));
|
|
1755
1778
|
const receipt = await provider.waitForTransaction(hash, 1, 60000);
|
|
1756
1779
|
if (!receipt || receipt.status !== 1) {
|
|
1757
|
-
console.error("Transaction failed.");
|
|
1780
|
+
console.error(colors_1.c.failure + " " + colors_1.c.red("Transaction failed."));
|
|
1758
1781
|
process.exit(1);
|
|
1759
1782
|
}
|
|
1760
1783
|
const confirmed = await walletContract.authorizedMachineKeys(checksumKey);
|
|
1761
|
-
console.log(
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1784
|
+
console.log("\n" + colors_1.c.success + colors_1.c.white(` Machine key authorized: ${confirmed ? "YES" : "NO"}`));
|
|
1785
|
+
(0, tree_1.renderTree)([
|
|
1786
|
+
{ label: "Wallet", value: config.walletContractAddress ?? "" },
|
|
1787
|
+
{ label: "Machine key", value: checksumKey },
|
|
1788
|
+
{ label: "Tx", value: hash, last: true },
|
|
1789
|
+
]);
|
|
1765
1790
|
await client.disconnect({ topic: session.topic, reason: { code: 6000, message: "done" } });
|
|
1766
1791
|
process.exit(0);
|
|
1767
1792
|
});
|
|
@@ -1810,25 +1835,27 @@ function registerWalletCommands(program) {
|
|
|
1810
1835
|
: undefined;
|
|
1811
1836
|
const walletInterface = new ethers_1.ethers.Interface(abis_1.ARC402_WALLET_MACHINE_KEY_ABI);
|
|
1812
1837
|
const { client, session, account } = await (0, walletconnect_1.connectPhoneWallet)(config.walletConnectProjectId, chainId, config, { telegramOpts, prompt: `Revoke machine key ${checksumKey} on ARC402Wallet` });
|
|
1813
|
-
console.log(
|
|
1814
|
-
console.log("Sending revokeMachineKey transaction...");
|
|
1838
|
+
console.log("\n" + colors_1.c.success + colors_1.c.white(` Connected: ${account}`));
|
|
1839
|
+
console.log(colors_1.c.dim("Sending revokeMachineKey transaction..."));
|
|
1815
1840
|
const hash = await (0, walletconnect_1.sendTransactionWithSession)(client, session, account, chainId, {
|
|
1816
1841
|
to: config.walletContractAddress,
|
|
1817
1842
|
data: walletInterface.encodeFunctionData("revokeMachineKey", [checksumKey]),
|
|
1818
1843
|
value: "0x0",
|
|
1819
1844
|
});
|
|
1820
|
-
console.log(
|
|
1821
|
-
console.log("Waiting for confirmation...");
|
|
1845
|
+
console.log("\n" + colors_1.c.dim("Transaction submitted:") + " " + colors_1.c.white(hash));
|
|
1846
|
+
console.log(colors_1.c.dim("Waiting for confirmation..."));
|
|
1822
1847
|
const receipt = await provider.waitForTransaction(hash, 1, 60000);
|
|
1823
1848
|
if (!receipt || receipt.status !== 1) {
|
|
1824
|
-
console.error("Transaction failed.");
|
|
1849
|
+
console.error(colors_1.c.failure + " " + colors_1.c.red("Transaction failed."));
|
|
1825
1850
|
process.exit(1);
|
|
1826
1851
|
}
|
|
1827
1852
|
const stillAuthorized = await walletContract.authorizedMachineKeys(checksumKey);
|
|
1828
|
-
console.log(
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1853
|
+
console.log("\n" + colors_1.c.success + colors_1.c.white(` Machine key revoked: ${stillAuthorized ? "NO (still authorized — check tx)" : "YES"}`));
|
|
1854
|
+
(0, tree_1.renderTree)([
|
|
1855
|
+
{ label: "Wallet", value: config.walletContractAddress ?? "" },
|
|
1856
|
+
{ label: "Machine key", value: checksumKey },
|
|
1857
|
+
{ label: "Tx", value: hash, last: true },
|
|
1858
|
+
]);
|
|
1832
1859
|
await client.disconnect({ topic: session.topic, reason: { code: 6000, message: "done" } });
|
|
1833
1860
|
process.exit(0);
|
|
1834
1861
|
});
|
|
@@ -1942,11 +1969,13 @@ function registerWalletCommands(program) {
|
|
|
1942
1969
|
console.log(JSON.stringify({ walletAddress: walletAddr, contextId, taskType: opts.taskType, txHash: receipt?.hash }));
|
|
1943
1970
|
}
|
|
1944
1971
|
else {
|
|
1945
|
-
console.log(
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1972
|
+
console.log(" " + colors_1.c.success + colors_1.c.white(" Context opened"));
|
|
1973
|
+
(0, tree_1.renderTree)([
|
|
1974
|
+
{ label: "contextId", value: contextId },
|
|
1975
|
+
{ label: "taskType", value: opts.taskType },
|
|
1976
|
+
{ label: "Tx", value: receipt?.hash ?? "", last: true },
|
|
1977
|
+
]);
|
|
1978
|
+
console.log(colors_1.c.dim("\nNote: Each context allows only one spend. Call `arc402 wallet attest` then `arc402 wallet drain` (or executeSpend directly)."));
|
|
1950
1979
|
}
|
|
1951
1980
|
});
|
|
1952
1981
|
// ─── attest (J1-03) ────────────────────────────────────────────────────────
|
|
@@ -2004,14 +2033,16 @@ function registerWalletCommands(program) {
|
|
|
2004
2033
|
}));
|
|
2005
2034
|
}
|
|
2006
2035
|
else {
|
|
2007
|
-
console.log(
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2036
|
+
console.log(" " + colors_1.c.success + colors_1.c.white(" Attestation created"));
|
|
2037
|
+
(0, tree_1.renderTree)([
|
|
2038
|
+
{ label: "attestationId", value: attestationId },
|
|
2039
|
+
{ label: "recipient", value: checksumRecipient },
|
|
2040
|
+
{ label: "amount", value: opts.amount + " ETH" },
|
|
2041
|
+
{ label: "token", value: tokenAddress === ethers_1.ethers.ZeroAddress ? "ETH" : tokenAddress },
|
|
2042
|
+
{ label: "expiresAt", value: new Date(expiresAt * 1000).toISOString() },
|
|
2043
|
+
{ label: "Tx", value: receipt?.hash ?? "", last: true },
|
|
2044
|
+
]);
|
|
2045
|
+
console.log(colors_1.c.dim("\nUse this attestationId in `arc402 wallet drain` or your spend flow."));
|
|
2015
2046
|
}
|
|
2016
2047
|
});
|
|
2017
2048
|
// ─── velocity-status (J8-03) ───────────────────────────────────────────────
|
|
@@ -2132,9 +2163,9 @@ function registerWalletCommands(program) {
|
|
|
2132
2163
|
console.log(JSON.stringify({ walletAddress: walletAddr, txHash: receipt?.hash, contextOpen: false }));
|
|
2133
2164
|
}
|
|
2134
2165
|
else {
|
|
2135
|
-
console.log(
|
|
2136
|
-
console.log(
|
|
2137
|
-
console.log(
|
|
2166
|
+
console.log(" " + colors_1.c.success + colors_1.c.white(" Context closed"));
|
|
2167
|
+
console.log(" " + colors_1.c.dim("Tx:") + " " + colors_1.c.white(receipt?.hash ?? ""));
|
|
2168
|
+
console.log(" " + colors_1.c.dim("Wallet:") + " " + colors_1.c.white(walletAddr));
|
|
2138
2169
|
}
|
|
2139
2170
|
});
|
|
2140
2171
|
// ─── drain ─────────────────────────────────────────────────────────────────
|
|
@@ -2231,26 +2262,26 @@ function registerWalletCommands(program) {
|
|
|
2231
2262
|
// ── Step 1: context cleanup ────────────────────────────────────────────
|
|
2232
2263
|
const isOpen = await walletContract.contextOpen();
|
|
2233
2264
|
if (isOpen) {
|
|
2234
|
-
console.log("Stale context found — closing it first...");
|
|
2265
|
+
console.log(colors_1.c.dim("Stale context found — closing it first..."));
|
|
2235
2266
|
const closeTx = await walletContract.closeContext();
|
|
2236
2267
|
await closeTx.wait(2);
|
|
2237
|
-
console.log(`
|
|
2268
|
+
console.log(" " + colors_1.c.success + colors_1.c.dim(` Closed: ${closeTx.hash}`));
|
|
2238
2269
|
}
|
|
2239
2270
|
// ── Step 2: openContext ────────────────────────────────────────────────
|
|
2240
2271
|
const contextId = ethers_1.ethers.keccak256(ethers_1.ethers.toUtf8Bytes(`drain-${Date.now()}`));
|
|
2241
|
-
console.log("Opening context...");
|
|
2272
|
+
console.log(colors_1.c.dim("Opening context..."));
|
|
2242
2273
|
const openTx = await walletContract.openContext(contextId, "drain");
|
|
2243
2274
|
const openReceipt = await openTx.wait(1);
|
|
2244
|
-
console.log(`
|
|
2275
|
+
console.log(" " + colors_1.c.success + colors_1.c.dim(` openContext: ${openReceipt?.hash}`));
|
|
2245
2276
|
// ── Step 3: attest (direct on wallet — onlyOwnerOrMachineKey, NOT via executeContractCall)
|
|
2246
2277
|
const attestationId = ethers_1.ethers.hexlify(ethers_1.ethers.randomBytes(32));
|
|
2247
2278
|
const expiry = Math.floor(Date.now() / 1000) + 600; // 10 min TTL
|
|
2248
|
-
console.log("Creating attestation (direct on wallet)...");
|
|
2279
|
+
console.log(colors_1.c.dim("Creating attestation (direct on wallet)..."));
|
|
2249
2280
|
const attestTx = await walletContract.attest(attestationId, "spend", `drain to ${checksumRecipient}`, checksumRecipient, drainAmount, ethers_1.ethers.ZeroAddress, expiry);
|
|
2250
2281
|
const attestReceipt = await attestTx.wait(1);
|
|
2251
|
-
console.log(`
|
|
2282
|
+
console.log(" " + colors_1.c.success + colors_1.c.dim(` attest: ${attestReceipt?.hash}`));
|
|
2252
2283
|
// ── Step 4: executeSpend ───────────────────────────────────────────────
|
|
2253
|
-
console.log("Executing spend...");
|
|
2284
|
+
console.log(colors_1.c.dim("Executing spend..."));
|
|
2254
2285
|
let spendReceiptHash;
|
|
2255
2286
|
try {
|
|
2256
2287
|
const spendTx = await walletContract.executeSpend(checksumRecipient, drainAmount, opts.category, attestationId);
|
|
@@ -2260,12 +2291,12 @@ function registerWalletCommands(program) {
|
|
|
2260
2291
|
catch (e) {
|
|
2261
2292
|
(0, wallet_router_1.handleWalletError)(e);
|
|
2262
2293
|
}
|
|
2263
|
-
console.log(`
|
|
2294
|
+
console.log(" " + colors_1.c.success + colors_1.c.dim(` executeSpend: ${spendReceiptHash}`));
|
|
2264
2295
|
// ── Step 5: closeContext ───────────────────────────────────────────────
|
|
2265
|
-
console.log("Closing context...");
|
|
2296
|
+
console.log(colors_1.c.dim("Closing context..."));
|
|
2266
2297
|
const closeTx2 = await walletContract.closeContext();
|
|
2267
2298
|
const closeReceipt = await closeTx2.wait(1);
|
|
2268
|
-
console.log(`
|
|
2299
|
+
console.log(" " + colors_1.c.success + colors_1.c.dim(` closeContext: ${closeReceipt?.hash}`));
|
|
2269
2300
|
const newBalance = await provider.getBalance(walletAddr);
|
|
2270
2301
|
if (opts.json) {
|
|
2271
2302
|
console.log(JSON.stringify({
|
|
@@ -2284,9 +2315,11 @@ function registerWalletCommands(program) {
|
|
|
2284
2315
|
}));
|
|
2285
2316
|
}
|
|
2286
2317
|
else {
|
|
2287
|
-
console.log(
|
|
2288
|
-
|
|
2289
|
-
|
|
2318
|
+
console.log("\n" + colors_1.c.success + colors_1.c.white(" Drain complete"));
|
|
2319
|
+
(0, tree_1.renderTree)([
|
|
2320
|
+
{ label: "Sent", value: `${ethers_1.ethers.formatEther(drainAmount)} ETH → ${checksumRecipient}` },
|
|
2321
|
+
{ label: "Remaining", value: `${ethers_1.ethers.formatEther(newBalance)} ETH`, last: true },
|
|
2322
|
+
]);
|
|
2290
2323
|
}
|
|
2291
2324
|
});
|
|
2292
2325
|
// ─── drain-token ───────────────────────────────────────────────────────────
|
|
@@ -2408,34 +2441,34 @@ function registerWalletCommands(program) {
|
|
|
2408
2441
|
// ── Step 1: context cleanup ──────────────────────────────────────────────
|
|
2409
2442
|
const isOpenT = await walletContractT.contextOpen();
|
|
2410
2443
|
if (isOpenT) {
|
|
2411
|
-
console.log("Stale context found — closing it first...");
|
|
2444
|
+
console.log(colors_1.c.dim("Stale context found — closing it first..."));
|
|
2412
2445
|
const closeTxT = await walletContractT.closeContext();
|
|
2413
2446
|
await closeTxT.wait(2);
|
|
2414
|
-
console.log(`
|
|
2447
|
+
console.log(" " + colors_1.c.success + colors_1.c.dim(` Closed: ${closeTxT.hash}`));
|
|
2415
2448
|
}
|
|
2416
2449
|
// ── Step 2: openContext ──────────────────────────────────────────────────
|
|
2417
2450
|
const contextIdT = ethers_1.ethers.keccak256(ethers_1.ethers.toUtf8Bytes(`drain-token-${Date.now()}`));
|
|
2418
|
-
console.log("Opening context...");
|
|
2451
|
+
console.log(colors_1.c.dim("Opening context..."));
|
|
2419
2452
|
const openTxT = await walletContractT.openContext(contextIdT, "drain");
|
|
2420
2453
|
const openReceiptT = await openTxT.wait(1);
|
|
2421
|
-
console.log(`
|
|
2454
|
+
console.log(" " + colors_1.c.success + colors_1.c.dim(` openContext: ${openReceiptT?.hash}`));
|
|
2422
2455
|
// ── Step 3: attest with token address ────────────────────────────────────
|
|
2423
2456
|
const attestationIdT = ethers_1.ethers.hexlify(ethers_1.ethers.randomBytes(32));
|
|
2424
2457
|
const expiryT = Math.floor(Date.now() / 1000) + 600; // 10 min TTL
|
|
2425
|
-
console.log("Creating attestation (with token address)...");
|
|
2458
|
+
console.log(colors_1.c.dim("Creating attestation (with token address)..."));
|
|
2426
2459
|
const attestTxT = await walletContractT.attest(attestationIdT, "spend", `token drain to ${checksumRecipient}`, checksumRecipient, tokenAmount, tokenAddress, expiryT);
|
|
2427
2460
|
const attestReceiptT = await attestTxT.wait(1);
|
|
2428
|
-
console.log(`
|
|
2461
|
+
console.log(" " + colors_1.c.success + colors_1.c.dim(` attest: ${attestReceiptT?.hash}`));
|
|
2429
2462
|
// ── Step 4: executeTokenSpend ────────────────────────────────────────────
|
|
2430
|
-
console.log("Executing token spend...");
|
|
2463
|
+
console.log(colors_1.c.dim("Executing token spend..."));
|
|
2431
2464
|
const spendTxT = await walletContractT.executeTokenSpend(checksumRecipient, tokenAmount, tokenAddress, opts.category, attestationIdT);
|
|
2432
2465
|
const spendReceiptT = await spendTxT.wait(1);
|
|
2433
|
-
console.log(`
|
|
2466
|
+
console.log(" " + colors_1.c.success + colors_1.c.dim(` executeTokenSpend: ${spendReceiptT?.hash}`));
|
|
2434
2467
|
// ── Step 5: closeContext ─────────────────────────────────────────────────
|
|
2435
|
-
console.log("Closing context...");
|
|
2468
|
+
console.log(colors_1.c.dim("Closing context..."));
|
|
2436
2469
|
const closeTxT2 = await walletContractT.closeContext();
|
|
2437
2470
|
const closeReceiptT = await closeTxT2.wait(1);
|
|
2438
|
-
console.log(`
|
|
2471
|
+
console.log(" " + colors_1.c.success + colors_1.c.dim(` closeContext: ${closeReceiptT?.hash}`));
|
|
2439
2472
|
const newTokenBalance = await erc20.balanceOf(walletAddr);
|
|
2440
2473
|
if (opts.json) {
|
|
2441
2474
|
console.log(JSON.stringify({
|
|
@@ -2455,10 +2488,12 @@ function registerWalletCommands(program) {
|
|
|
2455
2488
|
}));
|
|
2456
2489
|
}
|
|
2457
2490
|
else {
|
|
2458
|
-
console.log(
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2491
|
+
console.log("\n" + colors_1.c.success + colors_1.c.white(" Token drain complete"));
|
|
2492
|
+
(0, tree_1.renderTree)([
|
|
2493
|
+
{ label: "Sent", value: `${amountArg} → ${checksumRecipient}` },
|
|
2494
|
+
{ label: "Token", value: tokenAddress },
|
|
2495
|
+
{ label: "Remaining", value: ethers_1.ethers.formatUnits(newTokenBalance, decimals), last: true },
|
|
2496
|
+
]);
|
|
2462
2497
|
}
|
|
2463
2498
|
});
|
|
2464
2499
|
// ─── set-passkey ───────────────────────────────────────────────────────────
|
|
@@ -2507,22 +2542,24 @@ function registerWalletCommands(program) {
|
|
|
2507
2542
|
telegramOpts,
|
|
2508
2543
|
prompt: `Activate passkey (Face ID) on ARC402Wallet — enables P256 governance signing`,
|
|
2509
2544
|
});
|
|
2510
|
-
console.log(
|
|
2511
|
-
console.log("Sending setPasskey transaction...");
|
|
2545
|
+
console.log("\n" + colors_1.c.success + colors_1.c.white(` Connected: ${account}`));
|
|
2546
|
+
console.log(colors_1.c.dim("Sending setPasskey transaction..."));
|
|
2512
2547
|
const hash = await (0, walletconnect_1.sendTransactionWithSession)(client, session, account, chainId, txData);
|
|
2513
|
-
console.log(
|
|
2514
|
-
console.log("Waiting for confirmation...");
|
|
2548
|
+
console.log("\n" + colors_1.c.dim("Transaction submitted:") + " " + colors_1.c.white(hash));
|
|
2549
|
+
console.log(colors_1.c.dim("Waiting for confirmation..."));
|
|
2515
2550
|
const receipt = await provider.waitForTransaction(hash, 1, 60000);
|
|
2516
2551
|
if (!receipt || receipt.status !== 1) {
|
|
2517
|
-
console.error("Transaction failed.");
|
|
2552
|
+
console.error(colors_1.c.failure + " " + colors_1.c.red("Transaction failed."));
|
|
2518
2553
|
process.exit(1);
|
|
2519
2554
|
}
|
|
2520
|
-
console.log(
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2555
|
+
console.log("\n" + colors_1.c.success + colors_1.c.white(" Passkey activated on ARC402Wallet"));
|
|
2556
|
+
(0, tree_1.renderTree)([
|
|
2557
|
+
{ label: "Wallet", value: config.walletContractAddress ?? "" },
|
|
2558
|
+
{ label: "pubKeyX", value: pubKeyX },
|
|
2559
|
+
{ label: "pubKeyY", value: pubKeyY },
|
|
2560
|
+
{ label: "Tx", value: hash, last: true },
|
|
2561
|
+
]);
|
|
2562
|
+
console.log(colors_1.c.dim("\nGovernance ops now require Face ID instead of MetaMask."));
|
|
2526
2563
|
await client.disconnect({ topic: session.topic, reason: { code: 6000, message: "done" } });
|
|
2527
2564
|
process.exit(0);
|
|
2528
2565
|
});
|