@piprail/sdk 1.24.0 → 2.0.0
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 +40 -0
- package/README.md +4 -4
- package/dist/{algorand-677ILBQS.js → algorand-RJ4DRWHV.js} +10 -18
- package/dist/{algorand-ZJ53VCTN.cjs → algorand-RUDF55XY.cjs} +23 -31
- package/dist/{aptos-XIIHPAOO.cjs → aptos-PESRG2EQ.cjs} +22 -30
- package/dist/{aptos-3TSKTI4D.js → aptos-SMEQXIYJ.js} +10 -18
- package/dist/{chunk-L6WQRHEZ.js → chunk-47VEOHZN.js} +13 -0
- package/dist/{chunk-U35MG4TF.cjs → chunk-DKQXW454.cjs} +14 -1
- package/dist/index.cjs +137 -105
- package/dist/index.d.cts +31 -32
- package/dist/index.d.ts +31 -32
- package/dist/index.js +56 -24
- package/dist/{near-TWA4PYOD.js → near-CHE7B2CY.js} +10 -18
- package/dist/{near-MG256A3E.cjs → near-VWBV3SUW.cjs} +24 -32
- package/dist/{solana-KWNRY5NR.js → solana-DTO2R3AT.js} +7 -10
- package/dist/{solana-UEMHFQH5.cjs → solana-OIHRPGX2.cjs} +33 -36
- package/dist/{stellar-SCRRPCEA.cjs → stellar-AF7PYMMF.cjs} +27 -37
- package/dist/{stellar-YB7JXKK4.js → stellar-T5VONOEO.js} +11 -21
- package/dist/{sui-LFT65OGU.cjs → sui-3TF5XVRT.cjs} +23 -31
- package/dist/{sui-IODKU2MA.js → sui-J53NYMVL.js} +10 -18
- package/dist/{ton-QN5GTOCS.js → ton-CPK57L2O.js} +9 -12
- package/dist/{ton-RAYJFKJC.cjs → ton-ZEI7YUK7.cjs} +20 -23
- package/dist/{tron-KX4VWS7V.cjs → tron-5B3Q4SMF.cjs} +30 -38
- package/dist/{tron-QSNCDYRB.js → tron-LZRCDRZC.js} +11 -19
- package/dist/{xrpl-ECHK3GIX.js → xrpl-AH4FFC2C.js} +11 -19
- package/dist/{xrpl-GXUFDXHU.cjs → xrpl-BL4QXOVN.cjs} +27 -35
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
|
|
27
|
+
var _chunkDKQXW454cjs = require('./chunk-DKQXW454.cjs');
|
|
27
28
|
|
|
28
29
|
// src/drivers/registry.ts
|
|
29
30
|
var byFamily = /* @__PURE__ */ new Map();
|
|
@@ -52,13 +53,13 @@ function resolveNetwork(opts) {
|
|
|
52
53
|
const family = familyForChain(opts.chain);
|
|
53
54
|
const driver = byFamily.get(family);
|
|
54
55
|
if (!driver) {
|
|
55
|
-
throw new (0,
|
|
56
|
+
throw new (0, _chunkDKQXW454cjs.UnsupportedNetworkError)(
|
|
56
57
|
`No driver registered for the "${family}" family \u2014 it may not be mounted yet (use the async resolveNetwork()).`
|
|
57
58
|
);
|
|
58
59
|
}
|
|
59
60
|
const net = driver.resolve(opts);
|
|
60
61
|
if (!net) {
|
|
61
|
-
throw new (0,
|
|
62
|
+
throw new (0, _chunkDKQXW454cjs.UnsupportedNetworkError)(
|
|
62
63
|
`The ${family} driver didn't recognise this chain input.`
|
|
63
64
|
);
|
|
64
65
|
}
|
|
@@ -319,20 +320,21 @@ function resolveChain(input, rpcUrlOverride) {
|
|
|
319
320
|
|
|
320
321
|
var _accounts = require('viem/accounts');
|
|
321
322
|
function createWalletAdapter(config, resolved) {
|
|
322
|
-
|
|
323
|
-
|
|
323
|
+
_chunkDKQXW454cjs.assertNoLegacyWalletKey.call(void 0, config, "EVM");
|
|
324
|
+
if ("key" in config) {
|
|
325
|
+
const account = _accounts.privateKeyToAccount.call(void 0, config.key);
|
|
324
326
|
const transport = _viem.http.call(void 0, resolved.rpcUrl);
|
|
325
327
|
const walletClient = _viem.createWalletClient.call(void 0, { account, chain: resolved.chain, transport });
|
|
326
328
|
return { account, walletClient };
|
|
327
329
|
}
|
|
328
330
|
const wc = config.walletClient;
|
|
329
331
|
if (!wc.account) {
|
|
330
|
-
throw new (0,
|
|
331
|
-
"chain is EVM; the provided walletClient has no attached account. Use `createWalletClient({ account, chain, transport })`, or pass {
|
|
332
|
+
throw new (0, _chunkDKQXW454cjs.WrongFamilyError)(
|
|
333
|
+
"chain is EVM; the provided walletClient has no attached account. Use `createWalletClient({ account, chain, transport })`, or pass { key }."
|
|
332
334
|
);
|
|
333
335
|
}
|
|
334
336
|
if (wc.chain && wc.chain.id !== resolved.chainId) {
|
|
335
|
-
throw new (0,
|
|
337
|
+
throw new (0, _chunkDKQXW454cjs.WrongChainError)(
|
|
336
338
|
`PipRailClient: walletClient is on chain ${wc.chain.id} but the SDK was configured with chain ${resolved.chainId}. They must match.`
|
|
337
339
|
);
|
|
338
340
|
}
|
|
@@ -662,7 +664,7 @@ async function payExactEvm(input) {
|
|
|
662
664
|
code = void 0;
|
|
663
665
|
}
|
|
664
666
|
if (code && code !== "0x") {
|
|
665
|
-
throw new (0,
|
|
667
|
+
throw new (0, _chunkDKQXW454cjs.UnsupportedSchemeError)(
|
|
666
668
|
`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.`
|
|
667
669
|
);
|
|
668
670
|
}
|
|
@@ -672,13 +674,13 @@ async function payExactEvm(input) {
|
|
|
672
674
|
domain = await readExactDomain(publicClient, accept.asset);
|
|
673
675
|
}
|
|
674
676
|
if (!domain) {
|
|
675
|
-
throw new (0,
|
|
677
|
+
throw new (0, _chunkDKQXW454cjs.UnsupportedSchemeError)(
|
|
676
678
|
`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.`
|
|
677
679
|
);
|
|
678
680
|
}
|
|
679
681
|
const g = globalThis.crypto;
|
|
680
682
|
if (!_optionalChain([g, 'optionalAccess', _5 => _5.getRandomValues])) {
|
|
681
|
-
throw new (0,
|
|
683
|
+
throw new (0, _chunkDKQXW454cjs.UnsupportedSchemeError)(
|
|
682
684
|
"this runtime lacks Web Crypto (globalThis.crypto.getRandomValues); the exact rail needs a CSPRNG nonce."
|
|
683
685
|
);
|
|
684
686
|
}
|
|
@@ -935,7 +937,7 @@ async function verifyAndSettleExactEvm(input) {
|
|
|
935
937
|
args: writeArgs
|
|
936
938
|
});
|
|
937
939
|
} catch (err) {
|
|
938
|
-
throw new (0,
|
|
940
|
+
throw new (0, _chunkDKQXW454cjs.SettlementError)(
|
|
939
941
|
`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.`,
|
|
940
942
|
{ cause: err }
|
|
941
943
|
);
|
|
@@ -947,7 +949,7 @@ async function verifyAndSettleExactEvm(input) {
|
|
|
947
949
|
return { ok: false, error: "tx_reverted", detail: `Settlement tx ${txHash} reverted on-chain.` };
|
|
948
950
|
}
|
|
949
951
|
} catch (err) {
|
|
950
|
-
throw new (0,
|
|
952
|
+
throw new (0, _chunkDKQXW454cjs.SettlementError)(
|
|
951
953
|
`exact settle: broadcast ${txHash} but couldn't confirm it (${shorten(err instanceof Error ? err.message : String(err))}).`,
|
|
952
954
|
{ cause: err }
|
|
953
955
|
);
|
|
@@ -1078,7 +1080,7 @@ function shorten2(msg) {
|
|
|
1078
1080
|
function randomPermit2Nonce() {
|
|
1079
1081
|
const g = globalThis.crypto;
|
|
1080
1082
|
if (!_optionalChain([g, 'optionalAccess', _8 => _8.getRandomValues])) {
|
|
1081
|
-
throw new (0,
|
|
1083
|
+
throw new (0, _chunkDKQXW454cjs.UnsupportedSchemeError)(
|
|
1082
1084
|
"this runtime lacks Web Crypto (globalThis.crypto.getRandomValues); the permit2 rail needs a CSPRNG nonce."
|
|
1083
1085
|
);
|
|
1084
1086
|
}
|
|
@@ -1097,7 +1099,7 @@ async function ensurePermit2Allowance(input) {
|
|
|
1097
1099
|
args: [account.address, PERMIT2_ADDRESS]
|
|
1098
1100
|
});
|
|
1099
1101
|
} catch (err) {
|
|
1100
|
-
throw new (0,
|
|
1102
|
+
throw new (0, _chunkDKQXW454cjs.UnsupportedSchemeError)(
|
|
1101
1103
|
`permit2: couldn't read the Permit2 allowance for ${token} (${shorten2(err instanceof Error ? err.message : String(err))}).`
|
|
1102
1104
|
);
|
|
1103
1105
|
}
|
|
@@ -1114,7 +1116,7 @@ async function ensurePermit2Allowance(input) {
|
|
|
1114
1116
|
await publicClient.waitForTransactionReceipt({ hash, confirmations: 1 });
|
|
1115
1117
|
return hash;
|
|
1116
1118
|
} catch (err) {
|
|
1117
|
-
throw _nullishCoalesce(
|
|
1119
|
+
throw _nullishCoalesce(_chunkDKQXW454cjs.toInsufficientFundsError.call(void 0, err), () => ( new (0, _chunkDKQXW454cjs.SettlementError)(
|
|
1118
1120
|
`permit2: the one-time Permit2 approval for ${token} failed to broadcast (${shorten2(err instanceof Error ? err.message : String(err))}).`,
|
|
1119
1121
|
{ cause: err }
|
|
1120
1122
|
)));
|
|
@@ -1129,7 +1131,7 @@ async function payPermit2Evm(input) {
|
|
|
1129
1131
|
code = void 0;
|
|
1130
1132
|
}
|
|
1131
1133
|
if (code && code !== "0x") {
|
|
1132
|
-
throw new (0,
|
|
1134
|
+
throw new (0, _chunkDKQXW454cjs.UnsupportedSchemeError)(
|
|
1133
1135
|
`permit2 buyer rail requires an EOA signer; ${account.address} is a contract / EIP-1271 / EIP-7702-delegated account. Pay via onchain-proof.`
|
|
1134
1136
|
);
|
|
1135
1137
|
}
|
|
@@ -1304,7 +1306,7 @@ async function verifyAndSettlePermit2Evm(input) {
|
|
|
1304
1306
|
args: settleArgs
|
|
1305
1307
|
});
|
|
1306
1308
|
} catch (err) {
|
|
1307
|
-
throw new (0,
|
|
1309
|
+
throw new (0, _chunkDKQXW454cjs.SettlementError)(
|
|
1308
1310
|
`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.`,
|
|
1309
1311
|
{ cause: err }
|
|
1310
1312
|
);
|
|
@@ -1316,7 +1318,7 @@ async function verifyAndSettlePermit2Evm(input) {
|
|
|
1316
1318
|
return { ok: false, error: "tx_reverted", detail: `Settlement tx ${txHash} reverted on-chain.` };
|
|
1317
1319
|
}
|
|
1318
1320
|
} catch (err) {
|
|
1319
|
-
throw new (0,
|
|
1321
|
+
throw new (0, _chunkDKQXW454cjs.SettlementError)(
|
|
1320
1322
|
`permit2 settle: broadcast ${txHash} but couldn't confirm it (${shorten2(err instanceof Error ? err.message : String(err))}).`,
|
|
1321
1323
|
{ cause: err }
|
|
1322
1324
|
);
|
|
@@ -1549,15 +1551,15 @@ function makeEvmNetwork(resolved) {
|
|
|
1549
1551
|
const info = resolved.tokens[token.toUpperCase()];
|
|
1550
1552
|
if (!info) {
|
|
1551
1553
|
const known = Object.keys(resolved.tokens).join(", ") || "(none built in)";
|
|
1552
|
-
throw new (0,
|
|
1554
|
+
throw new (0, _chunkDKQXW454cjs.UnknownTokenError)(
|
|
1553
1555
|
`token "${token}" isn't built in for ${resolved.chain.name} (known: ${known}). Pass { address, decimals } instead, or use 'native'.`
|
|
1554
1556
|
);
|
|
1555
1557
|
}
|
|
1556
1558
|
return { asset: info.address, decimals: info.decimals, symbol: info.symbol };
|
|
1557
1559
|
}
|
|
1558
|
-
|
|
1560
|
+
_chunkDKQXW454cjs.rejectForeignToken.call(void 0, token, "evm", network);
|
|
1559
1561
|
if (!("address" in token)) {
|
|
1560
|
-
throw new (0,
|
|
1562
|
+
throw new (0, _chunkDKQXW454cjs.WrongFamilyError)(
|
|
1561
1563
|
`chain ${network} is EVM; a custom token must be { address, decimals }.`
|
|
1562
1564
|
);
|
|
1563
1565
|
}
|
|
@@ -1589,15 +1591,21 @@ function makeEvmNetwork(resolved) {
|
|
|
1589
1591
|
},
|
|
1590
1592
|
assertValidPayTo(payTo) {
|
|
1591
1593
|
if (!_viem.isAddress.call(void 0, payTo)) {
|
|
1592
|
-
throw new (0,
|
|
1594
|
+
throw new (0, _chunkDKQXW454cjs.WrongFamilyError)(
|
|
1593
1595
|
`chain ${network} is EVM, but payTo "${payTo}" is not a valid 0x address.`
|
|
1594
1596
|
);
|
|
1595
1597
|
}
|
|
1596
1598
|
},
|
|
1597
1599
|
bindWallet(wallet) {
|
|
1598
|
-
if (typeof wallet !== "object" || wallet === null
|
|
1599
|
-
throw new (0,
|
|
1600
|
-
`chain ${network} is EVM; wallet must be {
|
|
1600
|
+
if (typeof wallet !== "object" || wallet === null) {
|
|
1601
|
+
throw new (0, _chunkDKQXW454cjs.WrongFamilyError)(
|
|
1602
|
+
`chain ${network} is EVM; wallet must be { key } (0x\u2026 hex) or { walletClient }.`
|
|
1603
|
+
);
|
|
1604
|
+
}
|
|
1605
|
+
_chunkDKQXW454cjs.assertNoLegacyWalletKey.call(void 0, wallet, "EVM");
|
|
1606
|
+
if (!("key" in wallet) && !("walletClient" in wallet)) {
|
|
1607
|
+
throw new (0, _chunkDKQXW454cjs.WrongFamilyError)(
|
|
1608
|
+
`chain ${network} is EVM; wallet must be { key } (0x\u2026 hex) or { walletClient }.`
|
|
1601
1609
|
);
|
|
1602
1610
|
}
|
|
1603
1611
|
return { _native: createWalletAdapter(wallet, resolved) };
|
|
@@ -1613,12 +1621,12 @@ function makeEvmNetwork(resolved) {
|
|
|
1613
1621
|
});
|
|
1614
1622
|
} catch (err) {
|
|
1615
1623
|
if (isViemInsufficientFunds(err)) {
|
|
1616
|
-
throw new (0,
|
|
1624
|
+
throw new (0, _chunkDKQXW454cjs.InsufficientFundsError)(
|
|
1617
1625
|
err instanceof Error ? err.message : "Insufficient funds for payment.",
|
|
1618
1626
|
{ cause: err }
|
|
1619
1627
|
);
|
|
1620
1628
|
}
|
|
1621
|
-
throw _nullishCoalesce(
|
|
1629
|
+
throw _nullishCoalesce(_chunkDKQXW454cjs.toInsufficientFundsError.call(void 0, err), () => ( err));
|
|
1622
1630
|
}
|
|
1623
1631
|
},
|
|
1624
1632
|
async confirm(ref, minConfirmations) {
|
|
@@ -1629,7 +1637,7 @@ function makeEvmNetwork(resolved) {
|
|
|
1629
1637
|
});
|
|
1630
1638
|
return { height: receipt.blockNumber.toString() };
|
|
1631
1639
|
} catch (err) {
|
|
1632
|
-
throw new (0,
|
|
1640
|
+
throw new (0, _chunkDKQXW454cjs.ConfirmationTimeoutError)(
|
|
1633
1641
|
`EVM tx ${ref} did not reach ${minConfirmations} confirmation(s) in time.`,
|
|
1634
1642
|
{ cause: err }
|
|
1635
1643
|
);
|
|
@@ -1639,7 +1647,7 @@ function makeEvmNetwork(resolved) {
|
|
|
1639
1647
|
const { decimals, symbol } = resolved.chain.nativeCurrency;
|
|
1640
1648
|
if (accept.scheme === "exact") {
|
|
1641
1649
|
const permit2 = accept.extra.assetTransferMethod === "permit2";
|
|
1642
|
-
return
|
|
1650
|
+
return _chunkDKQXW454cjs.nativeCost.call(void 0, {
|
|
1643
1651
|
symbol,
|
|
1644
1652
|
decimals,
|
|
1645
1653
|
fee: 0n,
|
|
@@ -1650,7 +1658,7 @@ function makeEvmNetwork(resolved) {
|
|
|
1650
1658
|
const gasLimit = accept.asset === "native" ? 21000n : 65000n;
|
|
1651
1659
|
try {
|
|
1652
1660
|
const gasPrice = await publicClient.getGasPrice();
|
|
1653
|
-
return
|
|
1661
|
+
return _chunkDKQXW454cjs.nativeCost.call(void 0, {
|
|
1654
1662
|
symbol,
|
|
1655
1663
|
decimals,
|
|
1656
1664
|
fee: gasPrice * gasLimit,
|
|
@@ -1659,7 +1667,7 @@ function makeEvmNetwork(resolved) {
|
|
|
1659
1667
|
});
|
|
1660
1668
|
} catch (e20) {
|
|
1661
1669
|
const gasPrice = 5000000000n;
|
|
1662
|
-
return
|
|
1670
|
+
return _chunkDKQXW454cjs.nativeCost.call(void 0, {
|
|
1663
1671
|
symbol,
|
|
1664
1672
|
decimals,
|
|
1665
1673
|
fee: gasPrice * gasLimit,
|
|
@@ -1793,9 +1801,9 @@ var loaders = {
|
|
|
1793
1801
|
solana: async () => {
|
|
1794
1802
|
let mod;
|
|
1795
1803
|
try {
|
|
1796
|
-
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./solana-
|
|
1804
|
+
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./solana-OIHRPGX2.cjs")));
|
|
1797
1805
|
} catch (cause) {
|
|
1798
|
-
throw new (0,
|
|
1806
|
+
throw new (0, _chunkDKQXW454cjs.MissingDriverError)(
|
|
1799
1807
|
`Solana selected, but its packages aren't installed. Run: npm install @solana/web3.js @solana/spl-token bs58`,
|
|
1800
1808
|
{ cause }
|
|
1801
1809
|
);
|
|
@@ -1805,9 +1813,9 @@ var loaders = {
|
|
|
1805
1813
|
ton: async () => {
|
|
1806
1814
|
let mod;
|
|
1807
1815
|
try {
|
|
1808
|
-
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./ton-
|
|
1816
|
+
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./ton-ZEI7YUK7.cjs")));
|
|
1809
1817
|
} catch (cause) {
|
|
1810
|
-
throw new (0,
|
|
1818
|
+
throw new (0, _chunkDKQXW454cjs.MissingDriverError)(
|
|
1811
1819
|
`TON selected, but its packages aren't installed. Run: npm install @ton/ton @ton/core @ton/crypto`,
|
|
1812
1820
|
{ cause }
|
|
1813
1821
|
);
|
|
@@ -1817,9 +1825,9 @@ var loaders = {
|
|
|
1817
1825
|
stellar: async () => {
|
|
1818
1826
|
let mod;
|
|
1819
1827
|
try {
|
|
1820
|
-
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./stellar-
|
|
1828
|
+
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./stellar-AF7PYMMF.cjs")));
|
|
1821
1829
|
} catch (cause) {
|
|
1822
|
-
throw new (0,
|
|
1830
|
+
throw new (0, _chunkDKQXW454cjs.MissingDriverError)(
|
|
1823
1831
|
`Stellar selected, but its package isn't installed. Run: npm install @stellar/stellar-sdk`,
|
|
1824
1832
|
{ cause }
|
|
1825
1833
|
);
|
|
@@ -1829,9 +1837,9 @@ var loaders = {
|
|
|
1829
1837
|
xrpl: async () => {
|
|
1830
1838
|
let mod;
|
|
1831
1839
|
try {
|
|
1832
|
-
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./xrpl-
|
|
1840
|
+
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./xrpl-BL4QXOVN.cjs")));
|
|
1833
1841
|
} catch (cause) {
|
|
1834
|
-
throw new (0,
|
|
1842
|
+
throw new (0, _chunkDKQXW454cjs.MissingDriverError)(
|
|
1835
1843
|
`XRPL selected, but its package isn't installed. Run: npm install xrpl`,
|
|
1836
1844
|
{ cause }
|
|
1837
1845
|
);
|
|
@@ -1841,9 +1849,9 @@ var loaders = {
|
|
|
1841
1849
|
tron: async () => {
|
|
1842
1850
|
let mod;
|
|
1843
1851
|
try {
|
|
1844
|
-
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./tron-
|
|
1852
|
+
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./tron-5B3Q4SMF.cjs")));
|
|
1845
1853
|
} catch (cause) {
|
|
1846
|
-
throw new (0,
|
|
1854
|
+
throw new (0, _chunkDKQXW454cjs.MissingDriverError)(
|
|
1847
1855
|
`Tron selected, but its package isn't installed. Run: npm install tronweb`,
|
|
1848
1856
|
{ cause }
|
|
1849
1857
|
);
|
|
@@ -1853,9 +1861,9 @@ var loaders = {
|
|
|
1853
1861
|
sui: async () => {
|
|
1854
1862
|
let mod;
|
|
1855
1863
|
try {
|
|
1856
|
-
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./sui-
|
|
1864
|
+
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./sui-3TF5XVRT.cjs")));
|
|
1857
1865
|
} catch (cause) {
|
|
1858
|
-
throw new (0,
|
|
1866
|
+
throw new (0, _chunkDKQXW454cjs.MissingDriverError)(
|
|
1859
1867
|
`Sui selected, but its package isn't installed. Run: npm install @mysten/sui`,
|
|
1860
1868
|
{ cause }
|
|
1861
1869
|
);
|
|
@@ -1865,9 +1873,9 @@ var loaders = {
|
|
|
1865
1873
|
near: async () => {
|
|
1866
1874
|
let mod;
|
|
1867
1875
|
try {
|
|
1868
|
-
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./near-
|
|
1876
|
+
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./near-VWBV3SUW.cjs")));
|
|
1869
1877
|
} catch (cause) {
|
|
1870
|
-
throw new (0,
|
|
1878
|
+
throw new (0, _chunkDKQXW454cjs.MissingDriverError)(
|
|
1871
1879
|
`NEAR selected, but its package isn't installed. Run: npm install near-api-js`,
|
|
1872
1880
|
{ cause }
|
|
1873
1881
|
);
|
|
@@ -1877,9 +1885,9 @@ var loaders = {
|
|
|
1877
1885
|
aptos: async () => {
|
|
1878
1886
|
let mod;
|
|
1879
1887
|
try {
|
|
1880
|
-
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./aptos-
|
|
1888
|
+
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./aptos-PESRG2EQ.cjs")));
|
|
1881
1889
|
} catch (cause) {
|
|
1882
|
-
throw new (0,
|
|
1890
|
+
throw new (0, _chunkDKQXW454cjs.MissingDriverError)(
|
|
1883
1891
|
`Aptos selected, but its package isn't installed. Run: npm install @aptos-labs/ts-sdk`,
|
|
1884
1892
|
{ cause }
|
|
1885
1893
|
);
|
|
@@ -1889,9 +1897,9 @@ var loaders = {
|
|
|
1889
1897
|
algorand: async () => {
|
|
1890
1898
|
let mod;
|
|
1891
1899
|
try {
|
|
1892
|
-
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./algorand-
|
|
1900
|
+
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./algorand-RUDF55XY.cjs")));
|
|
1893
1901
|
} catch (cause) {
|
|
1894
|
-
throw new (0,
|
|
1902
|
+
throw new (0, _chunkDKQXW454cjs.MissingDriverError)(
|
|
1895
1903
|
`Algorand selected, but its package isn't installed. Run: npm install algosdk`,
|
|
1896
1904
|
{ cause }
|
|
1897
1905
|
);
|
|
@@ -2438,7 +2446,7 @@ function evaluatePolicy(intent, policy, spentForAssetBase, ctx) {
|
|
|
2438
2446
|
}
|
|
2439
2447
|
}
|
|
2440
2448
|
if (policy.maxAmount !== void 0) {
|
|
2441
|
-
const cap =
|
|
2449
|
+
const cap = _chunkDKQXW454cjs.floorUnits.call(void 0, policy.maxAmount, intent.decimals);
|
|
2442
2450
|
if (intent.amountBase > cap) {
|
|
2443
2451
|
return deny(
|
|
2444
2452
|
"MAX_AMOUNT",
|
|
@@ -2447,7 +2455,7 @@ function evaluatePolicy(intent, policy, spentForAssetBase, ctx) {
|
|
|
2447
2455
|
}
|
|
2448
2456
|
}
|
|
2449
2457
|
if (policy.maxTotal !== void 0) {
|
|
2450
|
-
const cap =
|
|
2458
|
+
const cap = _chunkDKQXW454cjs.floorUnits.call(void 0, policy.maxTotal, intent.decimals);
|
|
2451
2459
|
if (spentForAssetBase + intent.amountBase > cap) {
|
|
2452
2460
|
return deny(
|
|
2453
2461
|
"MAX_TOTAL",
|
|
@@ -2456,7 +2464,7 @@ function evaluatePolicy(intent, policy, spentForAssetBase, ctx) {
|
|
|
2456
2464
|
}
|
|
2457
2465
|
}
|
|
2458
2466
|
if (ctx && policy.windowTotal !== void 0 && policy.windowSeconds !== void 0) {
|
|
2459
|
-
const cap =
|
|
2467
|
+
const cap = _chunkDKQXW454cjs.floorUnits.call(void 0, policy.windowTotal, intent.decimals);
|
|
2460
2468
|
if (ctx.spentInWindowBase + intent.amountBase > cap) {
|
|
2461
2469
|
return deny(
|
|
2462
2470
|
"WINDOW_TOTAL",
|
|
@@ -2545,7 +2553,7 @@ var SpendLedger = (_class = class {constructor() { _class.prototype.__init.call(
|
|
|
2545
2553
|
symbol: b.symbol,
|
|
2546
2554
|
decimals: b.decimals,
|
|
2547
2555
|
totalBase: b.total.toString(),
|
|
2548
|
-
totalFormatted:
|
|
2556
|
+
totalFormatted: _chunkDKQXW454cjs.formatUnits.call(void 0, b.total, b.decimals),
|
|
2549
2557
|
count: b.count
|
|
2550
2558
|
})),
|
|
2551
2559
|
records: [...this.records]
|
|
@@ -2741,13 +2749,13 @@ var PipRailClient = (_class2 = class {
|
|
|
2741
2749
|
spentBase: b.totalBase.toString()
|
|
2742
2750
|
};
|
|
2743
2751
|
if (maxTotal === void 0) return base2;
|
|
2744
|
-
const capBase =
|
|
2752
|
+
const capBase = _chunkDKQXW454cjs.floorUnits.call(void 0, maxTotal, b.decimals);
|
|
2745
2753
|
const remainingBase = capBase > b.totalBase ? capBase - b.totalBase : 0n;
|
|
2746
2754
|
return {
|
|
2747
2755
|
...base2,
|
|
2748
2756
|
capBase: capBase.toString(),
|
|
2749
2757
|
remainingBase: remainingBase.toString(),
|
|
2750
|
-
remainingFormatted:
|
|
2758
|
+
remainingFormatted: _chunkDKQXW454cjs.formatUnits.call(void 0, remainingBase, b.decimals)
|
|
2751
2759
|
};
|
|
2752
2760
|
});
|
|
2753
2761
|
}
|
|
@@ -2787,11 +2795,11 @@ var PipRailClient = (_class2 = class {
|
|
|
2787
2795
|
if (res.status !== 402) return null;
|
|
2788
2796
|
const challenge = await parseChallenge(res);
|
|
2789
2797
|
if (!challenge) {
|
|
2790
|
-
throw new (0,
|
|
2798
|
+
throw new (0, _chunkDKQXW454cjs.InvalidEnvelopeError)("402 response did not include a parseable x402 challenge.");
|
|
2791
2799
|
}
|
|
2792
2800
|
const { net, wallet } = await this.ensure();
|
|
2793
2801
|
if (!wallet) {
|
|
2794
|
-
throw new (0,
|
|
2802
|
+
throw new (0, _chunkDKQXW454cjs.WalletRequiredError)(
|
|
2795
2803
|
"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."
|
|
2796
2804
|
);
|
|
2797
2805
|
}
|
|
@@ -2959,7 +2967,7 @@ var PipRailClient = (_class2 = class {
|
|
|
2959
2967
|
async fetch(url, init) {
|
|
2960
2968
|
const body = _optionalChain([init, 'optionalAccess', _41 => _41.body]);
|
|
2961
2969
|
if (body !== void 0 && body !== null && !isReplayableBodyInit(body)) {
|
|
2962
|
-
throw new (0,
|
|
2970
|
+
throw new (0, _chunkDKQXW454cjs.NonReplayableBodyError)(
|
|
2963
2971
|
"fetch(): init.body is not replayable. Pass a string, FormData, URLSearchParams, ArrayBuffer, or Blob \u2014 not a ReadableStream."
|
|
2964
2972
|
);
|
|
2965
2973
|
}
|
|
@@ -2969,7 +2977,7 @@ var PipRailClient = (_class2 = class {
|
|
|
2969
2977
|
const resolved = await this.resolveChallenge(url, firstResponse, schemes);
|
|
2970
2978
|
const { net, wallet, challenge } = resolved;
|
|
2971
2979
|
if (!wallet) {
|
|
2972
|
-
throw new (0,
|
|
2980
|
+
throw new (0, _chunkDKQXW454cjs.WalletRequiredError)(
|
|
2973
2981
|
"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)."
|
|
2974
2982
|
);
|
|
2975
2983
|
}
|
|
@@ -2979,7 +2987,7 @@ var PipRailClient = (_class2 = class {
|
|
|
2979
2987
|
if (autoRoute) {
|
|
2980
2988
|
const plan = await this.planFromChallenge(net, wallet, challenge, url, schemes);
|
|
2981
2989
|
if (!plan.best) {
|
|
2982
|
-
throw new (0,
|
|
2990
|
+
throw new (0, _chunkDKQXW454cjs.PaymentDeclinedError)(_nullishCoalesce(plan.fundingHint, () => ( "No rail is settleable for this payment.")));
|
|
2983
2991
|
}
|
|
2984
2992
|
accept = plan.best.accept;
|
|
2985
2993
|
quote = plan.best.quote;
|
|
@@ -3003,7 +3011,7 @@ var PipRailClient = (_class2 = class {
|
|
|
3003
3011
|
async resolveChallenge(url, response, schemes) {
|
|
3004
3012
|
const challenge = await parseChallenge(response);
|
|
3005
3013
|
if (!challenge) {
|
|
3006
|
-
throw new (0,
|
|
3014
|
+
throw new (0, _chunkDKQXW454cjs.InvalidEnvelopeError)(
|
|
3007
3015
|
"402 response did not include a parseable x402 challenge."
|
|
3008
3016
|
);
|
|
3009
3017
|
}
|
|
@@ -3014,7 +3022,7 @@ var PipRailClient = (_class2 = class {
|
|
|
3014
3022
|
(a) => a.scheme === "exact" && net.supports(a.network)
|
|
3015
3023
|
);
|
|
3016
3024
|
if (schemes.includes("exact") && exactOnNet && typeof net.payExact !== "function") {
|
|
3017
|
-
throw new (0,
|
|
3025
|
+
throw new (0, _chunkDKQXW454cjs.UnsupportedSchemeError)(
|
|
3018
3026
|
`This 402 offers a standard 'exact' rail on ${net.network}, but the ${net.family} family can't pay 'exact' (supported on EVM + Solana today), and no 'onchain-proof' rail was offered.`
|
|
3019
3027
|
);
|
|
3020
3028
|
}
|
|
@@ -3023,13 +3031,13 @@ var PipRailClient = (_class2 = class {
|
|
|
3023
3031
|
(a) => a.scheme === "exact" && net.supports(a.network) && net.describeAsset(a.asset) != null
|
|
3024
3032
|
);
|
|
3025
3033
|
if (payable) {
|
|
3026
|
-
throw new (0,
|
|
3034
|
+
throw new (0, _chunkDKQXW454cjs.NoCompatibleAcceptError)(
|
|
3027
3035
|
`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).`
|
|
3028
3036
|
);
|
|
3029
3037
|
}
|
|
3030
3038
|
}
|
|
3031
3039
|
const networks = [...new Set(challenge.accepts.map((a) => a.network))].join(", ");
|
|
3032
|
-
throw new (0,
|
|
3040
|
+
throw new (0, _chunkDKQXW454cjs.NoCompatibleAcceptError)(
|
|
3033
3041
|
`No accepts[] entry payable by this client on ${net.network} (schemes: ${schemes.join(", ")}; challenge offered: ${networks || "none"}).`
|
|
3034
3042
|
);
|
|
3035
3043
|
}
|
|
@@ -3131,21 +3139,21 @@ var PipRailClient = (_class2 = class {
|
|
|
3131
3139
|
if (isExact) {
|
|
3132
3140
|
if (tokenKnown && bal.token < amount) {
|
|
3133
3141
|
blockers.push("INSUFFICIENT_TOKEN");
|
|
3134
|
-
shortfall.token =
|
|
3142
|
+
shortfall.token = _chunkDKQXW454cjs.formatUnits.call(void 0, amount - bal.token, quote.decimals);
|
|
3135
3143
|
}
|
|
3136
3144
|
} else if (isNative) {
|
|
3137
3145
|
if (nativeKnown && bal.native < amount + fee) {
|
|
3138
3146
|
blockers.push("INSUFFICIENT_TOKEN");
|
|
3139
|
-
shortfall.token =
|
|
3147
|
+
shortfall.token = _chunkDKQXW454cjs.formatUnits.call(void 0, amount + fee - bal.native, quote.decimals);
|
|
3140
3148
|
}
|
|
3141
3149
|
} else {
|
|
3142
3150
|
if (tokenKnown && bal.token < amount) {
|
|
3143
3151
|
blockers.push("INSUFFICIENT_TOKEN");
|
|
3144
|
-
shortfall.token =
|
|
3152
|
+
shortfall.token = _chunkDKQXW454cjs.formatUnits.call(void 0, amount - bal.token, quote.decimals);
|
|
3145
3153
|
}
|
|
3146
3154
|
if (nativeKnown && bal.native < fee) {
|
|
3147
3155
|
blockers.push("INSUFFICIENT_GAS");
|
|
3148
|
-
shortfall.native =
|
|
3156
|
+
shortfall.native = _chunkDKQXW454cjs.formatUnits.call(void 0, fee - bal.native, cost.feeDecimals);
|
|
3149
3157
|
} else if (nativeKnown && fee > 0n && bal.native < fee * 3n / 2n) {
|
|
3150
3158
|
warnings.push("THIN_GAS_MARGIN");
|
|
3151
3159
|
}
|
|
@@ -3170,8 +3178,8 @@ var PipRailClient = (_class2 = class {
|
|
|
3170
3178
|
blockers,
|
|
3171
3179
|
warnings,
|
|
3172
3180
|
balance: {
|
|
3173
|
-
token: bal.token != null ?
|
|
3174
|
-
native: bal.native != null ?
|
|
3181
|
+
token: bal.token != null ? _chunkDKQXW454cjs.formatUnits.call(void 0, bal.token, quote.decimals) : null,
|
|
3182
|
+
native: bal.native != null ? _chunkDKQXW454cjs.formatUnits.call(void 0, bal.native, cost.feeDecimals) : null
|
|
3175
3183
|
},
|
|
3176
3184
|
need: { token: quote.amountFormatted, native: cost.feeFormatted },
|
|
3177
3185
|
...shortfall.token || shortfall.native ? { shortfall } : {},
|
|
@@ -3182,7 +3190,7 @@ var PipRailClient = (_class2 = class {
|
|
|
3182
3190
|
* driver's describeAsset) + the policy verdict + a symbol-mismatch flag. */
|
|
3183
3191
|
buildQuote(net, accept, url, description) {
|
|
3184
3192
|
if (!/^\d+$/.test(accept.amount)) {
|
|
3185
|
-
throw new (0,
|
|
3193
|
+
throw new (0, _chunkDKQXW454cjs.InvalidEnvelopeError)(
|
|
3186
3194
|
`challenge amount "${accept.amount}" is not a base-unit integer.`
|
|
3187
3195
|
);
|
|
3188
3196
|
}
|
|
@@ -3190,12 +3198,12 @@ var PipRailClient = (_class2 = class {
|
|
|
3190
3198
|
const described = net.describeAsset(accept.asset);
|
|
3191
3199
|
const decimals = _nullishCoalesce(_optionalChain([described, 'optionalAccess', _44 => _44.decimals]), () => ( accept.extra.decimals));
|
|
3192
3200
|
if (decimals === void 0) {
|
|
3193
|
-
throw new (0,
|
|
3201
|
+
throw new (0, _chunkDKQXW454cjs.InvalidEnvelopeError)(
|
|
3194
3202
|
`challenge for ${accept.asset} on ${accept.network} states no decimals and the SDK doesn't recognise the token \u2014 refusing to price it.`
|
|
3195
3203
|
);
|
|
3196
3204
|
}
|
|
3197
3205
|
const symbol = _nullishCoalesce(_optionalChain([described, 'optionalAccess', _45 => _45.symbol]), () => ( accept.extra.symbol));
|
|
3198
|
-
const amountFormatted =
|
|
3206
|
+
const amountFormatted = _chunkDKQXW454cjs.formatUnits.call(void 0, amountBase, decimals);
|
|
3199
3207
|
const intent = {
|
|
3200
3208
|
host: hostOf2(url),
|
|
3201
3209
|
chain: this.opts.chain,
|
|
@@ -3253,7 +3261,7 @@ var PipRailClient = (_class2 = class {
|
|
|
3253
3261
|
* TERMINAL expiry/approval decline it must not retry) without parsing prose. */
|
|
3254
3262
|
async authorize(quote) {
|
|
3255
3263
|
if (!quote.withinPolicy) {
|
|
3256
|
-
throw new (0,
|
|
3264
|
+
throw new (0, _chunkDKQXW454cjs.PaymentDeclinedError)(
|
|
3257
3265
|
`Payment refused by policy: ${_nullishCoalesce(quote.policyReason, () => ( "not allowed"))}`,
|
|
3258
3266
|
{ reasonCode: reasonCodeForPolicy(quote.policyCode) }
|
|
3259
3267
|
);
|
|
@@ -3264,13 +3272,13 @@ var PipRailClient = (_class2 = class {
|
|
|
3264
3272
|
try {
|
|
3265
3273
|
approved = await hook(quote);
|
|
3266
3274
|
} catch (err) {
|
|
3267
|
-
throw new (0,
|
|
3275
|
+
throw new (0, _chunkDKQXW454cjs.PaymentDeclinedError)("onBeforePay threw \u2014 refusing to pay.", {
|
|
3268
3276
|
cause: err,
|
|
3269
3277
|
reasonCode: "APPROVAL"
|
|
3270
3278
|
});
|
|
3271
3279
|
}
|
|
3272
3280
|
if (!approved) {
|
|
3273
|
-
throw new (0,
|
|
3281
|
+
throw new (0, _chunkDKQXW454cjs.PaymentDeclinedError)(
|
|
3274
3282
|
`onBeforePay declined ${quote.amountFormatted} ${_nullishCoalesce(quote.symbol, () => ( ""))}`.trimEnd() + ` on ${quote.network}.`,
|
|
3275
3283
|
{ reasonCode: "APPROVAL" }
|
|
3276
3284
|
);
|
|
@@ -3295,7 +3303,7 @@ var PipRailClient = (_class2 = class {
|
|
|
3295
3303
|
}
|
|
3296
3304
|
async payAndConfirm(net, wallet, accept) {
|
|
3297
3305
|
if (!net.supports(accept.network)) {
|
|
3298
|
-
throw new (0,
|
|
3306
|
+
throw new (0, _chunkDKQXW454cjs.WrongChainError)(
|
|
3299
3307
|
`Challenge expects ${accept.network} but client is on ${net.network}.`
|
|
3300
3308
|
);
|
|
3301
3309
|
}
|
|
@@ -3348,7 +3356,7 @@ var PipRailClient = (_class2 = class {
|
|
|
3348
3356
|
});
|
|
3349
3357
|
} catch (err) {
|
|
3350
3358
|
if (timeoutController.signal.aborted) {
|
|
3351
|
-
throw new (0,
|
|
3359
|
+
throw new (0, _chunkDKQXW454cjs.PaymentTimeoutError)(
|
|
3352
3360
|
`Server did not respond within ${this.retryTimeoutMs}ms after broadcasting payment ${ref}. Re-verify or re-submit ref=${ref} \u2014 do NOT re-pay.`,
|
|
3353
3361
|
{ cause: err, ref }
|
|
3354
3362
|
);
|
|
@@ -3370,7 +3378,7 @@ var PipRailClient = (_class2 = class {
|
|
|
3370
3378
|
kind: "payment-failed",
|
|
3371
3379
|
reason: `server returned 402 after broadcasting payment ${ref}${unconfirmedNote} (${why})`
|
|
3372
3380
|
});
|
|
3373
|
-
throw new (0,
|
|
3381
|
+
throw new (0, _chunkDKQXW454cjs.MaxRetriesExceededError)(
|
|
3374
3382
|
`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).`,
|
|
3375
3383
|
{ ref }
|
|
3376
3384
|
);
|
|
@@ -3394,7 +3402,7 @@ var PipRailClient = (_class2 = class {
|
|
|
3394
3402
|
*/
|
|
3395
3403
|
async payExactRail(net, wallet, accept, url, init, quote) {
|
|
3396
3404
|
if (!net.payExact) {
|
|
3397
|
-
throw new (0,
|
|
3405
|
+
throw new (0, _chunkDKQXW454cjs.UnsupportedSchemeError)(
|
|
3398
3406
|
`the ${net.family} family can't pay a standard 'exact' rail (supported on EVM + Solana today).`
|
|
3399
3407
|
);
|
|
3400
3408
|
}
|
|
@@ -3404,7 +3412,7 @@ var PipRailClient = (_class2 = class {
|
|
|
3404
3412
|
headers.set(HEADER_SIGNATURE, buildExactSignatureHeader({ accepted, payload }));
|
|
3405
3413
|
const rejectDefinitive = (why2) => {
|
|
3406
3414
|
this.safeEmit({ kind: "payment-failed", reason: `exact: facilitator rejected nonce=${nonce} (${why2})` });
|
|
3407
|
-
throw new (0,
|
|
3415
|
+
throw new (0, _chunkDKQXW454cjs.MaxRetriesExceededError)(
|
|
3408
3416
|
`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}.`,
|
|
3409
3417
|
{ ref: nonce }
|
|
3410
3418
|
);
|
|
@@ -3427,7 +3435,7 @@ var PipRailClient = (_class2 = class {
|
|
|
3427
3435
|
try {
|
|
3428
3436
|
response = await fetch(url, { ..._nullishCoalesce(init, () => ( {})), headers, signal });
|
|
3429
3437
|
} catch (err) {
|
|
3430
|
-
throw new (0,
|
|
3438
|
+
throw new (0, _chunkDKQXW454cjs.PaymentTimeoutError)(
|
|
3431
3439
|
`exact: no response after submitting the authorization (nonce=${nonce}) to ${hostOf2(url)}. The facilitator may have already settled it \u2014 verify on-chain with authorizationState(${payerFrom}, ${nonce}) before re-presenting; do NOT re-pay.`,
|
|
3432
3440
|
{ cause: err, ref: nonce }
|
|
3433
3441
|
);
|
|
@@ -3460,7 +3468,7 @@ var PipRailClient = (_class2 = class {
|
|
|
3460
3468
|
kind: "payment-failed",
|
|
3461
3469
|
reason: `exact: 402 after submitting authorization nonce=${nonce} (${why})`
|
|
3462
3470
|
});
|
|
3463
|
-
throw new (0,
|
|
3471
|
+
throw new (0, _chunkDKQXW454cjs.MaxRetriesExceededError)(
|
|
3464
3472
|
`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 authorizationState(${payerFrom}, ${nonce}) first. ref=${nonce}.`,
|
|
3465
3473
|
{ ref: nonce }
|
|
3466
3474
|
);
|
|
@@ -3573,7 +3581,7 @@ async function fetchAcross(clients, url, init) {
|
|
|
3573
3581
|
const best = rankAcross(live.map((p) => p.plan)).find((o) => o.state === "payable");
|
|
3574
3582
|
if (!best) {
|
|
3575
3583
|
const hint = mergeDeclineHint(live.map((p) => p.plan));
|
|
3576
|
-
throw new (0,
|
|
3584
|
+
throw new (0, _chunkDKQXW454cjs.PaymentDeclinedError)(hint || "No funded chain can settle this payment right now.");
|
|
3577
3585
|
}
|
|
3578
3586
|
const owner = live.find((p) => p.plan.options.includes(best)).client;
|
|
3579
3587
|
return owner.fetch(url, { ..._nullishCoalesce(init, () => ( {})), autoRoute: true });
|
|
@@ -3669,9 +3677,9 @@ var MultiChainPayer = class _MultiChainPayer {
|
|
|
3669
3677
|
* ```ts
|
|
3670
3678
|
* const payer = MultiChainPayer.fromWallets({
|
|
3671
3679
|
* wallets: {
|
|
3672
|
-
* base: {
|
|
3673
|
-
* solana: {
|
|
3674
|
-
* xrpl: {
|
|
3680
|
+
* base: { key: process.env.EVM_KEY! },
|
|
3681
|
+
* solana: { key: process.env.SOLANA_SECRET! },
|
|
3682
|
+
* xrpl: { key: process.env.XRPL_SEED! },
|
|
3675
3683
|
* },
|
|
3676
3684
|
* policy: { maxAmount: '1.00', maxTotal: '20.00', tokens: ['USDC', 'USDT'] },
|
|
3677
3685
|
* })
|
|
@@ -3879,7 +3887,7 @@ function summarizePlan(plan) {
|
|
|
3879
3887
|
return `NOT payable: ${_nullishCoalesce(plan.fundingHint, () => ( `no settleable rail on ${plan.network}`))}`;
|
|
3880
3888
|
}
|
|
3881
3889
|
function explainDecline(err) {
|
|
3882
|
-
if (!(err instanceof
|
|
3890
|
+
if (!(err instanceof _chunkDKQXW454cjs.PipRailError)) {
|
|
3883
3891
|
return `Payment failed: ${err instanceof Error ? err.message : String(err)}`;
|
|
3884
3892
|
}
|
|
3885
3893
|
switch (err.code) {
|
|
@@ -4188,14 +4196,14 @@ function paymentTools(client) {
|
|
|
4188
4196
|
receipt: parseReceipt(res)
|
|
4189
4197
|
};
|
|
4190
4198
|
} catch (err) {
|
|
4191
|
-
if (err instanceof
|
|
4199
|
+
if (err instanceof _chunkDKQXW454cjs.PipRailError) {
|
|
4192
4200
|
const out = {
|
|
4193
4201
|
ok: false,
|
|
4194
4202
|
code: err.code,
|
|
4195
4203
|
reason: err.message,
|
|
4196
4204
|
explain: explainDecline(err)
|
|
4197
4205
|
};
|
|
4198
|
-
if (err instanceof
|
|
4206
|
+
if (err instanceof _chunkDKQXW454cjs.PaymentDeclinedError) {
|
|
4199
4207
|
out.declined = true;
|
|
4200
4208
|
if (err.reasonCode) out.reasonCode = err.reasonCode;
|
|
4201
4209
|
}
|
|
@@ -4522,13 +4530,13 @@ async function settleViaFacilitator(input) {
|
|
|
4522
4530
|
try {
|
|
4523
4531
|
verify = await post(`${base2}/verify`, body, auth);
|
|
4524
4532
|
} catch (err) {
|
|
4525
|
-
throw new (0,
|
|
4533
|
+
throw new (0, _chunkDKQXW454cjs.SettlementError)(
|
|
4526
4534
|
`exact settle (facilitator ${base2}): /verify request failed (${err instanceof Error ? err.message : String(err)}).`,
|
|
4527
4535
|
{ cause: err }
|
|
4528
4536
|
);
|
|
4529
4537
|
}
|
|
4530
4538
|
if (verify.status !== 200) {
|
|
4531
|
-
throw new (0,
|
|
4539
|
+
throw new (0, _chunkDKQXW454cjs.SettlementError)(
|
|
4532
4540
|
`exact settle (facilitator ${base2}): /verify returned HTTP ${verify.status} (transport/auth error).`
|
|
4533
4541
|
);
|
|
4534
4542
|
}
|
|
@@ -4544,13 +4552,13 @@ async function settleViaFacilitator(input) {
|
|
|
4544
4552
|
try {
|
|
4545
4553
|
settle = await post(`${base2}/settle`, body, auth);
|
|
4546
4554
|
} catch (err) {
|
|
4547
|
-
throw new (0,
|
|
4555
|
+
throw new (0, _chunkDKQXW454cjs.SettlementError)(
|
|
4548
4556
|
`exact settle (facilitator ${base2}): /settle request failed (${err instanceof Error ? err.message : String(err)}).`,
|
|
4549
4557
|
{ cause: err }
|
|
4550
4558
|
);
|
|
4551
4559
|
}
|
|
4552
4560
|
if (settle.status !== 200) {
|
|
4553
|
-
throw new (0,
|
|
4561
|
+
throw new (0, _chunkDKQXW454cjs.SettlementError)(
|
|
4554
4562
|
`exact settle (facilitator ${base2}): /settle returned HTTP ${settle.status} (transport/auth error).`
|
|
4555
4563
|
);
|
|
4556
4564
|
}
|
|
@@ -4617,7 +4625,7 @@ function createPaymentGate(options) {
|
|
|
4617
4625
|
}
|
|
4618
4626
|
net.assertValidPayTo(payTo);
|
|
4619
4627
|
const { asset, decimals, symbol } = net.resolveToken(a.token);
|
|
4620
|
-
const amountBase =
|
|
4628
|
+
const amountBase = _chunkDKQXW454cjs.parseUnits.call(void 0, a.amount, decimals);
|
|
4621
4629
|
const spec = { net, asset, decimals, symbol, amountBase, amountFormatted: a.amount, payTo };
|
|
4622
4630
|
if (options.exact) {
|
|
4623
4631
|
const outcome = await resolveExactRail(net, asset);
|
|
@@ -4649,7 +4657,7 @@ function createPaymentGate(options) {
|
|
|
4649
4657
|
if (settle === "self") {
|
|
4650
4658
|
if (cfg.relayer === void 0) {
|
|
4651
4659
|
throw new Error(
|
|
4652
|
-
"requirePayment: exact `settle: 'self'` needs a `relayer` wallet (the gas-paying key that broadcasts the settle), e.g. exact: { settle: 'self', relayer: {
|
|
4660
|
+
"requirePayment: exact `settle: 'self'` needs a `relayer` wallet (the gas-paying key that broadcasts the settle), e.g. exact: { settle: 'self', relayer: { key } }."
|
|
4653
4661
|
);
|
|
4654
4662
|
}
|
|
4655
4663
|
relayer = net.bindWallet(cfg.relayer);
|
|
@@ -4815,7 +4823,7 @@ function createPaymentGate(options) {
|
|
|
4815
4823
|
function enrichReceipt(spec, receipt) {
|
|
4816
4824
|
let amountFormatted = receipt.amount;
|
|
4817
4825
|
try {
|
|
4818
|
-
amountFormatted =
|
|
4826
|
+
amountFormatted = _chunkDKQXW454cjs.formatUnits.call(void 0, BigInt(receipt.amount), spec.decimals);
|
|
4819
4827
|
} catch (e35) {
|
|
4820
4828
|
}
|
|
4821
4829
|
return {
|
|
@@ -5005,7 +5013,7 @@ function requirePayment(options) {
|
|
|
5005
5013
|
try {
|
|
5006
5014
|
result = await gate.verify(_nullishCoalesce(req.headers[HEADER_SIGNATURE], () => ( req.headers[HEADER_SIGNATURE_V1])));
|
|
5007
5015
|
} catch (err) {
|
|
5008
|
-
if (err instanceof
|
|
5016
|
+
if (err instanceof _chunkDKQXW454cjs.SettlementError) {
|
|
5009
5017
|
res.status(502);
|
|
5010
5018
|
res.json({ x402Version: 2, error: "settlement_failed", detail: err.message });
|
|
5011
5019
|
return;
|
|
@@ -5038,25 +5046,49 @@ function normaliseHeader(value) {
|
|
|
5038
5046
|
|
|
5039
5047
|
// src/facilitators.ts
|
|
5040
5048
|
var KNOWN_FACILITATORS = {
|
|
5041
|
-
//
|
|
5042
|
-
//
|
|
5049
|
+
// Base (eip155:8453). Every entry is keyless and LIVE-settled by us (a real EIP-3009
|
|
5050
|
+
// exact payment, buyer paid zero ETH) — not just a /supported read — on the dated day.
|
|
5043
5051
|
"eip155:8453": [
|
|
5044
5052
|
{
|
|
5045
5053
|
url: "https://facilitator.payai.network",
|
|
5046
5054
|
keyless: true,
|
|
5047
5055
|
schemes: ["exact"],
|
|
5048
5056
|
settles: ["eip3009"],
|
|
5049
|
-
note: "PayAI \u2014 keyless, sponsors gas (Base USDC EIP-3009)"
|
|
5057
|
+
note: "PayAI \u2014 keyless, sponsors gas (Base USDC EIP-3009). Verified 2026-06-14 (/supported + live demo)."
|
|
5058
|
+
},
|
|
5059
|
+
{
|
|
5060
|
+
url: "https://facilitator.xpay.sh",
|
|
5061
|
+
keyless: true,
|
|
5062
|
+
schemes: ["exact"],
|
|
5063
|
+
settles: ["eip3009"],
|
|
5064
|
+
note: "xpay \u2014 keyless, zero-fee, sponsors gas. LIVE-settled on Base 2026-06-15 (tx 0x2273d5\u2026)."
|
|
5050
5065
|
}
|
|
5051
5066
|
],
|
|
5052
|
-
//
|
|
5067
|
+
// Solana (mainnet-beta). Keyless fee-payer sponsors for the SVM exact rail, each LIVE-settled
|
|
5068
|
+
// by us (a real SPL TransferChecked, buyer paid zero SOL) on the dated day — beyond a /supported
|
|
5069
|
+
// read. Daydreams + Questflow are intentionally ABSENT: their /supported is public but /verify
|
|
5070
|
+
// returns 401 (an API key is required), so they are not keyless for settlement.
|
|
5053
5071
|
"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp": [
|
|
5054
5072
|
{
|
|
5055
5073
|
url: "https://facilitator.payai.network",
|
|
5056
5074
|
keyless: true,
|
|
5057
5075
|
schemes: ["exact"],
|
|
5058
5076
|
settles: ["svm"],
|
|
5059
|
-
note: "PayAI \u2014 keyless fee-payer sponsor (Solana SPL SVM)"
|
|
5077
|
+
note: "PayAI \u2014 keyless fee-payer sponsor (Solana SPL SVM). LIVE-settled 2026-06-14 (tx 4dL8jRKH\u2026)."
|
|
5078
|
+
},
|
|
5079
|
+
{
|
|
5080
|
+
url: "https://pay.openfacilitator.io",
|
|
5081
|
+
keyless: true,
|
|
5082
|
+
schemes: ["exact"],
|
|
5083
|
+
settles: ["svm"],
|
|
5084
|
+
note: "OpenFacilitator \u2014 keyless (no signup), fee-payer sponsor. LIVE-settled on Solana 2026-06-15 (tx 5BabDtX\u2026)."
|
|
5085
|
+
},
|
|
5086
|
+
{
|
|
5087
|
+
url: "https://facilitator.corbits.dev",
|
|
5088
|
+
keyless: true,
|
|
5089
|
+
schemes: ["exact"],
|
|
5090
|
+
settles: ["svm"],
|
|
5091
|
+
note: "Corbits \u2014 keyless, Solana-first fee-payer sponsor. LIVE-settled on Solana 2026-06-15 (tx BCreYer\u2026)."
|
|
5060
5092
|
}
|
|
5061
5093
|
]
|
|
5062
5094
|
};
|
|
@@ -5267,4 +5299,4 @@ async function deliverReceipt(receipt, options) {
|
|
|
5267
5299
|
|
|
5268
5300
|
|
|
5269
5301
|
|
|
5270
|
-
exports.BRAND = BRAND; exports.CHAINS = CHAINS; exports.ConfirmationTimeoutError =
|
|
5302
|
+
exports.BRAND = BRAND; exports.CHAINS = CHAINS; exports.ConfirmationTimeoutError = _chunkDKQXW454cjs.ConfirmationTimeoutError; exports.DIRECTORY_INFO = DIRECTORY_INFO; exports.EIP3009_TYPES = EIP3009_TYPES; exports.EXACT_NETWORK_SLUGS = EXACT_NETWORK_SLUGS; 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 = _chunkDKQXW454cjs.InsufficientFundsError; exports.InvalidEnvelopeError = _chunkDKQXW454cjs.InvalidEnvelopeError; exports.KNOWN_FACILITATORS = KNOWN_FACILITATORS; exports.MaxRetriesExceededError = _chunkDKQXW454cjs.MaxRetriesExceededError; exports.MissingDriverError = _chunkDKQXW454cjs.MissingDriverError; exports.MultiChainPayer = MultiChainPayer; exports.NoCompatibleAcceptError = _chunkDKQXW454cjs.NoCompatibleAcceptError; exports.NonReplayableBodyError = _chunkDKQXW454cjs.NonReplayableBodyError; exports.PERMIT2_ADDRESS = PERMIT2_ADDRESS; exports.PERMIT2_PROXY_CHAIN_IDS = PERMIT2_PROXY_CHAIN_IDS; exports.PERMIT2_WITNESS_TYPES = PERMIT2_WITNESS_TYPES; exports.PIPRAIL_AGENT_GUIDE = PIPRAIL_AGENT_GUIDE; exports.POWERED_BY = POWERED_BY; exports.PaymentDeclinedError = _chunkDKQXW454cjs.PaymentDeclinedError; exports.PaymentTimeoutError = _chunkDKQXW454cjs.PaymentTimeoutError; exports.PipRailClient = PipRailClient; exports.PipRailError = _chunkDKQXW454cjs.PipRailError; exports.REGISTER_ATTRIBUTION = REGISTER_ATTRIBUTION; exports.RecipientNotReadyError = _chunkDKQXW454cjs.RecipientNotReadyError; exports.SettlementError = _chunkDKQXW454cjs.SettlementError; exports.UnknownTokenError = _chunkDKQXW454cjs.UnknownTokenError; exports.UnsupportedNetworkError = _chunkDKQXW454cjs.UnsupportedNetworkError; exports.UnsupportedSchemeError = _chunkDKQXW454cjs.UnsupportedSchemeError; exports.WalletRequiredError = _chunkDKQXW454cjs.WalletRequiredError; exports.WrongChainError = _chunkDKQXW454cjs.WrongChainError; exports.WrongFamilyError = _chunkDKQXW454cjs.WrongFamilyError; exports.X402_EXACT_PERMIT2_PROXY = X402_EXACT_PERMIT2_PROXY; exports.agentGuide = agentGuide; exports.appendAttribution = appendAttribution; exports.buildBazaarExtension = buildBazaarExtension; exports.buildChallengeHeader = buildChallengeHeader; exports.buildExactAuthorization = buildExactAuthorization; exports.buildExactSignatureHeader = buildExactSignatureHeader; exports.buildOpenApi = buildOpenApi; exports.buildReceiptHeader = buildReceiptHeader; exports.buildSelfDescription = buildSelfDescription; exports.buildSignatureHeader = buildSignatureHeader; exports.buildWellKnownX402 = buildWellKnownX402; exports.buildX402DnsTxt = buildX402DnsTxt; exports.chainIdForExactNetwork = chainIdForExactNetwork; exports.claim402IndexDomain = claim402IndexDomain; exports.classifyChallenge = classifyChallenge; exports.createPaymentGate = createPaymentGate; exports.decorateOutcome = decorateOutcome; exports.deliverReceipt = deliverReceipt; 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.getDirectoryInfo = getDirectoryInfo; exports.isPermit2ProxyChain = isPermit2ProxyChain; exports.knownFacilitatorsFor = knownFacilitatorsFor; exports.normalizeNetwork = normalizeNetwork; exports.parseChallenge = parseChallenge; exports.parseExactPaymentHeader = parseExactPaymentHeader; exports.parseExactRequirements = parseExactRequirements; exports.parseFacilitatorSupported = parseFacilitatorSupported; exports.parseReceipt = parseReceipt; exports.parseSettleResponse = parseSettleResponse; exports.parseSignatureHeader = parseSignatureHeader; exports.paymentTools = paymentTools; exports.pickAccept = pickAccept; exports.planAcross = planAcross; exports.readExactDomain = readExactDomain; exports.register402Index = register402Index; exports.registerDriver = registerDriver; exports.registerX402Scan = registerX402Scan; exports.renderLandingPage = renderLandingPage; exports.requirePayment = requirePayment; exports.resolveChain = resolveChain; exports.searchOpenIndexes = searchOpenIndexes; exports.settleViaFacilitator = settleViaFacilitator; exports.summarizePlan = summarizePlan; exports.toInsufficientFundsError = _chunkDKQXW454cjs.toInsufficientFundsError; exports.toInvalidBody = toInvalidBody; exports.verify402IndexDomain = verify402IndexDomain;
|