@dexterai/x402 2.1.0 → 3.0.1

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.
@@ -656,21 +656,51 @@ var EvmAdapter = class {
656
656
  });
657
657
  const url = rpcUrl || this.getDefaultRpcUrl(accept.network);
658
658
  const currentAllowance = await this.readAllowance(url, asset, wallet.address, PERMIT2_ADDRESS);
659
+ let approvalExtension;
659
660
  if (currentAllowance < BigInt(amount)) {
660
- if (!wallet.sendTransaction) {
661
+ const approveData = this.encodeApprove(PERMIT2_ADDRESS, MAX_UINT256);
662
+ if (wallet.signTransaction) {
663
+ this.log(`Signing Permit2 approval for relay (current allowance: ${currentAllowance})`);
664
+ const chainId2 = this.getChainId(accept.network);
665
+ const gasPrice = await this.readGasPrice(url);
666
+ const nonce2 = await this.readNonce(url, wallet.address);
667
+ const signedTx = await wallet.signTransaction({
668
+ to: asset,
669
+ data: approveData,
670
+ chainId: chainId2,
671
+ gas: 50000n,
672
+ // standard ERC-20 approve
673
+ gasPrice,
674
+ nonce: nonce2
675
+ });
676
+ approvalExtension = {
677
+ erc20ApprovalGasSponsoring: {
678
+ info: {
679
+ from: wallet.address,
680
+ asset,
681
+ spender: PERMIT2_ADDRESS,
682
+ amount: MAX_UINT256.toString(),
683
+ signedTransaction: signedTx,
684
+ version: "1"
685
+ }
686
+ }
687
+ };
688
+ this.log("Permit2 approval signed for facilitator relay");
689
+ } else if (wallet.sendTransaction) {
690
+ this.log(`Approving Permit2 directly (current allowance: ${currentAllowance})`);
691
+ const approveTxHash = await wallet.sendTransaction({
692
+ to: asset,
693
+ data: approveData,
694
+ value: 0n
695
+ });
696
+ this.log(`Permit2 approval tx sent: ${approveTxHash}`);
697
+ await this.waitForReceipt(url, approveTxHash);
698
+ this.log("Permit2 approval confirmed");
699
+ } else {
661
700
  throw new Error(
662
- "Permit2 payments require a wallet that supports sendTransaction for the one-time Permit2 approval. Use createEvmKeypairWallet() or a browser wallet with transaction support."
701
+ "Permit2 payments require a wallet that supports signTransaction or sendTransaction for the one-time Permit2 approval. Use createEvmKeypairWallet() or a browser wallet with transaction support."
663
702
  );
664
703
  }
665
- this.log(`Approving Permit2 for ${asset} (current allowance: ${currentAllowance})`);
666
- const approveTxHash = await wallet.sendTransaction({
667
- to: asset,
668
- data: this.encodeApprove(PERMIT2_ADDRESS, MAX_UINT256),
669
- value: 0n
670
- });
671
- this.log(`Permit2 approval tx sent: ${approveTxHash}`);
672
- await this.waitForReceipt(url, approveTxHash);
673
- this.log("Permit2 approval confirmed");
674
704
  } else {
675
705
  this.log("Sufficient Permit2 allowance, skipping approval");
676
706
  }
@@ -725,7 +755,8 @@ var EvmAdapter = class {
725
755
  };
726
756
  return {
727
757
  serialized: JSON.stringify(payload),
728
- signature
758
+ signature,
759
+ extensions: approvalExtension
729
760
  };
730
761
  }
731
762
  /**
@@ -794,6 +825,43 @@ var EvmAdapter = class {
794
825
  }
795
826
  throw new Error(`Approval transaction receipt timeout after ${timeoutMs}ms: ${txHash}`);
796
827
  }
828
+ /**
829
+ * Read gas price via eth_gasPrice RPC call.
830
+ */
831
+ async readGasPrice(rpcUrl) {
832
+ try {
833
+ const response = await fetch(rpcUrl, {
834
+ method: "POST",
835
+ headers: { "Content-Type": "application/json" },
836
+ body: JSON.stringify({ jsonrpc: "2.0", id: 1, method: "eth_gasPrice", params: [] })
837
+ });
838
+ const result = await response.json();
839
+ return result.result ? BigInt(result.result) : 50000000n;
840
+ } catch {
841
+ return 50000000n;
842
+ }
843
+ }
844
+ /**
845
+ * Read transaction count (nonce) via eth_getTransactionCount RPC call.
846
+ */
847
+ async readNonce(rpcUrl, address) {
848
+ try {
849
+ const response = await fetch(rpcUrl, {
850
+ method: "POST",
851
+ headers: { "Content-Type": "application/json" },
852
+ body: JSON.stringify({
853
+ jsonrpc: "2.0",
854
+ id: 1,
855
+ method: "eth_getTransactionCount",
856
+ params: [address, "latest"]
857
+ })
858
+ });
859
+ const result = await response.json();
860
+ return result.result ? parseInt(result.result, 16) : 0;
861
+ } catch {
862
+ return 0;
863
+ }
864
+ }
797
865
  /**
798
866
  * Calculate how much to approve based on the facilitator's approval strategy.
799
867
  * Buffered approvals reduce the number of on-chain approval txs for micropayments.
@@ -1,5 +1,5 @@
1
- import { e as SolanaAdapter, f as EvmAdapter, C as ChainAdapter } from '../types-D1u7iu8n.cjs';
2
- export { q as ARBITRUM_ONE, s as AVALANCHE, A as AdapterConfig, B as BASE_MAINNET, p as BASE_SEPOLIA, l as BSC_MAINNET, o as BSC_STABLECOIN_ADDRESSES, n as BSC_USDC, m as BSC_USDT, d as BalanceInfo, v as ETHEREUM_MAINNET, E as EvmWallet, G as GenericWallet, O as OPTIMISM, P as PERMIT2_ADDRESS, r as POLYGON, t as SKALE_BASE, u as SKALE_BASE_SEPOLIA, h as SOLANA_DEVNET, b as SOLANA_MAINNET, j as SOLANA_TESTNET, g as SignedTransaction, S as SolanaWallet, U as USDC_ADDRESSES, W as WalletSet, X as X402_EXACT_PERMIT2_PROXY, a as createEvmAdapter, c as createSolanaAdapter, k as isEvmWallet, i as isSolanaWallet } from '../types-D1u7iu8n.cjs';
1
+ import { e as SolanaAdapter, f as EvmAdapter, C as ChainAdapter } from '../types-C_aQh02s.cjs';
2
+ export { q as ARBITRUM_ONE, s as AVALANCHE, A as AdapterConfig, B as BASE_MAINNET, p as BASE_SEPOLIA, l as BSC_MAINNET, o as BSC_STABLECOIN_ADDRESSES, n as BSC_USDC, m as BSC_USDT, d as BalanceInfo, v as ETHEREUM_MAINNET, E as EvmWallet, G as GenericWallet, O as OPTIMISM, P as PERMIT2_ADDRESS, r as POLYGON, t as SKALE_BASE, u as SKALE_BASE_SEPOLIA, h as SOLANA_DEVNET, b as SOLANA_MAINNET, j as SOLANA_TESTNET, g as SignedTransaction, S as SolanaWallet, U as USDC_ADDRESSES, W as WalletSet, X as X402_EXACT_PERMIT2_PROXY, a as createEvmAdapter, c as createSolanaAdapter, k as isEvmWallet, i as isSolanaWallet } from '../types-C_aQh02s.cjs';
3
3
  import '../types-_iT11DL0.cjs';
4
4
 
5
5
  /**
@@ -1,5 +1,5 @@
1
- import { e as SolanaAdapter, f as EvmAdapter, C as ChainAdapter } from '../types-YQlJI5E3.js';
2
- export { q as ARBITRUM_ONE, s as AVALANCHE, A as AdapterConfig, B as BASE_MAINNET, p as BASE_SEPOLIA, l as BSC_MAINNET, o as BSC_STABLECOIN_ADDRESSES, n as BSC_USDC, m as BSC_USDT, d as BalanceInfo, v as ETHEREUM_MAINNET, E as EvmWallet, G as GenericWallet, O as OPTIMISM, P as PERMIT2_ADDRESS, r as POLYGON, t as SKALE_BASE, u as SKALE_BASE_SEPOLIA, h as SOLANA_DEVNET, b as SOLANA_MAINNET, j as SOLANA_TESTNET, g as SignedTransaction, S as SolanaWallet, U as USDC_ADDRESSES, W as WalletSet, X as X402_EXACT_PERMIT2_PROXY, a as createEvmAdapter, c as createSolanaAdapter, k as isEvmWallet, i as isSolanaWallet } from '../types-YQlJI5E3.js';
1
+ import { e as SolanaAdapter, f as EvmAdapter, C as ChainAdapter } from '../types-DBS0XOsH.js';
2
+ export { q as ARBITRUM_ONE, s as AVALANCHE, A as AdapterConfig, B as BASE_MAINNET, p as BASE_SEPOLIA, l as BSC_MAINNET, o as BSC_STABLECOIN_ADDRESSES, n as BSC_USDC, m as BSC_USDT, d as BalanceInfo, v as ETHEREUM_MAINNET, E as EvmWallet, G as GenericWallet, O as OPTIMISM, P as PERMIT2_ADDRESS, r as POLYGON, t as SKALE_BASE, u as SKALE_BASE_SEPOLIA, h as SOLANA_DEVNET, b as SOLANA_MAINNET, j as SOLANA_TESTNET, g as SignedTransaction, S as SolanaWallet, U as USDC_ADDRESSES, W as WalletSet, X as X402_EXACT_PERMIT2_PROXY, a as createEvmAdapter, c as createSolanaAdapter, k as isEvmWallet, i as isSolanaWallet } from '../types-DBS0XOsH.js';
3
3
  import '../types-_iT11DL0.js';
4
4
 
5
5
  /**
@@ -606,21 +606,51 @@ var EvmAdapter = class {
606
606
  });
607
607
  const url = rpcUrl || this.getDefaultRpcUrl(accept.network);
608
608
  const currentAllowance = await this.readAllowance(url, asset, wallet.address, PERMIT2_ADDRESS);
609
+ let approvalExtension;
609
610
  if (currentAllowance < BigInt(amount)) {
610
- if (!wallet.sendTransaction) {
611
+ const approveData = this.encodeApprove(PERMIT2_ADDRESS, MAX_UINT256);
612
+ if (wallet.signTransaction) {
613
+ this.log(`Signing Permit2 approval for relay (current allowance: ${currentAllowance})`);
614
+ const chainId2 = this.getChainId(accept.network);
615
+ const gasPrice = await this.readGasPrice(url);
616
+ const nonce2 = await this.readNonce(url, wallet.address);
617
+ const signedTx = await wallet.signTransaction({
618
+ to: asset,
619
+ data: approveData,
620
+ chainId: chainId2,
621
+ gas: 50000n,
622
+ // standard ERC-20 approve
623
+ gasPrice,
624
+ nonce: nonce2
625
+ });
626
+ approvalExtension = {
627
+ erc20ApprovalGasSponsoring: {
628
+ info: {
629
+ from: wallet.address,
630
+ asset,
631
+ spender: PERMIT2_ADDRESS,
632
+ amount: MAX_UINT256.toString(),
633
+ signedTransaction: signedTx,
634
+ version: "1"
635
+ }
636
+ }
637
+ };
638
+ this.log("Permit2 approval signed for facilitator relay");
639
+ } else if (wallet.sendTransaction) {
640
+ this.log(`Approving Permit2 directly (current allowance: ${currentAllowance})`);
641
+ const approveTxHash = await wallet.sendTransaction({
642
+ to: asset,
643
+ data: approveData,
644
+ value: 0n
645
+ });
646
+ this.log(`Permit2 approval tx sent: ${approveTxHash}`);
647
+ await this.waitForReceipt(url, approveTxHash);
648
+ this.log("Permit2 approval confirmed");
649
+ } else {
611
650
  throw new Error(
612
- "Permit2 payments require a wallet that supports sendTransaction for the one-time Permit2 approval. Use createEvmKeypairWallet() or a browser wallet with transaction support."
651
+ "Permit2 payments require a wallet that supports signTransaction or sendTransaction for the one-time Permit2 approval. Use createEvmKeypairWallet() or a browser wallet with transaction support."
613
652
  );
614
653
  }
615
- this.log(`Approving Permit2 for ${asset} (current allowance: ${currentAllowance})`);
616
- const approveTxHash = await wallet.sendTransaction({
617
- to: asset,
618
- data: this.encodeApprove(PERMIT2_ADDRESS, MAX_UINT256),
619
- value: 0n
620
- });
621
- this.log(`Permit2 approval tx sent: ${approveTxHash}`);
622
- await this.waitForReceipt(url, approveTxHash);
623
- this.log("Permit2 approval confirmed");
624
654
  } else {
625
655
  this.log("Sufficient Permit2 allowance, skipping approval");
626
656
  }
@@ -675,7 +705,8 @@ var EvmAdapter = class {
675
705
  };
676
706
  return {
677
707
  serialized: JSON.stringify(payload),
678
- signature
708
+ signature,
709
+ extensions: approvalExtension
679
710
  };
680
711
  }
681
712
  /**
@@ -744,6 +775,43 @@ var EvmAdapter = class {
744
775
  }
745
776
  throw new Error(`Approval transaction receipt timeout after ${timeoutMs}ms: ${txHash}`);
746
777
  }
778
+ /**
779
+ * Read gas price via eth_gasPrice RPC call.
780
+ */
781
+ async readGasPrice(rpcUrl) {
782
+ try {
783
+ const response = await fetch(rpcUrl, {
784
+ method: "POST",
785
+ headers: { "Content-Type": "application/json" },
786
+ body: JSON.stringify({ jsonrpc: "2.0", id: 1, method: "eth_gasPrice", params: [] })
787
+ });
788
+ const result = await response.json();
789
+ return result.result ? BigInt(result.result) : 50000000n;
790
+ } catch {
791
+ return 50000000n;
792
+ }
793
+ }
794
+ /**
795
+ * Read transaction count (nonce) via eth_getTransactionCount RPC call.
796
+ */
797
+ async readNonce(rpcUrl, address) {
798
+ try {
799
+ const response = await fetch(rpcUrl, {
800
+ method: "POST",
801
+ headers: { "Content-Type": "application/json" },
802
+ body: JSON.stringify({
803
+ jsonrpc: "2.0",
804
+ id: 1,
805
+ method: "eth_getTransactionCount",
806
+ params: [address, "latest"]
807
+ })
808
+ });
809
+ const result = await response.json();
810
+ return result.result ? parseInt(result.result, 16) : 0;
811
+ } catch {
812
+ return 0;
813
+ }
814
+ }
747
815
  /**
748
816
  * Calculate how much to approve based on the facilitator's approval strategy.
749
817
  * Buffered approvals reduce the number of on-chain approval txs for micropayments.
@@ -191,6 +191,7 @@ __export(client_exports, {
191
191
  SOLANA_MAINNET: () => SOLANA_MAINNET,
192
192
  USDC_MINT: () => USDC_MINT,
193
193
  X402Error: () => X402Error,
194
+ capabilitySearch: () => import_x402_core.capabilitySearch,
194
195
  createBudgetAccount: () => createBudgetAccount,
195
196
  createEvmAdapter: () => createEvmAdapter,
196
197
  createEvmKeypairWallet: () => createEvmKeypairWallet,
@@ -203,7 +204,6 @@ __export(client_exports, {
203
204
  getSponsoredRecommendations: () => getSponsoredRecommendations,
204
205
  isEvmKeypairWallet: () => isEvmKeypairWallet,
205
206
  isKeypairWallet: () => isKeypairWallet,
206
- searchAPIs: () => searchAPIs,
207
207
  wrapFetch: () => wrapFetch
208
208
  });
209
209
  module.exports = __toCommonJS(client_exports);
@@ -820,21 +820,51 @@ var EvmAdapter = class {
820
820
  });
821
821
  const url = rpcUrl || this.getDefaultRpcUrl(accept.network);
822
822
  const currentAllowance = await this.readAllowance(url, asset, wallet.address, PERMIT2_ADDRESS);
823
+ let approvalExtension;
823
824
  if (currentAllowance < BigInt(amount)) {
824
- if (!wallet.sendTransaction) {
825
+ const approveData = this.encodeApprove(PERMIT2_ADDRESS, MAX_UINT256);
826
+ if (wallet.signTransaction) {
827
+ this.log(`Signing Permit2 approval for relay (current allowance: ${currentAllowance})`);
828
+ const chainId2 = this.getChainId(accept.network);
829
+ const gasPrice = await this.readGasPrice(url);
830
+ const nonce2 = await this.readNonce(url, wallet.address);
831
+ const signedTx = await wallet.signTransaction({
832
+ to: asset,
833
+ data: approveData,
834
+ chainId: chainId2,
835
+ gas: 50000n,
836
+ // standard ERC-20 approve
837
+ gasPrice,
838
+ nonce: nonce2
839
+ });
840
+ approvalExtension = {
841
+ erc20ApprovalGasSponsoring: {
842
+ info: {
843
+ from: wallet.address,
844
+ asset,
845
+ spender: PERMIT2_ADDRESS,
846
+ amount: MAX_UINT256.toString(),
847
+ signedTransaction: signedTx,
848
+ version: "1"
849
+ }
850
+ }
851
+ };
852
+ this.log("Permit2 approval signed for facilitator relay");
853
+ } else if (wallet.sendTransaction) {
854
+ this.log(`Approving Permit2 directly (current allowance: ${currentAllowance})`);
855
+ const approveTxHash = await wallet.sendTransaction({
856
+ to: asset,
857
+ data: approveData,
858
+ value: 0n
859
+ });
860
+ this.log(`Permit2 approval tx sent: ${approveTxHash}`);
861
+ await this.waitForReceipt(url, approveTxHash);
862
+ this.log("Permit2 approval confirmed");
863
+ } else {
825
864
  throw new Error(
826
- "Permit2 payments require a wallet that supports sendTransaction for the one-time Permit2 approval. Use createEvmKeypairWallet() or a browser wallet with transaction support."
865
+ "Permit2 payments require a wallet that supports signTransaction or sendTransaction for the one-time Permit2 approval. Use createEvmKeypairWallet() or a browser wallet with transaction support."
827
866
  );
828
867
  }
829
- this.log(`Approving Permit2 for ${asset} (current allowance: ${currentAllowance})`);
830
- const approveTxHash = await wallet.sendTransaction({
831
- to: asset,
832
- data: this.encodeApprove(PERMIT2_ADDRESS, MAX_UINT256),
833
- value: 0n
834
- });
835
- this.log(`Permit2 approval tx sent: ${approveTxHash}`);
836
- await this.waitForReceipt(url, approveTxHash);
837
- this.log("Permit2 approval confirmed");
838
868
  } else {
839
869
  this.log("Sufficient Permit2 allowance, skipping approval");
840
870
  }
@@ -889,7 +919,8 @@ var EvmAdapter = class {
889
919
  };
890
920
  return {
891
921
  serialized: JSON.stringify(payload),
892
- signature
922
+ signature,
923
+ extensions: approvalExtension
893
924
  };
894
925
  }
895
926
  /**
@@ -958,6 +989,43 @@ var EvmAdapter = class {
958
989
  }
959
990
  throw new Error(`Approval transaction receipt timeout after ${timeoutMs}ms: ${txHash}`);
960
991
  }
992
+ /**
993
+ * Read gas price via eth_gasPrice RPC call.
994
+ */
995
+ async readGasPrice(rpcUrl) {
996
+ try {
997
+ const response = await fetch(rpcUrl, {
998
+ method: "POST",
999
+ headers: { "Content-Type": "application/json" },
1000
+ body: JSON.stringify({ jsonrpc: "2.0", id: 1, method: "eth_gasPrice", params: [] })
1001
+ });
1002
+ const result = await response.json();
1003
+ return result.result ? BigInt(result.result) : 50000000n;
1004
+ } catch {
1005
+ return 50000000n;
1006
+ }
1007
+ }
1008
+ /**
1009
+ * Read transaction count (nonce) via eth_getTransactionCount RPC call.
1010
+ */
1011
+ async readNonce(rpcUrl, address) {
1012
+ try {
1013
+ const response = await fetch(rpcUrl, {
1014
+ method: "POST",
1015
+ headers: { "Content-Type": "application/json" },
1016
+ body: JSON.stringify({
1017
+ jsonrpc: "2.0",
1018
+ id: 1,
1019
+ method: "eth_getTransactionCount",
1020
+ params: [address, "latest"]
1021
+ })
1022
+ });
1023
+ const result = await response.json();
1024
+ return result.result ? parseInt(result.result, 16) : 0;
1025
+ } catch {
1026
+ return 0;
1027
+ }
1028
+ }
961
1029
  /**
962
1030
  * Calculate how much to approve based on the facilitator's approval strategy.
963
1031
  * Buffered approvals reduce the number of on-chain approval txs for micropayments.
@@ -1219,6 +1287,9 @@ function createX402Client(config) {
1219
1287
  accepted: accept,
1220
1288
  payload
1221
1289
  };
1290
+ if (signedTx.extensions) {
1291
+ paymentSignature.extensions = signedTx.extensions;
1292
+ }
1222
1293
  const paymentSignatureHeader = btoa(JSON.stringify(paymentSignature));
1223
1294
  const passResponse = await customFetch(passUrl, {
1224
1295
  ...init,
@@ -1397,6 +1468,9 @@ function createX402Client(config) {
1397
1468
  accepted: accept,
1398
1469
  payload
1399
1470
  };
1471
+ if (signedTx.extensions) {
1472
+ paymentSignature.extensions = signedTx.extensions;
1473
+ }
1400
1474
  const paymentSignatureHeader = btoa(JSON.stringify(paymentSignature));
1401
1475
  log("Retrying request with payment...");
1402
1476
  const retryResponse = await fetchWithRetry(input, {
@@ -1525,7 +1599,16 @@ async function createEvmKeypairWallet(privateKey) {
1525
1599
  const account = privateKeyToAccount(normalizedKey);
1526
1600
  return {
1527
1601
  address: account.address,
1528
- signTypedData: (params) => account.signTypedData(params)
1602
+ signTypedData: (params) => account.signTypedData(params),
1603
+ signTransaction: (params) => account.signTransaction({
1604
+ to: params.to,
1605
+ data: params.data,
1606
+ chainId: params.chainId,
1607
+ gas: params.gas,
1608
+ gasPrice: params.gasPrice,
1609
+ nonce: params.nonce,
1610
+ type: "legacy"
1611
+ })
1529
1612
  };
1530
1613
  }
1531
1614
  function isEvmKeypairWallet(wallet) {
@@ -1592,56 +1675,7 @@ function wrapFetch(fetchImpl, options) {
1592
1675
  }
1593
1676
 
1594
1677
  // src/client/discovery.ts
1595
- var DEFAULT_MARKETPLACE = "https://x402.dexter.cash/api/facilitator/marketplace/resources";
1596
- async function searchAPIs(options = {}) {
1597
- const {
1598
- query,
1599
- category,
1600
- network,
1601
- maxPrice,
1602
- verifiedOnly,
1603
- sort = "marketplace",
1604
- limit = 20,
1605
- marketplaceUrl = DEFAULT_MARKETPLACE
1606
- } = options;
1607
- const params = new URLSearchParams();
1608
- if (query) params.set("search", query);
1609
- if (category) params.set("category", category);
1610
- if (network) params.set("network", network);
1611
- if (maxPrice !== void 0) params.set("maxPrice", String(maxPrice));
1612
- if (verifiedOnly) params.set("verified", "true");
1613
- params.set("sort", sort);
1614
- params.set("order", "desc");
1615
- params.set("limit", String(Math.min(limit, 50)));
1616
- const url = `${marketplaceUrl}?${params.toString()}`;
1617
- const response = await fetch(url, {
1618
- headers: { "Accept": "application/json" },
1619
- signal: AbortSignal.timeout(15e3)
1620
- });
1621
- if (!response.ok) {
1622
- throw new Error(`Marketplace search failed: ${response.status}`);
1623
- }
1624
- const data = await response.json();
1625
- if (!data.resources) return [];
1626
- return data.resources.map((r) => ({
1627
- name: r.displayName || r.resourceUrl,
1628
- url: r.resourceUrl,
1629
- method: r.method || "GET",
1630
- price: r.priceLabel || (r.priceUsdc ? `$${r.priceUsdc.toFixed(4)}` : "free"),
1631
- priceUsdc: r.priceUsdc ?? null,
1632
- network: r.priceNetwork ?? null,
1633
- description: r.description || "",
1634
- category: r.category || "uncategorized",
1635
- qualityScore: r.qualityScore ?? null,
1636
- verified: r.verificationStatus === "pass",
1637
- totalCalls: r.totalSettlements || 0,
1638
- totalVolume: r.totalVolumeUsdc ? `$${r.totalVolumeUsdc.toLocaleString("en-US", { minimumFractionDigits: 2 })}` : null,
1639
- seller: r.seller?.displayName ?? null,
1640
- sellerReputation: r.reputationScore ?? null,
1641
- authRequired: r.authRequired || false,
1642
- lastActive: r.lastSettlementAt ?? null
1643
- }));
1644
- }
1678
+ var import_x402_core = require("@dexterai/x402-core");
1645
1679
 
1646
1680
  // src/client/budget-account.ts
1647
1681
  function createBudgetAccount(config) {
@@ -1778,6 +1812,7 @@ async function fireImpressionBeacon(response) {
1778
1812
  SOLANA_MAINNET,
1779
1813
  USDC_MINT,
1780
1814
  X402Error,
1815
+ capabilitySearch,
1781
1816
  createBudgetAccount,
1782
1817
  createEvmAdapter,
1783
1818
  createEvmKeypairWallet,
@@ -1790,6 +1825,5 @@ async function fireImpressionBeacon(response) {
1790
1825
  getSponsoredRecommendations,
1791
1826
  isEvmKeypairWallet,
1792
1827
  isKeypairWallet,
1793
- searchAPIs,
1794
1828
  wrapFetch
1795
1829
  });
@@ -1,9 +1,10 @@
1
- export { P as PaymentReceipt, a as X402Client, X as X402ClientConfig, c as createX402Client, f as fireImpressionBeacon, g as getPaymentReceipt, d as getSponsoredAccessInfo, b as getSponsoredRecommendations } from '../sponsored-access-DAVzu4x6.cjs';
1
+ export { P as PaymentReceipt, a as X402Client, X as X402ClientConfig, c as createX402Client, f as fireImpressionBeacon, g as getPaymentReceipt, d as getSponsoredAccessInfo, b as getSponsoredRecommendations } from '../sponsored-access-CE7WpV5b.cjs';
2
2
  import { A as AccessPassClientConfig, P as PaymentAccept } from '../types-_iT11DL0.cjs';
3
3
  export { b as AccessPassInfo, a as AccessPassTier, D as DEXTER_FACILITATOR_URL, U as USDC_MINT, X as X402Error } from '../types-_iT11DL0.cjs';
4
4
  import { Keypair } from '@solana/web3.js';
5
- import { S as SolanaWallet, E as EvmWallet } from '../types-D1u7iu8n.cjs';
6
- export { B as BASE_MAINNET, C as ChainAdapter, b as SOLANA_MAINNET, W as WalletSet, a as createEvmAdapter, c as createSolanaAdapter } from '../types-D1u7iu8n.cjs';
5
+ import { S as SolanaWallet, E as EvmWallet } from '../types-C_aQh02s.cjs';
6
+ export { B as BASE_MAINNET, C as ChainAdapter, b as SOLANA_MAINNET, W as WalletSet, a as createEvmAdapter, c as createSolanaAdapter } from '../types-C_aQh02s.cjs';
7
+ export { FormattedResource as CapabilityAPI, CapabilitySearchOptions, CapabilitySearchResult, NoMatchReason, capabilitySearch } from '@dexterai/x402-core';
7
8
  export { SponsoredAccessSettlementInfo, SponsoredRecommendation } from '@dexterai/x402-ads-types';
8
9
 
9
10
  /**
@@ -237,107 +238,6 @@ declare function createEvmKeypairWallet(privateKey: string): Promise<EvmWallet>;
237
238
  */
238
239
  declare function isEvmKeypairWallet(wallet: unknown): wallet is EvmWallet;
239
240
 
240
- /**
241
- * API Discovery — Find x402 Paid APIs
242
- *
243
- * Search the Dexter marketplace for x402-enabled APIs. Discover endpoints
244
- * by category, price range, network, and quality score — then pay for them
245
- * with the same SDK.
246
- *
247
- * @example
248
- * ```typescript
249
- * import { searchAPIs } from '@dexterai/x402/client';
250
- *
251
- * const results = await searchAPIs({ query: 'sentiment analysis', maxPrice: 0.10 });
252
- * for (const api of results) {
253
- * console.log(`${api.name}: ${api.price} — ${api.description}`);
254
- * }
255
- *
256
- * // Then call one with wrapFetch:
257
- * const response = await x402Fetch(results[0].url);
258
- * ```
259
- */
260
- /**
261
- * Search options for discovering x402 APIs
262
- */
263
- interface SearchAPIsOptions {
264
- /** Search query (e.g., 'sentiment analysis', 'token price', 'image generation') */
265
- query?: string;
266
- /** Filter by category (e.g., 'defi', 'ai', 'data', 'social') */
267
- category?: string;
268
- /** Filter by payment network (e.g., 'solana', 'base', 'polygon') */
269
- network?: string;
270
- /** Maximum price per call in USDC */
271
- maxPrice?: number;
272
- /** Only return verified endpoints (quality score 75+) */
273
- verifiedOnly?: boolean;
274
- /** Sort order */
275
- sort?: 'marketplace' | 'relevance' | 'quality_score' | 'settlements' | 'volume' | 'recent';
276
- /** Maximum results to return (default 20, max 50) */
277
- limit?: number;
278
- /** Marketplace API URL (default: Dexter marketplace) */
279
- marketplaceUrl?: string;
280
- }
281
- /**
282
- * A discovered x402 API endpoint
283
- */
284
- interface DiscoveredAPI {
285
- /** API name */
286
- name: string;
287
- /** Full resource URL — pass directly to wrapFetch or createX402Client.fetch */
288
- url: string;
289
- /** HTTP method */
290
- method: string;
291
- /** Price per call (formatted, e.g., '$0.05') */
292
- price: string;
293
- /** Price per call in USDC (raw number, null if free) */
294
- priceUsdc: number | null;
295
- /** Payment network */
296
- network: string | null;
297
- /** Human-readable description */
298
- description: string;
299
- /** Category (e.g., 'defi', 'ai', 'data') */
300
- category: string;
301
- /** Quality score (0-100, null if unscored) */
302
- qualityScore: number | null;
303
- /** Whether the endpoint has been verified */
304
- verified: boolean;
305
- /** Total number of settlements (calls) */
306
- totalCalls: number;
307
- /** Total volume in USDC (formatted, e.g., '$1,234.56') */
308
- totalVolume: string | null;
309
- /** Seller name */
310
- seller: string | null;
311
- /** Seller reputation score */
312
- sellerReputation: number | null;
313
- /** Whether authentication is required beyond payment */
314
- authRequired: boolean;
315
- /** Last time someone called this API */
316
- lastActive: string | null;
317
- }
318
- /**
319
- * Search the Dexter marketplace for x402 paid APIs.
320
- *
321
- * Returns a list of discovered endpoints that can be called directly
322
- * with `wrapFetch` or `createX402Client.fetch`.
323
- *
324
- * @example Find AI APIs under $0.10
325
- * ```typescript
326
- * const apis = await searchAPIs({ query: 'ai', maxPrice: 0.10 });
327
- * ```
328
- *
329
- * @example Browse all verified DeFi tools
330
- * ```typescript
331
- * const apis = await searchAPIs({ category: 'defi', verifiedOnly: true });
332
- * ```
333
- *
334
- * @example Find cheapest APIs on Solana
335
- * ```typescript
336
- * const apis = await searchAPIs({ network: 'solana', sort: 'quality_score' });
337
- * ```
338
- */
339
- declare function searchAPIs(options?: SearchAPIsOptions): Promise<DiscoveredAPI[]>;
340
-
341
241
  /**
342
242
  * Budget Account — Autonomous Agent Spending Controls
343
243
  *
@@ -423,4 +323,4 @@ interface BudgetAccount {
423
323
  */
424
324
  declare function createBudgetAccount(config: BudgetAccountConfig): BudgetAccount;
425
325
 
426
- export { AccessPassClientConfig, type BudgetAccount, type BudgetAccountConfig, type BudgetConfig, type DiscoveredAPI, KEYPAIR_SYMBOL, type KeypairWallet, type PaymentRecord, type SearchAPIsOptions, type WrapFetchOptions, createBudgetAccount, createEvmKeypairWallet, createKeypairWallet, isEvmKeypairWallet, isKeypairWallet, searchAPIs, wrapFetch };
326
+ export { AccessPassClientConfig, type BudgetAccount, type BudgetAccountConfig, type BudgetConfig, KEYPAIR_SYMBOL, type KeypairWallet, type PaymentRecord, type WrapFetchOptions, createBudgetAccount, createEvmKeypairWallet, createKeypairWallet, isEvmKeypairWallet, isKeypairWallet, wrapFetch };