@piprail/sdk 2.15.0 → 2.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +73 -0
- package/README.md +1 -1
- package/dist/{algorand-CSEUTWNW.js → algorand-UF7BLBFN.js} +1 -1
- package/dist/{algorand-I2O24RSM.cjs → algorand-XGSWDMCZ.cjs} +32 -32
- package/dist/{aptos-GA5AEYYL.cjs → aptos-J2QSWHTO.cjs} +31 -31
- package/dist/{aptos-J7QGCWNW.js → aptos-KDLX42CR.js} +1 -1
- package/dist/{chunk-3FR22M3O.cjs → chunk-QONQSZHJ.cjs} +2 -2
- package/dist/{chunk-3ZWM3DKM.js → chunk-QU25LSVS.js} +2 -2
- package/dist/index.cjs +167 -181
- package/dist/index.js +35 -49
- package/dist/{near-NDQLGI4U.cjs → near-5LTTDU6G.cjs} +27 -27
- package/dist/{near-YA4Y4IGC.js → near-OLKCMTBI.js} +1 -1
- package/dist/{solana-OU6IUMQM.cjs → solana-S2T3JNR7.cjs} +32 -32
- package/dist/{solana-MB6G3OA5.js → solana-WO2G7WWZ.js} +1 -1
- package/dist/{stellar-RSNVOIKL.cjs → stellar-E2KWEV2E.cjs} +20 -20
- package/dist/{stellar-WDWSYOED.js → stellar-EUFZLX6J.js} +1 -1
- package/dist/{sui-GVSFNNJX.js → sui-KCIITCYH.js} +6 -2
- package/dist/{sui-MVC46BFJ.cjs → sui-Q3NJOJZS.cjs} +21 -17
- package/dist/{ton-MYOI3U3H.cjs → ton-J7TQWRN4.cjs} +16 -16
- package/dist/{ton-EJMGM3YI.js → ton-WH2JVQOO.js} +1 -1
- package/dist/{tron-VAPVMGJK.js → tron-FXBXDNEY.js} +1 -1
- package/dist/{tron-42X5N4GQ.cjs → tron-HIPMOX7S.cjs} +25 -25
- package/dist/{xrpl-Q2UWPCTJ.js → xrpl-6B2XOXGC.js} +1 -1
- package/dist/{xrpl-MGUBUNSZ.cjs → xrpl-VOUXIUYD.cjs} +20 -20
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
parseUnits,
|
|
33
33
|
rejectForeignToken,
|
|
34
34
|
toInsufficientFundsError
|
|
35
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-QU25LSVS.js";
|
|
36
36
|
|
|
37
37
|
// src/drivers/registry.ts
|
|
38
38
|
var byFamily = /* @__PURE__ */ new Map();
|
|
@@ -1757,7 +1757,16 @@ function decodeBase64Json(value) {
|
|
|
1757
1757
|
return fromBase64Json(value);
|
|
1758
1758
|
}
|
|
1759
1759
|
function toBase64Json(value) {
|
|
1760
|
-
|
|
1760
|
+
let json;
|
|
1761
|
+
try {
|
|
1762
|
+
json = JSON.stringify(value);
|
|
1763
|
+
} catch (cause) {
|
|
1764
|
+
throw new InvalidConfigError(
|
|
1765
|
+
`x402: this payload cannot be serialised to JSON (${cause.message}). Amounts must be decimal STRINGS, not BigInt \u2014 pass '50000', not 50000n.`,
|
|
1766
|
+
{ cause }
|
|
1767
|
+
);
|
|
1768
|
+
}
|
|
1769
|
+
return encodeBase64(json);
|
|
1761
1770
|
}
|
|
1762
1771
|
function networkForChain(chainId) {
|
|
1763
1772
|
return `eip155:${chainId}`;
|
|
@@ -2296,7 +2305,19 @@ function makeEvmNetwork(resolved) {
|
|
|
2296
2305
|
return resolveExactRailEvm({
|
|
2297
2306
|
asset,
|
|
2298
2307
|
method,
|
|
2299
|
-
|
|
2308
|
+
// `readExactDomain` fails CLOSED to null on two very different causes: the token really
|
|
2309
|
+
// isn't EIP-3009, or the RPC read blipped (rate-limit, timeout, an HTML error page from a
|
|
2310
|
+
// proxy). Treating a blip as "not EIP-3009" silently downgrades a perfectly good gasless
|
|
2311
|
+
// rail to onchain-proof — the merchant's buyers start paying gas and the warning blames
|
|
2312
|
+
// their TOKEN, which is the one thing that isn't wrong. The buyer side already retries
|
|
2313
|
+
// once for exactly this reason (see payExactEvm); the gate side did not, so a rate-limited
|
|
2314
|
+
// public RPC could turn real Base USDC into "this token isn't EIP-3009". Mirror it.
|
|
2315
|
+
readDomain: async (a) => {
|
|
2316
|
+
const first = await readExactDomain(publicClient, a);
|
|
2317
|
+
if (first) return first;
|
|
2318
|
+
await new Promise((r) => setTimeout(r, 300));
|
|
2319
|
+
return readExactDomain(publicClient, a);
|
|
2320
|
+
},
|
|
2300
2321
|
permit2Supported: () => isPermit2ProxyChain(resolved.chainId)
|
|
2301
2322
|
});
|
|
2302
2323
|
},
|
|
@@ -2382,7 +2403,7 @@ var loaders = {
|
|
|
2382
2403
|
solana: async () => {
|
|
2383
2404
|
let mod;
|
|
2384
2405
|
try {
|
|
2385
|
-
mod = await import("./solana-
|
|
2406
|
+
mod = await import("./solana-WO2G7WWZ.js");
|
|
2386
2407
|
} catch (cause) {
|
|
2387
2408
|
throw new MissingDriverError(
|
|
2388
2409
|
`Solana selected, but its packages aren't installed. Run: npm install @solana/web3.js @solana/spl-token bs58`,
|
|
@@ -2394,7 +2415,7 @@ var loaders = {
|
|
|
2394
2415
|
ton: async () => {
|
|
2395
2416
|
let mod;
|
|
2396
2417
|
try {
|
|
2397
|
-
mod = await import("./ton-
|
|
2418
|
+
mod = await import("./ton-WH2JVQOO.js");
|
|
2398
2419
|
} catch (cause) {
|
|
2399
2420
|
throw new MissingDriverError(
|
|
2400
2421
|
`TON selected, but its packages aren't installed. Run: npm install @ton/ton @ton/core @ton/crypto`,
|
|
@@ -2406,7 +2427,7 @@ var loaders = {
|
|
|
2406
2427
|
stellar: async () => {
|
|
2407
2428
|
let mod;
|
|
2408
2429
|
try {
|
|
2409
|
-
mod = await import("./stellar-
|
|
2430
|
+
mod = await import("./stellar-EUFZLX6J.js");
|
|
2410
2431
|
} catch (cause) {
|
|
2411
2432
|
throw new MissingDriverError(
|
|
2412
2433
|
`Stellar selected, but its package isn't installed. Run: npm install @stellar/stellar-sdk`,
|
|
@@ -2418,7 +2439,7 @@ var loaders = {
|
|
|
2418
2439
|
xrpl: async () => {
|
|
2419
2440
|
let mod;
|
|
2420
2441
|
try {
|
|
2421
|
-
mod = await import("./xrpl-
|
|
2442
|
+
mod = await import("./xrpl-6B2XOXGC.js");
|
|
2422
2443
|
} catch (cause) {
|
|
2423
2444
|
throw new MissingDriverError(
|
|
2424
2445
|
`XRPL selected, but its package isn't installed. Run: npm install xrpl`,
|
|
@@ -2430,7 +2451,7 @@ var loaders = {
|
|
|
2430
2451
|
tron: async () => {
|
|
2431
2452
|
let mod;
|
|
2432
2453
|
try {
|
|
2433
|
-
mod = await import("./tron-
|
|
2454
|
+
mod = await import("./tron-FXBXDNEY.js");
|
|
2434
2455
|
} catch (cause) {
|
|
2435
2456
|
throw new MissingDriverError(
|
|
2436
2457
|
`Tron selected, but its package isn't installed. Run: npm install tronweb`,
|
|
@@ -2442,7 +2463,7 @@ var loaders = {
|
|
|
2442
2463
|
sui: async () => {
|
|
2443
2464
|
let mod;
|
|
2444
2465
|
try {
|
|
2445
|
-
mod = await import("./sui-
|
|
2466
|
+
mod = await import("./sui-KCIITCYH.js");
|
|
2446
2467
|
} catch (cause) {
|
|
2447
2468
|
throw new MissingDriverError(
|
|
2448
2469
|
`Sui selected, but its package isn't installed. Run: npm install @mysten/sui`,
|
|
@@ -2454,7 +2475,7 @@ var loaders = {
|
|
|
2454
2475
|
near: async () => {
|
|
2455
2476
|
let mod;
|
|
2456
2477
|
try {
|
|
2457
|
-
mod = await import("./near-
|
|
2478
|
+
mod = await import("./near-OLKCMTBI.js");
|
|
2458
2479
|
} catch (cause) {
|
|
2459
2480
|
throw new MissingDriverError(
|
|
2460
2481
|
`NEAR selected, but its package isn't installed. Run: npm install near-api-js`,
|
|
@@ -2466,7 +2487,7 @@ var loaders = {
|
|
|
2466
2487
|
aptos: async () => {
|
|
2467
2488
|
let mod;
|
|
2468
2489
|
try {
|
|
2469
|
-
mod = await import("./aptos-
|
|
2490
|
+
mod = await import("./aptos-KDLX42CR.js");
|
|
2470
2491
|
} catch (cause) {
|
|
2471
2492
|
throw new MissingDriverError(
|
|
2472
2493
|
`Aptos selected, but its package isn't installed. Run: npm install @aptos-labs/ts-sdk`,
|
|
@@ -2478,7 +2499,7 @@ var loaders = {
|
|
|
2478
2499
|
algorand: async () => {
|
|
2479
2500
|
let mod;
|
|
2480
2501
|
try {
|
|
2481
|
-
mod = await import("./algorand-
|
|
2502
|
+
mod = await import("./algorand-UF7BLBFN.js");
|
|
2482
2503
|
} catch (cause) {
|
|
2483
2504
|
throw new MissingDriverError(
|
|
2484
2505
|
`Algorand selected, but its package isn't installed. Run: npm install algosdk`,
|
|
@@ -6418,13 +6439,6 @@ var KNOWN_FACILITATORS = {
|
|
|
6418
6439
|
settles: ["eip3009"],
|
|
6419
6440
|
note: "Dexter \u2014 keyless, gas-sponsored (Base USDC EIP-3009). LIVE-settled on Base 2026-06-17 (tx 0xdf030e4d5bf41a88c5a3bfe73bb433dfbb90b058d3b8ded63b68e026eedb9de8). Note: ~$0.001 dynamic floor on Base."
|
|
6420
6441
|
},
|
|
6421
|
-
{
|
|
6422
|
-
url: "https://facilitator.corbits.dev",
|
|
6423
|
-
keyless: true,
|
|
6424
|
-
schemes: ["exact"],
|
|
6425
|
-
settles: ["eip3009"],
|
|
6426
|
-
note: "Corbits (Faremeter) \u2014 keyless, sponsors gas (Base USDC EIP-3009). LIVE-settled on Base 2026-06-17 (tx 0x2e41c581af023100429ada81f1371bef82d41dd577ed438d72ddc18676d4213d). Also seeded on Monad + Solana."
|
|
6427
|
-
},
|
|
6428
6442
|
{
|
|
6429
6443
|
url: "https://facilitator.goplausible.xyz",
|
|
6430
6444
|
keyless: true,
|
|
@@ -6438,26 +6452,12 @@ var KNOWN_FACILITATORS = {
|
|
|
6438
6452
|
schemes: ["exact"],
|
|
6439
6453
|
settles: ["eip3009"],
|
|
6440
6454
|
note: "Cascade \u2014 keyless, sponsors gas (Base USDC EIP-3009). LIVE-settled on Base 2026-06-18 (tx 0x2e784725f3c66e170720cc8df43a9248f02ad80914fcbe05dadbdbe411c3b52b)."
|
|
6441
|
-
},
|
|
6442
|
-
{
|
|
6443
|
-
url: "https://facilitator.bitcoinsapi.com",
|
|
6444
|
-
keyless: true,
|
|
6445
|
-
schemes: ["exact"],
|
|
6446
|
-
settles: ["eip3009"],
|
|
6447
|
-
note: "Satoshi (bitcoinsapi) \u2014 keyless, sponsors gas (Base USDC EIP-3009). LIVE-settled on Base 2026-06-18 (tx 0xbb2b6c354b12c6d07cce91e2b337e38327d4b0833bbd1dfbeda3ad495b67b819)."
|
|
6448
6455
|
}
|
|
6449
6456
|
],
|
|
6450
6457
|
// Monad (eip155:143). Corbits + Ultravioleta DAO each keyless-settle the EVM EIP-3009 exact rail
|
|
6451
6458
|
// (Monad's native Circle USDC), buyer paid zero gas — real LIVE settles, not just /supported reads.
|
|
6452
6459
|
// Makes `exact: true` zero-config gasless on Monad.
|
|
6453
6460
|
"eip155:143": [
|
|
6454
|
-
{
|
|
6455
|
-
url: "https://facilitator.corbits.dev",
|
|
6456
|
-
keyless: true,
|
|
6457
|
-
schemes: ["exact"],
|
|
6458
|
-
settles: ["eip3009"],
|
|
6459
|
-
note: "Corbits (Faremeter) \u2014 keyless, sponsors gas (Monad native USDC EIP-3009). LIVE-settled on Monad 2026-06-17 (tx 0x7797be27ce22c17f7433a0389bd22d46e338899b1faac505fffd068174428ae6)."
|
|
6460
|
-
},
|
|
6461
6461
|
{
|
|
6462
6462
|
url: "https://facilitator.ultravioletadao.xyz",
|
|
6463
6463
|
keyless: true,
|
|
@@ -6540,13 +6540,6 @@ var KNOWN_FACILITATORS = {
|
|
|
6540
6540
|
settles: ["eip3009"],
|
|
6541
6541
|
note: "Polygon Labs (the official Polygon facilitator) \u2014 keyless, sponsors gas. LIVE-settled on Polygon 2026-06-18 (tx 0x6a8ca60ea111959a61a85ad6c4f2ed99e192052ec7b9ffb59baa33691a86f419)."
|
|
6542
6542
|
},
|
|
6543
|
-
{
|
|
6544
|
-
url: "https://facilitator.corbits.dev",
|
|
6545
|
-
keyless: true,
|
|
6546
|
-
schemes: ["exact"],
|
|
6547
|
-
settles: ["eip3009"],
|
|
6548
|
-
note: "Corbits (Faremeter) \u2014 keyless, sponsors gas. LIVE-settled on Polygon 2026-06-18 (tx 0x2fadca2ee3cd7fcff32d015e8b06109de6b747d7cd0f80dcd8fb022b2d58d008)."
|
|
6549
|
-
},
|
|
6550
6543
|
{
|
|
6551
6544
|
url: "https://facilitator.ultravioletadao.xyz",
|
|
6552
6545
|
keyless: true,
|
|
@@ -6674,13 +6667,6 @@ var KNOWN_FACILITATORS = {
|
|
|
6674
6667
|
schemes: ["exact"],
|
|
6675
6668
|
settles: ["svm"],
|
|
6676
6669
|
note: "OpenFacilitator \u2014 keyless (no signup), fee-payer sponsor. LIVE-settled on Solana 2026-06-15 (tx 5BabDtX\u2026)."
|
|
6677
|
-
},
|
|
6678
|
-
{
|
|
6679
|
-
url: "https://facilitator.corbits.dev",
|
|
6680
|
-
keyless: true,
|
|
6681
|
-
schemes: ["exact"],
|
|
6682
|
-
settles: ["svm"],
|
|
6683
|
-
note: "Corbits \u2014 keyless, Solana-first fee-payer sponsor. LIVE-settled on Solana 2026-06-15 (tx BCreYer\u2026)."
|
|
6684
6670
|
}
|
|
6685
6671
|
]
|
|
6686
6672
|
// NEAR (near:mainnet) — DELIBERATELY UNSEEDED: no x402 facilitator settles NEAR yet.
|
|
@@ -6871,7 +6857,7 @@ function createPaymentGate(options) {
|
|
|
6871
6857
|
);
|
|
6872
6858
|
}
|
|
6873
6859
|
return {
|
|
6874
|
-
skipReason: `${net.network}:
|
|
6860
|
+
skipReason: `${net.network}: auto-selected Permit2, which a third-party facilitator can't settle \u2014 it would serve onchain-proof only here. Either this token isn't EIP-3009 (use USDC / EURC with the facilitator, or \`settle: 'self'\` to settle Permit2 yourself), OR the EIP-712 domain read failed on your RPC (transient): if you expected a gasless rail here, pass a reliable \`rpcUrl\` and retry.`
|
|
6875
6861
|
};
|
|
6876
6862
|
}
|
|
6877
6863
|
const mode = settle === "self" ? { kind: "self", relayer } : {
|
|
@@ -7220,7 +7206,7 @@ function createPaymentGate(options) {
|
|
|
7220
7206
|
`Proof claims ${sig.accepted.asset} on ${sig.accepted.network}, which this resource doesn't accept (offered: ${specs.map((s) => `${s.asset}@${s.net.network}`).join(", ")}).`
|
|
7221
7207
|
);
|
|
7222
7208
|
}
|
|
7223
|
-
const ref = sig.payload.txHash;
|
|
7209
|
+
const ref = typeof sig.payload.txHash === "string" ? sig.payload.txHash.trim() : sig.payload.txHash;
|
|
7224
7210
|
if (await claimTx(ref)) return rejection("tx_already_used", `Proof ${ref} was already redeemed.`);
|
|
7225
7211
|
let result;
|
|
7226
7212
|
try {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _chunkQONQSZHJcjs = require('./chunk-QONQSZHJ.cjs');
|
|
14
14
|
|
|
15
15
|
// src/drivers/near/index.ts
|
|
16
16
|
var _nearapijs = require('near-api-js');
|
|
@@ -61,18 +61,18 @@ async function payNear(params) {
|
|
|
61
61
|
return res.hash;
|
|
62
62
|
} catch (err) {
|
|
63
63
|
if (isNearRegistrationError(err)) {
|
|
64
|
-
throw new (0,
|
|
64
|
+
throw new (0, _chunkQONQSZHJcjs.RecipientNotReadyError)(
|
|
65
65
|
`NEAR recipient ${accept.payTo} isn't registered on token ${accept.asset} (NEP-145 storage_deposit) \u2014 register it once (\u22480.00125 NEAR) before it can receive. (NEAR: not registered)`,
|
|
66
66
|
{ cause: err }
|
|
67
67
|
);
|
|
68
68
|
}
|
|
69
69
|
if (isNearAffordability(err)) {
|
|
70
|
-
throw new (0,
|
|
70
|
+
throw new (0, _chunkQONQSZHJcjs.InsufficientFundsError)(
|
|
71
71
|
err instanceof Error ? err.message : "Insufficient NEAR balance for the payment.",
|
|
72
72
|
{ cause: err }
|
|
73
73
|
);
|
|
74
74
|
}
|
|
75
|
-
throw _nullishCoalesce(
|
|
75
|
+
throw _nullishCoalesce(_chunkQONQSZHJcjs.toInsufficientFundsError.call(void 0, err), () => ( err));
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
async function payNearNative(params) {
|
|
@@ -82,12 +82,12 @@ async function payNearNative(params) {
|
|
|
82
82
|
return res.hash;
|
|
83
83
|
} catch (err) {
|
|
84
84
|
if (isNearAffordability(err)) {
|
|
85
|
-
throw new (0,
|
|
85
|
+
throw new (0, _chunkQONQSZHJcjs.InsufficientFundsError)(
|
|
86
86
|
err instanceof Error ? err.message : "Insufficient NEAR balance for the payment.",
|
|
87
87
|
{ cause: err }
|
|
88
88
|
);
|
|
89
89
|
}
|
|
90
|
-
throw _nullishCoalesce(
|
|
90
|
+
throw _nullishCoalesce(_chunkQONQSZHJcjs.toInsufficientFundsError.call(void 0, err), () => ( err));
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
function isNearRegistrationError(err) {
|
|
@@ -109,28 +109,28 @@ var NONCE_BLOCK_MULTIPLIER = 1000000n;
|
|
|
109
109
|
async function payExactNear(input) {
|
|
110
110
|
const { signer, senderId, blockHeight, accessKeyNonce, accept } = input;
|
|
111
111
|
if (accept.asset === "native") {
|
|
112
|
-
throw new (0,
|
|
112
|
+
throw new (0, _chunkQONQSZHJcjs.UnsupportedSchemeError)(
|
|
113
113
|
"NEAR exact is NEP-141-only (an ft_transfer); native NEAR is not exact-payable. Pay via onchain-proof."
|
|
114
114
|
);
|
|
115
115
|
}
|
|
116
116
|
if (!isValidNearAccountId(accept.asset)) {
|
|
117
|
-
throw new (0,
|
|
117
|
+
throw new (0, _chunkQONQSZHJcjs.UnsupportedSchemeError)(`NEAR exact: asset "${accept.asset}" must be a NEP-141 contract account id.`);
|
|
118
118
|
}
|
|
119
119
|
if (!isValidNearAccountId(accept.payTo)) {
|
|
120
|
-
throw new (0,
|
|
120
|
+
throw new (0, _chunkQONQSZHJcjs.UnsupportedSchemeError)(`NEAR exact: payTo "${accept.payTo}" is not a valid NEAR account id.`);
|
|
121
121
|
}
|
|
122
122
|
if (!isValidNearAccountId(senderId)) {
|
|
123
|
-
throw new (0,
|
|
123
|
+
throw new (0, _chunkQONQSZHJcjs.UnsupportedSchemeError)(`NEAR exact: sender "${senderId}" is not a valid NEAR account id.`);
|
|
124
124
|
}
|
|
125
125
|
const t = accept.maxTimeoutSeconds;
|
|
126
126
|
if (!Number.isInteger(t) || t <= 0) {
|
|
127
|
-
throw new (0,
|
|
127
|
+
throw new (0, _chunkQONQSZHJcjs.UnsupportedSchemeError)("NEAR exact: maxTimeoutSeconds must be a positive integer.");
|
|
128
128
|
}
|
|
129
129
|
const timeoutBlocks = BigInt(Math.max(1, Math.ceil(t / ESTIMATED_BLOCK_SECONDS)));
|
|
130
130
|
const maxBlockHeight = blockHeight + timeoutBlocks;
|
|
131
131
|
const nonce = accessKeyNonce + 1n;
|
|
132
132
|
if (nonce >= blockHeight * NONCE_BLOCK_MULTIPLIER) {
|
|
133
|
-
throw new (0,
|
|
133
|
+
throw new (0, _chunkQONQSZHJcjs.UnsupportedSchemeError)(
|
|
134
134
|
"NEAR exact: the access-key nonce is at the protocol ceiling for this block height; cannot build a delegate action."
|
|
135
135
|
);
|
|
136
136
|
}
|
|
@@ -259,7 +259,7 @@ async function verifyAndSettleExactNear(input) {
|
|
|
259
259
|
if (/not enough|insufficient|exceeded the prepaid gas|NotEnoughBalance|doesn't have enough|is not registered/i.test(m)) {
|
|
260
260
|
return fail("tx_reverted", `the ft_transfer would fail on chain: ${shorten(m)}.`);
|
|
261
261
|
}
|
|
262
|
-
throw new (0,
|
|
262
|
+
throw new (0, _chunkQONQSZHJcjs.SettlementError)(
|
|
263
263
|
`NEAR exact settle: the relayer could not submit the delegate (${shorten(m)}). The buyer's signed delegate is still valid \u2014 fund/fix the relayer and the buyer can re-present it.`,
|
|
264
264
|
{ cause: err }
|
|
265
265
|
);
|
|
@@ -408,13 +408,13 @@ function txNotFound(hash) {
|
|
|
408
408
|
|
|
409
409
|
function assertNearWallet(wallet, network) {
|
|
410
410
|
if (typeof wallet !== "object" || wallet === null) {
|
|
411
|
-
throw new (0,
|
|
411
|
+
throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)(
|
|
412
412
|
`chain ${network} is NEAR; wallet must be { accountId, key } (key = ed25519:\u2026).`
|
|
413
413
|
);
|
|
414
414
|
}
|
|
415
|
-
|
|
415
|
+
_chunkQONQSZHJcjs.assertNoLegacyWalletKey.call(void 0, wallet, "NEAR");
|
|
416
416
|
if (!("accountId" in wallet) || !("key" in wallet)) {
|
|
417
|
-
throw new (0,
|
|
417
|
+
throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)(
|
|
418
418
|
`chain ${network} is NEAR; wallet must be { accountId, key } (key = ed25519:\u2026).`
|
|
419
419
|
);
|
|
420
420
|
}
|
|
@@ -422,13 +422,13 @@ function assertNearWallet(wallet, network) {
|
|
|
422
422
|
}
|
|
423
423
|
function resolveNearWallet(config) {
|
|
424
424
|
if (!config.accountId || !config.key) {
|
|
425
|
-
throw new (0,
|
|
425
|
+
throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)("NEAR wallet needs { accountId, key } (key = ed25519:\u2026).");
|
|
426
426
|
}
|
|
427
427
|
let signer;
|
|
428
428
|
try {
|
|
429
429
|
signer = _nearapijs.KeyPairSigner.fromSecretKey(config.key);
|
|
430
430
|
} catch (cause) {
|
|
431
|
-
throw new (0,
|
|
431
|
+
throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)("NEAR wallet { key } is not a valid ed25519:\u2026 secret key.", {
|
|
432
432
|
cause
|
|
433
433
|
});
|
|
434
434
|
}
|
|
@@ -490,16 +490,16 @@ function makeNearNetwork(preset, rpcUrl) {
|
|
|
490
490
|
const info = preset.tokens[token.toUpperCase()];
|
|
491
491
|
if (!info) {
|
|
492
492
|
const known = Object.keys(preset.tokens).join(", ") || "(none built in)";
|
|
493
|
-
throw new (0,
|
|
493
|
+
throw new (0, _chunkQONQSZHJcjs.UnknownTokenError)(
|
|
494
494
|
`token "${token}" isn't built in for NEAR (known: ${known}). Pass { contractId, decimals } for a custom NEP-141.`
|
|
495
495
|
);
|
|
496
496
|
}
|
|
497
497
|
return { asset: info.contractId, decimals: info.decimals, symbol: info.symbol };
|
|
498
498
|
}
|
|
499
|
-
|
|
499
|
+
_chunkQONQSZHJcjs.rejectForeignToken.call(void 0, token, "near", network);
|
|
500
500
|
const t = token;
|
|
501
501
|
if (!t.contractId || typeof t.decimals !== "number") {
|
|
502
|
-
throw new (0,
|
|
502
|
+
throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)(
|
|
503
503
|
`chain ${network} is NEAR; a custom token must be { contractId, decimals }.`
|
|
504
504
|
);
|
|
505
505
|
}
|
|
@@ -518,12 +518,12 @@ function makeNearNetwork(preset, rpcUrl) {
|
|
|
518
518
|
},
|
|
519
519
|
assertValidPayTo(payTo) {
|
|
520
520
|
if (payTo.startsWith("0x")) {
|
|
521
|
-
throw new (0,
|
|
521
|
+
throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)(
|
|
522
522
|
`chain ${network} is NEAR, but payTo "${payTo}" looks like an EVM/Sui 0x address.`
|
|
523
523
|
);
|
|
524
524
|
}
|
|
525
525
|
if (!isValidNearAccountId(payTo)) {
|
|
526
|
-
throw new (0,
|
|
526
|
+
throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)(
|
|
527
527
|
`chain ${network} is NEAR, but payTo "${payTo}" is not a valid NEAR account id.`
|
|
528
528
|
);
|
|
529
529
|
}
|
|
@@ -567,11 +567,11 @@ function makeNearNetwork(preset, rpcUrl) {
|
|
|
567
567
|
if (tx && tx.success) return { height: "0" };
|
|
568
568
|
} catch (e11) {
|
|
569
569
|
}
|
|
570
|
-
throw new (0,
|
|
570
|
+
throw new (0, _chunkQONQSZHJcjs.ConfirmationTimeoutError)(`NEAR tx ${hash} not confirmed in time.`);
|
|
571
571
|
},
|
|
572
572
|
async estimateCost(accept) {
|
|
573
573
|
if (accept.scheme === "exact") {
|
|
574
|
-
return
|
|
574
|
+
return _chunkQONQSZHJcjs.nativeCost.call(void 0, {
|
|
575
575
|
symbol: "NEAR",
|
|
576
576
|
decimals: NEAR_DECIMALS,
|
|
577
577
|
fee: 0n,
|
|
@@ -579,7 +579,7 @@ function makeNearNetwork(preset, rpcUrl) {
|
|
|
579
579
|
detail: "gasless \u2014 the relayer prepays gas + the 1 yocto; the buyer pays 0 NEAR"
|
|
580
580
|
});
|
|
581
581
|
}
|
|
582
|
-
return
|
|
582
|
+
return _chunkQONQSZHJcjs.nativeCost.call(void 0, {
|
|
583
583
|
symbol: "NEAR",
|
|
584
584
|
decimals: NEAR_DECIMALS,
|
|
585
585
|
fee: 1500000000000000000000n,
|
|
@@ -701,7 +701,7 @@ function makeNearNetwork(preset, rpcUrl) {
|
|
|
701
701
|
try {
|
|
702
702
|
relayerWallet = resolveNearWallet(relayer._native);
|
|
703
703
|
} catch (err) {
|
|
704
|
-
throw new (0,
|
|
704
|
+
throw new (0, _chunkQONQSZHJcjs.SettlementError)(
|
|
705
705
|
`NEAR exact settle: the relayer wallet is invalid (${err instanceof Error ? err.message : String(err)}).`,
|
|
706
706
|
{ cause: err }
|
|
707
707
|
);
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunkQONQSZHJcjs = require('./chunk-QONQSZHJ.cjs');
|
|
12
12
|
|
|
13
13
|
// src/drivers/solana/index.ts
|
|
14
14
|
var _web3js = require('@solana/web3.js');
|
|
@@ -237,7 +237,7 @@ function isEmptySig(sig) {
|
|
|
237
237
|
function memoRandomNonce() {
|
|
238
238
|
const g = globalThis.crypto;
|
|
239
239
|
if (!_optionalChain([g, 'optionalAccess', _3 => _3.getRandomValues])) {
|
|
240
|
-
throw new (0,
|
|
240
|
+
throw new (0, _chunkQONQSZHJcjs.UnsupportedSchemeError)(
|
|
241
241
|
"this runtime lacks Web Crypto (globalThis.crypto.getRandomValues); SVM exact needs a CSPRNG nonce."
|
|
242
242
|
);
|
|
243
243
|
}
|
|
@@ -249,7 +249,7 @@ function memoDataFor(accept) {
|
|
|
249
249
|
if (accept.extra.memo !== void 0) {
|
|
250
250
|
const bytes = Buffer.from(accept.extra.memo, "utf8");
|
|
251
251
|
if (bytes.length > MAX_MEMO_BYTES) {
|
|
252
|
-
throw new (0,
|
|
252
|
+
throw new (0, _chunkQONQSZHJcjs.UnsupportedSchemeError)(
|
|
253
253
|
`SVM exact: extra.memo is ${bytes.length} bytes; the scheme caps it at ${MAX_MEMO_BYTES}.`
|
|
254
254
|
);
|
|
255
255
|
}
|
|
@@ -263,15 +263,15 @@ function memoInstruction(accept) {
|
|
|
263
263
|
async function payExactSolana(input) {
|
|
264
264
|
const { connection, keypair, accept } = input;
|
|
265
265
|
if (accept.asset === "native") {
|
|
266
|
-
throw new (0,
|
|
266
|
+
throw new (0, _chunkQONQSZHJcjs.UnsupportedSchemeError)(
|
|
267
267
|
"SVM exact is SPL-token only (TransferChecked); native SOL is not exact-payable. Pay via onchain-proof."
|
|
268
268
|
);
|
|
269
269
|
}
|
|
270
270
|
if (!accept.extra.feePayer) {
|
|
271
|
-
throw new (0,
|
|
271
|
+
throw new (0, _chunkQONQSZHJcjs.UnsupportedSchemeError)("SVM exact rail must advertise extra.feePayer (the merchant sponsor key).");
|
|
272
272
|
}
|
|
273
273
|
if (accept.extra.decimals === void 0) {
|
|
274
|
-
throw new (0,
|
|
274
|
+
throw new (0, _chunkQONQSZHJcjs.UnsupportedSchemeError)("SVM exact rail must advertise extra.decimals for the TransferChecked.");
|
|
275
275
|
}
|
|
276
276
|
let feePayer;
|
|
277
277
|
let mint;
|
|
@@ -281,12 +281,12 @@ async function payExactSolana(input) {
|
|
|
281
281
|
mint = new (0, _web3js.PublicKey)(accept.asset);
|
|
282
282
|
payTo = new (0, _web3js.PublicKey)(accept.payTo);
|
|
283
283
|
} catch (err) {
|
|
284
|
-
throw new (0,
|
|
284
|
+
throw new (0, _chunkQONQSZHJcjs.UnsupportedSchemeError)(
|
|
285
285
|
`SVM exact: bad feePayer/asset/payTo (${err instanceof Error ? err.message : String(err)}).`
|
|
286
286
|
);
|
|
287
287
|
}
|
|
288
288
|
if (feePayer.equals(payTo)) {
|
|
289
|
-
throw new (0,
|
|
289
|
+
throw new (0, _chunkQONQSZHJcjs.UnsupportedSchemeError)(
|
|
290
290
|
"SVM exact: the fee payer must differ from payTo \u2014 payTo appears in the transfer instruction, which the fee payer must not (a scheme MUST-rule). Use a separate relayer key for the gate."
|
|
291
291
|
);
|
|
292
292
|
}
|
|
@@ -300,7 +300,7 @@ async function payExactSolana(input) {
|
|
|
300
300
|
destInfo = "unknown";
|
|
301
301
|
}
|
|
302
302
|
if (destInfo === null) {
|
|
303
|
-
throw new (0,
|
|
303
|
+
throw new (0, _chunkQONQSZHJcjs.UnsupportedSchemeError)(
|
|
304
304
|
`SVM exact: the recipient's token account for ${mint.toBase58()} doesn't exist yet \u2014 the exact rail can't create it. Pay via onchain-proof (which creates it), or have ${payTo.toBase58()} create its associated token account first.`
|
|
305
305
|
);
|
|
306
306
|
}
|
|
@@ -331,11 +331,11 @@ async function payExactSolana(input) {
|
|
|
331
331
|
tx.sign([keypair]);
|
|
332
332
|
const buyerIndex = message.staticAccountKeys.findIndex((k) => k.equals(keypair.publicKey));
|
|
333
333
|
if (buyerIndex < 1 || buyerIndex >= message.header.numRequiredSignatures) {
|
|
334
|
-
throw new (0,
|
|
334
|
+
throw new (0, _chunkQONQSZHJcjs.UnsupportedSchemeError)("SVM exact: could not locate the buyer signer slot.");
|
|
335
335
|
}
|
|
336
336
|
const buyerSig = tx.signatures[buyerIndex];
|
|
337
337
|
if (!buyerSig || isEmptySig(buyerSig)) {
|
|
338
|
-
throw new (0,
|
|
338
|
+
throw new (0, _chunkQONQSZHJcjs.UnsupportedSchemeError)("SVM exact: the wallet did not produce a buyer signature.");
|
|
339
339
|
}
|
|
340
340
|
const transaction = Buffer.from(tx.serialize()).toString("base64");
|
|
341
341
|
return {
|
|
@@ -362,15 +362,15 @@ async function verifyAndSettleExactSolana(input) {
|
|
|
362
362
|
if (!accept.extra.feePayer) throw new Error("rail is missing extra.feePayer");
|
|
363
363
|
railFeePayer = new (0, _web3js.PublicKey)(accept.extra.feePayer);
|
|
364
364
|
} catch (err) {
|
|
365
|
-
throw new (0,
|
|
365
|
+
throw new (0, _chunkQONQSZHJcjs.SettlementError)(`SVM exact: rail has a bad payTo/asset/feePayer (${err instanceof Error ? err.message : String(err)}).`);
|
|
366
366
|
}
|
|
367
367
|
if (!railFeePayer.equals(feePayerKeypair.publicKey)) {
|
|
368
|
-
throw new (0,
|
|
368
|
+
throw new (0, _chunkQONQSZHJcjs.SettlementError)(
|
|
369
369
|
"SVM exact: the gate relayer key does not match the rail extra.feePayer \u2014 misconfigured rail."
|
|
370
370
|
);
|
|
371
371
|
}
|
|
372
372
|
if (feePayerKeypair.publicKey.equals(payTo)) {
|
|
373
|
-
throw new (0,
|
|
373
|
+
throw new (0, _chunkQONQSZHJcjs.SettlementError)("SVM exact: the fee payer must differ from payTo \u2014 misconfigured rail.");
|
|
374
374
|
}
|
|
375
375
|
const program = tokenProgramFor(accept);
|
|
376
376
|
let tx;
|
|
@@ -512,7 +512,7 @@ async function verifyAndSettleExactSolana(input) {
|
|
|
512
512
|
} catch (err) {
|
|
513
513
|
const msg = err instanceof Error ? err.message : String(err);
|
|
514
514
|
if (/blockhash|block height|expired/i.test(msg)) return fail("payment_expired", `Settle broadcast rejected \u2014 blockhash expired: ${shorten(msg)}.`);
|
|
515
|
-
throw new (0,
|
|
515
|
+
throw new (0, _chunkQONQSZHJcjs.SettlementError)(
|
|
516
516
|
`SVM exact settle: the merchant fee payer failed to broadcast (${shorten(msg)}). The buyer's signed transaction is still valid \u2014 fund/fix the fee payer and the buyer can re-present it.`,
|
|
517
517
|
{ cause: err }
|
|
518
518
|
);
|
|
@@ -522,7 +522,7 @@ async function verifyAndSettleExactSolana(input) {
|
|
|
522
522
|
return fail("tx_reverted", `Settle tx ${txid} reverted on-chain (a post-simulate race).`);
|
|
523
523
|
}
|
|
524
524
|
if (confirmed === "timeout") {
|
|
525
|
-
throw new (0,
|
|
525
|
+
throw new (0, _chunkQONQSZHJcjs.SettlementError)(
|
|
526
526
|
`SVM exact settle: broadcast ${txid} but it did not confirm in time. It likely landed \u2014 re-verify by signature before re-presenting; do NOT re-pay.`
|
|
527
527
|
);
|
|
528
528
|
}
|
|
@@ -565,18 +565,18 @@ async function pollConfirmed(connection, signature) {
|
|
|
565
565
|
|
|
566
566
|
function toKeypair(wallet, network) {
|
|
567
567
|
if (typeof wallet !== "object" || wallet === null) {
|
|
568
|
-
throw new (0,
|
|
568
|
+
throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)(
|
|
569
569
|
`chain ${network} is Solana; wallet must be { key } (base58 secret) or { signer }.`
|
|
570
570
|
);
|
|
571
571
|
}
|
|
572
|
-
|
|
572
|
+
_chunkQONQSZHJcjs.assertNoLegacyWalletKey.call(void 0, wallet, "Solana");
|
|
573
573
|
if ("signer" in wallet) {
|
|
574
574
|
return wallet.signer;
|
|
575
575
|
}
|
|
576
576
|
if ("key" in wallet) {
|
|
577
577
|
const sk = wallet.key;
|
|
578
578
|
if (typeof sk === "string" && sk.startsWith("0x")) {
|
|
579
|
-
throw new (0,
|
|
579
|
+
throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)(
|
|
580
580
|
`chain ${network} is Solana, but the wallet { key } is a 0x\u2026 hex key \u2014 that's an EVM key. A Solana key is a base58 secret string (or a 64-byte Uint8Array).`
|
|
581
581
|
);
|
|
582
582
|
}
|
|
@@ -584,12 +584,12 @@ function toKeypair(wallet, network) {
|
|
|
584
584
|
const bytes = typeof sk === "string" ? _bs582.default.decode(sk) : sk;
|
|
585
585
|
return _web3js.Keypair.fromSecretKey(bytes);
|
|
586
586
|
} catch (err) {
|
|
587
|
-
throw new (0,
|
|
587
|
+
throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)(
|
|
588
588
|
`chain ${network} is Solana; the wallet { key } isn't a valid Solana secret (expected a base58 secret string or a 64-byte Uint8Array): ${err instanceof Error ? err.message : String(err)}.`
|
|
589
589
|
);
|
|
590
590
|
}
|
|
591
591
|
}
|
|
592
|
-
throw new (0,
|
|
592
|
+
throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)(
|
|
593
593
|
`chain ${network} is Solana; wallet must be { key } (base58 secret) or { signer }.`
|
|
594
594
|
);
|
|
595
595
|
}
|
|
@@ -618,15 +618,15 @@ function makeSolanaNetwork(preset, rpcUrl) {
|
|
|
618
618
|
const info = preset.tokens[token.toUpperCase()];
|
|
619
619
|
if (!info) {
|
|
620
620
|
const known = Object.keys(preset.tokens).join(", ") || "(none built in)";
|
|
621
|
-
throw new (0,
|
|
621
|
+
throw new (0, _chunkQONQSZHJcjs.UnknownTokenError)(
|
|
622
622
|
`token "${token}" isn't built in for Solana (known: ${known}). Pass { mint, decimals } instead, or use 'native'.`
|
|
623
623
|
);
|
|
624
624
|
}
|
|
625
625
|
return { asset: info.mint, decimals: info.decimals, symbol: info.symbol };
|
|
626
626
|
}
|
|
627
|
-
|
|
627
|
+
_chunkQONQSZHJcjs.rejectForeignToken.call(void 0, token, "solana", network);
|
|
628
628
|
if (!("mint" in token)) {
|
|
629
|
-
throw new (0,
|
|
629
|
+
throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)(
|
|
630
630
|
`chain ${network} is Solana; a custom token must be { mint, decimals }.`
|
|
631
631
|
);
|
|
632
632
|
}
|
|
@@ -645,14 +645,14 @@ function makeSolanaNetwork(preset, rpcUrl) {
|
|
|
645
645
|
},
|
|
646
646
|
assertValidPayTo(payTo) {
|
|
647
647
|
if (payTo.startsWith("0x")) {
|
|
648
|
-
throw new (0,
|
|
648
|
+
throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)(
|
|
649
649
|
`chain ${network} is Solana, but payTo "${payTo}" looks like an EVM address.`
|
|
650
650
|
);
|
|
651
651
|
}
|
|
652
652
|
try {
|
|
653
653
|
new (0, _web3js.PublicKey)(payTo);
|
|
654
654
|
} catch (e7) {
|
|
655
|
-
throw new (0,
|
|
655
|
+
throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)(
|
|
656
656
|
`chain ${network} is Solana, but payTo "${payTo}" is not a base58 address.`
|
|
657
657
|
);
|
|
658
658
|
}
|
|
@@ -664,7 +664,7 @@ function makeSolanaNetwork(preset, rpcUrl) {
|
|
|
664
664
|
try {
|
|
665
665
|
return await paySolana({ connection, keypair: wallet._native, accept });
|
|
666
666
|
} catch (err) {
|
|
667
|
-
throw _nullishCoalesce(
|
|
667
|
+
throw _nullishCoalesce(_chunkQONQSZHJcjs.toInsufficientFundsError.call(void 0, err), () => ( err));
|
|
668
668
|
}
|
|
669
669
|
},
|
|
670
670
|
async confirm(ref) {
|
|
@@ -675,19 +675,19 @@ function makeSolanaNetwork(preset, rpcUrl) {
|
|
|
675
675
|
});
|
|
676
676
|
info = value[0];
|
|
677
677
|
} catch (err) {
|
|
678
|
-
throw new (0,
|
|
678
|
+
throw new (0, _chunkQONQSZHJcjs.ConfirmationTimeoutError)(
|
|
679
679
|
`Solana payment ${ref} could not be confirmed (RPC read failed).`,
|
|
680
680
|
{ cause: err }
|
|
681
681
|
);
|
|
682
682
|
}
|
|
683
683
|
if (!info || info.err || info.confirmationStatus !== "confirmed" && info.confirmationStatus !== "finalized") {
|
|
684
|
-
throw new (0,
|
|
684
|
+
throw new (0, _chunkQONQSZHJcjs.ConfirmationTimeoutError)(`Solana payment ${ref} did not confirm in time.`);
|
|
685
685
|
}
|
|
686
686
|
return { height: String(info.slot) };
|
|
687
687
|
},
|
|
688
688
|
async estimateCost(accept) {
|
|
689
689
|
if (accept.scheme === "exact") {
|
|
690
|
-
return
|
|
690
|
+
return _chunkQONQSZHJcjs.nativeCost.call(void 0, {
|
|
691
691
|
symbol: "SOL",
|
|
692
692
|
decimals: SOL_DECIMALS,
|
|
693
693
|
fee: 0n,
|
|
@@ -697,7 +697,7 @@ function makeSolanaNetwork(preset, rpcUrl) {
|
|
|
697
697
|
}
|
|
698
698
|
const base = 5000n;
|
|
699
699
|
if (accept.asset === "native") {
|
|
700
|
-
return
|
|
700
|
+
return _chunkQONQSZHJcjs.nativeCost.call(void 0, {
|
|
701
701
|
symbol: "SOL",
|
|
702
702
|
decimals: SOL_DECIMALS,
|
|
703
703
|
fee: base,
|
|
@@ -706,7 +706,7 @@ function makeSolanaNetwork(preset, rpcUrl) {
|
|
|
706
706
|
});
|
|
707
707
|
}
|
|
708
708
|
const ataRent = 2039280n;
|
|
709
|
-
return
|
|
709
|
+
return _chunkQONQSZHJcjs.nativeCost.call(void 0, {
|
|
710
710
|
symbol: "SOL",
|
|
711
711
|
decimals: SOL_DECIMALS,
|
|
712
712
|
fee: base + ataRent,
|