@piprail/sdk 2.13.0 → 2.14.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 (30) hide show
  1. package/CHANGELOG.md +96 -0
  2. package/dist/{algorand-AA3WXKW4.js → algorand-6J3IABVF.js} +12 -11
  3. package/dist/{algorand-FCEECDG6.cjs → algorand-QU6G2DQZ.cjs} +43 -42
  4. package/dist/{aptos-LY67Q6QF.js → aptos-DHOMTBLZ.js} +11 -10
  5. package/dist/{aptos-GHJPO6JJ.cjs → aptos-LFTQGBBK.cjs} +41 -40
  6. package/dist/{chunk-MWBT7MCE.cjs → chunk-GYM46G5L.cjs} +22 -4
  7. package/dist/{chunk-SC2ZYDHD.js → chunk-PAMKCWVW.js} +22 -4
  8. package/dist/index.cjs +505 -234
  9. package/dist/index.d.cts +281 -12
  10. package/dist/index.d.ts +281 -12
  11. package/dist/index.js +302 -31
  12. package/dist/{ledger-mF_SoiDB.d.ts → ledger-uFtXlIHY.d.cts} +31 -1
  13. package/dist/{ledger-mF_SoiDB.d.cts → ledger-uFtXlIHY.d.ts} +31 -1
  14. package/dist/{near-FZBUICCS.js → near-5PXTVQ47.js} +14 -5
  15. package/dist/{near-6KAQVVG2.cjs → near-YNNK7RW7.cjs} +39 -30
  16. package/dist/node.d.cts +2 -2
  17. package/dist/node.d.ts +2 -2
  18. package/dist/{solana-ELUWO6N5.js → solana-HITVI3HF.js} +22 -7
  19. package/dist/{solana-MYF4HBO4.cjs → solana-N3UCNCYE.cjs} +54 -39
  20. package/dist/{stellar-ASP2THL2.js → stellar-2QT6YYKN.js} +4 -4
  21. package/dist/{stellar-CRWBSX4E.cjs → stellar-Y3SQN7S5.cjs} +23 -23
  22. package/dist/{sui-Y4RLKKE2.cjs → sui-4AL4E6XU.cjs} +35 -27
  23. package/dist/{sui-FZIKZNVI.js → sui-FV5L6WF5.js} +20 -12
  24. package/dist/{ton-7GKCTC5H.js → ton-5FWDQ4QR.js} +18 -7
  25. package/dist/{ton-AOR3EURW.cjs → ton-5HDVOTMR.cjs} +33 -22
  26. package/dist/{tron-BMCWN5SS.js → tron-AZDY7BMQ.js} +10 -10
  27. package/dist/{tron-OMXB6EW2.cjs → tron-TX2B4N2A.cjs} +39 -39
  28. package/dist/{xrpl-Y6SQNYLC.cjs → xrpl-5TYDLQFS.cjs} +31 -31
  29. package/dist/{xrpl-DD7TJL5L.js → xrpl-UJL5J7CY.js} +13 -13
  30. package/package.json +1 -1
@@ -10,7 +10,7 @@ var _chunkCQREG5LEcjs = require('./chunk-CQREG5LE.cjs');
10
10
 
11
11
 
12
12
 
13
- var _chunkMWBT7MCEcjs = require('./chunk-MWBT7MCE.cjs');
13
+ var _chunkGYM46G5Lcjs = require('./chunk-GYM46G5L.cjs');
14
14
 
15
15
  // src/drivers/tron/index.ts
16
16
  var _tronweb = require('tronweb');
@@ -62,7 +62,7 @@ async function payTron(params) {
62
62
  return _nullishCoalesce(_nullishCoalesce(broadcast.txid, () => ( _optionalChain([broadcast, 'access', _7 => _7.transaction, 'optionalAccess', _8 => _8.txID]))), () => ( signed.txID));
63
63
  }
64
64
  if (isTronAffordability(broadcast.code, broadcast.message)) {
65
- throw new (0, _chunkMWBT7MCEcjs.InsufficientFundsError)(
65
+ throw new (0, _chunkGYM46G5Lcjs.InsufficientFundsError)(
66
66
  `Tron payment rejected (${_nullishCoalesce(broadcast.code, () => ( "broadcast"))}): not enough TRX for energy/bandwidth, or insufficient token balance.`
67
67
  );
68
68
  }
@@ -70,15 +70,15 @@ async function payTron(params) {
70
70
  `Tron broadcast failed: ${_nullishCoalesce(broadcast.code, () => ( ""))} ${decodeMaybeHex(broadcast.message)}`.trim()
71
71
  );
72
72
  } catch (err) {
73
- if (err instanceof _chunkMWBT7MCEcjs.InsufficientFundsError) throw err;
74
- throw _nullishCoalesce(_chunkMWBT7MCEcjs.toInsufficientFundsError.call(void 0, err), () => ( err));
73
+ if (err instanceof _chunkGYM46G5Lcjs.InsufficientFundsError) throw err;
74
+ throw _nullishCoalesce(_chunkGYM46G5Lcjs.toInsufficientFundsError.call(void 0, err), () => ( err));
75
75
  }
76
76
  }
77
77
  async function payTronNative(params) {
78
78
  const { client, from, privateKey, accept } = params;
79
79
  const sun = BigInt(accept.amount);
80
80
  if (sun > BigInt(Number.MAX_SAFE_INTEGER)) {
81
- throw new (0, _chunkMWBT7MCEcjs.InsufficientFundsError)(
81
+ throw new (0, _chunkGYM46G5Lcjs.InsufficientFundsError)(
82
82
  `Tron native amount ${accept.amount} sun exceeds the safe-integer range tronweb.sendTrx accepts \u2014 price this resource in a smaller native amount or a TRC-20 token.`
83
83
  );
84
84
  }
@@ -90,7 +90,7 @@ async function payTronNative(params) {
90
90
  return _nullishCoalesce(_nullishCoalesce(broadcast.txid, () => ( _optionalChain([broadcast, 'access', _11 => _11.transaction, 'optionalAccess', _12 => _12.txID]))), () => ( signed.txID));
91
91
  }
92
92
  if (isTronAffordability(broadcast.code, broadcast.message)) {
93
- throw new (0, _chunkMWBT7MCEcjs.InsufficientFundsError)(
93
+ throw new (0, _chunkGYM46G5Lcjs.InsufficientFundsError)(
94
94
  `Tron TRX payment rejected (${_nullishCoalesce(broadcast.code, () => ( "broadcast"))}): not enough TRX for the amount plus bandwidth (and the ~1 TRX account-creation fee if the recipient is new).`
95
95
  );
96
96
  }
@@ -98,8 +98,8 @@ async function payTronNative(params) {
98
98
  `Tron TRX broadcast failed: ${_nullishCoalesce(broadcast.code, () => ( ""))} ${decodeMaybeHex(broadcast.message)}`.trim()
99
99
  );
100
100
  } catch (err) {
101
- if (err instanceof _chunkMWBT7MCEcjs.InsufficientFundsError) throw err;
102
- throw _nullishCoalesce(_chunkMWBT7MCEcjs.toInsufficientFundsError.call(void 0, err), () => ( err));
101
+ if (err instanceof _chunkGYM46G5Lcjs.InsufficientFundsError) throw err;
102
+ throw _nullishCoalesce(_chunkGYM46G5Lcjs.toInsufficientFundsError.call(void 0, err), () => ( err));
103
103
  }
104
104
  }
105
105
  function decodeMaybeHex(message) {
@@ -141,11 +141,11 @@ async function verifyTron(params) {
141
141
  };
142
142
  }
143
143
  const ageSeconds = Math.floor(Date.now() / 1e3) - Math.floor(info.blockTimeStamp / 1e3);
144
- if (Number.isFinite(ageSeconds) && ageSeconds > accept.maxTimeoutSeconds) {
144
+ if (!Number.isFinite(ageSeconds) || ageSeconds > accept.maxTimeoutSeconds) {
145
145
  return {
146
146
  ok: false,
147
147
  error: "payment_expired",
148
- detail: `Payment is ${ageSeconds}s old; max allowed is ${accept.maxTimeoutSeconds}s.`
148
+ detail: Number.isFinite(ageSeconds) ? `Payment is ${ageSeconds}s old; max allowed is ${accept.maxTimeoutSeconds}s.` : `Cannot determine the age of ${txid} (no blockTimeStamp) \u2014 fail closed.`
149
149
  };
150
150
  }
151
151
  const { total, from } = sumTransfersTo(_nullishCoalesce(info.log, () => ( [])), tokenHex20, payToHex20);
@@ -181,12 +181,15 @@ async function verifyTronNative(params) {
181
181
  return txNotFound(txid);
182
182
  }
183
183
  if (!info || !info.id) return txNotFound(txid);
184
+ if (_optionalChain([info, 'access', _17 => _17.receipt, 'optionalAccess', _18 => _18.result]) && info.receipt.result !== "SUCCESS") {
185
+ return { ok: false, error: "tx_reverted", detail: `Tron tx ${txid} did not succeed (receipt.result=${info.receipt.result}).` };
186
+ }
184
187
  const ageSeconds = Math.floor(Date.now() / 1e3) - Math.floor(info.blockTimeStamp / 1e3);
185
- if (Number.isFinite(ageSeconds) && ageSeconds > accept.maxTimeoutSeconds) {
188
+ if (!Number.isFinite(ageSeconds) || ageSeconds > accept.maxTimeoutSeconds) {
186
189
  return {
187
190
  ok: false,
188
191
  error: "payment_expired",
189
- detail: `Payment is ${ageSeconds}s old; max allowed is ${accept.maxTimeoutSeconds}s.`
192
+ detail: Number.isFinite(ageSeconds) ? `Payment is ${ageSeconds}s old; max allowed is ${accept.maxTimeoutSeconds}s.` : `Cannot determine the age of ${txid} (no blockTimeStamp) \u2014 fail closed.`
190
193
  };
191
194
  }
192
195
  let tx;
@@ -196,11 +199,11 @@ async function verifyTronNative(params) {
196
199
  return txNotFound(txid);
197
200
  }
198
201
  if (!tx) return txNotFound(txid);
199
- const ret = _optionalChain([tx, 'access', _17 => _17.ret, 'optionalAccess', _18 => _18[0], 'optionalAccess', _19 => _19.contractRet]);
202
+ const ret = _optionalChain([tx, 'access', _19 => _19.ret, 'optionalAccess', _20 => _20[0], 'optionalAccess', _21 => _21.contractRet]);
200
203
  if (ret && ret !== "SUCCESS") {
201
204
  return { ok: false, error: "tx_reverted", detail: `Tron tx ${txid} did not succeed (contractRet=${ret}).` };
202
205
  }
203
- const contract = (_nullishCoalesce(_optionalChain([tx, 'access', _20 => _20.raw_data, 'optionalAccess', _21 => _21.contract]), () => ( [])))[0];
206
+ const contract = (_nullishCoalesce(_optionalChain([tx, 'access', _22 => _22.raw_data, 'optionalAccess', _23 => _23.contract]), () => ( [])))[0];
204
207
  if (!contract || contract.type !== "TransferContract") {
205
208
  return {
206
209
  ok: false,
@@ -208,7 +211,7 @@ async function verifyTronNative(params) {
208
211
  detail: `Tron tx ${txid} is not a native TRX transfer (TransferContract).`
209
212
  };
210
213
  }
211
- const value = _nullishCoalesce(_optionalChain([contract, 'access', _22 => _22.parameter, 'optionalAccess', _23 => _23.value]), () => ( {}));
214
+ const value = _nullishCoalesce(_optionalChain([contract, 'access', _24 => _24.parameter, 'optionalAccess', _25 => _25.value]), () => ( {}));
212
215
  const to = String(_nullishCoalesce(value.to_address, () => ( ""))).toLowerCase().replace(/^0x/, "");
213
216
  if (to !== payToHex41) {
214
217
  return { ok: false, error: "wrong_recipient", detail: `Native TRX in ${txid} was not sent to ${accept.payTo}.` };
@@ -270,13 +273,13 @@ function txNotFound(txid) {
270
273
  // src/drivers/tron/wallet.ts
271
274
  function assertTronWallet(wallet, network) {
272
275
  if (typeof wallet !== "object" || wallet === null) {
273
- throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)(
276
+ throw new (0, _chunkGYM46G5Lcjs.WrongFamilyError)(
274
277
  `chain ${network} is Tron; wallet must be { key } (32-byte hex).`
275
278
  );
276
279
  }
277
- _chunkMWBT7MCEcjs.assertNoLegacyWalletKey.call(void 0, wallet, "Tron");
280
+ _chunkGYM46G5Lcjs.assertNoLegacyWalletKey.call(void 0, wallet, "Tron");
278
281
  if (!("key" in wallet)) {
279
- throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)(
282
+ throw new (0, _chunkGYM46G5Lcjs.WrongFamilyError)(
280
283
  `chain ${network} is Tron; wallet must be { key } (32-byte hex).`
281
284
  );
282
285
  }
@@ -284,14 +287,14 @@ function assertTronWallet(wallet, network) {
284
287
  }
285
288
  function resolveTronPrivateKey(config) {
286
289
  if (!config.key) {
287
- throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)("Tron wallet needs { key } (32-byte hex).");
290
+ throw new (0, _chunkGYM46G5Lcjs.WrongFamilyError)("Tron wallet needs { key } (32-byte hex).");
288
291
  }
289
292
  if (typeof config.key !== "string") {
290
- throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)("Tron wallet { key } must be a 32-byte hex string.");
293
+ throw new (0, _chunkGYM46G5Lcjs.WrongFamilyError)("Tron wallet { key } must be a 32-byte hex string.");
291
294
  }
292
295
  const hex = config.key.replace(/^0x/i, "").toLowerCase();
293
296
  if (!/^[0-9a-f]{64}$/.test(hex)) {
294
- throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)(
297
+ throw new (0, _chunkGYM46G5Lcjs.WrongFamilyError)(
295
298
  "Tron wallet { key } must be a 32-byte hex string (64 hex chars)."
296
299
  );
297
300
  }
@@ -341,21 +344,21 @@ function makeTronNetwork(preset, rpcUrl) {
341
344
  const info = preset.tokens[token.toUpperCase()];
342
345
  if (!info) {
343
346
  const known = Object.keys(preset.tokens).join(", ") || "(none built in)";
344
- throw new (0, _chunkMWBT7MCEcjs.UnknownTokenError)(
347
+ throw new (0, _chunkGYM46G5Lcjs.UnknownTokenError)(
345
348
  `token "${token}" isn't built in for Tron (known: ${known}). Note: native USDC doesn't exist on Tron. Pass { address, decimals } for a custom TRC-20.`
346
349
  );
347
350
  }
348
351
  return { asset: info.address, decimals: info.decimals, symbol: info.symbol };
349
352
  }
350
- _chunkMWBT7MCEcjs.rejectForeignToken.call(void 0, token, "tron", network);
353
+ _chunkGYM46G5Lcjs.rejectForeignToken.call(void 0, token, "tron", network);
351
354
  if (!("address" in token)) {
352
- throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)(
355
+ throw new (0, _chunkGYM46G5Lcjs.WrongFamilyError)(
353
356
  `chain ${network} is Tron; a custom token must be { address, decimals } (Base58 T\u2026 contract).`
354
357
  );
355
358
  }
356
359
  const t = token;
357
360
  if (t.address.startsWith("0x") || !tronWeb.isAddress(t.address)) {
358
- throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)(
361
+ throw new (0, _chunkGYM46G5Lcjs.WrongFamilyError)(
359
362
  `chain ${network} is Tron, but token address "${t.address}" is not a valid Tron contract (T\u2026).`
360
363
  );
361
364
  }
@@ -374,12 +377,12 @@ function makeTronNetwork(preset, rpcUrl) {
374
377
  },
375
378
  assertValidPayTo(payTo) {
376
379
  if (payTo.startsWith("0x")) {
377
- throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)(
380
+ throw new (0, _chunkGYM46G5Lcjs.WrongFamilyError)(
378
381
  `chain ${network} is Tron, but payTo "${payTo}" looks like an EVM address.`
379
382
  );
380
383
  }
381
384
  if (!tronWeb.isAddress(payTo)) {
382
- throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)(
385
+ throw new (0, _chunkGYM46G5Lcjs.WrongFamilyError)(
383
386
  `chain ${network} is Tron, but payTo "${payTo}" is not a valid Tron address (T\u2026).`
384
387
  );
385
388
  }
@@ -391,7 +394,7 @@ function makeTronNetwork(preset, rpcUrl) {
391
394
  const privateKey = resolveTronPrivateKey(wallet._native);
392
395
  const from = tronWeb.address.fromPrivateKey(privateKey);
393
396
  if (!from) {
394
- throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)("Tron wallet { key } could not derive an address.");
397
+ throw new (0, _chunkGYM46G5Lcjs.WrongFamilyError)("Tron wallet { key } could not derive an address.");
395
398
  }
396
399
  if (accept.asset === "native") {
397
400
  return payTronNative({ client: tronWeb, from, privateKey, accept });
@@ -405,7 +408,7 @@ function makeTronNetwork(preset, rpcUrl) {
405
408
  });
406
409
  },
407
410
  async confirm(ref) {
408
- const txid = stripTronPrefix(ref);
411
+ const txid = ref;
409
412
  for (let i = 0; i < 30; i += 1) {
410
413
  try {
411
414
  const info = await reader.getTransactionInfo(txid);
@@ -414,11 +417,11 @@ function makeTronNetwork(preset, rpcUrl) {
414
417
  }
415
418
  await _chunkCQREG5LEcjs.delay.call(void 0, 2500);
416
419
  }
417
- throw new (0, _chunkMWBT7MCEcjs.ConfirmationTimeoutError)(`Tron tx ${txid} did not solidify in time.`);
420
+ throw new (0, _chunkGYM46G5Lcjs.ConfirmationTimeoutError)(`Tron tx ${txid} did not solidify in time.`);
418
421
  },
419
422
  async estimateCost(accept, opts) {
420
423
  if (accept.asset === "native") {
421
- return _chunkMWBT7MCEcjs.nativeCost.call(void 0, {
424
+ return _chunkGYM46G5Lcjs.nativeCost.call(void 0, {
422
425
  symbol: "TRX",
423
426
  decimals: TRX_DECIMALS,
424
427
  fee: 1300000n,
@@ -428,7 +431,7 @@ function makeTronNetwork(preset, rpcUrl) {
428
431
  }
429
432
  const ENERGY_PRICE = 420n;
430
433
  const BANDWIDTH_SUN = 345000n;
431
- if (_optionalChain([opts, 'optionalAccess', _24 => _24.from])) {
434
+ if (_optionalChain([opts, 'optionalAccess', _26 => _26.from])) {
432
435
  try {
433
436
  const r = await tronWeb.transactionBuilder.triggerConstantContract(
434
437
  accept.asset,
@@ -442,7 +445,7 @@ function makeTronNetwork(preset, rpcUrl) {
442
445
  );
443
446
  const energy = BigInt(_nullishCoalesce(r.energy_used, () => ( 0)));
444
447
  if (energy > 0n) {
445
- return _chunkMWBT7MCEcjs.nativeCost.call(void 0, {
448
+ return _chunkGYM46G5Lcjs.nativeCost.call(void 0, {
446
449
  symbol: "TRX",
447
450
  decimals: TRX_DECIMALS,
448
451
  fee: energy * ENERGY_PRICE + BANDWIDTH_SUN,
@@ -453,7 +456,7 @@ function makeTronNetwork(preset, rpcUrl) {
453
456
  } catch (e8) {
454
457
  }
455
458
  }
456
- return _chunkMWBT7MCEcjs.nativeCost.call(void 0, {
459
+ return _chunkGYM46G5Lcjs.nativeCost.call(void 0, {
457
460
  symbol: "TRX",
458
461
  decimals: TRX_DECIMALS,
459
462
  fee: 30000n * ENERGY_PRICE + BANDWIDTH_SUN,
@@ -478,7 +481,7 @@ function makeTronNetwork(preset, rpcUrl) {
478
481
  [{ type: "address", value: owner }],
479
482
  owner
480
483
  );
481
- const hex = _optionalChain([res, 'optionalAccess', _25 => _25.constant_result, 'optionalAccess', _26 => _26[0]]);
484
+ const hex = _optionalChain([res, 'optionalAccess', _27 => _27.constant_result, 'optionalAccess', _28 => _28[0]]);
482
485
  token = hex == null ? null : BigInt("0x" + hex);
483
486
  } catch (e9) {
484
487
  token = null;
@@ -490,7 +493,7 @@ function makeTronNetwork(preset, rpcUrl) {
490
493
  return { ready: "n/a" };
491
494
  },
492
495
  async verify(ref, accept) {
493
- const txid = stripTronPrefix(ref);
496
+ const txid = ref;
494
497
  if (accept.asset === "native") {
495
498
  return verifyTronNative({
496
499
  reader,
@@ -511,9 +514,6 @@ function makeTronNetwork(preset, rpcUrl) {
511
514
  }
512
515
  };
513
516
  }
514
- function stripTronPrefix(ref) {
515
- return ref.startsWith("tron:") ? ref.slice(5) : ref;
516
- }
517
517
 
518
518
 
519
519
  exports.tronDriver = tronDriver;
@@ -12,8 +12,7 @@ var _chunkCQREG5LEcjs = require('./chunk-CQREG5LE.cjs');
12
12
 
13
13
 
14
14
 
15
-
16
- var _chunkMWBT7MCEcjs = require('./chunk-MWBT7MCE.cjs');
15
+ var _chunkGYM46G5Lcjs = require('./chunk-GYM46G5L.cjs');
17
16
 
18
17
  // src/drivers/xrpl/index.ts
19
18
  var _xrpl = require('xrpl');
@@ -95,17 +94,17 @@ async function payXrpl(params) {
95
94
  const code = res.engine_result;
96
95
  if (code.startsWith("tes")) return _nullishCoalesce(_optionalChain([res, 'access', _ => _.tx_json, 'optionalAccess', _2 => _2.hash]), () => ( signed.hash));
97
96
  const recipientMsg = recipientNotReadyMessage(code);
98
- if (recipientMsg) throw new (0, _chunkMWBT7MCEcjs.RecipientNotReadyError)(recipientMsg, { cause: makeEngineError(res) });
97
+ if (recipientMsg) throw new (0, _chunkGYM46G5Lcjs.RecipientNotReadyError)(recipientMsg, { cause: makeEngineError(res) });
99
98
  if (isAffordabilityCode(code)) {
100
- throw new (0, _chunkMWBT7MCEcjs.InsufficientFundsError)(
99
+ throw new (0, _chunkGYM46G5Lcjs.InsufficientFundsError)(
101
100
  `XRPL payment rejected: the sender can't cover it \u2014 balance or the 1 XRP base reserve. (XRPL: ${code})`,
102
101
  { cause: makeEngineError(res) }
103
102
  );
104
103
  }
105
104
  throw makeEngineError(res);
106
105
  } catch (err) {
107
- if (err instanceof _chunkMWBT7MCEcjs.InsufficientFundsError || err instanceof _chunkMWBT7MCEcjs.RecipientNotReadyError) throw err;
108
- throw _nullishCoalesce(_chunkMWBT7MCEcjs.toInsufficientFundsError.call(void 0, err), () => ( err));
106
+ if (err instanceof _chunkGYM46G5Lcjs.InsufficientFundsError || err instanceof _chunkGYM46G5Lcjs.RecipientNotReadyError) throw err;
107
+ throw _nullishCoalesce(_chunkGYM46G5Lcjs.toInsufficientFundsError.call(void 0, err), () => ( err));
109
108
  }
110
109
  }
111
110
  function amountForAccept(accept) {
@@ -152,7 +151,7 @@ async function verifyXrpl(params) {
152
151
  const wantAsset = parseXrplAssetId(accept.asset);
153
152
  let txs;
154
153
  try {
155
- txs = await reader.transactionsForAccount(accept.payTo, 50);
154
+ txs = await reader.transactionsForAccount(accept.payTo, 200);
156
155
  } catch (e2) {
157
156
  return rpcFailed(nonce);
158
157
  }
@@ -174,15 +173,16 @@ async function verifyXrpl(params) {
174
173
  detail: `XRPL tx ${tx.hash} for nonce ${nonce} failed on-ledger (${tx.result}).`
175
174
  };
176
175
  }
177
- if (typeof tx.date === "number") {
178
- const ageSeconds = Math.floor(Date.now() / 1e3) - (tx.date + RIPPLE_EPOCH_OFFSET);
179
- if (ageSeconds > accept.maxTimeoutSeconds) {
180
- return {
181
- ok: false,
182
- error: "payment_expired",
183
- detail: `Payment is ${ageSeconds}s old; max allowed is ${accept.maxTimeoutSeconds}s.`
184
- };
185
- }
176
+ if (typeof tx.date !== "number") {
177
+ return { ok: false, error: "payment_expired", detail: `Cannot determine the age of ${tx.hash} (no ledger date) \u2014 fail closed.` };
178
+ }
179
+ const ageSeconds = Math.floor(Date.now() / 1e3) - (tx.date + RIPPLE_EPOCH_OFFSET);
180
+ if (!Number.isFinite(ageSeconds) || ageSeconds > accept.maxTimeoutSeconds) {
181
+ return {
182
+ ok: false,
183
+ error: "payment_expired",
184
+ detail: `Payment is ${ageSeconds}s old; max allowed is ${accept.maxTimeoutSeconds}s.`
185
+ };
186
186
  }
187
187
  const paid = deliveredBaseUnits(tx.delivered_amount, wantAsset, accept.extra.decimals);
188
188
  if (paid === null) {
@@ -230,7 +230,7 @@ function deliveredBaseUnits(delivered, want, decimals) {
230
230
  return null;
231
231
  }
232
232
  try {
233
- return _chunkMWBT7MCEcjs.floorUnits.call(void 0, delivered.value, decimals);
233
+ return _chunkGYM46G5Lcjs.floorUnits.call(void 0, delivered.value, decimals);
234
234
  } catch (e3) {
235
235
  return null;
236
236
  }
@@ -254,13 +254,13 @@ function rpcFailed(nonce) {
254
254
 
255
255
  function assertXrplWallet(wallet, network) {
256
256
  if (typeof wallet !== "object" || wallet === null) {
257
- throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)(
257
+ throw new (0, _chunkGYM46G5Lcjs.WrongFamilyError)(
258
258
  `chain ${network} is XRPL; wallet must be { key } (s\u2026 seed) or { wallet }.`
259
259
  );
260
260
  }
261
- _chunkMWBT7MCEcjs.assertNoLegacyWalletKey.call(void 0, wallet, "XRPL");
261
+ _chunkGYM46G5Lcjs.assertNoLegacyWalletKey.call(void 0, wallet, "XRPL");
262
262
  if (!("key" in wallet) && !("wallet" in wallet)) {
263
- throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)(
263
+ throw new (0, _chunkGYM46G5Lcjs.WrongFamilyError)(
264
264
  `chain ${network} is XRPL; wallet must be { key } (s\u2026 seed) or { wallet }.`
265
265
  );
266
266
  }
@@ -270,11 +270,11 @@ function resolveXrplWallet(config) {
270
270
  if (config.wallet) return config.wallet;
271
271
  if (config.key) {
272
272
  if (!_xrpl.isValidSecret.call(void 0, config.key)) {
273
- throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)("XRPL wallet { key } is not a valid s\u2026 secret seed.");
273
+ throw new (0, _chunkGYM46G5Lcjs.WrongFamilyError)("XRPL wallet { key } is not a valid s\u2026 secret seed.");
274
274
  }
275
275
  return _xrpl.Wallet.fromSeed(config.key);
276
276
  }
277
- throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)("XRPL wallet needs { key } (s\u2026 seed) or { wallet }.");
277
+ throw new (0, _chunkGYM46G5Lcjs.WrongFamilyError)("XRPL wallet needs { key } (s\u2026 seed) or { wallet }.");
278
278
  }
279
279
 
280
280
  // src/drivers/xrpl/index.ts
@@ -349,7 +349,7 @@ function makeXrplNetwork(preset, rpcUrl) {
349
349
  const info = preset.tokens[token.toUpperCase()];
350
350
  if (!info) {
351
351
  const known = Object.keys(preset.tokens).join(", ") || "(none built in)";
352
- throw new (0, _chunkMWBT7MCEcjs.UnknownTokenError)(
352
+ throw new (0, _chunkGYM46G5Lcjs.UnknownTokenError)(
353
353
  `token "${token}" isn't built in for XRPL (known: ${known}). Pass { issuer, currencyHex, decimals } for a custom IOU, or use 'native'.`
354
354
  );
355
355
  }
@@ -359,10 +359,10 @@ function makeXrplNetwork(preset, rpcUrl) {
359
359
  symbol: info.symbol
360
360
  };
361
361
  }
362
- _chunkMWBT7MCEcjs.rejectForeignToken.call(void 0, token, "xrpl", network);
362
+ _chunkGYM46G5Lcjs.rejectForeignToken.call(void 0, token, "xrpl", network);
363
363
  const t = token;
364
364
  if (!t.issuer || !t.currencyHex || typeof t.decimals !== "number") {
365
- throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)(
365
+ throw new (0, _chunkGYM46G5Lcjs.WrongFamilyError)(
366
366
  `chain ${network} is XRPL; a custom token must be { issuer, currencyHex, decimals }.`
367
367
  );
368
368
  }
@@ -383,12 +383,12 @@ function makeXrplNetwork(preset, rpcUrl) {
383
383
  },
384
384
  assertValidPayTo(payTo) {
385
385
  if (payTo.startsWith("0x")) {
386
- throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)(
386
+ throw new (0, _chunkGYM46G5Lcjs.WrongFamilyError)(
387
387
  `chain ${network} is XRPL, but payTo "${payTo}" looks like an EVM address.`
388
388
  );
389
389
  }
390
390
  if (!_xrpl.isValidClassicAddress.call(void 0, payTo)) {
391
- throw new (0, _chunkMWBT7MCEcjs.WrongFamilyError)(
391
+ throw new (0, _chunkGYM46G5Lcjs.WrongFamilyError)(
392
392
  `chain ${network} is XRPL, but payTo "${payTo}" is not a valid XRPL account (r\u2026).`
393
393
  );
394
394
  }
@@ -411,14 +411,14 @@ function makeXrplNetwork(preset, rpcUrl) {
411
411
  }
412
412
  await _chunkCQREG5LEcjs.delay.call(void 0, 1500);
413
413
  }
414
- throw new (0, _chunkMWBT7MCEcjs.ConfirmationTimeoutError)(`XRPL tx ${ref} not validated on-ledger in time.`);
414
+ throw new (0, _chunkGYM46G5Lcjs.ConfirmationTimeoutError)(`XRPL tx ${ref} not validated on-ledger in time.`);
415
415
  },
416
416
  async estimateCost() {
417
417
  try {
418
418
  const drops = await payClient.feeDrops();
419
419
  const n = Number(drops);
420
420
  const fee = BigInt(Number.isFinite(n) && n > 12 ? Math.ceil(n) : 12);
421
- return _chunkMWBT7MCEcjs.nativeCost.call(void 0, {
421
+ return _chunkGYM46G5Lcjs.nativeCost.call(void 0, {
422
422
  symbol: XRP_SYMBOL,
423
423
  decimals: XRP_DECIMALS,
424
424
  fee,
@@ -426,7 +426,7 @@ function makeXrplNetwork(preset, rpcUrl) {
426
426
  detail: `network fee ${fee} drops`
427
427
  });
428
428
  } catch (e5) {
429
- return _chunkMWBT7MCEcjs.nativeCost.call(void 0, {
429
+ return _chunkGYM46G5Lcjs.nativeCost.call(void 0, {
430
430
  symbol: XRP_SYMBOL,
431
431
  decimals: XRP_DECIMALS,
432
432
  fee: 12n,
@@ -463,7 +463,7 @@ function makeXrplNetwork(preset, rpcUrl) {
463
463
  const line = r.lines.find(
464
464
  (l) => l.currency.toUpperCase() === (_nullishCoalesce(currencyHex, () => ( ""))).toUpperCase() && l.account === issuer
465
465
  );
466
- token = line ? _chunkMWBT7MCEcjs.parseUnits.call(void 0, line.balance, XRP_DECIMALS) : 0n;
466
+ token = line ? _chunkGYM46G5Lcjs.floorUnits.call(void 0, line.balance, XRP_DECIMALS) : 0n;
467
467
  } catch (e) {
468
468
  token = isXrplActNotFound(e) ? 0n : null;
469
469
  }
@@ -10,10 +10,9 @@ import {
10
10
  assertNoLegacyWalletKey,
11
11
  floorUnits,
12
12
  nativeCost,
13
- parseUnits,
14
13
  rejectForeignToken,
15
14
  toInsufficientFundsError
16
- } from "./chunk-SC2ZYDHD.js";
15
+ } from "./chunk-PAMKCWVW.js";
17
16
 
18
17
  // src/drivers/xrpl/index.ts
19
18
  import { isValidClassicAddress } from "xrpl";
@@ -152,7 +151,7 @@ async function verifyXrpl(params) {
152
151
  const wantAsset = parseXrplAssetId(accept.asset);
153
152
  let txs;
154
153
  try {
155
- txs = await reader.transactionsForAccount(accept.payTo, 50);
154
+ txs = await reader.transactionsForAccount(accept.payTo, 200);
156
155
  } catch {
157
156
  return rpcFailed(nonce);
158
157
  }
@@ -174,15 +173,16 @@ async function verifyXrpl(params) {
174
173
  detail: `XRPL tx ${tx.hash} for nonce ${nonce} failed on-ledger (${tx.result}).`
175
174
  };
176
175
  }
177
- if (typeof tx.date === "number") {
178
- const ageSeconds = Math.floor(Date.now() / 1e3) - (tx.date + RIPPLE_EPOCH_OFFSET);
179
- if (ageSeconds > accept.maxTimeoutSeconds) {
180
- return {
181
- ok: false,
182
- error: "payment_expired",
183
- detail: `Payment is ${ageSeconds}s old; max allowed is ${accept.maxTimeoutSeconds}s.`
184
- };
185
- }
176
+ if (typeof tx.date !== "number") {
177
+ return { ok: false, error: "payment_expired", detail: `Cannot determine the age of ${tx.hash} (no ledger date) \u2014 fail closed.` };
178
+ }
179
+ const ageSeconds = Math.floor(Date.now() / 1e3) - (tx.date + RIPPLE_EPOCH_OFFSET);
180
+ if (!Number.isFinite(ageSeconds) || ageSeconds > accept.maxTimeoutSeconds) {
181
+ return {
182
+ ok: false,
183
+ error: "payment_expired",
184
+ detail: `Payment is ${ageSeconds}s old; max allowed is ${accept.maxTimeoutSeconds}s.`
185
+ };
186
186
  }
187
187
  const paid = deliveredBaseUnits(tx.delivered_amount, wantAsset, accept.extra.decimals);
188
188
  if (paid === null) {
@@ -463,7 +463,7 @@ function makeXrplNetwork(preset, rpcUrl) {
463
463
  const line = r.lines.find(
464
464
  (l) => l.currency.toUpperCase() === (currencyHex ?? "").toUpperCase() && l.account === issuer
465
465
  );
466
- token = line ? parseUnits(line.balance, XRP_DECIMALS) : 0n;
466
+ token = line ? floorUnits(line.balance, XRP_DECIMALS) : 0n;
467
467
  } catch (e) {
468
468
  token = isXrplActNotFound(e) ? 0n : null;
469
469
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@piprail/sdk",
3
- "version": "2.13.0",
3
+ "version": "2.14.0",
4
4
  "description": "Accept x402 crypto payments across 29 chains — every major EVM chain plus Solana, TON, Tron, NEAR, Sui, Aptos, Algorand, Stellar & XRPL — in a couple of lines. No backend, no database, no fee; payments settle straight to your wallet.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",