@piprail/sdk 2.15.0 → 2.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/CHANGELOG.md +260 -0
  2. package/README.md +2 -2
  3. package/dist/{algorand-CSEUTWNW.js → algorand-25FMBCT3.js} +13 -4
  4. package/dist/{algorand-I2O24RSM.cjs → algorand-Q3TUQLPK.cjs} +49 -40
  5. package/dist/{aptos-J7QGCWNW.js → aptos-SBV6SGDP.js} +3 -3
  6. package/dist/{aptos-GA5AEYYL.cjs → aptos-VBJONBFY.cjs} +36 -36
  7. package/dist/chunk-2CX7XRZK.js +649 -0
  8. package/dist/chunk-C52H5TYB.js +474 -0
  9. package/dist/chunk-OXEFPLZA.cjs +474 -0
  10. package/dist/{chunk-3FR22M3O.cjs → chunk-QONQSZHJ.cjs} +2 -2
  11. package/dist/{chunk-3ZWM3DKM.js → chunk-QU25LSVS.js} +2 -2
  12. package/dist/chunk-V2IJ5HUW.cjs +649 -0
  13. package/dist/index.cjs +507 -1347
  14. package/dist/index.d.cts +39 -6
  15. package/dist/index.d.ts +39 -6
  16. package/dist/index.js +192 -1032
  17. package/dist/{ledger-uFtXlIHY.d.cts → ledger-Crc1bZox.d.cts} +164 -10
  18. package/dist/{ledger-uFtXlIHY.d.ts → ledger-Crc1bZox.d.ts} +164 -10
  19. package/dist/{near-NDQLGI4U.cjs → near-5LTTDU6G.cjs} +27 -27
  20. package/dist/{near-YA4Y4IGC.js → near-OLKCMTBI.js} +1 -1
  21. package/dist/node.d.cts +2 -2
  22. package/dist/node.d.ts +2 -2
  23. package/dist/{solana-OU6IUMQM.cjs → solana-AI2G7V33.cjs} +73 -52
  24. package/dist/{solana-MB6G3OA5.js → solana-HTKDRTD3.js} +32 -11
  25. package/dist/{stellar-RSNVOIKL.cjs → stellar-E2KWEV2E.cjs} +20 -20
  26. package/dist/{stellar-WDWSYOED.js → stellar-EUFZLX6J.js} +1 -1
  27. package/dist/{sui-GVSFNNJX.js → sui-KCIITCYH.js} +6 -2
  28. package/dist/{sui-MVC46BFJ.cjs → sui-Q3NJOJZS.cjs} +21 -17
  29. package/dist/{ton-MYOI3U3H.cjs → ton-J7TQWRN4.cjs} +16 -16
  30. package/dist/{ton-EJMGM3YI.js → ton-WH2JVQOO.js} +1 -1
  31. package/dist/{tron-VAPVMGJK.js → tron-FXBXDNEY.js} +1 -1
  32. package/dist/{tron-42X5N4GQ.cjs → tron-HIPMOX7S.cjs} +25 -25
  33. package/dist/{xrpl-Q2UWPCTJ.js → xrpl-RUOB37QH.js} +283 -5
  34. package/dist/{xrpl-MGUBUNSZ.cjs → xrpl-SVVS445B.cjs} +312 -34
  35. package/package.json +1 -1
@@ -10,7 +10,7 @@
10
10
 
11
11
 
12
12
 
13
- var _chunk3FR22M3Ocjs = require('./chunk-3FR22M3O.cjs');
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, _chunk3FR22M3Ocjs.RecipientNotReadyError)(
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, _chunk3FR22M3Ocjs.InsufficientFundsError)(
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(_chunk3FR22M3Ocjs.toInsufficientFundsError.call(void 0, err), () => ( err));
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, _chunk3FR22M3Ocjs.InsufficientFundsError)(
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(_chunk3FR22M3Ocjs.toInsufficientFundsError.call(void 0, err), () => ( err));
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, _chunk3FR22M3Ocjs.UnsupportedSchemeError)(
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, _chunk3FR22M3Ocjs.UnsupportedSchemeError)(`NEAR exact: asset "${accept.asset}" must be a NEP-141 contract account id.`);
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, _chunk3FR22M3Ocjs.UnsupportedSchemeError)(`NEAR exact: payTo "${accept.payTo}" is not a valid NEAR account id.`);
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, _chunk3FR22M3Ocjs.UnsupportedSchemeError)(`NEAR exact: sender "${senderId}" is not a valid NEAR account id.`);
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, _chunk3FR22M3Ocjs.UnsupportedSchemeError)("NEAR exact: maxTimeoutSeconds must be a positive integer.");
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, _chunk3FR22M3Ocjs.UnsupportedSchemeError)(
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, _chunk3FR22M3Ocjs.SettlementError)(
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, _chunk3FR22M3Ocjs.WrongFamilyError)(
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
- _chunk3FR22M3Ocjs.assertNoLegacyWalletKey.call(void 0, wallet, "NEAR");
415
+ _chunkQONQSZHJcjs.assertNoLegacyWalletKey.call(void 0, wallet, "NEAR");
416
416
  if (!("accountId" in wallet) || !("key" in wallet)) {
417
- throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
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, _chunk3FR22M3Ocjs.WrongFamilyError)("NEAR wallet needs { accountId, key } (key = ed25519:\u2026).");
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, _chunk3FR22M3Ocjs.WrongFamilyError)("NEAR wallet { key } is not a valid ed25519:\u2026 secret key.", {
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, _chunk3FR22M3Ocjs.UnknownTokenError)(
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
- _chunk3FR22M3Ocjs.rejectForeignToken.call(void 0, token, "near", network);
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, _chunk3FR22M3Ocjs.WrongFamilyError)(
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, _chunk3FR22M3Ocjs.WrongFamilyError)(
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, _chunk3FR22M3Ocjs.WrongFamilyError)(
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, _chunk3FR22M3Ocjs.ConfirmationTimeoutError)(`NEAR tx ${hash} not confirmed in time.`);
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 _chunk3FR22M3Ocjs.nativeCost.call(void 0, {
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 _chunk3FR22M3Ocjs.nativeCost.call(void 0, {
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, _chunk3FR22M3Ocjs.SettlementError)(
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
  );
@@ -10,7 +10,7 @@ import {
10
10
  nativeCost,
11
11
  rejectForeignToken,
12
12
  toInsufficientFundsError
13
- } from "./chunk-3ZWM3DKM.js";
13
+ } from "./chunk-QU25LSVS.js";
14
14
 
15
15
  // src/drivers/near/index.ts
16
16
  import { JsonRpcProvider, Account, actions as actions2 } from "near-api-js";
package/dist/node.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { v as SpendStore } from './ledger-uFtXlIHY.cjs';
2
- export { T as memorySpendStore } from './ledger-uFtXlIHY.cjs';
1
+ import { v as SpendStore } from './ledger-Crc1bZox.cjs';
2
+ export { _ as memorySpendStore } from './ledger-Crc1bZox.cjs';
3
3
 
4
4
  /**
5
5
  * A durable {@link SpendStore} backed by a local JSONL file (one settled payment per
package/dist/node.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { v as SpendStore } from './ledger-uFtXlIHY.js';
2
- export { T as memorySpendStore } from './ledger-uFtXlIHY.js';
1
+ import { v as SpendStore } from './ledger-Crc1bZox.js';
2
+ export { _ as memorySpendStore } from './ledger-Crc1bZox.js';
3
3
 
4
4
  /**
5
5
  * A durable {@link SpendStore} backed by a local JSONL file (one settled payment per
@@ -8,7 +8,7 @@
8
8
 
9
9
 
10
10
 
11
- var _chunk3FR22M3Ocjs = require('./chunk-3FR22M3O.cjs');
11
+ var _chunkQONQSZHJcjs = require('./chunk-QONQSZHJ.cjs');
12
12
 
13
13
  // src/drivers/solana/index.ts
14
14
  var _web3js = require('@solana/web3.js');
@@ -229,15 +229,25 @@ var MAX_COMPUTE_UNIT_PRICE_MICROLAMPORTS = 100000n;
229
229
  var CB_SET_UNIT_LIMIT = 2;
230
230
  var CB_SET_UNIT_PRICE = 3;
231
231
  function tokenProgramFor(accept) {
232
- return accept.extra.tokenProgram === "token-2022" ? _spltoken.TOKEN_2022_PROGRAM_ID : _spltoken.TOKEN_PROGRAM_ID;
232
+ return _optionalChain([accept, 'access', _3 => _3.extra, 'optionalAccess', _4 => _4.tokenProgram]) === "token-2022" ? _spltoken.TOKEN_2022_PROGRAM_ID : _spltoken.TOKEN_PROGRAM_ID;
233
+ }
234
+ async function readMintDecimals(connection, mint) {
235
+ try {
236
+ const info = await connection.getAccountInfo(mint);
237
+ const data = _optionalChain([info, 'optionalAccess', _5 => _5.data]);
238
+ if (!data || data.length < 45) return void 0;
239
+ return data[44];
240
+ } catch (e3) {
241
+ return void 0;
242
+ }
233
243
  }
234
244
  function isEmptySig(sig) {
235
245
  return !sig || sig.every((b) => b === 0);
236
246
  }
237
247
  function memoRandomNonce() {
238
248
  const g = globalThis.crypto;
239
- if (!_optionalChain([g, 'optionalAccess', _3 => _3.getRandomValues])) {
240
- throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)(
249
+ if (!_optionalChain([g, 'optionalAccess', _6 => _6.getRandomValues])) {
250
+ throw new (0, _chunkQONQSZHJcjs.UnsupportedSchemeError)(
241
251
  "this runtime lacks Web Crypto (globalThis.crypto.getRandomValues); SVM exact needs a CSPRNG nonce."
242
252
  );
243
253
  }
@@ -246,10 +256,10 @@ function memoRandomNonce() {
246
256
  return Buffer.from([...raw].map((b) => b.toString(16).padStart(2, "0")).join(""), "utf8");
247
257
  }
248
258
  function memoDataFor(accept) {
249
- if (accept.extra.memo !== void 0) {
259
+ if (_optionalChain([accept, 'access', _7 => _7.extra, 'optionalAccess', _8 => _8.memo]) !== void 0) {
250
260
  const bytes = Buffer.from(accept.extra.memo, "utf8");
251
261
  if (bytes.length > MAX_MEMO_BYTES) {
252
- throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)(
262
+ throw new (0, _chunkQONQSZHJcjs.UnsupportedSchemeError)(
253
263
  `SVM exact: extra.memo is ${bytes.length} bytes; the scheme caps it at ${MAX_MEMO_BYTES}.`
254
264
  );
255
265
  }
@@ -263,30 +273,40 @@ function memoInstruction(accept) {
263
273
  async function payExactSolana(input) {
264
274
  const { connection, keypair, accept } = input;
265
275
  if (accept.asset === "native") {
266
- throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)(
276
+ throw new (0, _chunkQONQSZHJcjs.UnsupportedSchemeError)(
267
277
  "SVM exact is SPL-token only (TransferChecked); native SOL is not exact-payable. Pay via onchain-proof."
268
278
  );
269
279
  }
270
- if (!accept.extra.feePayer) {
271
- throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)("SVM exact rail must advertise extra.feePayer (the merchant sponsor key).");
272
- }
273
- if (accept.extra.decimals === void 0) {
274
- throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)("SVM exact rail must advertise extra.decimals for the TransferChecked.");
280
+ const extra = _nullishCoalesce(accept.extra, () => ( {}));
281
+ if (!extra.feePayer) {
282
+ throw new (0, _chunkQONQSZHJcjs.UnsupportedSchemeError)("SVM exact rail must advertise extra.feePayer (the merchant sponsor key).");
275
283
  }
276
284
  let feePayer;
277
285
  let mint;
278
286
  let payTo;
279
287
  try {
280
- feePayer = new (0, _web3js.PublicKey)(accept.extra.feePayer);
288
+ feePayer = new (0, _web3js.PublicKey)(extra.feePayer);
281
289
  mint = new (0, _web3js.PublicKey)(accept.asset);
282
290
  payTo = new (0, _web3js.PublicKey)(accept.payTo);
283
291
  } catch (err) {
284
- throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)(
292
+ throw new (0, _chunkQONQSZHJcjs.UnsupportedSchemeError)(
285
293
  `SVM exact: bad feePayer/asset/payTo (${err instanceof Error ? err.message : String(err)}).`
286
294
  );
287
295
  }
296
+ const onChainDecimals = await readMintDecimals(connection, mint);
297
+ const decimals = _nullishCoalesce(onChainDecimals, () => ( extra.decimals));
298
+ if (decimals === void 0) {
299
+ throw new (0, _chunkQONQSZHJcjs.UnsupportedSchemeError)(
300
+ `SVM exact: couldn't read the decimals of mint ${accept.asset} on-chain, and the rail states none. Retry with a reliable rpcUrl \u2014 TransferChecked cannot be built without them.`
301
+ );
302
+ }
303
+ if (onChainDecimals !== void 0 && extra.decimals !== void 0 && extra.decimals !== onChainDecimals) {
304
+ throw new (0, _chunkQONQSZHJcjs.UnsupportedSchemeError)(
305
+ `SVM exact: the rail states ${extra.decimals} decimals for ${accept.asset} but the mint says ${onChainDecimals} \u2014 refusing to sign (a mismatch this size misprices the transfer).`
306
+ );
307
+ }
288
308
  if (feePayer.equals(payTo)) {
289
- throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)(
309
+ throw new (0, _chunkQONQSZHJcjs.UnsupportedSchemeError)(
290
310
  "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
311
  );
292
312
  }
@@ -296,11 +316,11 @@ async function payExactSolana(input) {
296
316
  let destInfo = "unknown";
297
317
  try {
298
318
  destInfo = await input.connection.getAccountInfo(dest);
299
- } catch (e3) {
319
+ } catch (e4) {
300
320
  destInfo = "unknown";
301
321
  }
302
322
  if (destInfo === null) {
303
- throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)(
323
+ throw new (0, _chunkQONQSZHJcjs.UnsupportedSchemeError)(
304
324
  `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
325
  );
306
326
  }
@@ -314,7 +334,8 @@ async function payExactSolana(input) {
314
334
  dest,
315
335
  keypair.publicKey,
316
336
  BigInt(accept.amount),
317
- accept.extra.decimals,
337
+ decimals,
338
+ // read from the MINT (see above), not from the server's `extra`
318
339
  [],
319
340
  program
320
341
  ),
@@ -331,11 +352,11 @@ async function payExactSolana(input) {
331
352
  tx.sign([keypair]);
332
353
  const buyerIndex = message.staticAccountKeys.findIndex((k) => k.equals(keypair.publicKey));
333
354
  if (buyerIndex < 1 || buyerIndex >= message.header.numRequiredSignatures) {
334
- throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)("SVM exact: could not locate the buyer signer slot.");
355
+ throw new (0, _chunkQONQSZHJcjs.UnsupportedSchemeError)("SVM exact: could not locate the buyer signer slot.");
335
356
  }
336
357
  const buyerSig = tx.signatures[buyerIndex];
337
358
  if (!buyerSig || isEmptySig(buyerSig)) {
338
- throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)("SVM exact: the wallet did not produce a buyer signature.");
359
+ throw new (0, _chunkQONQSZHJcjs.UnsupportedSchemeError)("SVM exact: the wallet did not produce a buyer signature.");
339
360
  }
340
361
  const transaction = Buffer.from(tx.serialize()).toString("base64");
341
362
  return {
@@ -359,18 +380,18 @@ async function verifyAndSettleExactSolana(input) {
359
380
  try {
360
381
  payTo = new (0, _web3js.PublicKey)(accept.payTo);
361
382
  mint = new (0, _web3js.PublicKey)(accept.asset);
362
- if (!accept.extra.feePayer) throw new Error("rail is missing extra.feePayer");
383
+ if (!_optionalChain([accept, 'access', _9 => _9.extra, 'optionalAccess', _10 => _10.feePayer])) throw new Error("rail is missing extra.feePayer");
363
384
  railFeePayer = new (0, _web3js.PublicKey)(accept.extra.feePayer);
364
385
  } catch (err) {
365
- throw new (0, _chunk3FR22M3Ocjs.SettlementError)(`SVM exact: rail has a bad payTo/asset/feePayer (${err instanceof Error ? err.message : String(err)}).`);
386
+ throw new (0, _chunkQONQSZHJcjs.SettlementError)(`SVM exact: rail has a bad payTo/asset/feePayer (${err instanceof Error ? err.message : String(err)}).`);
366
387
  }
367
388
  if (!railFeePayer.equals(feePayerKeypair.publicKey)) {
368
- throw new (0, _chunk3FR22M3Ocjs.SettlementError)(
389
+ throw new (0, _chunkQONQSZHJcjs.SettlementError)(
369
390
  "SVM exact: the gate relayer key does not match the rail extra.feePayer \u2014 misconfigured rail."
370
391
  );
371
392
  }
372
393
  if (feePayerKeypair.publicKey.equals(payTo)) {
373
- throw new (0, _chunk3FR22M3Ocjs.SettlementError)("SVM exact: the fee payer must differ from payTo \u2014 misconfigured rail.");
394
+ throw new (0, _chunkQONQSZHJcjs.SettlementError)("SVM exact: the fee payer must differ from payTo \u2014 misconfigured rail.");
374
395
  }
375
396
  const program = tokenProgramFor(accept);
376
397
  let tx;
@@ -389,7 +410,7 @@ async function verifyAndSettleExactSolana(input) {
389
410
  try {
390
411
  ;
391
412
  ({ value } = await connection.getAddressLookupTable(lookup.accountKey));
392
- } catch (e4) {
413
+ } catch (e5) {
393
414
  return fail("tx_not_found", `Could not read lookup table ${lookup.accountKey.toBase58()} (transient RPC) \u2014 retry.`);
394
415
  }
395
416
  if (!value) {
@@ -411,7 +432,7 @@ async function verifyAndSettleExactSolana(input) {
411
432
  return fail("signature_invalid", "The fee payer is invoked as a program.");
412
433
  }
413
434
  for (const i of ix.accountKeyIndexes) {
414
- if (_optionalChain([keys, 'access', _4 => _4.get, 'call', _5 => _5(i), 'optionalAccess', _6 => _6.equals, 'call', _7 => _7(feePayerKey)])) {
435
+ if (_optionalChain([keys, 'access', _11 => _11.get, 'call', _12 => _12(i), 'optionalAccess', _13 => _13.equals, 'call', _14 => _14(feePayerKey)])) {
415
436
  return fail("signature_invalid", "The fee payer appears in an instruction account list (would risk a fund drain).");
416
437
  }
417
438
  }
@@ -460,14 +481,14 @@ async function verifyAndSettleExactSolana(input) {
460
481
  }),
461
482
  program
462
483
  );
463
- } catch (e5) {
484
+ } catch (e6) {
464
485
  continue;
465
486
  }
466
487
  if (!decoded.keys.mint.pubkey.equals(mint)) continue;
467
488
  if (!decoded.keys.destination.pubkey.equals(expectedDest)) {
468
489
  return fail("wrong_recipient", `A transfer pays ${decoded.keys.destination.pubkey.toBase58()}, not payTo's ATA ${expectedDest.toBase58()}.`);
469
490
  }
470
- if (decoded.data.decimals !== accept.extra.decimals) {
491
+ if (_optionalChain([accept, 'access', _15 => _15.extra, 'optionalAccess', _16 => _16.decimals]) !== void 0 && decoded.data.decimals !== accept.extra.decimals) {
471
492
  return fail("transfer_not_found", `Transfer decimals ${decoded.data.decimals} \u2260 rail decimals ${accept.extra.decimals}.`);
472
493
  }
473
494
  sawTransferToPayTo = true;
@@ -512,7 +533,7 @@ async function verifyAndSettleExactSolana(input) {
512
533
  } catch (err) {
513
534
  const msg = err instanceof Error ? err.message : String(err);
514
535
  if (/blockhash|block height|expired/i.test(msg)) return fail("payment_expired", `Settle broadcast rejected \u2014 blockhash expired: ${shorten(msg)}.`);
515
- throw new (0, _chunk3FR22M3Ocjs.SettlementError)(
536
+ throw new (0, _chunkQONQSZHJcjs.SettlementError)(
516
537
  `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
538
  { cause: err }
518
539
  );
@@ -522,7 +543,7 @@ async function verifyAndSettleExactSolana(input) {
522
543
  return fail("tx_reverted", `Settle tx ${txid} reverted on-chain (a post-simulate race).`);
523
544
  }
524
545
  if (confirmed === "timeout") {
525
- throw new (0, _chunk3FR22M3Ocjs.SettlementError)(
546
+ throw new (0, _chunkQONQSZHJcjs.SettlementError)(
526
547
  `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
548
  );
528
549
  }
@@ -548,7 +569,7 @@ async function pollConfirmed(connection, signature) {
548
569
  try {
549
570
  const { value } = await connection.getSignatureStatuses([signature], { searchTransactionHistory: true });
550
571
  info = value[0];
551
- } catch (e6) {
572
+ } catch (e7) {
552
573
  info = null;
553
574
  }
554
575
  if (info) {
@@ -565,18 +586,18 @@ async function pollConfirmed(connection, signature) {
565
586
 
566
587
  function toKeypair(wallet, network) {
567
588
  if (typeof wallet !== "object" || wallet === null) {
568
- throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
589
+ throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)(
569
590
  `chain ${network} is Solana; wallet must be { key } (base58 secret) or { signer }.`
570
591
  );
571
592
  }
572
- _chunk3FR22M3Ocjs.assertNoLegacyWalletKey.call(void 0, wallet, "Solana");
593
+ _chunkQONQSZHJcjs.assertNoLegacyWalletKey.call(void 0, wallet, "Solana");
573
594
  if ("signer" in wallet) {
574
595
  return wallet.signer;
575
596
  }
576
597
  if ("key" in wallet) {
577
598
  const sk = wallet.key;
578
599
  if (typeof sk === "string" && sk.startsWith("0x")) {
579
- throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
600
+ throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)(
580
601
  `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
602
  );
582
603
  }
@@ -584,12 +605,12 @@ function toKeypair(wallet, network) {
584
605
  const bytes = typeof sk === "string" ? _bs582.default.decode(sk) : sk;
585
606
  return _web3js.Keypair.fromSecretKey(bytes);
586
607
  } catch (err) {
587
- throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
608
+ throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)(
588
609
  `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
610
  );
590
611
  }
591
612
  }
592
- throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
613
+ throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)(
593
614
  `chain ${network} is Solana; wallet must be { key } (base58 secret) or { signer }.`
594
615
  );
595
616
  }
@@ -618,15 +639,15 @@ function makeSolanaNetwork(preset, rpcUrl) {
618
639
  const info = preset.tokens[token.toUpperCase()];
619
640
  if (!info) {
620
641
  const known = Object.keys(preset.tokens).join(", ") || "(none built in)";
621
- throw new (0, _chunk3FR22M3Ocjs.UnknownTokenError)(
642
+ throw new (0, _chunkQONQSZHJcjs.UnknownTokenError)(
622
643
  `token "${token}" isn't built in for Solana (known: ${known}). Pass { mint, decimals } instead, or use 'native'.`
623
644
  );
624
645
  }
625
646
  return { asset: info.mint, decimals: info.decimals, symbol: info.symbol };
626
647
  }
627
- _chunk3FR22M3Ocjs.rejectForeignToken.call(void 0, token, "solana", network);
648
+ _chunkQONQSZHJcjs.rejectForeignToken.call(void 0, token, "solana", network);
628
649
  if (!("mint" in token)) {
629
- throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
650
+ throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)(
630
651
  `chain ${network} is Solana; a custom token must be { mint, decimals }.`
631
652
  );
632
653
  }
@@ -645,14 +666,14 @@ function makeSolanaNetwork(preset, rpcUrl) {
645
666
  },
646
667
  assertValidPayTo(payTo) {
647
668
  if (payTo.startsWith("0x")) {
648
- throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
669
+ throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)(
649
670
  `chain ${network} is Solana, but payTo "${payTo}" looks like an EVM address.`
650
671
  );
651
672
  }
652
673
  try {
653
674
  new (0, _web3js.PublicKey)(payTo);
654
- } catch (e7) {
655
- throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
675
+ } catch (e8) {
676
+ throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)(
656
677
  `chain ${network} is Solana, but payTo "${payTo}" is not a base58 address.`
657
678
  );
658
679
  }
@@ -664,7 +685,7 @@ function makeSolanaNetwork(preset, rpcUrl) {
664
685
  try {
665
686
  return await paySolana({ connection, keypair: wallet._native, accept });
666
687
  } catch (err) {
667
- throw _nullishCoalesce(_chunk3FR22M3Ocjs.toInsufficientFundsError.call(void 0, err), () => ( err));
688
+ throw _nullishCoalesce(_chunkQONQSZHJcjs.toInsufficientFundsError.call(void 0, err), () => ( err));
668
689
  }
669
690
  },
670
691
  async confirm(ref) {
@@ -675,19 +696,19 @@ function makeSolanaNetwork(preset, rpcUrl) {
675
696
  });
676
697
  info = value[0];
677
698
  } catch (err) {
678
- throw new (0, _chunk3FR22M3Ocjs.ConfirmationTimeoutError)(
699
+ throw new (0, _chunkQONQSZHJcjs.ConfirmationTimeoutError)(
679
700
  `Solana payment ${ref} could not be confirmed (RPC read failed).`,
680
701
  { cause: err }
681
702
  );
682
703
  }
683
704
  if (!info || info.err || info.confirmationStatus !== "confirmed" && info.confirmationStatus !== "finalized") {
684
- throw new (0, _chunk3FR22M3Ocjs.ConfirmationTimeoutError)(`Solana payment ${ref} did not confirm in time.`);
705
+ throw new (0, _chunkQONQSZHJcjs.ConfirmationTimeoutError)(`Solana payment ${ref} did not confirm in time.`);
685
706
  }
686
707
  return { height: String(info.slot) };
687
708
  },
688
709
  async estimateCost(accept) {
689
710
  if (accept.scheme === "exact") {
690
- return _chunk3FR22M3Ocjs.nativeCost.call(void 0, {
711
+ return _chunkQONQSZHJcjs.nativeCost.call(void 0, {
691
712
  symbol: "SOL",
692
713
  decimals: SOL_DECIMALS,
693
714
  fee: 0n,
@@ -697,7 +718,7 @@ function makeSolanaNetwork(preset, rpcUrl) {
697
718
  }
698
719
  const base = 5000n;
699
720
  if (accept.asset === "native") {
700
- return _chunk3FR22M3Ocjs.nativeCost.call(void 0, {
721
+ return _chunkQONQSZHJcjs.nativeCost.call(void 0, {
701
722
  symbol: "SOL",
702
723
  decimals: SOL_DECIMALS,
703
724
  fee: base,
@@ -706,7 +727,7 @@ function makeSolanaNetwork(preset, rpcUrl) {
706
727
  });
707
728
  }
708
729
  const ataRent = 2039280n;
709
- return _chunk3FR22M3Ocjs.nativeCost.call(void 0, {
730
+ return _chunkQONQSZHJcjs.nativeCost.call(void 0, {
710
731
  symbol: "SOL",
711
732
  decimals: SOL_DECIMALS,
712
733
  fee: base + ataRent,
@@ -722,7 +743,7 @@ function makeSolanaNetwork(preset, rpcUrl) {
722
743
  try {
723
744
  const mint = new (0, _web3js.PublicKey)(asset);
724
745
  const info = await connection.getAccountInfo(mint);
725
- const programId = _optionalChain([info, 'optionalAccess', _8 => _8.owner, 'access', _9 => _9.equals, 'call', _10 => _10(_spltoken.TOKEN_2022_PROGRAM_ID)]) ? _spltoken.TOKEN_2022_PROGRAM_ID : _spltoken.TOKEN_PROGRAM_ID;
746
+ const programId = _optionalChain([info, 'optionalAccess', _17 => _17.owner, 'access', _18 => _18.equals, 'call', _19 => _19(_spltoken.TOKEN_2022_PROGRAM_ID)]) ? _spltoken.TOKEN_2022_PROGRAM_ID : _spltoken.TOKEN_PROGRAM_ID;
726
747
  const ata = _spltoken.getAssociatedTokenAddressSync.call(void 0, mint, owner, false, programId);
727
748
  token = (await _spltoken.getAccount.call(void 0, connection, ata, "confirmed", programId)).amount;
728
749
  } catch (e) {
@@ -780,14 +801,14 @@ function makeSolanaNetwork(preset, rpcUrl) {
780
801
  if (!fp) return null;
781
802
  try {
782
803
  new (0, _web3js.PublicKey)(fp);
783
- } catch (e8) {
804
+ } catch (e9) {
784
805
  return null;
785
806
  }
786
807
  let tokenProgram = "spl-token";
787
808
  try {
788
809
  const info = await connection.getAccountInfo(new (0, _web3js.PublicKey)(asset));
789
- if (_optionalChain([info, 'optionalAccess', _11 => _11.owner, 'access', _12 => _12.equals, 'call', _13 => _13(_spltoken.TOKEN_2022_PROGRAM_ID)])) tokenProgram = "token-2022";
790
- } catch (e9) {
810
+ if (_optionalChain([info, 'optionalAccess', _20 => _20.owner, 'access', _21 => _21.equals, 'call', _22 => _22(_spltoken.TOKEN_2022_PROGRAM_ID)])) tokenProgram = "token-2022";
811
+ } catch (e10) {
791
812
  }
792
813
  return { method: "svm", extra: { feePayer: fp, tokenProgram } };
793
814
  }