@piprail/sdk 2.14.0 → 2.14.2

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.
@@ -8,7 +8,7 @@
8
8
 
9
9
 
10
10
 
11
- var _chunkGYM46G5Lcjs = require('./chunk-GYM46G5L.cjs');
11
+ var _chunk3FR22M3Ocjs = require('./chunk-3FR22M3O.cjs');
12
12
 
13
13
  // src/drivers/solana/index.ts
14
14
  var _web3js = require('@solana/web3.js');
@@ -237,7 +237,7 @@ function isEmptySig(sig) {
237
237
  function memoRandomNonce() {
238
238
  const g = globalThis.crypto;
239
239
  if (!_optionalChain([g, 'optionalAccess', _3 => _3.getRandomValues])) {
240
- throw new (0, _chunkGYM46G5Lcjs.UnsupportedSchemeError)(
240
+ throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)(
241
241
  "this runtime lacks Web Crypto (globalThis.crypto.getRandomValues); SVM exact needs a CSPRNG nonce."
242
242
  );
243
243
  }
@@ -249,7 +249,7 @@ function memoDataFor(accept) {
249
249
  if (accept.extra.memo !== void 0) {
250
250
  const bytes = Buffer.from(accept.extra.memo, "utf8");
251
251
  if (bytes.length > MAX_MEMO_BYTES) {
252
- throw new (0, _chunkGYM46G5Lcjs.UnsupportedSchemeError)(
252
+ throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)(
253
253
  `SVM exact: extra.memo is ${bytes.length} bytes; the scheme caps it at ${MAX_MEMO_BYTES}.`
254
254
  );
255
255
  }
@@ -263,15 +263,15 @@ function memoInstruction(accept) {
263
263
  async function payExactSolana(input) {
264
264
  const { connection, keypair, accept } = input;
265
265
  if (accept.asset === "native") {
266
- throw new (0, _chunkGYM46G5Lcjs.UnsupportedSchemeError)(
266
+ throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)(
267
267
  "SVM exact is SPL-token only (TransferChecked); native SOL is not exact-payable. Pay via onchain-proof."
268
268
  );
269
269
  }
270
270
  if (!accept.extra.feePayer) {
271
- throw new (0, _chunkGYM46G5Lcjs.UnsupportedSchemeError)("SVM exact rail must advertise extra.feePayer (the merchant sponsor key).");
271
+ throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)("SVM exact rail must advertise extra.feePayer (the merchant sponsor key).");
272
272
  }
273
273
  if (accept.extra.decimals === void 0) {
274
- throw new (0, _chunkGYM46G5Lcjs.UnsupportedSchemeError)("SVM exact rail must advertise extra.decimals for the TransferChecked.");
274
+ throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)("SVM exact rail must advertise extra.decimals for the TransferChecked.");
275
275
  }
276
276
  let feePayer;
277
277
  let mint;
@@ -281,12 +281,12 @@ async function payExactSolana(input) {
281
281
  mint = new (0, _web3js.PublicKey)(accept.asset);
282
282
  payTo = new (0, _web3js.PublicKey)(accept.payTo);
283
283
  } catch (err) {
284
- throw new (0, _chunkGYM46G5Lcjs.UnsupportedSchemeError)(
284
+ throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)(
285
285
  `SVM exact: bad feePayer/asset/payTo (${err instanceof Error ? err.message : String(err)}).`
286
286
  );
287
287
  }
288
288
  if (feePayer.equals(payTo)) {
289
- throw new (0, _chunkGYM46G5Lcjs.UnsupportedSchemeError)(
289
+ throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)(
290
290
  "SVM exact: the fee payer must differ from payTo \u2014 payTo appears in the transfer instruction, which the fee payer must not (a scheme MUST-rule). Use a separate relayer key for the gate."
291
291
  );
292
292
  }
@@ -300,7 +300,7 @@ async function payExactSolana(input) {
300
300
  destInfo = "unknown";
301
301
  }
302
302
  if (destInfo === null) {
303
- throw new (0, _chunkGYM46G5Lcjs.UnsupportedSchemeError)(
303
+ throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)(
304
304
  `SVM exact: the recipient's token account for ${mint.toBase58()} doesn't exist yet \u2014 the exact rail can't create it. Pay via onchain-proof (which creates it), or have ${payTo.toBase58()} create its associated token account first.`
305
305
  );
306
306
  }
@@ -331,11 +331,11 @@ async function payExactSolana(input) {
331
331
  tx.sign([keypair]);
332
332
  const buyerIndex = message.staticAccountKeys.findIndex((k) => k.equals(keypair.publicKey));
333
333
  if (buyerIndex < 1 || buyerIndex >= message.header.numRequiredSignatures) {
334
- throw new (0, _chunkGYM46G5Lcjs.UnsupportedSchemeError)("SVM exact: could not locate the buyer signer slot.");
334
+ throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)("SVM exact: could not locate the buyer signer slot.");
335
335
  }
336
336
  const buyerSig = tx.signatures[buyerIndex];
337
337
  if (!buyerSig || isEmptySig(buyerSig)) {
338
- throw new (0, _chunkGYM46G5Lcjs.UnsupportedSchemeError)("SVM exact: the wallet did not produce a buyer signature.");
338
+ throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)("SVM exact: the wallet did not produce a buyer signature.");
339
339
  }
340
340
  const transaction = Buffer.from(tx.serialize()).toString("base64");
341
341
  return {
@@ -362,15 +362,15 @@ async function verifyAndSettleExactSolana(input) {
362
362
  if (!accept.extra.feePayer) throw new Error("rail is missing extra.feePayer");
363
363
  railFeePayer = new (0, _web3js.PublicKey)(accept.extra.feePayer);
364
364
  } catch (err) {
365
- throw new (0, _chunkGYM46G5Lcjs.SettlementError)(`SVM exact: rail has a bad payTo/asset/feePayer (${err instanceof Error ? err.message : String(err)}).`);
365
+ throw new (0, _chunk3FR22M3Ocjs.SettlementError)(`SVM exact: rail has a bad payTo/asset/feePayer (${err instanceof Error ? err.message : String(err)}).`);
366
366
  }
367
367
  if (!railFeePayer.equals(feePayerKeypair.publicKey)) {
368
- throw new (0, _chunkGYM46G5Lcjs.SettlementError)(
368
+ throw new (0, _chunk3FR22M3Ocjs.SettlementError)(
369
369
  "SVM exact: the gate relayer key does not match the rail extra.feePayer \u2014 misconfigured rail."
370
370
  );
371
371
  }
372
372
  if (feePayerKeypair.publicKey.equals(payTo)) {
373
- throw new (0, _chunkGYM46G5Lcjs.SettlementError)("SVM exact: the fee payer must differ from payTo \u2014 misconfigured rail.");
373
+ throw new (0, _chunk3FR22M3Ocjs.SettlementError)("SVM exact: the fee payer must differ from payTo \u2014 misconfigured rail.");
374
374
  }
375
375
  const program = tokenProgramFor(accept);
376
376
  let tx;
@@ -512,7 +512,7 @@ async function verifyAndSettleExactSolana(input) {
512
512
  } catch (err) {
513
513
  const msg = err instanceof Error ? err.message : String(err);
514
514
  if (/blockhash|block height|expired/i.test(msg)) return fail("payment_expired", `Settle broadcast rejected \u2014 blockhash expired: ${shorten(msg)}.`);
515
- throw new (0, _chunkGYM46G5Lcjs.SettlementError)(
515
+ throw new (0, _chunk3FR22M3Ocjs.SettlementError)(
516
516
  `SVM exact settle: the merchant fee payer failed to broadcast (${shorten(msg)}). The buyer's signed transaction is still valid \u2014 fund/fix the fee payer and the buyer can re-present it.`,
517
517
  { cause: err }
518
518
  );
@@ -522,7 +522,7 @@ async function verifyAndSettleExactSolana(input) {
522
522
  return fail("tx_reverted", `Settle tx ${txid} reverted on-chain (a post-simulate race).`);
523
523
  }
524
524
  if (confirmed === "timeout") {
525
- throw new (0, _chunkGYM46G5Lcjs.SettlementError)(
525
+ throw new (0, _chunk3FR22M3Ocjs.SettlementError)(
526
526
  `SVM exact settle: broadcast ${txid} but it did not confirm in time. It likely landed \u2014 re-verify by signature before re-presenting; do NOT re-pay.`
527
527
  );
528
528
  }
@@ -565,18 +565,18 @@ async function pollConfirmed(connection, signature) {
565
565
 
566
566
  function toKeypair(wallet, network) {
567
567
  if (typeof wallet !== "object" || wallet === null) {
568
- throw new (0, _chunkGYM46G5Lcjs.WrongFamilyError)(
568
+ throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
569
569
  `chain ${network} is Solana; wallet must be { key } (base58 secret) or { signer }.`
570
570
  );
571
571
  }
572
- _chunkGYM46G5Lcjs.assertNoLegacyWalletKey.call(void 0, wallet, "Solana");
572
+ _chunk3FR22M3Ocjs.assertNoLegacyWalletKey.call(void 0, wallet, "Solana");
573
573
  if ("signer" in wallet) {
574
574
  return wallet.signer;
575
575
  }
576
576
  if ("key" in wallet) {
577
577
  const sk = wallet.key;
578
578
  if (typeof sk === "string" && sk.startsWith("0x")) {
579
- throw new (0, _chunkGYM46G5Lcjs.WrongFamilyError)(
579
+ throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
580
580
  `chain ${network} is Solana, but the wallet { key } is a 0x\u2026 hex key \u2014 that's an EVM key. A Solana key is a base58 secret string (or a 64-byte Uint8Array).`
581
581
  );
582
582
  }
@@ -584,12 +584,12 @@ function toKeypair(wallet, network) {
584
584
  const bytes = typeof sk === "string" ? _bs582.default.decode(sk) : sk;
585
585
  return _web3js.Keypair.fromSecretKey(bytes);
586
586
  } catch (err) {
587
- throw new (0, _chunkGYM46G5Lcjs.WrongFamilyError)(
587
+ throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
588
588
  `chain ${network} is Solana; the wallet { key } isn't a valid Solana secret (expected a base58 secret string or a 64-byte Uint8Array): ${err instanceof Error ? err.message : String(err)}.`
589
589
  );
590
590
  }
591
591
  }
592
- throw new (0, _chunkGYM46G5Lcjs.WrongFamilyError)(
592
+ throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
593
593
  `chain ${network} is Solana; wallet must be { key } (base58 secret) or { signer }.`
594
594
  );
595
595
  }
@@ -618,15 +618,15 @@ function makeSolanaNetwork(preset, rpcUrl) {
618
618
  const info = preset.tokens[token.toUpperCase()];
619
619
  if (!info) {
620
620
  const known = Object.keys(preset.tokens).join(", ") || "(none built in)";
621
- throw new (0, _chunkGYM46G5Lcjs.UnknownTokenError)(
621
+ throw new (0, _chunk3FR22M3Ocjs.UnknownTokenError)(
622
622
  `token "${token}" isn't built in for Solana (known: ${known}). Pass { mint, decimals } instead, or use 'native'.`
623
623
  );
624
624
  }
625
625
  return { asset: info.mint, decimals: info.decimals, symbol: info.symbol };
626
626
  }
627
- _chunkGYM46G5Lcjs.rejectForeignToken.call(void 0, token, "solana", network);
627
+ _chunk3FR22M3Ocjs.rejectForeignToken.call(void 0, token, "solana", network);
628
628
  if (!("mint" in token)) {
629
- throw new (0, _chunkGYM46G5Lcjs.WrongFamilyError)(
629
+ throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
630
630
  `chain ${network} is Solana; a custom token must be { mint, decimals }.`
631
631
  );
632
632
  }
@@ -645,14 +645,14 @@ function makeSolanaNetwork(preset, rpcUrl) {
645
645
  },
646
646
  assertValidPayTo(payTo) {
647
647
  if (payTo.startsWith("0x")) {
648
- throw new (0, _chunkGYM46G5Lcjs.WrongFamilyError)(
648
+ throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
649
649
  `chain ${network} is Solana, but payTo "${payTo}" looks like an EVM address.`
650
650
  );
651
651
  }
652
652
  try {
653
653
  new (0, _web3js.PublicKey)(payTo);
654
654
  } catch (e7) {
655
- throw new (0, _chunkGYM46G5Lcjs.WrongFamilyError)(
655
+ throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
656
656
  `chain ${network} is Solana, but payTo "${payTo}" is not a base58 address.`
657
657
  );
658
658
  }
@@ -664,7 +664,7 @@ function makeSolanaNetwork(preset, rpcUrl) {
664
664
  try {
665
665
  return await paySolana({ connection, keypair: wallet._native, accept });
666
666
  } catch (err) {
667
- throw _nullishCoalesce(_chunkGYM46G5Lcjs.toInsufficientFundsError.call(void 0, err), () => ( err));
667
+ throw _nullishCoalesce(_chunk3FR22M3Ocjs.toInsufficientFundsError.call(void 0, err), () => ( err));
668
668
  }
669
669
  },
670
670
  async confirm(ref) {
@@ -675,19 +675,19 @@ function makeSolanaNetwork(preset, rpcUrl) {
675
675
  });
676
676
  info = value[0];
677
677
  } catch (err) {
678
- throw new (0, _chunkGYM46G5Lcjs.ConfirmationTimeoutError)(
678
+ throw new (0, _chunk3FR22M3Ocjs.ConfirmationTimeoutError)(
679
679
  `Solana payment ${ref} could not be confirmed (RPC read failed).`,
680
680
  { cause: err }
681
681
  );
682
682
  }
683
683
  if (!info || info.err || info.confirmationStatus !== "confirmed" && info.confirmationStatus !== "finalized") {
684
- throw new (0, _chunkGYM46G5Lcjs.ConfirmationTimeoutError)(`Solana payment ${ref} did not confirm in time.`);
684
+ throw new (0, _chunk3FR22M3Ocjs.ConfirmationTimeoutError)(`Solana payment ${ref} did not confirm in time.`);
685
685
  }
686
686
  return { height: String(info.slot) };
687
687
  },
688
688
  async estimateCost(accept) {
689
689
  if (accept.scheme === "exact") {
690
- return _chunkGYM46G5Lcjs.nativeCost.call(void 0, {
690
+ return _chunk3FR22M3Ocjs.nativeCost.call(void 0, {
691
691
  symbol: "SOL",
692
692
  decimals: SOL_DECIMALS,
693
693
  fee: 0n,
@@ -697,7 +697,7 @@ function makeSolanaNetwork(preset, rpcUrl) {
697
697
  }
698
698
  const base = 5000n;
699
699
  if (accept.asset === "native") {
700
- return _chunkGYM46G5Lcjs.nativeCost.call(void 0, {
700
+ return _chunk3FR22M3Ocjs.nativeCost.call(void 0, {
701
701
  symbol: "SOL",
702
702
  decimals: SOL_DECIMALS,
703
703
  fee: base,
@@ -706,7 +706,7 @@ function makeSolanaNetwork(preset, rpcUrl) {
706
706
  });
707
707
  }
708
708
  const ataRent = 2039280n;
709
- return _chunkGYM46G5Lcjs.nativeCost.call(void 0, {
709
+ return _chunk3FR22M3Ocjs.nativeCost.call(void 0, {
710
710
  symbol: "SOL",
711
711
  decimals: SOL_DECIMALS,
712
712
  fee: base + ataRent,
@@ -12,7 +12,7 @@ var _chunkCQREG5LEcjs = require('./chunk-CQREG5LE.cjs');
12
12
 
13
13
 
14
14
 
15
- var _chunkGYM46G5Lcjs = require('./chunk-GYM46G5L.cjs');
15
+ var _chunk3FR22M3Ocjs = require('./chunk-3FR22M3O.cjs');
16
16
 
17
17
  // src/drivers/stellar/index.ts
18
18
  var _stellarsdk = require('@stellar/stellar-sdk');
@@ -98,30 +98,30 @@ function mapSubmitError(err) {
98
98
  const seen = codes.join(", ");
99
99
  const has = (re) => codes.some((c) => re.test(c));
100
100
  if (has(/op_no_destination/i)) {
101
- return new (0, _chunkGYM46G5Lcjs.RecipientNotReadyError)(
101
+ return new (0, _chunk3FR22M3Ocjs.RecipientNotReadyError)(
102
102
  `Stellar destination account doesn't exist yet \u2014 create it with \u22651 XLM (the base reserve) before it can receive. (Stellar: ${seen})`,
103
103
  { cause: err }
104
104
  );
105
105
  }
106
106
  if (has(/op_(no_trust|line_full|not_authorized)/i) && !has(/src_no_trust/i)) {
107
- return new (0, _chunkGYM46G5Lcjs.RecipientNotReadyError)(
107
+ return new (0, _chunk3FR22M3Ocjs.RecipientNotReadyError)(
108
108
  `Stellar destination can't hold this asset \u2014 it needs a trustline for it (and to be authorized) before it can receive. (Stellar: ${seen})`,
109
109
  { cause: err }
110
110
  );
111
111
  }
112
112
  if (has(/underfunded|insufficient|low_reserve|src_no_trust/i)) {
113
- return new (0, _chunkGYM46G5Lcjs.InsufficientFundsError)(
113
+ return new (0, _chunk3FR22M3Ocjs.InsufficientFundsError)(
114
114
  `Stellar payment failed: the sender can't cover it \u2014 balance, base reserve, or no trustline to send this asset. (Stellar: ${seen})`,
115
115
  { cause: err }
116
116
  );
117
117
  }
118
118
  if (isAccountNotFound(err)) {
119
- return new (0, _chunkGYM46G5Lcjs.InsufficientFundsError)(
119
+ return new (0, _chunk3FR22M3Ocjs.InsufficientFundsError)(
120
120
  "Stellar source account not found on-chain \u2014 fund the sender (\u2265 base reserve) before it can pay.",
121
121
  { cause: err }
122
122
  );
123
123
  }
124
- return _nullishCoalesce(_chunkGYM46G5Lcjs.toInsufficientFundsError.call(void 0, err), () => ( err));
124
+ return _nullishCoalesce(_chunk3FR22M3Ocjs.toInsufficientFundsError.call(void 0, err), () => ( err));
125
125
  }
126
126
  function isAccountNotFound(err) {
127
127
  const e = err;
@@ -218,7 +218,7 @@ function assetMatches(p, want) {
218
218
  }
219
219
  function parseAmount(amount, decimals) {
220
220
  try {
221
- return _chunkGYM46G5Lcjs.parseUnits.call(void 0, amount, decimals);
221
+ return _chunk3FR22M3Ocjs.parseUnits.call(void 0, amount, decimals);
222
222
  } catch (e4) {
223
223
  return 0n;
224
224
  }
@@ -242,13 +242,13 @@ function rpcFailed(nonce) {
242
242
 
243
243
  function assertStellarWallet(wallet, network) {
244
244
  if (typeof wallet !== "object" || wallet === null) {
245
- throw new (0, _chunkGYM46G5Lcjs.WrongFamilyError)(
245
+ throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
246
246
  `chain ${network} is Stellar; wallet must be { key } (S\u2026 seed) or { keypair }.`
247
247
  );
248
248
  }
249
- _chunkGYM46G5Lcjs.assertNoLegacyWalletKey.call(void 0, wallet, "Stellar");
249
+ _chunk3FR22M3Ocjs.assertNoLegacyWalletKey.call(void 0, wallet, "Stellar");
250
250
  if (!("key" in wallet) && !("keypair" in wallet)) {
251
- throw new (0, _chunkGYM46G5Lcjs.WrongFamilyError)(
251
+ throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
252
252
  `chain ${network} is Stellar; wallet must be { key } (S\u2026 seed) or { keypair }.`
253
253
  );
254
254
  }
@@ -258,11 +258,11 @@ function resolveStellarWallet(config) {
258
258
  if (config.keypair) return config.keypair;
259
259
  if (config.key) {
260
260
  if (!_stellarsdk.StrKey.isValidEd25519SecretSeed(config.key)) {
261
- throw new (0, _chunkGYM46G5Lcjs.WrongFamilyError)("Stellar wallet { key } is not a valid S\u2026 secret seed.");
261
+ throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)("Stellar wallet { key } is not a valid S\u2026 secret seed.");
262
262
  }
263
263
  return _stellarsdk.Keypair.fromSecret(config.key);
264
264
  }
265
- throw new (0, _chunkGYM46G5Lcjs.WrongFamilyError)("Stellar wallet needs { key } (S\u2026 seed) or { keypair }.");
265
+ throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)("Stellar wallet needs { key } (S\u2026 seed) or { keypair }.");
266
266
  }
267
267
 
268
268
  // src/drivers/stellar/index.ts
@@ -317,7 +317,7 @@ function makeStellarNetwork(preset, rpcUrl) {
317
317
  const info = preset.tokens[token.toUpperCase()];
318
318
  if (!info) {
319
319
  const known = Object.keys(preset.tokens).join(", ") || "(none built in)";
320
- throw new (0, _chunkGYM46G5Lcjs.UnknownTokenError)(
320
+ throw new (0, _chunk3FR22M3Ocjs.UnknownTokenError)(
321
321
  `token "${token}" isn't built in for Stellar (known: ${known}). Pass { issuer, code, decimals } for a custom asset, or use 'native'.`
322
322
  );
323
323
  }
@@ -327,10 +327,10 @@ function makeStellarNetwork(preset, rpcUrl) {
327
327
  symbol: info.symbol
328
328
  };
329
329
  }
330
- _chunkGYM46G5Lcjs.rejectForeignToken.call(void 0, token, "stellar", network);
330
+ _chunk3FR22M3Ocjs.rejectForeignToken.call(void 0, token, "stellar", network);
331
331
  const t = token;
332
332
  if (!t.issuer || !t.code || typeof t.decimals !== "number") {
333
- throw new (0, _chunkGYM46G5Lcjs.WrongFamilyError)(
333
+ throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
334
334
  `chain ${network} is Stellar; a custom token must be { issuer, code, decimals }.`
335
335
  );
336
336
  }
@@ -351,12 +351,12 @@ function makeStellarNetwork(preset, rpcUrl) {
351
351
  },
352
352
  assertValidPayTo(payTo) {
353
353
  if (payTo.startsWith("0x")) {
354
- throw new (0, _chunkGYM46G5Lcjs.WrongFamilyError)(
354
+ throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
355
355
  `chain ${network} is Stellar, but payTo "${payTo}" looks like an EVM address.`
356
356
  );
357
357
  }
358
358
  if (!_stellarsdk.StrKey.isValidEd25519PublicKey(payTo)) {
359
- throw new (0, _chunkGYM46G5Lcjs.WrongFamilyError)(
359
+ throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
360
360
  `chain ${network} is Stellar, but payTo "${payTo}" is not a valid Stellar account (G\u2026).`
361
361
  );
362
362
  }
@@ -377,10 +377,10 @@ function makeStellarNetwork(preset, rpcUrl) {
377
377
  await _chunkCQREG5LEcjs.delay.call(void 0, 1500);
378
378
  }
379
379
  }
380
- throw new (0, _chunkGYM46G5Lcjs.ConfirmationTimeoutError)(`Stellar tx ${ref} not visible on Horizon in time.`);
380
+ throw new (0, _chunk3FR22M3Ocjs.ConfirmationTimeoutError)(`Stellar tx ${ref} not visible on Horizon in time.`);
381
381
  },
382
382
  async estimateCost() {
383
- return _chunkGYM46G5Lcjs.nativeCost.call(void 0, {
383
+ return _chunk3FR22M3Ocjs.nativeCost.call(void 0, {
384
384
  symbol: XLM_SYMBOL,
385
385
  decimals: STELLAR_DECIMALS,
386
386
  fee: 100n,
@@ -404,7 +404,7 @@ function makeStellarNetwork(preset, rpcUrl) {
404
404
  }
405
405
  const toBase = (s) => {
406
406
  try {
407
- return s != null ? _chunkGYM46G5Lcjs.parseUnits.call(void 0, s, STELLAR_DECIMALS) : 0n;
407
+ return s != null ? _chunk3FR22M3Ocjs.parseUnits.call(void 0, s, STELLAR_DECIMALS) : 0n;
408
408
  } catch (e7) {
409
409
  return 0n;
410
410
  }
@@ -12,7 +12,7 @@ import {
12
12
  parseUnits,
13
13
  rejectForeignToken,
14
14
  toInsufficientFundsError
15
- } from "./chunk-PAMKCWVW.js";
15
+ } from "./chunk-3ZWM3DKM.js";
16
16
 
17
17
  // src/drivers/stellar/index.ts
18
18
  import { Horizon, StrKey as StrKey2 } from "@stellar/stellar-sdk";
@@ -7,7 +7,7 @@ import {
7
7
  nativeCost,
8
8
  rejectForeignToken,
9
9
  toInsufficientFundsError
10
- } from "./chunk-PAMKCWVW.js";
10
+ } from "./chunk-3ZWM3DKM.js";
11
11
 
12
12
  // src/drivers/sui/index.ts
13
13
  import { SuiJsonRpcClient } from "@mysten/sui/jsonRpc";
@@ -7,7 +7,7 @@
7
7
 
8
8
 
9
9
 
10
- var _chunkGYM46G5Lcjs = require('./chunk-GYM46G5L.cjs');
10
+ var _chunk3FR22M3Ocjs = require('./chunk-3FR22M3O.cjs');
11
11
 
12
12
  // src/drivers/sui/index.ts
13
13
  var _jsonRpc = require('@mysten/sui/jsonRpc');
@@ -57,7 +57,7 @@ async function paySui(params) {
57
57
  cursor = page.hasNextPage ? page.nextCursor : null;
58
58
  } while (gathered < amount && cursor);
59
59
  if (!ids.length) {
60
- throw new (0, _chunkGYM46G5Lcjs.InsufficientFundsError)(
60
+ throw new (0, _chunk3FR22M3Ocjs.InsufficientFundsError)(
61
61
  `Sui wallet holds no ${accept.asset} coin objects to pay from.`
62
62
  );
63
63
  }
@@ -75,14 +75,14 @@ async function paySui(params) {
75
75
  });
76
76
  return res.digest;
77
77
  } catch (err) {
78
- if (err instanceof _chunkGYM46G5Lcjs.InsufficientFundsError) throw err;
78
+ if (err instanceof _chunk3FR22M3Ocjs.InsufficientFundsError) throw err;
79
79
  if (isSuiAffordability(err)) {
80
- throw new (0, _chunkGYM46G5Lcjs.InsufficientFundsError)(
80
+ throw new (0, _chunk3FR22M3Ocjs.InsufficientFundsError)(
81
81
  err instanceof Error ? err.message : "Insufficient SUI/coin balance for the payment.",
82
82
  { cause: err }
83
83
  );
84
84
  }
85
- throw _nullishCoalesce(_chunkGYM46G5Lcjs.toInsufficientFundsError.call(void 0, err), () => ( err));
85
+ throw _nullishCoalesce(_chunk3FR22M3Ocjs.toInsufficientFundsError.call(void 0, err), () => ( err));
86
86
  }
87
87
  }
88
88
  function isSuiAffordability(err) {
@@ -170,13 +170,13 @@ function normalizeSuiAddress(value) {
170
170
  var _ed25519 = require('@mysten/sui/keypairs/ed25519');
171
171
  function assertSuiWallet(wallet, network) {
172
172
  if (typeof wallet !== "object" || wallet === null) {
173
- throw new (0, _chunkGYM46G5Lcjs.WrongFamilyError)(
173
+ throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
174
174
  `chain ${network} is Sui; wallet must be { key } (suiprivkey1\u2026 ) or { keypair }.`
175
175
  );
176
176
  }
177
- _chunkGYM46G5Lcjs.assertNoLegacyWalletKey.call(void 0, wallet, "Sui");
177
+ _chunk3FR22M3Ocjs.assertNoLegacyWalletKey.call(void 0, wallet, "Sui");
178
178
  if (!("key" in wallet) && !("keypair" in wallet)) {
179
- throw new (0, _chunkGYM46G5Lcjs.WrongFamilyError)(
179
+ throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
180
180
  `chain ${network} is Sui; wallet must be { key } (suiprivkey1\u2026) or { keypair }.`
181
181
  );
182
182
  }
@@ -188,13 +188,13 @@ function resolveSuiKeypair(config) {
188
188
  try {
189
189
  return _ed25519.Ed25519Keypair.fromSecretKey(config.key);
190
190
  } catch (cause) {
191
- throw new (0, _chunkGYM46G5Lcjs.WrongFamilyError)(
191
+ throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
192
192
  "Sui wallet { key } is not a valid suiprivkey1\u2026 secret (or 32-byte key).",
193
193
  { cause }
194
194
  );
195
195
  }
196
196
  }
197
- throw new (0, _chunkGYM46G5Lcjs.WrongFamilyError)("Sui wallet needs { key } (suiprivkey1\u2026) or { keypair }.");
197
+ throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)("Sui wallet needs { key } (suiprivkey1\u2026) or { keypair }.");
198
198
  }
199
199
 
200
200
  // src/drivers/sui/index.ts
@@ -246,16 +246,16 @@ function makeSuiNetwork(preset, rpcUrl) {
246
246
  const info = preset.tokens[token.toUpperCase()];
247
247
  if (!info) {
248
248
  const known = Object.keys(preset.tokens).join(", ") || "(none built in)";
249
- throw new (0, _chunkGYM46G5Lcjs.UnknownTokenError)(
249
+ throw new (0, _chunk3FR22M3Ocjs.UnknownTokenError)(
250
250
  `token "${token}" isn't built in for Sui (known: ${known}). Note: no native USDT on Sui. Pass { coinType, decimals } for a custom coin, or use 'native'.`
251
251
  );
252
252
  }
253
253
  return { asset: info.coinType, decimals: info.decimals, symbol: info.symbol };
254
254
  }
255
- _chunkGYM46G5Lcjs.rejectForeignToken.call(void 0, token, "sui", network);
255
+ _chunk3FR22M3Ocjs.rejectForeignToken.call(void 0, token, "sui", network);
256
256
  const t = token;
257
257
  if (!t.coinType || typeof t.decimals !== "number") {
258
- throw new (0, _chunkGYM46G5Lcjs.WrongFamilyError)(
258
+ throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
259
259
  `chain ${network} is Sui; a custom token must be { coinType, decimals }.`
260
260
  );
261
261
  }
@@ -274,7 +274,7 @@ function makeSuiNetwork(preset, rpcUrl) {
274
274
  },
275
275
  assertValidPayTo(payTo) {
276
276
  if (!_utils.isValidSuiAddress.call(void 0, payTo)) {
277
- throw new (0, _chunkGYM46G5Lcjs.WrongFamilyError)(
277
+ throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
278
278
  `chain ${network} is Sui, but payTo "${payTo}" is not a valid Sui address (0x + 32 bytes).`
279
279
  );
280
280
  }
@@ -291,11 +291,11 @@ function makeSuiNetwork(preset, rpcUrl) {
291
291
  const tx = await client.waitForTransaction({ digest: ref, options: { showEffects: true } });
292
292
  return { height: String(_nullishCoalesce(tx.checkpoint, () => ( "0"))) };
293
293
  } catch (err) {
294
- throw new (0, _chunkGYM46G5Lcjs.ConfirmationTimeoutError)(`Sui tx ${ref} did not finalize in time.`, { cause: err });
294
+ throw new (0, _chunk3FR22M3Ocjs.ConfirmationTimeoutError)(`Sui tx ${ref} did not finalize in time.`, { cause: err });
295
295
  }
296
296
  },
297
297
  async estimateCost() {
298
- return _chunkGYM46G5Lcjs.nativeCost.call(void 0, {
298
+ return _chunk3FR22M3Ocjs.nativeCost.call(void 0, {
299
299
  symbol: SUI_SYMBOL,
300
300
  decimals: SUI_DECIMALS,
301
301
  fee: 3000000n,
@@ -9,7 +9,7 @@ import {
9
9
  nativeCost,
10
10
  rejectForeignToken,
11
11
  toInsufficientFundsError
12
- } from "./chunk-PAMKCWVW.js";
12
+ } from "./chunk-3ZWM3DKM.js";
13
13
 
14
14
  // src/drivers/ton/index.ts
15
15
  import { Address as Address2 } from "@ton/core";
@@ -9,7 +9,7 @@ var _chunkCQREG5LEcjs = require('./chunk-CQREG5LE.cjs');
9
9
 
10
10
 
11
11
 
12
- var _chunkGYM46G5Lcjs = require('./chunk-GYM46G5L.cjs');
12
+ var _chunk3FR22M3Ocjs = require('./chunk-3FR22M3O.cjs');
13
13
 
14
14
  // src/drivers/ton/index.ts
15
15
  var _core = require('@ton/core');
@@ -76,7 +76,7 @@ async function waitForSeqno(opened, from, { tries = 30, intervalMs = 2e3 } = {})
76
76
  }
77
77
  if (current > from) return;
78
78
  }
79
- throw new (0, _chunkGYM46G5Lcjs.ConfirmationTimeoutError)(
79
+ throw new (0, _chunk3FR22M3Ocjs.ConfirmationTimeoutError)(
80
80
  `TON wallet seqno did not advance past ${from} \u2014 the payment may not have been accepted.`
81
81
  );
82
82
  }
@@ -207,13 +207,13 @@ var _crypto = require('@ton/crypto');
207
207
 
208
208
  function assertTonWallet(wallet, network) {
209
209
  if (typeof wallet !== "object" || wallet === null) {
210
- throw new (0, _chunkGYM46G5Lcjs.WrongFamilyError)(
210
+ throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
211
211
  `chain ${network} is TON; wallet must be { key } (24-word mnemonic) or { keyPair }.`
212
212
  );
213
213
  }
214
- _chunkGYM46G5Lcjs.assertNoLegacyWalletKey.call(void 0, wallet, "TON");
214
+ _chunk3FR22M3Ocjs.assertNoLegacyWalletKey.call(void 0, wallet, "TON");
215
215
  if (!("key" in wallet) && !("keyPair" in wallet)) {
216
- throw new (0, _chunkGYM46G5Lcjs.WrongFamilyError)(
216
+ throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
217
217
  `chain ${network} is TON; wallet must be { key } (24-word mnemonic) or { keyPair }.`
218
218
  );
219
219
  }
@@ -224,13 +224,13 @@ async function resolveTonWallet(config) {
224
224
  let keyPair;
225
225
  if (config.key) {
226
226
  if (typeof config.key !== "string" && !Array.isArray(config.key)) {
227
- throw new (0, _chunkGYM46G5Lcjs.WrongFamilyError)(
227
+ throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
228
228
  "chain is TON; the wallet { key } must be a 24-word mnemonic (a string or string[])."
229
229
  );
230
230
  }
231
231
  const words = Array.isArray(config.key) ? config.key : config.key.trim().split(/\s+/);
232
232
  if (!await _crypto.mnemonicValidate.call(void 0, words)) {
233
- throw new (0, _chunkGYM46G5Lcjs.WrongFamilyError)(
233
+ throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
234
234
  "chain is TON; the wallet { key } is not a valid TON mnemonic (expected 24 words from the TON/BIP-39 wordlist)."
235
235
  );
236
236
  }
@@ -238,7 +238,7 @@ async function resolveTonWallet(config) {
238
238
  } else if (config.keyPair) {
239
239
  keyPair = config.keyPair;
240
240
  } else {
241
- throw new (0, _chunkGYM46G5Lcjs.WrongFamilyError)("TON wallet needs { key } (24-word mnemonic) or { keyPair }.");
241
+ throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)("TON wallet needs { key } (24-word mnemonic) or { keyPair }.");
242
242
  }
243
243
  const contract = version === "v5r1" ? _ton.WalletContractV5R1.create({ workchain: 0, publicKey: keyPair.publicKey }) : _ton.WalletContractV4.create({ workchain: 0, publicKey: keyPair.publicKey });
244
244
  return { keyPair, contract };
@@ -287,15 +287,15 @@ function makeTonNetwork(preset, rpcUrl) {
287
287
  const info = preset.tokens[token.toUpperCase()];
288
288
  if (!info) {
289
289
  const known = Object.keys(preset.tokens).join(", ") || "(none built in)";
290
- throw new (0, _chunkGYM46G5Lcjs.UnknownTokenError)(
290
+ throw new (0, _chunk3FR22M3Ocjs.UnknownTokenError)(
291
291
  `token "${token}" isn't built in for TON (known: ${known}). Note: native USDC doesn't exist on TON. Pass { master, decimals } for a custom jetton, or use 'native'.`
292
292
  );
293
293
  }
294
294
  return { asset: info.master, decimals: info.decimals, symbol: info.symbol };
295
295
  }
296
- _chunkGYM46G5Lcjs.rejectForeignToken.call(void 0, token, "ton", network);
296
+ _chunk3FR22M3Ocjs.rejectForeignToken.call(void 0, token, "ton", network);
297
297
  if (!("master" in token)) {
298
- throw new (0, _chunkGYM46G5Lcjs.WrongFamilyError)(
298
+ throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
299
299
  `chain ${network} is TON; a custom token must be { master, decimals }.`
300
300
  );
301
301
  }
@@ -314,14 +314,14 @@ function makeTonNetwork(preset, rpcUrl) {
314
314
  },
315
315
  assertValidPayTo(payTo) {
316
316
  if (payTo.startsWith("0x")) {
317
- throw new (0, _chunkGYM46G5Lcjs.WrongFamilyError)(
317
+ throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
318
318
  `chain ${network} is TON, but payTo "${payTo}" looks like an EVM address.`
319
319
  );
320
320
  }
321
321
  try {
322
322
  _core.Address.parse(payTo);
323
323
  } catch (e6) {
324
- throw new (0, _chunkGYM46G5Lcjs.WrongFamilyError)(
324
+ throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
325
325
  `chain ${network} is TON, but payTo "${payTo}" is not a valid TON address.`
326
326
  );
327
327
  }
@@ -337,7 +337,7 @@ function makeTonNetwork(preset, rpcUrl) {
337
337
  const watch = await watchAccountFor(accept);
338
338
  return encodeRef(watch, accept.extra.nonce);
339
339
  } catch (err) {
340
- throw _nullishCoalesce(_chunkGYM46G5Lcjs.toInsufficientFundsError.call(void 0, err), () => ( err));
340
+ throw _nullishCoalesce(_chunk3FR22M3Ocjs.toInsufficientFundsError.call(void 0, err), () => ( err));
341
341
  }
342
342
  },
343
343
  async confirm(ref) {
@@ -356,12 +356,12 @@ function makeTonNetwork(preset, rpcUrl) {
356
356
  if (inc && inc.comment === nonce) return { height: tx.lt.toString() };
357
357
  }
358
358
  }
359
- throw new (0, _chunkGYM46G5Lcjs.ConfirmationTimeoutError)(`TON payment for nonce ${nonce} did not settle in time.`);
359
+ throw new (0, _chunk3FR22M3Ocjs.ConfirmationTimeoutError)(`TON payment for nonce ${nonce} did not settle in time.`);
360
360
  },
361
361
  async estimateCost(accept) {
362
362
  const fee = accept.asset === "native" ? 10000000n : 50000000n;
363
363
  const detail = accept.asset === "native" ? `~0.01 ${TON_NATIVE_SYMBOL} network fee` : `~0.05 ${TON_NATIVE_SYMBOL} attached for the jetton transfer (leftover refunded)`;
364
- return _chunkGYM46G5Lcjs.nativeCost.call(void 0, { symbol: TON_NATIVE_SYMBOL, decimals: TON_DECIMALS, fee, basis: "heuristic", detail });
364
+ return _chunk3FR22M3Ocjs.nativeCost.call(void 0, { symbol: TON_NATIVE_SYMBOL, decimals: TON_DECIMALS, fee, basis: "heuristic", detail });
365
365
  },
366
366
  async balanceOf(wallet, asset) {
367
367
  let owner;