@piprail/sdk 1.3.0 → 1.4.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.
package/dist/index.cjs CHANGED
@@ -20,7 +20,7 @@
20
20
 
21
21
 
22
22
 
23
- var _chunkYJPWIK5Lcjs = require('./chunk-YJPWIK5L.cjs');
23
+ var _chunkIQGT65WScjs = require('./chunk-IQGT65WS.cjs');
24
24
 
25
25
  // src/drivers/registry.ts
26
26
  var byFamily = /* @__PURE__ */ new Map();
@@ -40,6 +40,7 @@ function familyForChain(chain) {
40
40
  if (chain.startsWith("sui")) return "sui";
41
41
  if (chain.startsWith("near")) return "near";
42
42
  if (chain.startsWith("aptos")) return "aptos";
43
+ if (chain.startsWith("algorand")) return "algorand";
43
44
  return "evm";
44
45
  }
45
46
  return "evm";
@@ -48,13 +49,13 @@ function resolveNetwork(opts) {
48
49
  const family = familyForChain(opts.chain);
49
50
  const driver = byFamily.get(family);
50
51
  if (!driver) {
51
- throw new (0, _chunkYJPWIK5Lcjs.UnsupportedNetworkError)(
52
+ throw new (0, _chunkIQGT65WScjs.UnsupportedNetworkError)(
52
53
  `No driver registered for the "${family}" family \u2014 it may not be mounted yet (use the async resolveNetwork()).`
53
54
  );
54
55
  }
55
56
  const net = driver.resolve(opts);
56
57
  if (!net) {
57
- throw new (0, _chunkYJPWIK5Lcjs.UnsupportedNetworkError)(
58
+ throw new (0, _chunkIQGT65WScjs.UnsupportedNetworkError)(
58
59
  `The ${family} driver didn't recognise this chain input.`
59
60
  );
60
61
  }
@@ -298,12 +299,12 @@ function createWalletAdapter(config, resolved) {
298
299
  }
299
300
  const wc = config.walletClient;
300
301
  if (!wc.account) {
301
- throw new (0, _chunkYJPWIK5Lcjs.WrongFamilyError)(
302
+ throw new (0, _chunkIQGT65WScjs.WrongFamilyError)(
302
303
  "chain is EVM; the provided walletClient has no attached account. Use `createWalletClient({ account, chain, transport })`, or pass { privateKey }."
303
304
  );
304
305
  }
305
306
  if (wc.chain && wc.chain.id !== resolved.chainId) {
306
- throw new (0, _chunkYJPWIK5Lcjs.WrongChainError)(
307
+ throw new (0, _chunkIQGT65WScjs.WrongChainError)(
307
308
  `PipRailClient: walletClient is on chain ${wc.chain.id} but the SDK was configured with chain ${resolved.chainId}. They must match.`
308
309
  );
309
310
  }
@@ -606,15 +607,15 @@ function makeEvmNetwork(resolved) {
606
607
  const info = resolved.tokens[token.toUpperCase()];
607
608
  if (!info) {
608
609
  const known = Object.keys(resolved.tokens).join(", ") || "(none built in)";
609
- throw new (0, _chunkYJPWIK5Lcjs.UnknownTokenError)(
610
+ throw new (0, _chunkIQGT65WScjs.UnknownTokenError)(
610
611
  `token "${token}" isn't built in for ${resolved.chain.name} (known: ${known}). Pass { address, decimals } instead, or use 'native'.`
611
612
  );
612
613
  }
613
614
  return { asset: info.address, decimals: info.decimals, symbol: info.symbol };
614
615
  }
615
- _chunkYJPWIK5Lcjs.rejectForeignToken.call(void 0, token, "evm", network);
616
+ _chunkIQGT65WScjs.rejectForeignToken.call(void 0, token, "evm", network);
616
617
  if (!("address" in token)) {
617
- throw new (0, _chunkYJPWIK5Lcjs.WrongFamilyError)(
618
+ throw new (0, _chunkIQGT65WScjs.WrongFamilyError)(
618
619
  `chain ${network} is EVM; a custom token must be { address, decimals }.`
619
620
  );
620
621
  }
@@ -646,14 +647,14 @@ function makeEvmNetwork(resolved) {
646
647
  },
647
648
  assertValidPayTo(payTo) {
648
649
  if (!_viem.isAddress.call(void 0, payTo)) {
649
- throw new (0, _chunkYJPWIK5Lcjs.WrongFamilyError)(
650
+ throw new (0, _chunkIQGT65WScjs.WrongFamilyError)(
650
651
  `chain ${network} is EVM, but payTo "${payTo}" is not a valid 0x address.`
651
652
  );
652
653
  }
653
654
  },
654
655
  bindWallet(wallet) {
655
656
  if (typeof wallet !== "object" || wallet === null || !("privateKey" in wallet) && !("walletClient" in wallet)) {
656
- throw new (0, _chunkYJPWIK5Lcjs.WrongFamilyError)(
657
+ throw new (0, _chunkIQGT65WScjs.WrongFamilyError)(
657
658
  `chain ${network} is EVM; wallet must be { privateKey } or { walletClient }.`
658
659
  );
659
660
  }
@@ -670,12 +671,12 @@ function makeEvmNetwork(resolved) {
670
671
  });
671
672
  } catch (err) {
672
673
  if (isViemInsufficientFunds(err)) {
673
- throw new (0, _chunkYJPWIK5Lcjs.InsufficientFundsError)(
674
+ throw new (0, _chunkIQGT65WScjs.InsufficientFundsError)(
674
675
  err instanceof Error ? err.message : "Insufficient funds for payment.",
675
676
  { cause: err }
676
677
  );
677
678
  }
678
- throw _nullishCoalesce(_chunkYJPWIK5Lcjs.toInsufficientFundsError.call(void 0, err), () => ( err));
679
+ throw _nullishCoalesce(_chunkIQGT65WScjs.toInsufficientFundsError.call(void 0, err), () => ( err));
679
680
  }
680
681
  },
681
682
  async confirm(ref, minConfirmations) {
@@ -686,7 +687,7 @@ function makeEvmNetwork(resolved) {
686
687
  });
687
688
  return { height: receipt.blockNumber.toString() };
688
689
  } catch (err) {
689
- throw new (0, _chunkYJPWIK5Lcjs.ConfirmationTimeoutError)(
690
+ throw new (0, _chunkIQGT65WScjs.ConfirmationTimeoutError)(
690
691
  `EVM tx ${ref} did not reach ${minConfirmations} confirmation(s) in time.`,
691
692
  { cause: err }
692
693
  );
@@ -697,7 +698,7 @@ function makeEvmNetwork(resolved) {
697
698
  const gasLimit = accept.asset === "native" ? 21000n : 65000n;
698
699
  try {
699
700
  const gasPrice = await publicClient.getGasPrice();
700
- return _chunkYJPWIK5Lcjs.nativeCost.call(void 0, {
701
+ return _chunkIQGT65WScjs.nativeCost.call(void 0, {
701
702
  symbol,
702
703
  decimals,
703
704
  fee: gasPrice * gasLimit,
@@ -706,7 +707,7 @@ function makeEvmNetwork(resolved) {
706
707
  });
707
708
  } catch (e10) {
708
709
  const gasPrice = 5000000000n;
709
- return _chunkYJPWIK5Lcjs.nativeCost.call(void 0, {
710
+ return _chunkIQGT65WScjs.nativeCost.call(void 0, {
710
711
  symbol,
711
712
  decimals,
712
713
  fee: gasPrice * gasLimit,
@@ -738,9 +739,9 @@ var loaders = {
738
739
  solana: async () => {
739
740
  let mod;
740
741
  try {
741
- mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./solana-RJPNEFSN.cjs")));
742
+ mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./solana-DVA6I55L.cjs")));
742
743
  } catch (cause) {
743
- throw new (0, _chunkYJPWIK5Lcjs.MissingDriverError)(
744
+ throw new (0, _chunkIQGT65WScjs.MissingDriverError)(
744
745
  `Solana selected, but its packages aren't installed. Run: npm install @solana/web3.js @solana/spl-token bs58`,
745
746
  { cause }
746
747
  );
@@ -750,9 +751,9 @@ var loaders = {
750
751
  ton: async () => {
751
752
  let mod;
752
753
  try {
753
- mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./ton-C4KTFXDL.cjs")));
754
+ mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./ton-TVK4TEDX.cjs")));
754
755
  } catch (cause) {
755
- throw new (0, _chunkYJPWIK5Lcjs.MissingDriverError)(
756
+ throw new (0, _chunkIQGT65WScjs.MissingDriverError)(
756
757
  `TON selected, but its packages aren't installed. Run: npm install @ton/ton @ton/core @ton/crypto`,
757
758
  { cause }
758
759
  );
@@ -762,9 +763,9 @@ var loaders = {
762
763
  stellar: async () => {
763
764
  let mod;
764
765
  try {
765
- mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./stellar-SUGNX52Z.cjs")));
766
+ mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./stellar-4D5EWT3V.cjs")));
766
767
  } catch (cause) {
767
- throw new (0, _chunkYJPWIK5Lcjs.MissingDriverError)(
768
+ throw new (0, _chunkIQGT65WScjs.MissingDriverError)(
768
769
  `Stellar selected, but its package isn't installed. Run: npm install @stellar/stellar-sdk`,
769
770
  { cause }
770
771
  );
@@ -774,9 +775,9 @@ var loaders = {
774
775
  xrpl: async () => {
775
776
  let mod;
776
777
  try {
777
- mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./xrpl-N6ZAJRGC.cjs")));
778
+ mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./xrpl-ICO6G7UK.cjs")));
778
779
  } catch (cause) {
779
- throw new (0, _chunkYJPWIK5Lcjs.MissingDriverError)(
780
+ throw new (0, _chunkIQGT65WScjs.MissingDriverError)(
780
781
  `XRPL selected, but its package isn't installed. Run: npm install xrpl`,
781
782
  { cause }
782
783
  );
@@ -786,9 +787,9 @@ var loaders = {
786
787
  tron: async () => {
787
788
  let mod;
788
789
  try {
789
- mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./tron-DTU7NPEM.cjs")));
790
+ mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./tron-Y5RZJZRT.cjs")));
790
791
  } catch (cause) {
791
- throw new (0, _chunkYJPWIK5Lcjs.MissingDriverError)(
792
+ throw new (0, _chunkIQGT65WScjs.MissingDriverError)(
792
793
  `Tron selected, but its package isn't installed. Run: npm install tronweb`,
793
794
  { cause }
794
795
  );
@@ -798,9 +799,9 @@ var loaders = {
798
799
  sui: async () => {
799
800
  let mod;
800
801
  try {
801
- mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./sui-HZWPHVU4.cjs")));
802
+ mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./sui-5HMIHOZK.cjs")));
802
803
  } catch (cause) {
803
- throw new (0, _chunkYJPWIK5Lcjs.MissingDriverError)(
804
+ throw new (0, _chunkIQGT65WScjs.MissingDriverError)(
804
805
  `Sui selected, but its package isn't installed. Run: npm install @mysten/sui`,
805
806
  { cause }
806
807
  );
@@ -810,9 +811,9 @@ var loaders = {
810
811
  near: async () => {
811
812
  let mod;
812
813
  try {
813
- mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./near-DISWUB7Y.cjs")));
814
+ mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./near-KDA5DPTX.cjs")));
814
815
  } catch (cause) {
815
- throw new (0, _chunkYJPWIK5Lcjs.MissingDriverError)(
816
+ throw new (0, _chunkIQGT65WScjs.MissingDriverError)(
816
817
  `NEAR selected, but its package isn't installed. Run: npm install near-api-js`,
817
818
  { cause }
818
819
  );
@@ -822,14 +823,26 @@ var loaders = {
822
823
  aptos: async () => {
823
824
  let mod;
824
825
  try {
825
- mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./aptos-T3MNKUPB.cjs")));
826
+ mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./aptos-TPSOQ2VL.cjs")));
826
827
  } catch (cause) {
827
- throw new (0, _chunkYJPWIK5Lcjs.MissingDriverError)(
828
+ throw new (0, _chunkIQGT65WScjs.MissingDriverError)(
828
829
  `Aptos selected, but its package isn't installed. Run: npm install @aptos-labs/ts-sdk`,
829
830
  { cause }
830
831
  );
831
832
  }
832
833
  registerDriver(mod.aptosDriver);
834
+ },
835
+ algorand: async () => {
836
+ let mod;
837
+ try {
838
+ mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./algorand-IDFUG5CI.cjs")));
839
+ } catch (cause) {
840
+ throw new (0, _chunkIQGT65WScjs.MissingDriverError)(
841
+ `Algorand selected, but its package isn't installed. Run: npm install algosdk`,
842
+ { cause }
843
+ );
844
+ }
845
+ registerDriver(mod.algorandDriver);
833
846
  }
834
847
  };
835
848
  var inFlight = /* @__PURE__ */ new Map();
@@ -896,7 +909,7 @@ function evaluatePolicy(intent, policy, spentForAssetBase) {
896
909
  }
897
910
  }
898
911
  if (policy.maxAmount !== void 0) {
899
- const cap = _chunkYJPWIK5Lcjs.floorUnits.call(void 0, policy.maxAmount, intent.decimals);
912
+ const cap = _chunkIQGT65WScjs.floorUnits.call(void 0, policy.maxAmount, intent.decimals);
900
913
  if (intent.amountBase > cap) {
901
914
  return deny(
902
915
  `payment of ${intent.amountBase} base units exceeds policy.maxAmount ` + `(${policy.maxAmount} ${_nullishCoalesce(intent.symbol, () => ( ""))}).`.trimEnd()
@@ -904,7 +917,7 @@ function evaluatePolicy(intent, policy, spentForAssetBase) {
904
917
  }
905
918
  }
906
919
  if (policy.maxTotal !== void 0) {
907
- const cap = _chunkYJPWIK5Lcjs.floorUnits.call(void 0, policy.maxTotal, intent.decimals);
920
+ const cap = _chunkIQGT65WScjs.floorUnits.call(void 0, policy.maxTotal, intent.decimals);
908
921
  if (spentForAssetBase + intent.amountBase > cap) {
909
922
  return deny(
910
923
  `this payment would push spend on ${_nullishCoalesce(intent.symbol, () => ( intent.asset))} past policy.maxTotal (${policy.maxTotal}); already spent ${spentForAssetBase} base units.`
@@ -954,7 +967,7 @@ var SpendLedger = (_class = class {constructor() { _class.prototype.__init.call(
954
967
  symbol: b.symbol,
955
968
  decimals: b.decimals,
956
969
  totalBase: b.total.toString(),
957
- totalFormatted: _chunkYJPWIK5Lcjs.formatUnits.call(void 0, b.total, b.decimals),
970
+ totalFormatted: _chunkIQGT65WScjs.formatUnits.call(void 0, b.total, b.decimals),
958
971
  count: b.count
959
972
  })),
960
973
  records: [...this.records]
@@ -1081,7 +1094,7 @@ var PipRailClient = (_class2 = class {
1081
1094
  async fetch(url, init) {
1082
1095
  const body = _optionalChain([init, 'optionalAccess', _9 => _9.body]);
1083
1096
  if (body !== void 0 && body !== null && !isReplayableBodyInit(body)) {
1084
- throw new (0, _chunkYJPWIK5Lcjs.NonReplayableBodyError)(
1097
+ throw new (0, _chunkIQGT65WScjs.NonReplayableBodyError)(
1085
1098
  "fetch(): init.body is not replayable. Pass a string, FormData, URLSearchParams, ArrayBuffer, or Blob \u2014 not a ReadableStream."
1086
1099
  );
1087
1100
  }
@@ -1107,7 +1120,7 @@ var PipRailClient = (_class2 = class {
1107
1120
  async resolveChallenge(url, response) {
1108
1121
  const challenge = await parseChallenge(response);
1109
1122
  if (!challenge) {
1110
- throw new (0, _chunkYJPWIK5Lcjs.InvalidEnvelopeError)(
1123
+ throw new (0, _chunkIQGT65WScjs.InvalidEnvelopeError)(
1111
1124
  "402 response did not include a parseable x402 challenge."
1112
1125
  );
1113
1126
  }
@@ -1117,7 +1130,7 @@ var PipRailClient = (_class2 = class {
1117
1130
  );
1118
1131
  if (candidates.length === 0) {
1119
1132
  const networks = challenge.accepts.map((a) => a.network).join(", ");
1120
- throw new (0, _chunkYJPWIK5Lcjs.NoCompatibleAcceptError)(
1133
+ throw new (0, _chunkIQGT65WScjs.NoCompatibleAcceptError)(
1121
1134
  `No accepts[] entry for ${net.network} (challenge offered: ${networks || "none"}).`
1122
1135
  );
1123
1136
  }
@@ -1132,7 +1145,7 @@ var PipRailClient = (_class2 = class {
1132
1145
  * driver's describeAsset) + the policy verdict + a symbol-mismatch flag. */
1133
1146
  buildQuote(net, accept, url, description) {
1134
1147
  if (!/^\d+$/.test(accept.amount)) {
1135
- throw new (0, _chunkYJPWIK5Lcjs.InvalidEnvelopeError)(
1148
+ throw new (0, _chunkIQGT65WScjs.InvalidEnvelopeError)(
1136
1149
  `challenge amount "${accept.amount}" is not a base-unit integer.`
1137
1150
  );
1138
1151
  }
@@ -1140,7 +1153,7 @@ var PipRailClient = (_class2 = class {
1140
1153
  const described = net.describeAsset(accept.asset);
1141
1154
  const decimals = _nullishCoalesce(_optionalChain([described, 'optionalAccess', _10 => _10.decimals]), () => ( accept.extra.decimals));
1142
1155
  const symbol = _nullishCoalesce(_optionalChain([described, 'optionalAccess', _11 => _11.symbol]), () => ( accept.extra.symbol));
1143
- const amountFormatted = _chunkYJPWIK5Lcjs.formatUnits.call(void 0, amountBase, decimals);
1156
+ const amountFormatted = _chunkIQGT65WScjs.formatUnits.call(void 0, amountBase, decimals);
1144
1157
  const intent = {
1145
1158
  host: hostOf(url),
1146
1159
  chain: this.opts.chain,
@@ -1180,7 +1193,7 @@ var PipRailClient = (_class2 = class {
1180
1193
  * throwing PaymentDeclinedError, before any funds move. */
1181
1194
  async authorize(quote) {
1182
1195
  if (!quote.withinPolicy) {
1183
- throw new (0, _chunkYJPWIK5Lcjs.PaymentDeclinedError)(
1196
+ throw new (0, _chunkIQGT65WScjs.PaymentDeclinedError)(
1184
1197
  `Payment refused by policy: ${_nullishCoalesce(quote.policyReason, () => ( "not allowed"))}`
1185
1198
  );
1186
1199
  }
@@ -1190,12 +1203,12 @@ var PipRailClient = (_class2 = class {
1190
1203
  try {
1191
1204
  approved = await hook(quote);
1192
1205
  } catch (err) {
1193
- throw new (0, _chunkYJPWIK5Lcjs.PaymentDeclinedError)("onBeforePay threw \u2014 refusing to pay.", {
1206
+ throw new (0, _chunkIQGT65WScjs.PaymentDeclinedError)("onBeforePay threw \u2014 refusing to pay.", {
1194
1207
  cause: err
1195
1208
  });
1196
1209
  }
1197
1210
  if (!approved) {
1198
- throw new (0, _chunkYJPWIK5Lcjs.PaymentDeclinedError)(
1211
+ throw new (0, _chunkIQGT65WScjs.PaymentDeclinedError)(
1199
1212
  `onBeforePay declined ${quote.amountFormatted} ${_nullishCoalesce(quote.symbol, () => ( ""))}`.trimEnd() + ` on ${quote.network}.`
1200
1213
  );
1201
1214
  }
@@ -1219,7 +1232,7 @@ var PipRailClient = (_class2 = class {
1219
1232
  }
1220
1233
  async payAndConfirm(net, wallet, accept) {
1221
1234
  if (!net.supports(accept.network)) {
1222
- throw new (0, _chunkYJPWIK5Lcjs.WrongChainError)(
1235
+ throw new (0, _chunkIQGT65WScjs.WrongChainError)(
1223
1236
  `Challenge expects ${accept.network} but client is on ${net.network}.`
1224
1237
  );
1225
1238
  }
@@ -1272,7 +1285,7 @@ var PipRailClient = (_class2 = class {
1272
1285
  });
1273
1286
  } catch (err) {
1274
1287
  if (timeoutController.signal.aborted) {
1275
- throw new (0, _chunkYJPWIK5Lcjs.PaymentTimeoutError)(
1288
+ throw new (0, _chunkIQGT65WScjs.PaymentTimeoutError)(
1276
1289
  `Server did not respond within ${this.retryTimeoutMs}ms after broadcasting payment ${ref}. Re-verify or re-submit ref=${ref} \u2014 do NOT re-pay.`,
1277
1290
  { cause: err, ref }
1278
1291
  );
@@ -1294,7 +1307,7 @@ var PipRailClient = (_class2 = class {
1294
1307
  kind: "payment-failed",
1295
1308
  reason: `server returned 402 after broadcasting payment ${ref}${unconfirmedNote} (${why})`
1296
1309
  });
1297
- throw new (0, _chunkYJPWIK5Lcjs.MaxRetriesExceededError)(
1310
+ throw new (0, _chunkIQGT65WScjs.MaxRetriesExceededError)(
1298
1311
  `Server still returned 402 after ${attempts} attempt(s) with on-chain proof ref=${ref}${unconfirmedNote}. Last server rejection: ${why}. Re-verify or re-submit ref=${ref} before retrying \u2014 never re-pay (it would double-spend).`,
1299
1312
  { ref }
1300
1313
  );
@@ -1402,7 +1415,7 @@ function paymentTools(client) {
1402
1415
  receipt: parseReceipt(res)
1403
1416
  };
1404
1417
  } catch (err) {
1405
- if (err instanceof _chunkYJPWIK5Lcjs.PaymentDeclinedError) {
1418
+ if (err instanceof _chunkIQGT65WScjs.PaymentDeclinedError) {
1406
1419
  return { declined: true, reason: err.message };
1407
1420
  }
1408
1421
  throw err;
@@ -1451,7 +1464,7 @@ function createPaymentGate(options) {
1451
1464
  }
1452
1465
  net.assertValidPayTo(payTo);
1453
1466
  const { asset, decimals, symbol } = net.resolveToken(a.token);
1454
- const amountBase = _chunkYJPWIK5Lcjs.parseUnits.call(void 0, a.amount, decimals);
1467
+ const amountBase = _chunkIQGT65WScjs.parseUnits.call(void 0, a.amount, decimals);
1455
1468
  return { net, asset, decimals, symbol, amountBase, amountFormatted: a.amount, payTo };
1456
1469
  })
1457
1470
  );
@@ -1730,4 +1743,4 @@ function encodeXPaymentHeader(input) {
1730
1743
 
1731
1744
 
1732
1745
 
1733
- exports.CHAINS = CHAINS; exports.ConfirmationTimeoutError = _chunkYJPWIK5Lcjs.ConfirmationTimeoutError; exports.EIP3009_TYPES = EIP3009_TYPES; exports.EXACT_NETWORK_SLUGS = EXACT_NETWORK_SLUGS; exports.InsufficientFundsError = _chunkYJPWIK5Lcjs.InsufficientFundsError; exports.InvalidEnvelopeError = _chunkYJPWIK5Lcjs.InvalidEnvelopeError; exports.MaxRetriesExceededError = _chunkYJPWIK5Lcjs.MaxRetriesExceededError; exports.MissingDriverError = _chunkYJPWIK5Lcjs.MissingDriverError; exports.NoCompatibleAcceptError = _chunkYJPWIK5Lcjs.NoCompatibleAcceptError; exports.NonReplayableBodyError = _chunkYJPWIK5Lcjs.NonReplayableBodyError; exports.PaymentDeclinedError = _chunkYJPWIK5Lcjs.PaymentDeclinedError; exports.PaymentTimeoutError = _chunkYJPWIK5Lcjs.PaymentTimeoutError; exports.PipRailClient = PipRailClient; exports.PipRailError = _chunkYJPWIK5Lcjs.PipRailError; exports.RecipientNotReadyError = _chunkYJPWIK5Lcjs.RecipientNotReadyError; exports.UnknownTokenError = _chunkYJPWIK5Lcjs.UnknownTokenError; exports.UnsupportedNetworkError = _chunkYJPWIK5Lcjs.UnsupportedNetworkError; exports.WrongChainError = _chunkYJPWIK5Lcjs.WrongChainError; exports.WrongFamilyError = _chunkYJPWIK5Lcjs.WrongFamilyError; exports.buildChallengeHeader = buildChallengeHeader; exports.buildExactAuthorization = buildExactAuthorization; exports.buildReceiptHeader = buildReceiptHeader; exports.buildSignatureHeader = buildSignatureHeader; exports.chainIdForExactNetwork = chainIdForExactNetwork; exports.createPaymentGate = createPaymentGate; exports.encodeXPaymentHeader = encodeXPaymentHeader; exports.evaluatePolicy = evaluatePolicy; exports.parseChallenge = parseChallenge; exports.parseExactRequirements = parseExactRequirements; exports.parseReceipt = parseReceipt; exports.parseSignatureHeader = parseSignatureHeader; exports.paymentTools = paymentTools; exports.pickAccept = pickAccept; exports.registerDriver = registerDriver; exports.requirePayment = requirePayment; exports.resolveChain = resolveChain; exports.toInsufficientFundsError = _chunkYJPWIK5Lcjs.toInsufficientFundsError; exports.toInvalidBody = toInvalidBody;
1746
+ exports.CHAINS = CHAINS; exports.ConfirmationTimeoutError = _chunkIQGT65WScjs.ConfirmationTimeoutError; exports.EIP3009_TYPES = EIP3009_TYPES; exports.EXACT_NETWORK_SLUGS = EXACT_NETWORK_SLUGS; exports.InsufficientFundsError = _chunkIQGT65WScjs.InsufficientFundsError; exports.InvalidEnvelopeError = _chunkIQGT65WScjs.InvalidEnvelopeError; exports.MaxRetriesExceededError = _chunkIQGT65WScjs.MaxRetriesExceededError; exports.MissingDriverError = _chunkIQGT65WScjs.MissingDriverError; exports.NoCompatibleAcceptError = _chunkIQGT65WScjs.NoCompatibleAcceptError; exports.NonReplayableBodyError = _chunkIQGT65WScjs.NonReplayableBodyError; exports.PaymentDeclinedError = _chunkIQGT65WScjs.PaymentDeclinedError; exports.PaymentTimeoutError = _chunkIQGT65WScjs.PaymentTimeoutError; exports.PipRailClient = PipRailClient; exports.PipRailError = _chunkIQGT65WScjs.PipRailError; exports.RecipientNotReadyError = _chunkIQGT65WScjs.RecipientNotReadyError; exports.UnknownTokenError = _chunkIQGT65WScjs.UnknownTokenError; exports.UnsupportedNetworkError = _chunkIQGT65WScjs.UnsupportedNetworkError; exports.WrongChainError = _chunkIQGT65WScjs.WrongChainError; exports.WrongFamilyError = _chunkIQGT65WScjs.WrongFamilyError; exports.buildChallengeHeader = buildChallengeHeader; exports.buildExactAuthorization = buildExactAuthorization; exports.buildReceiptHeader = buildReceiptHeader; exports.buildSignatureHeader = buildSignatureHeader; exports.chainIdForExactNetwork = chainIdForExactNetwork; exports.createPaymentGate = createPaymentGate; exports.encodeXPaymentHeader = encodeXPaymentHeader; exports.evaluatePolicy = evaluatePolicy; exports.parseChallenge = parseChallenge; exports.parseExactRequirements = parseExactRequirements; exports.parseReceipt = parseReceipt; exports.parseSignatureHeader = parseSignatureHeader; exports.paymentTools = paymentTools; exports.pickAccept = pickAccept; exports.registerDriver = registerDriver; exports.requirePayment = requirePayment; exports.resolveChain = resolveChain; exports.toInsufficientFundsError = _chunkIQGT65WScjs.toInsufficientFundsError; exports.toInvalidBody = toInvalidBody;
package/dist/index.d.cts CHANGED
@@ -3777,9 +3777,9 @@ declare function resolveChain(input: ChainInput, rpcUrlOverride?: string): Resol
3777
3777
  */
3778
3778
 
3779
3779
  /** The chain families the SDK knows about. */
3780
- type ChainFamily = 'evm' | 'solana' | 'ton' | 'stellar' | 'xrpl' | 'tron' | 'sui' | 'near' | 'aptos';
3780
+ type ChainFamily = 'evm' | 'solana' | 'ton' | 'stellar' | 'xrpl' | 'tron' | 'sui' | 'near' | 'aptos' | 'algorand';
3781
3781
  /** What chain to use: an EVM name/Chain/{id,rpcUrl}, or a non-EVM family name. */
3782
- type ChainSelector = ChainInput | 'solana' | 'ton' | 'stellar' | 'xrpl' | 'tron' | 'sui' | 'near' | 'aptos';
3782
+ type ChainSelector = ChainInput | 'solana' | 'ton' | 'stellar' | 'xrpl' | 'tron' | 'sui' | 'near' | 'aptos' | 'algorand';
3783
3783
  /** An EVM ERC-20 token, by contract address. */
3784
3784
  interface EvmToken {
3785
3785
  address: `0x${string}`;
@@ -3837,6 +3837,12 @@ interface AptosToken {
3837
3837
  decimals: number;
3838
3838
  symbol?: string;
3839
3839
  }
3840
+ /** An Algorand Standard Asset (ASA), by its numeric asset id. */
3841
+ interface AlgorandToken {
3842
+ assetId: number;
3843
+ decimals: number;
3844
+ symbol?: string;
3845
+ }
3840
3846
  /**
3841
3847
  * What to be paid in. Each driver validates the forms it accepts:
3842
3848
  * - 'native' the chain's native coin (ETH, BNB, SOL, TON, XLM, XRP)
@@ -3850,8 +3856,9 @@ interface AptosToken {
3850
3856
  * - SuiToken any coin (Sui)
3851
3857
  * - NearToken any NEP-141 (NEAR)
3852
3858
  * - AptosToken any Fungible Asset (Aptos)
3859
+ * - AlgorandToken any ASA (Algorand)
3853
3860
  */
3854
- type TokenInput = 'native' | (string & {}) | EvmToken | SolanaToken | TonToken | StellarToken | XrplToken | TronToken | SuiToken | NearToken | AptosToken;
3861
+ type TokenInput = 'native' | (string & {}) | EvmToken | SolanaToken | TonToken | StellarToken | XrplToken | TronToken | SuiToken | NearToken | AptosToken | AlgorandToken;
3855
3862
  /** What a driver resolves a TokenInput into. `asset`: 0x | base58 mint | 'native'. */
3856
3863
  interface ResolvedToken {
3857
3864
  asset: string;
package/dist/index.d.ts CHANGED
@@ -3777,9 +3777,9 @@ declare function resolveChain(input: ChainInput, rpcUrlOverride?: string): Resol
3777
3777
  */
3778
3778
 
3779
3779
  /** The chain families the SDK knows about. */
3780
- type ChainFamily = 'evm' | 'solana' | 'ton' | 'stellar' | 'xrpl' | 'tron' | 'sui' | 'near' | 'aptos';
3780
+ type ChainFamily = 'evm' | 'solana' | 'ton' | 'stellar' | 'xrpl' | 'tron' | 'sui' | 'near' | 'aptos' | 'algorand';
3781
3781
  /** What chain to use: an EVM name/Chain/{id,rpcUrl}, or a non-EVM family name. */
3782
- type ChainSelector = ChainInput | 'solana' | 'ton' | 'stellar' | 'xrpl' | 'tron' | 'sui' | 'near' | 'aptos';
3782
+ type ChainSelector = ChainInput | 'solana' | 'ton' | 'stellar' | 'xrpl' | 'tron' | 'sui' | 'near' | 'aptos' | 'algorand';
3783
3783
  /** An EVM ERC-20 token, by contract address. */
3784
3784
  interface EvmToken {
3785
3785
  address: `0x${string}`;
@@ -3837,6 +3837,12 @@ interface AptosToken {
3837
3837
  decimals: number;
3838
3838
  symbol?: string;
3839
3839
  }
3840
+ /** An Algorand Standard Asset (ASA), by its numeric asset id. */
3841
+ interface AlgorandToken {
3842
+ assetId: number;
3843
+ decimals: number;
3844
+ symbol?: string;
3845
+ }
3840
3846
  /**
3841
3847
  * What to be paid in. Each driver validates the forms it accepts:
3842
3848
  * - 'native' the chain's native coin (ETH, BNB, SOL, TON, XLM, XRP)
@@ -3850,8 +3856,9 @@ interface AptosToken {
3850
3856
  * - SuiToken any coin (Sui)
3851
3857
  * - NearToken any NEP-141 (NEAR)
3852
3858
  * - AptosToken any Fungible Asset (Aptos)
3859
+ * - AlgorandToken any ASA (Algorand)
3853
3860
  */
3854
- type TokenInput = 'native' | (string & {}) | EvmToken | SolanaToken | TonToken | StellarToken | XrplToken | TronToken | SuiToken | NearToken | AptosToken;
3861
+ type TokenInput = 'native' | (string & {}) | EvmToken | SolanaToken | TonToken | StellarToken | XrplToken | TronToken | SuiToken | NearToken | AptosToken | AlgorandToken;
3855
3862
  /** What a driver resolves a TokenInput into. `asset`: 0x | base58 mint | 'native'. */
3856
3863
  interface ResolvedToken {
3857
3864
  asset: string;
package/dist/index.js CHANGED
@@ -20,7 +20,7 @@ import {
20
20
  parseUnits,
21
21
  rejectForeignToken,
22
22
  toInsufficientFundsError
23
- } from "./chunk-AGKC3C7Y.js";
23
+ } from "./chunk-QDS6FBZP.js";
24
24
 
25
25
  // src/drivers/registry.ts
26
26
  var byFamily = /* @__PURE__ */ new Map();
@@ -40,6 +40,7 @@ function familyForChain(chain) {
40
40
  if (chain.startsWith("sui")) return "sui";
41
41
  if (chain.startsWith("near")) return "near";
42
42
  if (chain.startsWith("aptos")) return "aptos";
43
+ if (chain.startsWith("algorand")) return "algorand";
43
44
  return "evm";
44
45
  }
45
46
  return "evm";
@@ -738,7 +739,7 @@ var loaders = {
738
739
  solana: async () => {
739
740
  let mod;
740
741
  try {
741
- mod = await import("./solana-37F2PR5H.js");
742
+ mod = await import("./solana-HNRTS4KM.js");
742
743
  } catch (cause) {
743
744
  throw new MissingDriverError(
744
745
  `Solana selected, but its packages aren't installed. Run: npm install @solana/web3.js @solana/spl-token bs58`,
@@ -750,7 +751,7 @@ var loaders = {
750
751
  ton: async () => {
751
752
  let mod;
752
753
  try {
753
- mod = await import("./ton-NIDWF77T.js");
754
+ mod = await import("./ton-3XMIM2FU.js");
754
755
  } catch (cause) {
755
756
  throw new MissingDriverError(
756
757
  `TON selected, but its packages aren't installed. Run: npm install @ton/ton @ton/core @ton/crypto`,
@@ -762,7 +763,7 @@ var loaders = {
762
763
  stellar: async () => {
763
764
  let mod;
764
765
  try {
765
- mod = await import("./stellar-ALOVOMFD.js");
766
+ mod = await import("./stellar-4TDVVJYO.js");
766
767
  } catch (cause) {
767
768
  throw new MissingDriverError(
768
769
  `Stellar selected, but its package isn't installed. Run: npm install @stellar/stellar-sdk`,
@@ -774,7 +775,7 @@ var loaders = {
774
775
  xrpl: async () => {
775
776
  let mod;
776
777
  try {
777
- mod = await import("./xrpl-6ODQS7JR.js");
778
+ mod = await import("./xrpl-ISFG3SSN.js");
778
779
  } catch (cause) {
779
780
  throw new MissingDriverError(
780
781
  `XRPL selected, but its package isn't installed. Run: npm install xrpl`,
@@ -786,7 +787,7 @@ var loaders = {
786
787
  tron: async () => {
787
788
  let mod;
788
789
  try {
789
- mod = await import("./tron-LPMK57H7.js");
790
+ mod = await import("./tron-6D65YJEU.js");
790
791
  } catch (cause) {
791
792
  throw new MissingDriverError(
792
793
  `Tron selected, but its package isn't installed. Run: npm install tronweb`,
@@ -798,7 +799,7 @@ var loaders = {
798
799
  sui: async () => {
799
800
  let mod;
800
801
  try {
801
- mod = await import("./sui-OLC5ID4X.js");
802
+ mod = await import("./sui-ALUTM5GX.js");
802
803
  } catch (cause) {
803
804
  throw new MissingDriverError(
804
805
  `Sui selected, but its package isn't installed. Run: npm install @mysten/sui`,
@@ -810,7 +811,7 @@ var loaders = {
810
811
  near: async () => {
811
812
  let mod;
812
813
  try {
813
- mod = await import("./near-YX3XOASO.js");
814
+ mod = await import("./near-NOJTO4GX.js");
814
815
  } catch (cause) {
815
816
  throw new MissingDriverError(
816
817
  `NEAR selected, but its package isn't installed. Run: npm install near-api-js`,
@@ -822,7 +823,7 @@ var loaders = {
822
823
  aptos: async () => {
823
824
  let mod;
824
825
  try {
825
- mod = await import("./aptos-MQY7KOOJ.js");
826
+ mod = await import("./aptos-AWWSCPDH.js");
826
827
  } catch (cause) {
827
828
  throw new MissingDriverError(
828
829
  `Aptos selected, but its package isn't installed. Run: npm install @aptos-labs/ts-sdk`,
@@ -830,6 +831,18 @@ var loaders = {
830
831
  );
831
832
  }
832
833
  registerDriver(mod.aptosDriver);
834
+ },
835
+ algorand: async () => {
836
+ let mod;
837
+ try {
838
+ mod = await import("./algorand-XJ5OVWQB.js");
839
+ } catch (cause) {
840
+ throw new MissingDriverError(
841
+ `Algorand selected, but its package isn't installed. Run: npm install algosdk`,
842
+ { cause }
843
+ );
844
+ }
845
+ registerDriver(mod.algorandDriver);
833
846
  }
834
847
  };
835
848
  var inFlight = /* @__PURE__ */ new Map();