@blockrun/clawrouter 0.12.26 → 0.12.28

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.d.ts CHANGED
@@ -762,8 +762,6 @@ type WalletResolution = {
762
762
  source: "saved" | "env" | "generated";
763
763
  mnemonic?: string;
764
764
  solanaPrivateKeyBytes?: Uint8Array;
765
- /** Legacy (secp256k1) Solana key bytes, present when migration is needed. */
766
- legacySolanaKeyBytes?: Uint8Array;
767
765
  };
768
766
  /**
769
767
  * Set up Solana wallet for existing EVM-only users.
package/dist/index.js CHANGED
@@ -4214,32 +4214,6 @@ Then run: npx @blockrun/clawrouter`
4214
4214
  solanaPrivateKeyBytes: derived.solanaPrivateKeyBytes
4215
4215
  };
4216
4216
  }
4217
- async function logMigrationWarning(legacyKeyBytes, newKeyBytes) {
4218
- try {
4219
- const { createKeyPairSignerFromPrivateKeyBytes: createKeyPairSignerFromPrivateKeyBytes2 } = await import("@solana/kit");
4220
- const [oldSigner, newSigner] = await Promise.all([
4221
- createKeyPairSignerFromPrivateKeyBytes2(legacyKeyBytes),
4222
- createKeyPairSignerFromPrivateKeyBytes2(newKeyBytes)
4223
- ]);
4224
- console.log(`[ClawRouter]`);
4225
- console.log(`[ClawRouter] \u26A0 SOLANA WALLET MIGRATION DETECTED`);
4226
- 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`);
4227
- console.log(`[ClawRouter] Old address (secp256k1): ${oldSigner.address}`);
4228
- console.log(`[ClawRouter] New address (SLIP-10): ${newSigner.address}`);
4229
- console.log(`[ClawRouter]`);
4230
- console.log(`[ClawRouter] Your Solana wallet derivation has been fixed to use`);
4231
- console.log(`[ClawRouter] SLIP-10 Ed25519 (Phantom/Solflare compatible).`);
4232
- console.log(`[ClawRouter]`);
4233
- console.log(`[ClawRouter] If you had funds in the old wallet, run:`);
4234
- console.log(`[ClawRouter] /wallet migrate-solana`);
4235
- console.log(`[ClawRouter]`);
4236
- console.log(`[ClawRouter] The new wallet pays gas. Send ~0.005 SOL to:`);
4237
- console.log(`[ClawRouter] ${newSigner.address}`);
4238
- 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`);
4239
- console.log(`[ClawRouter]`);
4240
- } catch {
4241
- }
4242
- }
4243
4217
  async function resolveOrGenerateWalletKey() {
4244
4218
  const saved = await loadSavedWallet();
4245
4219
  if (saved) {
@@ -4247,19 +4221,13 @@ async function resolveOrGenerateWalletKey() {
4247
4221
  const mnemonic = await loadMnemonic();
4248
4222
  if (mnemonic) {
4249
4223
  const solanaKeyBytes = deriveSolanaKeyBytes(mnemonic);
4250
- const result2 = {
4224
+ return {
4251
4225
  key: saved,
4252
4226
  address: account.address,
4253
4227
  source: "saved",
4254
4228
  mnemonic,
4255
4229
  solanaPrivateKeyBytes: solanaKeyBytes
4256
4230
  };
4257
- const legacyKeyBytes = deriveSolanaKeyBytesLegacy(mnemonic);
4258
- if (Buffer.from(legacyKeyBytes).toString("hex") !== Buffer.from(solanaKeyBytes).toString("hex")) {
4259
- result2.legacySolanaKeyBytes = legacyKeyBytes;
4260
- await logMigrationWarning(legacyKeyBytes, solanaKeyBytes);
4261
- }
4262
- return result2;
4263
4231
  }
4264
4232
  return { key: saved, address: account.address, source: "saved" };
4265
4233
  }
@@ -4269,19 +4237,13 @@ async function resolveOrGenerateWalletKey() {
4269
4237
  const mnemonic = await loadMnemonic();
4270
4238
  if (mnemonic) {
4271
4239
  const solanaKeyBytes = deriveSolanaKeyBytes(mnemonic);
4272
- const result2 = {
4240
+ return {
4273
4241
  key: envKey,
4274
4242
  address: account.address,
4275
4243
  source: "env",
4276
4244
  mnemonic,
4277
4245
  solanaPrivateKeyBytes: solanaKeyBytes
4278
4246
  };
4279
- const legacyKeyBytes = deriveSolanaKeyBytesLegacy(mnemonic);
4280
- if (Buffer.from(legacyKeyBytes).toString("hex") !== Buffer.from(solanaKeyBytes).toString("hex")) {
4281
- result2.legacySolanaKeyBytes = legacyKeyBytes;
4282
- await logMigrationWarning(legacyKeyBytes, solanaKeyBytes);
4283
- }
4284
- return result2;
4285
4247
  }
4286
4248
  return { key: envKey, address: account.address, source: "env" };
4287
4249
  }
@@ -5578,6 +5540,58 @@ function transformPaymentError(errorBody) {
5578
5540
  }
5579
5541
  }
5580
5542
  }
5543
+ if (parsed.error === "Payment verification failed" && parsed.code === "PAYMENT_INVALID" && parsed.debug) {
5544
+ const debugLower = parsed.debug.toLowerCase();
5545
+ const wallet = parsed.payer || "unknown";
5546
+ const shortWallet = wallet.length > 12 ? `${wallet.slice(0, 6)}...${wallet.slice(-4)}` : wallet;
5547
+ if (debugLower.includes("insufficient")) {
5548
+ return JSON.stringify({
5549
+ error: {
5550
+ message: "Insufficient Solana USDC balance.",
5551
+ type: "insufficient_funds",
5552
+ wallet,
5553
+ help: `Fund wallet ${shortWallet} with USDC on Solana, or switch to Base: /wallet base`
5554
+ }
5555
+ });
5556
+ }
5557
+ if (debugLower.includes("transaction_simulation_failed") || debugLower.includes("simulation")) {
5558
+ console.error(`[ClawRouter] Solana transaction simulation failed: ${parsed.debug}`);
5559
+ return JSON.stringify({
5560
+ error: {
5561
+ message: "Solana payment simulation failed. Retrying with a different model.",
5562
+ type: "transaction_simulation_failed",
5563
+ help: "This is usually temporary. If it persists, try: /model free"
5564
+ }
5565
+ });
5566
+ }
5567
+ if (debugLower.includes("invalid signature") || debugLower.includes("invalid_signature")) {
5568
+ return JSON.stringify({
5569
+ error: {
5570
+ message: "Solana payment signature invalid.",
5571
+ type: "invalid_payload",
5572
+ help: "Try again. If this persists, reinstall ClawRouter: curl -fsSL https://blockrun.ai/ClawRouter-update | bash"
5573
+ }
5574
+ });
5575
+ }
5576
+ if (debugLower.includes("expired")) {
5577
+ return JSON.stringify({
5578
+ error: {
5579
+ message: "Solana payment expired. Retrying.",
5580
+ type: "expired",
5581
+ help: "This is usually temporary."
5582
+ }
5583
+ });
5584
+ }
5585
+ console.error(`[ClawRouter] Solana payment verification failed: ${parsed.debug} payer=${wallet}`);
5586
+ return JSON.stringify({
5587
+ error: {
5588
+ message: `Solana payment verification failed: ${parsed.debug}`,
5589
+ type: "payment_invalid",
5590
+ wallet,
5591
+ help: "Try again or switch to Base: /wallet base"
5592
+ }
5593
+ });
5594
+ }
5581
5595
  if (parsed.error === "Settlement failed" || parsed.error === "Payment settlement failed" || parsed.details?.includes("Settlement failed") || parsed.details?.includes("transaction_simulation_failed")) {
5582
5596
  const details = parsed.details || "";
5583
5597
  const gasError = details.includes("unable to estimate gas");
@@ -6146,7 +6160,7 @@ async function startProxy(options) {
6146
6160
  const solanaSigner = await createKeyPairSignerFromPrivateKeyBytes2(solanaPrivateKeyBytes);
6147
6161
  solanaAddress = solanaSigner.address;
6148
6162
  registerExactSvmScheme(x402, { signer: solanaSigner });
6149
- console.log(`[ClawRouter] Solana x402 scheme registered: ${solanaAddress}`);
6163
+ console.log(`[ClawRouter] Solana wallet: ${solanaAddress}`);
6150
6164
  }
6151
6165
  x402.onAfterPaymentCreation(async (context) => {
6152
6166
  const network = context.selectedRequirements.network;
@@ -8446,17 +8460,18 @@ async function startProxyInBackground(api) {
8446
8460
  api.logger.info(`Pricing: Simple ~$0.001 | Code ~$0.01 | Complex ~$0.05 | Free: $0`);
8447
8461
  const currentChain = await resolvePaymentChain();
8448
8462
  const displayAddress = currentChain === "solana" && proxy.solanaAddress ? proxy.solanaAddress : wallet.address;
8463
+ const network = currentChain === "solana" ? "Solana" : "Base";
8449
8464
  proxy.balanceMonitor.checkBalance().then((balance) => {
8450
8465
  if (balance.isEmpty) {
8451
- api.logger.info(`Wallet: ${displayAddress} | Balance: $0.00`);
8452
- api.logger.info(`Using FREE model. Fund wallet for premium models.`);
8466
+ api.logger.info(`Wallet (${network}): ${displayAddress}`);
8467
+ api.logger.info(`Balance: $0.00 \u2014 send USDC on ${network} to the address above to unlock paid models.`);
8453
8468
  } else if (balance.isLow) {
8454
- api.logger.info(`Wallet: ${displayAddress} | Balance: ${balance.balanceUSD} (low)`);
8469
+ api.logger.info(`Wallet (${network}): ${displayAddress} | Balance: ${balance.balanceUSD} (low \u2014 top up soon)`);
8455
8470
  } else {
8456
- api.logger.info(`Wallet: ${displayAddress} | Balance: ${balance.balanceUSD}`);
8471
+ api.logger.info(`Wallet (${network}): ${displayAddress} | Balance: ${balance.balanceUSD}`);
8457
8472
  }
8458
8473
  }).catch(() => {
8459
- api.logger.info(`Wallet: ${displayAddress} | Balance: (checking...)`);
8474
+ api.logger.info(`Wallet (${network}): ${displayAddress} | Balance: (checking...)`);
8460
8475
  });
8461
8476
  }
8462
8477
  async function createStatsCommand() {