@relai-fi/x402 0.6.11-rc.2 → 0.6.11-rc.4
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 +20 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +20 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -4931,7 +4931,7 @@ var NETWORK_CONFIGS = {
|
|
|
4931
4931
|
settlementNetwork: "skale-base-sepolia"
|
|
4932
4932
|
},
|
|
4933
4933
|
"skale-base": {
|
|
4934
|
-
chainId:
|
|
4934
|
+
chainId: 1187947933,
|
|
4935
4935
|
usdc: "0x85889c8c714505E0c94b30fcfcF64fE3Ac8FCb20",
|
|
4936
4936
|
domainName: "Bridged USDC",
|
|
4937
4937
|
rpc: "https://skale-base.skalenodes.com/v1/base",
|
|
@@ -5516,12 +5516,22 @@ function buildRequestError(response, payload) {
|
|
|
5516
5516
|
function isNotFoundResponse(response, payload) {
|
|
5517
5517
|
return response.status === 404 || payload.errorCode === "not_found";
|
|
5518
5518
|
}
|
|
5519
|
+
function inferStoredPaymentCodeKind(normalizedCode) {
|
|
5520
|
+
if (normalizedCode.length === 8 && (normalizedCode.startsWith("D") || normalizedCode.startsWith("S"))) {
|
|
5521
|
+
return "solana";
|
|
5522
|
+
}
|
|
5523
|
+
return null;
|
|
5524
|
+
}
|
|
5519
5525
|
async function fetchStoredCodeWithFallback(facilitatorUrl, normalizedCode, options = {}) {
|
|
5520
5526
|
const suffix = options.suffix ? `/${options.suffix.replace(/^\/+/, "")}` : "";
|
|
5527
|
+
const inferredKind = options.preferredKind ?? inferStoredPaymentCodeKind(normalizedCode);
|
|
5521
5528
|
const attempts = [
|
|
5522
5529
|
{ kind: "evm", url: `${facilitatorUrl}/payment-codes/${normalizedCode}${suffix}` },
|
|
5523
5530
|
{ kind: "solana", url: `${facilitatorUrl}/solana-payment-codes/${normalizedCode}${suffix}` }
|
|
5524
5531
|
];
|
|
5532
|
+
if (inferredKind) {
|
|
5533
|
+
attempts.sort((left, right) => Number(right.kind === inferredKind) - Number(left.kind === inferredKind));
|
|
5534
|
+
}
|
|
5525
5535
|
let lastError = null;
|
|
5526
5536
|
for (const attempt of attempts) {
|
|
5527
5537
|
const { response, payload } = await fetchWithPayload(attempt.url, options.init);
|
|
@@ -5561,6 +5571,7 @@ async function createPaymentCode(config2, params) {
|
|
|
5561
5571
|
return generateSolanaPaymentCode(config2, params.wallet, {
|
|
5562
5572
|
amount: amount3,
|
|
5563
5573
|
network: params.network,
|
|
5574
|
+
solanaRpcUrl: params.solanaRpcUrl,
|
|
5564
5575
|
claimLink: params.claimLink === true,
|
|
5565
5576
|
description: params.description,
|
|
5566
5577
|
ttlSeconds
|
|
@@ -5628,6 +5639,7 @@ async function createPaymentCodesBatch(config2, params) {
|
|
|
5628
5639
|
}));
|
|
5629
5640
|
return generateSolanaPaymentCodesBatch(config2, params.wallet, {
|
|
5630
5641
|
network: params.network,
|
|
5642
|
+
solanaRpcUrl: params.solanaRpcUrl,
|
|
5631
5643
|
items
|
|
5632
5644
|
});
|
|
5633
5645
|
}
|
|
@@ -5742,6 +5754,7 @@ async function redeemStoredPaymentCode(config2, code, params) {
|
|
|
5742
5754
|
const normalizedCode = code.trim().toUpperCase();
|
|
5743
5755
|
const { payload } = await fetchStoredCodeWithFallback(facilitatorUrl, normalizedCode, {
|
|
5744
5756
|
suffix: "redeem",
|
|
5757
|
+
preferredKind: params.solanaNetwork ? "solana" : params.evmNetwork ? "evm" : void 0,
|
|
5745
5758
|
init: {
|
|
5746
5759
|
method: "POST",
|
|
5747
5760
|
headers: { "Content-Type": "application/json" },
|
|
@@ -5757,7 +5770,9 @@ async function redeemStoredPaymentCode(config2, code, params) {
|
|
|
5757
5770
|
async function cancelStoredPaymentCode(config2, code, params = {}) {
|
|
5758
5771
|
const facilitatorUrl = config2.facilitatorUrl ?? DEFAULT_FACILITATOR4;
|
|
5759
5772
|
const normalizedCode = code.trim().toUpperCase();
|
|
5760
|
-
const statusInfo = await fetchStoredCodeWithFallback(facilitatorUrl, normalizedCode
|
|
5773
|
+
const statusInfo = await fetchStoredCodeWithFallback(facilitatorUrl, normalizedCode, {
|
|
5774
|
+
preferredKind: params.network === "solana" || params.network === "solana-devnet" ? "solana" : params.network ? "evm" : void 0
|
|
5775
|
+
});
|
|
5761
5776
|
if (statusInfo.kind === "solana") {
|
|
5762
5777
|
if (!params.solanaWallet) {
|
|
5763
5778
|
throw new Error("A Solana wallet is required to cancel this payment code");
|
|
@@ -5887,7 +5902,9 @@ async function payPayRequestWithStoredCode(config2, request, paymentCode, option
|
|
|
5887
5902
|
const normalizedPaymentCode = paymentCode.trim().toUpperCase();
|
|
5888
5903
|
const requestInfo = isPaymentRequestObject(request) ? request : await getPayRequest(config2, request.trim().toUpperCase());
|
|
5889
5904
|
const normalizedRequestCode = isPaymentRequestObject(request) ? requestInfo.code.trim().toUpperCase() : request.trim().toUpperCase();
|
|
5890
|
-
const codeStatusInfo = await fetchStoredCodeWithFallback(facilitatorUrl, normalizedPaymentCode
|
|
5905
|
+
const codeStatusInfo = await fetchStoredCodeWithFallback(facilitatorUrl, normalizedPaymentCode, {
|
|
5906
|
+
preferredKind: inferStoredPaymentCodeKind(normalizedPaymentCode) ?? void 0
|
|
5907
|
+
});
|
|
5891
5908
|
if (codeStatusInfo.kind === "solana") {
|
|
5892
5909
|
if (!normalizedRequestCode) {
|
|
5893
5910
|
throw new Error("A payment request object with a valid code is required when paying a request with a stored Solana code");
|