@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/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,32 @@ All notable changes to `@piprail/sdk` are documented here. The format
|
|
|
4
4
|
follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the
|
|
5
5
|
versions follow [Semantic Versioning](https://semver.org/).
|
|
6
6
|
|
|
7
|
+
## [2.13.1] — 2026-06-21 — Family-correct `exact`-rail recovery hints (no EVM-only assumptions on non-EVM rails)
|
|
8
|
+
|
|
9
|
+
A correctness pass on the family-agnostic `exact` buyer path: its failure/timeout messages and one
|
|
10
|
+
audit-ref fallback hardcoded the **EVM-only** `authorizationState(from, nonce)` recovery and a stale
|
|
11
|
+
EVM-centric family list, even when paying a Solana / Algorand / Aptos / NEAR `exact` rail. The wire,
|
|
12
|
+
the settlement, and every default are **unchanged** — this only corrects user-facing text + an
|
|
13
|
+
internal label, and documents a signing prerequisite. Proven on Base + Solana mainnet (live `exact`
|
|
14
|
+
+ `onchain-proof` settlements, all clean).
|
|
15
|
+
|
|
16
|
+
- **fix(client): `PaymentTimeoutError` + `MaxRetriesExceededError` recovery hints are now
|
|
17
|
+
family-correct.** Both `exact`-path messages named the EVM `authorizationState(from, nonce)` for
|
|
18
|
+
every family; they now name the real single-use marker per family (EVM EIP-3009 nonce / Permit2
|
|
19
|
+
bitmap · Solana tx signature · Algorand group id · Aptos sequence number · NEAR access-key nonce),
|
|
20
|
+
via a new pure `util/exactRecovery.ts` helper (chain-agnostic, with a safe default for any future
|
|
21
|
+
family).
|
|
22
|
+
- **fix(client): the affirmative-settle audit-ref fallback** (used only when the facilitator echoes
|
|
23
|
+
no settle/receipt tx) was labelled `eip3009-nonce:` on every family; it's now `<family>-nonce:`
|
|
24
|
+
(EVM keeps `eip3009-nonce:`). No effect when a settle/receipt tx is present — the normal case.
|
|
25
|
+
- **fix(client): the "can't pay an `exact` rail" error listed `EVM, Solana, Algorand + NEAR`** —
|
|
26
|
+
now correctly includes **Aptos**.
|
|
27
|
+
- **docs(receipts): `DeliverReceiptOptions.secret`** now documents that signing uses Web Crypto
|
|
28
|
+
(`crypto.subtle`, always present on Node ≥ 20 / modern browsers); on a runtime without it the body
|
|
29
|
+
is sent unsigned with no signature header, so a receiver must reject a *missing* signature.
|
|
30
|
+
- **docs:** `errors/error-hierarchy` + `errors/why-payments-fail` exact-recovery passages now
|
|
31
|
+
describe the per-family marker, not just the EVM one.
|
|
32
|
+
|
|
7
33
|
## [2.13.0] — 2026-06-21 — A2A hardening: spec-correct `payment-failed`, schema-contract precision + exhaustive edge-case coverage
|
|
8
34
|
|
|
9
35
|
An extreme-hardening pass on the **x402-over-A2A seller transport**, audited against the **real
|
|
@@ -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/algorand/index.ts
|
|
16
16
|
var _algosdk = require('algosdk'); var _algosdk2 = _interopRequireDefault(_algosdk);
|
|
@@ -58,13 +58,13 @@ async function payAlgorand(params) {
|
|
|
58
58
|
} catch (err) {
|
|
59
59
|
const mapped = mapAlgorandError(err, accept.payTo);
|
|
60
60
|
if (mapped) throw mapped;
|
|
61
|
-
throw _nullishCoalesce(
|
|
61
|
+
throw _nullishCoalesce(_chunkDCOUJZPLcjs.toInsufficientFundsError.call(void 0, err), () => ( err));
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
function mapAlgorandError(err, payTo) {
|
|
65
65
|
const m = err instanceof Error ? err.message : String(err);
|
|
66
66
|
if (/must optin/i.test(m) || /missing from/i.test(m) && m.includes(payTo)) {
|
|
67
|
-
return new (0,
|
|
67
|
+
return new (0, _chunkDCOUJZPLcjs.RecipientNotReadyError)(
|
|
68
68
|
`Algorand recipient ${payTo} hasn't opted into this asset \u2014 it must opt in (a 0-amount asset transfer to itself) before it can receive. (Algorand: ${firstLine(m)})`,
|
|
69
69
|
{ cause: err }
|
|
70
70
|
);
|
|
@@ -72,7 +72,7 @@ function mapAlgorandError(err, payTo) {
|
|
|
72
72
|
if (/overspend|below min|min(imum)? balance|tried to spend|balance \d+ below|asset \d+ missing from|insufficient|underflow/i.test(
|
|
73
73
|
m
|
|
74
74
|
)) {
|
|
75
|
-
return new (0,
|
|
75
|
+
return new (0, _chunkDCOUJZPLcjs.InsufficientFundsError)(
|
|
76
76
|
`Algorand payment failed: the sender can't cover it \u2014 token balance, ALGO for fees, the 0.1-ALGO minimum balance, or a missing asset opt-in on the sender. (Algorand: ${firstLine(m)})`,
|
|
77
77
|
{ cause: err }
|
|
78
78
|
);
|
|
@@ -99,33 +99,33 @@ function isSet(addr) {
|
|
|
99
99
|
function randomNote() {
|
|
100
100
|
const g = globalThis.crypto;
|
|
101
101
|
if (!_optionalChain([g, 'optionalAccess', _ => _.getRandomValues])) {
|
|
102
|
-
throw new (0,
|
|
102
|
+
throw new (0, _chunkDCOUJZPLcjs.UnsupportedSchemeError)("Algorand exact: no Web Crypto CSPRNG available to generate a unique note.");
|
|
103
103
|
}
|
|
104
104
|
return g.getRandomValues(new Uint8Array(32));
|
|
105
105
|
}
|
|
106
106
|
async function payExactAlgorand(input) {
|
|
107
107
|
const { suggestedParams, sk, sender, accept } = input;
|
|
108
108
|
if (accept.asset === "native") {
|
|
109
|
-
throw new (0,
|
|
109
|
+
throw new (0, _chunkDCOUJZPLcjs.UnsupportedSchemeError)(
|
|
110
110
|
"Algorand exact is ASA-only (an asset transfer); native ALGO is not exact-payable. Pay via onchain-proof."
|
|
111
111
|
);
|
|
112
112
|
}
|
|
113
113
|
const feePayer = accept.extra.feePayer;
|
|
114
114
|
if (!feePayer) {
|
|
115
|
-
throw new (0,
|
|
115
|
+
throw new (0, _chunkDCOUJZPLcjs.UnsupportedSchemeError)("Algorand exact rail must advertise extra.feePayer (the fee sponsor address).");
|
|
116
116
|
}
|
|
117
117
|
const assetId = parseAlgorandAssetId(accept.asset);
|
|
118
118
|
if (assetId === null) {
|
|
119
|
-
throw new (0,
|
|
119
|
+
throw new (0, _chunkDCOUJZPLcjs.UnsupportedSchemeError)(`Algorand exact rail asset "${accept.asset}" must be a numeric ASA id.`);
|
|
120
120
|
}
|
|
121
121
|
if (!_algosdk2.default.isValidAddress(feePayer)) {
|
|
122
|
-
throw new (0,
|
|
122
|
+
throw new (0, _chunkDCOUJZPLcjs.UnsupportedSchemeError)(`Algorand exact: extra.feePayer "${feePayer}" is not a valid Algorand address.`);
|
|
123
123
|
}
|
|
124
124
|
if (!_algosdk2.default.isValidAddress(accept.payTo)) {
|
|
125
|
-
throw new (0,
|
|
125
|
+
throw new (0, _chunkDCOUJZPLcjs.UnsupportedSchemeError)(`Algorand exact: payTo "${accept.payTo}" is not a valid Algorand address.`);
|
|
126
126
|
}
|
|
127
127
|
if (feePayer === sender) {
|
|
128
|
-
throw new (0,
|
|
128
|
+
throw new (0, _chunkDCOUJZPLcjs.UnsupportedSchemeError)(
|
|
129
129
|
"Algorand exact: the fee payer must differ from the payer \u2014 the buyer must pay ZERO ALGO (the sponsor pays the pooled fee)."
|
|
130
130
|
);
|
|
131
131
|
}
|
|
@@ -172,13 +172,13 @@ function decodeElement(bytes) {
|
|
|
172
172
|
async function verifyAndSettleExactAlgorand(input) {
|
|
173
173
|
const { client, feePayerSk, feePayerAddr, payload, accept } = input;
|
|
174
174
|
const railFeePayer = accept.extra.feePayer;
|
|
175
|
-
if (!railFeePayer) throw new (0,
|
|
175
|
+
if (!railFeePayer) throw new (0, _chunkDCOUJZPLcjs.SettlementError)("Algorand exact: rail is missing extra.feePayer.");
|
|
176
176
|
if (railFeePayer !== feePayerAddr) {
|
|
177
|
-
throw new (0,
|
|
177
|
+
throw new (0, _chunkDCOUJZPLcjs.SettlementError)("Algorand exact: the gate relayer address does not match the rail extra.feePayer \u2014 misconfigured rail.");
|
|
178
178
|
}
|
|
179
179
|
const assetId = parseAlgorandAssetId(accept.asset);
|
|
180
|
-
if (assetId === null) throw new (0,
|
|
181
|
-
if (!_algosdk2.default.isValidAddress(accept.payTo)) throw new (0,
|
|
180
|
+
if (assetId === null) throw new (0, _chunkDCOUJZPLcjs.SettlementError)(`Algorand exact: rail asset "${accept.asset}" is not a numeric ASA id.`);
|
|
181
|
+
if (!_algosdk2.default.isValidAddress(accept.payTo)) throw new (0, _chunkDCOUJZPLcjs.SettlementError)(`Algorand exact: rail payTo "${accept.payTo}" is invalid.`);
|
|
182
182
|
const { paymentIndex, paymentGroup } = payload;
|
|
183
183
|
if (paymentGroup.length !== GROUP_SIZE) {
|
|
184
184
|
return fail("signature_invalid", `Algorand exact expects a ${GROUP_SIZE}-transaction group (payment + fee), got ${paymentGroup.length}.`);
|
|
@@ -244,7 +244,7 @@ async function verifyAndSettleExactAlgorand(input) {
|
|
|
244
244
|
try {
|
|
245
245
|
feeSigned = fee.signTxn(feePayerSk);
|
|
246
246
|
} catch (err) {
|
|
247
|
-
throw new (0,
|
|
247
|
+
throw new (0, _chunkDCOUJZPLcjs.SettlementError)(`Algorand exact settle: the gate could not sign the fee transaction (${shorten(err instanceof Error ? err.message : String(err))}).`, { cause: err });
|
|
248
248
|
}
|
|
249
249
|
const signedGroup = elements.map((el, i) => i === paymentIndex ? payElement.raw : feeSigned);
|
|
250
250
|
try {
|
|
@@ -266,7 +266,7 @@ async function verifyAndSettleExactAlgorand(input) {
|
|
|
266
266
|
if (/signature|sig|auth|malformed/i.test(m)) return fail("signature_invalid", `Settle rejected \u2014 bad signature: ${shorten(m)}.`);
|
|
267
267
|
if (/already in ledger|already committed|duplicate/i.test(m)) return fail("tx_already_used", `This payment was already settled: ${shorten(m)}.`);
|
|
268
268
|
if (/\bround\b|expired|lifetime|stale|validity/i.test(m)) return fail("payment_expired", `Settle rejected \u2014 validity window expired: ${shorten(m)}.`);
|
|
269
|
-
throw new (0,
|
|
269
|
+
throw new (0, _chunkDCOUJZPLcjs.SettlementError)(
|
|
270
270
|
`Algorand exact settle: the group failed to submit (${shorten(m)}). The buyer's signed transaction is still valid \u2014 fund/fix the fee payer (${railFeePayer}) and the buyer can re-present it.`,
|
|
271
271
|
{ cause: err }
|
|
272
272
|
);
|
|
@@ -275,10 +275,10 @@ async function verifyAndSettleExactAlgorand(input) {
|
|
|
275
275
|
try {
|
|
276
276
|
round = await client.waitForConfirmation(buyerTxid);
|
|
277
277
|
} catch (err) {
|
|
278
|
-
throw new (0,
|
|
278
|
+
throw new (0, _chunkDCOUJZPLcjs.SettlementError)(`Algorand exact settle: submitted ${buyerTxid} but confirmation read failed (${shorten(err instanceof Error ? err.message : String(err))}). It likely landed \u2014 re-verify before re-presenting; do NOT re-pay.`, { cause: err });
|
|
279
279
|
}
|
|
280
280
|
if (round === null) {
|
|
281
|
-
throw new (0,
|
|
281
|
+
throw new (0, _chunkDCOUJZPLcjs.SettlementError)(`Algorand exact settle: submitted ${buyerTxid} but it did not confirm in time. It likely landed \u2014 re-verify before re-presenting; do NOT re-pay.`);
|
|
282
282
|
}
|
|
283
283
|
return {
|
|
284
284
|
ok: true,
|
|
@@ -373,13 +373,13 @@ function rpcFailed(nonce) {
|
|
|
373
373
|
|
|
374
374
|
function assertAlgorandWallet(wallet, network) {
|
|
375
375
|
if (typeof wallet !== "object" || wallet === null) {
|
|
376
|
-
throw new (0,
|
|
376
|
+
throw new (0, _chunkDCOUJZPLcjs.WrongFamilyError)(
|
|
377
377
|
`chain ${network} is Algorand; wallet must be { key } (25-word mnemonic) or { account }.`
|
|
378
378
|
);
|
|
379
379
|
}
|
|
380
|
-
|
|
380
|
+
_chunkDCOUJZPLcjs.assertNoLegacyWalletKey.call(void 0, wallet, "Algorand");
|
|
381
381
|
if (!("key" in wallet) && !("account" in wallet)) {
|
|
382
|
-
throw new (0,
|
|
382
|
+
throw new (0, _chunkDCOUJZPLcjs.WrongFamilyError)(
|
|
383
383
|
`chain ${network} is Algorand; wallet must be { key } (25-word mnemonic) or { account }.`
|
|
384
384
|
);
|
|
385
385
|
}
|
|
@@ -394,13 +394,13 @@ function resolveAlgorandWallet(config) {
|
|
|
394
394
|
const { addr, sk } = _algosdk2.default.mnemonicToSecretKey(config.key);
|
|
395
395
|
return { addr: addr.toString(), sk };
|
|
396
396
|
} catch (cause) {
|
|
397
|
-
throw new (0,
|
|
397
|
+
throw new (0, _chunkDCOUJZPLcjs.WrongFamilyError)(
|
|
398
398
|
"Algorand wallet { key } is not a valid 25-word Algorand mnemonic.",
|
|
399
399
|
{ cause }
|
|
400
400
|
);
|
|
401
401
|
}
|
|
402
402
|
}
|
|
403
|
-
throw new (0,
|
|
403
|
+
throw new (0, _chunkDCOUJZPLcjs.WrongFamilyError)("Algorand wallet needs { key } (25-word mnemonic) or { account }.");
|
|
404
404
|
}
|
|
405
405
|
|
|
406
406
|
// src/drivers/algorand/index.ts
|
|
@@ -471,16 +471,16 @@ function makeAlgorandNetwork(preset, algodUrl) {
|
|
|
471
471
|
const info = preset.tokens[token.toUpperCase()];
|
|
472
472
|
if (!info) {
|
|
473
473
|
const known = Object.keys(preset.tokens).join(", ") || "(none built in)";
|
|
474
|
-
throw new (0,
|
|
474
|
+
throw new (0, _chunkDCOUJZPLcjs.UnknownTokenError)(
|
|
475
475
|
`token "${token}" isn't built in for Algorand (known: ${known}). Pass { assetId, decimals } for a custom ASA, or use 'native'.`
|
|
476
476
|
);
|
|
477
477
|
}
|
|
478
478
|
return { asset: algorandAssetId(info.assetId), decimals: info.decimals, symbol: info.symbol };
|
|
479
479
|
}
|
|
480
|
-
|
|
480
|
+
_chunkDCOUJZPLcjs.rejectForeignToken.call(void 0, token, "algorand", network);
|
|
481
481
|
const t = token;
|
|
482
482
|
if (typeof t.assetId !== "number" || typeof t.decimals !== "number") {
|
|
483
|
-
throw new (0,
|
|
483
|
+
throw new (0, _chunkDCOUJZPLcjs.WrongFamilyError)(
|
|
484
484
|
`chain ${network} is Algorand; a custom token must be { assetId, decimals }.`
|
|
485
485
|
);
|
|
486
486
|
}
|
|
@@ -501,12 +501,12 @@ function makeAlgorandNetwork(preset, algodUrl) {
|
|
|
501
501
|
},
|
|
502
502
|
assertValidPayTo(payTo) {
|
|
503
503
|
if (payTo.startsWith("0x")) {
|
|
504
|
-
throw new (0,
|
|
504
|
+
throw new (0, _chunkDCOUJZPLcjs.WrongFamilyError)(
|
|
505
505
|
`chain ${network} is Algorand, but payTo "${payTo}" looks like an EVM address.`
|
|
506
506
|
);
|
|
507
507
|
}
|
|
508
508
|
if (!_algosdk2.default.isValidAddress(payTo)) {
|
|
509
|
-
throw new (0,
|
|
509
|
+
throw new (0, _chunkDCOUJZPLcjs.WrongFamilyError)(
|
|
510
510
|
`chain ${network} is Algorand, but payTo "${payTo}" is not a valid Algorand address.`
|
|
511
511
|
);
|
|
512
512
|
}
|
|
@@ -523,14 +523,14 @@ function makeAlgorandNetwork(preset, algodUrl) {
|
|
|
523
523
|
const info = await _algosdk2.default.waitForConfirmation(algod, ref, 10);
|
|
524
524
|
return { height: String(_nullishCoalesce(info.confirmedRound, () => ( 0))) };
|
|
525
525
|
} catch (err) {
|
|
526
|
-
throw new (0,
|
|
526
|
+
throw new (0, _chunkDCOUJZPLcjs.ConfirmationTimeoutError)(`Algorand tx ${ref} did not confirm in time.`, {
|
|
527
527
|
cause: err
|
|
528
528
|
});
|
|
529
529
|
}
|
|
530
530
|
},
|
|
531
531
|
async estimateCost(accept) {
|
|
532
532
|
if (accept.scheme === "exact") {
|
|
533
|
-
return
|
|
533
|
+
return _chunkDCOUJZPLcjs.nativeCost.call(void 0, {
|
|
534
534
|
symbol: ALGO_SYMBOL,
|
|
535
535
|
decimals: ALGO_DECIMALS,
|
|
536
536
|
fee: 0n,
|
|
@@ -538,7 +538,7 @@ function makeAlgorandNetwork(preset, algodUrl) {
|
|
|
538
538
|
detail: "gasless \u2014 the fee payer (facilitator/relayer) pools the group fee; the buyer pays 0 ALGO"
|
|
539
539
|
});
|
|
540
540
|
}
|
|
541
|
-
return
|
|
541
|
+
return _chunkDCOUJZPLcjs.nativeCost.call(void 0, {
|
|
542
542
|
symbol: ALGO_SYMBOL,
|
|
543
543
|
decimals: ALGO_DECIMALS,
|
|
544
544
|
fee: 1000n,
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _chunkDCOUJZPLcjs = require('./chunk-DCOUJZPL.cjs');
|
|
13
13
|
|
|
14
14
|
// src/drivers/aptos/index.ts
|
|
15
15
|
var _tssdk = require('@aptos-labs/ts-sdk');
|
|
@@ -58,14 +58,14 @@ async function payAptos(params) {
|
|
|
58
58
|
const res = await client.signSubmit({ signer, transaction });
|
|
59
59
|
return res.hash;
|
|
60
60
|
} catch (err) {
|
|
61
|
-
if (err instanceof
|
|
61
|
+
if (err instanceof _chunkDCOUJZPLcjs.InsufficientFundsError) throw err;
|
|
62
62
|
if (isAptosAffordability(err)) {
|
|
63
|
-
throw new (0,
|
|
63
|
+
throw new (0, _chunkDCOUJZPLcjs.InsufficientFundsError)(
|
|
64
64
|
err instanceof Error ? err.message : "Insufficient APT/token balance for the payment.",
|
|
65
65
|
{ cause: err }
|
|
66
66
|
);
|
|
67
67
|
}
|
|
68
|
-
throw _nullishCoalesce(
|
|
68
|
+
throw _nullishCoalesce(_chunkDCOUJZPLcjs.toInsufficientFundsError.call(void 0, err), () => ( err));
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
function isAptosAffordability(err) {
|
|
@@ -103,24 +103,24 @@ function parseAddr(addr) {
|
|
|
103
103
|
async function payExactAptos(input) {
|
|
104
104
|
const { client, sender, accept } = input;
|
|
105
105
|
if (accept.asset === "native") {
|
|
106
|
-
throw new (0,
|
|
106
|
+
throw new (0, _chunkDCOUJZPLcjs.UnsupportedSchemeError)(
|
|
107
107
|
"Aptos exact is Fungible-Asset only (a primary_fungible_store transfer); native APT is not exact-payable. Pay via onchain-proof."
|
|
108
108
|
);
|
|
109
109
|
}
|
|
110
110
|
const feePayer = accept.extra.feePayer;
|
|
111
111
|
if (!feePayer) {
|
|
112
|
-
throw new (0,
|
|
112
|
+
throw new (0, _chunkDCOUJZPLcjs.UnsupportedSchemeError)("Aptos exact rail must advertise extra.feePayer (the gas sponsor address).");
|
|
113
113
|
}
|
|
114
114
|
const feePayerAddr = parseAddr(feePayer);
|
|
115
|
-
if (!feePayerAddr) throw new (0,
|
|
115
|
+
if (!feePayerAddr) throw new (0, _chunkDCOUJZPLcjs.UnsupportedSchemeError)(`Aptos exact: extra.feePayer "${feePayer}" is not a valid Aptos address.`);
|
|
116
116
|
const payToAddr = parseAddr(accept.payTo);
|
|
117
|
-
if (!payToAddr) throw new (0,
|
|
117
|
+
if (!payToAddr) throw new (0, _chunkDCOUJZPLcjs.UnsupportedSchemeError)(`Aptos exact: payTo "${accept.payTo}" is not a valid Aptos address.`);
|
|
118
118
|
const metadataAddr = parseAddr(accept.asset);
|
|
119
|
-
if (!metadataAddr) throw new (0,
|
|
119
|
+
if (!metadataAddr) throw new (0, _chunkDCOUJZPLcjs.UnsupportedSchemeError)(`Aptos exact: asset "${accept.asset}" is not a valid FA metadata address.`);
|
|
120
120
|
const senderAddr = parseAddr(sender);
|
|
121
|
-
if (!senderAddr) throw new (0,
|
|
121
|
+
if (!senderAddr) throw new (0, _chunkDCOUJZPLcjs.UnsupportedSchemeError)(`Aptos exact: payer "${sender}" is not a valid Aptos address.`);
|
|
122
122
|
if (feePayerAddr.equals(senderAddr)) {
|
|
123
|
-
throw new (0,
|
|
123
|
+
throw new (0, _chunkDCOUJZPLcjs.UnsupportedSchemeError)(
|
|
124
124
|
"Aptos exact: the fee payer must differ from the payer \u2014 the buyer must pay ZERO APT (the sponsor pays gas)."
|
|
125
125
|
);
|
|
126
126
|
}
|
|
@@ -158,16 +158,16 @@ function argBytes(arg) {
|
|
|
158
158
|
async function verifyAndSettleExactAptos(input) {
|
|
159
159
|
const { client, feePayerAddr, payload, accept } = input;
|
|
160
160
|
const railFeePayer = accept.extra.feePayer;
|
|
161
|
-
if (!railFeePayer) throw new (0,
|
|
161
|
+
if (!railFeePayer) throw new (0, _chunkDCOUJZPLcjs.SettlementError)("Aptos exact: rail is missing extra.feePayer.");
|
|
162
162
|
if (railFeePayer !== feePayerAddr) {
|
|
163
|
-
throw new (0,
|
|
163
|
+
throw new (0, _chunkDCOUJZPLcjs.SettlementError)("Aptos exact: the gate relayer address does not match the rail extra.feePayer \u2014 misconfigured rail.");
|
|
164
164
|
}
|
|
165
|
-
if (accept.asset === "native") throw new (0,
|
|
165
|
+
if (accept.asset === "native") throw new (0, _chunkDCOUJZPLcjs.SettlementError)("Aptos exact: native APT is not exact-payable (misconfigured rail).");
|
|
166
166
|
const railFeePayerAddr = parseAddr(railFeePayer);
|
|
167
167
|
const railPayTo = parseAddr(accept.payTo);
|
|
168
168
|
const railMetadata = parseAddr(accept.asset);
|
|
169
169
|
if (!railFeePayerAddr || !railPayTo || !railMetadata) {
|
|
170
|
-
throw new (0,
|
|
170
|
+
throw new (0, _chunkDCOUJZPLcjs.SettlementError)("Aptos exact: rail feePayer/payTo/asset is not a valid Aptos address (misconfigured rail).");
|
|
171
171
|
}
|
|
172
172
|
let tx;
|
|
173
173
|
let senderAuth;
|
|
@@ -241,7 +241,7 @@ async function verifyAndSettleExactAptos(input) {
|
|
|
241
241
|
try {
|
|
242
242
|
feePayerAuth = client.signAsFeePayer({ transaction: tx });
|
|
243
243
|
} catch (err) {
|
|
244
|
-
throw new (0,
|
|
244
|
+
throw new (0, _chunkDCOUJZPLcjs.SettlementError)(`Aptos exact settle: the gate could not sign as fee payer (${shorten(err instanceof Error ? err.message : String(err))}).`, { cause: err });
|
|
245
245
|
}
|
|
246
246
|
if (senderAuth instanceof _tssdk.AccountAuthenticatorEd25519) {
|
|
247
247
|
try {
|
|
@@ -264,7 +264,7 @@ async function verifyAndSettleExactAptos(input) {
|
|
|
264
264
|
if (/signature|invalid.*auth|INVALID_SIGNATURE/i.test(m)) return fail("signature_invalid", `Settle rejected \u2014 bad signature: ${shorten(m)}.`);
|
|
265
265
|
if (/SEQUENCE_NUMBER_TOO_OLD|already.*(committed|ledger)|duplicate/i.test(m)) return fail("tx_already_used", `This payment was already settled: ${shorten(m)}.`);
|
|
266
266
|
if (/EXPIRED|expired|TOO_NEW/i.test(m)) return fail("payment_expired", `Settle rejected \u2014 expired/stale: ${shorten(m)}.`);
|
|
267
|
-
throw new (0,
|
|
267
|
+
throw new (0, _chunkDCOUJZPLcjs.SettlementError)(
|
|
268
268
|
`Aptos exact settle: the transaction failed to submit (${shorten(m)}). The buyer's signed transaction is still valid \u2014 fund/fix the fee payer (${railFeePayer}) and the buyer can re-present it.`,
|
|
269
269
|
{ cause: err }
|
|
270
270
|
);
|
|
@@ -273,10 +273,10 @@ async function verifyAndSettleExactAptos(input) {
|
|
|
273
273
|
try {
|
|
274
274
|
confirmed = await client.waitForConfirmation(hash);
|
|
275
275
|
} catch (err) {
|
|
276
|
-
throw new (0,
|
|
276
|
+
throw new (0, _chunkDCOUJZPLcjs.SettlementError)(`Aptos exact settle: submitted ${hash} but confirmation read failed (${shorten(err instanceof Error ? err.message : String(err))}). It likely landed \u2014 re-verify before re-presenting; do NOT re-pay.`, { cause: err });
|
|
277
277
|
}
|
|
278
278
|
if (confirmed === null) {
|
|
279
|
-
throw new (0,
|
|
279
|
+
throw new (0, _chunkDCOUJZPLcjs.SettlementError)(`Aptos exact settle: submitted ${hash} but it did not confirm in time. It likely landed \u2014 re-verify before re-presenting; do NOT re-pay.`);
|
|
280
280
|
}
|
|
281
281
|
if (!confirmed.success) {
|
|
282
282
|
return fail("tx_reverted", `Settle tx ${hash} reverted on-chain (a post-simulate race).`);
|
|
@@ -371,13 +371,13 @@ function txNotFound(hash) {
|
|
|
371
371
|
|
|
372
372
|
function assertAptosWallet(wallet, network) {
|
|
373
373
|
if (typeof wallet !== "object" || wallet === null) {
|
|
374
|
-
throw new (0,
|
|
374
|
+
throw new (0, _chunkDCOUJZPLcjs.WrongFamilyError)(
|
|
375
375
|
`chain ${network} is Aptos; wallet must be { key } (ed25519-priv-0x\u2026) or { account }.`
|
|
376
376
|
);
|
|
377
377
|
}
|
|
378
|
-
|
|
378
|
+
_chunkDCOUJZPLcjs.assertNoLegacyWalletKey.call(void 0, wallet, "Aptos");
|
|
379
379
|
if (!("key" in wallet) && !("account" in wallet)) {
|
|
380
|
-
throw new (0,
|
|
380
|
+
throw new (0, _chunkDCOUJZPLcjs.WrongFamilyError)(
|
|
381
381
|
`chain ${network} is Aptos; wallet must be { key } (ed25519-priv-0x\u2026) or { account }.`
|
|
382
382
|
);
|
|
383
383
|
}
|
|
@@ -389,13 +389,13 @@ function resolveAptosAccount(config) {
|
|
|
389
389
|
try {
|
|
390
390
|
return _tssdk.Account.fromPrivateKey({ privateKey: new (0, _tssdk.Ed25519PrivateKey)(config.key) });
|
|
391
391
|
} catch (cause) {
|
|
392
|
-
throw new (0,
|
|
392
|
+
throw new (0, _chunkDCOUJZPLcjs.WrongFamilyError)(
|
|
393
393
|
"Aptos wallet { key } is not a valid ed25519 secret (ed25519-priv-0x\u2026 or 0x\u2026 hex).",
|
|
394
394
|
{ cause }
|
|
395
395
|
);
|
|
396
396
|
}
|
|
397
397
|
}
|
|
398
|
-
throw new (0,
|
|
398
|
+
throw new (0, _chunkDCOUJZPLcjs.WrongFamilyError)("Aptos wallet needs { key } (ed25519-priv-0x\u2026) or { account }.");
|
|
399
399
|
}
|
|
400
400
|
|
|
401
401
|
// src/drivers/aptos/index.ts
|
|
@@ -467,16 +467,16 @@ function makeAptosNetwork(preset, rpcUrl) {
|
|
|
467
467
|
const info = preset.tokens[token.toUpperCase()];
|
|
468
468
|
if (!info) {
|
|
469
469
|
const known = Object.keys(preset.tokens).join(", ") || "(none built in)";
|
|
470
|
-
throw new (0,
|
|
470
|
+
throw new (0, _chunkDCOUJZPLcjs.UnknownTokenError)(
|
|
471
471
|
`token "${token}" isn't built in for Aptos (known: ${known}). Pass { metadata, decimals } for a custom Fungible Asset, or use 'native'.`
|
|
472
472
|
);
|
|
473
473
|
}
|
|
474
474
|
return { asset: info.metadata, decimals: info.decimals, symbol: info.symbol };
|
|
475
475
|
}
|
|
476
|
-
|
|
476
|
+
_chunkDCOUJZPLcjs.rejectForeignToken.call(void 0, token, "aptos", network);
|
|
477
477
|
const t = token;
|
|
478
478
|
if (!t.metadata || typeof t.decimals !== "number") {
|
|
479
|
-
throw new (0,
|
|
479
|
+
throw new (0, _chunkDCOUJZPLcjs.WrongFamilyError)(
|
|
480
480
|
`chain ${network} is Aptos; a custom token must be { metadata, decimals }.`
|
|
481
481
|
);
|
|
482
482
|
}
|
|
@@ -503,7 +503,7 @@ function makeAptosNetwork(preset, rpcUrl) {
|
|
|
503
503
|
valid = false;
|
|
504
504
|
}
|
|
505
505
|
if (!valid || evmLike) {
|
|
506
|
-
throw new (0,
|
|
506
|
+
throw new (0, _chunkDCOUJZPLcjs.WrongFamilyError)(
|
|
507
507
|
`chain ${network} is Aptos, but payTo "${payTo}" is not a valid Aptos address (0x + 32 bytes).`
|
|
508
508
|
);
|
|
509
509
|
}
|
|
@@ -525,12 +525,12 @@ function makeAptosNetwork(preset, rpcUrl) {
|
|
|
525
525
|
const tx = await aptos.waitForTransaction({ transactionHash: ref });
|
|
526
526
|
return { height: String(_nullishCoalesce(tx.version, () => ( "0"))) };
|
|
527
527
|
} catch (err) {
|
|
528
|
-
throw new (0,
|
|
528
|
+
throw new (0, _chunkDCOUJZPLcjs.ConfirmationTimeoutError)(`Aptos tx ${ref} did not finalize in time.`, { cause: err });
|
|
529
529
|
}
|
|
530
530
|
},
|
|
531
531
|
async estimateCost(accept) {
|
|
532
532
|
if (accept.scheme === "exact") {
|
|
533
|
-
return
|
|
533
|
+
return _chunkDCOUJZPLcjs.nativeCost.call(void 0, {
|
|
534
534
|
symbol: APT_SYMBOL,
|
|
535
535
|
decimals: APT_DECIMALS,
|
|
536
536
|
fee: 0n,
|
|
@@ -538,7 +538,7 @@ function makeAptosNetwork(preset, rpcUrl) {
|
|
|
538
538
|
detail: "gasless \u2014 the fee payer (facilitator/relayer) sponsors gas; the buyer pays 0 APT"
|
|
539
539
|
});
|
|
540
540
|
}
|
|
541
|
-
return
|
|
541
|
+
return _chunkDCOUJZPLcjs.nativeCost.call(void 0, {
|
|
542
542
|
symbol: APT_SYMBOL,
|
|
543
543
|
decimals: APT_DECIMALS,
|
|
544
544
|
fee: 100000n,
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
nativeCost,
|
|
10
10
|
rejectForeignToken,
|
|
11
11
|
toInsufficientFundsError
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-O32N6MFN.js";
|
|
13
13
|
|
|
14
14
|
// src/drivers/aptos/index.ts
|
|
15
15
|
import { Aptos, AptosConfig, Network, AccountAddress as AccountAddress2 } from "@aptos-labs/ts-sdk";
|
|
@@ -40,10 +40,12 @@ var MaxRetriesExceededError = (_class5 = class extends PipRailError {
|
|
|
40
40
|
/**
|
|
41
41
|
* The proof ref — recover with it, don't re-pay. Its meaning depends on the
|
|
42
42
|
* scheme: for `onchain-proof` it's the already-broadcast transaction ref
|
|
43
|
-
* (re-verify or re-submit it). For a standard `exact` rail it's the
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
43
|
+
* (re-verify or re-submit it). For a standard `exact` rail it's the authorization's
|
|
44
|
+
* single-use marker (NOT a tx hash) — re-PRESENT the same signed authorization, never
|
|
45
|
+
* re-sign a fresh nonce, and verify it on-chain before assuming it didn't settle. On
|
|
46
|
+
* EVM that marker is the EIP-3009 NONCE (a `0x…` value), checked via the token's
|
|
47
|
+
* `authorizationState(from, nonce)`; the non-EVM `exact` rails key off their own marker
|
|
48
|
+
* (Solana tx signature, Algorand group id, Aptos account sequence number, NEAR access-key nonce).
|
|
47
49
|
*/
|
|
48
50
|
|
|
49
51
|
constructor(message, options) {
|
|
@@ -40,10 +40,12 @@ var MaxRetriesExceededError = class extends PipRailError {
|
|
|
40
40
|
/**
|
|
41
41
|
* The proof ref — recover with it, don't re-pay. Its meaning depends on the
|
|
42
42
|
* scheme: for `onchain-proof` it's the already-broadcast transaction ref
|
|
43
|
-
* (re-verify or re-submit it). For a standard `exact` rail it's the
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
43
|
+
* (re-verify or re-submit it). For a standard `exact` rail it's the authorization's
|
|
44
|
+
* single-use marker (NOT a tx hash) — re-PRESENT the same signed authorization, never
|
|
45
|
+
* re-sign a fresh nonce, and verify it on-chain before assuming it didn't settle. On
|
|
46
|
+
* EVM that marker is the EIP-3009 NONCE (a `0x…` value), checked via the token's
|
|
47
|
+
* `authorizationState(from, nonce)`; the non-EVM `exact` rails key off their own marker
|
|
48
|
+
* (Solana tx signature, Algorand group id, Aptos account sequence number, NEAR access-key nonce).
|
|
47
49
|
*/
|
|
48
50
|
ref;
|
|
49
51
|
constructor(message, options) {
|