apow-cli 0.12.0 → 0.12.3

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.
@@ -50,7 +50,8 @@ exports.getGrindUrl = getGrindUrl;
50
50
  exports.grindNonceHttp = grindNonceHttp;
51
51
  const config_1 = require("./config");
52
52
  const DEFAULT_GRIND_URL = "https://grind.apow.io/grind";
53
- const GRIND_HTTP_TIMEOUT_MS = 60_000;
53
+ // The service allows 300 seconds including cold startup. Leave transport margin.
54
+ const GRIND_HTTP_TIMEOUT_MS = 330_000;
54
55
  // Lazy singleton — created on first grind, reused across calls
55
56
  let _fetchWithPayment = null;
56
57
  function resetPaymentFetch() {
@@ -115,13 +116,11 @@ async function grindNonceHttp(challengeNumber, target, minerAddress, grindUrl, s
115
116
  }
116
117
  if (timeoutSignal.aborted) {
117
118
  resetPaymentFetch();
118
- throw new Error(`Remote GPU grind timed out (${GRIND_HTTP_TIMEOUT_MS / 1000}s)`);
119
+ throw new Error(`Remote GPU grind timed out (${GRIND_HTTP_TIMEOUT_MS / 1000}s); payment outcome is unknown`);
119
120
  }
120
121
  resetPaymentFetch();
121
- if (attempt === 1) {
122
- continue;
123
- }
124
- throw new Error(`Remote GPU grind request failed: ${err instanceof Error ? err.message : String(err)}`);
122
+ // A lost response can follow a settled payment. Do not replay an unknown paid request.
123
+ throw new Error(`Remote GPU grind request failed; payment outcome is unknown: ${err instanceof Error ? err.message : String(err)}`);
125
124
  }
126
125
  if (response.ok) {
127
126
  break;
@@ -139,7 +138,7 @@ async function grindNonceHttp(challengeNumber, target, minerAddress, grindUrl, s
139
138
  }
140
139
  const combinedError = `${reason} ${bodyDetail}`.trim();
141
140
  const stalePaymentSession = /No matching payment requirements|facilitator|payment session|authorization/i.test(combinedError);
142
- if (attempt === 1 && (stalePaymentSession || response.status >= 500)) {
141
+ if (attempt === 1 && response.status === 402 && stalePaymentSession) {
143
142
  resetPaymentFetch();
144
143
  continue;
145
144
  }
@@ -149,7 +148,7 @@ async function grindNonceHttp(challengeNumber, target, minerAddress, grindUrl, s
149
148
  throw new Error("x402 GPU payment failed: insufficient USDC balance");
150
149
  }
151
150
  else if (reason.includes("simulation_failed")) {
152
- throw new Error(`x402 GPU payment failed: EVM simulation failed (USDC approval issue?) [${reason}]`);
151
+ throw new Error(`x402 GPU payment failed: EVM simulation failed; check balance, policy, and service settlement RPC [${reason}]`);
153
152
  }
154
153
  else if (attempt === 1) {
155
154
  continue;
@@ -159,8 +158,10 @@ async function grindNonceHttp(challengeNumber, target, minerAddress, grindUrl, s
159
158
  }
160
159
  }
161
160
  if (response.status === 504) {
162
- throw new Error(`Remote GPU grind timed out (${GRIND_HTTP_TIMEOUT_MS / 1000}s)`);
161
+ throw new Error("Remote GPU service timed out; payment outcome is unknown");
163
162
  }
163
+ if (response.status >= 500)
164
+ throw new Error(`GrindProxy HTTP ${response.status}; payment outcome is unknown`);
164
165
  throw new Error(`GrindProxy HTTP ${response.status}: ${(bodyDetail || body).slice(0, 200)}`);
165
166
  }
166
167
  if (!response || !response.ok) {
package/dist/index.js CHANGED
@@ -44,11 +44,12 @@ const commander_1 = require("commander");
44
44
  const viem_1 = require("viem");
45
45
  const MiningAgent_json_1 = __importDefault(require("./abi/MiningAgent.json"));
46
46
  const config_1 = require("./config");
47
- const constants_1 = require("./bridge/constants");
48
47
  const detect_1 = require("./detect");
49
48
  const errors_1 = require("./errors");
50
49
  const explorer_1 = require("./explorer");
51
50
  const fund_1 = require("./fund");
51
+ const base_funding_1 = require("./base-funding");
52
+ const wallet_recovery_1 = require("./wallet-recovery");
52
53
  const llm_setup_1 = require("./llm-setup");
53
54
  const mint_1 = require("./mint");
54
55
  const miner_1 = require("./miner");
@@ -343,7 +344,7 @@ async function setupWizard(options = {}) {
343
344
  console.log("");
344
345
  console.log(` ${ui.dim("Back up the encrypted keystore and its password separately.")}`);
345
346
  console.log("");
346
- console.log(` ${ui.dim("Fund this address with ≥0.005 ETH on Base to start.")}`);
347
+ console.log(` ${ui.dim("Verify wallet recovery before funding. apow start calculates the ETH deposit.")}`);
347
348
  console.log("");
348
349
  }
349
350
  values.PRIVATE_KEY = "";
@@ -363,7 +364,7 @@ async function setupWizard(options = {}) {
363
364
  ui.ok("LLM: Auto (Zero Config via ClawRouter x402; wallet-paid in USDC)");
364
365
  ui.ok("Grinder: Auto (Zero Config via RunPod x402; wallet-paid in USDC)");
365
366
  console.log(` ${ui.dim("Easy mode is agent-first: no RPC key, no LLM key, no GPU rental setup.")}`);
366
- console.log(` ${ui.dim(`Fund the wallet with ETH + USDC on Base, then run: apow start${options.easyMode ? " --easy" : ""}`)}`);
367
+ console.log(` ${ui.dim(`Deposit Base ETH only. The CLI converts the service budget to USDC. Run: apow start${options.easyMode ? " --easy" : ""}`)}`);
367
368
  }
368
369
  else {
369
370
  // Advanced: user picks which services remain autonomous
@@ -516,17 +517,26 @@ async function setupWizard(options = {}) {
516
517
  console.log("");
517
518
  }
518
519
  }
519
- function showFundingHandoff(address, needsEth, needsUsdc, easyMode) {
520
+ function showFundingHandoff(address, depositEth, easyMode) {
520
521
  ui.warn("Pausing for Base funding.");
521
- ui.hint(`Send funds to ${address} on Base.`);
522
- if (needsEth) {
523
- ui.hint(`Need at least ${constants_1.MIN_ETH} ETH for gas and minting.`);
524
- }
525
- if (needsUsdc) {
526
- ui.hint(`Need at least ${constants_1.MIN_USDC} USDC for x402 RPC + LLM services.`);
527
- }
522
+ ui.hint(`Send at least ${(0, viem_1.formatEther)(depositEth)} ETH on Base to ${address}.`);
523
+ ui.hint("This quote includes the current mint price, an ETH reserve, and the USDC conversion if needed. Costs can change before deposit.");
524
+ ui.hint("The CLI converts ETH to USDC within the signing policy. You do not need to send USDC.");
528
525
  ui.hint(`After funds arrive, rerun \`apow start${easyMode ? " --easy" : ""}\`.`);
529
526
  }
527
+ async function checkWalletRecovery() {
528
+ if (!wallet_1.account || !config_1.config.keystorePath)
529
+ throw new Error("Use an encrypted APoW wallet before funding.");
530
+ // A person can supply a separately retained password directly in a local terminal.
531
+ // Headless agents must use a saved secret-manager command, never process memory alone.
532
+ const password = ui.isInteractiveSession()
533
+ ? await ui.promptSecret("Re-enter your separately saved keystore password to test recovery") : undefined;
534
+ if (ui.isInteractiveSession() && !password)
535
+ throw new Error("Wallet recovery test cancelled.");
536
+ (0, wallet_recovery_1.verifyWalletRecovery)(config_1.config.keystorePath, wallet_1.account.address, password);
537
+ ui.ok(`Fresh-process unlock verified for ${wallet_1.account.address}.`);
538
+ ui.hint("Keep an independent encrypted-keystore backup and its password separately. This check does not verify host uptime or your backup.");
539
+ }
530
540
  async function runStartFlow(options = {}) {
531
541
  await (0, brand_intro_1.showBrandIntro)("start");
532
542
  const unlockedConfiguredWallet = await unlockConfiguredKeystoreIfNeeded();
@@ -551,16 +561,23 @@ async function runStartFlow(options = {}) {
551
561
  ui.hint("Restore the default enforce-mode Easy Mode caps, then retry.");
552
562
  return;
553
563
  }
564
+ await (0, config_1.writeEnvFile)({ USE_X402: "true", USE_X402_GRIND: "true", LLM_PROVIDER: "clawrouter", ALLOW_LOCAL_FALLBACK_WITH_X402: "false" });
565
+ (0, config_1.reloadConfig)();
566
+ (0, wallet_1.reinitClients)();
554
567
  }
555
- const bootstrapClient = config_1.config.useX402 && config_1.config.chainName === "base" && config_1.config.rpcUrl
556
- ? (0, viem_1.createPublicClient)({ chain: config_1.config.chain, transport: (0, viem_1.http)(config_1.config.rpcUrl) })
557
- : wallet_1.publicClient;
568
+ await checkWalletRecovery();
569
+ const bootstrapClient = (0, wallet_1.getFundingClients)().publicClient;
558
570
  let miners = [];
559
571
  try {
560
572
  miners = await (0, detect_1.detectMinersWithClient)(bootstrapClient, wallet_1.account.address);
561
573
  }
562
574
  catch {
563
- ui.warn("Could not query wallet rigs via bootstrap RPC — continuing with funding guidance.");
575
+ throw new Error("Could not query owned rigs. Retry when the funding RPC responds; do not create a replacement wallet or rig.");
576
+ }
577
+ const funding = await (0, base_funding_1.prepareBaseFunding)(miners.length === 0, true);
578
+ if (!funding.ready) {
579
+ showFundingHandoff(wallet_1.account.address, funding.depositEth, options.easyMode === true);
580
+ return;
564
581
  }
565
582
  if (miners.length > 0) {
566
583
  const best = (0, detect_1.selectBestMiner)(miners);
@@ -570,47 +587,6 @@ async function runStartFlow(options = {}) {
570
587
  await (0, miner_1.startMining)(best.tokenId, { easyMode: options.easyMode === true });
571
588
  return;
572
589
  }
573
- let ethBalance = 0;
574
- let usdcBalance = 0;
575
- let balanceChecksAvailable = true;
576
- try {
577
- const [ethBalanceRaw, usdcBalanceRaw] = await Promise.all([
578
- bootstrapClient.getBalance({ address: wallet_1.account.address }),
579
- config_1.config.useX402
580
- ? bootstrapClient.readContract({
581
- address: config_1.config.chainName === "base" ? "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913" : config_1.config.agentCoinAddress,
582
- abi: erc20BalanceAbi,
583
- functionName: "balanceOf",
584
- args: [wallet_1.account.address],
585
- })
586
- : Promise.resolve(0n),
587
- ]);
588
- ethBalance = Number((0, viem_1.formatEther)(ethBalanceRaw));
589
- usdcBalance = Number((0, viem_1.formatUnits)(usdcBalanceRaw, 6));
590
- }
591
- catch {
592
- balanceChecksAvailable = false;
593
- ui.warn("Could not query wallet balances via bootstrap RPC — funding flow may still be needed.");
594
- }
595
- const needsEth = !balanceChecksAvailable || ethBalance < constants_1.MIN_ETH;
596
- const needsUsdc = config_1.config.useX402 && (!balanceChecksAvailable || usdcBalance < constants_1.MIN_USDC);
597
- if (needsEth || needsUsdc) {
598
- console.log(` ${ui.yellow("Funding needed before minting.")}`);
599
- const fundingRows = [
600
- ["Wallet", `${wallet_1.account.address.slice(0, 6)}...${wallet_1.account.address.slice(-4)}`],
601
- ["ETH", balanceChecksAvailable ? `${ethBalance.toFixed(6)} ETH${needsEth ? ` (need ≥${constants_1.MIN_ETH})` : ""}` : "unknown (RPC check failed)"],
602
- ];
603
- if (config_1.config.useX402) {
604
- fundingRows.push([
605
- "USDC",
606
- balanceChecksAvailable ? `${usdcBalance.toFixed(2)} USDC${needsUsdc ? ` (need ≥${constants_1.MIN_USDC})` : ""}` : "unknown (RPC check failed)",
607
- ]);
608
- }
609
- ui.table(fundingRows);
610
- console.log("");
611
- showFundingHandoff(wallet_1.account.address, needsEth, needsUsdc, options.easyMode === true);
612
- return;
613
- }
614
590
  (0, context_1.setSignerContext)("mint");
615
591
  await (0, mint_1.runMintFlow)({
616
592
  easyMode: options.easyMode === true,
@@ -662,11 +638,13 @@ async function main() {
662
638
  .description("Fund your wallet — bridge from Solana/Ethereum or send on Base")
663
639
  .option("--chain <chain>", "Source chain: solana, ethereum, base")
664
640
  .option("--token <token>", "Source token: sol, usdc, eth")
665
- .option("--amount <eth>", "Target ETH amount (default: 0.005)")
641
+ .option("--amount <eth>", "Bridge ETH target (default: live funding requirement)")
666
642
  .option("--no-swap", "Skip auto-split after bridging")
667
643
  .action(async (opts) => {
668
644
  (0, context_1.setSignerContext)("fund");
669
- await unlockConfiguredKeystoreIfNeeded();
645
+ const unlocked = await unlockConfiguredKeystoreIfNeeded();
646
+ if (config_1.config.keystorePath && !unlocked && !wallet_1.account)
647
+ return;
670
648
  if (!config_1.config.privateKey || !wallet_1.account) {
671
649
  ui.warn("No wallet configured — launching setup first.");
672
650
  await setupWizard();
@@ -677,6 +655,7 @@ async function main() {
677
655
  return;
678
656
  }
679
657
  }
658
+ await checkWalletRecovery();
680
659
  await (0, fund_1.runFundFlow)(opts);
681
660
  });
682
661
  program
@@ -684,7 +663,9 @@ async function main() {
684
663
  .description("Mint a new miner NFT (Easy Mode: x402 LLM, no API key)")
685
664
  .action(async () => {
686
665
  (0, context_1.setSignerContext)("mint");
687
- await unlockConfiguredKeystoreIfNeeded();
666
+ const unlocked = await unlockConfiguredKeystoreIfNeeded();
667
+ if (config_1.config.keystorePath && !unlocked && !wallet_1.account)
668
+ return;
688
669
  if (!config_1.config.privateKey || !wallet_1.account) {
689
670
  ui.warn("No wallet configured — launching setup first.");
690
671
  await setupWizard();
@@ -695,6 +676,12 @@ async function main() {
695
676
  return;
696
677
  }
697
678
  }
679
+ await checkWalletRecovery();
680
+ const funding = await (0, base_funding_1.prepareBaseFunding)(true, true);
681
+ if (!funding.ready) {
682
+ showFundingHandoff(wallet_1.account.address, funding.depositEth, false);
683
+ return;
684
+ }
698
685
  await (0, preflight_1.runPreflight)("wallet");
699
686
  await (0, mint_1.runMintFlow)();
700
687
  });
@@ -821,6 +808,13 @@ async function main() {
821
808
  const walletCmd = program
822
809
  .command("wallet")
823
810
  .description("Wallet generation and management");
811
+ walletCmd.command("verify-recovery")
812
+ .description("Test a fresh-process unlock of the same wallet before funding")
813
+ .action(async () => {
814
+ if (!await unlockConfiguredKeystoreIfNeeded())
815
+ throw new Error("Unlock the existing wallet; do not replace it.");
816
+ await checkWalletRecovery();
817
+ });
824
818
  walletCmd
825
819
  .command("new")
826
820
  .description("Generate a new encrypted Base wallet")
package/dist/miner.js CHANGED
@@ -541,10 +541,10 @@ async function startMining(tokenId, options = {}) {
541
541
  throw err;
542
542
  const msg = err instanceof Error ? err.message : String(err);
543
543
  if (msg.includes("insufficient USDC")) {
544
- console.log(` ${ui.yellow("x402 GPU: insufficient USDC.")} Run: ${ui.cyan("apow wallet fund")}`);
544
+ console.log(` ${ui.yellow("x402 GPU: insufficient USDC.")} Run: ${ui.cyan("apow start --easy")} for an ETH-only quote.`);
545
545
  }
546
546
  else if (msg.includes("simulation_failed")) {
547
- console.log(` ${ui.yellow("x402 GPU: EVM simulation failed.")} ${ui.dim("USDC approval or balance issue")}`);
547
+ console.log(` ${ui.yellow("x402 GPU: EVM simulation failed.")} ${ui.dim("Check balance, signing policy, and the service RPC")}`);
548
548
  }
549
549
  else if (msg.includes("402")) {
550
550
  console.log(` ${ui.yellow("x402 GPU payment failed.")} ${ui.dim(msg.slice(0, 120))}`);
package/dist/preflight.js CHANGED
@@ -39,7 +39,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.runPreflight = runPreflight;
40
40
  const node_child_process_1 = require("node:child_process");
41
41
  const viem_1 = require("viem");
42
- const chains_1 = require("viem/chains");
43
42
  const AgentCoin_json_1 = __importDefault(require("./abi/AgentCoin.json"));
44
43
  const MiningAgent_json_1 = __importDefault(require("./abi/MiningAgent.json"));
45
44
  const config_1 = require("./config");
@@ -49,12 +48,12 @@ const policy_1 = require("./policy/policy");
49
48
  const spend_ledger_1 = require("./policy/spend-ledger");
50
49
  const secure_env_1 = require("./secure-env");
51
50
  const wallet_1 = require("./wallet");
51
+ const base_funding_1 = require("./base-funding");
52
52
  const ui = __importStar(require("./ui"));
53
53
  const agentCoinAbi = AgentCoin_json_1.default;
54
54
  const miningAgentAbi = MiningAgent_json_1.default;
55
55
  const USDC_ADDRESS = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
56
56
  const USDC_DECIMALS = 6;
57
- const MINT_GAS_RESERVE_ETH = (0, viem_1.parseEther)("0.003");
58
57
  const erc20BalanceAbi = [
59
58
  {
60
59
  type: "function",
@@ -145,18 +144,11 @@ async function runPreflight(level) {
145
144
  // Check x402: USDC balance BEFORE RPC check (can't use x402 without USDC)
146
145
  let x402Funded = false;
147
146
  if (config_1.config.useX402 && wallet_1.account) {
148
- if (!config_1.config.rpcUrl) {
149
- x402Funded = true; // optimistic — the x402 RPC check below will verify reachability.
150
- ui.warn("Skipping x402 USDC precheck because RPC_URL is not set; refusing to use public Base RPC endpoints");
151
- }
152
- else {
147
+ {
153
148
  try {
154
149
  // Use a separate lightweight client to avoid chicken-and-egg
155
150
  // (can't use x402 to check if we can pay for x402)
156
- const checkClient = (0, viem_1.createPublicClient)({
157
- chain: chains_1.base,
158
- transport: (0, viem_1.http)(config_1.config.rpcUrl),
159
- });
151
+ const checkClient = (0, wallet_1.getFundingClients)().publicClient;
160
152
  const usdcBalance = (await checkClient.readContract({
161
153
  address: USDC_ADDRESS,
162
154
  abi: erc20BalanceAbi,
@@ -167,7 +159,7 @@ async function runPreflight(level) {
167
159
  results.push({
168
160
  label: "No USDC balance — QuickNode x402 requires USDC on Base",
169
161
  passed: false,
170
- fix: `Send at least 2.00 USDC to ${wallet_1.account.address} on Base for x402 starting balance; add more if you want extra headroom. Run \`apow fund\` to bridge from Solana or Ethereum.`,
162
+ fix: "Run `apow start --easy` to quote an ETH-only deposit and convert the service budget to USDC.",
171
163
  });
172
164
  }
173
165
  else {
@@ -180,9 +172,7 @@ async function runPreflight(level) {
180
172
  }
181
173
  }
182
174
  catch {
183
- // USDC check failed — can't verify, warn but don't block
184
- x402Funded = true; // optimistic — let the RPC check determine reachability
185
- ui.warn("Could not check USDC balance — QuickNode x402 may fail if wallet has no USDC");
175
+ results.push({ label: "Could not verify x402 funding", passed: false, fix: "Retry when the funding RPC responds" });
186
176
  }
187
177
  }
188
178
  }
@@ -257,12 +247,12 @@ async function runPreflight(level) {
257
247
  abi: miningAgentAbi,
258
248
  functionName: "getMintPrice",
259
249
  }));
260
- const requiredBalance = mintPrice + MINT_GAS_RESERVE_ETH;
250
+ const requiredBalance = mintPrice + base_funding_1.MINT_GAS_RESERVE_ETH;
261
251
  if (balance < requiredBalance) {
262
252
  results.push({
263
253
  label: `Mint-ready ETH balance (${ethBalance.toFixed(6)} ETH)`,
264
254
  passed: false,
265
- fix: `Mint needs ${(0, viem_1.formatEther)(mintPrice)} ETH for the rig plus ~${(0, viem_1.formatEther)(MINT_GAS_RESERVE_ETH)} ETH for the getChallenge and mint transactions. Send at least ${(0, viem_1.formatEther)(requiredBalance)} ETH to ${wallet_1.account.address} on Base.`,
255
+ fix: `Mint price is ${(0, viem_1.formatEther)(mintPrice)} ETH; the CLI also retains a conservative ${(0, viem_1.formatEther)(base_funding_1.MINT_GAS_RESERVE_ETH)} ETH reserve. The reserve is not a transaction fee. Run apow start --easy for the complete ETH-only quote.`,
266
256
  });
267
257
  }
268
258
  else {
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.verifyWalletRecovery = verifyWalletRecovery;
4
+ const node_child_process_1 = require("node:child_process");
5
+ const node_fs_1 = require("node:fs");
6
+ const node_path_1 = require("node:path");
7
+ const dotenv_1 = require("dotenv");
8
+ /** Verify an independent unlock without returning a key or password to the caller. */
9
+ function verifyWalletRecovery(keystorePath, expectedAddress, password) {
10
+ const environment = { ...process.env };
11
+ delete environment.PRIVATE_KEY;
12
+ delete environment.KEYSTORE_PASSWORD;
13
+ delete environment.APOW_KEYSTORE_PASSWORD;
14
+ delete environment.KEYSTORE_PASSWORD_CMD;
15
+ delete environment.APOW_KEYSTORE_PASSWORD_CMD;
16
+ if (!password) {
17
+ let saved = {};
18
+ try {
19
+ saved = (0, dotenv_1.parse)((0, node_fs_1.readFileSync)((0, node_path_1.join)(process.cwd(), ".env")));
20
+ }
21
+ catch { /* report below */ }
22
+ const command = saved.KEYSTORE_PASSWORD_CMD || saved.APOW_KEYSTORE_PASSWORD_CMD;
23
+ if (!command?.trim()) {
24
+ throw new Error("Before funding, save a secret-manager unlock command as KEYSTORE_PASSWORD_CMD in .env. A process-only password will not survive a restart. Do not put the password in chat or .env.");
25
+ }
26
+ environment.KEYSTORE_PASSWORD_CMD = command;
27
+ }
28
+ const script = `
29
+ try {
30
+ const fs = require('node:fs');
31
+ const { spawnSync } = require('node:child_process');
32
+ let password = fs.readFileSync(0, 'utf8');
33
+ if (!password) {
34
+ const result = spawnSync(process.env.KEYSTORE_PASSWORD_CMD, { shell: true, encoding: 'utf8', timeout: 10000, stdio: ['ignore', 'pipe', 'ignore'] });
35
+ if (result.status !== 0) process.exit(1);
36
+ password = result.stdout.trim();
37
+ }
38
+ if (!password) process.exit(1);
39
+ const { loadEncryptedKeystoreFile } = require(process.argv[1]);
40
+ const { privateKeyToAccount } = require(process.argv[3]);
41
+ const address = privateKeyToAccount(loadEncryptedKeystoreFile(process.argv[2], password)).address;
42
+ process.stdout.write(address);
43
+ } catch { process.exit(1); }
44
+ `;
45
+ const result = (0, node_child_process_1.spawnSync)(process.execPath, ["-e", script, (0, node_path_1.join)(__dirname, "wallet-store.js"), keystorePath, require.resolve("viem/accounts")], {
46
+ env: environment, input: password ?? "", encoding: "utf8", timeout: 30_000,
47
+ stdio: ["pipe", "pipe", "ignore"],
48
+ });
49
+ if (result.status !== 0 || result.stdout.trim().toLowerCase() !== expectedAddress.toLowerCase()) {
50
+ throw new Error("Fresh-process wallet recovery failed. Keep the same wallet and repair its secret-manager unlock before funding.");
51
+ }
52
+ }
package/dist/wallet.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.walletClient = exports.account = exports.publicClient = void 0;
3
+ exports.walletClient = exports.account = exports.publicClient = exports.DATA_SUFFIX = void 0;
4
4
  exports.reinitClients = reinitClients;
5
5
  exports.getFundingClients = getFundingClients;
6
6
  exports.requireWallet = requireWallet;
@@ -10,7 +10,7 @@ const erc8021_1 = require("ox/erc8021");
10
10
  const config_1 = require("./config");
11
11
  const local_keystore_1 = require("./signer/local-keystore");
12
12
  const x402_1 = require("./x402");
13
- const DATA_SUFFIX = erc8021_1.Attribution.toDataSuffix({ codes: ["bc_6wfeb1kd"] });
13
+ exports.DATA_SUFFIX = erc8021_1.Attribution.toDataSuffix({ codes: ["bc_6wfeb1kd"] });
14
14
  function getTransport() {
15
15
  const signer = (0, local_keystore_1.getSigner)();
16
16
  if (config_1.config.useX402 && signer) {
@@ -29,7 +29,7 @@ exports.walletClient = exports.account
29
29
  account: exports.account,
30
30
  chain: config_1.config.chain,
31
31
  transport,
32
- dataSuffix: DATA_SUFFIX,
32
+ dataSuffix: exports.DATA_SUFFIX,
33
33
  })
34
34
  : null;
35
35
  let bootstrapPublicClient = (0, viem_1.createPublicClient)({
@@ -42,14 +42,14 @@ let bootstrapWalletClient = bootstrapAccount
42
42
  account: bootstrapAccount,
43
43
  chain: config_1.config.chain,
44
44
  transport: getBootstrapTransport(),
45
- dataSuffix: DATA_SUFFIX,
45
+ dataSuffix: exports.DATA_SUFFIX,
46
46
  })
47
47
  : null;
48
48
  function shouldUseBootstrapFundingClients() {
49
- return config_1.config.useX402 && config_1.config.chainName === "base" && !!config_1.config.rpcUrl;
49
+ return config_1.config.chainName === "base";
50
50
  }
51
51
  function getBootstrapTransport() {
52
- return config_1.config.rpcUrl ? (0, viem_1.http)(config_1.config.rpcUrl) : transport;
52
+ return config_1.config.chainName === "base" ? (0, viem_1.http)(config_1.config.rpcUrl || "https://base.publicnode.com") : transport;
53
53
  }
54
54
  /** Reinitialize clients after config changes (e.g., x402 fallback). */
55
55
  function reinitClients() {
@@ -62,7 +62,7 @@ function reinitClients() {
62
62
  account: exports.account,
63
63
  chain: config_1.config.chain,
64
64
  transport,
65
- dataSuffix: DATA_SUFFIX,
65
+ dataSuffix: exports.DATA_SUFFIX,
66
66
  })
67
67
  : null;
68
68
  bootstrapPublicClient = (0, viem_1.createPublicClient)({
@@ -75,7 +75,7 @@ function reinitClients() {
75
75
  account: bootstrapAccount,
76
76
  chain: config_1.config.chain,
77
77
  transport: getBootstrapTransport(),
78
- dataSuffix: DATA_SUFFIX,
78
+ dataSuffix: exports.DATA_SUFFIX,
79
79
  })
80
80
  : null;
81
81
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apow-cli",
3
- "version": "0.12.0",
3
+ "version": "0.12.3",
4
4
  "description": "Mine AGENT tokens on Base L2 with Agentic Proof of Work",
5
5
  "keywords": [
6
6
  "apow",
@@ -16,11 +16,12 @@
16
16
  "author": "Agentoshi",
17
17
  "repository": {
18
18
  "type": "git",
19
- "url": "https://github.com/Agentoshi/apow-cli.git"
19
+ "url": "git+https://github.com/Agentoshi/apow.git",
20
+ "directory": "packages/cli"
20
21
  },
21
22
  "homepage": "https://apow.io",
22
23
  "bugs": {
23
- "url": "https://github.com/Agentoshi/apow-cli/issues"
24
+ "url": "https://github.com/Agentoshi/apow/issues"
24
25
  },
25
26
  "bin": {
26
27
  "apow": "dist/index.js",
@@ -45,7 +46,7 @@
45
46
  "scripts": {
46
47
  "build": "tsc",
47
48
  "dev": "tsx src/index.ts",
48
- "test": "tsx --test \"src/**/*.test.ts\"",
49
+ "test": "npm run build && tsx --test \"src/**/*.test.ts\"",
49
50
  "prepublishOnly": "npm run build"
50
51
  },
51
52
  "dependencies": {