@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/index.js CHANGED
@@ -3688,8 +3688,17 @@ var WALLET_FILE = join4(WALLET_DIR, "wallet.key");
3688
3688
  async function loadSavedWallet() {
3689
3689
  try {
3690
3690
  const key = (await readFile2(WALLET_FILE, "utf-8")).trim();
3691
- if (key.startsWith("0x") && key.length === 66) return key;
3692
- } catch {
3691
+ if (key.startsWith("0x") && key.length === 66) {
3692
+ console.log(`[ClawRouter] \u2713 Loaded existing wallet from ${WALLET_FILE}`);
3693
+ return key;
3694
+ }
3695
+ console.warn(`[ClawRouter] \u26A0 Wallet file exists but is invalid (wrong format)`);
3696
+ } catch (err) {
3697
+ if (err.code !== "ENOENT") {
3698
+ console.error(
3699
+ `[ClawRouter] \u2717 Failed to read wallet file: ${err instanceof Error ? err.message : String(err)}`
3700
+ );
3701
+ }
3693
3702
  }
3694
3703
  return void 0;
3695
3704
  }
@@ -3698,6 +3707,17 @@ async function generateAndSaveWallet() {
3698
3707
  const account = privateKeyToAccount3(key);
3699
3708
  await mkdir2(WALLET_DIR, { recursive: true });
3700
3709
  await writeFile(WALLET_FILE, key + "\n", { mode: 384 });
3710
+ try {
3711
+ const verification = (await readFile2(WALLET_FILE, "utf-8")).trim();
3712
+ if (verification !== key) {
3713
+ throw new Error("Wallet file verification failed - content mismatch");
3714
+ }
3715
+ console.log(`[ClawRouter] \u2713 Wallet saved and verified at ${WALLET_FILE}`);
3716
+ } catch (err) {
3717
+ throw new Error(
3718
+ `Failed to verify wallet file after creation: ${err instanceof Error ? err.message : String(err)}`
3719
+ );
3720
+ }
3701
3721
  return { key, address: account.address };
3702
3722
  }
3703
3723
  async function resolveOrGenerateWalletKey() {