@coinlist-co/react 0.12.2-rc.bc20f5b → 0.12.2-rc.eea3be6

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 (33) hide show
  1. package/dist/{chunk-C6GF7MDF.js → chunk-335G7ZM5.js} +858 -762
  2. package/dist/chunk-335G7ZM5.js.map +1 -0
  3. package/dist/{chunk-3WW5FLT7.js → chunk-IUAGXUJY.js} +10 -10
  4. package/dist/chunk-IUAGXUJY.js.map +1 -0
  5. package/dist/chunk-MJ6YXZWH.js +22 -0
  6. package/dist/chunk-MJ6YXZWH.js.map +1 -0
  7. package/dist/{chunk-IZJ4JSSC.js → chunk-WBB6P6ZI.js} +152 -203
  8. package/dist/chunk-WBB6P6ZI.js.map +1 -0
  9. package/dist/client/index.d.ts +3129 -5675
  10. package/dist/client/index.js +10574 -10828
  11. package/dist/client/index.js.map +1 -1
  12. package/dist/server/index.d.ts +2 -32
  13. package/dist/server/index.js +6 -4
  14. package/dist/server/index.js.map +1 -1
  15. package/dist/{time-CVZpAkGY.d.cts → time-qZW4aYYp.d.ts} +1922 -3181
  16. package/dist/{token-registry-snapshot-BkwA8KmD.d.ts → token-registry-snapshot-CMrhSBun.d.ts} +22 -58
  17. package/dist/universal/index.d.ts +92 -1067
  18. package/dist/universal/index.js +24 -46
  19. package/package.json +18 -14
  20. package/dist/chunk-3WW5FLT7.js.map +0 -1
  21. package/dist/chunk-C6GF7MDF.js.map +0 -1
  22. package/dist/chunk-IZJ4JSSC.js.map +0 -1
  23. package/dist/client/index.cjs +0 -20460
  24. package/dist/client/index.cjs.map +0 -1
  25. package/dist/client/index.d.cts +0 -8195
  26. package/dist/server/index.cjs +0 -4525
  27. package/dist/server/index.cjs.map +0 -1
  28. package/dist/server/index.d.cts +0 -382
  29. package/dist/time-CVZpAkGY.d.ts +0 -3987
  30. package/dist/token-registry-snapshot-bR14QehS.d.cts +0 -245
  31. package/dist/universal/index.cjs +0 -4562
  32. package/dist/universal/index.cjs.map +0 -1
  33. package/dist/universal/index.d.cts +0 -1362
@@ -291,105 +291,74 @@ function isExpired({
291
291
  return now >= expiresAt - buffer;
292
292
  }
293
293
 
294
- // src/universal/core/shared/blockchain/erc20/abi.ts
295
- var ERC20_ABI = [
296
- {
297
- type: "function",
298
- name: "allowance",
299
- inputs: [
300
- { name: "owner", type: "address" },
301
- { name: "spender", type: "address" }
302
- ],
303
- outputs: [{ name: "", type: "uint256" }],
304
- stateMutability: "view"
305
- },
306
- {
307
- type: "function",
308
- name: "approve",
309
- inputs: [
310
- { name: "spender", type: "address" },
311
- { name: "amount", type: "uint256" }
312
- ],
313
- outputs: [{ name: "", type: "bool" }],
314
- stateMutability: "nonpayable"
315
- },
316
- {
317
- type: "function",
318
- name: "balanceOf",
319
- inputs: [{ name: "account", type: "address" }],
320
- outputs: [{ name: "", type: "uint256" }],
321
- stateMutability: "view"
322
- },
323
- {
324
- type: "function",
325
- name: "decimals",
326
- inputs: [],
327
- outputs: [{ name: "", type: "uint8" }],
328
- stateMutability: "view"
329
- },
330
- {
331
- type: "function",
332
- name: "name",
333
- inputs: [],
334
- outputs: [{ name: "", type: "string" }],
335
- stateMutability: "view"
336
- },
337
- {
338
- type: "function",
339
- name: "symbol",
340
- inputs: [],
341
- outputs: [{ name: "", type: "string" }],
342
- stateMutability: "view"
343
- },
344
- {
345
- type: "function",
346
- name: "totalSupply",
347
- inputs: [],
348
- outputs: [{ name: "", type: "uint256" }],
349
- stateMutability: "view"
350
- },
351
- {
352
- type: "function",
353
- name: "transfer",
354
- inputs: [
355
- { name: "recipient", type: "address" },
356
- { name: "amount", type: "uint256" }
357
- ],
358
- outputs: [{ name: "", type: "bool" }],
359
- stateMutability: "nonpayable"
360
- },
361
- {
362
- type: "function",
363
- name: "transferFrom",
364
- inputs: [
365
- { name: "sender", type: "address" },
366
- { name: "recipient", type: "address" },
367
- { name: "amount", type: "uint256" }
368
- ],
369
- outputs: [{ name: "", type: "bool" }],
370
- stateMutability: "nonpayable"
371
- },
372
- {
373
- type: "event",
374
- name: "Approval",
375
- inputs: [
376
- { name: "owner", type: "address", indexed: true },
377
- { name: "spender", type: "address", indexed: true },
378
- { name: "value", type: "uint256", indexed: false }
379
- ],
380
- anonymous: false
381
- },
382
- {
383
- type: "event",
384
- name: "Transfer",
385
- inputs: [
386
- { name: "from", type: "address", indexed: true },
387
- { name: "to", type: "address", indexed: true },
388
- { name: "value", type: "uint256", indexed: false }
389
- ],
390
- anonymous: false
294
+ // src/universal/types/blockchain/ui.ts
295
+ var FormattedAmountUi = (value) => value;
296
+ var FormattedPercentUi = (value) => value;
297
+ var TxExplorerUrl = (value) => value;
298
+ var ShortenedWalletAddress = (value) => value;
299
+ var FormattedAmountAssetUi = (value) => value;
300
+ var AssetIconUrl = (value) => value;
301
+
302
+ // src/universal/core/shared/blockchain/chain.ts
303
+ import { base, baseSepolia, mainnet, sepolia } from "viem/chains";
304
+ var VIEM_CHAINS = {
305
+ ethereum_mainnet: mainnet,
306
+ ethereum_sepolia: sepolia,
307
+ base_mainnet: base,
308
+ base_sepolia: baseSepolia
309
+ };
310
+ function viemChain(chain) {
311
+ return VIEM_CHAINS[chain];
312
+ }
313
+ function getChainId(chain) {
314
+ return VIEM_CHAINS[chain].id;
315
+ }
316
+ function chainFromId(chainId) {
317
+ const chains = Object.keys(VIEM_CHAINS);
318
+ const chain = chains.find((c) => String(VIEM_CHAINS[c].id) === chainId);
319
+ if (!chain) {
320
+ throw new ValidationError(`Unsupported EIP-155 chain id: "${chainId}"`);
391
321
  }
392
- ];
322
+ return chain;
323
+ }
324
+ function contractOn(contracts, chain) {
325
+ return contracts.find((contract) => contract.chain === chain)?.address ?? null;
326
+ }
327
+ function getNetworkName(chain) {
328
+ switch (chain) {
329
+ case "ethereum_mainnet":
330
+ return "Ethereum";
331
+ case "ethereum_sepolia":
332
+ return "Ethereum Sepolia";
333
+ case "base_mainnet":
334
+ return "Base";
335
+ case "base_sepolia":
336
+ return "Base Sepolia";
337
+ default: {
338
+ const _exhaustive = chain;
339
+ return _exhaustive;
340
+ }
341
+ }
342
+ }
343
+ function txExplorerUrl(chain, txHash) {
344
+ return TxExplorerUrl(`${explorerBaseUrl(chain)}/tx/${txHash}`);
345
+ }
346
+ function explorerBaseUrl(chain) {
347
+ switch (chain) {
348
+ case "ethereum_mainnet":
349
+ return "https://etherscan.io";
350
+ case "ethereum_sepolia":
351
+ return "https://sepolia.etherscan.io";
352
+ case "base_mainnet":
353
+ return "https://basescan.org";
354
+ case "base_sepolia":
355
+ return "https://sepolia-explorer.base.org";
356
+ default: {
357
+ const _exhaustive = chain;
358
+ return _exhaustive;
359
+ }
360
+ }
361
+ }
393
362
 
394
363
  // src/universal/types/blockchain/core.ts
395
364
  var ETHEREUM_CHAINS = {
@@ -453,8 +422,18 @@ var BlockchainAmount = Object.assign(
453
422
  {
454
423
  add: (a, b) => combineAmounts(a, b, (x, y) => x + y),
455
424
  sub: (a, b) => combineAmounts(a, b, (x, y) => x - y),
456
- mul: multiplyAmounts,
457
- div: divideAmounts
425
+ /**
426
+ * `a * b`, in `a`'s decimals - a price times a quantity. Multiplies before
427
+ * it rescales, then truncates towards zero. The exact inverse of `div`.
428
+ */
429
+ mul: (a, b) => multiplyAmounts(a, b),
430
+ /**
431
+ * `a / b`, in `a`'s decimals - a price, a ratio. Rescales before it
432
+ * divides, then truncates towards zero.
433
+ *
434
+ * @throws MathError when `b` is zero.
435
+ */
436
+ div: (a, b) => divideAmounts(a, b)
458
437
  }
459
438
  );
460
439
  function multiplyAmounts(a, b) {
@@ -511,6 +490,36 @@ function blockchainAmountFromRawOrThrow({
511
490
  throw new ValidationError(`${label}: out of uint256 bounds (${value})`);
512
491
  }
513
492
  }
493
+ function positiveAmountFromRawOrThrow({
494
+ label,
495
+ raw,
496
+ decimals,
497
+ reason
498
+ }) {
499
+ const amount = blockchainAmountFromRawOrThrow({ label, raw, decimals });
500
+ if (amount.raw === 0n) {
501
+ throw new ValidationError(
502
+ `${label}: must be greater than zero ("${raw}") - ${reason}`
503
+ );
504
+ }
505
+ return amount;
506
+ }
507
+ function pricePerShare({
508
+ usd,
509
+ shares
510
+ }) {
511
+ const price = BlockchainAmount.div(usd, shares);
512
+ return BlockchainAmount({
513
+ raw: assertPriceFits(price.raw),
514
+ decimals: price.decimals
515
+ });
516
+ }
517
+ function assertPriceFits(raw) {
518
+ if (raw > MAX_UINT_256) {
519
+ throw new MathError(`Price per share: out of uint256 bounds (${raw})`);
520
+ }
521
+ return raw;
522
+ }
514
523
  function parseBlockchainAmount(amount, decimals) {
515
524
  const trimmed = amount.trim();
516
525
  if (trimmed === "") return { valid: false, reason: { type: "empty" } };
@@ -624,10 +633,13 @@ function requiredDate(value, field) {
624
633
  return date;
625
634
  }
626
635
  function dateOrNull(value, field) {
627
- return value === null ? null : requiredDate(value, field);
636
+ return mapNullish(value, (date) => requiredDate(date, field));
628
637
  }
629
638
  function decimalOrNull(value) {
630
- return value === null ? null : DecimalString(value);
639
+ return mapNullish(value, DecimalString);
640
+ }
641
+ function mapNullish(value, parse) {
642
+ return value === null || value === void 0 ? null : parse(value);
631
643
  }
632
644
  function requiredArray(value, field) {
633
645
  if (!Array.isArray(value)) {
@@ -637,6 +649,12 @@ function requiredArray(value, field) {
637
649
  }
638
650
  return value;
639
651
  }
652
+ function txFromWire(wire) {
653
+ return {
654
+ to: EvmContractAddress(wire.to),
655
+ data: HexEncodedTransactionData(wire.data)
656
+ };
657
+ }
640
658
 
641
659
  // src/universal/types/providers/centrifuge/centrifuge.ts
642
660
  var CentrifugeVaultStatus = {
@@ -665,19 +683,16 @@ var CentrifugeVaultStatus = {
665
683
  };
666
684
  var CentrifugeVaultBuyTransaction = {
667
685
  fromDto: (dto) => {
668
- const spendInputAmount = blockchainAmountFromRawOrThrow({
669
- label: "spend_input_amount",
670
- raw: dto.spend_input_amount,
671
- decimals: AssetDecimals(dto.spend_input_decimals)
672
- });
673
- if (spendInputAmount.raw <= 0n) {
674
- throw new ValidationError(
675
- `spend_input_amount: must be greater than zero ("${dto.spend_input_amount}") - a deposit of nothing is not a request`
676
- );
677
- }
678
686
  return {
679
687
  ...parseTransactionCore(dto, "CentrifugeVaultBuyTransaction"),
680
- spendInputAmount
688
+ spendInputAmount: positiveAmountFromRawOrThrow({
689
+ label: "spend_input_amount",
690
+ raw: dto.spend_input_amount,
691
+ decimals: AssetDecimals(dto.spend_input_decimals),
692
+ // Frontline refuses an `amount` of zero, so a zero here is a changed
693
+ // encoding, not a small deposit - and not calldata worth signing.
694
+ reason: "a deposit of nothing is not a request"
695
+ })
681
696
  };
682
697
  }
683
698
  };
@@ -691,72 +706,41 @@ var CentrifugeVaultClaimTransaction = {
691
706
  })
692
707
  })
693
708
  };
694
- var CentrifugeVaultPosition = {
695
- fromDto: (dto) => {
696
- const assetDecimals = AssetDecimals(dto.asset_decimals);
697
- const shareDecimals = AssetDecimals(dto.share_decimals);
698
- const asset = (label, raw) => blockchainAmountFromRawOrThrow({ label, raw, decimals: assetDecimals });
699
- const shares = (label, raw) => blockchainAmountFromRawOrThrow({ label, raw, decimals: shareDecimals });
709
+ var CentrifugeAssets = (amount) => amount;
710
+ var CentrifugeShares = (amount) => amount;
711
+ var CentrifugeDepositPosition = {
712
+ fromContract: (raw, context) => {
713
+ const assets = (label, value) => CentrifugeAssets(contractAmount(label, value, context.assetDecimals));
700
714
  return {
701
- chain: EthereumChain(dto.chain),
702
- symbol: AssetSymbol(dto.symbol),
703
- walletAddress: EvmWalletAddress(dto.wallet_address),
704
- status: dto.status,
705
- requested: asset("requested", dto.requested),
706
- pending: asset("pending", dto.pending),
707
- filledAssets: asset("filled_assets", dto.filled_assets),
708
- earnedShares: shares("earned_shares", dto.earned_shares),
709
- claimedShares: shares("claimed_shares", dto.claimed_shares),
710
- claimableShares: shares("claimable_shares", dto.claimable_shares),
711
- shareBalance: shares("share_balance", dto.share_balance),
712
- averagePrice: decimalOrNull(dto.average_price),
713
- frozen: dto.frozen,
714
- asOf: requiredDate(dto.as_of, "CentrifugeVaultPosition.as_of")
715
+ chain: context.chain,
716
+ proxy: context.proxy,
717
+ walletAddress: context.walletAddress,
718
+ pending: assets("pendingDepositRequest", raw.pendingDepositRequest),
719
+ claimable: assets("claimableDepositRequest", raw.claimableDepositRequest)
715
720
  };
716
721
  }
717
722
  };
718
- var CentrifugeVaultRedeemPosition = {
719
- fromDto: (dto) => ({
720
- chain: EthereumChain(dto.chain),
721
- symbol: AssetSymbol(dto.symbol),
722
- walletAddress: EvmWalletAddress(dto.wallet_address),
723
- status: dto.status,
724
- pending: blockchainAmountFromRawOrThrow({
725
- label: "pending",
726
- raw: dto.pending,
727
- decimals: AssetDecimals(dto.share_decimals)
728
- }),
729
- claimableAssets: blockchainAmountFromRawOrThrow({
730
- label: "claimable_assets",
731
- raw: dto.claimable_assets,
732
- decimals: AssetDecimals(dto.asset_decimals)
733
- }),
734
- frozen: dto.frozen,
735
- asOf: requiredDate(dto.as_of, "CentrifugeVaultRedeemPosition.as_of")
736
- })
723
+ var CentrifugeRedeemPosition = {
724
+ fromContract: (raw, context) => {
725
+ const shares = (label, value) => CentrifugeShares(contractAmount(label, value, context.shareDecimals));
726
+ return {
727
+ chain: context.chain,
728
+ proxy: context.proxy,
729
+ walletAddress: context.walletAddress,
730
+ pending: shares("pendingRedeemRequest", raw.pendingRedeemRequest),
731
+ claimable: shares("claimableRedeemRequest", raw.claimableRedeemRequest)
732
+ };
733
+ }
737
734
  };
738
735
  var CentrifugeVaultLeg = {
739
- /**
740
- * What a claim on the leg would collect: shares for `invest`, the funding
741
- * token for `redeem`.
742
- */
743
- claimable: (leg) => {
744
- switch (leg.direction) {
745
- case "invest":
746
- return leg.position.claimableShares;
747
- case "redeem":
748
- return leg.position.claimableAssets;
749
- default: {
750
- const exhaustive = leg;
751
- return exhaustive;
752
- }
753
- }
754
- },
755
736
  /** Whether the leg has anything queued or anything ready to claim. */
756
- isActive: (leg) => leg.position.pending.raw > 0n || CentrifugeVaultLeg.claimable(leg).raw > 0n
737
+ isActive: (leg) => leg.position.pending.raw > 0n || leg.position.claimable.raw > 0n
757
738
  };
739
+ function contractAmount(label, value, decimals) {
740
+ return BlockchainAmount({ raw: parseUint256(value, label), decimals });
741
+ }
758
742
  var CentrifugeVaultLegId = {
759
- /** Addresses compare case-insensitively: frontline echoes them lower case. */
743
+ /** Addresses compare case-insensitively: a host may pass either case. */
760
744
  of: (leg) => [
761
745
  leg.direction,
762
746
  leg.position.chain,
@@ -792,14 +776,25 @@ function parseOrderability(canOrder, reasons, model) {
792
776
  }
793
777
  function parseTransactionCore(dto, model) {
794
778
  return {
795
- tx: {
796
- to: EvmContractAddress(dto.to),
797
- data: HexEncodedTransactionData(dto.data)
798
- },
779
+ tx: txFromWire(dto),
799
780
  expiresAt: dateOrNull(dto.expires_at, `${model}.expires_at`)
800
781
  };
801
782
  }
802
783
 
784
+ // src/universal/api/frontline/providers/shared/spend-scale.ts
785
+ function assertSpendScaleAgrees({
786
+ published,
787
+ sized,
788
+ trade,
789
+ note
790
+ }) {
791
+ if (published === sized.decimals) return;
792
+ const because = note === void 0 ? "" : ` - ${note}`;
793
+ throw new ValidationError(
794
+ `spend_input_decimals: the ${trade} was priced in ${published} decimals but the order was sized in ${sized.decimals}${because}`
795
+ );
796
+ }
797
+
803
798
  // src/universal/api/frontline/providers/centrifuge/centrifuge.ts
804
799
  async function getCentrifugeVaultStatus(api, params) {
805
800
  const dto = await api.send({
@@ -823,30 +818,12 @@ async function buildCentrifugeVaultBuy(api, params) {
823
818
  },
824
819
  attributes: Attributes.protected()
825
820
  });
826
- if (dto.spend_input_decimals !== params.amount.decimals) {
827
- throw new ValidationError(
828
- `spend_input_decimals: the request was priced in ${dto.spend_input_decimals} decimals but the deposit was sized in ${params.amount.decimals}`
829
- );
830
- }
831
- return CentrifugeVaultBuyTransaction.fromDto(dto);
832
- }
833
- async function getCentrifugeVaultPosition(api, params) {
834
- const dto = await api.send({
835
- method: "GET",
836
- url: "/v1/centrifuge/vault/position",
837
- queryParams: walletFields(params),
838
- attributes: Attributes.protected()
839
- });
840
- return CentrifugeVaultPosition.fromDto(dto);
841
- }
842
- async function getCentrifugeVaultRedeemPosition(api, params) {
843
- const dto = await api.send({
844
- method: "GET",
845
- url: "/v1/centrifuge/vault/redeem-position",
846
- queryParams: walletFields(params),
847
- attributes: Attributes.protected()
821
+ assertSpendScaleAgrees({
822
+ published: dto.spend_input_decimals,
823
+ sized: params.amount,
824
+ trade: "deposit"
848
825
  });
849
- return CentrifugeVaultRedeemPosition.fromDto(dto);
826
+ return CentrifugeVaultBuyTransaction.fromDto(dto);
850
827
  }
851
828
  async function createCentrifugeVaultClaim(api, params) {
852
829
  const dto = await api.send({
@@ -874,12 +851,92 @@ function walletFields(params) {
874
851
  };
875
852
  }
876
853
 
877
- // src/universal/core/shared/observability/log-cause.ts
878
- import {
879
- BaseError,
880
- ContractFunctionExecutionError,
881
- ContractFunctionRevertedError,
882
- HttpRequestError,
854
+ // src/universal/core/providers/checkout/centrifuge/blockchain/abi.ts
855
+ var CENTRIFUGE_PROXY_ABI = [
856
+ {
857
+ type: "function",
858
+ name: "pendingDepositRequest",
859
+ inputs: [{ name: "investor", type: "address" }],
860
+ outputs: [{ name: "", type: "uint256" }],
861
+ stateMutability: "view"
862
+ },
863
+ {
864
+ type: "function",
865
+ name: "claimableDepositRequest",
866
+ inputs: [{ name: "investor", type: "address" }],
867
+ outputs: [{ name: "", type: "uint256" }],
868
+ stateMutability: "view"
869
+ },
870
+ {
871
+ type: "function",
872
+ name: "pendingRedeemRequest",
873
+ inputs: [{ name: "investor", type: "address" }],
874
+ outputs: [{ name: "", type: "uint256" }],
875
+ stateMutability: "view"
876
+ },
877
+ {
878
+ type: "function",
879
+ name: "claimableRedeemRequest",
880
+ inputs: [{ name: "investor", type: "address" }],
881
+ outputs: [{ name: "", type: "uint256" }],
882
+ stateMutability: "view"
883
+ }
884
+ ];
885
+
886
+ // src/universal/api/rpc/providers/centrifuge/position.ts
887
+ async function readCentrifugeDepositPosition(clients, params) {
888
+ const client = clients(params.vault.chain);
889
+ const proxy = proxyOf(params);
890
+ const wallet = params.walletAddress;
891
+ const [pendingDepositRequest, claimableDepositRequest] = await client.multicall({
892
+ allowFailure: false,
893
+ contracts: [
894
+ { ...proxy, functionName: "pendingDepositRequest", args: [wallet] },
895
+ { ...proxy, functionName: "claimableDepositRequest", args: [wallet] }
896
+ ]
897
+ });
898
+ return CentrifugeDepositPosition.fromContract(
899
+ { pendingDepositRequest, claimableDepositRequest },
900
+ contextOf(params)
901
+ );
902
+ }
903
+ async function readCentrifugeRedeemPosition(clients, params) {
904
+ const client = clients(params.vault.chain);
905
+ const proxy = proxyOf(params);
906
+ const wallet = params.walletAddress;
907
+ const [pendingRedeemRequest, claimableRedeemRequest] = await client.multicall(
908
+ {
909
+ allowFailure: false,
910
+ contracts: [
911
+ { ...proxy, functionName: "pendingRedeemRequest", args: [wallet] },
912
+ { ...proxy, functionName: "claimableRedeemRequest", args: [wallet] }
913
+ ]
914
+ }
915
+ );
916
+ return CentrifugeRedeemPosition.fromContract(
917
+ { pendingRedeemRequest, claimableRedeemRequest },
918
+ contextOf(params)
919
+ );
920
+ }
921
+ function proxyOf(params) {
922
+ return { address: params.vault.proxy, abi: CENTRIFUGE_PROXY_ABI };
923
+ }
924
+ function contextOf(params) {
925
+ return {
926
+ chain: params.vault.chain,
927
+ proxy: params.vault.proxy,
928
+ walletAddress: params.walletAddress,
929
+ assetDecimals: params.vault.funding.decimals,
930
+ shareDecimals: params.vault.share.decimals
931
+ };
932
+ }
933
+
934
+ // src/universal/core/shared/observability/log-cause.ts
935
+ import {
936
+ BaseError,
937
+ ContractFunctionExecutionError,
938
+ ContractFunctionRevertedError,
939
+ HttpRequestError,
883
940
  RpcError,
884
941
  SocketClosedError,
885
942
  TimeoutError,
@@ -1057,7 +1114,7 @@ var noopInternalLogger = {
1057
1114
  wrap: (_op, _params, run) => run()
1058
1115
  };
1059
1116
 
1060
- // src/universal/core/checkout/centrifuge/centrifuge-namespace.ts
1117
+ // src/universal/core/providers/checkout/centrifuge/centrifuge-namespace.ts
1061
1118
  var CentrifugeNamespaceImpl = class {
1062
1119
  constructor(ctx) {
1063
1120
  this.ctx = ctx;
@@ -1069,17 +1126,19 @@ var CentrifugeNamespaceImpl = class {
1069
1126
  return getCentrifugeVaultStatus(this.ctx.api, params);
1070
1127
  });
1071
1128
  }
1072
- async getPosition(params) {
1073
- return this.log.wrap("getPosition", params, async () => {
1074
- await this.ctx.ensureUserAuthenticated();
1075
- return getCentrifugeVaultPosition(this.ctx.api, params);
1076
- });
1129
+ async readDepositPosition(params) {
1130
+ return this.log.wrap(
1131
+ "readDepositPosition",
1132
+ params,
1133
+ () => readCentrifugeDepositPosition(this.ctx.rpc, params)
1134
+ );
1077
1135
  }
1078
- async getRedeemPosition(params) {
1079
- return this.log.wrap("getRedeemPosition", params, async () => {
1080
- await this.ctx.ensureUserAuthenticated();
1081
- return getCentrifugeVaultRedeemPosition(this.ctx.api, params);
1082
- });
1136
+ async readRedeemPosition(params) {
1137
+ return this.log.wrap(
1138
+ "readRedeemPosition",
1139
+ params,
1140
+ () => readCentrifugeRedeemPosition(this.ctx.rpc, params)
1141
+ );
1083
1142
  }
1084
1143
  async createClaim(params) {
1085
1144
  return this.log.wrap("createClaim", params, async () => {
@@ -1101,20 +1160,112 @@ var CentrifugeNamespaceImpl = class {
1101
1160
  }
1102
1161
  };
1103
1162
 
1104
- // src/universal/api/pagination.ts
1105
- async function fetchAllPages(fetchPage, baseParams) {
1106
- const items = [];
1107
- let cursor = null;
1108
- do {
1109
- const params = {
1110
- ...baseParams ?? {},
1111
- after: cursor ?? void 0
1112
- };
1113
- const page = await fetchPage(params);
1114
- items.push(...page.data);
1115
- cursor = page.startingAfter;
1116
- } while (cursor);
1117
- return items;
1163
+ // src/universal/core/shared/blockchain/formatters.ts
1164
+ import { formatUnits } from "viem";
1165
+ function shortenAddress(address) {
1166
+ const short = address.length > 10 ? `${address.slice(0, 6)}\u2026${address.slice(-4)}` : address;
1167
+ return ShortenedWalletAddress(short);
1168
+ }
1169
+ function formatAmount(amount, locale, options) {
1170
+ const decimal = formatRawAmount(amount);
1171
+ let [integerPart, fractionPart = ""] = decimal.split(".");
1172
+ const maxFractionDigits = options?.maxFractionDigits;
1173
+ const minFractionDigits = Math.min(
1174
+ options?.minFractionDigits ?? (maxFractionDigits !== void 0 ? maxFractionDigits : 2),
1175
+ maxFractionDigits ?? amount.decimals,
1176
+ amount.decimals
1177
+ );
1178
+ if (maxFractionDigits !== void 0 && fractionPart.length > maxFractionDigits) {
1179
+ ({ integerPart, fractionPart } = roundFractionHalfUp(
1180
+ integerPart,
1181
+ fractionPart,
1182
+ maxFractionDigits
1183
+ ));
1184
+ }
1185
+ const trimmed = fractionPart.replace(/0+$/, "");
1186
+ const fraction = trimmed.padEnd(minFractionDigits, "0");
1187
+ const integerFormatted = BigInt(integerPart).toLocaleString(locale);
1188
+ if (minFractionDigits === 0 && fraction === "") {
1189
+ return FormattedAmountUi(integerFormatted);
1190
+ }
1191
+ const decimalSeparator = new Intl.NumberFormat(locale).formatToParts(1.1).find((p) => p.type === "decimal")?.value ?? ".";
1192
+ return FormattedAmountUi(`${integerFormatted}${decimalSeparator}${fraction}`);
1193
+ }
1194
+ function roundFractionHalfUp(integerPart, fractionPart, maxFractionDigits) {
1195
+ if (fractionPart.length <= maxFractionDigits) {
1196
+ return { integerPart, fractionPart };
1197
+ }
1198
+ if (maxFractionDigits === 0) {
1199
+ const roundUp = fractionPart[0] >= "5";
1200
+ const integer = BigInt(integerPart) + (roundUp ? 1n : 0n);
1201
+ return { integerPart: integer.toString(), fractionPart: "" };
1202
+ }
1203
+ const trimmed = fractionPart.slice(0, maxFractionDigits);
1204
+ if (fractionPart[maxFractionDigits] < "5") {
1205
+ return { integerPart, fractionPart: trimmed };
1206
+ }
1207
+ const digits = trimmed.split("").map((digit) => Number.parseInt(digit, 10));
1208
+ let carry = 1;
1209
+ for (let i = digits.length - 1; i >= 0 && carry > 0; i -= 1) {
1210
+ const sum = digits[i] + carry;
1211
+ if (sum === 10) {
1212
+ digits[i] = 0;
1213
+ carry = 1;
1214
+ } else {
1215
+ digits[i] = sum;
1216
+ carry = 0;
1217
+ }
1218
+ }
1219
+ return {
1220
+ integerPart: carry > 0 ? (BigInt(integerPart) + 1n).toString() : integerPart,
1221
+ fractionPart: digits.join("")
1222
+ };
1223
+ }
1224
+ function formatRawAmount(amount) {
1225
+ return formatUnits(amount.raw, amount.decimals);
1226
+ }
1227
+ function formatCompactAmount(amount, locale) {
1228
+ const value = Number(formatRawAmount(amount));
1229
+ const formatted = new Intl.NumberFormat(locale, {
1230
+ notation: "compact",
1231
+ maximumFractionDigits: 2
1232
+ }).format(value);
1233
+ return FormattedAmountUi(formatted);
1234
+ }
1235
+ function formatBpsAsPercent(bps, locale) {
1236
+ const whole = bps / 100n;
1237
+ const fraction = bps % 100n;
1238
+ const wholeFormatted = whole.toLocaleString(locale);
1239
+ const decimalSeparator = new Intl.NumberFormat(locale).formatToParts(1.1).find((p) => p.type === "decimal")?.value ?? ".";
1240
+ if (fraction === 0n) {
1241
+ return FormattedPercentUi(`${wholeFormatted}%`);
1242
+ }
1243
+ const fractionFormatted = fraction.toString().padStart(2, "0").replace(/0+$/, "");
1244
+ return FormattedPercentUi(
1245
+ `${wholeFormatted}${decimalSeparator}${fractionFormatted}%`
1246
+ );
1247
+ }
1248
+ function usdAmount(amount) {
1249
+ return FormattedAmountAssetUi(`$${amount}`);
1250
+ }
1251
+ function assetAmount(amount, symbol) {
1252
+ return FormattedAmountAssetUi(`${amount} ${symbol}`);
1253
+ }
1254
+ var NA_AMOUNT_ASSET_UI = FormattedAmountAssetUi("-");
1255
+ var SHARE_MAX_FRACTION_DIGITS = AssetDecimals(6);
1256
+ var SHARE_MIN_FRACTION_DIGITS = AssetDecimals(2);
1257
+ function formatShareAmount(amount, locale) {
1258
+ return formatAmount(amount, locale, {
1259
+ maxFractionDigits: SHARE_MAX_FRACTION_DIGITS,
1260
+ minFractionDigits: SHARE_MIN_FRACTION_DIGITS
1261
+ });
1262
+ }
1263
+ var USD_FRACTION_DIGITS = AssetDecimals(2);
1264
+ function formattedUsdPrice(amount, locale) {
1265
+ if (!amount) return NA_AMOUNT_ASSET_UI;
1266
+ return usdAmount(
1267
+ formatAmount(amount, locale, { maxFractionDigits: USD_FRACTION_DIGITS })
1268
+ );
1118
1269
  }
1119
1270
 
1120
1271
  // src/universal/types/pagination.ts
@@ -1300,6 +1451,17 @@ var OfferVaultContract = {
1300
1451
  */
1301
1452
  listFromDto: (dtos) => dtos.filter((dto) => isChain(dto.chain)).map(OfferVaultContract.fromDto)
1302
1453
  };
1454
+ var OfferFundingContract = {
1455
+ fromDto: (dto) => ({
1456
+ chain: Chain(dto.chain),
1457
+ address: EvmContractAddress(dto.address)
1458
+ }),
1459
+ /**
1460
+ * Drops every contract on a chain this SDK does not name, as
1461
+ * {@link OfferVaultContract.listFromDto} does.
1462
+ */
1463
+ listFromDto: (dtos) => dtos.filter((dto) => isChain(dto.chain)).map(OfferFundingContract.fromDto)
1464
+ };
1303
1465
  var OfferDetail = {
1304
1466
  fromDto: (dto) => {
1305
1467
  const fundingAssets = requiredArray(
@@ -1341,7 +1503,15 @@ var OfferDetail = {
1341
1503
  ...base2,
1342
1504
  ...OfferEditorial.fromDto(dto, "OfferDetail"),
1343
1505
  type: dto.type,
1344
- logoUrl: requiredString(dto.logo_url, "OfferDetail.logo_url")
1506
+ logoUrl: requiredString(dto.logo_url, "OfferDetail.logo_url"),
1507
+ // `[]` is fine and a missing key is not, as for `swap_contracts`:
1508
+ // this is the spender a participation's approval names.
1509
+ fundingContracts: OfferFundingContract.listFromDto(
1510
+ requiredArray(
1511
+ dto.funding_contracts,
1512
+ "OfferDetail.funding_contracts"
1513
+ )
1514
+ )
1345
1515
  };
1346
1516
  case "superstate::swap":
1347
1517
  return {
@@ -1419,8 +1589,6 @@ var Milestone = {
1419
1589
 
1420
1590
  // src/universal/types/providers/coin-list/token-sale.ts
1421
1591
  var ParticipationId = (value) => value;
1422
- var Blockchain = (value) => value;
1423
- var WalletAddress = (value) => value;
1424
1592
  var ParticipationsPaginationParams = {
1425
1593
  toQueryParams: (params) => {
1426
1594
  const queryParams = PaginationParams.toQueryParams(params);
@@ -1444,10 +1612,10 @@ var Participation = {
1444
1612
  amount: dto.amount,
1445
1613
  displayAmount: dto.amount_string,
1446
1614
  asset: Asset.fromDto(dto.asset),
1447
- chain: Blockchain(dto.chain),
1615
+ chain: isChain(dto.chain) ? dto.chain : null,
1448
1616
  insertedAt: dto.inserted_at ? new Date(dto.inserted_at) : null,
1449
1617
  updatedAt: dto.updated_at ? new Date(dto.updated_at) : null,
1450
- walletAddress: walletAddress ? WalletAddress(walletAddress) : null
1618
+ walletAddress: walletAddress ? EvmWalletAddress(walletAddress) : null
1451
1619
  };
1452
1620
  }
1453
1621
  };
@@ -1464,6 +1632,22 @@ var CreateParticipationParams = {
1464
1632
  })
1465
1633
  };
1466
1634
 
1635
+ // src/universal/api/pagination.ts
1636
+ async function fetchAllPages(fetchPage, baseParams) {
1637
+ const items = [];
1638
+ let cursor = null;
1639
+ do {
1640
+ const params = {
1641
+ ...baseParams ?? {},
1642
+ after: cursor ?? void 0
1643
+ };
1644
+ const page = await fetchPage(params);
1645
+ items.push(...page.data);
1646
+ cursor = page.startingAfter;
1647
+ } while (cursor);
1648
+ return items;
1649
+ }
1650
+
1467
1651
  // src/universal/api/frontline/providers/coin-list/token-sale.ts
1468
1652
  async function fetchParticipations(api, offerId) {
1469
1653
  return fetchAllPages(
@@ -1498,7 +1682,7 @@ async function createParticipation(api, params) {
1498
1682
  return Participation.fromDto(dto);
1499
1683
  }
1500
1684
 
1501
- // src/universal/core/checkout/coin-list/token-sale-namespace.ts
1685
+ // src/universal/core/providers/checkout/coin-list/token-sale-namespace.ts
1502
1686
  var CoinListTokenSaleNamespaceImpl = class {
1503
1687
  constructor(ctx) {
1504
1688
  this.ctx = ctx;
@@ -1530,193 +1714,19 @@ var CoinListTokenSaleNamespaceImpl = class {
1530
1714
  }
1531
1715
  };
1532
1716
 
1533
- // src/universal/types/blockchain/ui.ts
1534
- var FormattedAmountUi = (value) => value;
1535
- var FormattedPercentUi = (value) => value;
1536
- var TxExplorerUrl = (value) => value;
1537
- var ShortenedWalletAddress = (value) => value;
1538
- var FormattedAmountAssetUi = (value) => value;
1539
- var AssetIconUrl = (value) => value;
1540
-
1541
- // src/universal/core/shared/blockchain/formatters.ts
1542
- import { formatUnits } from "viem";
1543
- function shortenAddress(address) {
1544
- const short = address.length > 10 ? `${address.slice(0, 6)}\u2026${address.slice(-4)}` : address;
1545
- return ShortenedWalletAddress(short);
1546
- }
1547
- function formatAmount(amount, locale, options) {
1548
- const decimal = formatRawAmount(amount);
1549
- let [integerPart, fractionPart = ""] = decimal.split(".");
1550
- const maxFractionDigits = options?.maxFractionDigits;
1551
- const minFractionDigits = Math.min(
1552
- options?.minFractionDigits ?? (maxFractionDigits !== void 0 ? maxFractionDigits : 2),
1553
- maxFractionDigits ?? amount.decimals,
1554
- amount.decimals
1555
- );
1556
- if (maxFractionDigits !== void 0 && fractionPart.length > maxFractionDigits) {
1557
- ({ integerPart, fractionPart } = roundFractionHalfUp(
1558
- integerPart,
1559
- fractionPart,
1560
- maxFractionDigits
1561
- ));
1562
- }
1563
- const trimmed = fractionPart.replace(/0+$/, "");
1564
- const fraction = trimmed.padEnd(minFractionDigits, "0");
1565
- const integerFormatted = BigInt(integerPart).toLocaleString(locale);
1566
- if (minFractionDigits === 0 && fraction === "") {
1567
- return FormattedAmountUi(integerFormatted);
1568
- }
1569
- const decimalSeparator = new Intl.NumberFormat(locale).formatToParts(1.1).find((p) => p.type === "decimal")?.value ?? ".";
1570
- return FormattedAmountUi(`${integerFormatted}${decimalSeparator}${fraction}`);
1571
- }
1572
- function roundFractionHalfUp(integerPart, fractionPart, maxFractionDigits) {
1573
- if (fractionPart.length <= maxFractionDigits) {
1574
- return { integerPart, fractionPart };
1575
- }
1576
- if (maxFractionDigits === 0) {
1577
- const roundUp = fractionPart[0] >= "5";
1578
- const integer = BigInt(integerPart) + (roundUp ? 1n : 0n);
1579
- return { integerPart: integer.toString(), fractionPart: "" };
1580
- }
1581
- const trimmed = fractionPart.slice(0, maxFractionDigits);
1582
- if (fractionPart[maxFractionDigits] < "5") {
1583
- return { integerPart, fractionPart: trimmed };
1584
- }
1585
- const digits = trimmed.split("").map((digit) => Number.parseInt(digit, 10));
1586
- let carry = 1;
1587
- for (let i = digits.length - 1; i >= 0 && carry > 0; i -= 1) {
1588
- const sum = digits[i] + carry;
1589
- if (sum === 10) {
1590
- digits[i] = 0;
1591
- carry = 1;
1592
- } else {
1593
- digits[i] = sum;
1594
- carry = 0;
1595
- }
1596
- }
1597
- return {
1598
- integerPart: carry > 0 ? (BigInt(integerPart) + 1n).toString() : integerPart,
1599
- fractionPart: digits.join("")
1600
- };
1601
- }
1602
- function formatRawAmount(amount) {
1603
- return formatUnits(amount.raw, amount.decimals);
1604
- }
1605
- function formatCompactAmount(amount, locale) {
1606
- const value = Number(formatRawAmount(amount));
1607
- const formatted = new Intl.NumberFormat(locale, {
1608
- notation: "compact",
1609
- maximumFractionDigits: 2
1610
- }).format(value);
1611
- return FormattedAmountUi(formatted);
1612
- }
1613
- function formatBpsAsPercent(bps, locale) {
1614
- const whole = bps / 100n;
1615
- const fraction = bps % 100n;
1616
- const wholeFormatted = whole.toLocaleString(locale);
1617
- const decimalSeparator = new Intl.NumberFormat(locale).formatToParts(1.1).find((p) => p.type === "decimal")?.value ?? ".";
1618
- if (fraction === 0n) {
1619
- return FormattedPercentUi(`${wholeFormatted}%`);
1620
- }
1621
- const fractionFormatted = fraction.toString().padStart(2, "0").replace(/0+$/, "");
1622
- return FormattedPercentUi(
1623
- `${wholeFormatted}${decimalSeparator}${fractionFormatted}%`
1624
- );
1625
- }
1626
- function usdAmount(amount) {
1627
- return FormattedAmountAssetUi(`$${amount}`);
1628
- }
1629
- function assetAmount(amount, symbol) {
1630
- return FormattedAmountAssetUi(`${amount} ${symbol}`);
1631
- }
1632
- var NA_AMOUNT_ASSET_UI = FormattedAmountAssetUi("-");
1633
- var SHARE_MAX_FRACTION_DIGITS = AssetDecimals(6);
1634
- var SHARE_MIN_FRACTION_DIGITS = AssetDecimals(2);
1635
- function formatShareAmount(amount, locale) {
1636
- return formatAmount(amount, locale, {
1637
- maxFractionDigits: SHARE_MAX_FRACTION_DIGITS,
1638
- minFractionDigits: SHARE_MIN_FRACTION_DIGITS
1639
- });
1640
- }
1641
- var USD_FRACTION_DIGITS = AssetDecimals(2);
1642
- function formattedUsdPrice(amount, locale) {
1643
- if (!amount) return NA_AMOUNT_ASSET_UI;
1644
- return usdAmount(
1645
- formatAmount(amount, locale, { maxFractionDigits: USD_FRACTION_DIGITS })
1646
- );
1647
- }
1648
-
1649
- // src/universal/core/shared/blockchain/chain.ts
1650
- import { base, baseSepolia, mainnet, sepolia } from "viem/chains";
1651
- var VIEM_CHAINS = {
1652
- ethereum_mainnet: mainnet,
1653
- ethereum_sepolia: sepolia,
1654
- base_mainnet: base,
1655
- base_sepolia: baseSepolia
1656
- };
1657
- function viemChain(chain) {
1658
- return VIEM_CHAINS[chain];
1659
- }
1660
- function getChainId(chain) {
1661
- return VIEM_CHAINS[chain].id;
1662
- }
1663
- function chainFromId(chainId) {
1664
- const chains = Object.keys(VIEM_CHAINS);
1665
- const chain = chains.find((c) => String(VIEM_CHAINS[c].id) === chainId);
1666
- if (!chain) {
1667
- throw new ValidationError(`Unsupported EIP-155 chain id: "${chainId}"`);
1668
- }
1669
- return chain;
1670
- }
1671
- function getNetworkName(chain) {
1672
- switch (chain) {
1673
- case "ethereum_mainnet":
1674
- return "Ethereum";
1675
- case "ethereum_sepolia":
1676
- return "Ethereum Sepolia";
1677
- case "base_mainnet":
1678
- return "Base";
1679
- case "base_sepolia":
1680
- return "Base Sepolia";
1681
- default: {
1682
- const _exhaustive = chain;
1683
- return _exhaustive;
1684
- }
1685
- }
1686
- }
1687
- function txExplorerUrl(chain, txHash) {
1688
- return TxExplorerUrl(`${explorerBaseUrl(chain)}/tx/${txHash}`);
1689
- }
1690
- function explorerBaseUrl(chain) {
1691
- switch (chain) {
1692
- case "ethereum_mainnet":
1693
- return "https://etherscan.io";
1694
- case "ethereum_sepolia":
1695
- return "https://sepolia.etherscan.io";
1696
- case "base_mainnet":
1697
- return "https://basescan.org";
1698
- case "base_sepolia":
1699
- return "https://sepolia-explorer.base.org";
1700
- default: {
1701
- const _exhaustive = chain;
1702
- return _exhaustive;
1703
- }
1704
- }
1705
- }
1706
-
1707
- // src/universal/types/providers/ondo/ondo.ts
1708
- var OndoTradingStatus = {
1709
- fromDto: (dto) => {
1710
- if (!dto.tradable) return { type: "not-tradable", side: dto.side };
1711
- return {
1712
- type: "tradable",
1713
- side: dto.side,
1714
- grossMaxTokens: decimalOrNull(dto.gross_max_tokens),
1715
- grossMaxNotionalValue: decimalOrNull(dto.gross_max_notional_value),
1716
- grossMaxActiveNotionalValue: decimalOrNull(
1717
- dto.gross_max_active_notional_value
1718
- )
1719
- };
1717
+ // src/universal/types/providers/ondo/ondo.ts
1718
+ var OndoTradingStatus = {
1719
+ fromDto: (dto) => {
1720
+ if (!dto.tradable) return { type: "not-tradable", side: dto.side };
1721
+ return {
1722
+ type: "tradable",
1723
+ side: dto.side,
1724
+ grossMaxTokens: decimalOrNull(dto.gross_max_tokens),
1725
+ grossMaxNotionalValue: decimalOrNull(dto.gross_max_notional_value),
1726
+ grossMaxActiveNotionalValue: decimalOrNull(
1727
+ dto.gross_max_active_notional_value
1728
+ )
1729
+ };
1720
1730
  }
1721
1731
  };
1722
1732
  var OndoQuote = {
@@ -1758,7 +1768,7 @@ var OndoBuyTransaction = {
1758
1768
  raw: dto.notional_value,
1759
1769
  decimals: spendDecimals
1760
1770
  }),
1761
- receiveOutputAmount: parsePositiveAmount({
1771
+ receiveOutputAmount: positiveAmountFromRawOrThrow({
1762
1772
  label: "receive_output_amount",
1763
1773
  raw: dto.receive_output_amount,
1764
1774
  decimals: outputDecimals,
@@ -1777,7 +1787,7 @@ var OndoSellTransaction = {
1777
1787
  fromDto: (dto) => {
1778
1788
  const spendDecimals = AssetDecimals(dto.spend_input_decimals);
1779
1789
  const outputDecimals = AssetDecimals(dto.receive_output_decimals);
1780
- const expectedQuantity = parsePositiveAmount({
1790
+ const expectedQuantity = positiveAmountFromRawOrThrow({
1781
1791
  label: "expected_quantity",
1782
1792
  raw: dto.expected_quantity,
1783
1793
  decimals: outputDecimals,
@@ -1811,12 +1821,12 @@ var OndoSellTransaction = {
1811
1821
  };
1812
1822
  function parseSwapCore(dto, spendDecimals) {
1813
1823
  return {
1814
- tx: {
1815
- to: EvmContractAddress(dto.to),
1816
- data: HexEncodedTransactionData(dto.data)
1817
- },
1818
- expiresAt: parseExpiresAt(dto.expires_at),
1819
- spendInputAmount: parsePositiveAmount({
1824
+ tx: txFromWire(dto),
1825
+ // A transaction whose expiry cannot be read is not safely fillable - the
1826
+ // deadline is encoded in the calldata either way, so broadcasting against
1827
+ // an unknown one only spends gas on a revert.
1828
+ expiresAt: requiredDate(dto.expires_at, "expires_at"),
1829
+ spendInputAmount: positiveAmountFromRawOrThrow({
1820
1830
  label: "spend_input_amount",
1821
1831
  raw: dto.spend_input_amount,
1822
1832
  decimals: spendDecimals,
@@ -1834,7 +1844,7 @@ function parseSwapCore(dto, spendDecimals) {
1834
1844
  };
1835
1845
  }
1836
1846
  function parseMinimumQuantity(raw, decimals, expectedQuantity) {
1837
- const amount = parsePositiveAmount({
1847
+ const amount = positiveAmountFromRawOrThrow({
1838
1848
  label: "minimum_quantity",
1839
1849
  raw,
1840
1850
  decimals,
@@ -1847,27 +1857,6 @@ function parseMinimumQuantity(raw, decimals, expectedQuantity) {
1847
1857
  }
1848
1858
  return amount;
1849
1859
  }
1850
- function parsePositiveAmount({
1851
- label,
1852
- raw,
1853
- decimals,
1854
- reason
1855
- }) {
1856
- const amount = blockchainAmountFromRawOrThrow({ label, raw, decimals });
1857
- if (amount.raw <= 0n) {
1858
- throw new ValidationError(
1859
- `${label}: must be greater than zero ("${raw}") - ${reason}`
1860
- );
1861
- }
1862
- return amount;
1863
- }
1864
- function parseExpiresAt(value) {
1865
- const date = new Date(value);
1866
- if (Number.isNaN(date.getTime())) {
1867
- throw new ValidationError(`expires_at: not a date ("${value}")`);
1868
- }
1869
- return date;
1870
- }
1871
1860
 
1872
1861
  // src/universal/api/frontline/providers/ondo/ondo.ts
1873
1862
  async function getOndoTradingStatus(api, params) {
@@ -1933,18 +1922,6 @@ function swapBody(params) {
1933
1922
  amount: params.amount.raw.toString()
1934
1923
  };
1935
1924
  }
1936
- function assertSpendScaleAgrees({
1937
- published,
1938
- sized,
1939
- trade,
1940
- note
1941
- }) {
1942
- if (published === sized.decimals) return;
1943
- const because = note === void 0 ? "" : ` - ${note}`;
1944
- throw new ValidationError(
1945
- `spend_input_decimals: the ${trade} was priced in ${published} decimals but the order was sized in ${sized.decimals}${because}`
1946
- );
1947
- }
1948
1925
  function sizeParam(params) {
1949
1926
  const tokenAmount = "tokenAmount" in params ? params.tokenAmount : void 0;
1950
1927
  const notionalValue = "notionalValue" in params ? params.notionalValue : void 0;
@@ -1964,7 +1941,7 @@ function sizeParam(params) {
1964
1941
  return { notional_value: notionalValue };
1965
1942
  }
1966
1943
 
1967
- // src/universal/core/checkout/ondo/ondo-namespace.ts
1944
+ // src/universal/core/providers/checkout/ondo/ondo-namespace.ts
1968
1945
  var OndoNamespaceImpl = class {
1969
1946
  constructor(ctx) {
1970
1947
  this.ctx = ctx;
@@ -1996,7 +1973,101 @@ var OndoNamespaceImpl = class {
1996
1973
  }
1997
1974
  };
1998
1975
 
1999
- // src/universal/core/checkout/superstate/blockchain/abi.ts
1976
+ // src/universal/types/providers/superstate/swap.ts
1977
+ var SwapPreview = {
1978
+ /** Maps the contract's `Preview { input, fee, output }` struct. */
1979
+ fromContract: (preview) => ({
1980
+ inputAmount: parseUint256(preview.input, "SwapPreview.input"),
1981
+ fee: parseUint256(preview.fee, "SwapPreview.fee"),
1982
+ outputAmount: parseUint256(preview.output, "SwapPreview.output")
1983
+ })
1984
+ };
1985
+ var PauseFlags = (value) => value;
1986
+ var SwapStatus = {
1987
+ /**
1988
+ * Maps the contract's `Status { uint32 flags; State state }` struct, where
1989
+ * `State` is `0 = Active | 1 = Paused | 2 = Stopped`.
1990
+ *
1991
+ * `flags` is carried onto the `paused` arm only. On the other two the
1992
+ * contract sets it to a self-identifying marker rather than to information -
1993
+ * so repeating it would invite a caller to read meaning into a constant.
1994
+ *
1995
+ * @throws ValidationError on a `state` outside the enum. A contract that has
1996
+ * grown a fourth state is one the SDK does not model, and guessing `active`
1997
+ * would let a halted swap read as a live one.
1998
+ */
1999
+ fromContract: (status) => {
2000
+ switch (status.state) {
2001
+ case 0:
2002
+ return { state: "active" };
2003
+ case 1:
2004
+ return { state: "paused", pausedLevels: PauseFlags(status.flags) };
2005
+ case 2:
2006
+ return { state: "stopped" };
2007
+ default:
2008
+ throw new ValidationError(
2009
+ `SwapStatus.state: unknown contract state (${status.state})`
2010
+ );
2011
+ }
2012
+ }
2013
+ };
2014
+ var AllowWalletResponse = {
2015
+ fromDto: (dto) => {
2016
+ switch (dto.action) {
2017
+ case "broadcast_transaction":
2018
+ return {
2019
+ action: "broadcast_transaction",
2020
+ tx: txFromWire(dto)
2021
+ };
2022
+ case "none":
2023
+ return {
2024
+ action: "none",
2025
+ alreadyAllowed: dto.already_allowed
2026
+ };
2027
+ default: {
2028
+ const _exhaustive = dto;
2029
+ return _exhaustive;
2030
+ }
2031
+ }
2032
+ }
2033
+ };
2034
+
2035
+ // src/universal/core/providers/checkout/superstate/blockchain/quote.ts
2036
+ var SwapQuote = {
2037
+ /**
2038
+ * Assembles a {@link SwapQuote} from a raw contract {@link SwapPreview}. The
2039
+ * input and fee are denominated in the input token; the output in the output
2040
+ * token.
2041
+ */
2042
+ fromPreview: (preview, inputDecimals, outputDecimals) => ({
2043
+ inputTokenAmount: BlockchainAmount({
2044
+ raw: preview.inputAmount,
2045
+ decimals: inputDecimals
2046
+ }),
2047
+ fee: BlockchainAmount({ raw: preview.fee, decimals: inputDecimals }),
2048
+ outputTokenAmount: BlockchainAmount({
2049
+ raw: preview.outputAmount,
2050
+ decimals: outputDecimals
2051
+ })
2052
+ })
2053
+ };
2054
+
2055
+ // src/universal/api/frontline/providers/superstate/swap.ts
2056
+ async function allowWallet(api, params) {
2057
+ const dto = await api.send({
2058
+ method: "POST",
2059
+ url: `/v1/offers/${encodeURIComponent(params.offerId)}/allow-wallet`,
2060
+ body: {
2061
+ wallet_address: params.walletAddress,
2062
+ chain: params.chain,
2063
+ signature: params.signature
2064
+ },
2065
+ attributes: Attributes.protected()
2066
+ });
2067
+ return AllowWalletResponse.fromDto(dto);
2068
+ }
2069
+
2070
+ // src/universal/core/providers/checkout/superstate/blockchain/abi.ts
2000
2071
  var SUPERSTATE_SWAP_ABI = [
2001
2072
  {
2002
2073
  type: "function",
@@ -2868,80 +2939,105 @@ var SUPERSTATE_SWAP_ABI = [
2868
2939
  }
2869
2940
  ];
2870
2941
 
2871
- // src/universal/types/providers/superstate/swap.ts
2872
- var SwapPreview = {
2873
- /** Maps the contract's `Preview { input, fee, output }` struct. */
2874
- fromContract: (preview) => ({
2875
- inputAmount: parseUint256(preview.input, "SwapPreview.input"),
2876
- fee: parseUint256(preview.fee, "SwapPreview.fee"),
2877
- outputAmount: parseUint256(preview.output, "SwapPreview.output")
2878
- })
2879
- };
2880
- var PauseFlags = (value) => value;
2881
- var SwapStatus = {
2882
- /**
2883
- * Maps the contract's `Status { uint32 flags; State state }` struct, where
2884
- * `State` is `0 = Active | 1 = Paused | 2 = Stopped`.
2885
- *
2886
- * `flags` is carried onto the `paused` arm only. On the other two the
2887
- * contract sets it to a self-identifying marker rather than to information -
2888
- * so repeating it would invite a caller to read meaning into a constant.
2889
- *
2890
- * @throws ValidationError on a `state` outside the enum. A contract that has
2891
- * grown a fourth state is one the SDK does not model, and guessing `active`
2892
- * would let a halted swap read as a live one.
2893
- */
2894
- fromContract: (status) => {
2895
- switch (status.state) {
2896
- case 0:
2897
- return { state: "active" };
2898
- case 1:
2899
- return { state: "paused", pausedLevels: PauseFlags(status.flags) };
2900
- case 2:
2901
- return { state: "stopped" };
2902
- default:
2903
- throw new ValidationError(
2904
- `SwapStatus.state: unknown contract state (${status.state})`
2905
- );
2906
- }
2907
- }
2908
- };
2909
- var AllowWalletResponse = {
2910
- fromDto: (dto) => {
2911
- switch (dto.action) {
2912
- case "broadcast_transaction":
2913
- return {
2914
- action: "broadcast_transaction",
2915
- to: EvmContractAddress(dto.to),
2916
- data: HexEncodedTransactionData(dto.data)
2917
- };
2918
- case "none":
2919
- return {
2920
- action: "none",
2921
- alreadyAllowed: dto.already_allowed
2922
- };
2923
- default: {
2924
- const _exhaustive = dto;
2925
- return _exhaustive;
2926
- }
2927
- }
2942
+ // src/universal/core/shared/blockchain/erc20/abi.ts
2943
+ var ERC20_ABI = [
2944
+ {
2945
+ type: "function",
2946
+ name: "allowance",
2947
+ inputs: [
2948
+ { name: "owner", type: "address" },
2949
+ { name: "spender", type: "address" }
2950
+ ],
2951
+ outputs: [{ name: "", type: "uint256" }],
2952
+ stateMutability: "view"
2953
+ },
2954
+ {
2955
+ type: "function",
2956
+ name: "approve",
2957
+ inputs: [
2958
+ { name: "spender", type: "address" },
2959
+ { name: "amount", type: "uint256" }
2960
+ ],
2961
+ outputs: [{ name: "", type: "bool" }],
2962
+ stateMutability: "nonpayable"
2963
+ },
2964
+ {
2965
+ type: "function",
2966
+ name: "balanceOf",
2967
+ inputs: [{ name: "account", type: "address" }],
2968
+ outputs: [{ name: "", type: "uint256" }],
2969
+ stateMutability: "view"
2970
+ },
2971
+ {
2972
+ type: "function",
2973
+ name: "decimals",
2974
+ inputs: [],
2975
+ outputs: [{ name: "", type: "uint8" }],
2976
+ stateMutability: "view"
2977
+ },
2978
+ {
2979
+ type: "function",
2980
+ name: "name",
2981
+ inputs: [],
2982
+ outputs: [{ name: "", type: "string" }],
2983
+ stateMutability: "view"
2984
+ },
2985
+ {
2986
+ type: "function",
2987
+ name: "symbol",
2988
+ inputs: [],
2989
+ outputs: [{ name: "", type: "string" }],
2990
+ stateMutability: "view"
2991
+ },
2992
+ {
2993
+ type: "function",
2994
+ name: "totalSupply",
2995
+ inputs: [],
2996
+ outputs: [{ name: "", type: "uint256" }],
2997
+ stateMutability: "view"
2998
+ },
2999
+ {
3000
+ type: "function",
3001
+ name: "transfer",
3002
+ inputs: [
3003
+ { name: "recipient", type: "address" },
3004
+ { name: "amount", type: "uint256" }
3005
+ ],
3006
+ outputs: [{ name: "", type: "bool" }],
3007
+ stateMutability: "nonpayable"
3008
+ },
3009
+ {
3010
+ type: "function",
3011
+ name: "transferFrom",
3012
+ inputs: [
3013
+ { name: "sender", type: "address" },
3014
+ { name: "recipient", type: "address" },
3015
+ { name: "amount", type: "uint256" }
3016
+ ],
3017
+ outputs: [{ name: "", type: "bool" }],
3018
+ stateMutability: "nonpayable"
3019
+ },
3020
+ {
3021
+ type: "event",
3022
+ name: "Approval",
3023
+ inputs: [
3024
+ { name: "owner", type: "address", indexed: true },
3025
+ { name: "spender", type: "address", indexed: true },
3026
+ { name: "value", type: "uint256", indexed: false }
3027
+ ],
3028
+ anonymous: false
3029
+ },
3030
+ {
3031
+ type: "event",
3032
+ name: "Transfer",
3033
+ inputs: [
3034
+ { name: "from", type: "address", indexed: true },
3035
+ { name: "to", type: "address", indexed: true },
3036
+ { name: "value", type: "uint256", indexed: false }
3037
+ ],
3038
+ anonymous: false
2928
3039
  }
2929
- };
2930
-
2931
- // src/universal/api/frontline/providers/superstate/swap.ts
2932
- async function allowWallet(api, params) {
2933
- const dto = await api.send({
2934
- method: "POST",
2935
- url: `/v1/offers/${encodeURIComponent(params.offerId)}/allow-wallet`,
2936
- body: {
2937
- wallet_address: params.walletAddress,
2938
- chain: params.chain,
2939
- signature: params.signature
2940
- },
2941
- attributes: Attributes.protected()
2942
- });
2943
- return AllowWalletResponse.fromDto(dto);
2944
- }
3040
+ ];
2945
3041
 
2946
3042
  // src/universal/api/rpc/providers/superstate/swap.ts
2947
3043
  async function getSwapAuthorization(clients, params) {
@@ -2992,7 +3088,7 @@ async function getSwapOutputToken(clients, params) {
2992
3088
  };
2993
3089
  }
2994
3090
 
2995
- // src/universal/core/checkout/superstate/swap-namespace.ts
3091
+ // src/universal/core/providers/checkout/superstate/swap-namespace.ts
2996
3092
  var SuperstateSwapNamespaceImpl = class {
2997
3093
  constructor(ctx) {
2998
3094
  this.ctx = ctx;
@@ -3012,6 +3108,20 @@ var SuperstateSwapNamespaceImpl = class {
3012
3108
  async () => getSwapPreview(this.ctx.rpc, params)
3013
3109
  );
3014
3110
  }
3111
+ async getQuote(params) {
3112
+ return this.log.wrap("getQuote", params, async () => {
3113
+ const { amount, outputTokenDecimals, ...ref } = params;
3114
+ const preview = await getSwapPreview(this.ctx.rpc, {
3115
+ ...ref,
3116
+ amount: amount.raw
3117
+ });
3118
+ return SwapQuote.fromPreview(
3119
+ preview,
3120
+ amount.decimals,
3121
+ outputTokenDecimals
3122
+ );
3123
+ });
3124
+ }
3015
3125
  async getStatus(params) {
3016
3126
  return this.log.wrap(
3017
3127
  "getStatus",
@@ -3156,54 +3266,195 @@ async function fetchRequirementStatuses(api, offerId) {
3156
3266
  url: `/v1/offers/${offerId}/requirements/statuses`,
3157
3267
  attributes: Attributes.protected()
3158
3268
  });
3159
- return RequirementStatusInfo.fromStatusesDto(response);
3269
+ return RequirementStatusInfo.fromStatusesDto(response);
3270
+ }
3271
+
3272
+ // src/universal/core/requirements/requirements-namespace.ts
3273
+ var RequirementsNamespaceImpl = class {
3274
+ constructor(ctx) {
3275
+ this.ctx = ctx;
3276
+ this.log = internalLogger(ctx.logger, "REQUIREMENTS");
3277
+ }
3278
+ async forOffer(offerId) {
3279
+ return this.log.wrap("forOffer", offerId, async () => {
3280
+ await this.ctx.ensureUserAuthenticated();
3281
+ return fetchOfferRequirements(
3282
+ this.ctx.api,
3283
+ offerId,
3284
+ void 0
3285
+ );
3286
+ });
3287
+ }
3288
+ async statuses(offerId) {
3289
+ return this.log.wrap("statuses", offerId, async () => {
3290
+ await this.ctx.ensureUserAuthenticated();
3291
+ return fetchRequirementStatuses(this.ctx.api, offerId);
3292
+ });
3293
+ }
3294
+ async createKycToken(params) {
3295
+ return this.log.wrap("createKycToken", params, async () => {
3296
+ await this.ctx.ensureUserAuthenticated();
3297
+ return createKycToken(
3298
+ this.ctx.api,
3299
+ params?.levelName,
3300
+ params?.reset
3301
+ );
3302
+ });
3303
+ }
3304
+ async getPii() {
3305
+ return this.log.wrap("getPii", void 0, async () => {
3306
+ await this.ctx.ensureUserAuthenticated();
3307
+ return fetchPii(this.ctx.api);
3308
+ });
3309
+ }
3310
+ async submitDocument(params) {
3311
+ return this.log.wrap("submitDocument", params, async () => {
3312
+ await this.ctx.ensureUserAuthenticated();
3313
+ return submitDocument(
3314
+ this.ctx.api,
3315
+ params.documentType,
3316
+ params.fields
3317
+ );
3318
+ });
3319
+ }
3320
+ };
3321
+
3322
+ // src/universal/types/offer-option-address.ts
3323
+ var OfferOptionAddressId = (value) => value;
3324
+ var OfferOptionAddress = {
3325
+ /** Maps the API DTO into the SDK offer-option-address domain model. */
3326
+ fromDto: (dto) => ({
3327
+ id: OfferOptionAddressId(dto.id),
3328
+ offerOptionId: OfferOptionId(dto.offer_option_id),
3329
+ address: EvmWalletAddress(dto.address),
3330
+ protocol: dto.protocol,
3331
+ createdAt: new Date(dto.created_at)
3332
+ })
3333
+ };
3334
+ var ConnectExternalWalletParams = {
3335
+ /** Maps connect-wallet params into the API DTO payload. */
3336
+ toDto: (params) => ({
3337
+ offer_option_id: params.offerOptionId,
3338
+ wallet_address: params.walletAddress,
3339
+ chain: params.chain,
3340
+ signature: params.signature
3341
+ })
3342
+ };
3343
+
3344
+ // src/universal/types/wallet-ownership-challenge.ts
3345
+ var WalletOwnershipChallenge = {
3346
+ /** Maps the API DTO into the SDK wallet-ownership-challenge domain model. */
3347
+ fromDto: (dto) => ({
3348
+ message: dto.message,
3349
+ expiresAt: new Date(dto.expires_at)
3350
+ })
3351
+ };
3352
+ var CreateWalletOwnershipChallengeParams = {
3353
+ /**
3354
+ * Maps challenge-request params into the API DTO payload. The discriminated
3355
+ * union guarantees SIWE fields are present exactly when `challengeType` is
3356
+ * `siwe`, so the mapping narrows on the discriminant.
3357
+ */
3358
+ toDto: (params) => {
3359
+ switch (params.challengeType) {
3360
+ case "plain":
3361
+ return {
3362
+ wallet_address: params.walletAddress,
3363
+ chain: params.chain,
3364
+ challenge_type: "plain"
3365
+ };
3366
+ case "siwe":
3367
+ return {
3368
+ wallet_address: params.walletAddress,
3369
+ chain: params.chain,
3370
+ challenge_type: "siwe",
3371
+ domain: params.domain,
3372
+ uri: params.uri,
3373
+ statement: params.statement
3374
+ };
3375
+ default: {
3376
+ const _exhaustive = params;
3377
+ return _exhaustive;
3378
+ }
3379
+ }
3380
+ }
3381
+ };
3382
+
3383
+ // src/universal/api/frontline/wallet-connect.ts
3384
+ async function createWalletOwnershipChallenge(api, params) {
3385
+ const dto = await api.send({
3386
+ method: "POST",
3387
+ url: "/v1/wallet-ownership",
3388
+ body: CreateWalletOwnershipChallengeParams.toDto(params),
3389
+ attributes: Attributes.protected()
3390
+ });
3391
+ return WalletOwnershipChallenge.fromDto(dto);
3392
+ }
3393
+ async function connectExternalWallet(api, params) {
3394
+ const dto = await api.send({
3395
+ method: "POST",
3396
+ url: `/v1/offers/${params.offerId}/addresses`,
3397
+ body: ConnectExternalWalletParams.toDto(params),
3398
+ attributes: Attributes.protected()
3399
+ });
3400
+ return OfferOptionAddress.fromDto(dto);
3401
+ }
3402
+ async function listOptionAddresses(api, offerId, offerOptionId) {
3403
+ const { data } = await api.send({
3404
+ method: "GET",
3405
+ url: `/v1/offers/${offerId}/addresses`,
3406
+ queryParams: { offer_option_id: offerOptionId },
3407
+ attributes: Attributes.protected()
3408
+ });
3409
+ return data.map(OfferOptionAddress.fromDto);
3410
+ }
3411
+ async function removeOptionAddress(api, offerId, addressId) {
3412
+ const dto = await api.send({
3413
+ method: "DELETE",
3414
+ url: `/v1/offers/${offerId}/addresses/${addressId}`,
3415
+ attributes: Attributes.protected()
3416
+ });
3417
+ return OfferOptionAddress.fromDto(dto);
3160
3418
  }
3161
3419
 
3162
- // src/universal/core/requirements/requirements-namespace.ts
3163
- var RequirementsNamespaceImpl = class {
3420
+ // src/universal/core/wallets/wallets-namespace.ts
3421
+ var WalletsNamespaceImpl = class {
3164
3422
  constructor(ctx) {
3165
3423
  this.ctx = ctx;
3166
- this.log = internalLogger(ctx.logger, "REQUIREMENTS");
3424
+ this.log = internalLogger(ctx.logger, "WALLETS");
3167
3425
  }
3168
- async forOffer(offerId) {
3169
- return this.log.wrap("forOffer", offerId, async () => {
3426
+ async createOwnershipChallenge(params) {
3427
+ return this.log.wrap("createOwnershipChallenge", params, async () => {
3170
3428
  await this.ctx.ensureUserAuthenticated();
3171
- return fetchOfferRequirements(
3429
+ return createWalletOwnershipChallenge(
3172
3430
  this.ctx.api,
3173
- offerId,
3174
- void 0
3431
+ params
3175
3432
  );
3176
3433
  });
3177
3434
  }
3178
- async statuses(offerId) {
3179
- return this.log.wrap("statuses", offerId, async () => {
3435
+ async connectExternal(params) {
3436
+ return this.log.wrap("connectExternal", params, async () => {
3180
3437
  await this.ctx.ensureUserAuthenticated();
3181
- return fetchRequirementStatuses(this.ctx.api, offerId);
3438
+ return connectExternalWallet(this.ctx.api, params);
3182
3439
  });
3183
3440
  }
3184
- async createKycToken(params) {
3185
- return this.log.wrap("createKycToken", params, async () => {
3441
+ async list(params) {
3442
+ return this.log.wrap("list", params, async () => {
3186
3443
  await this.ctx.ensureUserAuthenticated();
3187
- return createKycToken(
3444
+ return listOptionAddresses(
3188
3445
  this.ctx.api,
3189
- params?.levelName,
3190
- params?.reset
3446
+ params.offerId,
3447
+ params.offerOptionId
3191
3448
  );
3192
3449
  });
3193
3450
  }
3194
- async getPii() {
3195
- return this.log.wrap("getPii", void 0, async () => {
3196
- await this.ctx.ensureUserAuthenticated();
3197
- return fetchPii(this.ctx.api);
3198
- });
3199
- }
3200
- async submitDocument(params) {
3201
- return this.log.wrap("submitDocument", params, async () => {
3451
+ async remove(params) {
3452
+ return this.log.wrap("remove", params, async () => {
3202
3453
  await this.ctx.ensureUserAuthenticated();
3203
- return submitDocument(
3454
+ return removeOptionAddress(
3204
3455
  this.ctx.api,
3205
- params.documentType,
3206
- params.fields
3456
+ params.offerId,
3457
+ params.addressId
3207
3458
  );
3208
3459
  });
3209
3460
  }
@@ -3631,163 +3882,6 @@ var TokensNamespaceImpl = class {
3631
3882
  }
3632
3883
  };
3633
3884
 
3634
- // src/universal/types/offer-option-address.ts
3635
- var OfferOptionAddressId = (value) => value;
3636
- var OfferOptionAddress = {
3637
- /** Maps the API DTO into the SDK offer-option-address domain model. */
3638
- fromDto: (dto) => ({
3639
- id: OfferOptionAddressId(dto.id),
3640
- offerOptionId: OfferOptionId(dto.offer_option_id),
3641
- address: EvmWalletAddress(dto.address),
3642
- protocol: dto.protocol,
3643
- createdAt: new Date(dto.created_at)
3644
- })
3645
- };
3646
- var ConnectExternalWalletParams = {
3647
- /** Maps connect-wallet params into the API DTO payload. */
3648
- toDto: (params) => ({
3649
- offer_option_id: params.offerOptionId,
3650
- wallet_address: params.walletAddress,
3651
- chain: params.chain,
3652
- signature: params.signature
3653
- })
3654
- };
3655
-
3656
- // src/universal/types/wallet-ownership-challenge.ts
3657
- var WalletOwnershipChallenge = {
3658
- /** Maps the API DTO into the SDK wallet-ownership-challenge domain model. */
3659
- fromDto: (dto) => ({
3660
- message: dto.message,
3661
- expiresAt: new Date(dto.expires_at)
3662
- })
3663
- };
3664
- var CreateWalletOwnershipChallengeParams = {
3665
- /**
3666
- * Maps challenge-request params into the API DTO payload. The discriminated
3667
- * union guarantees SIWE fields are present exactly when `challengeType` is
3668
- * `siwe`, so the mapping narrows on the discriminant.
3669
- */
3670
- toDto: (params) => {
3671
- switch (params.challengeType) {
3672
- case "plain":
3673
- return {
3674
- wallet_address: params.walletAddress,
3675
- chain: params.chain,
3676
- challenge_type: "plain"
3677
- };
3678
- case "siwe":
3679
- return {
3680
- wallet_address: params.walletAddress,
3681
- chain: params.chain,
3682
- challenge_type: "siwe",
3683
- domain: params.domain,
3684
- uri: params.uri,
3685
- statement: params.statement
3686
- };
3687
- default: {
3688
- const _exhaustive = params;
3689
- return _exhaustive;
3690
- }
3691
- }
3692
- }
3693
- };
3694
-
3695
- // src/universal/api/frontline/wallet-connect.ts
3696
- async function createWalletOwnershipChallenge(api, params) {
3697
- const dto = await api.send({
3698
- method: "POST",
3699
- url: "/v1/wallet-ownership",
3700
- body: CreateWalletOwnershipChallengeParams.toDto(params),
3701
- attributes: Attributes.protected()
3702
- });
3703
- return WalletOwnershipChallenge.fromDto(dto);
3704
- }
3705
- async function connectExternalWallet(api, params) {
3706
- const dto = await api.send({
3707
- method: "POST",
3708
- url: `/v1/offers/${params.offerId}/addresses`,
3709
- body: ConnectExternalWalletParams.toDto(params),
3710
- attributes: Attributes.protected()
3711
- });
3712
- return OfferOptionAddress.fromDto(dto);
3713
- }
3714
- async function listOptionAddresses(api, offerId, offerOptionId) {
3715
- const { data } = await api.send({
3716
- method: "GET",
3717
- url: `/v1/offers/${offerId}/addresses`,
3718
- queryParams: { offer_option_id: offerOptionId },
3719
- attributes: Attributes.protected()
3720
- });
3721
- return data.map(OfferOptionAddress.fromDto);
3722
- }
3723
- async function removeOptionAddress(api, offerId, addressId) {
3724
- const dto = await api.send({
3725
- method: "DELETE",
3726
- url: `/v1/offers/${offerId}/addresses/${addressId}`,
3727
- attributes: Attributes.protected()
3728
- });
3729
- return OfferOptionAddress.fromDto(dto);
3730
- }
3731
-
3732
- // src/universal/core/wallets/wallets-namespace.ts
3733
- var WalletsNamespaceImpl = class {
3734
- constructor(ctx) {
3735
- this.ctx = ctx;
3736
- this.log = internalLogger(ctx.logger, "WALLETS");
3737
- }
3738
- async createOwnershipChallenge(params) {
3739
- return this.log.wrap("createOwnershipChallenge", params, async () => {
3740
- await this.ctx.ensureUserAuthenticated();
3741
- return createWalletOwnershipChallenge(
3742
- this.ctx.api,
3743
- params
3744
- );
3745
- });
3746
- }
3747
- async connectExternal(params) {
3748
- return this.log.wrap("connectExternal", params, async () => {
3749
- await this.ctx.ensureUserAuthenticated();
3750
- return connectExternalWallet(this.ctx.api, params);
3751
- });
3752
- }
3753
- async list(params) {
3754
- return this.log.wrap("list", params, async () => {
3755
- await this.ctx.ensureUserAuthenticated();
3756
- return listOptionAddresses(
3757
- this.ctx.api,
3758
- params.offerId,
3759
- params.offerOptionId
3760
- );
3761
- });
3762
- }
3763
- async remove(params) {
3764
- return this.log.wrap("remove", params, async () => {
3765
- await this.ctx.ensureUserAuthenticated();
3766
- return removeOptionAddress(
3767
- this.ctx.api,
3768
- params.offerId,
3769
- params.addressId
3770
- );
3771
- });
3772
- }
3773
- };
3774
-
3775
- // src/universal/types/oauth-session.ts
3776
- var ClientCredentialsOAuth = (value) => value;
3777
- var OAuthRefreshToken = (value) => value;
3778
- var OAuthSession = {
3779
- fromDto: (dto) => {
3780
- const expiresAt = new Date(Date.now() + dto.expires_in * 1e3);
3781
- return {
3782
- accessToken: {
3783
- value: dto.access_token,
3784
- expiresAt
3785
- },
3786
- ...dto.refresh_token != null && dto.refresh_token !== "" ? { refreshToken: OAuthRefreshToken(dto.refresh_token) } : void 0
3787
- };
3788
- }
3789
- };
3790
-
3791
3885
  // src/universal/api/frontline/offers.ts
3792
3886
  async function fetchOffers(api, clientCreds) {
3793
3887
  return fetchAllPages((params) => fetchOffersPage(api, params, clientCreds));
@@ -3844,6 +3938,7 @@ export {
3844
3938
  ValidationError,
3845
3939
  InvariantError,
3846
3940
  MathError,
3941
+ classifyLogCause,
3847
3942
  describeErrorUnredacted,
3848
3943
  internalLogger,
3849
3944
  HttpClient,
@@ -3852,6 +3947,18 @@ export {
3852
3947
  Seconds,
3853
3948
  isExpired,
3854
3949
  ERC20_ABI,
3950
+ FormattedAmountUi,
3951
+ FormattedPercentUi,
3952
+ TxExplorerUrl,
3953
+ ShortenedWalletAddress,
3954
+ FormattedAmountAssetUi,
3955
+ AssetIconUrl,
3956
+ viemChain,
3957
+ getChainId,
3958
+ chainFromId,
3959
+ contractOn,
3960
+ getNetworkName,
3961
+ txExplorerUrl,
3855
3962
  ETHEREUM_CHAINS,
3856
3963
  EthereumChain,
3857
3964
  SOLANA_CHAINS,
@@ -3874,17 +3981,30 @@ export {
3874
3981
  KnownAssetSymbol,
3875
3982
  Bps,
3876
3983
  blockchainAmountFromRawOrThrow,
3984
+ positiveAmountFromRawOrThrow,
3985
+ pricePerShare,
3877
3986
  parseBlockchainAmount,
3878
3987
  CentrifugeVaultStatus,
3879
3988
  CentrifugeVaultBuyTransaction,
3880
3989
  CentrifugeVaultClaimTransaction,
3881
- CentrifugeVaultPosition,
3882
- CentrifugeVaultRedeemPosition,
3990
+ CentrifugeAssets,
3991
+ CentrifugeShares,
3992
+ CentrifugeDepositPosition,
3993
+ CentrifugeRedeemPosition,
3883
3994
  CentrifugeVaultLeg,
3884
3995
  CentrifugeVaultLegId,
3885
3996
  CentrifugeVaultClaimProceedsTransaction,
3886
3997
  CentrifugeNamespaceImpl,
3887
- fetchAllPages,
3998
+ shortenAddress,
3999
+ formatAmount,
4000
+ formatRawAmount,
4001
+ formatCompactAmount,
4002
+ formatBpsAsPercent,
4003
+ usdAmount,
4004
+ assetAmount,
4005
+ NA_AMOUNT_ASSET_UI,
4006
+ formatShareAmount,
4007
+ formattedUsdPrice,
3888
4008
  Cursor,
3889
4009
  PaginatedResponse,
3890
4010
  PaginationParams,
@@ -3904,6 +4024,7 @@ export {
3904
4024
  OfferOptionSlug,
3905
4025
  OfferSwapContract,
3906
4026
  OfferVaultContract,
4027
+ OfferFundingContract,
3907
4028
  OfferDetail,
3908
4029
  OfferOption,
3909
4030
  FaqItem,
@@ -3911,33 +4032,10 @@ export {
3911
4032
  TermItem,
3912
4033
  Milestone,
3913
4034
  ParticipationId,
3914
- Blockchain,
3915
- WalletAddress,
3916
4035
  ParticipationsPaginationParams,
3917
4036
  Participation,
3918
4037
  CreateParticipationParams,
3919
4038
  CoinListTokenSaleNamespaceImpl,
3920
- FormattedAmountUi,
3921
- FormattedPercentUi,
3922
- TxExplorerUrl,
3923
- ShortenedWalletAddress,
3924
- FormattedAmountAssetUi,
3925
- AssetIconUrl,
3926
- shortenAddress,
3927
- formatAmount,
3928
- formatRawAmount,
3929
- formatCompactAmount,
3930
- formatBpsAsPercent,
3931
- usdAmount,
3932
- assetAmount,
3933
- NA_AMOUNT_ASSET_UI,
3934
- formatShareAmount,
3935
- formattedUsdPrice,
3936
- viemChain,
3937
- getChainId,
3938
- chainFromId,
3939
- getNetworkName,
3940
- txExplorerUrl,
3941
4039
  OndoTradingStatus,
3942
4040
  OndoQuote,
3943
4041
  OndoBuyTransaction,
@@ -3948,10 +4046,8 @@ export {
3948
4046
  PauseFlags,
3949
4047
  SwapStatus,
3950
4048
  AllowWalletResponse,
4049
+ SwapQuote,
3951
4050
  SuperstateSwapNamespaceImpl,
3952
- fetchOffers,
3953
- fetchOffersPage,
3954
- fetchOfferDetails,
3955
4051
  DocumentSubmission,
3956
4052
  KycToken,
3957
4053
  Iso2CountryCode,
@@ -3963,19 +4059,19 @@ export {
3963
4059
  RequirementStatusInfo,
3964
4060
  fetchOfferRequirements,
3965
4061
  RequirementsNamespaceImpl,
3966
- Erc20NamespaceImpl,
3967
- TokenLogoUrl,
3968
- TokenLogo,
3969
- TokenMetadata,
3970
- TokensNamespaceImpl,
3971
4062
  OfferOptionAddressId,
3972
4063
  OfferOptionAddress,
3973
4064
  ConnectExternalWalletParams,
3974
4065
  WalletOwnershipChallenge,
3975
4066
  CreateWalletOwnershipChallengeParams,
3976
4067
  WalletsNamespaceImpl,
3977
- ClientCredentialsOAuth,
3978
- OAuthRefreshToken,
3979
- OAuthSession
4068
+ fetchOffers,
4069
+ fetchOffersPage,
4070
+ fetchOfferDetails,
4071
+ Erc20NamespaceImpl,
4072
+ TokenLogoUrl,
4073
+ TokenLogo,
4074
+ TokenMetadata,
4075
+ TokensNamespaceImpl
3980
4076
  };
3981
- //# sourceMappingURL=chunk-C6GF7MDF.js.map
4077
+ //# sourceMappingURL=chunk-335G7ZM5.js.map