@piprail/sdk 1.13.1 → 1.14.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/CHAINS.md +3 -2
- package/CHANGELOG.md +39 -0
- package/ERRORS.md +2 -1
- package/README.md +19 -2
- package/STANDARDS.md +2 -0
- package/dist/{algorand-WGVF4KTU.js → algorand-7EUZYL2Z.js} +1 -1
- package/dist/{algorand-MXUSKX46.cjs → algorand-OIHGJN5S.cjs} +17 -17
- package/dist/{aptos-LPBLSEIQ.js → aptos-CDEYDDM5.js} +1 -1
- package/dist/{aptos-YT7SXWPF.cjs → aptos-WDWZOU25.cjs} +16 -16
- package/dist/{chunk-MDLZJGLY.cjs → chunk-FTKVCP6K.cjs} +24 -13
- package/dist/{chunk-SVMGHASK.js → chunk-H3A4KWLJ.js} +12 -1
- package/dist/index.cjs +405 -146
- package/dist/index.d.cts +209 -31
- package/dist/index.d.ts +209 -31
- package/dist/index.js +302 -43
- package/dist/{near-K6BDBABG.js → near-DT6LRIKB.js} +1 -1
- package/dist/{near-7ZDNISUX.cjs → near-FUH3VAXT.cjs} +19 -19
- package/dist/{solana-S3UFI3FE.js → solana-3TRYD4QB.js} +1 -1
- package/dist/{solana-PU7N2M64.cjs → solana-QUVXPKBZ.cjs} +14 -14
- package/dist/{stellar-VDQOFQEO.cjs → stellar-APZEBFAD.cjs} +21 -21
- package/dist/{stellar-Q5PO23SC.js → stellar-IK3UML6O.js} +1 -1
- package/dist/{sui-FKSMLKRF.cjs → sui-L7BQNJWO.cjs} +17 -17
- package/dist/{sui-WOXRKJXS.js → sui-VSE63WQM.js} +1 -1
- package/dist/{ton-VK6KRJHP.cjs → ton-5DLKKOFE.cjs} +14 -14
- package/dist/{ton-WPTXGLVK.js → ton-QHGQLJX2.js} +1 -1
- package/dist/{tron-6GXBXTR4.js → tron-2N2GA62O.js} +1 -1
- package/dist/{tron-WLOF5OUV.cjs → tron-HHIT6WKY.cjs} +24 -24
- package/dist/{xrpl-HEAPEXAM.js → xrpl-2GZMDYW5.js} +1 -1
- package/dist/{xrpl-CMNI25BV.cjs → xrpl-USEG4AHX.cjs} +21 -21
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
|
|
25
|
+
var _chunkFTKVCP6Kcjs = require('./chunk-FTKVCP6K.cjs');
|
|
25
26
|
|
|
26
27
|
// src/drivers/registry.ts
|
|
27
28
|
var byFamily = /* @__PURE__ */ new Map();
|
|
@@ -50,13 +51,13 @@ function resolveNetwork(opts) {
|
|
|
50
51
|
const family = familyForChain(opts.chain);
|
|
51
52
|
const driver = byFamily.get(family);
|
|
52
53
|
if (!driver) {
|
|
53
|
-
throw new (0,
|
|
54
|
+
throw new (0, _chunkFTKVCP6Kcjs.UnsupportedNetworkError)(
|
|
54
55
|
`No driver registered for the "${family}" family \u2014 it may not be mounted yet (use the async resolveNetwork()).`
|
|
55
56
|
);
|
|
56
57
|
}
|
|
57
58
|
const net = driver.resolve(opts);
|
|
58
59
|
if (!net) {
|
|
59
|
-
throw new (0,
|
|
60
|
+
throw new (0, _chunkFTKVCP6Kcjs.UnsupportedNetworkError)(
|
|
60
61
|
`The ${family} driver didn't recognise this chain input.`
|
|
61
62
|
);
|
|
62
63
|
}
|
|
@@ -97,13 +98,18 @@ var CHAINS = {
|
|
|
97
98
|
defaultRpc: "https://ethereum-rpc.publicnode.com",
|
|
98
99
|
tokens: {
|
|
99
100
|
USDC: { address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", decimals: 6, symbol: "USDC" },
|
|
100
|
-
USDT: { address: "0xdAC17F958D2ee523a2206206994597C13D831ec7", decimals: 6, symbol: "USDT" }
|
|
101
|
+
USDT: { address: "0xdAC17F958D2ee523a2206206994597C13D831ec7", decimals: 6, symbol: "USDT" },
|
|
102
|
+
// Circle EURC — EIP-3009 (exact-payable). On-chain EIP-712 domain name is "Euro Coin" here
|
|
103
|
+
// (NOT "EURC"); the buyer re-derives it on-chain, so the symbol below is display-only.
|
|
104
|
+
EURC: { address: "0x1aBaEA1f7C830bD89Acc67eC4af516284b1bC33c", decimals: 6, symbol: "EURC" }
|
|
101
105
|
}
|
|
102
106
|
},
|
|
103
107
|
base: {
|
|
104
108
|
chain: _chains.base,
|
|
105
109
|
tokens: {
|
|
106
|
-
USDC: { address: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", decimals: 6, symbol: "USDC" }
|
|
110
|
+
USDC: { address: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", decimals: 6, symbol: "USDC" },
|
|
111
|
+
// Circle EURC — EIP-3009 (exact-payable). On-chain EIP-712 domain name is "EURC" here.
|
|
112
|
+
EURC: { address: "0x60a3E35Cc302bFA44Cb288Bc5a4F316Fdb1adb42", decimals: 6, symbol: "EURC" }
|
|
107
113
|
}
|
|
108
114
|
},
|
|
109
115
|
arbitrum: {
|
|
@@ -139,7 +145,9 @@ var CHAINS = {
|
|
|
139
145
|
chain: _chains.avalanche,
|
|
140
146
|
tokens: {
|
|
141
147
|
USDC: { address: "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E", decimals: 6, symbol: "USDC" },
|
|
142
|
-
USDT: { address: "0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7", decimals: 6, symbol: "USDT" }
|
|
148
|
+
USDT: { address: "0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7", decimals: 6, symbol: "USDT" },
|
|
149
|
+
// Circle EURC — EIP-3009 (exact-payable). On-chain EIP-712 domain name is "Euro Coin" here.
|
|
150
|
+
EURC: { address: "0xC891EB4cbdEFf6e073e859e987815Ed1505c2ACD", decimals: 6, symbol: "EURC" }
|
|
143
151
|
}
|
|
144
152
|
},
|
|
145
153
|
// ── More popular EVM mainnets. Every address below was verified on-chain
|
|
@@ -312,12 +320,12 @@ function createWalletAdapter(config, resolved) {
|
|
|
312
320
|
}
|
|
313
321
|
const wc = config.walletClient;
|
|
314
322
|
if (!wc.account) {
|
|
315
|
-
throw new (0,
|
|
323
|
+
throw new (0, _chunkFTKVCP6Kcjs.WrongFamilyError)(
|
|
316
324
|
"chain is EVM; the provided walletClient has no attached account. Use `createWalletClient({ account, chain, transport })`, or pass { privateKey }."
|
|
317
325
|
);
|
|
318
326
|
}
|
|
319
327
|
if (wc.chain && wc.chain.id !== resolved.chainId) {
|
|
320
|
-
throw new (0,
|
|
328
|
+
throw new (0, _chunkFTKVCP6Kcjs.WrongChainError)(
|
|
321
329
|
`PipRailClient: walletClient is on chain ${wc.chain.id} but the SDK was configured with chain ${resolved.chainId}. They must match.`
|
|
322
330
|
);
|
|
323
331
|
}
|
|
@@ -591,6 +599,53 @@ function encodeXPaymentHeader(input) {
|
|
|
591
599
|
};
|
|
592
600
|
return base64(JSON.stringify(payload));
|
|
593
601
|
}
|
|
602
|
+
async function payExactEvm(input) {
|
|
603
|
+
const { publicClient, walletClient, account, chainId, accept } = input;
|
|
604
|
+
let code;
|
|
605
|
+
try {
|
|
606
|
+
code = await publicClient.getCode({ address: account.address });
|
|
607
|
+
} catch (e6) {
|
|
608
|
+
code = void 0;
|
|
609
|
+
}
|
|
610
|
+
if (code && code !== "0x") {
|
|
611
|
+
throw new (0, _chunkFTKVCP6Kcjs.UnsupportedSchemeError)(
|
|
612
|
+
`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.`
|
|
613
|
+
);
|
|
614
|
+
}
|
|
615
|
+
const domain = await readExactDomain(publicClient, accept.asset);
|
|
616
|
+
if (!domain) {
|
|
617
|
+
throw new (0, _chunkFTKVCP6Kcjs.UnsupportedSchemeError)(
|
|
618
|
+
`exact: ${accept.asset} on ${accept.network} isn't an EIP-3009 token (USDT needs Permit2; native coin and plain ERC-20s aren't exact-payable). Pay via onchain-proof.`
|
|
619
|
+
);
|
|
620
|
+
}
|
|
621
|
+
const g = globalThis.crypto;
|
|
622
|
+
if (!_optionalChain([g, 'optionalAccess', _5 => _5.getRandomValues])) {
|
|
623
|
+
throw new (0, _chunkFTKVCP6Kcjs.UnsupportedSchemeError)(
|
|
624
|
+
"this runtime lacks Web Crypto (globalThis.crypto.getRandomValues); the exact rail needs a CSPRNG nonce."
|
|
625
|
+
);
|
|
626
|
+
}
|
|
627
|
+
const raw = new Uint8Array(32);
|
|
628
|
+
g.getRandomValues(raw);
|
|
629
|
+
const nonce = `0x${[...raw].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
|
|
630
|
+
const now = Math.floor(Date.now() / 1e3);
|
|
631
|
+
const from = account.address;
|
|
632
|
+
const to = _viem.getAddress.call(void 0, accept.payTo);
|
|
633
|
+
const value = accept.amount;
|
|
634
|
+
const validAfter = "0";
|
|
635
|
+
const validBefore = String(now + accept.maxTimeoutSeconds);
|
|
636
|
+
const signature = await walletClient.signTypedData({
|
|
637
|
+
account,
|
|
638
|
+
domain: { name: domain.name, version: domain.version, chainId, verifyingContract: _viem.getAddress.call(void 0, accept.asset) },
|
|
639
|
+
types: EIP3009_TYPES,
|
|
640
|
+
primaryType: "TransferWithAuthorization",
|
|
641
|
+
message: { from, to, value: BigInt(value), validAfter: 0n, validBefore: BigInt(validBefore), nonce }
|
|
642
|
+
});
|
|
643
|
+
return {
|
|
644
|
+
payload: { signature, authorization: { from, to, value, validAfter, validBefore, nonce } },
|
|
645
|
+
payerFrom: from,
|
|
646
|
+
nonce
|
|
647
|
+
};
|
|
648
|
+
}
|
|
594
649
|
var eip3009Abi = [
|
|
595
650
|
{
|
|
596
651
|
type: "function",
|
|
@@ -644,7 +699,7 @@ async function readExactDomain(publicClient, asset) {
|
|
|
644
699
|
let token;
|
|
645
700
|
try {
|
|
646
701
|
token = _viem.getAddress.call(void 0, asset);
|
|
647
|
-
} catch (
|
|
702
|
+
} catch (e7) {
|
|
648
703
|
return null;
|
|
649
704
|
}
|
|
650
705
|
try {
|
|
@@ -662,7 +717,7 @@ async function readExactDomain(publicClient, asset) {
|
|
|
662
717
|
]);
|
|
663
718
|
if (typeof name !== "string" || typeof version !== "string" || !name || !version) return null;
|
|
664
719
|
return { name, version };
|
|
665
|
-
} catch (
|
|
720
|
+
} catch (e8) {
|
|
666
721
|
return null;
|
|
667
722
|
}
|
|
668
723
|
}
|
|
@@ -710,7 +765,7 @@ async function verifyAndSettleExactEvm(input) {
|
|
|
710
765
|
let fromCode;
|
|
711
766
|
try {
|
|
712
767
|
fromCode = await publicClient.getCode({ address: from });
|
|
713
|
-
} catch (
|
|
768
|
+
} catch (e9) {
|
|
714
769
|
return { ok: false, error: "tx_not_found", detail: `Could not read code at ${from} (transient RPC) \u2014 retry.` };
|
|
715
770
|
}
|
|
716
771
|
const isContractWallet = Boolean(fromCode && fromCode !== "0x");
|
|
@@ -746,7 +801,7 @@ async function verifyAndSettleExactEvm(input) {
|
|
|
746
801
|
if (used) {
|
|
747
802
|
return { ok: false, error: "tx_already_used", detail: `Authorization nonce ${nonce} already used or canceled on-chain.` };
|
|
748
803
|
}
|
|
749
|
-
} catch (
|
|
804
|
+
} catch (e10) {
|
|
750
805
|
return { ok: false, error: "tx_not_found", detail: "Could not read authorizationState (transient RPC) \u2014 retry." };
|
|
751
806
|
}
|
|
752
807
|
const baseArgs = [from, to, value, validAfter, validBefore, nonce];
|
|
@@ -786,7 +841,7 @@ async function verifyAndSettleExactEvm(input) {
|
|
|
786
841
|
args: writeArgs
|
|
787
842
|
});
|
|
788
843
|
} catch (err) {
|
|
789
|
-
throw new (0,
|
|
844
|
+
throw new (0, _chunkFTKVCP6Kcjs.SettlementError)(
|
|
790
845
|
`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.`,
|
|
791
846
|
{ cause: err }
|
|
792
847
|
);
|
|
@@ -798,7 +853,7 @@ async function verifyAndSettleExactEvm(input) {
|
|
|
798
853
|
return { ok: false, error: "tx_reverted", detail: `Settlement tx ${txHash} reverted on-chain.` };
|
|
799
854
|
}
|
|
800
855
|
} catch (err) {
|
|
801
|
-
throw new (0,
|
|
856
|
+
throw new (0, _chunkFTKVCP6Kcjs.SettlementError)(
|
|
802
857
|
`exact settle: broadcast ${txHash} but couldn't confirm it (${shorten(err instanceof Error ? err.message : String(err))}).`,
|
|
803
858
|
{ cause: err }
|
|
804
859
|
);
|
|
@@ -848,7 +903,7 @@ function decodeBase64(b64) {
|
|
|
848
903
|
function fromBase64Json(b64) {
|
|
849
904
|
try {
|
|
850
905
|
return JSON.parse(decodeBase64(b64));
|
|
851
|
-
} catch (
|
|
906
|
+
} catch (e11) {
|
|
852
907
|
return null;
|
|
853
908
|
}
|
|
854
909
|
}
|
|
@@ -873,6 +928,9 @@ function buildReceiptHeader(receipt) {
|
|
|
873
928
|
function buildSignatureHeader(signature) {
|
|
874
929
|
return toBase64Json(signature);
|
|
875
930
|
}
|
|
931
|
+
function buildExactSignatureHeader(input) {
|
|
932
|
+
return toBase64Json({ x402Version: 2, accepted: input.accepted, payload: input.payload });
|
|
933
|
+
}
|
|
876
934
|
async function parseChallenge(response) {
|
|
877
935
|
const headerValue = response.headers.get(HEADER_REQUIRED);
|
|
878
936
|
if (headerValue) {
|
|
@@ -882,22 +940,35 @@ async function parseChallenge(response) {
|
|
|
882
940
|
try {
|
|
883
941
|
const body = await response.clone().json();
|
|
884
942
|
if (isValidChallenge(body)) return body;
|
|
885
|
-
} catch (
|
|
943
|
+
} catch (e12) {
|
|
886
944
|
}
|
|
887
945
|
return null;
|
|
888
946
|
}
|
|
889
947
|
function parseReceipt(response) {
|
|
890
|
-
const headerValue = response.headers.get(HEADER_RESPONSE);
|
|
948
|
+
const headerValue = _nullishCoalesce(response.headers.get(HEADER_RESPONSE), () => ( response.headers.get(HEADER_RESPONSE_V1)));
|
|
891
949
|
if (!headerValue) return null;
|
|
892
950
|
const parsed = fromBase64Json(headerValue);
|
|
893
951
|
return isValidReceipt(parsed) ? parsed : null;
|
|
894
952
|
}
|
|
953
|
+
function parseSettleResponse(response) {
|
|
954
|
+
const headerValue = _nullishCoalesce(response.headers.get(HEADER_RESPONSE), () => ( response.headers.get(HEADER_RESPONSE_V1)));
|
|
955
|
+
if (!headerValue) return null;
|
|
956
|
+
const parsed = fromBase64Json(headerValue);
|
|
957
|
+
if (!parsed || typeof parsed !== "object" || typeof parsed.success !== "boolean") return null;
|
|
958
|
+
return {
|
|
959
|
+
success: parsed.success,
|
|
960
|
+
...typeof parsed.transaction === "string" ? { transaction: parsed.transaction } : {},
|
|
961
|
+
...typeof parsed.network === "string" ? { network: parsed.network } : {},
|
|
962
|
+
...typeof parsed.payer === "string" ? { payer: parsed.payer } : {},
|
|
963
|
+
...typeof parsed.errorReason === "string" ? { errorReason: parsed.errorReason } : {}
|
|
964
|
+
};
|
|
965
|
+
}
|
|
895
966
|
function parseSignatureHeader(value) {
|
|
896
967
|
const parsed = fromBase64Json(value);
|
|
897
968
|
if (!parsed || typeof parsed !== "object") return null;
|
|
898
969
|
const v = parsed;
|
|
899
970
|
const accepted = v.accepted;
|
|
900
|
-
const scheme = _nullishCoalesce(_optionalChain([accepted, 'optionalAccess',
|
|
971
|
+
const scheme = _nullishCoalesce(_optionalChain([accepted, 'optionalAccess', _6 => _6.scheme]), () => ( v.scheme));
|
|
901
972
|
if (scheme !== "onchain-proof") return null;
|
|
902
973
|
const payload = v.payload;
|
|
903
974
|
if (!payload || typeof payload.txHash !== "string" || typeof payload.nonce !== "string") {
|
|
@@ -910,9 +981,9 @@ function parseExactPaymentHeader(value) {
|
|
|
910
981
|
if (!parsed || typeof parsed !== "object") return null;
|
|
911
982
|
const v = parsed;
|
|
912
983
|
const accepted = _nullishCoalesce(v.accepted, () => ( null));
|
|
913
|
-
const scheme = _nullishCoalesce(_optionalChain([accepted, 'optionalAccess',
|
|
984
|
+
const scheme = _nullishCoalesce(_optionalChain([accepted, 'optionalAccess', _7 => _7.scheme]), () => ( v.scheme));
|
|
914
985
|
if (scheme !== "exact") return null;
|
|
915
|
-
const network = _nullishCoalesce(_optionalChain([accepted, 'optionalAccess',
|
|
986
|
+
const network = _nullishCoalesce(_optionalChain([accepted, 'optionalAccess', _8 => _8.network]), () => ( v.network));
|
|
916
987
|
if (typeof network !== "string") return null;
|
|
917
988
|
const payload = v.payload;
|
|
918
989
|
if (!payload || typeof payload !== "object") return null;
|
|
@@ -969,7 +1040,7 @@ var evmDriver = {
|
|
|
969
1040
|
let resolved;
|
|
970
1041
|
try {
|
|
971
1042
|
resolved = resolveChain(opts.chain, opts.rpcUrl);
|
|
972
|
-
} catch (
|
|
1043
|
+
} catch (e13) {
|
|
973
1044
|
return null;
|
|
974
1045
|
}
|
|
975
1046
|
return makeEvmNetwork(resolved);
|
|
@@ -997,15 +1068,15 @@ function makeEvmNetwork(resolved) {
|
|
|
997
1068
|
const info = resolved.tokens[token.toUpperCase()];
|
|
998
1069
|
if (!info) {
|
|
999
1070
|
const known = Object.keys(resolved.tokens).join(", ") || "(none built in)";
|
|
1000
|
-
throw new (0,
|
|
1071
|
+
throw new (0, _chunkFTKVCP6Kcjs.UnknownTokenError)(
|
|
1001
1072
|
`token "${token}" isn't built in for ${resolved.chain.name} (known: ${known}). Pass { address, decimals } instead, or use 'native'.`
|
|
1002
1073
|
);
|
|
1003
1074
|
}
|
|
1004
1075
|
return { asset: info.address, decimals: info.decimals, symbol: info.symbol };
|
|
1005
1076
|
}
|
|
1006
|
-
|
|
1077
|
+
_chunkFTKVCP6Kcjs.rejectForeignToken.call(void 0, token, "evm", network);
|
|
1007
1078
|
if (!("address" in token)) {
|
|
1008
|
-
throw new (0,
|
|
1079
|
+
throw new (0, _chunkFTKVCP6Kcjs.WrongFamilyError)(
|
|
1009
1080
|
`chain ${network} is EVM; a custom token must be { address, decimals }.`
|
|
1010
1081
|
);
|
|
1011
1082
|
}
|
|
@@ -1025,7 +1096,7 @@ function makeEvmNetwork(resolved) {
|
|
|
1025
1096
|
let normalized;
|
|
1026
1097
|
try {
|
|
1027
1098
|
normalized = _viem.getAddress.call(void 0, asset);
|
|
1028
|
-
} catch (
|
|
1099
|
+
} catch (e14) {
|
|
1029
1100
|
return null;
|
|
1030
1101
|
}
|
|
1031
1102
|
for (const info of Object.values(resolved.tokens)) {
|
|
@@ -1037,14 +1108,14 @@ function makeEvmNetwork(resolved) {
|
|
|
1037
1108
|
},
|
|
1038
1109
|
assertValidPayTo(payTo) {
|
|
1039
1110
|
if (!_viem.isAddress.call(void 0, payTo)) {
|
|
1040
|
-
throw new (0,
|
|
1111
|
+
throw new (0, _chunkFTKVCP6Kcjs.WrongFamilyError)(
|
|
1041
1112
|
`chain ${network} is EVM, but payTo "${payTo}" is not a valid 0x address.`
|
|
1042
1113
|
);
|
|
1043
1114
|
}
|
|
1044
1115
|
},
|
|
1045
1116
|
bindWallet(wallet) {
|
|
1046
1117
|
if (typeof wallet !== "object" || wallet === null || !("privateKey" in wallet) && !("walletClient" in wallet)) {
|
|
1047
|
-
throw new (0,
|
|
1118
|
+
throw new (0, _chunkFTKVCP6Kcjs.WrongFamilyError)(
|
|
1048
1119
|
`chain ${network} is EVM; wallet must be { privateKey } or { walletClient }.`
|
|
1049
1120
|
);
|
|
1050
1121
|
}
|
|
@@ -1061,12 +1132,12 @@ function makeEvmNetwork(resolved) {
|
|
|
1061
1132
|
});
|
|
1062
1133
|
} catch (err) {
|
|
1063
1134
|
if (isViemInsufficientFunds(err)) {
|
|
1064
|
-
throw new (0,
|
|
1135
|
+
throw new (0, _chunkFTKVCP6Kcjs.InsufficientFundsError)(
|
|
1065
1136
|
err instanceof Error ? err.message : "Insufficient funds for payment.",
|
|
1066
1137
|
{ cause: err }
|
|
1067
1138
|
);
|
|
1068
1139
|
}
|
|
1069
|
-
throw _nullishCoalesce(
|
|
1140
|
+
throw _nullishCoalesce(_chunkFTKVCP6Kcjs.toInsufficientFundsError.call(void 0, err), () => ( err));
|
|
1070
1141
|
}
|
|
1071
1142
|
},
|
|
1072
1143
|
async confirm(ref, minConfirmations) {
|
|
@@ -1077,7 +1148,7 @@ function makeEvmNetwork(resolved) {
|
|
|
1077
1148
|
});
|
|
1078
1149
|
return { height: receipt.blockNumber.toString() };
|
|
1079
1150
|
} catch (err) {
|
|
1080
|
-
throw new (0,
|
|
1151
|
+
throw new (0, _chunkFTKVCP6Kcjs.ConfirmationTimeoutError)(
|
|
1081
1152
|
`EVM tx ${ref} did not reach ${minConfirmations} confirmation(s) in time.`,
|
|
1082
1153
|
{ cause: err }
|
|
1083
1154
|
);
|
|
@@ -1085,19 +1156,28 @@ function makeEvmNetwork(resolved) {
|
|
|
1085
1156
|
},
|
|
1086
1157
|
async estimateCost(accept) {
|
|
1087
1158
|
const { decimals, symbol } = resolved.chain.nativeCurrency;
|
|
1159
|
+
if (accept.scheme === "exact") {
|
|
1160
|
+
return _chunkFTKVCP6Kcjs.nativeCost.call(void 0, {
|
|
1161
|
+
symbol,
|
|
1162
|
+
decimals,
|
|
1163
|
+
fee: 0n,
|
|
1164
|
+
basis: "estimated",
|
|
1165
|
+
detail: "gasless \u2014 the server/facilitator settles the signed authorization"
|
|
1166
|
+
});
|
|
1167
|
+
}
|
|
1088
1168
|
const gasLimit = accept.asset === "native" ? 21000n : 65000n;
|
|
1089
1169
|
try {
|
|
1090
1170
|
const gasPrice = await publicClient.getGasPrice();
|
|
1091
|
-
return
|
|
1171
|
+
return _chunkFTKVCP6Kcjs.nativeCost.call(void 0, {
|
|
1092
1172
|
symbol,
|
|
1093
1173
|
decimals,
|
|
1094
1174
|
fee: gasPrice * gasLimit,
|
|
1095
1175
|
basis: "estimated",
|
|
1096
1176
|
detail: `~${gasLimit} gas @ ${gasPrice} wei/gas`
|
|
1097
1177
|
});
|
|
1098
|
-
} catch (
|
|
1178
|
+
} catch (e15) {
|
|
1099
1179
|
const gasPrice = 5000000000n;
|
|
1100
|
-
return
|
|
1180
|
+
return _chunkFTKVCP6Kcjs.nativeCost.call(void 0, {
|
|
1101
1181
|
symbol,
|
|
1102
1182
|
decimals,
|
|
1103
1183
|
fee: gasPrice * gasLimit,
|
|
@@ -1118,7 +1198,7 @@ function makeEvmNetwork(resolved) {
|
|
|
1118
1198
|
functionName: "balanceOf",
|
|
1119
1199
|
args: [owner]
|
|
1120
1200
|
});
|
|
1121
|
-
} catch (
|
|
1201
|
+
} catch (e16) {
|
|
1122
1202
|
token = null;
|
|
1123
1203
|
}
|
|
1124
1204
|
return { token, native };
|
|
@@ -1146,6 +1226,21 @@ function makeEvmNetwork(resolved) {
|
|
|
1146
1226
|
minConfirmations: accept.extra.minConfirmations
|
|
1147
1227
|
});
|
|
1148
1228
|
},
|
|
1229
|
+
// Standard x402 `exact` rail (EIP-3009), BUYER side — EVM only. Re-derives the
|
|
1230
|
+
// token's EIP-712 domain on-chain, signs an authorization with the agent's own
|
|
1231
|
+
// key, and returns it for the client to frame into PAYMENT-SIGNATURE. Never
|
|
1232
|
+
// broadcasts. Throws UnsupportedSchemeError for a non-EIP-3009 token / contract signer.
|
|
1233
|
+
async payExact(wallet, accept) {
|
|
1234
|
+
const a = wallet._native;
|
|
1235
|
+
const { payload, payerFrom, nonce } = await payExactEvm({
|
|
1236
|
+
publicClient,
|
|
1237
|
+
walletClient: a.walletClient,
|
|
1238
|
+
account: a.account,
|
|
1239
|
+
chainId: resolved.chainId,
|
|
1240
|
+
accept
|
|
1241
|
+
});
|
|
1242
|
+
return { payload, accepted: accept, payerFrom, nonce };
|
|
1243
|
+
},
|
|
1149
1244
|
// Standard x402 `exact` rail (EIP-3009), seller side — EVM only.
|
|
1150
1245
|
async exactDomain(asset) {
|
|
1151
1246
|
return readExactDomain(publicClient, asset);
|
|
@@ -1176,9 +1271,9 @@ var loaders = {
|
|
|
1176
1271
|
solana: async () => {
|
|
1177
1272
|
let mod;
|
|
1178
1273
|
try {
|
|
1179
|
-
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./solana-
|
|
1274
|
+
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./solana-QUVXPKBZ.cjs")));
|
|
1180
1275
|
} catch (cause) {
|
|
1181
|
-
throw new (0,
|
|
1276
|
+
throw new (0, _chunkFTKVCP6Kcjs.MissingDriverError)(
|
|
1182
1277
|
`Solana selected, but its packages aren't installed. Run: npm install @solana/web3.js @solana/spl-token bs58`,
|
|
1183
1278
|
{ cause }
|
|
1184
1279
|
);
|
|
@@ -1188,9 +1283,9 @@ var loaders = {
|
|
|
1188
1283
|
ton: async () => {
|
|
1189
1284
|
let mod;
|
|
1190
1285
|
try {
|
|
1191
|
-
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./ton-
|
|
1286
|
+
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./ton-5DLKKOFE.cjs")));
|
|
1192
1287
|
} catch (cause) {
|
|
1193
|
-
throw new (0,
|
|
1288
|
+
throw new (0, _chunkFTKVCP6Kcjs.MissingDriverError)(
|
|
1194
1289
|
`TON selected, but its packages aren't installed. Run: npm install @ton/ton @ton/core @ton/crypto`,
|
|
1195
1290
|
{ cause }
|
|
1196
1291
|
);
|
|
@@ -1200,9 +1295,9 @@ var loaders = {
|
|
|
1200
1295
|
stellar: async () => {
|
|
1201
1296
|
let mod;
|
|
1202
1297
|
try {
|
|
1203
|
-
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./stellar-
|
|
1298
|
+
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./stellar-APZEBFAD.cjs")));
|
|
1204
1299
|
} catch (cause) {
|
|
1205
|
-
throw new (0,
|
|
1300
|
+
throw new (0, _chunkFTKVCP6Kcjs.MissingDriverError)(
|
|
1206
1301
|
`Stellar selected, but its package isn't installed. Run: npm install @stellar/stellar-sdk`,
|
|
1207
1302
|
{ cause }
|
|
1208
1303
|
);
|
|
@@ -1212,9 +1307,9 @@ var loaders = {
|
|
|
1212
1307
|
xrpl: async () => {
|
|
1213
1308
|
let mod;
|
|
1214
1309
|
try {
|
|
1215
|
-
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./xrpl-
|
|
1310
|
+
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./xrpl-USEG4AHX.cjs")));
|
|
1216
1311
|
} catch (cause) {
|
|
1217
|
-
throw new (0,
|
|
1312
|
+
throw new (0, _chunkFTKVCP6Kcjs.MissingDriverError)(
|
|
1218
1313
|
`XRPL selected, but its package isn't installed. Run: npm install xrpl`,
|
|
1219
1314
|
{ cause }
|
|
1220
1315
|
);
|
|
@@ -1224,9 +1319,9 @@ var loaders = {
|
|
|
1224
1319
|
tron: async () => {
|
|
1225
1320
|
let mod;
|
|
1226
1321
|
try {
|
|
1227
|
-
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./tron-
|
|
1322
|
+
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./tron-HHIT6WKY.cjs")));
|
|
1228
1323
|
} catch (cause) {
|
|
1229
|
-
throw new (0,
|
|
1324
|
+
throw new (0, _chunkFTKVCP6Kcjs.MissingDriverError)(
|
|
1230
1325
|
`Tron selected, but its package isn't installed. Run: npm install tronweb`,
|
|
1231
1326
|
{ cause }
|
|
1232
1327
|
);
|
|
@@ -1236,9 +1331,9 @@ var loaders = {
|
|
|
1236
1331
|
sui: async () => {
|
|
1237
1332
|
let mod;
|
|
1238
1333
|
try {
|
|
1239
|
-
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./sui-
|
|
1334
|
+
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./sui-L7BQNJWO.cjs")));
|
|
1240
1335
|
} catch (cause) {
|
|
1241
|
-
throw new (0,
|
|
1336
|
+
throw new (0, _chunkFTKVCP6Kcjs.MissingDriverError)(
|
|
1242
1337
|
`Sui selected, but its package isn't installed. Run: npm install @mysten/sui`,
|
|
1243
1338
|
{ cause }
|
|
1244
1339
|
);
|
|
@@ -1248,9 +1343,9 @@ var loaders = {
|
|
|
1248
1343
|
near: async () => {
|
|
1249
1344
|
let mod;
|
|
1250
1345
|
try {
|
|
1251
|
-
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./near-
|
|
1346
|
+
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./near-FUH3VAXT.cjs")));
|
|
1252
1347
|
} catch (cause) {
|
|
1253
|
-
throw new (0,
|
|
1348
|
+
throw new (0, _chunkFTKVCP6Kcjs.MissingDriverError)(
|
|
1254
1349
|
`NEAR selected, but its package isn't installed. Run: npm install near-api-js`,
|
|
1255
1350
|
{ cause }
|
|
1256
1351
|
);
|
|
@@ -1260,9 +1355,9 @@ var loaders = {
|
|
|
1260
1355
|
aptos: async () => {
|
|
1261
1356
|
let mod;
|
|
1262
1357
|
try {
|
|
1263
|
-
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./aptos-
|
|
1358
|
+
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./aptos-WDWZOU25.cjs")));
|
|
1264
1359
|
} catch (cause) {
|
|
1265
|
-
throw new (0,
|
|
1360
|
+
throw new (0, _chunkFTKVCP6Kcjs.MissingDriverError)(
|
|
1266
1361
|
`Aptos selected, but its package isn't installed. Run: npm install @aptos-labs/ts-sdk`,
|
|
1267
1362
|
{ cause }
|
|
1268
1363
|
);
|
|
@@ -1272,9 +1367,9 @@ var loaders = {
|
|
|
1272
1367
|
algorand: async () => {
|
|
1273
1368
|
let mod;
|
|
1274
1369
|
try {
|
|
1275
|
-
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./algorand-
|
|
1370
|
+
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./algorand-OIHGJN5S.cjs")));
|
|
1276
1371
|
} catch (cause) {
|
|
1277
|
-
throw new (0,
|
|
1372
|
+
throw new (0, _chunkFTKVCP6Kcjs.MissingDriverError)(
|
|
1278
1373
|
`Algorand selected, but its package isn't installed. Run: npm install algosdk`,
|
|
1279
1374
|
{ cause }
|
|
1280
1375
|
);
|
|
@@ -1391,7 +1486,7 @@ async function searchOpenIndexes(opts = {}) {
|
|
|
1391
1486
|
async function safeSearch(run) {
|
|
1392
1487
|
try {
|
|
1393
1488
|
return await run();
|
|
1394
|
-
} catch (
|
|
1489
|
+
} catch (e17) {
|
|
1395
1490
|
return [];
|
|
1396
1491
|
}
|
|
1397
1492
|
}
|
|
@@ -1497,7 +1592,7 @@ async function register402Index(input) {
|
|
|
1497
1592
|
if (res.ok) {
|
|
1498
1593
|
const body = await res.json().catch(() => ({}));
|
|
1499
1594
|
const msg = typeof body.message === "string" && body.message.length > 0 ? body.message : void 0;
|
|
1500
|
-
const live = _optionalChain([body, 'access',
|
|
1595
|
+
const live = _optionalChain([body, 'access', _9 => _9.service, 'optionalAccess', _10 => _10.status]) === "active";
|
|
1501
1596
|
return {
|
|
1502
1597
|
source: "402index",
|
|
1503
1598
|
ok: true,
|
|
@@ -1524,7 +1619,7 @@ async function readIndexError(res) {
|
|
|
1524
1619
|
(p) => typeof p === "string" && p.length > 0
|
|
1525
1620
|
);
|
|
1526
1621
|
return parts.length ? [...new Set(parts)].join(" \u2014 ") : void 0;
|
|
1527
|
-
} catch (
|
|
1622
|
+
} catch (e18) {
|
|
1528
1623
|
return void 0;
|
|
1529
1624
|
}
|
|
1530
1625
|
}
|
|
@@ -1634,11 +1729,11 @@ async function readSiwxInfo(res) {
|
|
|
1634
1729
|
try {
|
|
1635
1730
|
const body = await res.json();
|
|
1636
1731
|
const ext = body.extensions;
|
|
1637
|
-
const siwx = _optionalChain([ext, 'optionalAccess',
|
|
1638
|
-
const info = _nullishCoalesce(_optionalChain([siwx, 'optionalAccess',
|
|
1639
|
-
if (info && info.chainId == null && Array.isArray(_optionalChain([siwx, 'optionalAccess',
|
|
1732
|
+
const siwx = _optionalChain([ext, 'optionalAccess', _11 => _11["sign-in-with-x"]]);
|
|
1733
|
+
const info = _nullishCoalesce(_optionalChain([siwx, 'optionalAccess', _12 => _12.info]), () => ( siwx));
|
|
1734
|
+
if (info && info.chainId == null && Array.isArray(_optionalChain([siwx, 'optionalAccess', _13 => _13.supportedChains]))) {
|
|
1640
1735
|
const evm = siwx.supportedChains.find(
|
|
1641
|
-
(c) => typeof _optionalChain([c, 'optionalAccess',
|
|
1736
|
+
(c) => typeof _optionalChain([c, 'optionalAccess', _14 => _14.chainId]) === "string" && c.chainId.startsWith("eip155:")
|
|
1642
1737
|
);
|
|
1643
1738
|
if (evm && typeof evm.chainId === "string") info.chainId = evm.chainId;
|
|
1644
1739
|
}
|
|
@@ -1646,7 +1741,7 @@ async function readSiwxInfo(res) {
|
|
|
1646
1741
|
return info;
|
|
1647
1742
|
}
|
|
1648
1743
|
return null;
|
|
1649
|
-
} catch (
|
|
1744
|
+
} catch (e19) {
|
|
1650
1745
|
return null;
|
|
1651
1746
|
}
|
|
1652
1747
|
}
|
|
@@ -1694,7 +1789,7 @@ function mapRails(accepts) {
|
|
|
1694
1789
|
}
|
|
1695
1790
|
function matchesQuery(r, query) {
|
|
1696
1791
|
const q = query.toLowerCase();
|
|
1697
|
-
return r.resource.toLowerCase().includes(q) || (_nullishCoalesce(_optionalChain([r, 'access',
|
|
1792
|
+
return r.resource.toLowerCase().includes(q) || (_nullishCoalesce(_optionalChain([r, 'access', _15 => _15.name, 'optionalAccess', _16 => _16.toLowerCase, 'call', _17 => _17(), 'access', _18 => _18.includes, 'call', _19 => _19(q)]), () => ( false))) || (_nullishCoalesce(_optionalChain([r, 'access', _20 => _20.description, 'optionalAccess', _21 => _21.toLowerCase, 'call', _22 => _22(), 'access', _23 => _23.includes, 'call', _24 => _24(q)]), () => ( false)));
|
|
1698
1793
|
}
|
|
1699
1794
|
function pickString(o, ...keys) {
|
|
1700
1795
|
for (const k of keys) {
|
|
@@ -1727,7 +1822,7 @@ function hostOf(url) {
|
|
|
1727
1822
|
try {
|
|
1728
1823
|
const withScheme = /^[a-z][a-z0-9+.-]*:\/\//i.test(url) ? url : `https://${url}`;
|
|
1729
1824
|
return new URL(withScheme).hostname || url;
|
|
1730
|
-
} catch (
|
|
1825
|
+
} catch (e20) {
|
|
1731
1826
|
return url;
|
|
1732
1827
|
}
|
|
1733
1828
|
}
|
|
@@ -1792,7 +1887,7 @@ function evaluatePolicy(intent, policy, spentForAssetBase) {
|
|
|
1792
1887
|
}
|
|
1793
1888
|
}
|
|
1794
1889
|
if (policy.maxAmount !== void 0) {
|
|
1795
|
-
const cap =
|
|
1890
|
+
const cap = _chunkFTKVCP6Kcjs.floorUnits.call(void 0, policy.maxAmount, intent.decimals);
|
|
1796
1891
|
if (intent.amountBase > cap) {
|
|
1797
1892
|
return deny(
|
|
1798
1893
|
`payment of ${intent.amountBase} base units exceeds policy.maxAmount ` + `(${policy.maxAmount} ${_nullishCoalesce(intent.symbol, () => ( ""))}).`.trimEnd()
|
|
@@ -1800,7 +1895,7 @@ function evaluatePolicy(intent, policy, spentForAssetBase) {
|
|
|
1800
1895
|
}
|
|
1801
1896
|
}
|
|
1802
1897
|
if (policy.maxTotal !== void 0) {
|
|
1803
|
-
const cap =
|
|
1898
|
+
const cap = _chunkFTKVCP6Kcjs.floorUnits.call(void 0, policy.maxTotal, intent.decimals);
|
|
1804
1899
|
if (spentForAssetBase + intent.amountBase > cap) {
|
|
1805
1900
|
return deny(
|
|
1806
1901
|
`this payment would push spend on ${_nullishCoalesce(intent.symbol, () => ( intent.asset))} past policy.maxTotal (${policy.maxTotal}); already spent ${spentForAssetBase} base units.`
|
|
@@ -1838,7 +1933,7 @@ var SpendLedger = (_class = class {constructor() { _class.prototype.__init.call(
|
|
|
1838
1933
|
}
|
|
1839
1934
|
/** Running total (base units) already spent on this (network, asset). */
|
|
1840
1935
|
totalFor(network, asset) {
|
|
1841
|
-
return _nullishCoalesce(_optionalChain([this, 'access',
|
|
1936
|
+
return _nullishCoalesce(_optionalChain([this, 'access', _25 => _25.buckets, 'access', _26 => _26.get, 'call', _27 => _27(keyFor(network, asset)), 'optionalAccess', _28 => _28.total]), () => ( 0n));
|
|
1842
1937
|
}
|
|
1843
1938
|
/** An immutable snapshot of all spend so far. */
|
|
1844
1939
|
summary() {
|
|
@@ -1850,7 +1945,7 @@ var SpendLedger = (_class = class {constructor() { _class.prototype.__init.call(
|
|
|
1850
1945
|
symbol: b.symbol,
|
|
1851
1946
|
decimals: b.decimals,
|
|
1852
1947
|
totalBase: b.total.toString(),
|
|
1853
|
-
totalFormatted:
|
|
1948
|
+
totalFormatted: _chunkFTKVCP6Kcjs.formatUnits.call(void 0, b.total, b.decimals),
|
|
1854
1949
|
count: b.count
|
|
1855
1950
|
})),
|
|
1856
1951
|
records: [...this.records]
|
|
@@ -1859,6 +1954,7 @@ var SpendLedger = (_class = class {constructor() { _class.prototype.__init.call(
|
|
|
1859
1954
|
}, _class);
|
|
1860
1955
|
|
|
1861
1956
|
// src/client.ts
|
|
1957
|
+
var DEFAULT_SCHEMES = ["onchain-proof"];
|
|
1862
1958
|
var RECIPIENT_FIX = {
|
|
1863
1959
|
NO_TRUSTLINE: "the recipient needs a one-time trustline for this asset before it can receive",
|
|
1864
1960
|
NOT_REGISTERED: "the recipient must be storage_deposit-registered on this token (NEP-145, one-time)",
|
|
@@ -1887,7 +1983,7 @@ var PipRailClient = (_class2 = class {
|
|
|
1887
1983
|
safeEmit(event) {
|
|
1888
1984
|
try {
|
|
1889
1985
|
this.onEvent(event);
|
|
1890
|
-
} catch (
|
|
1986
|
+
} catch (e21) {
|
|
1891
1987
|
}
|
|
1892
1988
|
}
|
|
1893
1989
|
/** Auto-mount the chain's driver, resolve the network, and bind the wallet — once. */
|
|
@@ -1901,6 +1997,11 @@ var PipRailClient = (_class2 = class {
|
|
|
1901
1997
|
return { net, wallet };
|
|
1902
1998
|
})();
|
|
1903
1999
|
}
|
|
2000
|
+
/** Resolve the effective scheme set: a per-call override, else the constructor's
|
|
2001
|
+
* `schemes`, else the `onchain-proof`-only default. */
|
|
2002
|
+
resolveSchemes(perCall) {
|
|
2003
|
+
return _nullishCoalesce(_nullishCoalesce(perCall, () => ( this.opts.schemes)), () => ( DEFAULT_SCHEMES));
|
|
2004
|
+
}
|
|
1904
2005
|
/** GET that auto-handles 402. Pass a full URL to any x402-gated endpoint. */
|
|
1905
2006
|
get(url, init) {
|
|
1906
2007
|
return this.fetch(url, { ..._nullishCoalesce(init, () => ( {})), method: "GET" });
|
|
@@ -1912,7 +2013,7 @@ var PipRailClient = (_class2 = class {
|
|
|
1912
2013
|
* as-is) or a plain object (serialised as JSON).
|
|
1913
2014
|
*/
|
|
1914
2015
|
post(url, body, init) {
|
|
1915
|
-
const headers = new Headers(_optionalChain([init, 'optionalAccess',
|
|
2016
|
+
const headers = new Headers(_optionalChain([init, 'optionalAccess', _29 => _29.headers]));
|
|
1916
2017
|
let payload;
|
|
1917
2018
|
if (body === void 0 || body === null) {
|
|
1918
2019
|
payload = void 0;
|
|
@@ -1943,9 +2044,9 @@ var PipRailClient = (_class2 = class {
|
|
|
1943
2044
|
* "0.05 USDC on Base, within budget → pay it." No funds move.
|
|
1944
2045
|
*/
|
|
1945
2046
|
async quote(url, init) {
|
|
1946
|
-
const res = await fetch(url, { ..._nullishCoalesce(init, () => ( {})), method: _nullishCoalesce(_optionalChain([init, 'optionalAccess',
|
|
2047
|
+
const res = await fetch(url, { ..._nullishCoalesce(init, () => ( {})), method: _nullishCoalesce(_optionalChain([init, 'optionalAccess', _30 => _30.method]), () => ( "GET")) });
|
|
1947
2048
|
if (res.status !== 402) return null;
|
|
1948
|
-
const { quote } = await this.resolveChallenge(url, res);
|
|
2049
|
+
const { quote } = await this.resolveChallenge(url, res, this.resolveSchemes());
|
|
1949
2050
|
return quote;
|
|
1950
2051
|
}
|
|
1951
2052
|
/**
|
|
@@ -1962,9 +2063,9 @@ var PipRailClient = (_class2 = class {
|
|
|
1962
2063
|
* on Tron, where a USD₮ transfer can cost real TRX.
|
|
1963
2064
|
*/
|
|
1964
2065
|
async estimateCost(url, init) {
|
|
1965
|
-
const res = await fetch(url, { ..._nullishCoalesce(init, () => ( {})), method: _nullishCoalesce(_optionalChain([init, 'optionalAccess',
|
|
2066
|
+
const res = await fetch(url, { ..._nullishCoalesce(init, () => ( {})), method: _nullishCoalesce(_optionalChain([init, 'optionalAccess', _31 => _31.method]), () => ( "GET")) });
|
|
1966
2067
|
if (res.status !== 402) return null;
|
|
1967
|
-
const { net, accept, quote } = await this.resolveChallenge(url, res);
|
|
2068
|
+
const { net, accept, quote } = await this.resolveChallenge(url, res, this.resolveSchemes());
|
|
1968
2069
|
const cost = await net.estimateCost(accept);
|
|
1969
2070
|
return { quote, cost };
|
|
1970
2071
|
}
|
|
@@ -1993,14 +2094,14 @@ var PipRailClient = (_class2 = class {
|
|
|
1993
2094
|
* the plan yourself. No funds move.
|
|
1994
2095
|
*/
|
|
1995
2096
|
async planPayment(url, init) {
|
|
1996
|
-
const res = await fetch(url, { ..._nullishCoalesce(init, () => ( {})), method: _nullishCoalesce(_optionalChain([init, 'optionalAccess',
|
|
2097
|
+
const res = await fetch(url, { ..._nullishCoalesce(init, () => ( {})), method: _nullishCoalesce(_optionalChain([init, 'optionalAccess', _32 => _32.method]), () => ( "GET")) });
|
|
1997
2098
|
if (res.status !== 402) return null;
|
|
1998
2099
|
const challenge = await parseChallenge(res);
|
|
1999
2100
|
if (!challenge) {
|
|
2000
|
-
throw new (0,
|
|
2101
|
+
throw new (0, _chunkFTKVCP6Kcjs.InvalidEnvelopeError)("402 response did not include a parseable x402 challenge.");
|
|
2001
2102
|
}
|
|
2002
2103
|
const { net, wallet } = await this.ensure();
|
|
2003
|
-
return this.planFromChallenge(net, wallet, challenge, url);
|
|
2104
|
+
return this.planFromChallenge(net, wallet, challenge, url, this.resolveSchemes());
|
|
2004
2105
|
}
|
|
2005
2106
|
/**
|
|
2006
2107
|
* Convenience over {@link planPayment}: can the wallet settle this URL right now?
|
|
@@ -2028,8 +2129,8 @@ var PipRailClient = (_class2 = class {
|
|
|
2028
2129
|
* - A resource just listed via {@link register} may not appear yet — 402 Index reviews
|
|
2029
2130
|
* before publishing, so retry with a brief backoff if a fresh listing is missing.
|
|
2030
2131
|
* - Results are cross-scheme (mostly the mainstream `exact` scheme); `fetch()` pays
|
|
2031
|
-
*
|
|
2032
|
-
* `
|
|
2132
|
+
* `onchain-proof` rails by default, and standard `exact` rails too once you opt in
|
|
2133
|
+
* with `schemes: ['onchain-proof', 'exact']` (EVM + EIP-3009 — USDC/EURC).
|
|
2033
2134
|
*/
|
|
2034
2135
|
async discover(opts = {}) {
|
|
2035
2136
|
const found = await searchOpenIndexes({
|
|
@@ -2160,29 +2261,33 @@ var PipRailClient = (_class2 = class {
|
|
|
2160
2261
|
* streams throw `NonReplayableBodyError`.
|
|
2161
2262
|
*/
|
|
2162
2263
|
async fetch(url, init) {
|
|
2163
|
-
const body = _optionalChain([init, 'optionalAccess',
|
|
2264
|
+
const body = _optionalChain([init, 'optionalAccess', _33 => _33.body]);
|
|
2164
2265
|
if (body !== void 0 && body !== null && !isReplayableBodyInit(body)) {
|
|
2165
|
-
throw new (0,
|
|
2266
|
+
throw new (0, _chunkFTKVCP6Kcjs.NonReplayableBodyError)(
|
|
2166
2267
|
"fetch(): init.body is not replayable. Pass a string, FormData, URLSearchParams, ArrayBuffer, or Blob \u2014 not a ReadableStream."
|
|
2167
2268
|
);
|
|
2168
2269
|
}
|
|
2169
2270
|
const firstResponse = await fetch(url, init);
|
|
2170
2271
|
if (firstResponse.status !== 402) return firstResponse;
|
|
2171
|
-
const
|
|
2272
|
+
const schemes = this.resolveSchemes(_optionalChain([init, 'optionalAccess', _34 => _34.schemes]));
|
|
2273
|
+
const resolved = await this.resolveChallenge(url, firstResponse, schemes);
|
|
2172
2274
|
const { net, wallet, challenge } = resolved;
|
|
2173
2275
|
let accept = resolved.accept;
|
|
2174
2276
|
let quote = resolved.quote;
|
|
2175
|
-
const autoRoute = _nullishCoalesce(_nullishCoalesce(_optionalChain([init, 'optionalAccess',
|
|
2277
|
+
const autoRoute = _nullishCoalesce(_nullishCoalesce(_optionalChain([init, 'optionalAccess', _35 => _35.autoRoute]), () => ( this.opts.autoRoute)), () => ( false));
|
|
2176
2278
|
if (autoRoute) {
|
|
2177
|
-
const plan = await this.planFromChallenge(net, wallet, challenge, url);
|
|
2279
|
+
const plan = await this.planFromChallenge(net, wallet, challenge, url, schemes);
|
|
2178
2280
|
if (!plan.best) {
|
|
2179
|
-
throw new (0,
|
|
2281
|
+
throw new (0, _chunkFTKVCP6Kcjs.PaymentDeclinedError)(_nullishCoalesce(plan.fundingHint, () => ( "No rail is settleable for this payment.")));
|
|
2180
2282
|
}
|
|
2181
2283
|
accept = plan.best.accept;
|
|
2182
2284
|
quote = plan.best.quote;
|
|
2183
2285
|
}
|
|
2184
2286
|
this.safeEmit({ kind: "payment-required", challenge, accept });
|
|
2185
2287
|
await this.authorize(quote);
|
|
2288
|
+
if (accept.scheme === "exact") {
|
|
2289
|
+
return this.payExactRail(net, wallet, accept, url, init, quote);
|
|
2290
|
+
}
|
|
2186
2291
|
const { ref, confirmed } = await this.payAndConfirm(net, wallet, accept);
|
|
2187
2292
|
const response = await this.retryWithProof(url, init, accept, ref, confirmed);
|
|
2188
2293
|
this.recordSpend(quote, ref);
|
|
@@ -2194,19 +2299,37 @@ var PipRailClient = (_class2 = class {
|
|
|
2194
2299
|
* network, pick the accept the client can pay, and build its quote. Shared by
|
|
2195
2300
|
* `quote()` (read-only) and `fetch()` (which then authorises + pays).
|
|
2196
2301
|
*/
|
|
2197
|
-
async resolveChallenge(url, response) {
|
|
2302
|
+
async resolveChallenge(url, response, schemes) {
|
|
2198
2303
|
const challenge = await parseChallenge(response);
|
|
2199
2304
|
if (!challenge) {
|
|
2200
|
-
throw new (0,
|
|
2305
|
+
throw new (0, _chunkFTKVCP6Kcjs.InvalidEnvelopeError)(
|
|
2201
2306
|
"402 response did not include a parseable x402 challenge."
|
|
2202
2307
|
);
|
|
2203
2308
|
}
|
|
2204
2309
|
const { net, wallet } = await this.ensure();
|
|
2205
|
-
const candidates = this.gatherCandidates(net, challenge);
|
|
2310
|
+
const candidates = this.gatherCandidates(net, challenge, schemes);
|
|
2206
2311
|
if (candidates.length === 0) {
|
|
2207
|
-
const
|
|
2208
|
-
|
|
2209
|
-
|
|
2312
|
+
const exactOnNet = challenge.accepts.some(
|
|
2313
|
+
(a) => a.scheme === "exact" && net.supports(a.network)
|
|
2314
|
+
);
|
|
2315
|
+
if (schemes.includes("exact") && exactOnNet && typeof net.payExact !== "function") {
|
|
2316
|
+
throw new (0, _chunkFTKVCP6Kcjs.UnsupportedSchemeError)(
|
|
2317
|
+
`This 402 offers a standard 'exact' rail on ${net.network}, but the ${net.family} family can't pay 'exact' (EVM + EIP-3009 only), and no 'onchain-proof' rail was offered.`
|
|
2318
|
+
);
|
|
2319
|
+
}
|
|
2320
|
+
if (!schemes.includes("exact") && exactOnNet && typeof net.payExact === "function") {
|
|
2321
|
+
const payable = challenge.accepts.some(
|
|
2322
|
+
(a) => a.scheme === "exact" && net.supports(a.network) && net.describeAsset(a.asset) != null
|
|
2323
|
+
);
|
|
2324
|
+
if (payable) {
|
|
2325
|
+
throw new (0, _chunkFTKVCP6Kcjs.NoCompatibleAcceptError)(
|
|
2326
|
+
`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).`
|
|
2327
|
+
);
|
|
2328
|
+
}
|
|
2329
|
+
}
|
|
2330
|
+
const networks = [...new Set(challenge.accepts.map((a) => a.network))].join(", ");
|
|
2331
|
+
throw new (0, _chunkFTKVCP6Kcjs.NoCompatibleAcceptError)(
|
|
2332
|
+
`No accepts[] entry payable by this client on ${net.network} (schemes: ${schemes.join(", ")}; challenge offered: ${networks || "none"}).`
|
|
2210
2333
|
);
|
|
2211
2334
|
}
|
|
2212
2335
|
const priced = candidates.map((accept) => ({
|
|
@@ -2216,20 +2339,37 @@ var PipRailClient = (_class2 = class {
|
|
|
2216
2339
|
const chosen = _nullishCoalesce(priced.find((p) => p.quote.withinPolicy), () => ( priced[0]));
|
|
2217
2340
|
return { net, wallet, accept: chosen.accept, challenge, quote: chosen.quote };
|
|
2218
2341
|
}
|
|
2219
|
-
/** The candidate accepts this client could pay
|
|
2220
|
-
*
|
|
2221
|
-
*
|
|
2222
|
-
*
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
)
|
|
2342
|
+
/** The candidate accepts this client could pay, on the bound network. Always the
|
|
2343
|
+
* backendless `onchain-proof` rails; PLUS standard `exact` rails when `schemes`
|
|
2344
|
+
* enables them AND the driver can settle them (EVM `payExact` + a recognised
|
|
2345
|
+
* EIP-3009 token). `onchain-proof` is gathered FIRST so default selection is
|
|
2346
|
+
* unchanged when `exact` is off. */
|
|
2347
|
+
gatherCandidates(net, challenge, schemes) {
|
|
2348
|
+
const out = [];
|
|
2349
|
+
if (schemes.includes("onchain-proof")) {
|
|
2350
|
+
out.push(
|
|
2351
|
+
...challenge.accepts.filter(
|
|
2352
|
+
(a) => a.scheme === "onchain-proof" && net.supports(a.network)
|
|
2353
|
+
)
|
|
2354
|
+
);
|
|
2355
|
+
}
|
|
2356
|
+
if (schemes.includes("exact")) {
|
|
2357
|
+
out.push(
|
|
2358
|
+
...challenge.accepts.filter(
|
|
2359
|
+
(a) => a.scheme === "exact" && net.supports(a.network) && typeof net.payExact === "function" && net.describeAsset(a.asset) != null && // a foreign rail's maxTimeoutSeconds must be a usable positive integer, or
|
|
2360
|
+
// signing it would build a NaN/garbage validBefore — drop it silently
|
|
2361
|
+
// (symmetric with an unrecognised token) rather than leak a raw SyntaxError.
|
|
2362
|
+
Number.isInteger(a.maxTimeoutSeconds) && a.maxTimeoutSeconds > 0
|
|
2363
|
+
)
|
|
2364
|
+
);
|
|
2365
|
+
}
|
|
2366
|
+
return out;
|
|
2227
2367
|
}
|
|
2228
2368
|
/** Build the full {@link PaymentPlan} from an already-parsed challenge + bound
|
|
2229
2369
|
* net/wallet. Shared by `planPayment` (read-only) and `fetch`'s autoRoute. */
|
|
2230
|
-
async planFromChallenge(net, wallet, challenge, url) {
|
|
2370
|
+
async planFromChallenge(net, wallet, challenge, url, schemes) {
|
|
2231
2371
|
const chainLabel = typeof this.opts.chain === "string" ? this.opts.chain : net.network;
|
|
2232
|
-
const candidates = this.gatherCandidates(net, challenge);
|
|
2372
|
+
const candidates = this.gatherCandidates(net, challenge, schemes);
|
|
2233
2373
|
if (candidates.length === 0) {
|
|
2234
2374
|
const offered = [...new Set(challenge.accepts.map((a) => a.network))].join(", ") || "none";
|
|
2235
2375
|
return {
|
|
@@ -2269,29 +2409,35 @@ var PipRailClient = (_class2 = class {
|
|
|
2269
2409
|
const rr = await net.recipientReady(accept.payTo, accept.asset).catch(() => ({ ready: "unknown" }));
|
|
2270
2410
|
const amount = BigInt(accept.amount);
|
|
2271
2411
|
const fee = safeBig(cost.fee);
|
|
2412
|
+
const isExact = accept.scheme === "exact";
|
|
2272
2413
|
const isNative = accept.asset === "native";
|
|
2273
2414
|
const blockers = [];
|
|
2274
2415
|
const warnings = [];
|
|
2275
2416
|
const shortfall = {};
|
|
2276
2417
|
if (!quote.withinPolicy) blockers.push("OUTSIDE_POLICY");
|
|
2277
2418
|
if (quote.symbolMismatch) warnings.push("SYMBOL_MISMATCH");
|
|
2278
|
-
if (cost.basis === "heuristic") warnings.push("GAS_HEURISTIC");
|
|
2419
|
+
if (!isExact && cost.basis === "heuristic") warnings.push("GAS_HEURISTIC");
|
|
2279
2420
|
const tokenKnown = bal.token != null;
|
|
2280
2421
|
const nativeKnown = bal.native != null;
|
|
2281
|
-
if (!tokenKnown || !nativeKnown) warnings.push("BALANCE_UNREADABLE");
|
|
2282
|
-
if (
|
|
2422
|
+
if (isExact ? !tokenKnown : !tokenKnown || !nativeKnown) warnings.push("BALANCE_UNREADABLE");
|
|
2423
|
+
if (isExact) {
|
|
2424
|
+
if (tokenKnown && bal.token < amount) {
|
|
2425
|
+
blockers.push("INSUFFICIENT_TOKEN");
|
|
2426
|
+
shortfall.token = _chunkFTKVCP6Kcjs.formatUnits.call(void 0, amount - bal.token, quote.decimals);
|
|
2427
|
+
}
|
|
2428
|
+
} else if (isNative) {
|
|
2283
2429
|
if (nativeKnown && bal.native < amount + fee) {
|
|
2284
2430
|
blockers.push("INSUFFICIENT_TOKEN");
|
|
2285
|
-
shortfall.token =
|
|
2431
|
+
shortfall.token = _chunkFTKVCP6Kcjs.formatUnits.call(void 0, amount + fee - bal.native, quote.decimals);
|
|
2286
2432
|
}
|
|
2287
2433
|
} else {
|
|
2288
2434
|
if (tokenKnown && bal.token < amount) {
|
|
2289
2435
|
blockers.push("INSUFFICIENT_TOKEN");
|
|
2290
|
-
shortfall.token =
|
|
2436
|
+
shortfall.token = _chunkFTKVCP6Kcjs.formatUnits.call(void 0, amount - bal.token, quote.decimals);
|
|
2291
2437
|
}
|
|
2292
2438
|
if (nativeKnown && bal.native < fee) {
|
|
2293
2439
|
blockers.push("INSUFFICIENT_GAS");
|
|
2294
|
-
shortfall.native =
|
|
2440
|
+
shortfall.native = _chunkFTKVCP6Kcjs.formatUnits.call(void 0, fee - bal.native, cost.feeDecimals);
|
|
2295
2441
|
} else if (nativeKnown && fee > 0n && bal.native < fee * 3n / 2n) {
|
|
2296
2442
|
warnings.push("THIN_GAS_MARGIN");
|
|
2297
2443
|
}
|
|
@@ -2306,7 +2452,7 @@ var PipRailClient = (_class2 = class {
|
|
|
2306
2452
|
} else {
|
|
2307
2453
|
recipient = { ready: rr.ready };
|
|
2308
2454
|
}
|
|
2309
|
-
const unreadable = isNative ? !nativeKnown : !tokenKnown || !nativeKnown;
|
|
2455
|
+
const unreadable = isExact ? !tokenKnown : isNative ? !nativeKnown : !tokenKnown || !nativeKnown;
|
|
2310
2456
|
const state = blockers.length ? "blocked" : unreadable || rr.ready === "unknown" ? "unknown" : "payable";
|
|
2311
2457
|
return {
|
|
2312
2458
|
accept,
|
|
@@ -2316,8 +2462,8 @@ var PipRailClient = (_class2 = class {
|
|
|
2316
2462
|
blockers,
|
|
2317
2463
|
warnings,
|
|
2318
2464
|
balance: {
|
|
2319
|
-
token: bal.token != null ?
|
|
2320
|
-
native: bal.native != null ?
|
|
2465
|
+
token: bal.token != null ? _chunkFTKVCP6Kcjs.formatUnits.call(void 0, bal.token, quote.decimals) : null,
|
|
2466
|
+
native: bal.native != null ? _chunkFTKVCP6Kcjs.formatUnits.call(void 0, bal.native, cost.feeDecimals) : null
|
|
2321
2467
|
},
|
|
2322
2468
|
need: { token: quote.amountFormatted, native: cost.feeFormatted },
|
|
2323
2469
|
...shortfall.token || shortfall.native ? { shortfall } : {},
|
|
@@ -2328,15 +2474,20 @@ var PipRailClient = (_class2 = class {
|
|
|
2328
2474
|
* driver's describeAsset) + the policy verdict + a symbol-mismatch flag. */
|
|
2329
2475
|
buildQuote(net, accept, url, description) {
|
|
2330
2476
|
if (!/^\d+$/.test(accept.amount)) {
|
|
2331
|
-
throw new (0,
|
|
2477
|
+
throw new (0, _chunkFTKVCP6Kcjs.InvalidEnvelopeError)(
|
|
2332
2478
|
`challenge amount "${accept.amount}" is not a base-unit integer.`
|
|
2333
2479
|
);
|
|
2334
2480
|
}
|
|
2335
2481
|
const amountBase = BigInt(accept.amount);
|
|
2336
2482
|
const described = net.describeAsset(accept.asset);
|
|
2337
|
-
const decimals = _nullishCoalesce(_optionalChain([described, 'optionalAccess',
|
|
2338
|
-
|
|
2339
|
-
|
|
2483
|
+
const decimals = _nullishCoalesce(_optionalChain([described, 'optionalAccess', _36 => _36.decimals]), () => ( accept.extra.decimals));
|
|
2484
|
+
if (decimals === void 0) {
|
|
2485
|
+
throw new (0, _chunkFTKVCP6Kcjs.InvalidEnvelopeError)(
|
|
2486
|
+
`challenge for ${accept.asset} on ${accept.network} states no decimals and the SDK doesn't recognise the token \u2014 refusing to price it.`
|
|
2487
|
+
);
|
|
2488
|
+
}
|
|
2489
|
+
const symbol = _nullishCoalesce(_optionalChain([described, 'optionalAccess', _37 => _37.symbol]), () => ( accept.extra.symbol));
|
|
2490
|
+
const amountFormatted = _chunkFTKVCP6Kcjs.formatUnits.call(void 0, amountBase, decimals);
|
|
2340
2491
|
const intent = {
|
|
2341
2492
|
host: hostOf2(url),
|
|
2342
2493
|
chain: this.opts.chain,
|
|
@@ -2376,7 +2527,7 @@ var PipRailClient = (_class2 = class {
|
|
|
2376
2527
|
* throwing PaymentDeclinedError, before any funds move. */
|
|
2377
2528
|
async authorize(quote) {
|
|
2378
2529
|
if (!quote.withinPolicy) {
|
|
2379
|
-
throw new (0,
|
|
2530
|
+
throw new (0, _chunkFTKVCP6Kcjs.PaymentDeclinedError)(
|
|
2380
2531
|
`Payment refused by policy: ${_nullishCoalesce(quote.policyReason, () => ( "not allowed"))}`
|
|
2381
2532
|
);
|
|
2382
2533
|
}
|
|
@@ -2386,12 +2537,12 @@ var PipRailClient = (_class2 = class {
|
|
|
2386
2537
|
try {
|
|
2387
2538
|
approved = await hook(quote);
|
|
2388
2539
|
} catch (err) {
|
|
2389
|
-
throw new (0,
|
|
2540
|
+
throw new (0, _chunkFTKVCP6Kcjs.PaymentDeclinedError)("onBeforePay threw \u2014 refusing to pay.", {
|
|
2390
2541
|
cause: err
|
|
2391
2542
|
});
|
|
2392
2543
|
}
|
|
2393
2544
|
if (!approved) {
|
|
2394
|
-
throw new (0,
|
|
2545
|
+
throw new (0, _chunkFTKVCP6Kcjs.PaymentDeclinedError)(
|
|
2395
2546
|
`onBeforePay declined ${quote.amountFormatted} ${_nullishCoalesce(quote.symbol, () => ( ""))}`.trimEnd() + ` on ${quote.network}.`
|
|
2396
2547
|
);
|
|
2397
2548
|
}
|
|
@@ -2415,7 +2566,7 @@ var PipRailClient = (_class2 = class {
|
|
|
2415
2566
|
}
|
|
2416
2567
|
async payAndConfirm(net, wallet, accept) {
|
|
2417
2568
|
if (!net.supports(accept.network)) {
|
|
2418
|
-
throw new (0,
|
|
2569
|
+
throw new (0, _chunkFTKVCP6Kcjs.WrongChainError)(
|
|
2419
2570
|
`Challenge expects ${accept.network} but client is on ${net.network}.`
|
|
2420
2571
|
);
|
|
2421
2572
|
}
|
|
@@ -2444,7 +2595,7 @@ var PipRailClient = (_class2 = class {
|
|
|
2444
2595
|
accepted: accept,
|
|
2445
2596
|
payload: { nonce: accept.extra.nonce, txHash: ref }
|
|
2446
2597
|
};
|
|
2447
|
-
const headers = new Headers(_optionalChain([originalInit, 'optionalAccess',
|
|
2598
|
+
const headers = new Headers(_optionalChain([originalInit, 'optionalAccess', _38 => _38.headers]));
|
|
2448
2599
|
headers.set(HEADER_SIGNATURE, buildSignatureHeader(signature));
|
|
2449
2600
|
let lastResponse = null;
|
|
2450
2601
|
let lastReason = null;
|
|
@@ -2459,7 +2610,7 @@ var PipRailClient = (_class2 = class {
|
|
|
2459
2610
|
() => timeoutController.abort(),
|
|
2460
2611
|
this.retryTimeoutMs
|
|
2461
2612
|
);
|
|
2462
|
-
const signal = _optionalChain([originalInit, 'optionalAccess',
|
|
2613
|
+
const signal = _optionalChain([originalInit, 'optionalAccess', _39 => _39.signal]) && typeof AbortSignal.any === "function" ? AbortSignal.any([timeoutController.signal, originalInit.signal]) : timeoutController.signal;
|
|
2463
2614
|
try {
|
|
2464
2615
|
lastResponse = await fetch(url, {
|
|
2465
2616
|
..._nullishCoalesce(originalInit, () => ( {})),
|
|
@@ -2468,7 +2619,7 @@ var PipRailClient = (_class2 = class {
|
|
|
2468
2619
|
});
|
|
2469
2620
|
} catch (err) {
|
|
2470
2621
|
if (timeoutController.signal.aborted) {
|
|
2471
|
-
throw new (0,
|
|
2622
|
+
throw new (0, _chunkFTKVCP6Kcjs.PaymentTimeoutError)(
|
|
2472
2623
|
`Server did not respond within ${this.retryTimeoutMs}ms after broadcasting payment ${ref}. Re-verify or re-submit ref=${ref} \u2014 do NOT re-pay.`,
|
|
2473
2624
|
{ cause: err, ref }
|
|
2474
2625
|
);
|
|
@@ -2490,16 +2641,111 @@ var PipRailClient = (_class2 = class {
|
|
|
2490
2641
|
kind: "payment-failed",
|
|
2491
2642
|
reason: `server returned 402 after broadcasting payment ${ref}${unconfirmedNote} (${why})`
|
|
2492
2643
|
});
|
|
2493
|
-
throw new (0,
|
|
2644
|
+
throw new (0, _chunkFTKVCP6Kcjs.MaxRetriesExceededError)(
|
|
2494
2645
|
`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).`,
|
|
2495
2646
|
{ ref }
|
|
2496
2647
|
);
|
|
2497
2648
|
}
|
|
2649
|
+
/**
|
|
2650
|
+
* Pay a standard x402 `exact` rail — a SEPARATE, fundamentally more conservative
|
|
2651
|
+
* path than {@link retryWithProof}. The buyer SIGNS an EIP-3009 authorization ONCE
|
|
2652
|
+
* (the driver's `payExact`) and the server / merchant-chosen facilitator BROADCASTS
|
|
2653
|
+
* it synchronously, so a blind re-POST of a still-in-flight authorization could
|
|
2654
|
+
* double-BROADCAST it. Hence, unlike the onchain-proof loop:
|
|
2655
|
+
*
|
|
2656
|
+
* • sign exactly once — reuse the SAME header on every retry, never re-sign;
|
|
2657
|
+
* • retry ONLY an explicit 402 (a definitive pre-broadcast rejection), bounded
|
|
2658
|
+
* well under `maxTimeoutSeconds` so the loop can't outlive the authorization;
|
|
2659
|
+
* • a post-POST transport error/timeout → {@link PaymentTimeoutError} carrying the
|
|
2660
|
+
* nonce (the facilitator MAY have settled — verify on-chain, NEVER re-pay);
|
|
2661
|
+
* • a 5xx → return as-is (server settle failure; the authorization stays valid +
|
|
2662
|
+
* its nonce unused) — no settled event, no spend;
|
|
2663
|
+
* • a 200 whose SettleResponse says `success:false` → a rejection, NEVER a spend;
|
|
2664
|
+
* • the spend is recorded EXACTLY ONCE, on an affirmative settlement only.
|
|
2665
|
+
*/
|
|
2666
|
+
async payExactRail(net, wallet, accept, url, init, quote) {
|
|
2667
|
+
if (!net.payExact) {
|
|
2668
|
+
throw new (0, _chunkFTKVCP6Kcjs.UnsupportedSchemeError)(
|
|
2669
|
+
`the ${net.family} family can't pay a standard 'exact' rail (EVM + EIP-3009 only).`
|
|
2670
|
+
);
|
|
2671
|
+
}
|
|
2672
|
+
throwIfAborted(_optionalChain([init, 'optionalAccess', _40 => _40.signal]));
|
|
2673
|
+
const { payload, accepted, payerFrom, nonce } = await net.payExact(wallet, accept);
|
|
2674
|
+
const headers = new Headers(_optionalChain([init, 'optionalAccess', _41 => _41.headers]));
|
|
2675
|
+
headers.set(HEADER_SIGNATURE, buildExactSignatureHeader({ accepted, payload }));
|
|
2676
|
+
const rejectDefinitive = (why2) => {
|
|
2677
|
+
this.safeEmit({ kind: "payment-failed", reason: `exact: facilitator rejected nonce=${nonce} (${why2})` });
|
|
2678
|
+
throw new (0, _chunkFTKVCP6Kcjs.MaxRetriesExceededError)(
|
|
2679
|
+
`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}.`,
|
|
2680
|
+
{ ref: nonce }
|
|
2681
|
+
);
|
|
2682
|
+
};
|
|
2683
|
+
const deadline = Date.now() + Math.max(1, Math.floor(accept.maxTimeoutSeconds / 2)) * 1e3;
|
|
2684
|
+
const maxAttempts = Math.min(this.maxRetries, 3);
|
|
2685
|
+
let lastReason = null;
|
|
2686
|
+
for (let attempt = 0; attempt < maxAttempts; attempt += 1) {
|
|
2687
|
+
if (attempt > 0) {
|
|
2688
|
+
if (Date.now() >= deadline) break;
|
|
2689
|
+
await new Promise((r) => setTimeout(r, Math.min(2e3, 400 * 2 ** (attempt - 1))));
|
|
2690
|
+
}
|
|
2691
|
+
throwIfAborted(_optionalChain([init, 'optionalAccess', _42 => _42.signal]));
|
|
2692
|
+
const budget = Math.min(this.retryTimeoutMs, deadline - Date.now());
|
|
2693
|
+
if (budget <= 0) break;
|
|
2694
|
+
const timeoutController = new AbortController();
|
|
2695
|
+
const timeoutId = setTimeout(() => timeoutController.abort(), budget);
|
|
2696
|
+
const signal = _optionalChain([init, 'optionalAccess', _43 => _43.signal]) && typeof AbortSignal.any === "function" ? AbortSignal.any([timeoutController.signal, init.signal]) : timeoutController.signal;
|
|
2697
|
+
let response;
|
|
2698
|
+
try {
|
|
2699
|
+
response = await fetch(url, { ..._nullishCoalesce(init, () => ( {})), headers, signal });
|
|
2700
|
+
} catch (err) {
|
|
2701
|
+
throw new (0, _chunkFTKVCP6Kcjs.PaymentTimeoutError)(
|
|
2702
|
+
`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.`,
|
|
2703
|
+
{ cause: err, ref: nonce }
|
|
2704
|
+
);
|
|
2705
|
+
} finally {
|
|
2706
|
+
clearTimeout(timeoutId);
|
|
2707
|
+
}
|
|
2708
|
+
const settle = parseSettleResponse(response);
|
|
2709
|
+
if (response.status === 402) {
|
|
2710
|
+
if (settle && settle.success === false) rejectDefinitive(_nullishCoalesce(settle.errorReason, () => ( "the facilitator reported success:false")));
|
|
2711
|
+
lastReason = await _asyncNullishCoalesce(await readInvalidReason(response), async () => ( lastReason));
|
|
2712
|
+
continue;
|
|
2713
|
+
}
|
|
2714
|
+
if (response.ok && !(settle && settle.success === false)) {
|
|
2715
|
+
const receipt = parseReceipt(response);
|
|
2716
|
+
this.safeEmit({ kind: "payment-settled", receipt, ...settle ? { settle } : {} });
|
|
2717
|
+
const ref = _optionalChain([settle, 'optionalAccess', _44 => _44.transaction]) || _optionalChain([receipt, 'optionalAccess', _45 => _45.transaction]) || `eip3009-nonce:${nonce}`;
|
|
2718
|
+
this.recordSpend(quote, ref);
|
|
2719
|
+
return response;
|
|
2720
|
+
}
|
|
2721
|
+
if (response.status >= 500) {
|
|
2722
|
+
this.safeEmit({ kind: "payment-failed", reason: `exact: server ${response.status} \u2014 authorization nonce=${nonce} not settled` });
|
|
2723
|
+
return response;
|
|
2724
|
+
}
|
|
2725
|
+
if (settle && settle.success === false) rejectDefinitive(_nullishCoalesce(settle.errorReason, () => ( "the facilitator reported success:false")));
|
|
2726
|
+
this.safeEmit({ kind: "payment-failed", reason: `exact: server ${response.status} \u2014 authorization nonce=${nonce} not settled` });
|
|
2727
|
+
return response;
|
|
2728
|
+
}
|
|
2729
|
+
const why = lastReason ? `${lastReason.error}${lastReason.detail ? ` \u2014 ${lastReason.detail}` : ""}` : "server gave no reason";
|
|
2730
|
+
this.safeEmit({
|
|
2731
|
+
kind: "payment-failed",
|
|
2732
|
+
reason: `exact: 402 after submitting authorization nonce=${nonce} (${why})`
|
|
2733
|
+
});
|
|
2734
|
+
throw new (0, _chunkFTKVCP6Kcjs.MaxRetriesExceededError)(
|
|
2735
|
+
`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}.`,
|
|
2736
|
+
{ ref: nonce }
|
|
2737
|
+
);
|
|
2738
|
+
}
|
|
2498
2739
|
}, _class2);
|
|
2740
|
+
function throwIfAborted(signal) {
|
|
2741
|
+
if (_optionalChain([signal, 'optionalAccess', _46 => _46.aborted])) {
|
|
2742
|
+
throw _nullishCoalesce(signal.reason, () => ( new DOMException("This operation was aborted.", "AbortError")));
|
|
2743
|
+
}
|
|
2744
|
+
}
|
|
2499
2745
|
function safeBig(s) {
|
|
2500
2746
|
try {
|
|
2501
2747
|
return BigInt(s);
|
|
2502
|
-
} catch (
|
|
2748
|
+
} catch (e22) {
|
|
2503
2749
|
return 0n;
|
|
2504
2750
|
}
|
|
2505
2751
|
}
|
|
@@ -2532,10 +2778,10 @@ function buildFundingHint(options, chainLabel) {
|
|
|
2532
2778
|
return `Couldn't fully read your wallet on ${chainLabel} (RPC throttled) \u2014 retry; you may already be able to pay ${target.quote.amountFormatted} ${sym}.`;
|
|
2533
2779
|
}
|
|
2534
2780
|
const parts = [];
|
|
2535
|
-
if (target.blockers.includes("INSUFFICIENT_TOKEN") && _optionalChain([target, 'access',
|
|
2781
|
+
if (target.blockers.includes("INSUFFICIENT_TOKEN") && _optionalChain([target, 'access', _47 => _47.shortfall, 'optionalAccess', _48 => _48.token])) {
|
|
2536
2782
|
parts.push(`top up ${target.shortfall.token} ${sym}`);
|
|
2537
2783
|
}
|
|
2538
|
-
if (target.blockers.includes("INSUFFICIENT_GAS") && _optionalChain([target, 'access',
|
|
2784
|
+
if (target.blockers.includes("INSUFFICIENT_GAS") && _optionalChain([target, 'access', _49 => _49.shortfall, 'optionalAccess', _50 => _50.native])) {
|
|
2539
2785
|
parts.push(`add ~${target.shortfall.native} ${target.cost.feeSymbol} for gas`);
|
|
2540
2786
|
}
|
|
2541
2787
|
return parts.length ? `Can't settle on ${chainLabel}: ${parts.join(" and ")} (to pay ${target.quote.amountFormatted} ${sym}).` : `Can't settle on ${chainLabel} for ${target.quote.amountFormatted} ${sym}.`;
|
|
@@ -2549,7 +2795,7 @@ async function planAcross(clients, url, init) {
|
|
|
2549
2795
|
const status = best ? "ready" : options.some((o) => o.state === "unknown") ? "unknown" : "blocked";
|
|
2550
2796
|
return {
|
|
2551
2797
|
url,
|
|
2552
|
-
network: _nullishCoalesce(_optionalChain([best, 'optionalAccess',
|
|
2798
|
+
network: _nullishCoalesce(_optionalChain([best, 'optionalAccess', _51 => _51.accept, 'access', _52 => _52.network]), () => ( live[0].network)),
|
|
2553
2799
|
status,
|
|
2554
2800
|
payable: best !== null,
|
|
2555
2801
|
best,
|
|
@@ -2565,7 +2811,7 @@ function railOnNetwork(rail, matches) {
|
|
|
2565
2811
|
function hostOf2(url) {
|
|
2566
2812
|
try {
|
|
2567
2813
|
return new URL(url).hostname;
|
|
2568
|
-
} catch (
|
|
2814
|
+
} catch (e23) {
|
|
2569
2815
|
return url;
|
|
2570
2816
|
}
|
|
2571
2817
|
}
|
|
@@ -2582,8 +2828,8 @@ function isReplayableBodyInit(value) {
|
|
|
2582
2828
|
async function readInvalidReason(response) {
|
|
2583
2829
|
try {
|
|
2584
2830
|
const body = await response.clone().json();
|
|
2585
|
-
const ext = _optionalChain([body, 'optionalAccess',
|
|
2586
|
-
const piprail = _optionalChain([ext, 'optionalAccess',
|
|
2831
|
+
const ext = _optionalChain([body, 'optionalAccess', _53 => _53.extensions]);
|
|
2832
|
+
const piprail = _optionalChain([ext, 'optionalAccess', _54 => _54.piprail]);
|
|
2587
2833
|
if (piprail && typeof piprail.code === "string") {
|
|
2588
2834
|
return {
|
|
2589
2835
|
error: piprail.code,
|
|
@@ -2596,8 +2842,16 @@ async function readInvalidReason(response) {
|
|
|
2596
2842
|
detail: typeof body.detail === "string" ? body.detail : ""
|
|
2597
2843
|
};
|
|
2598
2844
|
}
|
|
2599
|
-
|
|
2845
|
+
if (body && body.isValid === false && typeof body.invalidReason === "string") {
|
|
2846
|
+
return {
|
|
2847
|
+
error: body.invalidReason,
|
|
2848
|
+
detail: typeof body.invalidMessage === "string" ? body.invalidMessage : ""
|
|
2849
|
+
};
|
|
2850
|
+
}
|
|
2851
|
+
} catch (e24) {
|
|
2600
2852
|
}
|
|
2853
|
+
const settle = parseSettleResponse(response);
|
|
2854
|
+
if (_optionalChain([settle, 'optionalAccess', _55 => _55.errorReason])) return { error: settle.errorReason, detail: "" };
|
|
2601
2855
|
return null;
|
|
2602
2856
|
}
|
|
2603
2857
|
|
|
@@ -2607,7 +2861,7 @@ async function readBody(res) {
|
|
|
2607
2861
|
if (!text) return null;
|
|
2608
2862
|
try {
|
|
2609
2863
|
return JSON.parse(text);
|
|
2610
|
-
} catch (
|
|
2864
|
+
} catch (e25) {
|
|
2611
2865
|
return text;
|
|
2612
2866
|
}
|
|
2613
2867
|
}
|
|
@@ -2726,17 +2980,17 @@ function paymentTools(client) {
|
|
|
2726
2980
|
},
|
|
2727
2981
|
{
|
|
2728
2982
|
name: "piprail_pay_request",
|
|
2729
|
-
description: "Fetch an x402 payment-gated URL, automatically
|
|
2983
|
+
description: "Fetch an x402 payment-gated URL, automatically making the required payment if needed (subject to the spend policy + approval hook). Pays whichever rail the client is configured for \u2014 PipRail's backendless on-chain rail, or, when enabled, the standard `exact` rail (where the buyer signs and the server settles, so no buyer gas). Returns the HTTP status, the response body, and a payment receipt if one settled. If the payment is refused by policy or the approval hook, returns { declined: true, reason } \u2014 no funds moved.",
|
|
2730
2984
|
annotations: {
|
|
2731
2985
|
title: "Pay an x402 request",
|
|
2732
2986
|
readOnlyHint: false,
|
|
2733
2987
|
// this is the one tool that MOVES FUNDS
|
|
2734
2988
|
destructiveHint: true,
|
|
2735
|
-
//
|
|
2989
|
+
// a payment is value-moving and not reversible
|
|
2736
2990
|
idempotentHint: false,
|
|
2737
2991
|
// paying twice = two payments
|
|
2738
2992
|
openWorldHint: true
|
|
2739
|
-
// fetches a URL and settles
|
|
2993
|
+
// fetches a URL and settles a payment
|
|
2740
2994
|
},
|
|
2741
2995
|
parameters: {
|
|
2742
2996
|
type: "object",
|
|
@@ -2778,7 +3032,7 @@ function paymentTools(client) {
|
|
|
2778
3032
|
receipt: parseReceipt(res)
|
|
2779
3033
|
};
|
|
2780
3034
|
} catch (err) {
|
|
2781
|
-
if (err instanceof
|
|
3035
|
+
if (err instanceof _chunkFTKVCP6Kcjs.PaymentDeclinedError) {
|
|
2782
3036
|
return { declined: true, reason: err.message };
|
|
2783
3037
|
}
|
|
2784
3038
|
throw err;
|
|
@@ -2853,7 +3107,7 @@ function buildBazaarExtension(descriptor = {}) {
|
|
|
2853
3107
|
function pathOf(url) {
|
|
2854
3108
|
try {
|
|
2855
3109
|
return new URL(url).pathname || "/";
|
|
2856
|
-
} catch (
|
|
3110
|
+
} catch (e26) {
|
|
2857
3111
|
return url.startsWith("/") ? url : `/${url}`;
|
|
2858
3112
|
}
|
|
2859
3113
|
}
|
|
@@ -2926,7 +3180,7 @@ async function post(url, body, headers) {
|
|
|
2926
3180
|
let json = null;
|
|
2927
3181
|
try {
|
|
2928
3182
|
json = await res.json();
|
|
2929
|
-
} catch (
|
|
3183
|
+
} catch (e27) {
|
|
2930
3184
|
}
|
|
2931
3185
|
return { status: res.status, json };
|
|
2932
3186
|
}
|
|
@@ -2942,13 +3196,13 @@ async function settleViaFacilitator(input) {
|
|
|
2942
3196
|
try {
|
|
2943
3197
|
verify = await post(`${base2}/verify`, body, auth);
|
|
2944
3198
|
} catch (err) {
|
|
2945
|
-
throw new (0,
|
|
3199
|
+
throw new (0, _chunkFTKVCP6Kcjs.SettlementError)(
|
|
2946
3200
|
`exact settle (facilitator ${base2}): /verify request failed (${err instanceof Error ? err.message : String(err)}).`,
|
|
2947
3201
|
{ cause: err }
|
|
2948
3202
|
);
|
|
2949
3203
|
}
|
|
2950
3204
|
if (verify.status !== 200) {
|
|
2951
|
-
throw new (0,
|
|
3205
|
+
throw new (0, _chunkFTKVCP6Kcjs.SettlementError)(
|
|
2952
3206
|
`exact settle (facilitator ${base2}): /verify returned HTTP ${verify.status} (transport/auth error).`
|
|
2953
3207
|
);
|
|
2954
3208
|
}
|
|
@@ -2964,13 +3218,13 @@ async function settleViaFacilitator(input) {
|
|
|
2964
3218
|
try {
|
|
2965
3219
|
settle = await post(`${base2}/settle`, body, auth);
|
|
2966
3220
|
} catch (err) {
|
|
2967
|
-
throw new (0,
|
|
3221
|
+
throw new (0, _chunkFTKVCP6Kcjs.SettlementError)(
|
|
2968
3222
|
`exact settle (facilitator ${base2}): /settle request failed (${err instanceof Error ? err.message : String(err)}).`,
|
|
2969
3223
|
{ cause: err }
|
|
2970
3224
|
);
|
|
2971
3225
|
}
|
|
2972
3226
|
if (settle.status !== 200) {
|
|
2973
|
-
throw new (0,
|
|
3227
|
+
throw new (0, _chunkFTKVCP6Kcjs.SettlementError)(
|
|
2974
3228
|
`exact settle (facilitator ${base2}): /settle returned HTTP ${settle.status} (transport/auth error).`
|
|
2975
3229
|
);
|
|
2976
3230
|
}
|
|
@@ -3036,7 +3290,7 @@ function createPaymentGate(options) {
|
|
|
3036
3290
|
}
|
|
3037
3291
|
net.assertValidPayTo(payTo);
|
|
3038
3292
|
const { asset, decimals, symbol } = net.resolveToken(a.token);
|
|
3039
|
-
const amountBase =
|
|
3293
|
+
const amountBase = _chunkFTKVCP6Kcjs.parseUnits.call(void 0, a.amount, decimals);
|
|
3040
3294
|
const spec = { net, asset, decimals, symbol, amountBase, amountFormatted: a.amount, payTo };
|
|
3041
3295
|
if (options.exact) spec.exact = await resolveExactRail(net, asset);
|
|
3042
3296
|
return spec;
|
|
@@ -3151,7 +3405,7 @@ function createPaymentGate(options) {
|
|
|
3151
3405
|
const specs = await ready();
|
|
3152
3406
|
const nonce = genNonce();
|
|
3153
3407
|
const bazaar = options.discovery ? { bazaar: buildBazaarExtension(options.discovery === true ? {} : options.discovery) } : void 0;
|
|
3154
|
-
const extensions = { ...bazaar, ..._optionalChain([opts, 'optionalAccess',
|
|
3408
|
+
const extensions = { ...bazaar, ..._optionalChain([opts, 'optionalAccess', _56 => _56.extensions]) };
|
|
3155
3409
|
const challenge2 = {
|
|
3156
3410
|
x402Version: 2,
|
|
3157
3411
|
resource: {
|
|
@@ -3159,7 +3413,7 @@ function createPaymentGate(options) {
|
|
|
3159
3413
|
...options.description ? { description: options.description } : {}
|
|
3160
3414
|
},
|
|
3161
3415
|
accepts: buildAccepts(specs, nonce),
|
|
3162
|
-
..._optionalChain([opts, 'optionalAccess',
|
|
3416
|
+
..._optionalChain([opts, 'optionalAccess', _57 => _57.error]) ? { error: opts.error } : {},
|
|
3163
3417
|
...Object.keys(extensions).length > 0 ? { extensions } : {}
|
|
3164
3418
|
};
|
|
3165
3419
|
return { challenge: challenge2, requiredHeader: buildChallengeHeader(challenge2) };
|
|
@@ -3182,7 +3436,7 @@ function createPaymentGate(options) {
|
|
|
3182
3436
|
if (options.onPaid) {
|
|
3183
3437
|
try {
|
|
3184
3438
|
options.onPaid(receipt);
|
|
3185
|
-
} catch (
|
|
3439
|
+
} catch (e28) {
|
|
3186
3440
|
}
|
|
3187
3441
|
}
|
|
3188
3442
|
}
|
|
@@ -3278,7 +3532,9 @@ function createPaymentGate(options) {
|
|
|
3278
3532
|
amount: accept.amount,
|
|
3279
3533
|
payTo: accept.payTo,
|
|
3280
3534
|
maxTimeoutSeconds: accept.maxTimeoutSeconds,
|
|
3281
|
-
|
|
3535
|
+
// name/version are OPTIONAL on the wire type (a foreign rail may omit them), but the
|
|
3536
|
+
// gate's OWN exact rail always read them on-chain at resolution — so they're present here.
|
|
3537
|
+
extra: { name: _nullishCoalesce(accept.extra.name, () => ( "")), version: _nullishCoalesce(accept.extra.version, () => ( "")) }
|
|
3282
3538
|
},
|
|
3283
3539
|
receipt: { network: accept.network, asset: accept.asset, payTo: accept.payTo, amount: accept.amount },
|
|
3284
3540
|
payerHint: exact.payload.authorization.from
|
|
@@ -3316,7 +3572,7 @@ function requirePayment(options) {
|
|
|
3316
3572
|
try {
|
|
3317
3573
|
result = await gate.verify(_nullishCoalesce(req.headers[HEADER_SIGNATURE], () => ( req.headers[HEADER_SIGNATURE_V1])));
|
|
3318
3574
|
} catch (err) {
|
|
3319
|
-
if (err instanceof
|
|
3575
|
+
if (err instanceof _chunkFTKVCP6Kcjs.SettlementError) {
|
|
3320
3576
|
res.status(502);
|
|
3321
3577
|
res.json({ x402Version: 2, error: "settlement_failed", detail: err.message });
|
|
3322
3578
|
return;
|
|
@@ -3410,4 +3666,7 @@ function normaliseHeader(value) {
|
|
|
3410
3666
|
|
|
3411
3667
|
|
|
3412
3668
|
|
|
3413
|
-
|
|
3669
|
+
|
|
3670
|
+
|
|
3671
|
+
|
|
3672
|
+
exports.CHAINS = CHAINS; exports.ConfirmationTimeoutError = _chunkFTKVCP6Kcjs.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 = _chunkFTKVCP6Kcjs.InsufficientFundsError; exports.InvalidEnvelopeError = _chunkFTKVCP6Kcjs.InvalidEnvelopeError; exports.MaxRetriesExceededError = _chunkFTKVCP6Kcjs.MaxRetriesExceededError; exports.MissingDriverError = _chunkFTKVCP6Kcjs.MissingDriverError; exports.NoCompatibleAcceptError = _chunkFTKVCP6Kcjs.NoCompatibleAcceptError; exports.NonReplayableBodyError = _chunkFTKVCP6Kcjs.NonReplayableBodyError; exports.PaymentDeclinedError = _chunkFTKVCP6Kcjs.PaymentDeclinedError; exports.PaymentTimeoutError = _chunkFTKVCP6Kcjs.PaymentTimeoutError; exports.PipRailClient = PipRailClient; exports.PipRailError = _chunkFTKVCP6Kcjs.PipRailError; exports.RecipientNotReadyError = _chunkFTKVCP6Kcjs.RecipientNotReadyError; exports.SettlementError = _chunkFTKVCP6Kcjs.SettlementError; exports.UnknownTokenError = _chunkFTKVCP6Kcjs.UnknownTokenError; exports.UnsupportedNetworkError = _chunkFTKVCP6Kcjs.UnsupportedNetworkError; exports.UnsupportedSchemeError = _chunkFTKVCP6Kcjs.UnsupportedSchemeError; exports.WrongChainError = _chunkFTKVCP6Kcjs.WrongChainError; exports.WrongFamilyError = _chunkFTKVCP6Kcjs.WrongFamilyError; exports.buildBazaarExtension = buildBazaarExtension; exports.buildChallengeHeader = buildChallengeHeader; exports.buildExactAuthorization = buildExactAuthorization; exports.buildExactSignatureHeader = buildExactSignatureHeader; exports.buildOpenApi = buildOpenApi; exports.buildReceiptHeader = buildReceiptHeader; exports.buildSignatureHeader = buildSignatureHeader; exports.buildWellKnownX402 = buildWellKnownX402; exports.buildX402DnsTxt = buildX402DnsTxt; exports.chainIdForExactNetwork = chainIdForExactNetwork; exports.claim402IndexDomain = claim402IndexDomain; exports.createPaymentGate = createPaymentGate; exports.decorateOutcome = decorateOutcome; exports.eip3009Abi = eip3009Abi; exports.encodeXPaymentHeader = encodeXPaymentHeader; exports.evaluatePolicy = evaluatePolicy; exports.getDirectoryInfo = getDirectoryInfo; exports.normalizeNetwork = normalizeNetwork; exports.parseChallenge = parseChallenge; exports.parseExactPaymentHeader = parseExactPaymentHeader; exports.parseExactRequirements = parseExactRequirements; 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.requirePayment = requirePayment; exports.resolveChain = resolveChain; exports.searchOpenIndexes = searchOpenIndexes; exports.settleViaFacilitator = settleViaFacilitator; exports.toInsufficientFundsError = _chunkFTKVCP6Kcjs.toInsufficientFundsError; exports.toInvalidBody = toInvalidBody; exports.verify402IndexDomain = verify402IndexDomain;
|