@relai-fi/x402 0.6.11-rc.0 → 0.6.11-rc.2

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.cjs CHANGED
@@ -4548,6 +4548,15 @@ function buildClaimUrl(facilitatorUrl, claimToken) {
4548
4548
  const origin = new URL(facilitatorUrl).origin;
4549
4549
  return new URL(`/claim/${claimToken}`, origin).toString();
4550
4550
  }
4551
+ function resolveSolanaRelayerConfig(relayerInfo, network) {
4552
+ const networkInfo = relayerInfo?.networks?.[network] ?? null;
4553
+ const relayerAddr = typeof networkInfo?.address === "string" && networkInfo.address.trim() ? networkInfo.address.trim() : "";
4554
+ const programId = typeof relayerInfo?.programId === "string" ? relayerInfo.programId.trim() : "";
4555
+ const usdcMint = typeof networkInfo?.usdc === "string" && networkInfo.usdc.trim() ? networkInfo.usdc.trim() : network === "solana-devnet" ? "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU" : "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
4556
+ if (!relayerAddr) throw new Error(`Missing per-network relayer address for ${network} in relayer-info response`);
4557
+ if (!programId) throw new Error("Missing Solana payment-code programId");
4558
+ return { relayerAddr, programId, usdcMint };
4559
+ }
4551
4560
  async function anchorDisc(name) {
4552
4561
  const preimage = new TextEncoder().encode(`global:${name}`);
4553
4562
  if (typeof globalThis !== "undefined" && globalThis.crypto?.subtle) {
@@ -4589,9 +4598,7 @@ async function generateSolanaPaymentCode(config2, wallet, params) {
4589
4598
  if (!infoRes.ok) throw new Error("Failed to fetch Solana relayer info");
4590
4599
  const relayerInfo = await infoRes.json();
4591
4600
  const network = params.network ?? relayerInfo.defaultNetwork ?? "solana";
4592
- const relayerAddr = relayerInfo.address;
4593
- const programId = relayerInfo.programId;
4594
- const usdcMint = relayerInfo.networks?.[network]?.usdc ?? (network === "solana-devnet" ? "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU" : "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
4601
+ const { relayerAddr, programId, usdcMint } = resolveSolanaRelayerConfig(relayerInfo, network);
4595
4602
  const code = generateCode(network, claimLink);
4596
4603
  const codeBytes = new TextEncoder().encode(code);
4597
4604
  const {
@@ -4695,9 +4702,7 @@ async function generateSolanaPaymentCodesBatch(config2, wallet, params) {
4695
4702
  if (!infoRes.ok) throw new Error("Failed to fetch Solana relayer info");
4696
4703
  const relayerInfo = await infoRes.json();
4697
4704
  const network = params.network ?? relayerInfo.defaultNetwork ?? "solana";
4698
- const relayerAddr = relayerInfo.address;
4699
- const programId = relayerInfo.programId;
4700
- const usdcMint = relayerInfo.networks?.[network]?.usdc ?? (network === "solana-devnet" ? "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU" : "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
4705
+ const { relayerAddr, programId, usdcMint } = resolveSolanaRelayerConfig(relayerInfo, network);
4701
4706
  const {
4702
4707
  Connection: Connection2,
4703
4708
  PublicKey: PublicKey2,
@@ -4829,9 +4834,7 @@ async function cancelSolanaPaymentCode(config2, code, wallet, options = {}) {
4829
4834
  if (!infoRes.ok) throw new Error("Failed to fetch Solana relayer info");
4830
4835
  const relayerInfo = await infoRes.json();
4831
4836
  const network = options.network ?? relayerInfo.defaultNetwork ?? "solana";
4832
- const relayerAddr = relayerInfo.address;
4833
- const programId = relayerInfo.programId;
4834
- const usdcMint = relayerInfo.networks?.[network]?.usdc ?? (network === "solana-devnet" ? "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU" : "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
4837
+ const { relayerAddr, programId, usdcMint } = resolveSolanaRelayerConfig(relayerInfo, network);
4835
4838
  const {
4836
4839
  Connection: Connection2,
4837
4840
  PublicKey: PublicKey2,