@blockrun/clawrouter 0.12.17 → 0.12.19
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 +56 -6
- package/dist/cli.js.map +1 -1
- package/dist/index.js +10 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -2877,12 +2877,14 @@ var BalanceMonitor = class {
|
|
|
2877
2877
|
*/
|
|
2878
2878
|
async checkBalance() {
|
|
2879
2879
|
const now = Date.now();
|
|
2880
|
-
if (this.cachedBalance !== null && now - this.cachedAt < CACHE_TTL_MS) {
|
|
2880
|
+
if (this.cachedBalance !== null && this.cachedBalance > 0n && now - this.cachedAt < CACHE_TTL_MS) {
|
|
2881
2881
|
return this.buildInfo(this.cachedBalance);
|
|
2882
2882
|
}
|
|
2883
2883
|
const balance = await this.fetchBalance();
|
|
2884
|
-
|
|
2885
|
-
|
|
2884
|
+
if (balance > 0n) {
|
|
2885
|
+
this.cachedBalance = balance;
|
|
2886
|
+
this.cachedAt = now;
|
|
2887
|
+
}
|
|
2886
2888
|
return this.buildInfo(balance);
|
|
2887
2889
|
}
|
|
2888
2890
|
/**
|
|
@@ -2985,12 +2987,14 @@ var SolanaBalanceMonitor = class {
|
|
|
2985
2987
|
}
|
|
2986
2988
|
async checkBalance() {
|
|
2987
2989
|
const now = Date.now();
|
|
2988
|
-
if (this.cachedBalance !== null && now - this.cachedAt < CACHE_TTL_MS2) {
|
|
2990
|
+
if (this.cachedBalance !== null && this.cachedBalance > 0n && now - this.cachedAt < CACHE_TTL_MS2) {
|
|
2989
2991
|
return this.buildInfo(this.cachedBalance);
|
|
2990
2992
|
}
|
|
2991
2993
|
const balance = await this.fetchBalance();
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
+
if (balance > 0n) {
|
|
2995
|
+
this.cachedBalance = balance;
|
|
2996
|
+
this.cachedAt = now;
|
|
2997
|
+
}
|
|
2994
2998
|
return this.buildInfo(balance);
|
|
2995
2999
|
}
|
|
2996
3000
|
deductEstimated(amountMicros) {
|
|
@@ -3826,6 +3830,43 @@ async function resolveOrGenerateWalletKey() {
|
|
|
3826
3830
|
solanaPrivateKeyBytes: result.solanaPrivateKeyBytes
|
|
3827
3831
|
};
|
|
3828
3832
|
}
|
|
3833
|
+
async function recoverWalletFromMnemonic() {
|
|
3834
|
+
const mnemonic = await loadMnemonic();
|
|
3835
|
+
if (!mnemonic) {
|
|
3836
|
+
console.error(`[ClawRouter] No mnemonic found at ${MNEMONIC_FILE}`);
|
|
3837
|
+
console.error(`[ClawRouter] Cannot recover \u2014 no mnemonic to derive from.`);
|
|
3838
|
+
process.exit(1);
|
|
3839
|
+
}
|
|
3840
|
+
const existing = await loadSavedWallet().catch(() => void 0);
|
|
3841
|
+
if (existing) {
|
|
3842
|
+
console.error(`[ClawRouter] wallet.key already exists at ${WALLET_FILE}`);
|
|
3843
|
+
console.error(`[ClawRouter] Recovery not needed.`);
|
|
3844
|
+
process.exit(1);
|
|
3845
|
+
}
|
|
3846
|
+
const derived = deriveAllKeys(mnemonic);
|
|
3847
|
+
const solanaKeyBytes = deriveSolanaKeyBytes(mnemonic);
|
|
3848
|
+
const solanaAddress = await getSolanaAddress(solanaKeyBytes).catch(() => void 0);
|
|
3849
|
+
console.log(`[ClawRouter]`);
|
|
3850
|
+
console.log(`[ClawRouter] \u26A0 WALLET RECOVERY FROM MNEMONIC`);
|
|
3851
|
+
console.log(`[ClawRouter] \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550`);
|
|
3852
|
+
console.log(`[ClawRouter] This only works if your mnemonic was originally`);
|
|
3853
|
+
console.log(`[ClawRouter] generated by ClawRouter (not set manually).`);
|
|
3854
|
+
console.log(`[ClawRouter]`);
|
|
3855
|
+
console.log(`[ClawRouter] Derived EVM Address : ${derived.evmAddress}`);
|
|
3856
|
+
if (solanaAddress) {
|
|
3857
|
+
console.log(`[ClawRouter] Derived Solana Address : ${solanaAddress}`);
|
|
3858
|
+
}
|
|
3859
|
+
console.log(`[ClawRouter]`);
|
|
3860
|
+
console.log(`[ClawRouter] If the Solana address above matches your funded`);
|
|
3861
|
+
console.log(`[ClawRouter] wallet, recovery is safe to proceed.`);
|
|
3862
|
+
console.log(`[ClawRouter] \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550`);
|
|
3863
|
+
console.log(`[ClawRouter]`);
|
|
3864
|
+
await mkdir2(WALLET_DIR, { recursive: true });
|
|
3865
|
+
await writeFile(WALLET_FILE, derived.evmPrivateKey + "\n", { mode: 384 });
|
|
3866
|
+
console.log(`[ClawRouter] \u2713 wallet.key restored at ${WALLET_FILE}`);
|
|
3867
|
+
console.log(`[ClawRouter] Run: npx @blockrun/clawrouter`);
|
|
3868
|
+
console.log(`[ClawRouter]`);
|
|
3869
|
+
}
|
|
3829
3870
|
async function loadPaymentChain() {
|
|
3830
3871
|
try {
|
|
3831
3872
|
const content = (await readTextFile(CHAIN_FILE)).trim();
|
|
@@ -7571,6 +7612,7 @@ Commands:
|
|
|
7571
7612
|
doctor opus Use Opus for deeper analysis (~$0.01)
|
|
7572
7613
|
partners List available partner APIs with pricing
|
|
7573
7614
|
partners test Test partner API endpoints (expect 402 = alive)
|
|
7615
|
+
wallet recover Restore wallet.key from mnemonic (if generated by ClawRouter)
|
|
7574
7616
|
|
|
7575
7617
|
Examples:
|
|
7576
7618
|
# Start standalone proxy
|
|
@@ -7605,6 +7647,7 @@ function parseArgs(args) {
|
|
|
7605
7647
|
report: false,
|
|
7606
7648
|
reportPeriod: "daily",
|
|
7607
7649
|
reportJson: false,
|
|
7650
|
+
walletRecover: false,
|
|
7608
7651
|
port: void 0
|
|
7609
7652
|
};
|
|
7610
7653
|
for (let i = 0; i < args.length; i++) {
|
|
@@ -7635,6 +7678,9 @@ function parseArgs(args) {
|
|
|
7635
7678
|
result.reportJson = true;
|
|
7636
7679
|
i++;
|
|
7637
7680
|
}
|
|
7681
|
+
} else if (arg === "wallet" && args[i + 1] === "recover") {
|
|
7682
|
+
result.walletRecover = true;
|
|
7683
|
+
i++;
|
|
7638
7684
|
} else if (arg === "--port" && args[i + 1]) {
|
|
7639
7685
|
result.port = parseInt(args[i + 1], 10);
|
|
7640
7686
|
i++;
|
|
@@ -7705,6 +7751,10 @@ ClawRouter Partner APIs (v${VERSION})
|
|
|
7705
7751
|
}
|
|
7706
7752
|
process.exit(0);
|
|
7707
7753
|
}
|
|
7754
|
+
if (args.walletRecover) {
|
|
7755
|
+
await recoverWalletFromMnemonic();
|
|
7756
|
+
process.exit(0);
|
|
7757
|
+
}
|
|
7708
7758
|
if (args.report) {
|
|
7709
7759
|
const report = await generateReport(args.reportPeriod, args.reportJson);
|
|
7710
7760
|
console.log(report);
|