@piprail/sdk 2.13.0 → 2.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -0
- package/dist/{algorand-FCEECDG6.cjs → algorand-AQK5EAUF.cjs} +32 -32
- package/dist/{algorand-AA3WXKW4.js → algorand-TQCYK2XT.js} +1 -1
- package/dist/{aptos-GHJPO6JJ.cjs → aptos-65UX7GKA.cjs} +31 -31
- package/dist/{aptos-LY67Q6QF.js → aptos-RYQOSFBQ.js} +1 -1
- package/dist/{chunk-MWBT7MCE.cjs → chunk-DCOUJZPL.cjs} +6 -4
- package/dist/{chunk-SC2ZYDHD.js → chunk-O32N6MFN.js} +6 -4
- package/dist/index.cjs +154 -136
- package/dist/index.d.cts +11 -5
- package/dist/index.d.ts +11 -5
- package/dist/index.js +32 -14
- package/dist/{near-6KAQVVG2.cjs → near-UDPFA6SV.cjs} +26 -26
- package/dist/{near-FZBUICCS.js → near-VDATC5AV.js} +1 -1
- package/dist/{solana-MYF4HBO4.cjs → solana-RQNXFCZO.cjs} +32 -32
- package/dist/{solana-ELUWO6N5.js → solana-VYLWFNAH.js} +1 -1
- package/dist/{stellar-ASP2THL2.js → stellar-KBR4V77T.js} +1 -1
- package/dist/{stellar-CRWBSX4E.cjs → stellar-OK2HW5PZ.cjs} +20 -20
- package/dist/{sui-FZIKZNVI.js → sui-BXHB6D3W.js} +1 -1
- package/dist/{sui-Y4RLKKE2.cjs → sui-SVFBJFW5.cjs} +16 -16
- package/dist/{ton-AOR3EURW.cjs → ton-D7YN6BGR.cjs} +16 -16
- package/dist/{ton-7GKCTC5H.js → ton-NNKQFQ6U.js} +1 -1
- package/dist/{tron-BMCWN5SS.js → tron-W2D5PQXV.js} +1 -1
- package/dist/{tron-OMXB6EW2.cjs → tron-WZFU57NX.cjs} +25 -25
- package/dist/{xrpl-DD7TJL5L.js → xrpl-37E23W53.js} +1 -1
- package/dist/{xrpl-Y6SQNYLC.cjs → xrpl-5NHY3NEL.cjs} +20 -20
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -4622,10 +4622,12 @@ declare class MaxRetriesExceededError extends PipRailError {
|
|
|
4622
4622
|
/**
|
|
4623
4623
|
* The proof ref — recover with it, don't re-pay. Its meaning depends on the
|
|
4624
4624
|
* scheme: for `onchain-proof` it's the already-broadcast transaction ref
|
|
4625
|
-
* (re-verify or re-submit it). For a standard `exact` rail it's the
|
|
4626
|
-
*
|
|
4627
|
-
*
|
|
4628
|
-
*
|
|
4625
|
+
* (re-verify or re-submit it). For a standard `exact` rail it's the authorization's
|
|
4626
|
+
* single-use marker (NOT a tx hash) — re-PRESENT the same signed authorization, never
|
|
4627
|
+
* re-sign a fresh nonce, and verify it on-chain before assuming it didn't settle. On
|
|
4628
|
+
* EVM that marker is the EIP-3009 NONCE (a `0x…` value), checked via the token's
|
|
4629
|
+
* `authorizationState(from, nonce)`; the non-EVM `exact` rails key off their own marker
|
|
4630
|
+
* (Solana tx signature, Algorand group id, Aptos account sequence number, NEAR access-key nonce).
|
|
4629
4631
|
*/
|
|
4630
4632
|
readonly ref?: string;
|
|
4631
4633
|
constructor(message: string, options?: ErrorOptions & {
|
|
@@ -7306,7 +7308,11 @@ interface DeliverReceiptOptions {
|
|
|
7306
7308
|
url: string;
|
|
7307
7309
|
/**
|
|
7308
7310
|
* Shared secret. When set, the raw JSON body is signed HMAC-SHA256 and sent as
|
|
7309
|
-
* `<signatureHeader>: sha256=<hex>` so the receiver can verify authenticity.
|
|
7311
|
+
* `<signatureHeader>: sha256=<hex>` so the receiver can verify authenticity. Signing uses Web
|
|
7312
|
+
* Crypto (`crypto.subtle`) — always present on the supported runtimes (Node ≥ 20, modern
|
|
7313
|
+
* browsers). On a runtime that lacks it the body is sent **unsigned, with no signature header**,
|
|
7314
|
+
* so a receiver must treat a *missing* signature as unauthenticated (reject it), never silently
|
|
7315
|
+
* accept an unsigned body.
|
|
7310
7316
|
*/
|
|
7311
7317
|
secret?: string;
|
|
7312
7318
|
/** Extra retry attempts after the first send (default 5 → up to 6 POSTs total). */
|
package/dist/index.d.ts
CHANGED
|
@@ -4622,10 +4622,12 @@ declare class MaxRetriesExceededError extends PipRailError {
|
|
|
4622
4622
|
/**
|
|
4623
4623
|
* The proof ref — recover with it, don't re-pay. Its meaning depends on the
|
|
4624
4624
|
* scheme: for `onchain-proof` it's the already-broadcast transaction ref
|
|
4625
|
-
* (re-verify or re-submit it). For a standard `exact` rail it's the
|
|
4626
|
-
*
|
|
4627
|
-
*
|
|
4628
|
-
*
|
|
4625
|
+
* (re-verify or re-submit it). For a standard `exact` rail it's the authorization's
|
|
4626
|
+
* single-use marker (NOT a tx hash) — re-PRESENT the same signed authorization, never
|
|
4627
|
+
* re-sign a fresh nonce, and verify it on-chain before assuming it didn't settle. On
|
|
4628
|
+
* EVM that marker is the EIP-3009 NONCE (a `0x…` value), checked via the token's
|
|
4629
|
+
* `authorizationState(from, nonce)`; the non-EVM `exact` rails key off their own marker
|
|
4630
|
+
* (Solana tx signature, Algorand group id, Aptos account sequence number, NEAR access-key nonce).
|
|
4629
4631
|
*/
|
|
4630
4632
|
readonly ref?: string;
|
|
4631
4633
|
constructor(message: string, options?: ErrorOptions & {
|
|
@@ -7306,7 +7308,11 @@ interface DeliverReceiptOptions {
|
|
|
7306
7308
|
url: string;
|
|
7307
7309
|
/**
|
|
7308
7310
|
* Shared secret. When set, the raw JSON body is signed HMAC-SHA256 and sent as
|
|
7309
|
-
* `<signatureHeader>: sha256=<hex>` so the receiver can verify authenticity.
|
|
7311
|
+
* `<signatureHeader>: sha256=<hex>` so the receiver can verify authenticity. Signing uses Web
|
|
7312
|
+
* Crypto (`crypto.subtle`) — always present on the supported runtimes (Node ≥ 20, modern
|
|
7313
|
+
* browsers). On a runtime that lacks it the body is sent **unsigned, with no signature header**,
|
|
7314
|
+
* so a receiver must treat a *missing* signature as unauthenticated (reject it), never silently
|
|
7315
|
+
* accept an unsigned body.
|
|
7310
7316
|
*/
|
|
7311
7317
|
secret?: string;
|
|
7312
7318
|
/** Extra retry attempts after the first send (default 5 → up to 6 POSTs total). */
|
package/dist/index.js
CHANGED
|
@@ -31,7 +31,7 @@ import {
|
|
|
31
31
|
parseUnits,
|
|
32
32
|
rejectForeignToken,
|
|
33
33
|
toInsufficientFundsError
|
|
34
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-O32N6MFN.js";
|
|
35
35
|
|
|
36
36
|
// src/drivers/registry.ts
|
|
37
37
|
var byFamily = /* @__PURE__ */ new Map();
|
|
@@ -2329,7 +2329,7 @@ var loaders = {
|
|
|
2329
2329
|
solana: async () => {
|
|
2330
2330
|
let mod;
|
|
2331
2331
|
try {
|
|
2332
|
-
mod = await import("./solana-
|
|
2332
|
+
mod = await import("./solana-VYLWFNAH.js");
|
|
2333
2333
|
} catch (cause) {
|
|
2334
2334
|
throw new MissingDriverError(
|
|
2335
2335
|
`Solana selected, but its packages aren't installed. Run: npm install @solana/web3.js @solana/spl-token bs58`,
|
|
@@ -2341,7 +2341,7 @@ var loaders = {
|
|
|
2341
2341
|
ton: async () => {
|
|
2342
2342
|
let mod;
|
|
2343
2343
|
try {
|
|
2344
|
-
mod = await import("./ton-
|
|
2344
|
+
mod = await import("./ton-NNKQFQ6U.js");
|
|
2345
2345
|
} catch (cause) {
|
|
2346
2346
|
throw new MissingDriverError(
|
|
2347
2347
|
`TON selected, but its packages aren't installed. Run: npm install @ton/ton @ton/core @ton/crypto`,
|
|
@@ -2353,7 +2353,7 @@ var loaders = {
|
|
|
2353
2353
|
stellar: async () => {
|
|
2354
2354
|
let mod;
|
|
2355
2355
|
try {
|
|
2356
|
-
mod = await import("./stellar-
|
|
2356
|
+
mod = await import("./stellar-KBR4V77T.js");
|
|
2357
2357
|
} catch (cause) {
|
|
2358
2358
|
throw new MissingDriverError(
|
|
2359
2359
|
`Stellar selected, but its package isn't installed. Run: npm install @stellar/stellar-sdk`,
|
|
@@ -2365,7 +2365,7 @@ var loaders = {
|
|
|
2365
2365
|
xrpl: async () => {
|
|
2366
2366
|
let mod;
|
|
2367
2367
|
try {
|
|
2368
|
-
mod = await import("./xrpl-
|
|
2368
|
+
mod = await import("./xrpl-37E23W53.js");
|
|
2369
2369
|
} catch (cause) {
|
|
2370
2370
|
throw new MissingDriverError(
|
|
2371
2371
|
`XRPL selected, but its package isn't installed. Run: npm install xrpl`,
|
|
@@ -2377,7 +2377,7 @@ var loaders = {
|
|
|
2377
2377
|
tron: async () => {
|
|
2378
2378
|
let mod;
|
|
2379
2379
|
try {
|
|
2380
|
-
mod = await import("./tron-
|
|
2380
|
+
mod = await import("./tron-W2D5PQXV.js");
|
|
2381
2381
|
} catch (cause) {
|
|
2382
2382
|
throw new MissingDriverError(
|
|
2383
2383
|
`Tron selected, but its package isn't installed. Run: npm install tronweb`,
|
|
@@ -2389,7 +2389,7 @@ var loaders = {
|
|
|
2389
2389
|
sui: async () => {
|
|
2390
2390
|
let mod;
|
|
2391
2391
|
try {
|
|
2392
|
-
mod = await import("./sui-
|
|
2392
|
+
mod = await import("./sui-BXHB6D3W.js");
|
|
2393
2393
|
} catch (cause) {
|
|
2394
2394
|
throw new MissingDriverError(
|
|
2395
2395
|
`Sui selected, but its package isn't installed. Run: npm install @mysten/sui`,
|
|
@@ -2401,7 +2401,7 @@ var loaders = {
|
|
|
2401
2401
|
near: async () => {
|
|
2402
2402
|
let mod;
|
|
2403
2403
|
try {
|
|
2404
|
-
mod = await import("./near-
|
|
2404
|
+
mod = await import("./near-VDATC5AV.js");
|
|
2405
2405
|
} catch (cause) {
|
|
2406
2406
|
throw new MissingDriverError(
|
|
2407
2407
|
`NEAR selected, but its package isn't installed. Run: npm install near-api-js`,
|
|
@@ -2413,7 +2413,7 @@ var loaders = {
|
|
|
2413
2413
|
aptos: async () => {
|
|
2414
2414
|
let mod;
|
|
2415
2415
|
try {
|
|
2416
|
-
mod = await import("./aptos-
|
|
2416
|
+
mod = await import("./aptos-RYQOSFBQ.js");
|
|
2417
2417
|
} catch (cause) {
|
|
2418
2418
|
throw new MissingDriverError(
|
|
2419
2419
|
`Aptos selected, but its package isn't installed. Run: npm install @aptos-labs/ts-sdk`,
|
|
@@ -2425,7 +2425,7 @@ var loaders = {
|
|
|
2425
2425
|
algorand: async () => {
|
|
2426
2426
|
let mod;
|
|
2427
2427
|
try {
|
|
2428
|
-
mod = await import("./algorand-
|
|
2428
|
+
mod = await import("./algorand-TQCYK2XT.js");
|
|
2429
2429
|
} catch (cause) {
|
|
2430
2430
|
throw new MissingDriverError(
|
|
2431
2431
|
`Algorand selected, but its package isn't installed. Run: npm install algosdk`,
|
|
@@ -3449,6 +3449,24 @@ var SpendLedger = class {
|
|
|
3449
3449
|
}
|
|
3450
3450
|
};
|
|
3451
3451
|
|
|
3452
|
+
// src/util/exactRecovery.ts
|
|
3453
|
+
function exactSettleCheckHint(family, payerFrom, nonce) {
|
|
3454
|
+
switch (family) {
|
|
3455
|
+
case "evm":
|
|
3456
|
+
return `the EIP-3009 \`authorizationState(${payerFrom}, ${nonce})\` (or, on the Permit2 method, the Permit2 nonce bitmap)`;
|
|
3457
|
+
case "solana":
|
|
3458
|
+
return `the buyer's transaction signature (a duplicate signature is the chain's own replay guard; plus the SPL-Memo nonce when present)`;
|
|
3459
|
+
case "algorand":
|
|
3460
|
+
return `the atomic group / transaction id`;
|
|
3461
|
+
case "aptos":
|
|
3462
|
+
return `the sender's account sequence number`;
|
|
3463
|
+
case "near":
|
|
3464
|
+
return `the access-key nonce (\`${nonce}\`)`;
|
|
3465
|
+
default:
|
|
3466
|
+
return `the single-use marker (\`ref=${nonce}\`)`;
|
|
3467
|
+
}
|
|
3468
|
+
}
|
|
3469
|
+
|
|
3452
3470
|
// src/client.ts
|
|
3453
3471
|
var DEFAULT_SCHEMES = ["onchain-proof"];
|
|
3454
3472
|
var RECIPIENT_FIX = {
|
|
@@ -4760,7 +4778,7 @@ var PipRailClient = class {
|
|
|
4760
4778
|
async payExactRail(net, wallet, accept, url, init, quote) {
|
|
4761
4779
|
if (!net.payExact) {
|
|
4762
4780
|
throw new UnsupportedSchemeError(
|
|
4763
|
-
`the ${net.family} family can't pay a standard 'exact' rail (supported on EVM, Solana, Algorand + NEAR today).`
|
|
4781
|
+
`the ${net.family} family can't pay a standard 'exact' rail (supported on EVM, Solana, Algorand, Aptos + NEAR today).`
|
|
4764
4782
|
);
|
|
4765
4783
|
}
|
|
4766
4784
|
throwIfAborted(init?.signal);
|
|
@@ -4793,7 +4811,7 @@ var PipRailClient = class {
|
|
|
4793
4811
|
response = await fetch(url, { ...init ?? {}, headers, signal });
|
|
4794
4812
|
} catch (err) {
|
|
4795
4813
|
throw new PaymentTimeoutError(
|
|
4796
|
-
`exact: no response after submitting the authorization (nonce=${nonce}) to ${hostOf2(url)}. The facilitator may have already settled it \u2014 verify on-chain
|
|
4814
|
+
`exact: no response after submitting the authorization (nonce=${nonce}) to ${hostOf2(url)}. The facilitator may have already settled it \u2014 verify on-chain via ${exactSettleCheckHint(net.family, payerFrom, nonce)} before re-presenting the SAME signed authorization; do NOT re-pay.`,
|
|
4797
4815
|
{ cause: err, ref: nonce }
|
|
4798
4816
|
);
|
|
4799
4817
|
} finally {
|
|
@@ -4809,7 +4827,7 @@ var PipRailClient = class {
|
|
|
4809
4827
|
const receipt = parseReceipt(response);
|
|
4810
4828
|
this.captureReceipt(response, url);
|
|
4811
4829
|
this.safeEmit({ kind: "payment-settled", receipt, ...settle ? { settle } : {} });
|
|
4812
|
-
const ref = settle?.transaction || receipt?.transaction ||
|
|
4830
|
+
const ref = settle?.transaction || receipt?.transaction || `${net.family === "evm" ? "eip3009" : net.family}-nonce:${nonce}`;
|
|
4813
4831
|
this.recordSpend(quote, ref);
|
|
4814
4832
|
return response;
|
|
4815
4833
|
}
|
|
@@ -4828,7 +4846,7 @@ var PipRailClient = class {
|
|
|
4828
4846
|
...lastReason ? { code: lastReason.error, detail: lastReason.detail } : {}
|
|
4829
4847
|
});
|
|
4830
4848
|
throw new MaxRetriesExceededError(
|
|
4831
|
-
`exact: server still returned 402 after submitting the signed authorization (nonce=${nonce}). Last rejection: ${why}. Re-present the SAME authorization \u2014 do NOT re-sign a fresh nonce; verify
|
|
4849
|
+
`exact: server still returned 402 after submitting the signed authorization (nonce=${nonce}). Last rejection: ${why}. Re-present the SAME authorization \u2014 do NOT re-sign a fresh nonce; verify on-chain via ${exactSettleCheckHint(net.family, payerFrom, nonce)} first. ref=${nonce}.`,
|
|
4832
4850
|
{ ref: nonce }
|
|
4833
4851
|
);
|
|
4834
4852
|
}
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _chunkDCOUJZPLcjs = require('./chunk-DCOUJZPL.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, _chunkDCOUJZPLcjs.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, _chunkDCOUJZPLcjs.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(_chunkDCOUJZPLcjs.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, _chunkDCOUJZPLcjs.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(_chunkDCOUJZPLcjs.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, _chunkDCOUJZPLcjs.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, _chunkDCOUJZPLcjs.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, _chunkDCOUJZPLcjs.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, _chunkDCOUJZPLcjs.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, _chunkDCOUJZPLcjs.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, _chunkDCOUJZPLcjs.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, _chunkDCOUJZPLcjs.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, _chunkDCOUJZPLcjs.WrongFamilyError)(
|
|
412
412
|
`chain ${network} is NEAR; wallet must be { accountId, key } (key = ed25519:\u2026).`
|
|
413
413
|
);
|
|
414
414
|
}
|
|
415
|
-
|
|
415
|
+
_chunkDCOUJZPLcjs.assertNoLegacyWalletKey.call(void 0, wallet, "NEAR");
|
|
416
416
|
if (!("accountId" in wallet) || !("key" in wallet)) {
|
|
417
|
-
throw new (0,
|
|
417
|
+
throw new (0, _chunkDCOUJZPLcjs.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, _chunkDCOUJZPLcjs.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, _chunkDCOUJZPLcjs.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, _chunkDCOUJZPLcjs.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
|
+
_chunkDCOUJZPLcjs.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, _chunkDCOUJZPLcjs.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, _chunkDCOUJZPLcjs.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, _chunkDCOUJZPLcjs.WrongFamilyError)(
|
|
527
527
|
`chain ${network} is NEAR, but payTo "${payTo}" is not a valid NEAR account id.`
|
|
528
528
|
);
|
|
529
529
|
}
|
|
@@ -567,10 +567,10 @@ 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, _chunkDCOUJZPLcjs.ConfirmationTimeoutError)(`NEAR tx ${hash} not confirmed in time.`);
|
|
571
571
|
},
|
|
572
572
|
async estimateCost() {
|
|
573
|
-
return
|
|
573
|
+
return _chunkDCOUJZPLcjs.nativeCost.call(void 0, {
|
|
574
574
|
symbol: "NEAR",
|
|
575
575
|
decimals: NEAR_DECIMALS,
|
|
576
576
|
fee: 1500000000000000000000n,
|
|
@@ -692,7 +692,7 @@ function makeNearNetwork(preset, rpcUrl) {
|
|
|
692
692
|
try {
|
|
693
693
|
relayerWallet = resolveNearWallet(relayer._native);
|
|
694
694
|
} catch (err) {
|
|
695
|
-
throw new (0,
|
|
695
|
+
throw new (0, _chunkDCOUJZPLcjs.SettlementError)(
|
|
696
696
|
`NEAR exact settle: the relayer wallet is invalid (${err instanceof Error ? err.message : String(err)}).`,
|
|
697
697
|
{ cause: err }
|
|
698
698
|
);
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunkDCOUJZPLcjs = require('./chunk-DCOUJZPL.cjs');
|
|
12
12
|
|
|
13
13
|
// src/drivers/solana/index.ts
|
|
14
14
|
var _web3js = require('@solana/web3.js');
|
|
@@ -236,7 +236,7 @@ function isEmptySig(sig) {
|
|
|
236
236
|
function memoRandomNonce() {
|
|
237
237
|
const g = globalThis.crypto;
|
|
238
238
|
if (!_optionalChain([g, 'optionalAccess', _3 => _3.getRandomValues])) {
|
|
239
|
-
throw new (0,
|
|
239
|
+
throw new (0, _chunkDCOUJZPLcjs.UnsupportedSchemeError)(
|
|
240
240
|
"this runtime lacks Web Crypto (globalThis.crypto.getRandomValues); SVM exact needs a CSPRNG nonce."
|
|
241
241
|
);
|
|
242
242
|
}
|
|
@@ -248,7 +248,7 @@ function memoDataFor(accept) {
|
|
|
248
248
|
if (accept.extra.memo !== void 0) {
|
|
249
249
|
const bytes = Buffer.from(accept.extra.memo, "utf8");
|
|
250
250
|
if (bytes.length > MAX_MEMO_BYTES) {
|
|
251
|
-
throw new (0,
|
|
251
|
+
throw new (0, _chunkDCOUJZPLcjs.UnsupportedSchemeError)(
|
|
252
252
|
`SVM exact: extra.memo is ${bytes.length} bytes; the scheme caps it at ${MAX_MEMO_BYTES}.`
|
|
253
253
|
);
|
|
254
254
|
}
|
|
@@ -262,15 +262,15 @@ function memoInstruction(accept) {
|
|
|
262
262
|
async function payExactSolana(input) {
|
|
263
263
|
const { connection, keypair, accept } = input;
|
|
264
264
|
if (accept.asset === "native") {
|
|
265
|
-
throw new (0,
|
|
265
|
+
throw new (0, _chunkDCOUJZPLcjs.UnsupportedSchemeError)(
|
|
266
266
|
"SVM exact is SPL-token only (TransferChecked); native SOL is not exact-payable. Pay via onchain-proof."
|
|
267
267
|
);
|
|
268
268
|
}
|
|
269
269
|
if (!accept.extra.feePayer) {
|
|
270
|
-
throw new (0,
|
|
270
|
+
throw new (0, _chunkDCOUJZPLcjs.UnsupportedSchemeError)("SVM exact rail must advertise extra.feePayer (the merchant sponsor key).");
|
|
271
271
|
}
|
|
272
272
|
if (accept.extra.decimals === void 0) {
|
|
273
|
-
throw new (0,
|
|
273
|
+
throw new (0, _chunkDCOUJZPLcjs.UnsupportedSchemeError)("SVM exact rail must advertise extra.decimals for the TransferChecked.");
|
|
274
274
|
}
|
|
275
275
|
let feePayer;
|
|
276
276
|
let mint;
|
|
@@ -280,12 +280,12 @@ async function payExactSolana(input) {
|
|
|
280
280
|
mint = new (0, _web3js.PublicKey)(accept.asset);
|
|
281
281
|
payTo = new (0, _web3js.PublicKey)(accept.payTo);
|
|
282
282
|
} catch (err) {
|
|
283
|
-
throw new (0,
|
|
283
|
+
throw new (0, _chunkDCOUJZPLcjs.UnsupportedSchemeError)(
|
|
284
284
|
`SVM exact: bad feePayer/asset/payTo (${err instanceof Error ? err.message : String(err)}).`
|
|
285
285
|
);
|
|
286
286
|
}
|
|
287
287
|
if (feePayer.equals(payTo)) {
|
|
288
|
-
throw new (0,
|
|
288
|
+
throw new (0, _chunkDCOUJZPLcjs.UnsupportedSchemeError)(
|
|
289
289
|
"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."
|
|
290
290
|
);
|
|
291
291
|
}
|
|
@@ -299,7 +299,7 @@ async function payExactSolana(input) {
|
|
|
299
299
|
destInfo = "unknown";
|
|
300
300
|
}
|
|
301
301
|
if (destInfo === null) {
|
|
302
|
-
throw new (0,
|
|
302
|
+
throw new (0, _chunkDCOUJZPLcjs.UnsupportedSchemeError)(
|
|
303
303
|
`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.`
|
|
304
304
|
);
|
|
305
305
|
}
|
|
@@ -330,11 +330,11 @@ async function payExactSolana(input) {
|
|
|
330
330
|
tx.sign([keypair]);
|
|
331
331
|
const buyerIndex = message.staticAccountKeys.findIndex((k) => k.equals(keypair.publicKey));
|
|
332
332
|
if (buyerIndex < 1 || buyerIndex >= message.header.numRequiredSignatures) {
|
|
333
|
-
throw new (0,
|
|
333
|
+
throw new (0, _chunkDCOUJZPLcjs.UnsupportedSchemeError)("SVM exact: could not locate the buyer signer slot.");
|
|
334
334
|
}
|
|
335
335
|
const buyerSig = tx.signatures[buyerIndex];
|
|
336
336
|
if (!buyerSig || isEmptySig(buyerSig)) {
|
|
337
|
-
throw new (0,
|
|
337
|
+
throw new (0, _chunkDCOUJZPLcjs.UnsupportedSchemeError)("SVM exact: the wallet did not produce a buyer signature.");
|
|
338
338
|
}
|
|
339
339
|
const transaction = Buffer.from(tx.serialize()).toString("base64");
|
|
340
340
|
return {
|
|
@@ -361,15 +361,15 @@ async function verifyAndSettleExactSolana(input) {
|
|
|
361
361
|
if (!accept.extra.feePayer) throw new Error("rail is missing extra.feePayer");
|
|
362
362
|
railFeePayer = new (0, _web3js.PublicKey)(accept.extra.feePayer);
|
|
363
363
|
} catch (err) {
|
|
364
|
-
throw new (0,
|
|
364
|
+
throw new (0, _chunkDCOUJZPLcjs.SettlementError)(`SVM exact: rail has a bad payTo/asset/feePayer (${err instanceof Error ? err.message : String(err)}).`);
|
|
365
365
|
}
|
|
366
366
|
if (!railFeePayer.equals(feePayerKeypair.publicKey)) {
|
|
367
|
-
throw new (0,
|
|
367
|
+
throw new (0, _chunkDCOUJZPLcjs.SettlementError)(
|
|
368
368
|
"SVM exact: the gate relayer key does not match the rail extra.feePayer \u2014 misconfigured rail."
|
|
369
369
|
);
|
|
370
370
|
}
|
|
371
371
|
if (feePayerKeypair.publicKey.equals(payTo)) {
|
|
372
|
-
throw new (0,
|
|
372
|
+
throw new (0, _chunkDCOUJZPLcjs.SettlementError)("SVM exact: the fee payer must differ from payTo \u2014 misconfigured rail.");
|
|
373
373
|
}
|
|
374
374
|
const program = tokenProgramFor(accept);
|
|
375
375
|
let tx;
|
|
@@ -509,7 +509,7 @@ async function verifyAndSettleExactSolana(input) {
|
|
|
509
509
|
} catch (err) {
|
|
510
510
|
const msg = err instanceof Error ? err.message : String(err);
|
|
511
511
|
if (/blockhash|block height|expired/i.test(msg)) return fail("payment_expired", `Settle broadcast rejected \u2014 blockhash expired: ${shorten(msg)}.`);
|
|
512
|
-
throw new (0,
|
|
512
|
+
throw new (0, _chunkDCOUJZPLcjs.SettlementError)(
|
|
513
513
|
`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.`,
|
|
514
514
|
{ cause: err }
|
|
515
515
|
);
|
|
@@ -519,7 +519,7 @@ async function verifyAndSettleExactSolana(input) {
|
|
|
519
519
|
return fail("tx_reverted", `Settle tx ${txid} reverted on-chain (a post-simulate race).`);
|
|
520
520
|
}
|
|
521
521
|
if (confirmed === "timeout") {
|
|
522
|
-
throw new (0,
|
|
522
|
+
throw new (0, _chunkDCOUJZPLcjs.SettlementError)(
|
|
523
523
|
`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.`
|
|
524
524
|
);
|
|
525
525
|
}
|
|
@@ -562,18 +562,18 @@ async function pollConfirmed(connection, signature) {
|
|
|
562
562
|
|
|
563
563
|
function toKeypair(wallet, network) {
|
|
564
564
|
if (typeof wallet !== "object" || wallet === null) {
|
|
565
|
-
throw new (0,
|
|
565
|
+
throw new (0, _chunkDCOUJZPLcjs.WrongFamilyError)(
|
|
566
566
|
`chain ${network} is Solana; wallet must be { key } (base58 secret) or { signer }.`
|
|
567
567
|
);
|
|
568
568
|
}
|
|
569
|
-
|
|
569
|
+
_chunkDCOUJZPLcjs.assertNoLegacyWalletKey.call(void 0, wallet, "Solana");
|
|
570
570
|
if ("signer" in wallet) {
|
|
571
571
|
return wallet.signer;
|
|
572
572
|
}
|
|
573
573
|
if ("key" in wallet) {
|
|
574
574
|
const sk = wallet.key;
|
|
575
575
|
if (typeof sk === "string" && sk.startsWith("0x")) {
|
|
576
|
-
throw new (0,
|
|
576
|
+
throw new (0, _chunkDCOUJZPLcjs.WrongFamilyError)(
|
|
577
577
|
`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).`
|
|
578
578
|
);
|
|
579
579
|
}
|
|
@@ -581,12 +581,12 @@ function toKeypair(wallet, network) {
|
|
|
581
581
|
const bytes = typeof sk === "string" ? _bs582.default.decode(sk) : sk;
|
|
582
582
|
return _web3js.Keypair.fromSecretKey(bytes);
|
|
583
583
|
} catch (err) {
|
|
584
|
-
throw new (0,
|
|
584
|
+
throw new (0, _chunkDCOUJZPLcjs.WrongFamilyError)(
|
|
585
585
|
`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)}.`
|
|
586
586
|
);
|
|
587
587
|
}
|
|
588
588
|
}
|
|
589
|
-
throw new (0,
|
|
589
|
+
throw new (0, _chunkDCOUJZPLcjs.WrongFamilyError)(
|
|
590
590
|
`chain ${network} is Solana; wallet must be { key } (base58 secret) or { signer }.`
|
|
591
591
|
);
|
|
592
592
|
}
|
|
@@ -615,15 +615,15 @@ function makeSolanaNetwork(preset, rpcUrl) {
|
|
|
615
615
|
const info = preset.tokens[token.toUpperCase()];
|
|
616
616
|
if (!info) {
|
|
617
617
|
const known = Object.keys(preset.tokens).join(", ") || "(none built in)";
|
|
618
|
-
throw new (0,
|
|
618
|
+
throw new (0, _chunkDCOUJZPLcjs.UnknownTokenError)(
|
|
619
619
|
`token "${token}" isn't built in for Solana (known: ${known}). Pass { mint, decimals } instead, or use 'native'.`
|
|
620
620
|
);
|
|
621
621
|
}
|
|
622
622
|
return { asset: info.mint, decimals: info.decimals, symbol: info.symbol };
|
|
623
623
|
}
|
|
624
|
-
|
|
624
|
+
_chunkDCOUJZPLcjs.rejectForeignToken.call(void 0, token, "solana", network);
|
|
625
625
|
if (!("mint" in token)) {
|
|
626
|
-
throw new (0,
|
|
626
|
+
throw new (0, _chunkDCOUJZPLcjs.WrongFamilyError)(
|
|
627
627
|
`chain ${network} is Solana; a custom token must be { mint, decimals }.`
|
|
628
628
|
);
|
|
629
629
|
}
|
|
@@ -642,14 +642,14 @@ function makeSolanaNetwork(preset, rpcUrl) {
|
|
|
642
642
|
},
|
|
643
643
|
assertValidPayTo(payTo) {
|
|
644
644
|
if (payTo.startsWith("0x")) {
|
|
645
|
-
throw new (0,
|
|
645
|
+
throw new (0, _chunkDCOUJZPLcjs.WrongFamilyError)(
|
|
646
646
|
`chain ${network} is Solana, but payTo "${payTo}" looks like an EVM address.`
|
|
647
647
|
);
|
|
648
648
|
}
|
|
649
649
|
try {
|
|
650
650
|
new (0, _web3js.PublicKey)(payTo);
|
|
651
651
|
} catch (e7) {
|
|
652
|
-
throw new (0,
|
|
652
|
+
throw new (0, _chunkDCOUJZPLcjs.WrongFamilyError)(
|
|
653
653
|
`chain ${network} is Solana, but payTo "${payTo}" is not a base58 address.`
|
|
654
654
|
);
|
|
655
655
|
}
|
|
@@ -661,7 +661,7 @@ function makeSolanaNetwork(preset, rpcUrl) {
|
|
|
661
661
|
try {
|
|
662
662
|
return await paySolana({ connection, keypair: wallet._native, accept });
|
|
663
663
|
} catch (err) {
|
|
664
|
-
throw _nullishCoalesce(
|
|
664
|
+
throw _nullishCoalesce(_chunkDCOUJZPLcjs.toInsufficientFundsError.call(void 0, err), () => ( err));
|
|
665
665
|
}
|
|
666
666
|
},
|
|
667
667
|
async confirm(ref) {
|
|
@@ -672,19 +672,19 @@ function makeSolanaNetwork(preset, rpcUrl) {
|
|
|
672
672
|
});
|
|
673
673
|
info = value[0];
|
|
674
674
|
} catch (err) {
|
|
675
|
-
throw new (0,
|
|
675
|
+
throw new (0, _chunkDCOUJZPLcjs.ConfirmationTimeoutError)(
|
|
676
676
|
`Solana payment ${ref} could not be confirmed (RPC read failed).`,
|
|
677
677
|
{ cause: err }
|
|
678
678
|
);
|
|
679
679
|
}
|
|
680
680
|
if (!info || info.err || info.confirmationStatus !== "confirmed" && info.confirmationStatus !== "finalized") {
|
|
681
|
-
throw new (0,
|
|
681
|
+
throw new (0, _chunkDCOUJZPLcjs.ConfirmationTimeoutError)(`Solana payment ${ref} did not confirm in time.`);
|
|
682
682
|
}
|
|
683
683
|
return { height: String(info.slot) };
|
|
684
684
|
},
|
|
685
685
|
async estimateCost(accept) {
|
|
686
686
|
if (accept.scheme === "exact") {
|
|
687
|
-
return
|
|
687
|
+
return _chunkDCOUJZPLcjs.nativeCost.call(void 0, {
|
|
688
688
|
symbol: "SOL",
|
|
689
689
|
decimals: SOL_DECIMALS,
|
|
690
690
|
fee: 0n,
|
|
@@ -694,7 +694,7 @@ function makeSolanaNetwork(preset, rpcUrl) {
|
|
|
694
694
|
}
|
|
695
695
|
const base = 5000n;
|
|
696
696
|
if (accept.asset === "native") {
|
|
697
|
-
return
|
|
697
|
+
return _chunkDCOUJZPLcjs.nativeCost.call(void 0, {
|
|
698
698
|
symbol: "SOL",
|
|
699
699
|
decimals: SOL_DECIMALS,
|
|
700
700
|
fee: base,
|
|
@@ -703,7 +703,7 @@ function makeSolanaNetwork(preset, rpcUrl) {
|
|
|
703
703
|
});
|
|
704
704
|
}
|
|
705
705
|
const ataRent = 2039280n;
|
|
706
|
-
return
|
|
706
|
+
return _chunkDCOUJZPLcjs.nativeCost.call(void 0, {
|
|
707
707
|
symbol: "SOL",
|
|
708
708
|
decimals: SOL_DECIMALS,
|
|
709
709
|
fee: base + ataRent,
|