@piprail/sdk 2.13.0 → 2.13.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 +26 -0
- package/dist/{algorand-FCEECDG6.cjs → algorand-AQK5EAUF.cjs} +32 -32
- package/dist/{algorand-AA3WXKW4.js → algorand-TQCYK2XT.js} +1 -1
- package/dist/{aptos-GHJPO6JJ.cjs → aptos-65UX7GKA.cjs} +31 -31
- package/dist/{aptos-LY67Q6QF.js → aptos-RYQOSFBQ.js} +1 -1
- package/dist/{chunk-MWBT7MCE.cjs → chunk-DCOUJZPL.cjs} +6 -4
- package/dist/{chunk-SC2ZYDHD.js → chunk-O32N6MFN.js} +6 -4
- package/dist/index.cjs +154 -136
- package/dist/index.d.cts +11 -5
- package/dist/index.d.ts +11 -5
- package/dist/index.js +32 -14
- package/dist/{near-6KAQVVG2.cjs → near-UDPFA6SV.cjs} +26 -26
- package/dist/{near-FZBUICCS.js → near-VDATC5AV.js} +1 -1
- package/dist/{solana-MYF4HBO4.cjs → solana-RQNXFCZO.cjs} +32 -32
- package/dist/{solana-ELUWO6N5.js → solana-VYLWFNAH.js} +1 -1
- package/dist/{stellar-ASP2THL2.js → stellar-KBR4V77T.js} +1 -1
- package/dist/{stellar-CRWBSX4E.cjs → stellar-OK2HW5PZ.cjs} +20 -20
- package/dist/{sui-FZIKZNVI.js → sui-BXHB6D3W.js} +1 -1
- package/dist/{sui-Y4RLKKE2.cjs → sui-SVFBJFW5.cjs} +16 -16
- package/dist/{ton-AOR3EURW.cjs → ton-D7YN6BGR.cjs} +16 -16
- package/dist/{ton-7GKCTC5H.js → ton-NNKQFQ6U.js} +1 -1
- package/dist/{tron-BMCWN5SS.js → tron-W2D5PQXV.js} +1 -1
- package/dist/{tron-OMXB6EW2.cjs → tron-WZFU57NX.cjs} +25 -25
- package/dist/{xrpl-DD7TJL5L.js → xrpl-37E23W53.js} +1 -1
- package/dist/{xrpl-Y6SQNYLC.cjs → xrpl-5NHY3NEL.cjs} +20 -20
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -31,7 +31,7 @@ var _chunkCQQI5IJXcjs = require('./chunk-CQQI5IJX.cjs');
|
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
|
|
34
|
-
var
|
|
34
|
+
var _chunkDCOUJZPLcjs = require('./chunk-DCOUJZPL.cjs');
|
|
35
35
|
|
|
36
36
|
// src/drivers/registry.ts
|
|
37
37
|
var byFamily = /* @__PURE__ */ new Map();
|
|
@@ -60,13 +60,13 @@ function resolveNetwork(opts) {
|
|
|
60
60
|
const family = familyForChain(opts.chain);
|
|
61
61
|
const driver = byFamily.get(family);
|
|
62
62
|
if (!driver) {
|
|
63
|
-
throw new (0,
|
|
63
|
+
throw new (0, _chunkDCOUJZPLcjs.UnsupportedNetworkError)(
|
|
64
64
|
`No driver registered for the "${family}" family \u2014 it may not be mounted yet (use the async resolveNetwork()).`
|
|
65
65
|
);
|
|
66
66
|
}
|
|
67
67
|
const net = driver.resolve(opts);
|
|
68
68
|
if (!net) {
|
|
69
|
-
throw new (0,
|
|
69
|
+
throw new (0, _chunkDCOUJZPLcjs.UnsupportedNetworkError)(
|
|
70
70
|
`The ${family} driver didn't recognise this chain input.`
|
|
71
71
|
);
|
|
72
72
|
}
|
|
@@ -331,12 +331,12 @@ function resolveChain(input, rpcUrlOverride) {
|
|
|
331
331
|
|
|
332
332
|
var _accounts = require('viem/accounts');
|
|
333
333
|
function createWalletAdapter(config, resolved) {
|
|
334
|
-
|
|
334
|
+
_chunkDCOUJZPLcjs.assertNoLegacyWalletKey.call(void 0, config, "EVM");
|
|
335
335
|
if ("key" in config) {
|
|
336
336
|
const key = config.key;
|
|
337
337
|
if (typeof key !== "string" || !/^0x[0-9a-fA-F]{64}$/.test(key)) {
|
|
338
338
|
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).";
|
|
339
|
-
throw new (0,
|
|
339
|
+
throw new (0, _chunkDCOUJZPLcjs.WrongFamilyError)(
|
|
340
340
|
`chain is EVM; the wallet { key } is not a valid 0x\u2026 32-byte hex private key${hint}`
|
|
341
341
|
);
|
|
342
342
|
}
|
|
@@ -344,7 +344,7 @@ function createWalletAdapter(config, resolved) {
|
|
|
344
344
|
try {
|
|
345
345
|
account = _accounts.privateKeyToAccount.call(void 0, key);
|
|
346
346
|
} catch (err) {
|
|
347
|
-
throw new (0,
|
|
347
|
+
throw new (0, _chunkDCOUJZPLcjs.WrongFamilyError)(
|
|
348
348
|
`chain is EVM; the wallet { key } is not a valid 0x\u2026 32-byte hex private key: ${err instanceof Error ? err.message : String(err)}.`
|
|
349
349
|
);
|
|
350
350
|
}
|
|
@@ -354,12 +354,12 @@ function createWalletAdapter(config, resolved) {
|
|
|
354
354
|
}
|
|
355
355
|
const wc = config.walletClient;
|
|
356
356
|
if (!wc.account) {
|
|
357
|
-
throw new (0,
|
|
357
|
+
throw new (0, _chunkDCOUJZPLcjs.WrongFamilyError)(
|
|
358
358
|
"chain is EVM; the provided walletClient has no attached account. Use `createWalletClient({ account, chain, transport })`, or pass { key }."
|
|
359
359
|
);
|
|
360
360
|
}
|
|
361
361
|
if (wc.chain && wc.chain.id !== resolved.chainId) {
|
|
362
|
-
throw new (0,
|
|
362
|
+
throw new (0, _chunkDCOUJZPLcjs.WrongChainError)(
|
|
363
363
|
`PipRailClient: walletClient is on chain ${wc.chain.id} but the SDK was configured with chain ${resolved.chainId}. They must match.`
|
|
364
364
|
);
|
|
365
365
|
}
|
|
@@ -689,7 +689,7 @@ async function payExactEvm(input) {
|
|
|
689
689
|
code = void 0;
|
|
690
690
|
}
|
|
691
691
|
if (code && code !== "0x") {
|
|
692
|
-
throw new (0,
|
|
692
|
+
throw new (0, _chunkDCOUJZPLcjs.UnsupportedSchemeError)(
|
|
693
693
|
`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.`
|
|
694
694
|
);
|
|
695
695
|
}
|
|
@@ -699,13 +699,13 @@ async function payExactEvm(input) {
|
|
|
699
699
|
domain = await readExactDomain(publicClient, accept.asset);
|
|
700
700
|
}
|
|
701
701
|
if (!domain) {
|
|
702
|
-
throw new (0,
|
|
702
|
+
throw new (0, _chunkDCOUJZPLcjs.UnsupportedSchemeError)(
|
|
703
703
|
`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.`
|
|
704
704
|
);
|
|
705
705
|
}
|
|
706
706
|
const g = globalThis.crypto;
|
|
707
707
|
if (!_optionalChain([g, 'optionalAccess', _5 => _5.getRandomValues])) {
|
|
708
|
-
throw new (0,
|
|
708
|
+
throw new (0, _chunkDCOUJZPLcjs.UnsupportedSchemeError)(
|
|
709
709
|
"this runtime lacks Web Crypto (globalThis.crypto.getRandomValues); the exact rail needs a CSPRNG nonce."
|
|
710
710
|
);
|
|
711
711
|
}
|
|
@@ -962,7 +962,7 @@ async function verifyAndSettleExactEvm(input) {
|
|
|
962
962
|
args: writeArgs
|
|
963
963
|
});
|
|
964
964
|
} catch (err) {
|
|
965
|
-
throw new (0,
|
|
965
|
+
throw new (0, _chunkDCOUJZPLcjs.SettlementError)(
|
|
966
966
|
`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.`,
|
|
967
967
|
{ cause: err }
|
|
968
968
|
);
|
|
@@ -974,7 +974,7 @@ async function verifyAndSettleExactEvm(input) {
|
|
|
974
974
|
return { ok: false, error: "tx_reverted", detail: `Settlement tx ${txHash} reverted on-chain.` };
|
|
975
975
|
}
|
|
976
976
|
} catch (err) {
|
|
977
|
-
throw new (0,
|
|
977
|
+
throw new (0, _chunkDCOUJZPLcjs.SettlementError)(
|
|
978
978
|
`exact settle: broadcast ${txHash} but couldn't confirm it (${shorten(err instanceof Error ? err.message : String(err))}).`,
|
|
979
979
|
{ cause: err }
|
|
980
980
|
);
|
|
@@ -1105,7 +1105,7 @@ function shorten2(msg) {
|
|
|
1105
1105
|
function randomPermit2Nonce() {
|
|
1106
1106
|
const g = globalThis.crypto;
|
|
1107
1107
|
if (!_optionalChain([g, 'optionalAccess', _8 => _8.getRandomValues])) {
|
|
1108
|
-
throw new (0,
|
|
1108
|
+
throw new (0, _chunkDCOUJZPLcjs.UnsupportedSchemeError)(
|
|
1109
1109
|
"this runtime lacks Web Crypto (globalThis.crypto.getRandomValues); the permit2 rail needs a CSPRNG nonce."
|
|
1110
1110
|
);
|
|
1111
1111
|
}
|
|
@@ -1124,7 +1124,7 @@ async function ensurePermit2Allowance(input) {
|
|
|
1124
1124
|
args: [account.address, PERMIT2_ADDRESS]
|
|
1125
1125
|
});
|
|
1126
1126
|
} catch (err) {
|
|
1127
|
-
throw new (0,
|
|
1127
|
+
throw new (0, _chunkDCOUJZPLcjs.UnsupportedSchemeError)(
|
|
1128
1128
|
`permit2: couldn't read the Permit2 allowance for ${token} (${shorten2(err instanceof Error ? err.message : String(err))}).`
|
|
1129
1129
|
);
|
|
1130
1130
|
}
|
|
@@ -1141,7 +1141,7 @@ async function ensurePermit2Allowance(input) {
|
|
|
1141
1141
|
await publicClient.waitForTransactionReceipt({ hash, confirmations: 1 });
|
|
1142
1142
|
return hash;
|
|
1143
1143
|
} catch (err) {
|
|
1144
|
-
throw _nullishCoalesce(
|
|
1144
|
+
throw _nullishCoalesce(_chunkDCOUJZPLcjs.toInsufficientFundsError.call(void 0, err), () => ( new (0, _chunkDCOUJZPLcjs.SettlementError)(
|
|
1145
1145
|
`permit2: the one-time Permit2 approval for ${token} failed to broadcast (${shorten2(err instanceof Error ? err.message : String(err))}).`,
|
|
1146
1146
|
{ cause: err }
|
|
1147
1147
|
)));
|
|
@@ -1156,7 +1156,7 @@ async function payPermit2Evm(input) {
|
|
|
1156
1156
|
code = void 0;
|
|
1157
1157
|
}
|
|
1158
1158
|
if (code && code !== "0x") {
|
|
1159
|
-
throw new (0,
|
|
1159
|
+
throw new (0, _chunkDCOUJZPLcjs.UnsupportedSchemeError)(
|
|
1160
1160
|
`permit2 buyer rail requires an EOA signer; ${account.address} is a contract / EIP-1271 / EIP-7702-delegated account. Pay via onchain-proof.`
|
|
1161
1161
|
);
|
|
1162
1162
|
}
|
|
@@ -1331,7 +1331,7 @@ async function verifyAndSettlePermit2Evm(input) {
|
|
|
1331
1331
|
args: settleArgs
|
|
1332
1332
|
});
|
|
1333
1333
|
} catch (err) {
|
|
1334
|
-
throw new (0,
|
|
1334
|
+
throw new (0, _chunkDCOUJZPLcjs.SettlementError)(
|
|
1335
1335
|
`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.`,
|
|
1336
1336
|
{ cause: err }
|
|
1337
1337
|
);
|
|
@@ -1343,7 +1343,7 @@ async function verifyAndSettlePermit2Evm(input) {
|
|
|
1343
1343
|
return { ok: false, error: "tx_reverted", detail: `Settlement tx ${txHash} reverted on-chain.` };
|
|
1344
1344
|
}
|
|
1345
1345
|
} catch (err) {
|
|
1346
|
-
throw new (0,
|
|
1346
|
+
throw new (0, _chunkDCOUJZPLcjs.SettlementError)(
|
|
1347
1347
|
`permit2 settle: broadcast ${txHash} but couldn't confirm it (${shorten2(err instanceof Error ? err.message : String(err))}).`,
|
|
1348
1348
|
{ cause: err }
|
|
1349
1349
|
);
|
|
@@ -1441,7 +1441,7 @@ function shorten3(msg) {
|
|
|
1441
1441
|
function randomPermit2Nonce2() {
|
|
1442
1442
|
const g = globalThis.crypto;
|
|
1443
1443
|
if (!_optionalChain([g, 'optionalAccess', _9 => _9.getRandomValues])) {
|
|
1444
|
-
throw new (0,
|
|
1444
|
+
throw new (0, _chunkDCOUJZPLcjs.UnsupportedSchemeError)(
|
|
1445
1445
|
"this runtime lacks Web Crypto (globalThis.crypto.getRandomValues); the upto rail needs a CSPRNG nonce."
|
|
1446
1446
|
);
|
|
1447
1447
|
}
|
|
@@ -1458,13 +1458,13 @@ async function payUptoEvm(input) {
|
|
|
1458
1458
|
code = void 0;
|
|
1459
1459
|
}
|
|
1460
1460
|
if (code && code !== "0x") {
|
|
1461
|
-
throw new (0,
|
|
1461
|
+
throw new (0, _chunkDCOUJZPLcjs.UnsupportedSchemeError)(
|
|
1462
1462
|
`upto buyer rail requires an EOA signer; ${account.address} is a contract / EIP-1271 / EIP-7702-delegated account. Pay via onchain-proof.`
|
|
1463
1463
|
);
|
|
1464
1464
|
}
|
|
1465
1465
|
const facilitatorAddress = _optionalChain([accept, 'access', _10 => _10.extra, 'optionalAccess', _11 => _11.facilitatorAddress]);
|
|
1466
1466
|
if (typeof facilitatorAddress !== "string" || facilitatorAddress.length === 0) {
|
|
1467
|
-
throw new (0,
|
|
1467
|
+
throw new (0, _chunkDCOUJZPLcjs.UnsupportedSchemeError)(
|
|
1468
1468
|
`upto: the rail carries no extra.facilitatorAddress to bind into witness.facilitator \u2014 refusing to sign.`
|
|
1469
1469
|
);
|
|
1470
1470
|
}
|
|
@@ -1685,7 +1685,7 @@ async function verifyAndSettleUptoEvm(input) {
|
|
|
1685
1685
|
args: settleArgs
|
|
1686
1686
|
});
|
|
1687
1687
|
} catch (err) {
|
|
1688
|
-
throw new (0,
|
|
1688
|
+
throw new (0, _chunkDCOUJZPLcjs.SettlementError)(
|
|
1689
1689
|
`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.`,
|
|
1690
1690
|
{ cause: err }
|
|
1691
1691
|
);
|
|
@@ -1697,7 +1697,7 @@ async function verifyAndSettleUptoEvm(input) {
|
|
|
1697
1697
|
return { ok: false, error: "tx_reverted", detail: `Settlement tx ${txHash} reverted on-chain.` };
|
|
1698
1698
|
}
|
|
1699
1699
|
} catch (err) {
|
|
1700
|
-
throw new (0,
|
|
1700
|
+
throw new (0, _chunkDCOUJZPLcjs.SettlementError)(
|
|
1701
1701
|
`upto settle: broadcast ${txHash} but couldn't confirm it (${shorten3(err instanceof Error ? err.message : String(err))}).`,
|
|
1702
1702
|
{ cause: err }
|
|
1703
1703
|
);
|
|
@@ -2027,15 +2027,15 @@ function makeEvmNetwork(resolved) {
|
|
|
2027
2027
|
const info = resolved.tokens[token.toUpperCase()];
|
|
2028
2028
|
if (!info) {
|
|
2029
2029
|
const known = Object.keys(resolved.tokens).join(", ") || "(none built in)";
|
|
2030
|
-
throw new (0,
|
|
2030
|
+
throw new (0, _chunkDCOUJZPLcjs.UnknownTokenError)(
|
|
2031
2031
|
`token "${token}" isn't built in for ${resolved.chain.name} (known: ${known}). Pass { address, decimals } instead, or use 'native'.`
|
|
2032
2032
|
);
|
|
2033
2033
|
}
|
|
2034
2034
|
return { asset: info.address, decimals: info.decimals, symbol: info.symbol };
|
|
2035
2035
|
}
|
|
2036
|
-
|
|
2036
|
+
_chunkDCOUJZPLcjs.rejectForeignToken.call(void 0, token, "evm", network);
|
|
2037
2037
|
if (!("address" in token)) {
|
|
2038
|
-
throw new (0,
|
|
2038
|
+
throw new (0, _chunkDCOUJZPLcjs.WrongFamilyError)(
|
|
2039
2039
|
`chain ${network} is EVM; a custom token must be { address, decimals }.`
|
|
2040
2040
|
);
|
|
2041
2041
|
}
|
|
@@ -2067,20 +2067,20 @@ function makeEvmNetwork(resolved) {
|
|
|
2067
2067
|
},
|
|
2068
2068
|
assertValidPayTo(payTo) {
|
|
2069
2069
|
if (!_viem.isAddress.call(void 0, payTo)) {
|
|
2070
|
-
throw new (0,
|
|
2070
|
+
throw new (0, _chunkDCOUJZPLcjs.WrongFamilyError)(
|
|
2071
2071
|
`chain ${network} is EVM, but payTo "${payTo}" is not a valid 0x address.`
|
|
2072
2072
|
);
|
|
2073
2073
|
}
|
|
2074
2074
|
},
|
|
2075
2075
|
bindWallet(wallet) {
|
|
2076
2076
|
if (typeof wallet !== "object" || wallet === null) {
|
|
2077
|
-
throw new (0,
|
|
2077
|
+
throw new (0, _chunkDCOUJZPLcjs.WrongFamilyError)(
|
|
2078
2078
|
`chain ${network} is EVM; wallet must be { key } (0x\u2026 hex) or { walletClient }.`
|
|
2079
2079
|
);
|
|
2080
2080
|
}
|
|
2081
|
-
|
|
2081
|
+
_chunkDCOUJZPLcjs.assertNoLegacyWalletKey.call(void 0, wallet, "EVM");
|
|
2082
2082
|
if (!("key" in wallet) && !("walletClient" in wallet)) {
|
|
2083
|
-
throw new (0,
|
|
2083
|
+
throw new (0, _chunkDCOUJZPLcjs.WrongFamilyError)(
|
|
2084
2084
|
`chain ${network} is EVM; wallet must be { key } (0x\u2026 hex) or { walletClient }.`
|
|
2085
2085
|
);
|
|
2086
2086
|
}
|
|
@@ -2097,12 +2097,12 @@ function makeEvmNetwork(resolved) {
|
|
|
2097
2097
|
});
|
|
2098
2098
|
} catch (err) {
|
|
2099
2099
|
if (isViemInsufficientFunds(err)) {
|
|
2100
|
-
throw new (0,
|
|
2100
|
+
throw new (0, _chunkDCOUJZPLcjs.InsufficientFundsError)(
|
|
2101
2101
|
err instanceof Error ? err.message : "Insufficient funds for payment.",
|
|
2102
2102
|
{ cause: err }
|
|
2103
2103
|
);
|
|
2104
2104
|
}
|
|
2105
|
-
throw _nullishCoalesce(
|
|
2105
|
+
throw _nullishCoalesce(_chunkDCOUJZPLcjs.toInsufficientFundsError.call(void 0, err), () => ( err));
|
|
2106
2106
|
}
|
|
2107
2107
|
},
|
|
2108
2108
|
async confirm(ref, minConfirmations) {
|
|
@@ -2113,7 +2113,7 @@ function makeEvmNetwork(resolved) {
|
|
|
2113
2113
|
});
|
|
2114
2114
|
return { height: receipt.blockNumber.toString() };
|
|
2115
2115
|
} catch (err) {
|
|
2116
|
-
throw new (0,
|
|
2116
|
+
throw new (0, _chunkDCOUJZPLcjs.ConfirmationTimeoutError)(
|
|
2117
2117
|
`EVM tx ${ref} did not reach ${minConfirmations} confirmation(s) in time.`,
|
|
2118
2118
|
{ cause: err }
|
|
2119
2119
|
);
|
|
@@ -2124,7 +2124,7 @@ function makeEvmNetwork(resolved) {
|
|
|
2124
2124
|
if (accept.scheme === "exact") {
|
|
2125
2125
|
const m = accept.extra.assetTransferMethod;
|
|
2126
2126
|
const permit2 = m === "permit2" || m === "permit2-exact";
|
|
2127
|
-
return
|
|
2127
|
+
return _chunkDCOUJZPLcjs.nativeCost.call(void 0, {
|
|
2128
2128
|
symbol,
|
|
2129
2129
|
decimals,
|
|
2130
2130
|
fee: 0n,
|
|
@@ -2135,7 +2135,7 @@ function makeEvmNetwork(resolved) {
|
|
|
2135
2135
|
const gasLimit = accept.asset === "native" ? 21000n : 65000n;
|
|
2136
2136
|
try {
|
|
2137
2137
|
const gasPrice = await publicClient.getGasPrice();
|
|
2138
|
-
return
|
|
2138
|
+
return _chunkDCOUJZPLcjs.nativeCost.call(void 0, {
|
|
2139
2139
|
symbol,
|
|
2140
2140
|
decimals,
|
|
2141
2141
|
fee: gasPrice * gasLimit,
|
|
@@ -2144,7 +2144,7 @@ function makeEvmNetwork(resolved) {
|
|
|
2144
2144
|
});
|
|
2145
2145
|
} catch (e23) {
|
|
2146
2146
|
const gasPrice = 5000000000n;
|
|
2147
|
-
return
|
|
2147
|
+
return _chunkDCOUJZPLcjs.nativeCost.call(void 0, {
|
|
2148
2148
|
symbol,
|
|
2149
2149
|
decimals,
|
|
2150
2150
|
fee: gasPrice * gasLimit,
|
|
@@ -2329,9 +2329,9 @@ var loaders = {
|
|
|
2329
2329
|
solana: async () => {
|
|
2330
2330
|
let mod;
|
|
2331
2331
|
try {
|
|
2332
|
-
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./solana-
|
|
2332
|
+
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./solana-RQNXFCZO.cjs")));
|
|
2333
2333
|
} catch (cause) {
|
|
2334
|
-
throw new (0,
|
|
2334
|
+
throw new (0, _chunkDCOUJZPLcjs.MissingDriverError)(
|
|
2335
2335
|
`Solana selected, but its packages aren't installed. Run: npm install @solana/web3.js @solana/spl-token bs58`,
|
|
2336
2336
|
{ cause }
|
|
2337
2337
|
);
|
|
@@ -2341,9 +2341,9 @@ var loaders = {
|
|
|
2341
2341
|
ton: async () => {
|
|
2342
2342
|
let mod;
|
|
2343
2343
|
try {
|
|
2344
|
-
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./ton-
|
|
2344
|
+
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./ton-D7YN6BGR.cjs")));
|
|
2345
2345
|
} catch (cause) {
|
|
2346
|
-
throw new (0,
|
|
2346
|
+
throw new (0, _chunkDCOUJZPLcjs.MissingDriverError)(
|
|
2347
2347
|
`TON selected, but its packages aren't installed. Run: npm install @ton/ton @ton/core @ton/crypto`,
|
|
2348
2348
|
{ cause }
|
|
2349
2349
|
);
|
|
@@ -2353,9 +2353,9 @@ var loaders = {
|
|
|
2353
2353
|
stellar: async () => {
|
|
2354
2354
|
let mod;
|
|
2355
2355
|
try {
|
|
2356
|
-
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./stellar-
|
|
2356
|
+
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./stellar-OK2HW5PZ.cjs")));
|
|
2357
2357
|
} catch (cause) {
|
|
2358
|
-
throw new (0,
|
|
2358
|
+
throw new (0, _chunkDCOUJZPLcjs.MissingDriverError)(
|
|
2359
2359
|
`Stellar selected, but its package isn't installed. Run: npm install @stellar/stellar-sdk`,
|
|
2360
2360
|
{ cause }
|
|
2361
2361
|
);
|
|
@@ -2365,9 +2365,9 @@ var loaders = {
|
|
|
2365
2365
|
xrpl: async () => {
|
|
2366
2366
|
let mod;
|
|
2367
2367
|
try {
|
|
2368
|
-
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./xrpl-
|
|
2368
|
+
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./xrpl-5NHY3NEL.cjs")));
|
|
2369
2369
|
} catch (cause) {
|
|
2370
|
-
throw new (0,
|
|
2370
|
+
throw new (0, _chunkDCOUJZPLcjs.MissingDriverError)(
|
|
2371
2371
|
`XRPL selected, but its package isn't installed. Run: npm install xrpl`,
|
|
2372
2372
|
{ cause }
|
|
2373
2373
|
);
|
|
@@ -2377,9 +2377,9 @@ var loaders = {
|
|
|
2377
2377
|
tron: async () => {
|
|
2378
2378
|
let mod;
|
|
2379
2379
|
try {
|
|
2380
|
-
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./tron-
|
|
2380
|
+
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./tron-WZFU57NX.cjs")));
|
|
2381
2381
|
} catch (cause) {
|
|
2382
|
-
throw new (0,
|
|
2382
|
+
throw new (0, _chunkDCOUJZPLcjs.MissingDriverError)(
|
|
2383
2383
|
`Tron selected, but its package isn't installed. Run: npm install tronweb`,
|
|
2384
2384
|
{ cause }
|
|
2385
2385
|
);
|
|
@@ -2389,9 +2389,9 @@ var loaders = {
|
|
|
2389
2389
|
sui: async () => {
|
|
2390
2390
|
let mod;
|
|
2391
2391
|
try {
|
|
2392
|
-
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./sui-
|
|
2392
|
+
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./sui-SVFBJFW5.cjs")));
|
|
2393
2393
|
} catch (cause) {
|
|
2394
|
-
throw new (0,
|
|
2394
|
+
throw new (0, _chunkDCOUJZPLcjs.MissingDriverError)(
|
|
2395
2395
|
`Sui selected, but its package isn't installed. Run: npm install @mysten/sui`,
|
|
2396
2396
|
{ cause }
|
|
2397
2397
|
);
|
|
@@ -2401,9 +2401,9 @@ var loaders = {
|
|
|
2401
2401
|
near: async () => {
|
|
2402
2402
|
let mod;
|
|
2403
2403
|
try {
|
|
2404
|
-
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./near-
|
|
2404
|
+
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./near-UDPFA6SV.cjs")));
|
|
2405
2405
|
} catch (cause) {
|
|
2406
|
-
throw new (0,
|
|
2406
|
+
throw new (0, _chunkDCOUJZPLcjs.MissingDriverError)(
|
|
2407
2407
|
`NEAR selected, but its package isn't installed. Run: npm install near-api-js`,
|
|
2408
2408
|
{ cause }
|
|
2409
2409
|
);
|
|
@@ -2413,9 +2413,9 @@ var loaders = {
|
|
|
2413
2413
|
aptos: async () => {
|
|
2414
2414
|
let mod;
|
|
2415
2415
|
try {
|
|
2416
|
-
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./aptos-
|
|
2416
|
+
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./aptos-65UX7GKA.cjs")));
|
|
2417
2417
|
} catch (cause) {
|
|
2418
|
-
throw new (0,
|
|
2418
|
+
throw new (0, _chunkDCOUJZPLcjs.MissingDriverError)(
|
|
2419
2419
|
`Aptos selected, but its package isn't installed. Run: npm install @aptos-labs/ts-sdk`,
|
|
2420
2420
|
{ cause }
|
|
2421
2421
|
);
|
|
@@ -2425,9 +2425,9 @@ var loaders = {
|
|
|
2425
2425
|
algorand: async () => {
|
|
2426
2426
|
let mod;
|
|
2427
2427
|
try {
|
|
2428
|
-
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./algorand-
|
|
2428
|
+
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./algorand-AQK5EAUF.cjs")));
|
|
2429
2429
|
} catch (cause) {
|
|
2430
|
-
throw new (0,
|
|
2430
|
+
throw new (0, _chunkDCOUJZPLcjs.MissingDriverError)(
|
|
2431
2431
|
`Algorand selected, but its package isn't installed. Run: npm install algosdk`,
|
|
2432
2432
|
{ cause }
|
|
2433
2433
|
);
|
|
@@ -3071,7 +3071,7 @@ function encodeBase642(str) {
|
|
|
3071
3071
|
}
|
|
3072
3072
|
|
|
3073
3073
|
// src/policy.ts
|
|
3074
|
-
var DENOM_PRECISION =
|
|
3074
|
+
var DENOM_PRECISION = _chunkDCOUJZPLcjs.MAX_DECIMALS;
|
|
3075
3075
|
var BUILTIN_DENOMS = {
|
|
3076
3076
|
USDC: "USD",
|
|
3077
3077
|
USDT: "USD",
|
|
@@ -3186,7 +3186,7 @@ function evaluatePolicy(intent, policy, spentForAssetBase, ctx) {
|
|
|
3186
3186
|
}
|
|
3187
3187
|
}
|
|
3188
3188
|
if (policy.maxAmount !== void 0) {
|
|
3189
|
-
const cap =
|
|
3189
|
+
const cap = _chunkDCOUJZPLcjs.floorUnits.call(void 0, policy.maxAmount, intent.decimals);
|
|
3190
3190
|
if (intent.amountBase > cap) {
|
|
3191
3191
|
return deny(
|
|
3192
3192
|
"MAX_AMOUNT",
|
|
@@ -3195,7 +3195,7 @@ function evaluatePolicy(intent, policy, spentForAssetBase, ctx) {
|
|
|
3195
3195
|
}
|
|
3196
3196
|
}
|
|
3197
3197
|
if (policy.maxTotal !== void 0) {
|
|
3198
|
-
const cap =
|
|
3198
|
+
const cap = _chunkDCOUJZPLcjs.floorUnits.call(void 0, policy.maxTotal, intent.decimals);
|
|
3199
3199
|
if (spentForAssetBase + intent.amountBase > cap) {
|
|
3200
3200
|
return deny(
|
|
3201
3201
|
"MAX_TOTAL",
|
|
@@ -3214,7 +3214,7 @@ function evaluatePolicy(intent, policy, spentForAssetBase, ctx) {
|
|
|
3214
3214
|
`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).`
|
|
3215
3215
|
);
|
|
3216
3216
|
}
|
|
3217
|
-
const capScaled =
|
|
3217
|
+
const capScaled = _chunkDCOUJZPLcjs.floorUnits.call(void 0, capStr, DENOM_PRECISION);
|
|
3218
3218
|
if ((_nullishCoalesce(ctx.spentInDenomScaled, () => ( 0n))) + thisScaled > capScaled) {
|
|
3219
3219
|
return deny(
|
|
3220
3220
|
"MAX_TOTAL_DENOM",
|
|
@@ -3232,7 +3232,7 @@ function evaluatePolicy(intent, policy, spentForAssetBase, ctx) {
|
|
|
3232
3232
|
}
|
|
3233
3233
|
}
|
|
3234
3234
|
if (ctx && policy.windowTotal !== void 0 && policy.windowSeconds !== void 0) {
|
|
3235
|
-
const cap =
|
|
3235
|
+
const cap = _chunkDCOUJZPLcjs.floorUnits.call(void 0, policy.windowTotal, intent.decimals);
|
|
3236
3236
|
if (ctx.spentInWindowBase + intent.amountBase > cap) {
|
|
3237
3237
|
return deny(
|
|
3238
3238
|
"WINDOW_TOTAL",
|
|
@@ -3298,7 +3298,7 @@ var SpendLedger = (_class = class {
|
|
|
3298
3298
|
* read or the constructor.
|
|
3299
3299
|
*/
|
|
3300
3300
|
isTallyable(r, decimals) {
|
|
3301
|
-
return !!r && typeof r.amountBase === "string" && /^\d+$/.test(r.amountBase) && Number.isInteger(decimals) && decimals >= 0 && decimals <=
|
|
3301
|
+
return !!r && typeof r.amountBase === "string" && /^\d+$/.test(r.amountBase) && Number.isInteger(decimals) && decimals >= 0 && decimals <= _chunkDCOUJZPLcjs.MAX_DECIMALS;
|
|
3302
3302
|
}
|
|
3303
3303
|
/** Apply a record to the in-memory tallies (records + per-asset bucket + denom total).
|
|
3304
3304
|
* Shared by {@link record} and constructor hydration; does NOT persist. Returns the
|
|
@@ -3435,13 +3435,13 @@ var SpendLedger = (_class = class {
|
|
|
3435
3435
|
symbol: b.symbol,
|
|
3436
3436
|
decimals: b.decimals,
|
|
3437
3437
|
totalBase: b.total.toString(),
|
|
3438
|
-
totalFormatted:
|
|
3438
|
+
totalFormatted: _chunkDCOUJZPLcjs.formatUnits.call(void 0, b.total, b.decimals),
|
|
3439
3439
|
count: b.count
|
|
3440
3440
|
})),
|
|
3441
3441
|
byDenom: [...this.denomTotals.entries()].map(([denom, scaled]) => ({
|
|
3442
3442
|
denom,
|
|
3443
3443
|
totalScaled: scaled.toString(),
|
|
3444
|
-
totalFormatted:
|
|
3444
|
+
totalFormatted: _chunkDCOUJZPLcjs.formatUnits.call(void 0, scaled, DENOM_PRECISION),
|
|
3445
3445
|
count: this.records.filter((r) => _optionalChain([r, 'access', _32 => _32.denom, 'optionalAccess', _33 => _33.toUpperCase, 'call', _34 => _34()]) === denom).length
|
|
3446
3446
|
})),
|
|
3447
3447
|
records: [...this.records]
|
|
@@ -3449,6 +3449,24 @@ var SpendLedger = (_class = class {
|
|
|
3449
3449
|
}
|
|
3450
3450
|
}, _class);
|
|
3451
3451
|
|
|
3452
|
+
// src/util/exactRecovery.ts
|
|
3453
|
+
function exactSettleCheckHint(family, payerFrom, nonce) {
|
|
3454
|
+
switch (family) {
|
|
3455
|
+
case "evm":
|
|
3456
|
+
return `the EIP-3009 \`authorizationState(${payerFrom}, ${nonce})\` (or, on the Permit2 method, the Permit2 nonce bitmap)`;
|
|
3457
|
+
case "solana":
|
|
3458
|
+
return `the buyer's transaction signature (a duplicate signature is the chain's own replay guard; plus the SPL-Memo nonce when present)`;
|
|
3459
|
+
case "algorand":
|
|
3460
|
+
return `the atomic group / transaction id`;
|
|
3461
|
+
case "aptos":
|
|
3462
|
+
return `the sender's account sequence number`;
|
|
3463
|
+
case "near":
|
|
3464
|
+
return `the access-key nonce (\`${nonce}\`)`;
|
|
3465
|
+
default:
|
|
3466
|
+
return `the single-use marker (\`ref=${nonce}\`)`;
|
|
3467
|
+
}
|
|
3468
|
+
}
|
|
3469
|
+
|
|
3452
3470
|
// src/client.ts
|
|
3453
3471
|
var DEFAULT_SCHEMES = ["onchain-proof"];
|
|
3454
3472
|
var RECIPIENT_FIX = {
|
|
@@ -3831,7 +3849,7 @@ var PipRailClient = (_class2 = class {
|
|
|
3831
3849
|
const cost = await net.estimateCost(accept);
|
|
3832
3850
|
return { quote, cost };
|
|
3833
3851
|
} catch (err) {
|
|
3834
|
-
if (err instanceof
|
|
3852
|
+
if (err instanceof _chunkDCOUJZPLcjs.InvalidEnvelopeError) return null;
|
|
3835
3853
|
throw err;
|
|
3836
3854
|
}
|
|
3837
3855
|
}
|
|
@@ -3883,14 +3901,14 @@ var PipRailClient = (_class2 = class {
|
|
|
3883
3901
|
return Object.entries(caps).map(([rawDenom, capStr]) => {
|
|
3884
3902
|
const denom = rawDenom.toUpperCase();
|
|
3885
3903
|
const spentScaled = this.ledger.totalForDenom(denom);
|
|
3886
|
-
const capScaled =
|
|
3904
|
+
const capScaled = _chunkDCOUJZPLcjs.floorUnits.call(void 0, capStr, DENOM_PRECISION);
|
|
3887
3905
|
const remainingScaled = capScaled > spentScaled ? capScaled - spentScaled : 0n;
|
|
3888
3906
|
const fraction = capScaled === 0n ? spentScaled > 0n ? 1 : 0 : Number(spentScaled * 1000000n / capScaled) / 1e6;
|
|
3889
3907
|
return {
|
|
3890
3908
|
denom,
|
|
3891
|
-
spentFormatted:
|
|
3892
|
-
capFormatted:
|
|
3893
|
-
remainingFormatted:
|
|
3909
|
+
spentFormatted: _chunkDCOUJZPLcjs.formatUnits.call(void 0, spentScaled, DENOM_PRECISION),
|
|
3910
|
+
capFormatted: _chunkDCOUJZPLcjs.formatUnits.call(void 0, capScaled, DENOM_PRECISION),
|
|
3911
|
+
remainingFormatted: _chunkDCOUJZPLcjs.formatUnits.call(void 0, remainingScaled, DENOM_PRECISION),
|
|
3894
3912
|
fraction
|
|
3895
3913
|
};
|
|
3896
3914
|
});
|
|
@@ -3931,13 +3949,13 @@ var PipRailClient = (_class2 = class {
|
|
|
3931
3949
|
spentBase: b.totalBase.toString()
|
|
3932
3950
|
};
|
|
3933
3951
|
if (maxTotal === void 0) return base2;
|
|
3934
|
-
const capBase =
|
|
3952
|
+
const capBase = _chunkDCOUJZPLcjs.floorUnits.call(void 0, maxTotal, b.decimals);
|
|
3935
3953
|
const remainingBase = capBase > b.totalBase ? capBase - b.totalBase : 0n;
|
|
3936
3954
|
return {
|
|
3937
3955
|
...base2,
|
|
3938
3956
|
capBase: capBase.toString(),
|
|
3939
3957
|
remainingBase: remainingBase.toString(),
|
|
3940
|
-
remainingFormatted:
|
|
3958
|
+
remainingFormatted: _chunkDCOUJZPLcjs.formatUnits.call(void 0, remainingBase, b.decimals)
|
|
3941
3959
|
};
|
|
3942
3960
|
});
|
|
3943
3961
|
}
|
|
@@ -3977,11 +3995,11 @@ var PipRailClient = (_class2 = class {
|
|
|
3977
3995
|
if (res.status !== 402) return null;
|
|
3978
3996
|
const challenge = await parseChallenge(res);
|
|
3979
3997
|
if (!challenge) {
|
|
3980
|
-
throw new (0,
|
|
3998
|
+
throw new (0, _chunkDCOUJZPLcjs.InvalidEnvelopeError)("402 response did not include a parseable x402 challenge.");
|
|
3981
3999
|
}
|
|
3982
4000
|
const { net, wallet } = await this.ensure();
|
|
3983
4001
|
if (!wallet) {
|
|
3984
|
-
throw new (0,
|
|
4002
|
+
throw new (0, _chunkDCOUJZPLcjs.WalletRequiredError)(
|
|
3985
4003
|
"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."
|
|
3986
4004
|
);
|
|
3987
4005
|
}
|
|
@@ -4156,7 +4174,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4156
4174
|
async fetch(url, init) {
|
|
4157
4175
|
const body = _optionalChain([init, 'optionalAccess', _55 => _55.body]);
|
|
4158
4176
|
if (body !== void 0 && body !== null && !isReplayableBodyInit(body)) {
|
|
4159
|
-
throw new (0,
|
|
4177
|
+
throw new (0, _chunkDCOUJZPLcjs.NonReplayableBodyError)(
|
|
4160
4178
|
"fetch(): init.body is not replayable. Pass a string, FormData, URLSearchParams, ArrayBuffer, or Blob \u2014 not a ReadableStream."
|
|
4161
4179
|
);
|
|
4162
4180
|
}
|
|
@@ -4166,7 +4184,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4166
4184
|
const resolved = await this.resolveChallenge(url, firstResponse, schemes);
|
|
4167
4185
|
const { net, wallet, challenge } = resolved;
|
|
4168
4186
|
if (!wallet) {
|
|
4169
|
-
throw new (0,
|
|
4187
|
+
throw new (0, _chunkDCOUJZPLcjs.WalletRequiredError)(
|
|
4170
4188
|
"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)."
|
|
4171
4189
|
);
|
|
4172
4190
|
}
|
|
@@ -4178,7 +4196,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4178
4196
|
if (!plan.best) {
|
|
4179
4197
|
const reason = _nullishCoalesce(plan.fundingHint, () => ( "No rail is settleable for this payment."));
|
|
4180
4198
|
this.safeEmit({ kind: "payment-failed", reason });
|
|
4181
|
-
throw new (0,
|
|
4199
|
+
throw new (0, _chunkDCOUJZPLcjs.PaymentDeclinedError)(reason);
|
|
4182
4200
|
}
|
|
4183
4201
|
accept = plan.best.accept;
|
|
4184
4202
|
quote = plan.best.quote;
|
|
@@ -4192,7 +4210,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4192
4210
|
return this.payExactRail(net, wallet, accept, url, init, quote);
|
|
4193
4211
|
}
|
|
4194
4212
|
if (accept.scheme !== "onchain-proof") {
|
|
4195
|
-
throw new (0,
|
|
4213
|
+
throw new (0, _chunkDCOUJZPLcjs.UnsupportedSchemeError)(
|
|
4196
4214
|
`internal: unrouted accept scheme '${accept.scheme}' reached the onchain-proof pay path.`
|
|
4197
4215
|
);
|
|
4198
4216
|
}
|
|
@@ -4210,7 +4228,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4210
4228
|
async resolveChallenge(url, response, schemes) {
|
|
4211
4229
|
const challenge = await parseChallenge(response);
|
|
4212
4230
|
if (!challenge) {
|
|
4213
|
-
throw new (0,
|
|
4231
|
+
throw new (0, _chunkDCOUJZPLcjs.InvalidEnvelopeError)(
|
|
4214
4232
|
"402 response did not include a parseable x402 challenge."
|
|
4215
4233
|
);
|
|
4216
4234
|
}
|
|
@@ -4221,7 +4239,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4221
4239
|
(a) => a.scheme === "exact" && this.supportsNetwork(net, a.network)
|
|
4222
4240
|
);
|
|
4223
4241
|
if (schemes.includes("exact") && exactOnNet && typeof net.payExact !== "function") {
|
|
4224
|
-
throw new (0,
|
|
4242
|
+
throw new (0, _chunkDCOUJZPLcjs.UnsupportedSchemeError)(
|
|
4225
4243
|
`This 402 offers a standard 'exact' rail on ${net.network}, but the ${net.family} family can't pay 'exact' (supported on EVM, Solana, Algorand + NEAR today), and no 'onchain-proof' rail was offered.`
|
|
4226
4244
|
);
|
|
4227
4245
|
}
|
|
@@ -4230,13 +4248,13 @@ var PipRailClient = (_class2 = class {
|
|
|
4230
4248
|
(a) => a.scheme === "exact" && this.supportsNetwork(net, a.network) && net.describeAsset(a.asset) != null
|
|
4231
4249
|
);
|
|
4232
4250
|
if (payable) {
|
|
4233
|
-
throw new (0,
|
|
4251
|
+
throw new (0, _chunkDCOUJZPLcjs.NoCompatibleAcceptError)(
|
|
4234
4252
|
`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).`
|
|
4235
4253
|
);
|
|
4236
4254
|
}
|
|
4237
4255
|
}
|
|
4238
4256
|
const networks = [...new Set(challenge.accepts.map((a) => a.network))].join(", ");
|
|
4239
|
-
throw new (0,
|
|
4257
|
+
throw new (0, _chunkDCOUJZPLcjs.NoCompatibleAcceptError)(
|
|
4240
4258
|
`No accepts[] entry payable by this client on ${net.network} (schemes: ${schemes.join(", ")}; challenge offered: ${networks || "none"}).`
|
|
4241
4259
|
);
|
|
4242
4260
|
}
|
|
@@ -4356,21 +4374,21 @@ var PipRailClient = (_class2 = class {
|
|
|
4356
4374
|
if (isExact) {
|
|
4357
4375
|
if (tokenKnown && bal.token < amount) {
|
|
4358
4376
|
blockers.push("INSUFFICIENT_TOKEN");
|
|
4359
|
-
shortfall.token =
|
|
4377
|
+
shortfall.token = _chunkDCOUJZPLcjs.formatUnits.call(void 0, amount - bal.token, quote.decimals);
|
|
4360
4378
|
}
|
|
4361
4379
|
} else if (isNative) {
|
|
4362
4380
|
if (nativeKnown && bal.native < amount + fee) {
|
|
4363
4381
|
blockers.push("INSUFFICIENT_TOKEN");
|
|
4364
|
-
shortfall.token =
|
|
4382
|
+
shortfall.token = _chunkDCOUJZPLcjs.formatUnits.call(void 0, amount + fee - bal.native, quote.decimals);
|
|
4365
4383
|
}
|
|
4366
4384
|
} else {
|
|
4367
4385
|
if (tokenKnown && bal.token < amount) {
|
|
4368
4386
|
blockers.push("INSUFFICIENT_TOKEN");
|
|
4369
|
-
shortfall.token =
|
|
4387
|
+
shortfall.token = _chunkDCOUJZPLcjs.formatUnits.call(void 0, amount - bal.token, quote.decimals);
|
|
4370
4388
|
}
|
|
4371
4389
|
if (nativeKnown && bal.native < fee) {
|
|
4372
4390
|
blockers.push("INSUFFICIENT_GAS");
|
|
4373
|
-
shortfall.native =
|
|
4391
|
+
shortfall.native = _chunkDCOUJZPLcjs.formatUnits.call(void 0, fee - bal.native, cost.feeDecimals);
|
|
4374
4392
|
} else if (nativeKnown && fee > 0n && bal.native < fee * 3n / 2n) {
|
|
4375
4393
|
warnings.push("THIN_GAS_MARGIN");
|
|
4376
4394
|
}
|
|
@@ -4395,8 +4413,8 @@ var PipRailClient = (_class2 = class {
|
|
|
4395
4413
|
blockers,
|
|
4396
4414
|
warnings,
|
|
4397
4415
|
balance: {
|
|
4398
|
-
token: bal.token != null ?
|
|
4399
|
-
native: bal.native != null ?
|
|
4416
|
+
token: bal.token != null ? _chunkDCOUJZPLcjs.formatUnits.call(void 0, bal.token, quote.decimals) : null,
|
|
4417
|
+
native: bal.native != null ? _chunkDCOUJZPLcjs.formatUnits.call(void 0, bal.native, cost.feeDecimals) : null
|
|
4400
4418
|
},
|
|
4401
4419
|
need: { token: quote.amountFormatted, native: cost.feeFormatted },
|
|
4402
4420
|
...shortfall.token || shortfall.native ? { shortfall } : {},
|
|
@@ -4407,12 +4425,12 @@ var PipRailClient = (_class2 = class {
|
|
|
4407
4425
|
* driver's describeAsset) + the policy verdict + a symbol-mismatch flag. */
|
|
4408
4426
|
buildQuote(net, accept, url, description) {
|
|
4409
4427
|
if (typeof accept.amount !== "string" || !/^\d+$/.test(accept.amount)) {
|
|
4410
|
-
throw new (0,
|
|
4428
|
+
throw new (0, _chunkDCOUJZPLcjs.InvalidEnvelopeError)(
|
|
4411
4429
|
`challenge amount "${String(accept.amount)}" is not a base-unit integer string.`
|
|
4412
4430
|
);
|
|
4413
4431
|
}
|
|
4414
4432
|
if (typeof accept.asset !== "string" || accept.asset.length === 0) {
|
|
4415
|
-
throw new (0,
|
|
4433
|
+
throw new (0, _chunkDCOUJZPLcjs.InvalidEnvelopeError)(
|
|
4416
4434
|
`challenge on ${accept.network} states no (string) asset \u2014 refusing to price it.`
|
|
4417
4435
|
);
|
|
4418
4436
|
}
|
|
@@ -4420,17 +4438,17 @@ var PipRailClient = (_class2 = class {
|
|
|
4420
4438
|
const described = net.describeAsset(accept.asset);
|
|
4421
4439
|
const decimals = _nullishCoalesce(_optionalChain([described, 'optionalAccess', _60 => _60.decimals]), () => ( _optionalChain([accept, 'access', _61 => _61.extra, 'optionalAccess', _62 => _62.decimals])));
|
|
4422
4440
|
if (typeof decimals !== "number" || !Number.isInteger(decimals) || decimals < 0) {
|
|
4423
|
-
throw new (0,
|
|
4441
|
+
throw new (0, _chunkDCOUJZPLcjs.InvalidEnvelopeError)(
|
|
4424
4442
|
`challenge for ${accept.asset} on ${accept.network} states no valid decimals and the SDK doesn't recognise the token \u2014 refusing to price it.`
|
|
4425
4443
|
);
|
|
4426
4444
|
}
|
|
4427
|
-
if (decimals >
|
|
4428
|
-
throw new (0,
|
|
4429
|
-
`challenge for ${accept.asset} on ${accept.network} states ${decimals} decimals (> ${
|
|
4445
|
+
if (decimals > _chunkDCOUJZPLcjs.MAX_DECIMALS) {
|
|
4446
|
+
throw new (0, _chunkDCOUJZPLcjs.InvalidEnvelopeError)(
|
|
4447
|
+
`challenge for ${accept.asset} on ${accept.network} states ${decimals} decimals (> ${_chunkDCOUJZPLcjs.MAX_DECIMALS}) \u2014 refusing to price it (no real token is that deep).`
|
|
4430
4448
|
);
|
|
4431
4449
|
}
|
|
4432
4450
|
const symbol = _nullishCoalesce(_optionalChain([described, 'optionalAccess', _63 => _63.symbol]), () => ( _optionalChain([accept, 'access', _64 => _64.extra, 'optionalAccess', _65 => _65.symbol])));
|
|
4433
|
-
const amountFormatted =
|
|
4451
|
+
const amountFormatted = _chunkDCOUJZPLcjs.formatUnits.call(void 0, amountBase, decimals);
|
|
4434
4452
|
const intent = {
|
|
4435
4453
|
host: hostOf2(url),
|
|
4436
4454
|
chain: this.opts.chain,
|
|
@@ -4535,7 +4553,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4535
4553
|
...opts.quote ? { quote: opts.quote } : {},
|
|
4536
4554
|
budget: this.budget()
|
|
4537
4555
|
});
|
|
4538
|
-
throw new (0,
|
|
4556
|
+
throw new (0, _chunkDCOUJZPLcjs.PaymentDeclinedError)(reason, {
|
|
4539
4557
|
...opts.reasonCode ? { reasonCode: opts.reasonCode } : {},
|
|
4540
4558
|
...opts.cause !== void 0 ? { cause: opts.cause } : {}
|
|
4541
4559
|
});
|
|
@@ -4567,7 +4585,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4567
4585
|
const max = BigInt(quote.amount);
|
|
4568
4586
|
const shown = claimed < max ? claimed : max;
|
|
4569
4587
|
settledBase = shown.toString();
|
|
4570
|
-
settledFormatted =
|
|
4588
|
+
settledFormatted = _chunkDCOUJZPLcjs.formatUnits.call(void 0, shown, quote.decimals);
|
|
4571
4589
|
} catch (e36) {
|
|
4572
4590
|
}
|
|
4573
4591
|
}
|
|
@@ -4618,8 +4636,8 @@ var PipRailClient = (_class2 = class {
|
|
|
4618
4636
|
fire(
|
|
4619
4637
|
"asset",
|
|
4620
4638
|
`${_nullishCoalesce(r.symbol, () => ( r.asset))} on ${r.network}`,
|
|
4621
|
-
|
|
4622
|
-
|
|
4639
|
+
_chunkDCOUJZPLcjs.formatUnits.call(void 0, spent, r.decimals),
|
|
4640
|
+
_chunkDCOUJZPLcjs.formatUnits.call(void 0, cap, r.decimals),
|
|
4623
4641
|
fraction
|
|
4624
4642
|
);
|
|
4625
4643
|
}
|
|
@@ -4630,14 +4648,14 @@ var PipRailClient = (_class2 = class {
|
|
|
4630
4648
|
if (_optionalChain([policy, 'optionalAccess', _71 => _71.windowTotal]) !== void 0 && policy.windowSeconds !== void 0) {
|
|
4631
4649
|
const since = Date.now() - policy.windowSeconds * 1e3;
|
|
4632
4650
|
for (const r of budget.byAsset) {
|
|
4633
|
-
const cap =
|
|
4651
|
+
const cap = _chunkDCOUJZPLcjs.floorUnits.call(void 0, policy.windowTotal, r.decimals);
|
|
4634
4652
|
const spent = this.ledger.totalSince(r.network, r.asset, since);
|
|
4635
4653
|
const fraction = cap === 0n ? spent > 0n ? 1 : 0 : Number(spent * 1000000n / cap) / 1e6;
|
|
4636
4654
|
fire(
|
|
4637
4655
|
"window",
|
|
4638
4656
|
`${_nullishCoalesce(r.symbol, () => ( r.asset))} on ${r.network}`,
|
|
4639
|
-
|
|
4640
|
-
|
|
4657
|
+
_chunkDCOUJZPLcjs.formatUnits.call(void 0, spent, r.decimals),
|
|
4658
|
+
_chunkDCOUJZPLcjs.formatUnits.call(void 0, cap, r.decimals),
|
|
4641
4659
|
fraction
|
|
4642
4660
|
);
|
|
4643
4661
|
}
|
|
@@ -4658,7 +4676,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4658
4676
|
}
|
|
4659
4677
|
async payAndConfirm(net, wallet, accept) {
|
|
4660
4678
|
if (!this.supportsNetwork(net, accept.network)) {
|
|
4661
|
-
throw new (0,
|
|
4679
|
+
throw new (0, _chunkDCOUJZPLcjs.WrongChainError)(
|
|
4662
4680
|
`Challenge expects ${accept.network} but client is on ${net.network}.`
|
|
4663
4681
|
);
|
|
4664
4682
|
}
|
|
@@ -4711,7 +4729,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4711
4729
|
});
|
|
4712
4730
|
} catch (err) {
|
|
4713
4731
|
if (timeoutController.signal.aborted) {
|
|
4714
|
-
throw new (0,
|
|
4732
|
+
throw new (0, _chunkDCOUJZPLcjs.PaymentTimeoutError)(
|
|
4715
4733
|
`Server did not respond within ${this.retryTimeoutMs}ms after broadcasting payment ${ref}. Re-verify or re-submit ref=${ref} \u2014 do NOT re-pay.`,
|
|
4716
4734
|
{ cause: err, ref }
|
|
4717
4735
|
);
|
|
@@ -4735,7 +4753,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4735
4753
|
reason: `server returned 402 after broadcasting payment ${ref}${unconfirmedNote} (${why})`,
|
|
4736
4754
|
...lastReason ? { code: lastReason.error, detail: lastReason.detail } : {}
|
|
4737
4755
|
});
|
|
4738
|
-
throw new (0,
|
|
4756
|
+
throw new (0, _chunkDCOUJZPLcjs.MaxRetriesExceededError)(
|
|
4739
4757
|
`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).`,
|
|
4740
4758
|
{ ref }
|
|
4741
4759
|
);
|
|
@@ -4759,8 +4777,8 @@ var PipRailClient = (_class2 = class {
|
|
|
4759
4777
|
*/
|
|
4760
4778
|
async payExactRail(net, wallet, accept, url, init, quote) {
|
|
4761
4779
|
if (!net.payExact) {
|
|
4762
|
-
throw new (0,
|
|
4763
|
-
`the ${net.family} family can't pay a standard 'exact' rail (supported on EVM, Solana, Algorand + NEAR today).`
|
|
4780
|
+
throw new (0, _chunkDCOUJZPLcjs.UnsupportedSchemeError)(
|
|
4781
|
+
`the ${net.family} family can't pay a standard 'exact' rail (supported on EVM, Solana, Algorand, Aptos + NEAR today).`
|
|
4764
4782
|
);
|
|
4765
4783
|
}
|
|
4766
4784
|
throwIfAborted(_optionalChain([init, 'optionalAccess', _78 => _78.signal]));
|
|
@@ -4769,7 +4787,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4769
4787
|
headers.set(HEADER_SIGNATURE, buildExactSignatureHeader({ accepted, payload }));
|
|
4770
4788
|
const rejectDefinitive = (why2) => {
|
|
4771
4789
|
this.safeEmit({ kind: "payment-failed", reason: `exact: facilitator rejected nonce=${nonce} (${why2})`, code: why2 });
|
|
4772
|
-
throw new (0,
|
|
4790
|
+
throw new (0, _chunkDCOUJZPLcjs.MaxRetriesExceededError)(
|
|
4773
4791
|
`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}.`,
|
|
4774
4792
|
{ ref: nonce }
|
|
4775
4793
|
);
|
|
@@ -4792,8 +4810,8 @@ var PipRailClient = (_class2 = class {
|
|
|
4792
4810
|
try {
|
|
4793
4811
|
response = await fetch(url, { ..._nullishCoalesce(init, () => ( {})), headers, signal });
|
|
4794
4812
|
} catch (err) {
|
|
4795
|
-
throw new (0,
|
|
4796
|
-
`exact: no response after submitting the authorization (nonce=${nonce}) to ${hostOf2(url)}. The facilitator may have already settled it \u2014 verify on-chain
|
|
4813
|
+
throw new (0, _chunkDCOUJZPLcjs.PaymentTimeoutError)(
|
|
4814
|
+
`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.`,
|
|
4797
4815
|
{ cause: err, ref: nonce }
|
|
4798
4816
|
);
|
|
4799
4817
|
} finally {
|
|
@@ -4809,7 +4827,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4809
4827
|
const receipt = parseReceipt(response);
|
|
4810
4828
|
this.captureReceipt(response, url);
|
|
4811
4829
|
this.safeEmit({ kind: "payment-settled", receipt, ...settle ? { settle } : {} });
|
|
4812
|
-
const ref = _optionalChain([settle, 'optionalAccess', _82 => _82.transaction]) || _optionalChain([receipt, 'optionalAccess', _83 => _83.transaction]) ||
|
|
4830
|
+
const ref = _optionalChain([settle, 'optionalAccess', _82 => _82.transaction]) || _optionalChain([receipt, 'optionalAccess', _83 => _83.transaction]) || `${net.family === "evm" ? "eip3009" : net.family}-nonce:${nonce}`;
|
|
4813
4831
|
this.recordSpend(quote, ref);
|
|
4814
4832
|
return response;
|
|
4815
4833
|
}
|
|
@@ -4827,8 +4845,8 @@ var PipRailClient = (_class2 = class {
|
|
|
4827
4845
|
reason: `exact: 402 after submitting authorization nonce=${nonce} (${why})`,
|
|
4828
4846
|
...lastReason ? { code: lastReason.error, detail: lastReason.detail } : {}
|
|
4829
4847
|
});
|
|
4830
|
-
throw new (0,
|
|
4831
|
-
`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
|
|
4848
|
+
throw new (0, _chunkDCOUJZPLcjs.MaxRetriesExceededError)(
|
|
4849
|
+
`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}.`,
|
|
4832
4850
|
{ ref: nonce }
|
|
4833
4851
|
);
|
|
4834
4852
|
}
|
|
@@ -4843,7 +4861,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4843
4861
|
*/
|
|
4844
4862
|
async payUptoRail(net, wallet, accept, url, init, quote) {
|
|
4845
4863
|
if (!net.payUpto) {
|
|
4846
|
-
throw new (0,
|
|
4864
|
+
throw new (0, _chunkDCOUJZPLcjs.UnsupportedSchemeError)(
|
|
4847
4865
|
`the ${net.family} family can't pay a standard 'upto' rail (EVM-Permit2 only today).`
|
|
4848
4866
|
);
|
|
4849
4867
|
}
|
|
@@ -4853,7 +4871,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4853
4871
|
headers.set(HEADER_SIGNATURE, buildUptoSignatureHeader({ accepted, payload }));
|
|
4854
4872
|
const rejectDefinitive = (why2) => {
|
|
4855
4873
|
this.safeEmit({ kind: "payment-failed", reason: `upto: facilitator rejected nonce=${nonce} (${why2})`, code: why2 });
|
|
4856
|
-
throw new (0,
|
|
4874
|
+
throw new (0, _chunkDCOUJZPLcjs.MaxRetriesExceededError)(
|
|
4857
4875
|
`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}.`,
|
|
4858
4876
|
{ ref: nonce }
|
|
4859
4877
|
);
|
|
@@ -4876,7 +4894,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4876
4894
|
try {
|
|
4877
4895
|
response = await fetch(url, { ..._nullishCoalesce(init, () => ( {})), headers, signal });
|
|
4878
4896
|
} catch (err) {
|
|
4879
|
-
throw new (0,
|
|
4897
|
+
throw new (0, _chunkDCOUJZPLcjs.PaymentTimeoutError)(
|
|
4880
4898
|
`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.`,
|
|
4881
4899
|
{ cause: err, ref: nonce }
|
|
4882
4900
|
);
|
|
@@ -4912,7 +4930,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4912
4930
|
reason: `upto: 402 after submitting authorization nonce=${nonce} (${why})`,
|
|
4913
4931
|
...lastReason ? { code: lastReason.error, detail: lastReason.detail } : {}
|
|
4914
4932
|
});
|
|
4915
|
-
throw new (0,
|
|
4933
|
+
throw new (0, _chunkDCOUJZPLcjs.MaxRetriesExceededError)(
|
|
4916
4934
|
`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}.`,
|
|
4917
4935
|
{ ref: nonce }
|
|
4918
4936
|
);
|
|
@@ -5025,7 +5043,7 @@ async function fetchAcross(clients, url, init) {
|
|
|
5025
5043
|
const best = rankAcross(live.map((p) => p.plan)).find((o) => o.state === "payable");
|
|
5026
5044
|
if (!best) {
|
|
5027
5045
|
const hint = mergeDeclineHint(live.map((p) => p.plan));
|
|
5028
|
-
throw new (0,
|
|
5046
|
+
throw new (0, _chunkDCOUJZPLcjs.PaymentDeclinedError)(hint || "No funded chain can settle this payment right now.");
|
|
5029
5047
|
}
|
|
5030
5048
|
const owner = live.find((p) => p.plan.options.includes(best)).client;
|
|
5031
5049
|
return owner.fetch(url, { ..._nullishCoalesce(init, () => ( {})), autoRoute: true });
|
|
@@ -5425,7 +5443,7 @@ function summarizePlan(plan) {
|
|
|
5425
5443
|
return `NOT payable: ${_nullishCoalesce(plan.fundingHint, () => ( `no settleable rail on ${plan.network}`))}`;
|
|
5426
5444
|
}
|
|
5427
5445
|
function explainDecline(err) {
|
|
5428
|
-
if (!(err instanceof
|
|
5446
|
+
if (!(err instanceof _chunkDCOUJZPLcjs.PipRailError)) {
|
|
5429
5447
|
return `Payment failed: ${err instanceof Error ? err.message : String(err)}`;
|
|
5430
5448
|
}
|
|
5431
5449
|
switch (err.code) {
|
|
@@ -5577,14 +5595,14 @@ async function readBody(res) {
|
|
|
5577
5595
|
}
|
|
5578
5596
|
}
|
|
5579
5597
|
function toToolError(err) {
|
|
5580
|
-
if (!(err instanceof
|
|
5598
|
+
if (!(err instanceof _chunkDCOUJZPLcjs.PipRailError)) throw err;
|
|
5581
5599
|
const out = {
|
|
5582
5600
|
ok: false,
|
|
5583
5601
|
code: err.code,
|
|
5584
5602
|
reason: err.message,
|
|
5585
5603
|
explain: explainDecline(err)
|
|
5586
5604
|
};
|
|
5587
|
-
if (err instanceof
|
|
5605
|
+
if (err instanceof _chunkDCOUJZPLcjs.PaymentDeclinedError) {
|
|
5588
5606
|
out.declined = true;
|
|
5589
5607
|
if (err.reasonCode) out.reasonCode = err.reasonCode;
|
|
5590
5608
|
}
|
|
@@ -5800,14 +5818,14 @@ function paymentTools(client) {
|
|
|
5800
5818
|
...verifiable ? { verifiableReceipt: { ...verifiable, resource: { url } } } : {}
|
|
5801
5819
|
};
|
|
5802
5820
|
} catch (err) {
|
|
5803
|
-
if (err instanceof
|
|
5821
|
+
if (err instanceof _chunkDCOUJZPLcjs.PipRailError) {
|
|
5804
5822
|
const out = {
|
|
5805
5823
|
ok: false,
|
|
5806
5824
|
code: err.code,
|
|
5807
5825
|
reason: err.message,
|
|
5808
5826
|
explain: explainDecline(err)
|
|
5809
5827
|
};
|
|
5810
|
-
if (err instanceof
|
|
5828
|
+
if (err instanceof _chunkDCOUJZPLcjs.PaymentDeclinedError) {
|
|
5811
5829
|
out.declined = true;
|
|
5812
5830
|
if (err.reasonCode) out.reasonCode = err.reasonCode;
|
|
5813
5831
|
}
|
|
@@ -6199,13 +6217,13 @@ async function settleViaFacilitator(input) {
|
|
|
6199
6217
|
try {
|
|
6200
6218
|
verify = await post(`${base2}/verify`, body, auth);
|
|
6201
6219
|
} catch (err) {
|
|
6202
|
-
throw new (0,
|
|
6220
|
+
throw new (0, _chunkDCOUJZPLcjs.SettlementError)(
|
|
6203
6221
|
`exact settle (facilitator ${base2}): /verify request failed (${err instanceof Error ? err.message : String(err)}).`,
|
|
6204
6222
|
{ cause: err }
|
|
6205
6223
|
);
|
|
6206
6224
|
}
|
|
6207
6225
|
if (verify.status !== 200) {
|
|
6208
|
-
throw new (0,
|
|
6226
|
+
throw new (0, _chunkDCOUJZPLcjs.SettlementError)(
|
|
6209
6227
|
`exact settle (facilitator ${base2}): /verify returned HTTP ${verify.status} (transport/auth error).`
|
|
6210
6228
|
);
|
|
6211
6229
|
}
|
|
@@ -6221,13 +6239,13 @@ async function settleViaFacilitator(input) {
|
|
|
6221
6239
|
try {
|
|
6222
6240
|
settle = await post(`${base2}/settle`, body, auth);
|
|
6223
6241
|
} catch (err) {
|
|
6224
|
-
throw new (0,
|
|
6242
|
+
throw new (0, _chunkDCOUJZPLcjs.SettlementError)(
|
|
6225
6243
|
`exact settle (facilitator ${base2}): /settle request failed (${err instanceof Error ? err.message : String(err)}).`,
|
|
6226
6244
|
{ cause: err }
|
|
6227
6245
|
);
|
|
6228
6246
|
}
|
|
6229
6247
|
if (settle.status !== 200) {
|
|
6230
|
-
throw new (0,
|
|
6248
|
+
throw new (0, _chunkDCOUJZPLcjs.SettlementError)(
|
|
6231
6249
|
`exact settle (facilitator ${base2}): /settle returned HTTP ${settle.status} (transport/auth error).`
|
|
6232
6250
|
);
|
|
6233
6251
|
}
|
|
@@ -6643,7 +6661,7 @@ function createPaymentGate(options) {
|
|
|
6643
6661
|
}
|
|
6644
6662
|
net.assertValidPayTo(payTo);
|
|
6645
6663
|
const { asset, decimals, symbol } = net.resolveToken(a.token);
|
|
6646
|
-
const amountBase =
|
|
6664
|
+
const amountBase = _chunkDCOUJZPLcjs.parseUnits.call(void 0, a.amount, decimals);
|
|
6647
6665
|
const spec = { net, asset, decimals, symbol, amountBase, amountFormatted: a.amount, payTo };
|
|
6648
6666
|
if (exactOption) {
|
|
6649
6667
|
const outcome = await resolveExactRail(net, asset);
|
|
@@ -6923,7 +6941,7 @@ function createPaymentGate(options) {
|
|
|
6923
6941
|
function enrichReceipt(spec, receipt) {
|
|
6924
6942
|
let amountFormatted = receipt.amount;
|
|
6925
6943
|
try {
|
|
6926
|
-
amountFormatted =
|
|
6944
|
+
amountFormatted = _chunkDCOUJZPLcjs.formatUnits.call(void 0, BigInt(receipt.amount), spec.decimals);
|
|
6927
6945
|
} catch (e47) {
|
|
6928
6946
|
}
|
|
6929
6947
|
return {
|
|
@@ -7165,7 +7183,7 @@ function createPaymentGate(options) {
|
|
|
7165
7183
|
const ftMethod = accept.extra.assetTransferMethod;
|
|
7166
7184
|
const needsFeePayer = ftMethod === "svm" || ftMethod === "algorand" || ftMethod === "aptos" || ftMethod === "near";
|
|
7167
7185
|
if (needsFeePayer && !accept.extra.feePayer) {
|
|
7168
|
-
throw new (0,
|
|
7186
|
+
throw new (0, _chunkDCOUJZPLcjs.SettlementError)(
|
|
7169
7187
|
`exact settle: the ${ftMethod} facilitator rail is missing extra.feePayer (the gas sponsor) \u2014 cannot settle.`
|
|
7170
7188
|
);
|
|
7171
7189
|
}
|
|
@@ -7213,15 +7231,15 @@ function createPaymentGate(options) {
|
|
|
7213
7231
|
if (s.endsWith("%")) {
|
|
7214
7232
|
const pct = s.slice(0, -1).trim();
|
|
7215
7233
|
if (!/^\d+(\.\d+)?$/.test(pct)) return null;
|
|
7216
|
-
const pctScaled =
|
|
7234
|
+
const pctScaled = _chunkDCOUJZPLcjs.floorUnits.call(void 0, pct, 4);
|
|
7217
7235
|
return maxAmount * pctScaled / (100n * 10n ** 4n);
|
|
7218
7236
|
}
|
|
7219
7237
|
if (s.startsWith("$")) {
|
|
7220
7238
|
const amt = s.slice(1).trim();
|
|
7221
|
-
return
|
|
7239
|
+
return _chunkDCOUJZPLcjs.floorUnits.call(void 0, amt, decimals);
|
|
7222
7240
|
}
|
|
7223
7241
|
if (/^\d+$/.test(s)) return BigInt(s);
|
|
7224
|
-
return
|
|
7242
|
+
return _chunkDCOUJZPLcjs.floorUnits.call(void 0, s, decimals);
|
|
7225
7243
|
} catch (e56) {
|
|
7226
7244
|
return null;
|
|
7227
7245
|
}
|
|
@@ -7272,7 +7290,7 @@ function createPaymentGate(options) {
|
|
|
7272
7290
|
result = await spec.net.settleUptoSelf({ relayer, payload: upto.payload, accept, settleAmount });
|
|
7273
7291
|
} catch (err) {
|
|
7274
7292
|
await settleTx(nonce, false);
|
|
7275
|
-
if (err instanceof
|
|
7293
|
+
if (err instanceof _chunkDCOUJZPLcjs.SettlementError) throw err;
|
|
7276
7294
|
return rejection(
|
|
7277
7295
|
"tx_reverted",
|
|
7278
7296
|
`upto: metering/settle failed (${err instanceof Error ? err.message : String(err)}).`
|
|
@@ -7313,7 +7331,7 @@ function createPaymentGate(options) {
|
|
|
7313
7331
|
}
|
|
7314
7332
|
function requirePayment(options) {
|
|
7315
7333
|
if (options.upto) {
|
|
7316
|
-
throw new (_class3 = class extends
|
|
7334
|
+
throw new (_class3 = class extends _chunkDCOUJZPLcjs.PipRailError {constructor(...args2) { super(...args2); _class3.prototype.__init7.call(this); }
|
|
7317
7335
|
__init7() {this.code = "UNSUPPORTED_SCHEME"}
|
|
7318
7336
|
}, _class3)(
|
|
7319
7337
|
"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."
|
|
@@ -7325,7 +7343,7 @@ function requirePayment(options) {
|
|
|
7325
7343
|
try {
|
|
7326
7344
|
result = await gate.verify(_nullishCoalesce(req.headers[HEADER_SIGNATURE], () => ( req.headers[HEADER_SIGNATURE_V1])));
|
|
7327
7345
|
} catch (err) {
|
|
7328
|
-
if (err instanceof
|
|
7346
|
+
if (err instanceof _chunkDCOUJZPLcjs.SettlementError) {
|
|
7329
7347
|
res.status(502);
|
|
7330
7348
|
res.json({
|
|
7331
7349
|
x402Version: 2,
|
|
@@ -7647,7 +7665,7 @@ function createA2APaymentHandler(options) {
|
|
|
7647
7665
|
try {
|
|
7648
7666
|
result = await gate.verifyObject(inbound.raw);
|
|
7649
7667
|
} catch (err) {
|
|
7650
|
-
if (err instanceof
|
|
7668
|
+
if (err instanceof _chunkDCOUJZPLcjs.SettlementError) {
|
|
7651
7669
|
return failedTask(id, "settlement_failed", err.message, attempted);
|
|
7652
7670
|
}
|
|
7653
7671
|
const detail = err instanceof Error ? err.message : String(err);
|
|
@@ -7841,4 +7859,4 @@ function resourceUrlFromMessage(message) {
|
|
|
7841
7859
|
|
|
7842
7860
|
|
|
7843
7861
|
|
|
7844
|
-
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 =
|
|
7862
|
+
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 = _chunkDCOUJZPLcjs.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.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 = _chunkDCOUJZPLcjs.InsufficientFundsError; exports.InvalidEnvelopeError = _chunkDCOUJZPLcjs.InvalidEnvelopeError; exports.KNOWN_FACILITATORS = KNOWN_FACILITATORS; exports.MaxRetriesExceededError = _chunkDCOUJZPLcjs.MaxRetriesExceededError; exports.MissingDriverError = _chunkDCOUJZPLcjs.MissingDriverError; exports.MultiChainPayer = MultiChainPayer; exports.NoCompatibleAcceptError = _chunkDCOUJZPLcjs.NoCompatibleAcceptError; exports.NonReplayableBodyError = _chunkDCOUJZPLcjs.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 = _chunkDCOUJZPLcjs.PaymentDeclinedError; exports.PaymentTimeoutError = _chunkDCOUJZPLcjs.PaymentTimeoutError; exports.PipRailClient = PipRailClient; exports.PipRailError = _chunkDCOUJZPLcjs.PipRailError; exports.REGISTER_ATTRIBUTION = REGISTER_ATTRIBUTION; exports.RecipientNotReadyError = _chunkDCOUJZPLcjs.RecipientNotReadyError; exports.SettlementError = _chunkDCOUJZPLcjs.SettlementError; exports.SpendLedger = SpendLedger; exports.UPTO_PROXY_CHAIN_IDS = UPTO_PROXY_CHAIN_IDS; exports.UnknownTokenError = _chunkDCOUJZPLcjs.UnknownTokenError; exports.UnsupportedNetworkError = _chunkDCOUJZPLcjs.UnsupportedNetworkError; exports.UnsupportedSchemeError = _chunkDCOUJZPLcjs.UnsupportedSchemeError; exports.VERIFY_CODE_TO_A2A_ERROR = VERIFY_CODE_TO_A2A_ERROR; exports.WalletRequiredError = _chunkDCOUJZPLcjs.WalletRequiredError; exports.WrongChainError = _chunkDCOUJZPLcjs.WrongChainError; exports.WrongFamilyError = _chunkDCOUJZPLcjs.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.buildOpenApi = buildOpenApi; exports.buildReceiptExtension = buildReceiptExtension; exports.buildReceiptHeader = buildReceiptHeader; exports.buildSelfDescription = buildSelfDescription; exports.buildSignatureHeader = buildSignatureHeader; exports.buildUptoSignatureHeader = buildUptoSignatureHeader; exports.buildWellKnownX402 = buildWellKnownX402; exports.buildX402DnsTxt = buildX402DnsTxt; exports.chainIdForExactNetwork = chainIdForExactNetwork; exports.claim402IndexDomain = claim402IndexDomain; exports.classifyChallenge = classifyChallenge; exports.createA2APaymentHandler = createA2APaymentHandler; exports.createPaymentGate = createPaymentGate; 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.getDirectoryInfo = getDirectoryInfo; 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.rankResources = rankResources; exports.readExactDomain = readExactDomain; 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.toInsufficientFundsError = _chunkDCOUJZPLcjs.toInsufficientFundsError; exports.toInvalidBody = toInvalidBody; exports.verify402IndexDomain = verify402IndexDomain;
|