@coinlist-co/react 0.12.2-rc.8a0d02a → 0.12.2-rc.99b1bd5

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 (34) hide show
  1. package/README.md +10 -0
  2. package/dist/{chunk-IZJ4JSSC.js → chunk-IQAJ3L25.js} +173 -253
  3. package/dist/chunk-IQAJ3L25.js.map +1 -0
  4. package/dist/{chunk-3WW5FLT7.js → chunk-J45AY2FX.js} +10 -10
  5. package/dist/chunk-J45AY2FX.js.map +1 -0
  6. package/dist/{chunk-C6GF7MDF.js → chunk-M2TURNJH.js} +876 -800
  7. package/dist/chunk-M2TURNJH.js.map +1 -0
  8. package/dist/chunk-MJ6YXZWH.js +22 -0
  9. package/dist/chunk-MJ6YXZWH.js.map +1 -0
  10. package/dist/client/index.d.ts +2836 -5619
  11. package/dist/client/index.js +7157 -8250
  12. package/dist/client/index.js.map +1 -1
  13. package/dist/server/index.d.ts +2 -32
  14. package/dist/server/index.js +6 -4
  15. package/dist/server/index.js.map +1 -1
  16. package/dist/{time-CVZpAkGY.d.cts → time-DkU7jivQ.d.ts} +1907 -3185
  17. package/dist/{token-registry-snapshot-BkwA8KmD.d.ts → token-registry-snapshot-D0OWXMe4.d.ts} +22 -58
  18. package/dist/universal/index.d.ts +81 -1067
  19. package/dist/universal/index.js +22 -46
  20. package/package.json +18 -14
  21. package/dist/chunk-3WW5FLT7.js.map +0 -1
  22. package/dist/chunk-C6GF7MDF.js.map +0 -1
  23. package/dist/chunk-IZJ4JSSC.js.map +0 -1
  24. package/dist/client/index.cjs +0 -20460
  25. package/dist/client/index.cjs.map +0 -1
  26. package/dist/client/index.d.cts +0 -8195
  27. package/dist/server/index.cjs +0 -4525
  28. package/dist/server/index.cjs.map +0 -1
  29. package/dist/server/index.d.cts +0 -382
  30. package/dist/time-CVZpAkGY.d.ts +0 -3987
  31. package/dist/token-registry-snapshot-bR14QehS.d.cts +0 -245
  32. package/dist/universal/index.cjs +0 -4562
  33. package/dist/universal/index.cjs.map +0 -1
  34. 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
@@ -1419,8 +1570,6 @@ var Milestone = {
1419
1570
 
1420
1571
  // src/universal/types/providers/coin-list/token-sale.ts
1421
1572
  var ParticipationId = (value) => value;
1422
- var Blockchain = (value) => value;
1423
- var WalletAddress = (value) => value;
1424
1573
  var ParticipationsPaginationParams = {
1425
1574
  toQueryParams: (params) => {
1426
1575
  const queryParams = PaginationParams.toQueryParams(params);
@@ -1444,10 +1593,10 @@ var Participation = {
1444
1593
  amount: dto.amount,
1445
1594
  displayAmount: dto.amount_string,
1446
1595
  asset: Asset.fromDto(dto.asset),
1447
- chain: Blockchain(dto.chain),
1596
+ chain: isChain(dto.chain) ? dto.chain : null,
1448
1597
  insertedAt: dto.inserted_at ? new Date(dto.inserted_at) : null,
1449
1598
  updatedAt: dto.updated_at ? new Date(dto.updated_at) : null,
1450
- walletAddress: walletAddress ? WalletAddress(walletAddress) : null
1599
+ walletAddress: walletAddress ? EvmWalletAddress(walletAddress) : null
1451
1600
  };
1452
1601
  }
1453
1602
  };
@@ -1464,6 +1613,22 @@ var CreateParticipationParams = {
1464
1613
  })
1465
1614
  };
1466
1615
 
1616
+ // src/universal/api/pagination.ts
1617
+ async function fetchAllPages(fetchPage, baseParams) {
1618
+ const items = [];
1619
+ let cursor = null;
1620
+ do {
1621
+ const params = {
1622
+ ...baseParams ?? {},
1623
+ after: cursor ?? void 0
1624
+ };
1625
+ const page = await fetchPage(params);
1626
+ items.push(...page.data);
1627
+ cursor = page.startingAfter;
1628
+ } while (cursor);
1629
+ return items;
1630
+ }
1631
+
1467
1632
  // src/universal/api/frontline/providers/coin-list/token-sale.ts
1468
1633
  async function fetchParticipations(api, offerId) {
1469
1634
  return fetchAllPages(
@@ -1498,7 +1663,7 @@ async function createParticipation(api, params) {
1498
1663
  return Participation.fromDto(dto);
1499
1664
  }
1500
1665
 
1501
- // src/universal/core/checkout/coin-list/token-sale-namespace.ts
1666
+ // src/universal/core/providers/checkout/coin-list/token-sale-namespace.ts
1502
1667
  var CoinListTokenSaleNamespaceImpl = class {
1503
1668
  constructor(ctx) {
1504
1669
  this.ctx = ctx;
@@ -1530,215 +1695,41 @@ var CoinListTokenSaleNamespaceImpl = class {
1530
1695
  }
1531
1696
  };
1532
1697
 
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
- ));
1698
+ // src/universal/types/providers/ondo/ondo.ts
1699
+ var OndoTradingStatus = {
1700
+ fromDto: (dto) => {
1701
+ if (!dto.tradable) return { type: "not-tradable", side: dto.side };
1702
+ return {
1703
+ type: "tradable",
1704
+ side: dto.side,
1705
+ grossMaxTokens: decimalOrNull(dto.gross_max_tokens),
1706
+ grossMaxNotionalValue: decimalOrNull(dto.gross_max_notional_value),
1707
+ grossMaxActiveNotionalValue: decimalOrNull(
1708
+ dto.gross_max_active_notional_value
1709
+ )
1710
+ };
1562
1711
  }
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
- };
1720
- }
1721
- };
1722
- var OndoQuote = {
1723
- fromDto: (dto) => {
1724
- const assetDecimals = AssetDecimals(dto.asset_decimals);
1725
- return {
1726
- chain: chainFromId(dto.chain_id),
1727
- ticker: Ticker(dto.ticker),
1728
- assetAddress: EvmContractAddress(dto.asset_address),
1729
- asset: {
1730
- name: dto.ticker,
1731
- symbol: AssetSymbol(dto.symbol),
1732
- decimals: assetDecimals
1733
- },
1734
- side: dto.side,
1735
- tokenBaseUnits: blockchainAmountFromRawOrThrow({
1736
- label: "tokenBaseUnits",
1737
- raw: dto.token_base_units,
1738
- decimals: assetDecimals
1739
- }),
1740
- price: DecimalString(dto.price)
1741
- };
1712
+ };
1713
+ var OndoQuote = {
1714
+ fromDto: (dto) => {
1715
+ const assetDecimals = AssetDecimals(dto.asset_decimals);
1716
+ return {
1717
+ chain: chainFromId(dto.chain_id),
1718
+ ticker: Ticker(dto.ticker),
1719
+ assetAddress: EvmContractAddress(dto.asset_address),
1720
+ asset: {
1721
+ name: dto.ticker,
1722
+ symbol: AssetSymbol(dto.symbol),
1723
+ decimals: assetDecimals
1724
+ },
1725
+ side: dto.side,
1726
+ tokenBaseUnits: blockchainAmountFromRawOrThrow({
1727
+ label: "tokenBaseUnits",
1728
+ raw: dto.token_base_units,
1729
+ decimals: assetDecimals
1730
+ }),
1731
+ price: DecimalString(dto.price)
1732
+ };
1742
1733
  }
1743
1734
  };
1744
1735
  var OndoBuyTransaction = {
@@ -1758,7 +1749,7 @@ var OndoBuyTransaction = {
1758
1749
  raw: dto.notional_value,
1759
1750
  decimals: spendDecimals
1760
1751
  }),
1761
- receiveOutputAmount: parsePositiveAmount({
1752
+ receiveOutputAmount: positiveAmountFromRawOrThrow({
1762
1753
  label: "receive_output_amount",
1763
1754
  raw: dto.receive_output_amount,
1764
1755
  decimals: outputDecimals,
@@ -1777,7 +1768,7 @@ var OndoSellTransaction = {
1777
1768
  fromDto: (dto) => {
1778
1769
  const spendDecimals = AssetDecimals(dto.spend_input_decimals);
1779
1770
  const outputDecimals = AssetDecimals(dto.receive_output_decimals);
1780
- const expectedQuantity = parsePositiveAmount({
1771
+ const expectedQuantity = positiveAmountFromRawOrThrow({
1781
1772
  label: "expected_quantity",
1782
1773
  raw: dto.expected_quantity,
1783
1774
  decimals: outputDecimals,
@@ -1811,12 +1802,12 @@ var OndoSellTransaction = {
1811
1802
  };
1812
1803
  function parseSwapCore(dto, spendDecimals) {
1813
1804
  return {
1814
- tx: {
1815
- to: EvmContractAddress(dto.to),
1816
- data: HexEncodedTransactionData(dto.data)
1817
- },
1818
- expiresAt: parseExpiresAt(dto.expires_at),
1819
- spendInputAmount: parsePositiveAmount({
1805
+ tx: txFromWire(dto),
1806
+ // A transaction whose expiry cannot be read is not safely fillable - the
1807
+ // deadline is encoded in the calldata either way, so broadcasting against
1808
+ // an unknown one only spends gas on a revert.
1809
+ expiresAt: requiredDate(dto.expires_at, "expires_at"),
1810
+ spendInputAmount: positiveAmountFromRawOrThrow({
1820
1811
  label: "spend_input_amount",
1821
1812
  raw: dto.spend_input_amount,
1822
1813
  decimals: spendDecimals,
@@ -1834,7 +1825,7 @@ function parseSwapCore(dto, spendDecimals) {
1834
1825
  };
1835
1826
  }
1836
1827
  function parseMinimumQuantity(raw, decimals, expectedQuantity) {
1837
- const amount = parsePositiveAmount({
1828
+ const amount = positiveAmountFromRawOrThrow({
1838
1829
  label: "minimum_quantity",
1839
1830
  raw,
1840
1831
  decimals,
@@ -1847,27 +1838,6 @@ function parseMinimumQuantity(raw, decimals, expectedQuantity) {
1847
1838
  }
1848
1839
  return amount;
1849
1840
  }
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
1841
 
1872
1842
  // src/universal/api/frontline/providers/ondo/ondo.ts
1873
1843
  async function getOndoTradingStatus(api, params) {
@@ -1933,18 +1903,6 @@ function swapBody(params) {
1933
1903
  amount: params.amount.raw.toString()
1934
1904
  };
1935
1905
  }
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
1906
  function sizeParam(params) {
1949
1907
  const tokenAmount = "tokenAmount" in params ? params.tokenAmount : void 0;
1950
1908
  const notionalValue = "notionalValue" in params ? params.notionalValue : void 0;
@@ -1964,7 +1922,7 @@ function sizeParam(params) {
1964
1922
  return { notional_value: notionalValue };
1965
1923
  }
1966
1924
 
1967
- // src/universal/core/checkout/ondo/ondo-namespace.ts
1925
+ // src/universal/core/providers/checkout/ondo/ondo-namespace.ts
1968
1926
  var OndoNamespaceImpl = class {
1969
1927
  constructor(ctx) {
1970
1928
  this.ctx = ctx;
@@ -1996,7 +1954,101 @@ var OndoNamespaceImpl = class {
1996
1954
  }
1997
1955
  };
1998
1956
 
1999
- // src/universal/core/checkout/superstate/blockchain/abi.ts
1957
+ // src/universal/types/providers/superstate/swap.ts
1958
+ var SwapPreview = {
1959
+ /** Maps the contract's `Preview { input, fee, output }` struct. */
1960
+ fromContract: (preview) => ({
1961
+ inputAmount: parseUint256(preview.input, "SwapPreview.input"),
1962
+ fee: parseUint256(preview.fee, "SwapPreview.fee"),
1963
+ outputAmount: parseUint256(preview.output, "SwapPreview.output")
1964
+ })
1965
+ };
1966
+ var PauseFlags = (value) => value;
1967
+ var SwapStatus = {
1968
+ /**
1969
+ * Maps the contract's `Status { uint32 flags; State state }` struct, where
1970
+ * `State` is `0 = Active | 1 = Paused | 2 = Stopped`.
1971
+ *
1972
+ * `flags` is carried onto the `paused` arm only. On the other two the
1973
+ * contract sets it to a self-identifying marker rather than to information -
1974
+ * so repeating it would invite a caller to read meaning into a constant.
1975
+ *
1976
+ * @throws ValidationError on a `state` outside the enum. A contract that has
1977
+ * grown a fourth state is one the SDK does not model, and guessing `active`
1978
+ * would let a halted swap read as a live one.
1979
+ */
1980
+ fromContract: (status) => {
1981
+ switch (status.state) {
1982
+ case 0:
1983
+ return { state: "active" };
1984
+ case 1:
1985
+ return { state: "paused", pausedLevels: PauseFlags(status.flags) };
1986
+ case 2:
1987
+ return { state: "stopped" };
1988
+ default:
1989
+ throw new ValidationError(
1990
+ `SwapStatus.state: unknown contract state (${status.state})`
1991
+ );
1992
+ }
1993
+ }
1994
+ };
1995
+ var AllowWalletResponse = {
1996
+ fromDto: (dto) => {
1997
+ switch (dto.action) {
1998
+ case "broadcast_transaction":
1999
+ return {
2000
+ action: "broadcast_transaction",
2001
+ tx: txFromWire(dto)
2002
+ };
2003
+ case "none":
2004
+ return {
2005
+ action: "none",
2006
+ alreadyAllowed: dto.already_allowed
2007
+ };
2008
+ default: {
2009
+ const _exhaustive = dto;
2010
+ return _exhaustive;
2011
+ }
2012
+ }
2013
+ }
2014
+ };
2015
+
2016
+ // src/universal/core/providers/checkout/superstate/blockchain/quote.ts
2017
+ var SwapQuote = {
2018
+ /**
2019
+ * Assembles a {@link SwapQuote} from a raw contract {@link SwapPreview}. The
2020
+ * input and fee are denominated in the input token; the output in the output
2021
+ * token.
2022
+ */
2023
+ fromPreview: (preview, inputDecimals, outputDecimals) => ({
2024
+ inputTokenAmount: BlockchainAmount({
2025
+ raw: preview.inputAmount,
2026
+ decimals: inputDecimals
2027
+ }),
2028
+ fee: BlockchainAmount({ raw: preview.fee, decimals: inputDecimals }),
2029
+ outputTokenAmount: BlockchainAmount({
2030
+ raw: preview.outputAmount,
2031
+ decimals: outputDecimals
2032
+ })
2033
+ })
2034
+ };
2035
+
2036
+ // src/universal/api/frontline/providers/superstate/swap.ts
2037
+ async function allowWallet(api, params) {
2038
+ const dto = await api.send({
2039
+ method: "POST",
2040
+ url: `/v1/offers/${encodeURIComponent(params.offerId)}/allow-wallet`,
2041
+ body: {
2042
+ wallet_address: params.walletAddress,
2043
+ chain: params.chain,
2044
+ signature: params.signature
2045
+ },
2046
+ attributes: Attributes.protected()
2047
+ });
2048
+ return AllowWalletResponse.fromDto(dto);
2049
+ }
2050
+
2051
+ // src/universal/core/providers/checkout/superstate/blockchain/abi.ts
2000
2052
  var SUPERSTATE_SWAP_ABI = [
2001
2053
  {
2002
2054
  type: "function",
@@ -2846,103 +2898,128 @@ var SUPERSTATE_SWAP_ABI = [
2846
2898
  inputs: []
2847
2899
  },
2848
2900
  {
2849
- type: "error",
2850
- name: "SwapFailed",
2901
+ type: "error",
2902
+ name: "SwapFailed",
2903
+ inputs: [
2904
+ {
2905
+ name: "user",
2906
+ type: "address",
2907
+ internalType: "address"
2908
+ },
2909
+ {
2910
+ name: "token",
2911
+ type: "address",
2912
+ internalType: "address"
2913
+ }
2914
+ ]
2915
+ },
2916
+ {
2917
+ type: "error",
2918
+ name: "Unauthorized",
2919
+ inputs: []
2920
+ }
2921
+ ];
2922
+
2923
+ // src/universal/core/shared/blockchain/erc20/abi.ts
2924
+ var ERC20_ABI = [
2925
+ {
2926
+ type: "function",
2927
+ name: "allowance",
2928
+ inputs: [
2929
+ { name: "owner", type: "address" },
2930
+ { name: "spender", type: "address" }
2931
+ ],
2932
+ outputs: [{ name: "", type: "uint256" }],
2933
+ stateMutability: "view"
2934
+ },
2935
+ {
2936
+ type: "function",
2937
+ name: "approve",
2938
+ inputs: [
2939
+ { name: "spender", type: "address" },
2940
+ { name: "amount", type: "uint256" }
2941
+ ],
2942
+ outputs: [{ name: "", type: "bool" }],
2943
+ stateMutability: "nonpayable"
2944
+ },
2945
+ {
2946
+ type: "function",
2947
+ name: "balanceOf",
2948
+ inputs: [{ name: "account", type: "address" }],
2949
+ outputs: [{ name: "", type: "uint256" }],
2950
+ stateMutability: "view"
2951
+ },
2952
+ {
2953
+ type: "function",
2954
+ name: "decimals",
2955
+ inputs: [],
2956
+ outputs: [{ name: "", type: "uint8" }],
2957
+ stateMutability: "view"
2958
+ },
2959
+ {
2960
+ type: "function",
2961
+ name: "name",
2962
+ inputs: [],
2963
+ outputs: [{ name: "", type: "string" }],
2964
+ stateMutability: "view"
2965
+ },
2966
+ {
2967
+ type: "function",
2968
+ name: "symbol",
2969
+ inputs: [],
2970
+ outputs: [{ name: "", type: "string" }],
2971
+ stateMutability: "view"
2972
+ },
2973
+ {
2974
+ type: "function",
2975
+ name: "totalSupply",
2976
+ inputs: [],
2977
+ outputs: [{ name: "", type: "uint256" }],
2978
+ stateMutability: "view"
2979
+ },
2980
+ {
2981
+ type: "function",
2982
+ name: "transfer",
2983
+ inputs: [
2984
+ { name: "recipient", type: "address" },
2985
+ { name: "amount", type: "uint256" }
2986
+ ],
2987
+ outputs: [{ name: "", type: "bool" }],
2988
+ stateMutability: "nonpayable"
2989
+ },
2990
+ {
2991
+ type: "function",
2992
+ name: "transferFrom",
2993
+ inputs: [
2994
+ { name: "sender", type: "address" },
2995
+ { name: "recipient", type: "address" },
2996
+ { name: "amount", type: "uint256" }
2997
+ ],
2998
+ outputs: [{ name: "", type: "bool" }],
2999
+ stateMutability: "nonpayable"
3000
+ },
3001
+ {
3002
+ type: "event",
3003
+ name: "Approval",
2851
3004
  inputs: [
2852
- {
2853
- name: "user",
2854
- type: "address",
2855
- internalType: "address"
2856
- },
2857
- {
2858
- name: "token",
2859
- type: "address",
2860
- internalType: "address"
2861
- }
2862
- ]
3005
+ { name: "owner", type: "address", indexed: true },
3006
+ { name: "spender", type: "address", indexed: true },
3007
+ { name: "value", type: "uint256", indexed: false }
3008
+ ],
3009
+ anonymous: false
2863
3010
  },
2864
3011
  {
2865
- type: "error",
2866
- name: "Unauthorized",
2867
- inputs: []
3012
+ type: "event",
3013
+ name: "Transfer",
3014
+ inputs: [
3015
+ { name: "from", type: "address", indexed: true },
3016
+ { name: "to", type: "address", indexed: true },
3017
+ { name: "value", type: "uint256", indexed: false }
3018
+ ],
3019
+ anonymous: false
2868
3020
  }
2869
3021
  ];
2870
3022
 
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
- }
2928
- }
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
- }
2945
-
2946
3023
  // src/universal/api/rpc/providers/superstate/swap.ts
2947
3024
  async function getSwapAuthorization(clients, params) {
2948
3025
  return clients(params.chain).readContract({
@@ -2992,7 +3069,7 @@ async function getSwapOutputToken(clients, params) {
2992
3069
  };
2993
3070
  }
2994
3071
 
2995
- // src/universal/core/checkout/superstate/swap-namespace.ts
3072
+ // src/universal/core/providers/checkout/superstate/swap-namespace.ts
2996
3073
  var SuperstateSwapNamespaceImpl = class {
2997
3074
  constructor(ctx) {
2998
3075
  this.ctx = ctx;
@@ -3012,6 +3089,20 @@ var SuperstateSwapNamespaceImpl = class {
3012
3089
  async () => getSwapPreview(this.ctx.rpc, params)
3013
3090
  );
3014
3091
  }
3092
+ async getQuote(params) {
3093
+ return this.log.wrap("getQuote", params, async () => {
3094
+ const { amount, outputTokenDecimals, ...ref } = params;
3095
+ const preview = await getSwapPreview(this.ctx.rpc, {
3096
+ ...ref,
3097
+ amount: amount.raw
3098
+ });
3099
+ return SwapQuote.fromPreview(
3100
+ preview,
3101
+ amount.decimals,
3102
+ outputTokenDecimals
3103
+ );
3104
+ });
3105
+ }
3015
3106
  async getStatus(params) {
3016
3107
  return this.log.wrap(
3017
3108
  "getStatus",
@@ -3156,54 +3247,195 @@ async function fetchRequirementStatuses(api, offerId) {
3156
3247
  url: `/v1/offers/${offerId}/requirements/statuses`,
3157
3248
  attributes: Attributes.protected()
3158
3249
  });
3159
- return RequirementStatusInfo.fromStatusesDto(response);
3250
+ return RequirementStatusInfo.fromStatusesDto(response);
3251
+ }
3252
+
3253
+ // src/universal/core/requirements/requirements-namespace.ts
3254
+ var RequirementsNamespaceImpl = class {
3255
+ constructor(ctx) {
3256
+ this.ctx = ctx;
3257
+ this.log = internalLogger(ctx.logger, "REQUIREMENTS");
3258
+ }
3259
+ async forOffer(offerId) {
3260
+ return this.log.wrap("forOffer", offerId, async () => {
3261
+ await this.ctx.ensureUserAuthenticated();
3262
+ return fetchOfferRequirements(
3263
+ this.ctx.api,
3264
+ offerId,
3265
+ void 0
3266
+ );
3267
+ });
3268
+ }
3269
+ async statuses(offerId) {
3270
+ return this.log.wrap("statuses", offerId, async () => {
3271
+ await this.ctx.ensureUserAuthenticated();
3272
+ return fetchRequirementStatuses(this.ctx.api, offerId);
3273
+ });
3274
+ }
3275
+ async createKycToken(params) {
3276
+ return this.log.wrap("createKycToken", params, async () => {
3277
+ await this.ctx.ensureUserAuthenticated();
3278
+ return createKycToken(
3279
+ this.ctx.api,
3280
+ params?.levelName,
3281
+ params?.reset
3282
+ );
3283
+ });
3284
+ }
3285
+ async getPii() {
3286
+ return this.log.wrap("getPii", void 0, async () => {
3287
+ await this.ctx.ensureUserAuthenticated();
3288
+ return fetchPii(this.ctx.api);
3289
+ });
3290
+ }
3291
+ async submitDocument(params) {
3292
+ return this.log.wrap("submitDocument", params, async () => {
3293
+ await this.ctx.ensureUserAuthenticated();
3294
+ return submitDocument(
3295
+ this.ctx.api,
3296
+ params.documentType,
3297
+ params.fields
3298
+ );
3299
+ });
3300
+ }
3301
+ };
3302
+
3303
+ // src/universal/types/offer-option-address.ts
3304
+ var OfferOptionAddressId = (value) => value;
3305
+ var OfferOptionAddress = {
3306
+ /** Maps the API DTO into the SDK offer-option-address domain model. */
3307
+ fromDto: (dto) => ({
3308
+ id: OfferOptionAddressId(dto.id),
3309
+ offerOptionId: OfferOptionId(dto.offer_option_id),
3310
+ address: EvmWalletAddress(dto.address),
3311
+ protocol: dto.protocol,
3312
+ createdAt: new Date(dto.created_at)
3313
+ })
3314
+ };
3315
+ var ConnectExternalWalletParams = {
3316
+ /** Maps connect-wallet params into the API DTO payload. */
3317
+ toDto: (params) => ({
3318
+ offer_option_id: params.offerOptionId,
3319
+ wallet_address: params.walletAddress,
3320
+ chain: params.chain,
3321
+ signature: params.signature
3322
+ })
3323
+ };
3324
+
3325
+ // src/universal/types/wallet-ownership-challenge.ts
3326
+ var WalletOwnershipChallenge = {
3327
+ /** Maps the API DTO into the SDK wallet-ownership-challenge domain model. */
3328
+ fromDto: (dto) => ({
3329
+ message: dto.message,
3330
+ expiresAt: new Date(dto.expires_at)
3331
+ })
3332
+ };
3333
+ var CreateWalletOwnershipChallengeParams = {
3334
+ /**
3335
+ * Maps challenge-request params into the API DTO payload. The discriminated
3336
+ * union guarantees SIWE fields are present exactly when `challengeType` is
3337
+ * `siwe`, so the mapping narrows on the discriminant.
3338
+ */
3339
+ toDto: (params) => {
3340
+ switch (params.challengeType) {
3341
+ case "plain":
3342
+ return {
3343
+ wallet_address: params.walletAddress,
3344
+ chain: params.chain,
3345
+ challenge_type: "plain"
3346
+ };
3347
+ case "siwe":
3348
+ return {
3349
+ wallet_address: params.walletAddress,
3350
+ chain: params.chain,
3351
+ challenge_type: "siwe",
3352
+ domain: params.domain,
3353
+ uri: params.uri,
3354
+ statement: params.statement
3355
+ };
3356
+ default: {
3357
+ const _exhaustive = params;
3358
+ return _exhaustive;
3359
+ }
3360
+ }
3361
+ }
3362
+ };
3363
+
3364
+ // src/universal/api/frontline/wallet-connect.ts
3365
+ async function createWalletOwnershipChallenge(api, params) {
3366
+ const dto = await api.send({
3367
+ method: "POST",
3368
+ url: "/v1/wallet-ownership",
3369
+ body: CreateWalletOwnershipChallengeParams.toDto(params),
3370
+ attributes: Attributes.protected()
3371
+ });
3372
+ return WalletOwnershipChallenge.fromDto(dto);
3373
+ }
3374
+ async function connectExternalWallet(api, params) {
3375
+ const dto = await api.send({
3376
+ method: "POST",
3377
+ url: `/v1/offers/${params.offerId}/addresses`,
3378
+ body: ConnectExternalWalletParams.toDto(params),
3379
+ attributes: Attributes.protected()
3380
+ });
3381
+ return OfferOptionAddress.fromDto(dto);
3382
+ }
3383
+ async function listOptionAddresses(api, offerId, offerOptionId) {
3384
+ const { data } = await api.send({
3385
+ method: "GET",
3386
+ url: `/v1/offers/${offerId}/addresses`,
3387
+ queryParams: { offer_option_id: offerOptionId },
3388
+ attributes: Attributes.protected()
3389
+ });
3390
+ return data.map(OfferOptionAddress.fromDto);
3391
+ }
3392
+ async function removeOptionAddress(api, offerId, addressId) {
3393
+ const dto = await api.send({
3394
+ method: "DELETE",
3395
+ url: `/v1/offers/${offerId}/addresses/${addressId}`,
3396
+ attributes: Attributes.protected()
3397
+ });
3398
+ return OfferOptionAddress.fromDto(dto);
3160
3399
  }
3161
3400
 
3162
- // src/universal/core/requirements/requirements-namespace.ts
3163
- var RequirementsNamespaceImpl = class {
3401
+ // src/universal/core/wallets/wallets-namespace.ts
3402
+ var WalletsNamespaceImpl = class {
3164
3403
  constructor(ctx) {
3165
3404
  this.ctx = ctx;
3166
- this.log = internalLogger(ctx.logger, "REQUIREMENTS");
3405
+ this.log = internalLogger(ctx.logger, "WALLETS");
3167
3406
  }
3168
- async forOffer(offerId) {
3169
- return this.log.wrap("forOffer", offerId, async () => {
3407
+ async createOwnershipChallenge(params) {
3408
+ return this.log.wrap("createOwnershipChallenge", params, async () => {
3170
3409
  await this.ctx.ensureUserAuthenticated();
3171
- return fetchOfferRequirements(
3410
+ return createWalletOwnershipChallenge(
3172
3411
  this.ctx.api,
3173
- offerId,
3174
- void 0
3412
+ params
3175
3413
  );
3176
3414
  });
3177
3415
  }
3178
- async statuses(offerId) {
3179
- return this.log.wrap("statuses", offerId, async () => {
3416
+ async connectExternal(params) {
3417
+ return this.log.wrap("connectExternal", params, async () => {
3180
3418
  await this.ctx.ensureUserAuthenticated();
3181
- return fetchRequirementStatuses(this.ctx.api, offerId);
3419
+ return connectExternalWallet(this.ctx.api, params);
3182
3420
  });
3183
3421
  }
3184
- async createKycToken(params) {
3185
- return this.log.wrap("createKycToken", params, async () => {
3422
+ async list(params) {
3423
+ return this.log.wrap("list", params, async () => {
3186
3424
  await this.ctx.ensureUserAuthenticated();
3187
- return createKycToken(
3425
+ return listOptionAddresses(
3188
3426
  this.ctx.api,
3189
- params?.levelName,
3190
- params?.reset
3427
+ params.offerId,
3428
+ params.offerOptionId
3191
3429
  );
3192
3430
  });
3193
3431
  }
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 () => {
3432
+ async remove(params) {
3433
+ return this.log.wrap("remove", params, async () => {
3202
3434
  await this.ctx.ensureUserAuthenticated();
3203
- return submitDocument(
3435
+ return removeOptionAddress(
3204
3436
  this.ctx.api,
3205
- params.documentType,
3206
- params.fields
3437
+ params.offerId,
3438
+ params.addressId
3207
3439
  );
3208
3440
  });
3209
3441
  }
@@ -3631,163 +3863,6 @@ var TokensNamespaceImpl = class {
3631
3863
  }
3632
3864
  };
3633
3865
 
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
3866
  // src/universal/api/frontline/offers.ts
3792
3867
  async function fetchOffers(api, clientCreds) {
3793
3868
  return fetchAllPages((params) => fetchOffersPage(api, params, clientCreds));
@@ -3844,6 +3919,7 @@ export {
3844
3919
  ValidationError,
3845
3920
  InvariantError,
3846
3921
  MathError,
3922
+ classifyLogCause,
3847
3923
  describeErrorUnredacted,
3848
3924
  internalLogger,
3849
3925
  HttpClient,
@@ -3852,6 +3928,18 @@ export {
3852
3928
  Seconds,
3853
3929
  isExpired,
3854
3930
  ERC20_ABI,
3931
+ FormattedAmountUi,
3932
+ FormattedPercentUi,
3933
+ TxExplorerUrl,
3934
+ ShortenedWalletAddress,
3935
+ FormattedAmountAssetUi,
3936
+ AssetIconUrl,
3937
+ viemChain,
3938
+ getChainId,
3939
+ chainFromId,
3940
+ contractOn,
3941
+ getNetworkName,
3942
+ txExplorerUrl,
3855
3943
  ETHEREUM_CHAINS,
3856
3944
  EthereumChain,
3857
3945
  SOLANA_CHAINS,
@@ -3874,17 +3962,30 @@ export {
3874
3962
  KnownAssetSymbol,
3875
3963
  Bps,
3876
3964
  blockchainAmountFromRawOrThrow,
3965
+ positiveAmountFromRawOrThrow,
3966
+ pricePerShare,
3877
3967
  parseBlockchainAmount,
3878
3968
  CentrifugeVaultStatus,
3879
3969
  CentrifugeVaultBuyTransaction,
3880
3970
  CentrifugeVaultClaimTransaction,
3881
- CentrifugeVaultPosition,
3882
- CentrifugeVaultRedeemPosition,
3971
+ CentrifugeAssets,
3972
+ CentrifugeShares,
3973
+ CentrifugeDepositPosition,
3974
+ CentrifugeRedeemPosition,
3883
3975
  CentrifugeVaultLeg,
3884
3976
  CentrifugeVaultLegId,
3885
3977
  CentrifugeVaultClaimProceedsTransaction,
3886
3978
  CentrifugeNamespaceImpl,
3887
- fetchAllPages,
3979
+ shortenAddress,
3980
+ formatAmount,
3981
+ formatRawAmount,
3982
+ formatCompactAmount,
3983
+ formatBpsAsPercent,
3984
+ usdAmount,
3985
+ assetAmount,
3986
+ NA_AMOUNT_ASSET_UI,
3987
+ formatShareAmount,
3988
+ formattedUsdPrice,
3888
3989
  Cursor,
3889
3990
  PaginatedResponse,
3890
3991
  PaginationParams,
@@ -3911,33 +4012,10 @@ export {
3911
4012
  TermItem,
3912
4013
  Milestone,
3913
4014
  ParticipationId,
3914
- Blockchain,
3915
- WalletAddress,
3916
4015
  ParticipationsPaginationParams,
3917
4016
  Participation,
3918
4017
  CreateParticipationParams,
3919
4018
  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
4019
  OndoTradingStatus,
3942
4020
  OndoQuote,
3943
4021
  OndoBuyTransaction,
@@ -3948,10 +4026,8 @@ export {
3948
4026
  PauseFlags,
3949
4027
  SwapStatus,
3950
4028
  AllowWalletResponse,
4029
+ SwapQuote,
3951
4030
  SuperstateSwapNamespaceImpl,
3952
- fetchOffers,
3953
- fetchOffersPage,
3954
- fetchOfferDetails,
3955
4031
  DocumentSubmission,
3956
4032
  KycToken,
3957
4033
  Iso2CountryCode,
@@ -3963,19 +4039,19 @@ export {
3963
4039
  RequirementStatusInfo,
3964
4040
  fetchOfferRequirements,
3965
4041
  RequirementsNamespaceImpl,
3966
- Erc20NamespaceImpl,
3967
- TokenLogoUrl,
3968
- TokenLogo,
3969
- TokenMetadata,
3970
- TokensNamespaceImpl,
3971
4042
  OfferOptionAddressId,
3972
4043
  OfferOptionAddress,
3973
4044
  ConnectExternalWalletParams,
3974
4045
  WalletOwnershipChallenge,
3975
4046
  CreateWalletOwnershipChallengeParams,
3976
4047
  WalletsNamespaceImpl,
3977
- ClientCredentialsOAuth,
3978
- OAuthRefreshToken,
3979
- OAuthSession
4048
+ fetchOffers,
4049
+ fetchOffersPage,
4050
+ fetchOfferDetails,
4051
+ Erc20NamespaceImpl,
4052
+ TokenLogoUrl,
4053
+ TokenLogo,
4054
+ TokenMetadata,
4055
+ TokensNamespaceImpl
3980
4056
  };
3981
- //# sourceMappingURL=chunk-C6GF7MDF.js.map
4057
+ //# sourceMappingURL=chunk-M2TURNJH.js.map