@blockrun/clawrouter 0.8.30 → 0.8.31
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/cli.js +22 -2
- package/dist/cli.js.map +1 -1
- package/dist/index.js +22 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -3548,8 +3548,17 @@ var WALLET_FILE = join4(WALLET_DIR, "wallet.key");
|
|
|
3548
3548
|
async function loadSavedWallet() {
|
|
3549
3549
|
try {
|
|
3550
3550
|
const key = (await readFile2(WALLET_FILE, "utf-8")).trim();
|
|
3551
|
-
if (key.startsWith("0x") && key.length === 66)
|
|
3552
|
-
|
|
3551
|
+
if (key.startsWith("0x") && key.length === 66) {
|
|
3552
|
+
console.log(`[ClawRouter] \u2713 Loaded existing wallet from ${WALLET_FILE}`);
|
|
3553
|
+
return key;
|
|
3554
|
+
}
|
|
3555
|
+
console.warn(`[ClawRouter] \u26A0 Wallet file exists but is invalid (wrong format)`);
|
|
3556
|
+
} catch (err) {
|
|
3557
|
+
if (err.code !== "ENOENT") {
|
|
3558
|
+
console.error(
|
|
3559
|
+
`[ClawRouter] \u2717 Failed to read wallet file: ${err instanceof Error ? err.message : String(err)}`
|
|
3560
|
+
);
|
|
3561
|
+
}
|
|
3553
3562
|
}
|
|
3554
3563
|
return void 0;
|
|
3555
3564
|
}
|
|
@@ -3558,6 +3567,17 @@ async function generateAndSaveWallet() {
|
|
|
3558
3567
|
const account = privateKeyToAccount3(key);
|
|
3559
3568
|
await mkdir2(WALLET_DIR, { recursive: true });
|
|
3560
3569
|
await writeFile(WALLET_FILE, key + "\n", { mode: 384 });
|
|
3570
|
+
try {
|
|
3571
|
+
const verification = (await readFile2(WALLET_FILE, "utf-8")).trim();
|
|
3572
|
+
if (verification !== key) {
|
|
3573
|
+
throw new Error("Wallet file verification failed - content mismatch");
|
|
3574
|
+
}
|
|
3575
|
+
console.log(`[ClawRouter] \u2713 Wallet saved and verified at ${WALLET_FILE}`);
|
|
3576
|
+
} catch (err) {
|
|
3577
|
+
throw new Error(
|
|
3578
|
+
`Failed to verify wallet file after creation: ${err instanceof Error ? err.message : String(err)}`
|
|
3579
|
+
);
|
|
3580
|
+
}
|
|
3561
3581
|
return { key, address: account.address };
|
|
3562
3582
|
}
|
|
3563
3583
|
async function resolveOrGenerateWalletKey() {
|