@piprail/sdk 2.14.2 → 2.15.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.
- package/CHANGELOG.md +98 -0
- package/README.md +3 -1
- package/dist/{algorand-CSEUTWNW.js → algorand-UF7BLBFN.js} +1 -1
- package/dist/{algorand-I2O24RSM.cjs → algorand-XGSWDMCZ.cjs} +32 -32
- package/dist/{aptos-GA5AEYYL.cjs → aptos-J2QSWHTO.cjs} +31 -31
- package/dist/{aptos-J7QGCWNW.js → aptos-KDLX42CR.js} +1 -1
- package/dist/{chunk-3FR22M3O.cjs → chunk-QONQSZHJ.cjs} +2 -2
- package/dist/{chunk-3ZWM3DKM.js → chunk-QU25LSVS.js} +2 -2
- package/dist/index.cjs +282 -181
- package/dist/index.d.cts +140 -1
- package/dist/index.d.ts +140 -1
- package/dist/index.js +151 -50
- package/dist/{near-NDQLGI4U.cjs → near-5LTTDU6G.cjs} +27 -27
- package/dist/{near-YA4Y4IGC.js → near-OLKCMTBI.js} +1 -1
- package/dist/{solana-OU6IUMQM.cjs → solana-S2T3JNR7.cjs} +32 -32
- package/dist/{solana-MB6G3OA5.js → solana-WO2G7WWZ.js} +1 -1
- package/dist/{stellar-RSNVOIKL.cjs → stellar-E2KWEV2E.cjs} +20 -20
- package/dist/{stellar-WDWSYOED.js → stellar-EUFZLX6J.js} +1 -1
- package/dist/{sui-GVSFNNJX.js → sui-KCIITCYH.js} +6 -2
- package/dist/{sui-MVC46BFJ.cjs → sui-Q3NJOJZS.cjs} +21 -17
- package/dist/{ton-MYOI3U3H.cjs → ton-J7TQWRN4.cjs} +16 -16
- package/dist/{ton-EJMGM3YI.js → ton-WH2JVQOO.js} +1 -1
- package/dist/{tron-VAPVMGJK.js → tron-FXBXDNEY.js} +1 -1
- package/dist/{tron-42X5N4GQ.cjs → tron-HIPMOX7S.cjs} +25 -25
- package/dist/{xrpl-Q2UWPCTJ.js → xrpl-6B2XOXGC.js} +1 -1
- package/dist/{xrpl-MGUBUNSZ.cjs → xrpl-VOUXIUYD.cjs} +20 -20
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -32,7 +32,7 @@ var _chunkCQQI5IJXcjs = require('./chunk-CQQI5IJX.cjs');
|
|
|
32
32
|
|
|
33
33
|
|
|
34
34
|
|
|
35
|
-
var
|
|
35
|
+
var _chunkQONQSZHJcjs = require('./chunk-QONQSZHJ.cjs');
|
|
36
36
|
|
|
37
37
|
// src/drivers/registry.ts
|
|
38
38
|
var byFamily = /* @__PURE__ */ new Map();
|
|
@@ -61,13 +61,13 @@ function resolveNetwork(opts) {
|
|
|
61
61
|
const family = familyForChain(opts.chain);
|
|
62
62
|
const driver = byFamily.get(family);
|
|
63
63
|
if (!driver) {
|
|
64
|
-
throw new (0,
|
|
64
|
+
throw new (0, _chunkQONQSZHJcjs.UnsupportedNetworkError)(
|
|
65
65
|
`No driver registered for the "${family}" family \u2014 it may not be mounted yet (use the async resolveNetwork()).`
|
|
66
66
|
);
|
|
67
67
|
}
|
|
68
68
|
const net = driver.resolve(opts);
|
|
69
69
|
if (!net) {
|
|
70
|
-
throw new (0,
|
|
70
|
+
throw new (0, _chunkQONQSZHJcjs.UnsupportedNetworkError)(
|
|
71
71
|
`The ${family} driver didn't recognise this chain input.`
|
|
72
72
|
);
|
|
73
73
|
}
|
|
@@ -332,12 +332,12 @@ function resolveChain(input, rpcUrlOverride) {
|
|
|
332
332
|
|
|
333
333
|
var _accounts = require('viem/accounts');
|
|
334
334
|
function createWalletAdapter(config, resolved) {
|
|
335
|
-
|
|
335
|
+
_chunkQONQSZHJcjs.assertNoLegacyWalletKey.call(void 0, config, "EVM");
|
|
336
336
|
if ("key" in config) {
|
|
337
337
|
const key = config.key;
|
|
338
338
|
if (typeof key !== "string" || !/^0x[0-9a-fA-F]{64}$/.test(key)) {
|
|
339
339
|
const hint = typeof key === "string" && !key.startsWith("0x") ? " (got a non-0x string \u2014 a base58/seed key belongs to another family; pass { key } as the EVM chain's 0x\u2026 hex secret)." : " (expected 0x followed by 64 hex characters).";
|
|
340
|
-
throw new (0,
|
|
340
|
+
throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)(
|
|
341
341
|
`chain is EVM; the wallet { key } is not a valid 0x\u2026 32-byte hex private key${hint}`
|
|
342
342
|
);
|
|
343
343
|
}
|
|
@@ -345,7 +345,7 @@ function createWalletAdapter(config, resolved) {
|
|
|
345
345
|
try {
|
|
346
346
|
account = _accounts.privateKeyToAccount.call(void 0, key);
|
|
347
347
|
} catch (err) {
|
|
348
|
-
throw new (0,
|
|
348
|
+
throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)(
|
|
349
349
|
`chain is EVM; the wallet { key } is not a valid 0x\u2026 32-byte hex private key: ${err instanceof Error ? err.message : String(err)}.`
|
|
350
350
|
);
|
|
351
351
|
}
|
|
@@ -355,12 +355,12 @@ function createWalletAdapter(config, resolved) {
|
|
|
355
355
|
}
|
|
356
356
|
const wc = config.walletClient;
|
|
357
357
|
if (!wc.account) {
|
|
358
|
-
throw new (0,
|
|
358
|
+
throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)(
|
|
359
359
|
"chain is EVM; the provided walletClient has no attached account. Use `createWalletClient({ account, chain, transport })`, or pass { key }."
|
|
360
360
|
);
|
|
361
361
|
}
|
|
362
362
|
if (wc.chain && wc.chain.id !== resolved.chainId) {
|
|
363
|
-
throw new (0,
|
|
363
|
+
throw new (0, _chunkQONQSZHJcjs.WrongChainError)(
|
|
364
364
|
`PipRailClient: walletClient is on chain ${wc.chain.id} but the SDK was configured with chain ${resolved.chainId}. They must match.`
|
|
365
365
|
);
|
|
366
366
|
}
|
|
@@ -690,7 +690,7 @@ async function payExactEvm(input) {
|
|
|
690
690
|
code = void 0;
|
|
691
691
|
}
|
|
692
692
|
if (code && code !== "0x") {
|
|
693
|
-
throw new (0,
|
|
693
|
+
throw new (0, _chunkQONQSZHJcjs.UnsupportedSchemeError)(
|
|
694
694
|
`exact buyer rail requires an EOA signer; ${account.address} is a contract / EIP-1271 / EIP-7702-delegated account (no recoverable ECDSA signature). Pay via onchain-proof.`
|
|
695
695
|
);
|
|
696
696
|
}
|
|
@@ -700,13 +700,13 @@ async function payExactEvm(input) {
|
|
|
700
700
|
domain = await readExactDomain(publicClient, accept.asset);
|
|
701
701
|
}
|
|
702
702
|
if (!domain) {
|
|
703
|
-
throw new (0,
|
|
703
|
+
throw new (0, _chunkQONQSZHJcjs.UnsupportedSchemeError)(
|
|
704
704
|
`exact: couldn't derive the EIP-712 domain for ${accept.asset} on ${accept.network}. Either it isn't an EIP-3009 token (USDT needs Permit2; native/plain ERC-20 aren't exact-payable) \u2014 pay via onchain-proof \u2014 OR your RPC couldn't read it (transient): if the gate advertised eip3009, pass a reliable rpcUrl and retry.`
|
|
705
705
|
);
|
|
706
706
|
}
|
|
707
707
|
const g = globalThis.crypto;
|
|
708
708
|
if (!_optionalChain([g, 'optionalAccess', _5 => _5.getRandomValues])) {
|
|
709
|
-
throw new (0,
|
|
709
|
+
throw new (0, _chunkQONQSZHJcjs.UnsupportedSchemeError)(
|
|
710
710
|
"this runtime lacks Web Crypto (globalThis.crypto.getRandomValues); the exact rail needs a CSPRNG nonce."
|
|
711
711
|
);
|
|
712
712
|
}
|
|
@@ -963,7 +963,7 @@ async function verifyAndSettleExactEvm(input) {
|
|
|
963
963
|
args: writeArgs
|
|
964
964
|
});
|
|
965
965
|
} catch (err) {
|
|
966
|
-
throw new (0,
|
|
966
|
+
throw new (0, _chunkQONQSZHJcjs.SettlementError)(
|
|
967
967
|
`exact settle: the merchant relayer failed to broadcast transferWithAuthorization (${shorten(err instanceof Error ? err.message : String(err))}). The payer's authorization is still valid and unused \u2014 fund/fix the relayer and the payer can retry.`,
|
|
968
968
|
{ cause: err }
|
|
969
969
|
);
|
|
@@ -975,7 +975,7 @@ async function verifyAndSettleExactEvm(input) {
|
|
|
975
975
|
return { ok: false, error: "tx_reverted", detail: `Settlement tx ${txHash} reverted on-chain.` };
|
|
976
976
|
}
|
|
977
977
|
} catch (err) {
|
|
978
|
-
throw new (0,
|
|
978
|
+
throw new (0, _chunkQONQSZHJcjs.SettlementError)(
|
|
979
979
|
`exact settle: broadcast ${txHash} but couldn't confirm it (${shorten(err instanceof Error ? err.message : String(err))}).`,
|
|
980
980
|
{ cause: err }
|
|
981
981
|
);
|
|
@@ -1106,7 +1106,7 @@ function shorten2(msg) {
|
|
|
1106
1106
|
function randomPermit2Nonce() {
|
|
1107
1107
|
const g = globalThis.crypto;
|
|
1108
1108
|
if (!_optionalChain([g, 'optionalAccess', _8 => _8.getRandomValues])) {
|
|
1109
|
-
throw new (0,
|
|
1109
|
+
throw new (0, _chunkQONQSZHJcjs.UnsupportedSchemeError)(
|
|
1110
1110
|
"this runtime lacks Web Crypto (globalThis.crypto.getRandomValues); the permit2 rail needs a CSPRNG nonce."
|
|
1111
1111
|
);
|
|
1112
1112
|
}
|
|
@@ -1125,7 +1125,7 @@ async function ensurePermit2Allowance(input) {
|
|
|
1125
1125
|
args: [account.address, PERMIT2_ADDRESS]
|
|
1126
1126
|
});
|
|
1127
1127
|
} catch (err) {
|
|
1128
|
-
throw new (0,
|
|
1128
|
+
throw new (0, _chunkQONQSZHJcjs.UnsupportedSchemeError)(
|
|
1129
1129
|
`permit2: couldn't read the Permit2 allowance for ${token} (${shorten2(err instanceof Error ? err.message : String(err))}).`
|
|
1130
1130
|
);
|
|
1131
1131
|
}
|
|
@@ -1142,7 +1142,7 @@ async function ensurePermit2Allowance(input) {
|
|
|
1142
1142
|
await publicClient.waitForTransactionReceipt({ hash, confirmations: 1 });
|
|
1143
1143
|
return hash;
|
|
1144
1144
|
} catch (err) {
|
|
1145
|
-
throw _nullishCoalesce(
|
|
1145
|
+
throw _nullishCoalesce(_chunkQONQSZHJcjs.toInsufficientFundsError.call(void 0, err), () => ( new (0, _chunkQONQSZHJcjs.SettlementError)(
|
|
1146
1146
|
`permit2: the one-time Permit2 approval for ${token} failed to broadcast (${shorten2(err instanceof Error ? err.message : String(err))}).`,
|
|
1147
1147
|
{ cause: err }
|
|
1148
1148
|
)));
|
|
@@ -1157,7 +1157,7 @@ async function payPermit2Evm(input) {
|
|
|
1157
1157
|
code = void 0;
|
|
1158
1158
|
}
|
|
1159
1159
|
if (code && code !== "0x") {
|
|
1160
|
-
throw new (0,
|
|
1160
|
+
throw new (0, _chunkQONQSZHJcjs.UnsupportedSchemeError)(
|
|
1161
1161
|
`permit2 buyer rail requires an EOA signer; ${account.address} is a contract / EIP-1271 / EIP-7702-delegated account. Pay via onchain-proof.`
|
|
1162
1162
|
);
|
|
1163
1163
|
}
|
|
@@ -1332,7 +1332,7 @@ async function verifyAndSettlePermit2Evm(input) {
|
|
|
1332
1332
|
args: settleArgs
|
|
1333
1333
|
});
|
|
1334
1334
|
} catch (err) {
|
|
1335
|
-
throw new (0,
|
|
1335
|
+
throw new (0, _chunkQONQSZHJcjs.SettlementError)(
|
|
1336
1336
|
`permit2 settle: the merchant relayer failed to broadcast the proxy settle (${shorten2(err instanceof Error ? err.message : String(err))}). The payer's signature is still valid and its nonce unused \u2014 fund/fix the relayer and the payer can retry.`,
|
|
1337
1337
|
{ cause: err }
|
|
1338
1338
|
);
|
|
@@ -1344,7 +1344,7 @@ async function verifyAndSettlePermit2Evm(input) {
|
|
|
1344
1344
|
return { ok: false, error: "tx_reverted", detail: `Settlement tx ${txHash} reverted on-chain.` };
|
|
1345
1345
|
}
|
|
1346
1346
|
} catch (err) {
|
|
1347
|
-
throw new (0,
|
|
1347
|
+
throw new (0, _chunkQONQSZHJcjs.SettlementError)(
|
|
1348
1348
|
`permit2 settle: broadcast ${txHash} but couldn't confirm it (${shorten2(err instanceof Error ? err.message : String(err))}).`,
|
|
1349
1349
|
{ cause: err }
|
|
1350
1350
|
);
|
|
@@ -1442,7 +1442,7 @@ function shorten3(msg) {
|
|
|
1442
1442
|
function randomPermit2Nonce2() {
|
|
1443
1443
|
const g = globalThis.crypto;
|
|
1444
1444
|
if (!_optionalChain([g, 'optionalAccess', _9 => _9.getRandomValues])) {
|
|
1445
|
-
throw new (0,
|
|
1445
|
+
throw new (0, _chunkQONQSZHJcjs.UnsupportedSchemeError)(
|
|
1446
1446
|
"this runtime lacks Web Crypto (globalThis.crypto.getRandomValues); the upto rail needs a CSPRNG nonce."
|
|
1447
1447
|
);
|
|
1448
1448
|
}
|
|
@@ -1459,13 +1459,13 @@ async function payUptoEvm(input) {
|
|
|
1459
1459
|
code = void 0;
|
|
1460
1460
|
}
|
|
1461
1461
|
if (code && code !== "0x") {
|
|
1462
|
-
throw new (0,
|
|
1462
|
+
throw new (0, _chunkQONQSZHJcjs.UnsupportedSchemeError)(
|
|
1463
1463
|
`upto buyer rail requires an EOA signer; ${account.address} is a contract / EIP-1271 / EIP-7702-delegated account. Pay via onchain-proof.`
|
|
1464
1464
|
);
|
|
1465
1465
|
}
|
|
1466
1466
|
const facilitatorAddress = _optionalChain([accept, 'access', _10 => _10.extra, 'optionalAccess', _11 => _11.facilitatorAddress]);
|
|
1467
1467
|
if (typeof facilitatorAddress !== "string" || facilitatorAddress.length === 0) {
|
|
1468
|
-
throw new (0,
|
|
1468
|
+
throw new (0, _chunkQONQSZHJcjs.UnsupportedSchemeError)(
|
|
1469
1469
|
`upto: the rail carries no extra.facilitatorAddress to bind into witness.facilitator \u2014 refusing to sign.`
|
|
1470
1470
|
);
|
|
1471
1471
|
}
|
|
@@ -1686,7 +1686,7 @@ async function verifyAndSettleUptoEvm(input) {
|
|
|
1686
1686
|
args: settleArgs
|
|
1687
1687
|
});
|
|
1688
1688
|
} catch (err) {
|
|
1689
|
-
throw new (0,
|
|
1689
|
+
throw new (0, _chunkQONQSZHJcjs.SettlementError)(
|
|
1690
1690
|
`upto settle: the merchant relayer failed to broadcast the proxy settle (${shorten3(err instanceof Error ? err.message : String(err))}). The payer's signature is still valid and its nonce unused \u2014 fund/fix the relayer and the payer can retry.`,
|
|
1691
1691
|
{ cause: err }
|
|
1692
1692
|
);
|
|
@@ -1698,7 +1698,7 @@ async function verifyAndSettleUptoEvm(input) {
|
|
|
1698
1698
|
return { ok: false, error: "tx_reverted", detail: `Settlement tx ${txHash} reverted on-chain.` };
|
|
1699
1699
|
}
|
|
1700
1700
|
} catch (err) {
|
|
1701
|
-
throw new (0,
|
|
1701
|
+
throw new (0, _chunkQONQSZHJcjs.SettlementError)(
|
|
1702
1702
|
`upto settle: broadcast ${txHash} but couldn't confirm it (${shorten3(err instanceof Error ? err.message : String(err))}).`,
|
|
1703
1703
|
{ cause: err }
|
|
1704
1704
|
);
|
|
@@ -1757,7 +1757,16 @@ function decodeBase64Json(value) {
|
|
|
1757
1757
|
return fromBase64Json(value);
|
|
1758
1758
|
}
|
|
1759
1759
|
function toBase64Json(value) {
|
|
1760
|
-
|
|
1760
|
+
let json;
|
|
1761
|
+
try {
|
|
1762
|
+
json = JSON.stringify(value);
|
|
1763
|
+
} catch (cause) {
|
|
1764
|
+
throw new (0, _chunkQONQSZHJcjs.InvalidConfigError)(
|
|
1765
|
+
`x402: this payload cannot be serialised to JSON (${cause.message}). Amounts must be decimal STRINGS, not BigInt \u2014 pass '50000', not 50000n.`,
|
|
1766
|
+
{ cause }
|
|
1767
|
+
);
|
|
1768
|
+
}
|
|
1769
|
+
return encodeBase64(json);
|
|
1761
1770
|
}
|
|
1762
1771
|
function networkForChain(chainId) {
|
|
1763
1772
|
return `eip155:${chainId}`;
|
|
@@ -2041,7 +2050,7 @@ var evmDriver = {
|
|
|
2041
2050
|
try {
|
|
2042
2051
|
return makeEvmNetwork(resolveChain(opts.chain, opts.rpcUrl));
|
|
2043
2052
|
} catch (err) {
|
|
2044
|
-
throw new (0,
|
|
2053
|
+
throw new (0, _chunkQONQSZHJcjs.UnsupportedNetworkError)(err instanceof Error ? err.message : String(err), { cause: err });
|
|
2045
2054
|
}
|
|
2046
2055
|
}
|
|
2047
2056
|
let resolved;
|
|
@@ -2075,20 +2084,20 @@ function makeEvmNetwork(resolved) {
|
|
|
2075
2084
|
const info = resolved.tokens[token.toUpperCase()];
|
|
2076
2085
|
if (!info) {
|
|
2077
2086
|
const known = Object.keys(resolved.tokens).join(", ") || "(none built in)";
|
|
2078
|
-
throw new (0,
|
|
2087
|
+
throw new (0, _chunkQONQSZHJcjs.UnknownTokenError)(
|
|
2079
2088
|
`token "${token}" isn't built in for ${resolved.chain.name} (known: ${known}). Pass { address, decimals } instead, or use 'native'.`
|
|
2080
2089
|
);
|
|
2081
2090
|
}
|
|
2082
2091
|
return { asset: info.address, decimals: info.decimals, symbol: info.symbol };
|
|
2083
2092
|
}
|
|
2084
|
-
|
|
2093
|
+
_chunkQONQSZHJcjs.rejectForeignToken.call(void 0, token, "evm", network);
|
|
2085
2094
|
if (!("address" in token)) {
|
|
2086
|
-
throw new (0,
|
|
2095
|
+
throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)(
|
|
2087
2096
|
`chain ${network} is EVM; a custom token must be { address, decimals }.`
|
|
2088
2097
|
);
|
|
2089
2098
|
}
|
|
2090
2099
|
if (!_viem.isAddress.call(void 0, token.address)) {
|
|
2091
|
-
throw new (0,
|
|
2100
|
+
throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)(
|
|
2092
2101
|
`chain ${network} is EVM, but token address "${token.address}" is not a valid 0x address.`
|
|
2093
2102
|
);
|
|
2094
2103
|
}
|
|
@@ -2120,20 +2129,20 @@ function makeEvmNetwork(resolved) {
|
|
|
2120
2129
|
},
|
|
2121
2130
|
assertValidPayTo(payTo) {
|
|
2122
2131
|
if (!_viem.isAddress.call(void 0, payTo)) {
|
|
2123
|
-
throw new (0,
|
|
2132
|
+
throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)(
|
|
2124
2133
|
`chain ${network} is EVM, but payTo "${payTo}" is not a valid 0x address.`
|
|
2125
2134
|
);
|
|
2126
2135
|
}
|
|
2127
2136
|
},
|
|
2128
2137
|
bindWallet(wallet) {
|
|
2129
2138
|
if (typeof wallet !== "object" || wallet === null) {
|
|
2130
|
-
throw new (0,
|
|
2139
|
+
throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)(
|
|
2131
2140
|
`chain ${network} is EVM; wallet must be { key } (0x\u2026 hex) or { walletClient }.`
|
|
2132
2141
|
);
|
|
2133
2142
|
}
|
|
2134
|
-
|
|
2143
|
+
_chunkQONQSZHJcjs.assertNoLegacyWalletKey.call(void 0, wallet, "EVM");
|
|
2135
2144
|
if (!("key" in wallet) && !("walletClient" in wallet)) {
|
|
2136
|
-
throw new (0,
|
|
2145
|
+
throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)(
|
|
2137
2146
|
`chain ${network} is EVM; wallet must be { key } (0x\u2026 hex) or { walletClient }.`
|
|
2138
2147
|
);
|
|
2139
2148
|
}
|
|
@@ -2150,12 +2159,12 @@ function makeEvmNetwork(resolved) {
|
|
|
2150
2159
|
});
|
|
2151
2160
|
} catch (err) {
|
|
2152
2161
|
if (isViemInsufficientFunds(err)) {
|
|
2153
|
-
throw new (0,
|
|
2162
|
+
throw new (0, _chunkQONQSZHJcjs.InsufficientFundsError)(
|
|
2154
2163
|
err instanceof Error ? err.message : "Insufficient funds for payment.",
|
|
2155
2164
|
{ cause: err }
|
|
2156
2165
|
);
|
|
2157
2166
|
}
|
|
2158
|
-
throw _nullishCoalesce(
|
|
2167
|
+
throw _nullishCoalesce(_chunkQONQSZHJcjs.toInsufficientFundsError.call(void 0, err), () => ( err));
|
|
2159
2168
|
}
|
|
2160
2169
|
},
|
|
2161
2170
|
async confirm(ref, minConfirmations) {
|
|
@@ -2166,7 +2175,7 @@ function makeEvmNetwork(resolved) {
|
|
|
2166
2175
|
});
|
|
2167
2176
|
return { height: receipt.blockNumber.toString() };
|
|
2168
2177
|
} catch (err) {
|
|
2169
|
-
throw new (0,
|
|
2178
|
+
throw new (0, _chunkQONQSZHJcjs.ConfirmationTimeoutError)(
|
|
2170
2179
|
`EVM tx ${ref} did not reach ${minConfirmations} confirmation(s) in time.`,
|
|
2171
2180
|
{ cause: err }
|
|
2172
2181
|
);
|
|
@@ -2177,7 +2186,7 @@ function makeEvmNetwork(resolved) {
|
|
|
2177
2186
|
if (accept.scheme === "exact" || accept.scheme === "upto") {
|
|
2178
2187
|
const m = _optionalChain([accept, 'access', _19 => _19.extra, 'optionalAccess', _20 => _20.assetTransferMethod]);
|
|
2179
2188
|
const permit2 = m === "permit2" || m === "permit2-exact" || m === "permit2-upto";
|
|
2180
|
-
return
|
|
2189
|
+
return _chunkQONQSZHJcjs.nativeCost.call(void 0, {
|
|
2181
2190
|
symbol,
|
|
2182
2191
|
decimals,
|
|
2183
2192
|
fee: 0n,
|
|
@@ -2188,7 +2197,7 @@ function makeEvmNetwork(resolved) {
|
|
|
2188
2197
|
const gasLimit = accept.asset === "native" ? 21000n : 65000n;
|
|
2189
2198
|
try {
|
|
2190
2199
|
const gasPrice = await publicClient.getGasPrice();
|
|
2191
|
-
return
|
|
2200
|
+
return _chunkQONQSZHJcjs.nativeCost.call(void 0, {
|
|
2192
2201
|
symbol,
|
|
2193
2202
|
decimals,
|
|
2194
2203
|
fee: gasPrice * gasLimit,
|
|
@@ -2197,7 +2206,7 @@ function makeEvmNetwork(resolved) {
|
|
|
2197
2206
|
});
|
|
2198
2207
|
} catch (e23) {
|
|
2199
2208
|
const gasPrice = 5000000000n;
|
|
2200
|
-
return
|
|
2209
|
+
return _chunkQONQSZHJcjs.nativeCost.call(void 0, {
|
|
2201
2210
|
symbol,
|
|
2202
2211
|
decimals,
|
|
2203
2212
|
fee: gasPrice * gasLimit,
|
|
@@ -2296,7 +2305,19 @@ function makeEvmNetwork(resolved) {
|
|
|
2296
2305
|
return resolveExactRailEvm({
|
|
2297
2306
|
asset,
|
|
2298
2307
|
method,
|
|
2299
|
-
|
|
2308
|
+
// `readExactDomain` fails CLOSED to null on two very different causes: the token really
|
|
2309
|
+
// isn't EIP-3009, or the RPC read blipped (rate-limit, timeout, an HTML error page from a
|
|
2310
|
+
// proxy). Treating a blip as "not EIP-3009" silently downgrades a perfectly good gasless
|
|
2311
|
+
// rail to onchain-proof — the merchant's buyers start paying gas and the warning blames
|
|
2312
|
+
// their TOKEN, which is the one thing that isn't wrong. The buyer side already retries
|
|
2313
|
+
// once for exactly this reason (see payExactEvm); the gate side did not, so a rate-limited
|
|
2314
|
+
// public RPC could turn real Base USDC into "this token isn't EIP-3009". Mirror it.
|
|
2315
|
+
readDomain: async (a) => {
|
|
2316
|
+
const first = await readExactDomain(publicClient, a);
|
|
2317
|
+
if (first) return first;
|
|
2318
|
+
await new Promise((r) => setTimeout(r, 300));
|
|
2319
|
+
return readExactDomain(publicClient, a);
|
|
2320
|
+
},
|
|
2300
2321
|
permit2Supported: () => isPermit2ProxyChain(resolved.chainId)
|
|
2301
2322
|
});
|
|
2302
2323
|
},
|
|
@@ -2382,9 +2403,9 @@ var loaders = {
|
|
|
2382
2403
|
solana: async () => {
|
|
2383
2404
|
let mod;
|
|
2384
2405
|
try {
|
|
2385
|
-
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./solana-
|
|
2406
|
+
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./solana-S2T3JNR7.cjs")));
|
|
2386
2407
|
} catch (cause) {
|
|
2387
|
-
throw new (0,
|
|
2408
|
+
throw new (0, _chunkQONQSZHJcjs.MissingDriverError)(
|
|
2388
2409
|
`Solana selected, but its packages aren't installed. Run: npm install @solana/web3.js @solana/spl-token bs58`,
|
|
2389
2410
|
{ cause }
|
|
2390
2411
|
);
|
|
@@ -2394,9 +2415,9 @@ var loaders = {
|
|
|
2394
2415
|
ton: async () => {
|
|
2395
2416
|
let mod;
|
|
2396
2417
|
try {
|
|
2397
|
-
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./ton-
|
|
2418
|
+
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./ton-J7TQWRN4.cjs")));
|
|
2398
2419
|
} catch (cause) {
|
|
2399
|
-
throw new (0,
|
|
2420
|
+
throw new (0, _chunkQONQSZHJcjs.MissingDriverError)(
|
|
2400
2421
|
`TON selected, but its packages aren't installed. Run: npm install @ton/ton @ton/core @ton/crypto`,
|
|
2401
2422
|
{ cause }
|
|
2402
2423
|
);
|
|
@@ -2406,9 +2427,9 @@ var loaders = {
|
|
|
2406
2427
|
stellar: async () => {
|
|
2407
2428
|
let mod;
|
|
2408
2429
|
try {
|
|
2409
|
-
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./stellar-
|
|
2430
|
+
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./stellar-E2KWEV2E.cjs")));
|
|
2410
2431
|
} catch (cause) {
|
|
2411
|
-
throw new (0,
|
|
2432
|
+
throw new (0, _chunkQONQSZHJcjs.MissingDriverError)(
|
|
2412
2433
|
`Stellar selected, but its package isn't installed. Run: npm install @stellar/stellar-sdk`,
|
|
2413
2434
|
{ cause }
|
|
2414
2435
|
);
|
|
@@ -2418,9 +2439,9 @@ var loaders = {
|
|
|
2418
2439
|
xrpl: async () => {
|
|
2419
2440
|
let mod;
|
|
2420
2441
|
try {
|
|
2421
|
-
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./xrpl-
|
|
2442
|
+
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./xrpl-VOUXIUYD.cjs")));
|
|
2422
2443
|
} catch (cause) {
|
|
2423
|
-
throw new (0,
|
|
2444
|
+
throw new (0, _chunkQONQSZHJcjs.MissingDriverError)(
|
|
2424
2445
|
`XRPL selected, but its package isn't installed. Run: npm install xrpl`,
|
|
2425
2446
|
{ cause }
|
|
2426
2447
|
);
|
|
@@ -2430,9 +2451,9 @@ var loaders = {
|
|
|
2430
2451
|
tron: async () => {
|
|
2431
2452
|
let mod;
|
|
2432
2453
|
try {
|
|
2433
|
-
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./tron-
|
|
2454
|
+
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./tron-HIPMOX7S.cjs")));
|
|
2434
2455
|
} catch (cause) {
|
|
2435
|
-
throw new (0,
|
|
2456
|
+
throw new (0, _chunkQONQSZHJcjs.MissingDriverError)(
|
|
2436
2457
|
`Tron selected, but its package isn't installed. Run: npm install tronweb`,
|
|
2437
2458
|
{ cause }
|
|
2438
2459
|
);
|
|
@@ -2442,9 +2463,9 @@ var loaders = {
|
|
|
2442
2463
|
sui: async () => {
|
|
2443
2464
|
let mod;
|
|
2444
2465
|
try {
|
|
2445
|
-
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./sui-
|
|
2466
|
+
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./sui-Q3NJOJZS.cjs")));
|
|
2446
2467
|
} catch (cause) {
|
|
2447
|
-
throw new (0,
|
|
2468
|
+
throw new (0, _chunkQONQSZHJcjs.MissingDriverError)(
|
|
2448
2469
|
`Sui selected, but its package isn't installed. Run: npm install @mysten/sui`,
|
|
2449
2470
|
{ cause }
|
|
2450
2471
|
);
|
|
@@ -2454,9 +2475,9 @@ var loaders = {
|
|
|
2454
2475
|
near: async () => {
|
|
2455
2476
|
let mod;
|
|
2456
2477
|
try {
|
|
2457
|
-
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./near-
|
|
2478
|
+
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./near-5LTTDU6G.cjs")));
|
|
2458
2479
|
} catch (cause) {
|
|
2459
|
-
throw new (0,
|
|
2480
|
+
throw new (0, _chunkQONQSZHJcjs.MissingDriverError)(
|
|
2460
2481
|
`NEAR selected, but its package isn't installed. Run: npm install near-api-js`,
|
|
2461
2482
|
{ cause }
|
|
2462
2483
|
);
|
|
@@ -2466,9 +2487,9 @@ var loaders = {
|
|
|
2466
2487
|
aptos: async () => {
|
|
2467
2488
|
let mod;
|
|
2468
2489
|
try {
|
|
2469
|
-
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./aptos-
|
|
2490
|
+
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./aptos-J2QSWHTO.cjs")));
|
|
2470
2491
|
} catch (cause) {
|
|
2471
|
-
throw new (0,
|
|
2492
|
+
throw new (0, _chunkQONQSZHJcjs.MissingDriverError)(
|
|
2472
2493
|
`Aptos selected, but its package isn't installed. Run: npm install @aptos-labs/ts-sdk`,
|
|
2473
2494
|
{ cause }
|
|
2474
2495
|
);
|
|
@@ -2478,9 +2499,9 @@ var loaders = {
|
|
|
2478
2499
|
algorand: async () => {
|
|
2479
2500
|
let mod;
|
|
2480
2501
|
try {
|
|
2481
|
-
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./algorand-
|
|
2502
|
+
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./algorand-XGSWDMCZ.cjs")));
|
|
2482
2503
|
} catch (cause) {
|
|
2483
|
-
throw new (0,
|
|
2504
|
+
throw new (0, _chunkQONQSZHJcjs.MissingDriverError)(
|
|
2484
2505
|
`Algorand selected, but its package isn't installed. Run: npm install algosdk`,
|
|
2485
2506
|
{ cause }
|
|
2486
2507
|
);
|
|
@@ -3124,7 +3145,7 @@ function encodeBase642(str) {
|
|
|
3124
3145
|
}
|
|
3125
3146
|
|
|
3126
3147
|
// src/policy.ts
|
|
3127
|
-
var DENOM_PRECISION =
|
|
3148
|
+
var DENOM_PRECISION = _chunkQONQSZHJcjs.MAX_DECIMALS;
|
|
3128
3149
|
var BUILTIN_DENOMS = {
|
|
3129
3150
|
USDC: "USD",
|
|
3130
3151
|
USDT: "USD",
|
|
@@ -3239,7 +3260,7 @@ function evaluatePolicy(intent, policy, spentForAssetBase, ctx) {
|
|
|
3239
3260
|
}
|
|
3240
3261
|
}
|
|
3241
3262
|
if (policy.maxAmount !== void 0) {
|
|
3242
|
-
const cap =
|
|
3263
|
+
const cap = _chunkQONQSZHJcjs.floorUnits.call(void 0, policy.maxAmount, intent.decimals);
|
|
3243
3264
|
if (intent.amountBase > cap) {
|
|
3244
3265
|
return deny(
|
|
3245
3266
|
"MAX_AMOUNT",
|
|
@@ -3248,7 +3269,7 @@ function evaluatePolicy(intent, policy, spentForAssetBase, ctx) {
|
|
|
3248
3269
|
}
|
|
3249
3270
|
}
|
|
3250
3271
|
if (policy.maxTotal !== void 0) {
|
|
3251
|
-
const cap =
|
|
3272
|
+
const cap = _chunkQONQSZHJcjs.floorUnits.call(void 0, policy.maxTotal, intent.decimals);
|
|
3252
3273
|
if (spentForAssetBase + intent.amountBase > cap) {
|
|
3253
3274
|
return deny(
|
|
3254
3275
|
"MAX_TOTAL",
|
|
@@ -3267,7 +3288,7 @@ function evaluatePolicy(intent, policy, spentForAssetBase, ctx) {
|
|
|
3267
3288
|
`token for ${denom} has more than ${DENOM_PRECISION} decimals \u2014 refusing to count it toward policy.maxTotalPerDenom.${denom} on trust (it can't be summed safely).`
|
|
3268
3289
|
);
|
|
3269
3290
|
}
|
|
3270
|
-
const capScaled =
|
|
3291
|
+
const capScaled = _chunkQONQSZHJcjs.floorUnits.call(void 0, capStr, DENOM_PRECISION);
|
|
3271
3292
|
if ((_nullishCoalesce(ctx.spentInDenomScaled, () => ( 0n))) + thisScaled > capScaled) {
|
|
3272
3293
|
return deny(
|
|
3273
3294
|
"MAX_TOTAL_DENOM",
|
|
@@ -3285,7 +3306,7 @@ function evaluatePolicy(intent, policy, spentForAssetBase, ctx) {
|
|
|
3285
3306
|
}
|
|
3286
3307
|
}
|
|
3287
3308
|
if (ctx && policy.windowTotal !== void 0 && policy.windowSeconds !== void 0) {
|
|
3288
|
-
const cap =
|
|
3309
|
+
const cap = _chunkQONQSZHJcjs.floorUnits.call(void 0, policy.windowTotal, intent.decimals);
|
|
3289
3310
|
if (ctx.spentInWindowBase + intent.amountBase > cap) {
|
|
3290
3311
|
return deny(
|
|
3291
3312
|
"WINDOW_TOTAL",
|
|
@@ -3351,7 +3372,7 @@ var SpendLedger = (_class = class {
|
|
|
3351
3372
|
* read or the constructor.
|
|
3352
3373
|
*/
|
|
3353
3374
|
isTallyable(r, decimals) {
|
|
3354
|
-
return !!r && typeof r.amountBase === "string" && /^\d+$/.test(r.amountBase) && Number.isInteger(decimals) && decimals >= 0 && decimals <=
|
|
3375
|
+
return !!r && typeof r.amountBase === "string" && /^\d+$/.test(r.amountBase) && Number.isInteger(decimals) && decimals >= 0 && decimals <= _chunkQONQSZHJcjs.MAX_DECIMALS;
|
|
3355
3376
|
}
|
|
3356
3377
|
/** Apply a record to the in-memory tallies (records + per-asset bucket + denom total).
|
|
3357
3378
|
* Shared by {@link record} and constructor hydration; does NOT persist. Returns the
|
|
@@ -3488,13 +3509,13 @@ var SpendLedger = (_class = class {
|
|
|
3488
3509
|
symbol: b.symbol,
|
|
3489
3510
|
decimals: b.decimals,
|
|
3490
3511
|
totalBase: b.total.toString(),
|
|
3491
|
-
totalFormatted:
|
|
3512
|
+
totalFormatted: _chunkQONQSZHJcjs.formatUnits.call(void 0, b.total, b.decimals),
|
|
3492
3513
|
count: b.count
|
|
3493
3514
|
})),
|
|
3494
3515
|
byDenom: [...this.denomTotals.entries()].map(([denom, scaled]) => ({
|
|
3495
3516
|
denom,
|
|
3496
3517
|
totalScaled: scaled.toString(),
|
|
3497
|
-
totalFormatted:
|
|
3518
|
+
totalFormatted: _chunkQONQSZHJcjs.formatUnits.call(void 0, scaled, DENOM_PRECISION),
|
|
3498
3519
|
count: this.records.filter((r) => _optionalChain([r, 'access', _34 => _34.denom, 'optionalAccess', _35 => _35.toUpperCase, 'call', _36 => _36()]) === denom).length
|
|
3499
3520
|
})),
|
|
3500
3521
|
records: [...this.records]
|
|
@@ -3902,7 +3923,7 @@ var PipRailClient = (_class2 = class {
|
|
|
3902
3923
|
const cost = await net.estimateCost(accept);
|
|
3903
3924
|
return { quote, cost };
|
|
3904
3925
|
} catch (err) {
|
|
3905
|
-
if (err instanceof
|
|
3926
|
+
if (err instanceof _chunkQONQSZHJcjs.InvalidEnvelopeError) return null;
|
|
3906
3927
|
throw err;
|
|
3907
3928
|
}
|
|
3908
3929
|
}
|
|
@@ -3954,14 +3975,14 @@ var PipRailClient = (_class2 = class {
|
|
|
3954
3975
|
return Object.entries(caps).map(([rawDenom, capStr]) => {
|
|
3955
3976
|
const denom = rawDenom.toUpperCase();
|
|
3956
3977
|
const spentScaled = this.ledger.totalForDenom(denom);
|
|
3957
|
-
const capScaled =
|
|
3978
|
+
const capScaled = _chunkQONQSZHJcjs.floorUnits.call(void 0, capStr, DENOM_PRECISION);
|
|
3958
3979
|
const remainingScaled = capScaled > spentScaled ? capScaled - spentScaled : 0n;
|
|
3959
3980
|
const fraction = capScaled === 0n ? spentScaled > 0n ? 1 : 0 : Number(spentScaled * 1000000n / capScaled) / 1e6;
|
|
3960
3981
|
return {
|
|
3961
3982
|
denom,
|
|
3962
|
-
spentFormatted:
|
|
3963
|
-
capFormatted:
|
|
3964
|
-
remainingFormatted:
|
|
3983
|
+
spentFormatted: _chunkQONQSZHJcjs.formatUnits.call(void 0, spentScaled, DENOM_PRECISION),
|
|
3984
|
+
capFormatted: _chunkQONQSZHJcjs.formatUnits.call(void 0, capScaled, DENOM_PRECISION),
|
|
3985
|
+
remainingFormatted: _chunkQONQSZHJcjs.formatUnits.call(void 0, remainingScaled, DENOM_PRECISION),
|
|
3965
3986
|
fraction
|
|
3966
3987
|
};
|
|
3967
3988
|
});
|
|
@@ -4002,13 +4023,13 @@ var PipRailClient = (_class2 = class {
|
|
|
4002
4023
|
spentBase: b.totalBase.toString()
|
|
4003
4024
|
};
|
|
4004
4025
|
if (maxTotal === void 0) return base2;
|
|
4005
|
-
const capBase =
|
|
4026
|
+
const capBase = _chunkQONQSZHJcjs.floorUnits.call(void 0, maxTotal, b.decimals);
|
|
4006
4027
|
const remainingBase = capBase > b.totalBase ? capBase - b.totalBase : 0n;
|
|
4007
4028
|
return {
|
|
4008
4029
|
...base2,
|
|
4009
4030
|
capBase: capBase.toString(),
|
|
4010
4031
|
remainingBase: remainingBase.toString(),
|
|
4011
|
-
remainingFormatted:
|
|
4032
|
+
remainingFormatted: _chunkQONQSZHJcjs.formatUnits.call(void 0, remainingBase, b.decimals)
|
|
4012
4033
|
};
|
|
4013
4034
|
});
|
|
4014
4035
|
}
|
|
@@ -4048,11 +4069,11 @@ var PipRailClient = (_class2 = class {
|
|
|
4048
4069
|
if (res.status !== 402) return null;
|
|
4049
4070
|
const challenge = await parseChallenge(res);
|
|
4050
4071
|
if (!challenge) {
|
|
4051
|
-
throw new (0,
|
|
4072
|
+
throw new (0, _chunkQONQSZHJcjs.InvalidEnvelopeError)("402 response did not include a parseable x402 challenge.");
|
|
4052
4073
|
}
|
|
4053
4074
|
const { net, wallet } = await this.ensure();
|
|
4054
4075
|
if (!wallet) {
|
|
4055
|
-
throw new (0,
|
|
4076
|
+
throw new (0, _chunkQONQSZHJcjs.WalletRequiredError)(
|
|
4056
4077
|
"planPayment needs a wallet (it checks YOUR balance, gas, and recipient-readiness). This client is read-only \u2014 construct it with a `wallet` to plan or pay."
|
|
4057
4078
|
);
|
|
4058
4079
|
}
|
|
@@ -4228,7 +4249,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4228
4249
|
async fetch(url, init) {
|
|
4229
4250
|
const body = _optionalChain([init, 'optionalAccess', _57 => _57.body]);
|
|
4230
4251
|
if (body !== void 0 && body !== null && !isReplayableBodyInit(body)) {
|
|
4231
|
-
throw new (0,
|
|
4252
|
+
throw new (0, _chunkQONQSZHJcjs.NonReplayableBodyError)(
|
|
4232
4253
|
"fetch(): init.body is not replayable. Pass a string, FormData, URLSearchParams, ArrayBuffer, or Blob \u2014 not a ReadableStream."
|
|
4233
4254
|
);
|
|
4234
4255
|
}
|
|
@@ -4238,7 +4259,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4238
4259
|
const resolved = await this.resolveChallenge(url, firstResponse, schemes);
|
|
4239
4260
|
const { net, wallet, challenge } = resolved;
|
|
4240
4261
|
if (!wallet) {
|
|
4241
|
-
throw new (0,
|
|
4262
|
+
throw new (0, _chunkQONQSZHJcjs.WalletRequiredError)(
|
|
4242
4263
|
"Paying a 402 needs a wallet to sign + settle. This client is read-only \u2014 construct it with a `wallet` to pay (quote/discover/register still work without one)."
|
|
4243
4264
|
);
|
|
4244
4265
|
}
|
|
@@ -4250,7 +4271,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4250
4271
|
if (!plan.best) {
|
|
4251
4272
|
const reason = _nullishCoalesce(plan.fundingHint, () => ( "No rail is settleable for this payment."));
|
|
4252
4273
|
this.safeEmit({ kind: "payment-failed", reason });
|
|
4253
|
-
throw new (0,
|
|
4274
|
+
throw new (0, _chunkQONQSZHJcjs.PaymentDeclinedError)(reason);
|
|
4254
4275
|
}
|
|
4255
4276
|
accept = plan.best.accept;
|
|
4256
4277
|
quote = plan.best.quote;
|
|
@@ -4264,7 +4285,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4264
4285
|
return this.payExactRail(net, wallet, accept, url, init, quote);
|
|
4265
4286
|
}
|
|
4266
4287
|
if (accept.scheme !== "onchain-proof") {
|
|
4267
|
-
throw new (0,
|
|
4288
|
+
throw new (0, _chunkQONQSZHJcjs.UnsupportedSchemeError)(
|
|
4268
4289
|
`internal: unrouted accept scheme '${accept.scheme}' reached the onchain-proof pay path.`
|
|
4269
4290
|
);
|
|
4270
4291
|
}
|
|
@@ -4282,7 +4303,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4282
4303
|
async resolveChallenge(url, response, schemes) {
|
|
4283
4304
|
const challenge = await parseChallenge(response);
|
|
4284
4305
|
if (!challenge) {
|
|
4285
|
-
throw new (0,
|
|
4306
|
+
throw new (0, _chunkQONQSZHJcjs.InvalidEnvelopeError)(
|
|
4286
4307
|
"402 response did not include a parseable x402 challenge."
|
|
4287
4308
|
);
|
|
4288
4309
|
}
|
|
@@ -4293,7 +4314,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4293
4314
|
(a) => a.scheme === "exact" && this.supportsNetwork(net, a.network)
|
|
4294
4315
|
);
|
|
4295
4316
|
if (schemes.includes("exact") && exactOnNet && typeof net.payExact !== "function") {
|
|
4296
|
-
throw new (0,
|
|
4317
|
+
throw new (0, _chunkQONQSZHJcjs.UnsupportedSchemeError)(
|
|
4297
4318
|
`This 402 offers a standard 'exact' rail on ${net.network}, but the ${net.family} family can't pay 'exact' (supported on EVM, Solana, Algorand, Aptos + NEAR today), and no 'onchain-proof' rail was offered.`
|
|
4298
4319
|
);
|
|
4299
4320
|
}
|
|
@@ -4302,13 +4323,13 @@ var PipRailClient = (_class2 = class {
|
|
|
4302
4323
|
(a) => a.scheme === "exact" && this.supportsNetwork(net, a.network) && net.describeAsset(a.asset) != null
|
|
4303
4324
|
);
|
|
4304
4325
|
if (payable) {
|
|
4305
|
-
throw new (0,
|
|
4326
|
+
throw new (0, _chunkQONQSZHJcjs.NoCompatibleAcceptError)(
|
|
4306
4327
|
`This 402 is payable only via the standard 'exact' rail on ${net.network}, which is OFF by default. Enable it: new PipRailClient({ \u2026, schemes: ['onchain-proof', 'exact'] }) or per call fetch(url, { schemes: ['exact'] }) (MCP: PIPRAIL_SCHEMES=onchain-proof,exact).`
|
|
4307
4328
|
);
|
|
4308
4329
|
}
|
|
4309
4330
|
}
|
|
4310
4331
|
const networks = [...new Set(challenge.accepts.map((a) => a.network))].join(", ");
|
|
4311
|
-
throw new (0,
|
|
4332
|
+
throw new (0, _chunkQONQSZHJcjs.NoCompatibleAcceptError)(
|
|
4312
4333
|
`No accepts[] entry payable by this client on ${net.network} (schemes: ${schemes.join(", ")}; challenge offered: ${networks || "none"}).`
|
|
4313
4334
|
);
|
|
4314
4335
|
}
|
|
@@ -4437,21 +4458,21 @@ var PipRailClient = (_class2 = class {
|
|
|
4437
4458
|
if (isExact) {
|
|
4438
4459
|
if (tokenKnown && bal.token < amount) {
|
|
4439
4460
|
blockers.push("INSUFFICIENT_TOKEN");
|
|
4440
|
-
shortfall.token =
|
|
4461
|
+
shortfall.token = _chunkQONQSZHJcjs.formatUnits.call(void 0, amount - bal.token, quote.decimals);
|
|
4441
4462
|
}
|
|
4442
4463
|
} else if (isNative) {
|
|
4443
4464
|
if (nativeKnown && bal.native < amount + fee) {
|
|
4444
4465
|
blockers.push("INSUFFICIENT_TOKEN");
|
|
4445
|
-
shortfall.token =
|
|
4466
|
+
shortfall.token = _chunkQONQSZHJcjs.formatUnits.call(void 0, amount + fee - bal.native, quote.decimals);
|
|
4446
4467
|
}
|
|
4447
4468
|
} else {
|
|
4448
4469
|
if (tokenKnown && bal.token < amount) {
|
|
4449
4470
|
blockers.push("INSUFFICIENT_TOKEN");
|
|
4450
|
-
shortfall.token =
|
|
4471
|
+
shortfall.token = _chunkQONQSZHJcjs.formatUnits.call(void 0, amount - bal.token, quote.decimals);
|
|
4451
4472
|
}
|
|
4452
4473
|
if (nativeKnown && bal.native < fee) {
|
|
4453
4474
|
blockers.push("INSUFFICIENT_GAS");
|
|
4454
|
-
shortfall.native =
|
|
4475
|
+
shortfall.native = _chunkQONQSZHJcjs.formatUnits.call(void 0, fee - bal.native, cost.feeDecimals);
|
|
4455
4476
|
} else if (nativeKnown && fee > 0n && bal.native < fee * 3n / 2n) {
|
|
4456
4477
|
warnings.push("THIN_GAS_MARGIN");
|
|
4457
4478
|
}
|
|
@@ -4476,8 +4497,8 @@ var PipRailClient = (_class2 = class {
|
|
|
4476
4497
|
blockers,
|
|
4477
4498
|
warnings,
|
|
4478
4499
|
balance: {
|
|
4479
|
-
token: bal.token != null ?
|
|
4480
|
-
native: bal.native != null ?
|
|
4500
|
+
token: bal.token != null ? _chunkQONQSZHJcjs.formatUnits.call(void 0, bal.token, quote.decimals) : null,
|
|
4501
|
+
native: bal.native != null ? _chunkQONQSZHJcjs.formatUnits.call(void 0, bal.native, cost.feeDecimals) : null
|
|
4481
4502
|
},
|
|
4482
4503
|
need: { token: quote.amountFormatted, native: cost.feeFormatted },
|
|
4483
4504
|
...shortfall.token || shortfall.native ? { shortfall } : {},
|
|
@@ -4488,12 +4509,12 @@ var PipRailClient = (_class2 = class {
|
|
|
4488
4509
|
* driver's describeAsset) + the policy verdict + a symbol-mismatch flag. */
|
|
4489
4510
|
buildQuote(net, accept, url, description) {
|
|
4490
4511
|
if (typeof accept.amount !== "string" || !/^\d+$/.test(accept.amount)) {
|
|
4491
|
-
throw new (0,
|
|
4512
|
+
throw new (0, _chunkQONQSZHJcjs.InvalidEnvelopeError)(
|
|
4492
4513
|
`challenge amount "${String(accept.amount)}" is not a base-unit integer string.`
|
|
4493
4514
|
);
|
|
4494
4515
|
}
|
|
4495
4516
|
if (typeof accept.asset !== "string" || accept.asset.length === 0) {
|
|
4496
|
-
throw new (0,
|
|
4517
|
+
throw new (0, _chunkQONQSZHJcjs.InvalidEnvelopeError)(
|
|
4497
4518
|
`challenge on ${accept.network} states no (string) asset \u2014 refusing to price it.`
|
|
4498
4519
|
);
|
|
4499
4520
|
}
|
|
@@ -4501,17 +4522,17 @@ var PipRailClient = (_class2 = class {
|
|
|
4501
4522
|
const described = net.describeAsset(accept.asset);
|
|
4502
4523
|
const decimals = _nullishCoalesce(_optionalChain([described, 'optionalAccess', _64 => _64.decimals]), () => ( _optionalChain([accept, 'access', _65 => _65.extra, 'optionalAccess', _66 => _66.decimals])));
|
|
4503
4524
|
if (typeof decimals !== "number" || !Number.isInteger(decimals) || decimals < 0) {
|
|
4504
|
-
throw new (0,
|
|
4525
|
+
throw new (0, _chunkQONQSZHJcjs.InvalidEnvelopeError)(
|
|
4505
4526
|
`challenge for ${accept.asset} on ${accept.network} states no valid decimals and the SDK doesn't recognise the token \u2014 refusing to price it.`
|
|
4506
4527
|
);
|
|
4507
4528
|
}
|
|
4508
|
-
if (decimals >
|
|
4509
|
-
throw new (0,
|
|
4510
|
-
`challenge for ${accept.asset} on ${accept.network} states ${decimals} decimals (> ${
|
|
4529
|
+
if (decimals > _chunkQONQSZHJcjs.MAX_DECIMALS) {
|
|
4530
|
+
throw new (0, _chunkQONQSZHJcjs.InvalidEnvelopeError)(
|
|
4531
|
+
`challenge for ${accept.asset} on ${accept.network} states ${decimals} decimals (> ${_chunkQONQSZHJcjs.MAX_DECIMALS}) \u2014 refusing to price it (no real token is that deep).`
|
|
4511
4532
|
);
|
|
4512
4533
|
}
|
|
4513
4534
|
const symbol = _nullishCoalesce(_optionalChain([described, 'optionalAccess', _67 => _67.symbol]), () => ( _optionalChain([accept, 'access', _68 => _68.extra, 'optionalAccess', _69 => _69.symbol])));
|
|
4514
|
-
const amountFormatted =
|
|
4535
|
+
const amountFormatted = _chunkQONQSZHJcjs.formatUnits.call(void 0, amountBase, decimals);
|
|
4515
4536
|
const intent = {
|
|
4516
4537
|
host: hostOf2(url),
|
|
4517
4538
|
chain: this.opts.chain,
|
|
@@ -4616,7 +4637,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4616
4637
|
...opts.quote ? { quote: opts.quote } : {},
|
|
4617
4638
|
budget: this.budget()
|
|
4618
4639
|
});
|
|
4619
|
-
throw new (0,
|
|
4640
|
+
throw new (0, _chunkQONQSZHJcjs.PaymentDeclinedError)(reason, {
|
|
4620
4641
|
...opts.reasonCode ? { reasonCode: opts.reasonCode } : {},
|
|
4621
4642
|
...opts.cause !== void 0 ? { cause: opts.cause } : {}
|
|
4622
4643
|
});
|
|
@@ -4648,7 +4669,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4648
4669
|
const max = BigInt(quote.amount);
|
|
4649
4670
|
const shown = claimed < max ? claimed : max;
|
|
4650
4671
|
settledBase = shown.toString();
|
|
4651
|
-
settledFormatted =
|
|
4672
|
+
settledFormatted = _chunkQONQSZHJcjs.formatUnits.call(void 0, shown, quote.decimals);
|
|
4652
4673
|
} catch (e36) {
|
|
4653
4674
|
}
|
|
4654
4675
|
}
|
|
@@ -4699,8 +4720,8 @@ var PipRailClient = (_class2 = class {
|
|
|
4699
4720
|
fire(
|
|
4700
4721
|
"asset",
|
|
4701
4722
|
`${_nullishCoalesce(r.symbol, () => ( r.asset))} on ${r.network}`,
|
|
4702
|
-
|
|
4703
|
-
|
|
4723
|
+
_chunkQONQSZHJcjs.formatUnits.call(void 0, spent, r.decimals),
|
|
4724
|
+
_chunkQONQSZHJcjs.formatUnits.call(void 0, cap, r.decimals),
|
|
4704
4725
|
fraction
|
|
4705
4726
|
);
|
|
4706
4727
|
}
|
|
@@ -4711,14 +4732,14 @@ var PipRailClient = (_class2 = class {
|
|
|
4711
4732
|
if (_optionalChain([policy, 'optionalAccess', _75 => _75.windowTotal]) !== void 0 && policy.windowSeconds !== void 0) {
|
|
4712
4733
|
const since = Date.now() - policy.windowSeconds * 1e3;
|
|
4713
4734
|
for (const r of budget.byAsset) {
|
|
4714
|
-
const cap =
|
|
4735
|
+
const cap = _chunkQONQSZHJcjs.floorUnits.call(void 0, policy.windowTotal, r.decimals);
|
|
4715
4736
|
const spent = this.ledger.totalSince(r.network, r.asset, since);
|
|
4716
4737
|
const fraction = cap === 0n ? spent > 0n ? 1 : 0 : Number(spent * 1000000n / cap) / 1e6;
|
|
4717
4738
|
fire(
|
|
4718
4739
|
"window",
|
|
4719
4740
|
`${_nullishCoalesce(r.symbol, () => ( r.asset))} on ${r.network}`,
|
|
4720
|
-
|
|
4721
|
-
|
|
4741
|
+
_chunkQONQSZHJcjs.formatUnits.call(void 0, spent, r.decimals),
|
|
4742
|
+
_chunkQONQSZHJcjs.formatUnits.call(void 0, cap, r.decimals),
|
|
4722
4743
|
fraction
|
|
4723
4744
|
);
|
|
4724
4745
|
}
|
|
@@ -4739,7 +4760,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4739
4760
|
}
|
|
4740
4761
|
async payAndConfirm(net, wallet, accept) {
|
|
4741
4762
|
if (!this.supportsNetwork(net, accept.network)) {
|
|
4742
|
-
throw new (0,
|
|
4763
|
+
throw new (0, _chunkQONQSZHJcjs.WrongChainError)(
|
|
4743
4764
|
`Challenge expects ${accept.network} but client is on ${net.network}.`
|
|
4744
4765
|
);
|
|
4745
4766
|
}
|
|
@@ -4792,7 +4813,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4792
4813
|
});
|
|
4793
4814
|
} catch (err) {
|
|
4794
4815
|
if (timeoutController.signal.aborted) {
|
|
4795
|
-
throw new (0,
|
|
4816
|
+
throw new (0, _chunkQONQSZHJcjs.PaymentTimeoutError)(
|
|
4796
4817
|
`Server did not respond within ${this.retryTimeoutMs}ms after broadcasting payment ${ref}. Re-verify or re-submit ref=${ref} \u2014 do NOT re-pay.`,
|
|
4797
4818
|
{ cause: err, ref }
|
|
4798
4819
|
);
|
|
@@ -4816,7 +4837,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4816
4837
|
reason: `server returned 402 after broadcasting payment ${ref}${unconfirmedNote} (${why})`,
|
|
4817
4838
|
...lastReason ? { code: lastReason.error, detail: lastReason.detail } : {}
|
|
4818
4839
|
});
|
|
4819
|
-
throw new (0,
|
|
4840
|
+
throw new (0, _chunkQONQSZHJcjs.MaxRetriesExceededError)(
|
|
4820
4841
|
`Server still returned 402 after ${attempts} attempt(s) with on-chain proof ref=${ref}${unconfirmedNote}. Last server rejection: ${why}. Re-verify or re-submit ref=${ref} before retrying \u2014 never re-pay (it would double-spend).`,
|
|
4821
4842
|
{ ref }
|
|
4822
4843
|
);
|
|
@@ -4840,7 +4861,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4840
4861
|
*/
|
|
4841
4862
|
async payExactRail(net, wallet, accept, url, init, quote) {
|
|
4842
4863
|
if (!net.payExact) {
|
|
4843
|
-
throw new (0,
|
|
4864
|
+
throw new (0, _chunkQONQSZHJcjs.UnsupportedSchemeError)(
|
|
4844
4865
|
`the ${net.family} family can't pay a standard 'exact' rail (supported on EVM, Solana, Algorand, Aptos + NEAR today).`
|
|
4845
4866
|
);
|
|
4846
4867
|
}
|
|
@@ -4850,7 +4871,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4850
4871
|
headers.set(HEADER_SIGNATURE, buildExactSignatureHeader({ accepted, payload }));
|
|
4851
4872
|
const rejectDefinitive = (why2) => {
|
|
4852
4873
|
this.safeEmit({ kind: "payment-failed", reason: `exact: facilitator rejected nonce=${nonce} (${why2})`, code: why2 });
|
|
4853
|
-
throw new (0,
|
|
4874
|
+
throw new (0, _chunkQONQSZHJcjs.MaxRetriesExceededError)(
|
|
4854
4875
|
`exact: the facilitator rejected the payment (${why2}). Fix the cause, then re-present the SAME signed authorization (nonce=${nonce}) \u2014 do NOT re-sign a fresh nonce. ref=${nonce}.`,
|
|
4855
4876
|
{ ref: nonce }
|
|
4856
4877
|
);
|
|
@@ -4873,7 +4894,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4873
4894
|
try {
|
|
4874
4895
|
response = await fetch(url, { ..._nullishCoalesce(init, () => ( {})), headers, signal });
|
|
4875
4896
|
} catch (err) {
|
|
4876
|
-
throw new (0,
|
|
4897
|
+
throw new (0, _chunkQONQSZHJcjs.PaymentTimeoutError)(
|
|
4877
4898
|
`exact: no response after submitting the authorization (nonce=${nonce}) to ${hostOf2(url)}. The facilitator may have already settled it \u2014 verify on-chain via ${exactSettleCheckHint(net.family, payerFrom, nonce)} before re-presenting the SAME signed authorization; do NOT re-pay.`,
|
|
4878
4899
|
{ cause: err, ref: nonce }
|
|
4879
4900
|
);
|
|
@@ -4908,7 +4929,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4908
4929
|
reason: `exact: 402 after submitting authorization nonce=${nonce} (${why})`,
|
|
4909
4930
|
...lastReason ? { code: lastReason.error, detail: lastReason.detail } : {}
|
|
4910
4931
|
});
|
|
4911
|
-
throw new (0,
|
|
4932
|
+
throw new (0, _chunkQONQSZHJcjs.MaxRetriesExceededError)(
|
|
4912
4933
|
`exact: server still returned 402 after submitting the signed authorization (nonce=${nonce}). Last rejection: ${why}. Re-present the SAME authorization \u2014 do NOT re-sign a fresh nonce; verify on-chain via ${exactSettleCheckHint(net.family, payerFrom, nonce)} first. ref=${nonce}.`,
|
|
4913
4934
|
{ ref: nonce }
|
|
4914
4935
|
);
|
|
@@ -4924,7 +4945,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4924
4945
|
*/
|
|
4925
4946
|
async payUptoRail(net, wallet, accept, url, init, quote) {
|
|
4926
4947
|
if (!net.payUpto) {
|
|
4927
|
-
throw new (0,
|
|
4948
|
+
throw new (0, _chunkQONQSZHJcjs.UnsupportedSchemeError)(
|
|
4928
4949
|
`the ${net.family} family can't pay a standard 'upto' rail (EVM-Permit2 only today).`
|
|
4929
4950
|
);
|
|
4930
4951
|
}
|
|
@@ -4934,7 +4955,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4934
4955
|
headers.set(HEADER_SIGNATURE, buildUptoSignatureHeader({ accepted, payload }));
|
|
4935
4956
|
const rejectDefinitive = (why2) => {
|
|
4936
4957
|
this.safeEmit({ kind: "payment-failed", reason: `upto: facilitator rejected nonce=${nonce} (${why2})`, code: why2 });
|
|
4937
|
-
throw new (0,
|
|
4958
|
+
throw new (0, _chunkQONQSZHJcjs.MaxRetriesExceededError)(
|
|
4938
4959
|
`upto: the server rejected the payment (${why2}). Fix the cause, then re-present the SAME signed authorization (nonce=${nonce}) \u2014 do NOT re-sign a fresh nonce. ref=${nonce}.`,
|
|
4939
4960
|
{ ref: nonce }
|
|
4940
4961
|
);
|
|
@@ -4957,7 +4978,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4957
4978
|
try {
|
|
4958
4979
|
response = await fetch(url, { ..._nullishCoalesce(init, () => ( {})), headers, signal });
|
|
4959
4980
|
} catch (err) {
|
|
4960
|
-
throw new (0,
|
|
4981
|
+
throw new (0, _chunkQONQSZHJcjs.PaymentTimeoutError)(
|
|
4961
4982
|
`upto: no response after submitting the authorization (nonce=${nonce}) to ${hostOf2(url)}. The merchant may have already settled it \u2014 verify on-chain before re-presenting; do NOT re-pay.`,
|
|
4962
4983
|
{ cause: err, ref: nonce }
|
|
4963
4984
|
);
|
|
@@ -4993,7 +5014,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4993
5014
|
reason: `upto: 402 after submitting authorization nonce=${nonce} (${why})`,
|
|
4994
5015
|
...lastReason ? { code: lastReason.error, detail: lastReason.detail } : {}
|
|
4995
5016
|
});
|
|
4996
|
-
throw new (0,
|
|
5017
|
+
throw new (0, _chunkQONQSZHJcjs.MaxRetriesExceededError)(
|
|
4997
5018
|
`upto: server still returned 402 after submitting the signed authorization (nonce=${nonce}). Last rejection: ${why}. Re-present the SAME authorization \u2014 do NOT re-sign a fresh nonce. ref=${nonce}.`,
|
|
4998
5019
|
{ ref: nonce }
|
|
4999
5020
|
);
|
|
@@ -5106,7 +5127,7 @@ async function fetchAcross(clients, url, init) {
|
|
|
5106
5127
|
const best = rankAcross(live.map((p) => p.plan)).find((o) => o.state === "payable");
|
|
5107
5128
|
if (!best) {
|
|
5108
5129
|
const hint = mergeDeclineHint(live.map((p) => p.plan));
|
|
5109
|
-
throw new (0,
|
|
5130
|
+
throw new (0, _chunkQONQSZHJcjs.PaymentDeclinedError)(hint || "No funded chain can settle this payment right now.");
|
|
5110
5131
|
}
|
|
5111
5132
|
const owner = live.find((p) => p.plan.options.includes(best)).client;
|
|
5112
5133
|
return owner.fetch(url, { ..._nullishCoalesce(init, () => ( {})), autoRoute: true });
|
|
@@ -5506,7 +5527,7 @@ function summarizePlan(plan) {
|
|
|
5506
5527
|
return `NOT payable: ${_nullishCoalesce(plan.fundingHint, () => ( `no settleable rail on ${plan.network}`))}`;
|
|
5507
5528
|
}
|
|
5508
5529
|
function explainDecline(err) {
|
|
5509
|
-
if (!(err instanceof
|
|
5530
|
+
if (!(err instanceof _chunkQONQSZHJcjs.PipRailError)) {
|
|
5510
5531
|
return `Payment failed: ${err instanceof Error ? err.message : String(err)}`;
|
|
5511
5532
|
}
|
|
5512
5533
|
switch (err.code) {
|
|
@@ -5662,14 +5683,14 @@ async function readBody(res) {
|
|
|
5662
5683
|
}
|
|
5663
5684
|
}
|
|
5664
5685
|
function toToolError(err) {
|
|
5665
|
-
if (!(err instanceof
|
|
5686
|
+
if (!(err instanceof _chunkQONQSZHJcjs.PipRailError)) throw err;
|
|
5666
5687
|
const out = {
|
|
5667
5688
|
ok: false,
|
|
5668
5689
|
code: err.code,
|
|
5669
5690
|
reason: err.message,
|
|
5670
5691
|
explain: explainDecline(err)
|
|
5671
5692
|
};
|
|
5672
|
-
if (err instanceof
|
|
5693
|
+
if (err instanceof _chunkQONQSZHJcjs.PaymentDeclinedError) {
|
|
5673
5694
|
out.declined = true;
|
|
5674
5695
|
if (err.reasonCode) out.reasonCode = err.reasonCode;
|
|
5675
5696
|
}
|
|
@@ -5885,14 +5906,14 @@ function paymentTools(client) {
|
|
|
5885
5906
|
...verifiable ? { verifiableReceipt: { ...verifiable, resource: { url } } } : {}
|
|
5886
5907
|
};
|
|
5887
5908
|
} catch (err) {
|
|
5888
|
-
if (err instanceof
|
|
5909
|
+
if (err instanceof _chunkQONQSZHJcjs.PipRailError) {
|
|
5889
5910
|
const out = {
|
|
5890
5911
|
ok: false,
|
|
5891
5912
|
code: err.code,
|
|
5892
5913
|
reason: err.message,
|
|
5893
5914
|
explain: explainDecline(err)
|
|
5894
5915
|
};
|
|
5895
|
-
if (err instanceof
|
|
5916
|
+
if (err instanceof _chunkQONQSZHJcjs.PaymentDeclinedError) {
|
|
5896
5917
|
out.declined = true;
|
|
5897
5918
|
if (err.reasonCode) out.reasonCode = err.reasonCode;
|
|
5898
5919
|
}
|
|
@@ -6148,11 +6169,11 @@ function buildWellKnownX402(input) {
|
|
|
6148
6169
|
}
|
|
6149
6170
|
function assertResourceList(resources, fn) {
|
|
6150
6171
|
if (!Array.isArray(resources)) {
|
|
6151
|
-
throw new (0,
|
|
6172
|
+
throw new (0, _chunkQONQSZHJcjs.InvalidConfigError)(`${fn}: \`resources\` must be an array of ResourceDescription.`);
|
|
6152
6173
|
}
|
|
6153
6174
|
resources.forEach((r, i) => {
|
|
6154
6175
|
if (r === null || typeof r !== "object" || typeof r.url !== "string") {
|
|
6155
|
-
throw new (0,
|
|
6176
|
+
throw new (0, _chunkQONQSZHJcjs.InvalidConfigError)(
|
|
6156
6177
|
`${fn}: resources[${i}] must be a ResourceDescription with a string \`url\`.`
|
|
6157
6178
|
);
|
|
6158
6179
|
}
|
|
@@ -6331,13 +6352,13 @@ async function settleViaFacilitator(input) {
|
|
|
6331
6352
|
try {
|
|
6332
6353
|
verify = await post(`${base2}/verify`, body, auth);
|
|
6333
6354
|
} catch (err) {
|
|
6334
|
-
throw new (0,
|
|
6355
|
+
throw new (0, _chunkQONQSZHJcjs.SettlementError)(
|
|
6335
6356
|
`exact settle (facilitator ${base2}): /verify request failed (${err instanceof Error ? err.message : String(err)}).`,
|
|
6336
6357
|
{ cause: err }
|
|
6337
6358
|
);
|
|
6338
6359
|
}
|
|
6339
6360
|
if (verify.status !== 200) {
|
|
6340
|
-
throw new (0,
|
|
6361
|
+
throw new (0, _chunkQONQSZHJcjs.SettlementError)(
|
|
6341
6362
|
`exact settle (facilitator ${base2}): /verify returned HTTP ${verify.status} (transport/auth error).`
|
|
6342
6363
|
);
|
|
6343
6364
|
}
|
|
@@ -6353,13 +6374,13 @@ async function settleViaFacilitator(input) {
|
|
|
6353
6374
|
try {
|
|
6354
6375
|
settle = await post(`${base2}/settle`, body, auth);
|
|
6355
6376
|
} catch (err) {
|
|
6356
|
-
throw new (0,
|
|
6377
|
+
throw new (0, _chunkQONQSZHJcjs.SettlementError)(
|
|
6357
6378
|
`exact settle (facilitator ${base2}): /settle request failed (${err instanceof Error ? err.message : String(err)}).`,
|
|
6358
6379
|
{ cause: err }
|
|
6359
6380
|
);
|
|
6360
6381
|
}
|
|
6361
6382
|
if (settle.status !== 200) {
|
|
6362
|
-
throw new (0,
|
|
6383
|
+
throw new (0, _chunkQONQSZHJcjs.SettlementError)(
|
|
6363
6384
|
`exact settle (facilitator ${base2}): /settle returned HTTP ${settle.status} (transport/auth error).`
|
|
6364
6385
|
);
|
|
6365
6386
|
}
|
|
@@ -6418,13 +6439,6 @@ var KNOWN_FACILITATORS = {
|
|
|
6418
6439
|
settles: ["eip3009"],
|
|
6419
6440
|
note: "Dexter \u2014 keyless, gas-sponsored (Base USDC EIP-3009). LIVE-settled on Base 2026-06-17 (tx 0xdf030e4d5bf41a88c5a3bfe73bb433dfbb90b058d3b8ded63b68e026eedb9de8). Note: ~$0.001 dynamic floor on Base."
|
|
6420
6441
|
},
|
|
6421
|
-
{
|
|
6422
|
-
url: "https://facilitator.corbits.dev",
|
|
6423
|
-
keyless: true,
|
|
6424
|
-
schemes: ["exact"],
|
|
6425
|
-
settles: ["eip3009"],
|
|
6426
|
-
note: "Corbits (Faremeter) \u2014 keyless, sponsors gas (Base USDC EIP-3009). LIVE-settled on Base 2026-06-17 (tx 0x2e41c581af023100429ada81f1371bef82d41dd577ed438d72ddc18676d4213d). Also seeded on Monad + Solana."
|
|
6427
|
-
},
|
|
6428
6442
|
{
|
|
6429
6443
|
url: "https://facilitator.goplausible.xyz",
|
|
6430
6444
|
keyless: true,
|
|
@@ -6438,26 +6452,12 @@ var KNOWN_FACILITATORS = {
|
|
|
6438
6452
|
schemes: ["exact"],
|
|
6439
6453
|
settles: ["eip3009"],
|
|
6440
6454
|
note: "Cascade \u2014 keyless, sponsors gas (Base USDC EIP-3009). LIVE-settled on Base 2026-06-18 (tx 0x2e784725f3c66e170720cc8df43a9248f02ad80914fcbe05dadbdbe411c3b52b)."
|
|
6441
|
-
},
|
|
6442
|
-
{
|
|
6443
|
-
url: "https://facilitator.bitcoinsapi.com",
|
|
6444
|
-
keyless: true,
|
|
6445
|
-
schemes: ["exact"],
|
|
6446
|
-
settles: ["eip3009"],
|
|
6447
|
-
note: "Satoshi (bitcoinsapi) \u2014 keyless, sponsors gas (Base USDC EIP-3009). LIVE-settled on Base 2026-06-18 (tx 0xbb2b6c354b12c6d07cce91e2b337e38327d4b0833bbd1dfbeda3ad495b67b819)."
|
|
6448
6455
|
}
|
|
6449
6456
|
],
|
|
6450
6457
|
// Monad (eip155:143). Corbits + Ultravioleta DAO each keyless-settle the EVM EIP-3009 exact rail
|
|
6451
6458
|
// (Monad's native Circle USDC), buyer paid zero gas — real LIVE settles, not just /supported reads.
|
|
6452
6459
|
// Makes `exact: true` zero-config gasless on Monad.
|
|
6453
6460
|
"eip155:143": [
|
|
6454
|
-
{
|
|
6455
|
-
url: "https://facilitator.corbits.dev",
|
|
6456
|
-
keyless: true,
|
|
6457
|
-
schemes: ["exact"],
|
|
6458
|
-
settles: ["eip3009"],
|
|
6459
|
-
note: "Corbits (Faremeter) \u2014 keyless, sponsors gas (Monad native USDC EIP-3009). LIVE-settled on Monad 2026-06-17 (tx 0x7797be27ce22c17f7433a0389bd22d46e338899b1faac505fffd068174428ae6)."
|
|
6460
|
-
},
|
|
6461
6461
|
{
|
|
6462
6462
|
url: "https://facilitator.ultravioletadao.xyz",
|
|
6463
6463
|
keyless: true,
|
|
@@ -6540,13 +6540,6 @@ var KNOWN_FACILITATORS = {
|
|
|
6540
6540
|
settles: ["eip3009"],
|
|
6541
6541
|
note: "Polygon Labs (the official Polygon facilitator) \u2014 keyless, sponsors gas. LIVE-settled on Polygon 2026-06-18 (tx 0x6a8ca60ea111959a61a85ad6c4f2ed99e192052ec7b9ffb59baa33691a86f419)."
|
|
6542
6542
|
},
|
|
6543
|
-
{
|
|
6544
|
-
url: "https://facilitator.corbits.dev",
|
|
6545
|
-
keyless: true,
|
|
6546
|
-
schemes: ["exact"],
|
|
6547
|
-
settles: ["eip3009"],
|
|
6548
|
-
note: "Corbits (Faremeter) \u2014 keyless, sponsors gas. LIVE-settled on Polygon 2026-06-18 (tx 0x2fadca2ee3cd7fcff32d015e8b06109de6b747d7cd0f80dcd8fb022b2d58d008)."
|
|
6549
|
-
},
|
|
6550
6543
|
{
|
|
6551
6544
|
url: "https://facilitator.ultravioletadao.xyz",
|
|
6552
6545
|
keyless: true,
|
|
@@ -6674,13 +6667,6 @@ var KNOWN_FACILITATORS = {
|
|
|
6674
6667
|
schemes: ["exact"],
|
|
6675
6668
|
settles: ["svm"],
|
|
6676
6669
|
note: "OpenFacilitator \u2014 keyless (no signup), fee-payer sponsor. LIVE-settled on Solana 2026-06-15 (tx 5BabDtX\u2026)."
|
|
6677
|
-
},
|
|
6678
|
-
{
|
|
6679
|
-
url: "https://facilitator.corbits.dev",
|
|
6680
|
-
keyless: true,
|
|
6681
|
-
schemes: ["exact"],
|
|
6682
|
-
settles: ["svm"],
|
|
6683
|
-
note: "Corbits \u2014 keyless, Solana-first fee-payer sponsor. LIVE-settled on Solana 2026-06-15 (tx BCreYer\u2026)."
|
|
6684
6670
|
}
|
|
6685
6671
|
]
|
|
6686
6672
|
// NEAR (near:mainnet) — DELIBERATELY UNSEEDED: no x402 facilitator settles NEAR yet.
|
|
@@ -6711,13 +6697,13 @@ function toInvalidBody(result) {
|
|
|
6711
6697
|
function normaliseAccepts(options) {
|
|
6712
6698
|
if (Array.isArray(options.accept) && options.accept.length > 0) {
|
|
6713
6699
|
if (options.chain !== void 0 || options.token !== void 0 || options.amount !== void 0) {
|
|
6714
|
-
throw new (0,
|
|
6700
|
+
throw new (0, _chunkQONQSZHJcjs.InvalidConfigError)(
|
|
6715
6701
|
"requirePayment: pass EITHER `accept: [...]` (multi-chain) OR `chain`/`token`/`amount` (single) \u2014 not both."
|
|
6716
6702
|
);
|
|
6717
6703
|
}
|
|
6718
6704
|
options.accept.forEach((a, i) => {
|
|
6719
6705
|
if (a === null || typeof a !== "object") {
|
|
6720
|
-
throw new (0,
|
|
6706
|
+
throw new (0, _chunkQONQSZHJcjs.InvalidConfigError)(
|
|
6721
6707
|
`requirePayment: accept[${i}] must be { chain, token, amount }, got ${a === null ? "null" : typeof a}.`
|
|
6722
6708
|
);
|
|
6723
6709
|
}
|
|
@@ -6727,7 +6713,7 @@ function normaliseAccepts(options) {
|
|
|
6727
6713
|
if (options.chain !== void 0 && options.token !== void 0 && options.amount !== void 0) {
|
|
6728
6714
|
return [{ chain: options.chain, token: options.token, amount: options.amount }];
|
|
6729
6715
|
}
|
|
6730
|
-
throw new (0,
|
|
6716
|
+
throw new (0, _chunkQONQSZHJcjs.InvalidConfigError)(
|
|
6731
6717
|
"requirePayment: provide either { chain, token, amount } or a non-empty `accept: [{ chain, token, amount }, \u2026]`."
|
|
6732
6718
|
);
|
|
6733
6719
|
}
|
|
@@ -6776,13 +6762,13 @@ function createPaymentGate(options) {
|
|
|
6776
6762
|
const net = await resolveNetwork2({ chain: a.chain, rpcUrl: _nullishCoalesce(a.rpcUrl, () => ( options.rpcUrl)) });
|
|
6777
6763
|
const payTo = _nullishCoalesce(a.payTo, () => ( options.payTo));
|
|
6778
6764
|
if (!payTo) {
|
|
6779
|
-
throw new (0,
|
|
6765
|
+
throw new (0, _chunkQONQSZHJcjs.InvalidConfigError)(
|
|
6780
6766
|
`requirePayment: no payTo for chain ${net.network}. Set it on the accept entry or pass a top-level payTo.`
|
|
6781
6767
|
);
|
|
6782
6768
|
}
|
|
6783
6769
|
net.assertValidPayTo(payTo);
|
|
6784
6770
|
const { asset, decimals, symbol } = net.resolveToken(a.token);
|
|
6785
|
-
const amountBase =
|
|
6771
|
+
const amountBase = _chunkQONQSZHJcjs.parseUnits.call(void 0, a.amount, decimals);
|
|
6786
6772
|
const spec = { net, asset, decimals, symbol, amountBase, amountFormatted: a.amount, payTo };
|
|
6787
6773
|
if (exactOption) {
|
|
6788
6774
|
const outcome = await resolveExactRail(net, asset);
|
|
@@ -6871,7 +6857,7 @@ function createPaymentGate(options) {
|
|
|
6871
6857
|
);
|
|
6872
6858
|
}
|
|
6873
6859
|
return {
|
|
6874
|
-
skipReason: `${net.network}:
|
|
6860
|
+
skipReason: `${net.network}: auto-selected Permit2, which a third-party facilitator can't settle \u2014 it would serve onchain-proof only here. Either this token isn't EIP-3009 (use USDC / EURC with the facilitator, or \`settle: 'self'\` to settle Permit2 yourself), OR the EIP-712 domain read failed on your RPC (transient): if you expected a gasless rail here, pass a reliable \`rpcUrl\` and retry.`
|
|
6875
6861
|
};
|
|
6876
6862
|
}
|
|
6877
6863
|
const mode = settle === "self" ? { kind: "self", relayer } : {
|
|
@@ -7065,7 +7051,7 @@ function createPaymentGate(options) {
|
|
|
7065
7051
|
function enrichReceipt(spec, receipt) {
|
|
7066
7052
|
let amountFormatted = receipt.amount;
|
|
7067
7053
|
try {
|
|
7068
|
-
amountFormatted =
|
|
7054
|
+
amountFormatted = _chunkQONQSZHJcjs.formatUnits.call(void 0, BigInt(receipt.amount), spec.decimals);
|
|
7069
7055
|
} catch (e49) {
|
|
7070
7056
|
}
|
|
7071
7057
|
return {
|
|
@@ -7220,7 +7206,7 @@ function createPaymentGate(options) {
|
|
|
7220
7206
|
`Proof claims ${sig.accepted.asset} on ${sig.accepted.network}, which this resource doesn't accept (offered: ${specs.map((s) => `${s.asset}@${s.net.network}`).join(", ")}).`
|
|
7221
7207
|
);
|
|
7222
7208
|
}
|
|
7223
|
-
const ref = sig.payload.txHash;
|
|
7209
|
+
const ref = typeof sig.payload.txHash === "string" ? sig.payload.txHash.trim() : sig.payload.txHash;
|
|
7224
7210
|
if (await claimTx(ref)) return rejection("tx_already_used", `Proof ${ref} was already redeemed.`);
|
|
7225
7211
|
let result;
|
|
7226
7212
|
try {
|
|
@@ -7317,7 +7303,7 @@ function createPaymentGate(options) {
|
|
|
7317
7303
|
const ftMethod = accept.extra.assetTransferMethod;
|
|
7318
7304
|
const needsFeePayer = ftMethod === "svm" || ftMethod === "algorand" || ftMethod === "aptos" || ftMethod === "near";
|
|
7319
7305
|
if (needsFeePayer && !accept.extra.feePayer) {
|
|
7320
|
-
throw new (0,
|
|
7306
|
+
throw new (0, _chunkQONQSZHJcjs.SettlementError)(
|
|
7321
7307
|
`exact settle: the ${ftMethod} facilitator rail is missing extra.feePayer (the gas sponsor) \u2014 cannot settle.`
|
|
7322
7308
|
);
|
|
7323
7309
|
}
|
|
@@ -7365,15 +7351,15 @@ function createPaymentGate(options) {
|
|
|
7365
7351
|
if (s.endsWith("%")) {
|
|
7366
7352
|
const pct = s.slice(0, -1).trim();
|
|
7367
7353
|
if (!/^\d+(\.\d+)?$/.test(pct)) return null;
|
|
7368
|
-
const pctScaled =
|
|
7354
|
+
const pctScaled = _chunkQONQSZHJcjs.floorUnits.call(void 0, pct, 4);
|
|
7369
7355
|
return maxAmount * pctScaled / (100n * 10n ** 4n);
|
|
7370
7356
|
}
|
|
7371
7357
|
if (s.startsWith("$")) {
|
|
7372
7358
|
const amt = s.slice(1).trim();
|
|
7373
|
-
return
|
|
7359
|
+
return _chunkQONQSZHJcjs.floorUnits.call(void 0, amt, decimals);
|
|
7374
7360
|
}
|
|
7375
7361
|
if (/^\d+$/.test(s)) return BigInt(s);
|
|
7376
|
-
return
|
|
7362
|
+
return _chunkQONQSZHJcjs.floorUnits.call(void 0, s, decimals);
|
|
7377
7363
|
} catch (e58) {
|
|
7378
7364
|
return null;
|
|
7379
7365
|
}
|
|
@@ -7424,7 +7410,7 @@ function createPaymentGate(options) {
|
|
|
7424
7410
|
result = await spec.net.settleUptoSelf({ relayer, payload: upto.payload, accept, settleAmount });
|
|
7425
7411
|
} catch (err) {
|
|
7426
7412
|
await settleTx(nonce, false);
|
|
7427
|
-
if (err instanceof
|
|
7413
|
+
if (err instanceof _chunkQONQSZHJcjs.SettlementError) throw err;
|
|
7428
7414
|
return rejection(
|
|
7429
7415
|
"tx_reverted",
|
|
7430
7416
|
`upto: metering/settle failed (${err instanceof Error ? err.message : String(err)}).`
|
|
@@ -7499,11 +7485,40 @@ function createPaymentGate(options) {
|
|
|
7499
7485
|
await settleTx(idKey, result.kind === "paid");
|
|
7500
7486
|
return result.kind === "paid" ? echoPaymentIdentifier(result, id) : result;
|
|
7501
7487
|
}
|
|
7502
|
-
|
|
7488
|
+
async function selfTest() {
|
|
7489
|
+
try {
|
|
7490
|
+
const specs = await ready();
|
|
7491
|
+
const warnings = [];
|
|
7492
|
+
const rails = specs.map((s) => {
|
|
7493
|
+
if (!s.symbol) {
|
|
7494
|
+
warnings.push(
|
|
7495
|
+
`${s.asset} on ${s.net.network}: custom token (no built-in symbol) \u2014 double-check the address + decimals.`
|
|
7496
|
+
);
|
|
7497
|
+
}
|
|
7498
|
+
return {
|
|
7499
|
+
network: s.net.network,
|
|
7500
|
+
asset: s.asset,
|
|
7501
|
+
...s.symbol ? { symbol: s.symbol } : {},
|
|
7502
|
+
decimals: s.decimals,
|
|
7503
|
+
amount: s.amountFormatted,
|
|
7504
|
+
payTo: s.payTo,
|
|
7505
|
+
schemes: [
|
|
7506
|
+
...s.exact ? ["exact"] : [],
|
|
7507
|
+
...s.upto ? ["upto"] : [],
|
|
7508
|
+
"onchain-proof"
|
|
7509
|
+
]
|
|
7510
|
+
};
|
|
7511
|
+
});
|
|
7512
|
+
return { ok: true, rails, warnings };
|
|
7513
|
+
} catch (err) {
|
|
7514
|
+
return { ok: false, rails: [], warnings: [], error: err instanceof Error ? err.message : String(err) };
|
|
7515
|
+
}
|
|
7516
|
+
}
|
|
7517
|
+
return { challenge, verify, verifyObject, describe, landingPage, selfTest };
|
|
7503
7518
|
}
|
|
7504
7519
|
function requirePayment(options) {
|
|
7505
7520
|
if (options.upto) {
|
|
7506
|
-
throw new (_class3 = class extends
|
|
7521
|
+
throw new (_class3 = class extends _chunkQONQSZHJcjs.PipRailError {constructor(...args2) { super(...args2); _class3.prototype.__init7.call(this); }
|
|
7507
7522
|
__init7() {this.code = "UNSUPPORTED_SCHEME"}
|
|
7508
7523
|
}, _class3)(
|
|
7509
7524
|
"requirePayment: the 'upto' (metered) rail is unsupported through the Express middleware \u2014 it settles before the route handler serves, so metered usage is unknown at settle time. Call gate.verify() directly (createPaymentGate) and meter inside settleAmount; see docs/accepting-payments/upto-rail-seller.md."
|
|
@@ -7515,7 +7530,7 @@ function requirePayment(options) {
|
|
|
7515
7530
|
try {
|
|
7516
7531
|
result = await gate.verify(_nullishCoalesce(req.headers[HEADER_SIGNATURE], () => ( req.headers[HEADER_SIGNATURE_V1])));
|
|
7517
7532
|
} catch (err) {
|
|
7518
|
-
if (err instanceof
|
|
7533
|
+
if (err instanceof _chunkQONQSZHJcjs.SettlementError) {
|
|
7519
7534
|
res.status(502);
|
|
7520
7535
|
res.json({
|
|
7521
7536
|
x402Version: 2,
|
|
@@ -7551,6 +7566,87 @@ function normaliseHeader(value) {
|
|
|
7551
7566
|
return value;
|
|
7552
7567
|
}
|
|
7553
7568
|
|
|
7569
|
+
// src/merchant.ts
|
|
7570
|
+
function createPaywall({ token = "USDC", ...rest }) {
|
|
7571
|
+
return createPaymentGate({ token, ...rest });
|
|
7572
|
+
}
|
|
7573
|
+
function createTipJar({ token = "USDC", min, ...rest }) {
|
|
7574
|
+
return createPaymentGate({ token, amount: min, ...rest });
|
|
7575
|
+
}
|
|
7576
|
+
|
|
7577
|
+
// src/adapters.ts
|
|
7578
|
+
function jsonResponse(body, status, headers) {
|
|
7579
|
+
return new Response(JSON.stringify(body), {
|
|
7580
|
+
status,
|
|
7581
|
+
headers: { "content-type": "application/json; charset=utf-8", ..._nullishCoalesce(headers, () => ( {})) }
|
|
7582
|
+
});
|
|
7583
|
+
}
|
|
7584
|
+
function withSettlementHeaders(res, receiptHeader) {
|
|
7585
|
+
const headers = new Headers();
|
|
7586
|
+
res.headers.forEach((value, key) => {
|
|
7587
|
+
if (key.toLowerCase() !== "set-cookie") headers.append(key, value);
|
|
7588
|
+
});
|
|
7589
|
+
const src = res.headers;
|
|
7590
|
+
const cookies = typeof src.getSetCookie === "function" ? src.getSetCookie() : (() => {
|
|
7591
|
+
const combined = res.headers.get("set-cookie");
|
|
7592
|
+
return combined ? [combined] : [];
|
|
7593
|
+
})();
|
|
7594
|
+
for (const cookie of cookies) headers.append("set-cookie", cookie);
|
|
7595
|
+
headers.set(HEADER_RESPONSE, receiptHeader);
|
|
7596
|
+
headers.set(HEADER_RESPONSE_V1, receiptHeader);
|
|
7597
|
+
return new Response(res.body, { status: res.status, statusText: res.statusText, headers });
|
|
7598
|
+
}
|
|
7599
|
+
function toFetchHandler(gate, serve) {
|
|
7600
|
+
return async (request, ...rest) => {
|
|
7601
|
+
let result;
|
|
7602
|
+
try {
|
|
7603
|
+
const sig = _nullishCoalesce(_nullishCoalesce(request.headers.get(HEADER_SIGNATURE), () => ( request.headers.get(HEADER_SIGNATURE_V1))), () => ( void 0));
|
|
7604
|
+
result = await gate.verify(sig);
|
|
7605
|
+
} catch (err) {
|
|
7606
|
+
if (err instanceof _chunkQONQSZHJcjs.SettlementError) {
|
|
7607
|
+
return jsonResponse(
|
|
7608
|
+
{
|
|
7609
|
+
x402Version: 2,
|
|
7610
|
+
error: "settlement_failed",
|
|
7611
|
+
detail: err.message,
|
|
7612
|
+
fallback: "The gasless `exact` settlement failed. This resource also accepts `onchain-proof` \u2014 retry by paying that rail yourself (you broadcast the transfer and pay the gas)."
|
|
7613
|
+
},
|
|
7614
|
+
502
|
|
7615
|
+
);
|
|
7616
|
+
}
|
|
7617
|
+
throw err;
|
|
7618
|
+
}
|
|
7619
|
+
if (result.kind === "paid") {
|
|
7620
|
+
const res = await serve(request, ...rest);
|
|
7621
|
+
return withSettlementHeaders(res, result.receiptHeader);
|
|
7622
|
+
}
|
|
7623
|
+
return jsonResponse(result.challenge, 402, { [HEADER_REQUIRED]: result.requiredHeader });
|
|
7624
|
+
};
|
|
7625
|
+
}
|
|
7626
|
+
function toWorker(gate, serve) {
|
|
7627
|
+
return { fetch: toFetchHandler(gate, serve) };
|
|
7628
|
+
}
|
|
7629
|
+
function proxyTo(origin) {
|
|
7630
|
+
const base2 = origin.replace(/\/+$/, "");
|
|
7631
|
+
return (request) => {
|
|
7632
|
+
const inUrl = new URL(request.url);
|
|
7633
|
+
const target = base2 + inUrl.pathname + inUrl.search;
|
|
7634
|
+
const headers = new Headers(request.headers);
|
|
7635
|
+
headers.delete(HEADER_SIGNATURE);
|
|
7636
|
+
headers.delete(HEADER_SIGNATURE_V1);
|
|
7637
|
+
const init = {
|
|
7638
|
+
method: request.method,
|
|
7639
|
+
headers,
|
|
7640
|
+
redirect: "manual"
|
|
7641
|
+
};
|
|
7642
|
+
if (request.method !== "GET" && request.method !== "HEAD") {
|
|
7643
|
+
init.body = request.body;
|
|
7644
|
+
init.duplex = "half";
|
|
7645
|
+
}
|
|
7646
|
+
return fetch(target, init);
|
|
7647
|
+
};
|
|
7648
|
+
}
|
|
7649
|
+
|
|
7554
7650
|
// src/receipts.ts
|
|
7555
7651
|
var DEFAULT_RETRIES = 5;
|
|
7556
7652
|
var DEFAULT_TIMEOUT_MS = 1e4;
|
|
@@ -7837,7 +7933,7 @@ function createA2APaymentHandler(options) {
|
|
|
7837
7933
|
try {
|
|
7838
7934
|
result = await gate.verifyObject(inbound.raw);
|
|
7839
7935
|
} catch (err) {
|
|
7840
|
-
if (err instanceof
|
|
7936
|
+
if (err instanceof _chunkQONQSZHJcjs.SettlementError) {
|
|
7841
7937
|
return failedTask(id, "settlement_failed", err.message, attempted);
|
|
7842
7938
|
}
|
|
7843
7939
|
const detail = err instanceof Error ? err.message : String(err);
|
|
@@ -7988,7 +8084,7 @@ function createMcpPaymentTool(options) {
|
|
|
7988
8084
|
try {
|
|
7989
8085
|
result = await gate.verifyObject(raw);
|
|
7990
8086
|
} catch (err) {
|
|
7991
|
-
if (err instanceof
|
|
8087
|
+
if (err instanceof _chunkQONQSZHJcjs.SettlementError) return settlementFailed("settlement_failed", err.message);
|
|
7992
8088
|
throw err;
|
|
7993
8089
|
}
|
|
7994
8090
|
if (result.kind === "paid") {
|
|
@@ -8155,4 +8251,9 @@ function createMcpPaymentTool(options) {
|
|
|
8155
8251
|
|
|
8156
8252
|
|
|
8157
8253
|
|
|
8158
|
-
|
|
8254
|
+
|
|
8255
|
+
|
|
8256
|
+
|
|
8257
|
+
|
|
8258
|
+
|
|
8259
|
+
exports.A2A_ERROR_KEY = A2A_ERROR_KEY; exports.A2A_EXTENSIONS_HEADER = A2A_EXTENSIONS_HEADER; exports.A2A_PAYLOAD_KEY = A2A_PAYLOAD_KEY; exports.A2A_RECEIPTS_KEY = A2A_RECEIPTS_KEY; exports.A2A_REQUIRED_KEY = A2A_REQUIRED_KEY; exports.A2A_STATUS_KEY = A2A_STATUS_KEY; exports.A2A_X402_EXTENSION_URI_V01 = A2A_X402_EXTENSION_URI_V01; exports.A2A_X402_EXTENSION_URI_V02 = A2A_X402_EXTENSION_URI_V02; exports.BRAND = BRAND; exports.BUILTIN_DENOMS = BUILTIN_DENOMS; exports.CHAINS = CHAINS; exports.ConfirmationTimeoutError = _chunkQONQSZHJcjs.ConfirmationTimeoutError; exports.DENOM_PRECISION = DENOM_PRECISION; exports.DIRECTORY_INFO = DIRECTORY_INFO; exports.EIP3009_TYPES = EIP3009_TYPES; exports.EXACT_NETWORK_SLUGS = EXACT_NETWORK_SLUGS; exports.EXT_OFFER_RECEIPT = EXT_OFFER_RECEIPT; exports.EXT_PAYMENT_IDENTIFIER = EXT_PAYMENT_IDENTIFIER; exports.GENERATOR = GENERATOR; exports.HEADER_REQUIRED = HEADER_REQUIRED; exports.HEADER_RESPONSE = HEADER_RESPONSE; exports.HEADER_RESPONSE_V1 = HEADER_RESPONSE_V1; exports.HEADER_SIGNATURE = HEADER_SIGNATURE; exports.HEADER_SIGNATURE_V1 = HEADER_SIGNATURE_V1; exports.InsufficientFundsError = _chunkQONQSZHJcjs.InsufficientFundsError; exports.InvalidConfigError = _chunkQONQSZHJcjs.InvalidConfigError; exports.InvalidEnvelopeError = _chunkQONQSZHJcjs.InvalidEnvelopeError; exports.KNOWN_FACILITATORS = KNOWN_FACILITATORS; exports.MCP_PAYMENT_META_KEY = MCP_PAYMENT_META_KEY; exports.MCP_PAYMENT_RESPONSE_META_KEY = MCP_PAYMENT_RESPONSE_META_KEY; exports.MaxRetriesExceededError = _chunkQONQSZHJcjs.MaxRetriesExceededError; exports.MissingDriverError = _chunkQONQSZHJcjs.MissingDriverError; exports.MultiChainPayer = MultiChainPayer; exports.NoCompatibleAcceptError = _chunkQONQSZHJcjs.NoCompatibleAcceptError; exports.NonReplayableBodyError = _chunkQONQSZHJcjs.NonReplayableBodyError; exports.PERMIT2_ADDRESS = PERMIT2_ADDRESS; exports.PERMIT2_PROXY_CHAIN_IDS = PERMIT2_PROXY_CHAIN_IDS; exports.PERMIT2_UPTO_WITNESS_TYPES = PERMIT2_UPTO_WITNESS_TYPES; exports.PERMIT2_WITNESS_TYPES = PERMIT2_WITNESS_TYPES; exports.PIPRAIL_AGENT_GUIDE = PIPRAIL_AGENT_GUIDE; exports.POWERED_BY = POWERED_BY; exports.PaymentDeclinedError = _chunkQONQSZHJcjs.PaymentDeclinedError; exports.PaymentTimeoutError = _chunkQONQSZHJcjs.PaymentTimeoutError; exports.PipRailClient = PipRailClient; exports.PipRailError = _chunkQONQSZHJcjs.PipRailError; exports.REGISTER_ATTRIBUTION = REGISTER_ATTRIBUTION; exports.RecipientNotReadyError = _chunkQONQSZHJcjs.RecipientNotReadyError; exports.SettlementError = _chunkQONQSZHJcjs.SettlementError; exports.SpendLedger = SpendLedger; exports.UPTO_PROXY_CHAIN_IDS = UPTO_PROXY_CHAIN_IDS; exports.UnknownTokenError = _chunkQONQSZHJcjs.UnknownTokenError; exports.UnsupportedNetworkError = _chunkQONQSZHJcjs.UnsupportedNetworkError; exports.UnsupportedSchemeError = _chunkQONQSZHJcjs.UnsupportedSchemeError; exports.VERIFY_CODE_TO_A2A_ERROR = VERIFY_CODE_TO_A2A_ERROR; exports.WalletRequiredError = _chunkQONQSZHJcjs.WalletRequiredError; exports.WrongChainError = _chunkQONQSZHJcjs.WrongChainError; exports.WrongFamilyError = _chunkQONQSZHJcjs.WrongFamilyError; exports.X402_EXACT_PERMIT2_PROXY = X402_EXACT_PERMIT2_PROXY; exports.X402_UPTO_PERMIT2_PROXY = X402_UPTO_PERMIT2_PROXY; exports.agentGuide = agentGuide; exports.appendAttribution = appendAttribution; exports.appendKeywords = appendKeywords; exports.buildBazaarExtension = buildBazaarExtension; exports.buildChallengeHeader = buildChallengeHeader; exports.buildEndpointInfo = buildEndpointInfo; exports.buildExactAuthorization = buildExactAuthorization; exports.buildExactSignatureHeader = buildExactSignatureHeader; exports.buildMcpPaymentMeta = buildMcpPaymentMeta; exports.buildOpenApi = buildOpenApi; exports.buildPaymentIdentifierAdvertisement = buildPaymentIdentifierAdvertisement; exports.buildReceiptExtension = buildReceiptExtension; exports.buildReceiptHeader = buildReceiptHeader; exports.buildSelfDescription = buildSelfDescription; exports.buildSignatureHeader = buildSignatureHeader; exports.buildUptoSignatureHeader = buildUptoSignatureHeader; exports.buildWellKnownX402 = buildWellKnownX402; exports.buildWellKnownX402Manifest = buildWellKnownX402Manifest; exports.buildX402DnsTxt = buildX402DnsTxt; exports.chainIdForExactNetwork = chainIdForExactNetwork; exports.claim402IndexDomain = claim402IndexDomain; exports.classifyChallenge = classifyChallenge; exports.createA2APaymentHandler = createA2APaymentHandler; exports.createMcpPaymentTool = createMcpPaymentTool; exports.createPaymentGate = createPaymentGate; exports.createPaywall = createPaywall; exports.createTipJar = createTipJar; exports.decodeBase64Json = decodeBase64Json; exports.decorateOutcome = decorateOutcome; exports.deliverReceipt = deliverReceipt; exports.denomOf = denomOf; exports.describeChallenge = describeChallenge; exports.discoveryHeaders = discoveryHeaders; exports.eip3009Abi = eip3009Abi; exports.encodeXPaymentHeader = encodeXPaymentHeader; exports.evaluatePolicy = evaluatePolicy; exports.explainDecline = explainDecline; exports.facilitatorCoverage = facilitatorCoverage; exports.fetchAcross = fetchAcross; exports.firstKeylessFacilitator = firstKeylessFacilitator; exports.formatSpendReport = formatSpendReport; exports.fromA2APaymentPayload = fromA2APaymentPayload; exports.fromA2APaymentRequired = fromA2APaymentRequired; exports.fromMcpPayment = fromMcpPayment; exports.fromMcpPaymentRequired = fromMcpPaymentRequired; exports.fromMcpPaymentResponse = fromMcpPaymentResponse; exports.getDirectoryInfo = getDirectoryInfo; exports.isMcpPaymentRequired = isMcpPaymentRequired; exports.isPermit2ProxyChain = isPermit2ProxyChain; exports.isUptoProxyChain = isUptoProxyChain; exports.knownFacilitatorsFor = knownFacilitatorsFor; exports.memorySpendStore = _chunkO4UQOZ4Zcjs.memorySpendStore; exports.normalizeNetwork = normalizeNetwork; exports.parseChallenge = parseChallenge; exports.parseExactObject = parseExactObject; exports.parseExactPaymentHeader = parseExactPaymentHeader; exports.parseExactRequirements = parseExactRequirements; exports.parseFacilitatorSupported = parseFacilitatorSupported; exports.parseReceipt = parseReceipt; exports.parseReceiptExtension = parseReceiptExtension; exports.parseSettleResponse = parseSettleResponse; exports.parseSignatureHeader = parseSignatureHeader; exports.parseSignatureObject = parseSignatureObject; exports.parseUptoObject = parseUptoObject; exports.parseUptoPaymentHeader = parseUptoPaymentHeader; exports.paymentTools = paymentTools; exports.pickAccept = pickAccept; exports.planAcross = planAcross; exports.proxyTo = proxyTo; exports.rankResources = rankResources; exports.readExactDomain = readExactDomain; exports.readPaymentIdentifier = readPaymentIdentifier; exports.register402Index = register402Index; exports.registerDriver = registerDriver; exports.registerX402Scan = registerX402Scan; exports.renderLandingPage = renderLandingPage; exports.requirePayment = requirePayment; exports.resolveChain = resolveChain; exports.scoreResource = scoreResource; exports.searchOpenIndexes = searchOpenIndexes; exports.settleViaFacilitator = settleViaFacilitator; exports.summarizePlan = summarizePlan; exports.toA2AErrorCode = toA2AErrorCode; exports.toA2APaymentFailed = toA2APaymentFailed; exports.toA2APaymentReceipts = toA2APaymentReceipts; exports.toA2APaymentRequired = toA2APaymentRequired; exports.toFetchHandler = toFetchHandler; exports.toInsufficientFundsError = _chunkQONQSZHJcjs.toInsufficientFundsError; exports.toInvalidBody = toInvalidBody; exports.toMcpPaymentRequired = toMcpPaymentRequired; exports.toMcpPaymentResponse = toMcpPaymentResponse; exports.toWorker = toWorker; exports.verify402IndexDomain = verify402IndexDomain;
|