@coinlist-co/react 0.12.1-rc.b45777f → 0.12.1-rc.b902290

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.
@@ -209,6 +209,106 @@ var MathError = class extends Error {
209
209
  }
210
210
  };
211
211
 
212
+ // src/universal/core/shared/blockchain/erc20/abi.ts
213
+ var ERC20_ABI = [
214
+ {
215
+ type: "function",
216
+ name: "allowance",
217
+ inputs: [
218
+ { name: "owner", type: "address" },
219
+ { name: "spender", type: "address" }
220
+ ],
221
+ outputs: [{ name: "", type: "uint256" }],
222
+ stateMutability: "view"
223
+ },
224
+ {
225
+ type: "function",
226
+ name: "approve",
227
+ inputs: [
228
+ { name: "spender", type: "address" },
229
+ { name: "amount", type: "uint256" }
230
+ ],
231
+ outputs: [{ name: "", type: "bool" }],
232
+ stateMutability: "nonpayable"
233
+ },
234
+ {
235
+ type: "function",
236
+ name: "balanceOf",
237
+ inputs: [{ name: "account", type: "address" }],
238
+ outputs: [{ name: "", type: "uint256" }],
239
+ stateMutability: "view"
240
+ },
241
+ {
242
+ type: "function",
243
+ name: "decimals",
244
+ inputs: [],
245
+ outputs: [{ name: "", type: "uint8" }],
246
+ stateMutability: "view"
247
+ },
248
+ {
249
+ type: "function",
250
+ name: "name",
251
+ inputs: [],
252
+ outputs: [{ name: "", type: "string" }],
253
+ stateMutability: "view"
254
+ },
255
+ {
256
+ type: "function",
257
+ name: "symbol",
258
+ inputs: [],
259
+ outputs: [{ name: "", type: "string" }],
260
+ stateMutability: "view"
261
+ },
262
+ {
263
+ type: "function",
264
+ name: "totalSupply",
265
+ inputs: [],
266
+ outputs: [{ name: "", type: "uint256" }],
267
+ stateMutability: "view"
268
+ },
269
+ {
270
+ type: "function",
271
+ name: "transfer",
272
+ inputs: [
273
+ { name: "recipient", type: "address" },
274
+ { name: "amount", type: "uint256" }
275
+ ],
276
+ outputs: [{ name: "", type: "bool" }],
277
+ stateMutability: "nonpayable"
278
+ },
279
+ {
280
+ type: "function",
281
+ name: "transferFrom",
282
+ inputs: [
283
+ { name: "sender", type: "address" },
284
+ { name: "recipient", type: "address" },
285
+ { name: "amount", type: "uint256" }
286
+ ],
287
+ outputs: [{ name: "", type: "bool" }],
288
+ stateMutability: "nonpayable"
289
+ },
290
+ {
291
+ type: "event",
292
+ name: "Approval",
293
+ inputs: [
294
+ { name: "owner", type: "address", indexed: true },
295
+ { name: "spender", type: "address", indexed: true },
296
+ { name: "value", type: "uint256", indexed: false }
297
+ ],
298
+ anonymous: false
299
+ },
300
+ {
301
+ type: "event",
302
+ name: "Transfer",
303
+ inputs: [
304
+ { name: "from", type: "address", indexed: true },
305
+ { name: "to", type: "address", indexed: true },
306
+ { name: "value", type: "uint256", indexed: false }
307
+ ],
308
+ anonymous: false
309
+ }
310
+ ];
311
+
212
312
  // src/universal/api/pagination.ts
213
313
  async function fetchAllPages(fetchPage, baseParams) {
214
314
  const items = [];
@@ -659,6 +759,16 @@ async function createParticipation(api, params) {
659
759
  }
660
760
 
661
761
  // src/universal/core/shared/observability/log-cause.ts
762
+ import {
763
+ BaseError,
764
+ ContractFunctionExecutionError,
765
+ ContractFunctionRevertedError,
766
+ HttpRequestError,
767
+ RpcError,
768
+ SocketClosedError,
769
+ TimeoutError,
770
+ WebSocketRequestError
771
+ } from "viem";
662
772
  function classifyLogCause(error) {
663
773
  if (error instanceof HttpError) {
664
774
  return httpCause(error);
@@ -678,8 +788,32 @@ function classifyLogCause(error) {
678
788
  if (error instanceof NotImplementedError) {
679
789
  return { type: "not-implemented" };
680
790
  }
791
+ if (error instanceof BaseError) {
792
+ const http = error.walk((e) => e instanceof HttpError);
793
+ if (http instanceof HttpError) {
794
+ return httpCause(http);
795
+ }
796
+ return { type: "rpc", reason: rpcFailureReason(error) };
797
+ }
681
798
  return { type: "generic-error", name: errorName(error) };
682
799
  }
800
+ function rpcFailureReason(error) {
801
+ if (error.walk((e) => e instanceof ContractFunctionRevertedError)) {
802
+ return "reverted";
803
+ }
804
+ if (error.walk((e) => e instanceof RpcError)) {
805
+ return "node-rejected";
806
+ }
807
+ if (error.walk(
808
+ (e) => e instanceof HttpRequestError || e instanceof WebSocketRequestError || e instanceof SocketClosedError || e instanceof TimeoutError
809
+ )) {
810
+ return "transport";
811
+ }
812
+ if (error instanceof ContractFunctionExecutionError) {
813
+ return "malformed-response";
814
+ }
815
+ return "unknown";
816
+ }
683
817
  function describeErrorUnredacted(error) {
684
818
  if (error instanceof HttpError) {
685
819
  return describeHttpErrorRedacted(error);
@@ -943,18 +1077,22 @@ function formattedUsdPrice(amount, locale) {
943
1077
  }
944
1078
 
945
1079
  // src/universal/core/shared/blockchain/chain.ts
946
- var CHAIN_IDS = {
947
- ethereum_mainnet: 1,
948
- ethereum_sepolia: 11155111,
949
- base_mainnet: 8453,
950
- base_sepolia: 84532
1080
+ import { base, baseSepolia, mainnet, sepolia } from "viem/chains";
1081
+ var VIEM_CHAINS = {
1082
+ ethereum_mainnet: mainnet,
1083
+ ethereum_sepolia: sepolia,
1084
+ base_mainnet: base,
1085
+ base_sepolia: baseSepolia
951
1086
  };
1087
+ function viemChain(chain) {
1088
+ return VIEM_CHAINS[chain];
1089
+ }
952
1090
  function getChainId(chain) {
953
- return CHAIN_IDS[chain];
1091
+ return VIEM_CHAINS[chain].id;
954
1092
  }
955
1093
  function chainFromId(chainId) {
956
- const chains = Object.keys(CHAIN_IDS);
957
- const chain = chains.find((c) => String(CHAIN_IDS[c]) === chainId);
1094
+ const chains = Object.keys(VIEM_CHAINS);
1095
+ const chain = chains.find((c) => String(VIEM_CHAINS[c].id) === chainId);
958
1096
  if (!chain) {
959
1097
  throw new ValidationError(`Unsupported EIP-155 chain id: "${chainId}"`);
960
1098
  }
@@ -1345,40 +1483,915 @@ var OndoNamespaceImpl = class {
1345
1483
  }
1346
1484
  };
1347
1485
 
1486
+ // src/universal/core/checkout/superstate/blockchain/abi.ts
1487
+ var SUPERSTATE_SWAP_ABI = [
1488
+ {
1489
+ type: "function",
1490
+ name: "KIND",
1491
+ inputs: [],
1492
+ outputs: [
1493
+ {
1494
+ name: "",
1495
+ type: "uint16",
1496
+ internalType: "uint16"
1497
+ }
1498
+ ],
1499
+ stateMutability: "view"
1500
+ },
1501
+ {
1502
+ type: "function",
1503
+ name: "ONE_HUNDRED_P",
1504
+ inputs: [],
1505
+ outputs: [
1506
+ {
1507
+ name: "",
1508
+ type: "uint256",
1509
+ internalType: "uint256"
1510
+ }
1511
+ ],
1512
+ stateMutability: "view"
1513
+ },
1514
+ {
1515
+ type: "function",
1516
+ name: "SWAP_LEVEL",
1517
+ inputs: [],
1518
+ outputs: [
1519
+ {
1520
+ name: "",
1521
+ type: "uint32",
1522
+ internalType: "uint32"
1523
+ }
1524
+ ],
1525
+ stateMutability: "view"
1526
+ },
1527
+ {
1528
+ type: "function",
1529
+ name: "VERSION",
1530
+ inputs: [],
1531
+ outputs: [
1532
+ {
1533
+ name: "",
1534
+ type: "uint16",
1535
+ internalType: "uint16"
1536
+ }
1537
+ ],
1538
+ stateMutability: "view"
1539
+ },
1540
+ {
1541
+ type: "function",
1542
+ name: "authorized",
1543
+ inputs: [
1544
+ {
1545
+ name: "user",
1546
+ type: "address",
1547
+ internalType: "address"
1548
+ }
1549
+ ],
1550
+ outputs: [
1551
+ {
1552
+ name: "",
1553
+ type: "bool",
1554
+ internalType: "bool"
1555
+ }
1556
+ ],
1557
+ stateMutability: "view"
1558
+ },
1559
+ {
1560
+ type: "function",
1561
+ name: "bpp",
1562
+ inputs: [
1563
+ {
1564
+ name: "amount",
1565
+ type: "uint256",
1566
+ internalType: "uint256"
1567
+ }
1568
+ ],
1569
+ outputs: [
1570
+ {
1571
+ name: "",
1572
+ type: "uint256",
1573
+ internalType: "uint256"
1574
+ }
1575
+ ],
1576
+ stateMutability: "view"
1577
+ },
1578
+ {
1579
+ type: "function",
1580
+ name: "bps",
1581
+ inputs: [],
1582
+ outputs: [
1583
+ {
1584
+ name: "",
1585
+ type: "uint256",
1586
+ internalType: "uint256"
1587
+ }
1588
+ ],
1589
+ stateMutability: "view"
1590
+ },
1591
+ {
1592
+ type: "function",
1593
+ name: "cancelOwnershipHandover",
1594
+ inputs: [],
1595
+ outputs: [],
1596
+ stateMutability: "payable"
1597
+ },
1598
+ {
1599
+ type: "function",
1600
+ name: "completeOwnershipHandover",
1601
+ inputs: [
1602
+ {
1603
+ name: "pendingOwner",
1604
+ type: "address",
1605
+ internalType: "address"
1606
+ }
1607
+ ],
1608
+ outputs: [],
1609
+ stateMutability: "payable"
1610
+ },
1611
+ {
1612
+ type: "function",
1613
+ name: "fee",
1614
+ inputs: [
1615
+ {
1616
+ name: "amount",
1617
+ type: "uint256",
1618
+ internalType: "uint256"
1619
+ }
1620
+ ],
1621
+ outputs: [
1622
+ {
1623
+ name: "",
1624
+ type: "uint256",
1625
+ internalType: "uint256"
1626
+ },
1627
+ {
1628
+ name: "",
1629
+ type: "uint256",
1630
+ internalType: "uint256"
1631
+ }
1632
+ ],
1633
+ stateMutability: "view"
1634
+ },
1635
+ {
1636
+ type: "function",
1637
+ name: "id",
1638
+ inputs: [],
1639
+ outputs: [
1640
+ {
1641
+ name: "",
1642
+ type: "bytes32",
1643
+ internalType: "bytes32"
1644
+ }
1645
+ ],
1646
+ stateMutability: "view"
1647
+ },
1648
+ {
1649
+ type: "function",
1650
+ name: "inputTokens",
1651
+ inputs: [
1652
+ {
1653
+ name: "",
1654
+ type: "address",
1655
+ internalType: "address"
1656
+ }
1657
+ ],
1658
+ outputs: [
1659
+ {
1660
+ name: "",
1661
+ type: "bool",
1662
+ internalType: "bool"
1663
+ }
1664
+ ],
1665
+ stateMutability: "view"
1666
+ },
1667
+ {
1668
+ type: "function",
1669
+ name: "outputToken",
1670
+ inputs: [],
1671
+ outputs: [
1672
+ {
1673
+ name: "",
1674
+ type: "address",
1675
+ internalType: "address"
1676
+ }
1677
+ ],
1678
+ stateMutability: "view"
1679
+ },
1680
+ {
1681
+ type: "function",
1682
+ name: "outputTokenBalance",
1683
+ inputs: [],
1684
+ outputs: [
1685
+ {
1686
+ name: "",
1687
+ type: "uint256",
1688
+ internalType: "uint256"
1689
+ }
1690
+ ],
1691
+ stateMutability: "view"
1692
+ },
1693
+ {
1694
+ type: "function",
1695
+ name: "owner",
1696
+ inputs: [],
1697
+ outputs: [
1698
+ {
1699
+ name: "result",
1700
+ type: "address",
1701
+ internalType: "address"
1702
+ }
1703
+ ],
1704
+ stateMutability: "view"
1705
+ },
1706
+ {
1707
+ type: "function",
1708
+ name: "ownershipHandoverExpiresAt",
1709
+ inputs: [
1710
+ {
1711
+ name: "pendingOwner",
1712
+ type: "address",
1713
+ internalType: "address"
1714
+ }
1715
+ ],
1716
+ outputs: [
1717
+ {
1718
+ name: "result",
1719
+ type: "uint256",
1720
+ internalType: "uint256"
1721
+ }
1722
+ ],
1723
+ stateMutability: "view"
1724
+ },
1725
+ {
1726
+ type: "function",
1727
+ name: "pause",
1728
+ inputs: [
1729
+ {
1730
+ name: "level",
1731
+ type: "uint32",
1732
+ internalType: "uint32"
1733
+ }
1734
+ ],
1735
+ outputs: [
1736
+ {
1737
+ name: "",
1738
+ type: "bool",
1739
+ internalType: "bool"
1740
+ }
1741
+ ],
1742
+ stateMutability: "nonpayable"
1743
+ },
1744
+ {
1745
+ type: "function",
1746
+ name: "paused",
1747
+ inputs: [],
1748
+ outputs: [
1749
+ {
1750
+ name: "",
1751
+ type: "uint32",
1752
+ internalType: "uint32"
1753
+ }
1754
+ ],
1755
+ stateMutability: "view"
1756
+ },
1757
+ {
1758
+ type: "function",
1759
+ name: "preview",
1760
+ inputs: [
1761
+ {
1762
+ name: "token",
1763
+ type: "address",
1764
+ internalType: "address"
1765
+ },
1766
+ {
1767
+ name: "amount",
1768
+ type: "uint256",
1769
+ internalType: "uint256"
1770
+ }
1771
+ ],
1772
+ outputs: [
1773
+ {
1774
+ name: "",
1775
+ type: "tuple",
1776
+ internalType: "struct Preview",
1777
+ components: [
1778
+ {
1779
+ name: "input",
1780
+ type: "uint256",
1781
+ internalType: "uint256"
1782
+ },
1783
+ {
1784
+ name: "fee",
1785
+ type: "uint256",
1786
+ internalType: "uint256"
1787
+ },
1788
+ {
1789
+ name: "output",
1790
+ type: "uint256",
1791
+ internalType: "uint256"
1792
+ }
1793
+ ]
1794
+ }
1795
+ ],
1796
+ stateMutability: "view"
1797
+ },
1798
+ {
1799
+ type: "function",
1800
+ name: "renounceOwnership",
1801
+ inputs: [],
1802
+ outputs: [],
1803
+ stateMutability: "payable"
1804
+ },
1805
+ {
1806
+ type: "function",
1807
+ name: "requestOwnershipHandover",
1808
+ inputs: [],
1809
+ outputs: [],
1810
+ stateMutability: "payable"
1811
+ },
1812
+ {
1813
+ type: "function",
1814
+ name: "setBps",
1815
+ inputs: [
1816
+ {
1817
+ name: "points",
1818
+ type: "uint256",
1819
+ internalType: "uint256"
1820
+ }
1821
+ ],
1822
+ outputs: [
1823
+ {
1824
+ name: "",
1825
+ type: "bool",
1826
+ internalType: "bool"
1827
+ }
1828
+ ],
1829
+ stateMutability: "nonpayable"
1830
+ },
1831
+ {
1832
+ type: "function",
1833
+ name: "setInputToken",
1834
+ inputs: [
1835
+ {
1836
+ name: "token",
1837
+ type: "address",
1838
+ internalType: "address"
1839
+ },
1840
+ {
1841
+ name: "val",
1842
+ type: "bool",
1843
+ internalType: "bool"
1844
+ }
1845
+ ],
1846
+ outputs: [
1847
+ {
1848
+ name: "",
1849
+ type: "bool",
1850
+ internalType: "bool"
1851
+ }
1852
+ ],
1853
+ stateMutability: "nonpayable"
1854
+ },
1855
+ {
1856
+ type: "function",
1857
+ name: "status",
1858
+ inputs: [],
1859
+ outputs: [
1860
+ {
1861
+ name: "",
1862
+ type: "tuple",
1863
+ internalType: "struct Status",
1864
+ components: [
1865
+ {
1866
+ name: "flags",
1867
+ type: "uint32",
1868
+ internalType: "uint32"
1869
+ },
1870
+ {
1871
+ name: "state",
1872
+ type: "uint8",
1873
+ internalType: "enum State"
1874
+ }
1875
+ ]
1876
+ }
1877
+ ],
1878
+ stateMutability: "view"
1879
+ },
1880
+ {
1881
+ type: "function",
1882
+ name: "stop",
1883
+ inputs: [],
1884
+ outputs: [
1885
+ {
1886
+ name: "",
1887
+ type: "bool",
1888
+ internalType: "bool"
1889
+ }
1890
+ ],
1891
+ stateMutability: "nonpayable"
1892
+ },
1893
+ {
1894
+ type: "function",
1895
+ name: "stopped",
1896
+ inputs: [],
1897
+ outputs: [
1898
+ {
1899
+ name: "",
1900
+ type: "bool",
1901
+ internalType: "bool"
1902
+ }
1903
+ ],
1904
+ stateMutability: "view"
1905
+ },
1906
+ {
1907
+ type: "function",
1908
+ name: "swap",
1909
+ inputs: [
1910
+ {
1911
+ name: "token",
1912
+ type: "address",
1913
+ internalType: "address"
1914
+ },
1915
+ {
1916
+ name: "amount",
1917
+ type: "uint256",
1918
+ internalType: "uint256"
1919
+ },
1920
+ {
1921
+ name: "slip",
1922
+ type: "uint256",
1923
+ internalType: "uint256"
1924
+ }
1925
+ ],
1926
+ outputs: [
1927
+ {
1928
+ name: "",
1929
+ type: "uint256",
1930
+ internalType: "uint256"
1931
+ }
1932
+ ],
1933
+ stateMutability: "nonpayable"
1934
+ },
1935
+ {
1936
+ type: "function",
1937
+ name: "tokenBalance",
1938
+ inputs: [
1939
+ {
1940
+ name: "token",
1941
+ type: "address",
1942
+ internalType: "address"
1943
+ }
1944
+ ],
1945
+ outputs: [
1946
+ {
1947
+ name: "",
1948
+ type: "uint256",
1949
+ internalType: "uint256"
1950
+ }
1951
+ ],
1952
+ stateMutability: "view"
1953
+ },
1954
+ {
1955
+ type: "function",
1956
+ name: "totals",
1957
+ inputs: [
1958
+ {
1959
+ name: "user",
1960
+ type: "address",
1961
+ internalType: "address"
1962
+ },
1963
+ {
1964
+ name: "token",
1965
+ type: "address",
1966
+ internalType: "address"
1967
+ }
1968
+ ],
1969
+ outputs: [
1970
+ {
1971
+ name: "",
1972
+ type: "tuple",
1973
+ internalType: "struct SwapTotal",
1974
+ components: [
1975
+ {
1976
+ name: "inputSum",
1977
+ type: "uint256",
1978
+ internalType: "uint256"
1979
+ },
1980
+ {
1981
+ name: "feeSum",
1982
+ type: "uint256",
1983
+ internalType: "uint256"
1984
+ },
1985
+ {
1986
+ name: "outputSum",
1987
+ type: "uint256",
1988
+ internalType: "uint256"
1989
+ },
1990
+ {
1991
+ name: "count",
1992
+ type: "uint256",
1993
+ internalType: "uint256"
1994
+ }
1995
+ ]
1996
+ }
1997
+ ],
1998
+ stateMutability: "view"
1999
+ },
2000
+ {
2001
+ type: "function",
2002
+ name: "totals",
2003
+ inputs: [
2004
+ {
2005
+ name: "token",
2006
+ type: "address",
2007
+ internalType: "address"
2008
+ }
2009
+ ],
2010
+ outputs: [
2011
+ {
2012
+ name: "",
2013
+ type: "tuple",
2014
+ internalType: "struct SwapTotal",
2015
+ components: [
2016
+ {
2017
+ name: "inputSum",
2018
+ type: "uint256",
2019
+ internalType: "uint256"
2020
+ },
2021
+ {
2022
+ name: "feeSum",
2023
+ type: "uint256",
2024
+ internalType: "uint256"
2025
+ },
2026
+ {
2027
+ name: "outputSum",
2028
+ type: "uint256",
2029
+ internalType: "uint256"
2030
+ },
2031
+ {
2032
+ name: "count",
2033
+ type: "uint256",
2034
+ internalType: "uint256"
2035
+ }
2036
+ ]
2037
+ }
2038
+ ],
2039
+ stateMutability: "view"
2040
+ },
2041
+ {
2042
+ type: "function",
2043
+ name: "transfer",
2044
+ inputs: [
2045
+ {
2046
+ name: "to",
2047
+ type: "address",
2048
+ internalType: "address"
2049
+ },
2050
+ {
2051
+ name: "amount",
2052
+ type: "uint256",
2053
+ internalType: "uint256"
2054
+ }
2055
+ ],
2056
+ outputs: [
2057
+ {
2058
+ name: "",
2059
+ type: "bool",
2060
+ internalType: "bool"
2061
+ }
2062
+ ],
2063
+ stateMutability: "nonpayable"
2064
+ },
2065
+ {
2066
+ type: "function",
2067
+ name: "transfer",
2068
+ inputs: [
2069
+ {
2070
+ name: "to",
2071
+ type: "address",
2072
+ internalType: "address"
2073
+ },
2074
+ {
2075
+ name: "token",
2076
+ type: "address",
2077
+ internalType: "address"
2078
+ },
2079
+ {
2080
+ name: "amount",
2081
+ type: "uint256",
2082
+ internalType: "uint256"
2083
+ }
2084
+ ],
2085
+ outputs: [
2086
+ {
2087
+ name: "",
2088
+ type: "bool",
2089
+ internalType: "bool"
2090
+ }
2091
+ ],
2092
+ stateMutability: "nonpayable"
2093
+ },
2094
+ {
2095
+ type: "function",
2096
+ name: "transferOwnership",
2097
+ inputs: [
2098
+ {
2099
+ name: "newOwner",
2100
+ type: "address",
2101
+ internalType: "address"
2102
+ }
2103
+ ],
2104
+ outputs: [],
2105
+ stateMutability: "payable"
2106
+ },
2107
+ {
2108
+ type: "event",
2109
+ name: "BpsUpdated",
2110
+ inputs: [
2111
+ {
2112
+ name: "prev",
2113
+ type: "uint256",
2114
+ indexed: false,
2115
+ internalType: "uint256"
2116
+ },
2117
+ {
2118
+ name: "next",
2119
+ type: "uint256",
2120
+ indexed: false,
2121
+ internalType: "uint256"
2122
+ }
2123
+ ],
2124
+ anonymous: false
2125
+ },
2126
+ {
2127
+ type: "event",
2128
+ name: "InputTokenUpdated",
2129
+ inputs: [
2130
+ {
2131
+ name: "token",
2132
+ type: "address",
2133
+ indexed: true,
2134
+ internalType: "address"
2135
+ },
2136
+ {
2137
+ name: "prev",
2138
+ type: "bool",
2139
+ indexed: false,
2140
+ internalType: "bool"
2141
+ },
2142
+ {
2143
+ name: "next",
2144
+ type: "bool",
2145
+ indexed: false,
2146
+ internalType: "bool"
2147
+ }
2148
+ ],
2149
+ anonymous: false
2150
+ },
2151
+ {
2152
+ type: "event",
2153
+ name: "OwnershipHandoverCanceled",
2154
+ inputs: [
2155
+ {
2156
+ name: "pendingOwner",
2157
+ type: "address",
2158
+ indexed: true,
2159
+ internalType: "address"
2160
+ }
2161
+ ],
2162
+ anonymous: false
2163
+ },
2164
+ {
2165
+ type: "event",
2166
+ name: "OwnershipHandoverRequested",
2167
+ inputs: [
2168
+ {
2169
+ name: "pendingOwner",
2170
+ type: "address",
2171
+ indexed: true,
2172
+ internalType: "address"
2173
+ }
2174
+ ],
2175
+ anonymous: false
2176
+ },
2177
+ {
2178
+ type: "event",
2179
+ name: "OwnershipTransferred",
2180
+ inputs: [
2181
+ {
2182
+ name: "oldOwner",
2183
+ type: "address",
2184
+ indexed: true,
2185
+ internalType: "address"
2186
+ },
2187
+ {
2188
+ name: "newOwner",
2189
+ type: "address",
2190
+ indexed: true,
2191
+ internalType: "address"
2192
+ }
2193
+ ],
2194
+ anonymous: false
2195
+ },
2196
+ {
2197
+ type: "event",
2198
+ name: "Paused",
2199
+ inputs: [
2200
+ {
2201
+ name: "previous",
2202
+ type: "uint32",
2203
+ indexed: false,
2204
+ internalType: "uint32"
2205
+ },
2206
+ {
2207
+ name: "next",
2208
+ type: "uint32",
2209
+ indexed: false,
2210
+ internalType: "uint32"
2211
+ }
2212
+ ],
2213
+ anonymous: false
2214
+ },
2215
+ {
2216
+ type: "event",
2217
+ name: "Stopped",
2218
+ inputs: [],
2219
+ anonymous: false
2220
+ },
2221
+ {
2222
+ type: "event",
2223
+ name: "Swapped",
2224
+ inputs: [
2225
+ {
2226
+ name: "user",
2227
+ type: "address",
2228
+ indexed: true,
2229
+ internalType: "address"
2230
+ },
2231
+ {
2232
+ name: "inputToken",
2233
+ type: "address",
2234
+ indexed: true,
2235
+ internalType: "address"
2236
+ },
2237
+ {
2238
+ name: "outputToken",
2239
+ type: "address",
2240
+ indexed: true,
2241
+ internalType: "address"
2242
+ },
2243
+ {
2244
+ name: "inputAmount",
2245
+ type: "uint256",
2246
+ indexed: false,
2247
+ internalType: "uint256"
2248
+ },
2249
+ {
2250
+ name: "fee",
2251
+ type: "uint256",
2252
+ indexed: false,
2253
+ internalType: "uint256"
2254
+ },
2255
+ {
2256
+ name: "outputAmount",
2257
+ type: "uint256",
2258
+ indexed: false,
2259
+ internalType: "uint256"
2260
+ }
2261
+ ],
2262
+ anonymous: false
2263
+ },
2264
+ {
2265
+ type: "event",
2266
+ name: "Transferred",
2267
+ inputs: [
2268
+ {
2269
+ name: "to",
2270
+ type: "address",
2271
+ indexed: true,
2272
+ internalType: "address"
2273
+ },
2274
+ {
2275
+ name: "token",
2276
+ type: "address",
2277
+ indexed: true,
2278
+ internalType: "address"
2279
+ },
2280
+ {
2281
+ name: "amount",
2282
+ type: "uint256",
2283
+ indexed: false,
2284
+ internalType: "uint256"
2285
+ }
2286
+ ],
2287
+ anonymous: false
2288
+ },
2289
+ {
2290
+ type: "error",
2291
+ name: "AlreadyInitialized",
2292
+ inputs: []
2293
+ },
2294
+ {
2295
+ type: "error",
2296
+ name: "InsufficientAmount",
2297
+ inputs: []
2298
+ },
2299
+ {
2300
+ type: "error",
2301
+ name: "InvalidAddress",
2302
+ inputs: []
2303
+ },
2304
+ {
2305
+ type: "error",
2306
+ name: "InvalidAmount",
2307
+ inputs: []
2308
+ },
2309
+ {
2310
+ type: "error",
2311
+ name: "IsPaused",
2312
+ inputs: [
2313
+ {
2314
+ name: "level",
2315
+ type: "uint32",
2316
+ internalType: "uint32"
2317
+ }
2318
+ ]
2319
+ },
2320
+ {
2321
+ type: "error",
2322
+ name: "IsStopped",
2323
+ inputs: []
2324
+ },
2325
+ {
2326
+ type: "error",
2327
+ name: "NewOwnerIsZeroAddress",
2328
+ inputs: []
2329
+ },
2330
+ {
2331
+ type: "error",
2332
+ name: "NoHandoverRequest",
2333
+ inputs: []
2334
+ },
2335
+ {
2336
+ type: "error",
2337
+ name: "SwapFailed",
2338
+ inputs: [
2339
+ {
2340
+ name: "user",
2341
+ type: "address",
2342
+ internalType: "address"
2343
+ },
2344
+ {
2345
+ name: "token",
2346
+ type: "address",
2347
+ internalType: "address"
2348
+ }
2349
+ ]
2350
+ },
2351
+ {
2352
+ type: "error",
2353
+ name: "Unauthorized",
2354
+ inputs: []
2355
+ }
2356
+ ];
2357
+
1348
2358
  // src/universal/types/providers/superstate/swap.ts
1349
- var SwapAuthorization = {
1350
- fromDto: (dto) => ({
1351
- authorized: dto.authorized
1352
- })
1353
- };
1354
2359
  var SwapPreview = {
1355
- fromDto: (dto) => ({
1356
- inputAmount: parseUint256(
1357
- BigInt(dto.pay_input_amount),
1358
- "SwapPreview.pay_input_amount"
1359
- ),
1360
- fee: parseUint256(BigInt(dto.fee), "SwapPreview.fee"),
1361
- outputAmount: parseUint256(
1362
- BigInt(dto.receive_output_amount),
1363
- "SwapPreview.receive_output_amount"
1364
- )
2360
+ /** Maps the contract's `Preview { input, fee, output }` struct. */
2361
+ fromContract: (preview) => ({
2362
+ inputAmount: parseUint256(preview.input, "SwapPreview.input"),
2363
+ fee: parseUint256(preview.fee, "SwapPreview.fee"),
2364
+ outputAmount: parseUint256(preview.output, "SwapPreview.output")
1365
2365
  })
1366
2366
  };
2367
+ var PauseFlags = (value) => value;
1367
2368
  var SwapStatus = {
1368
- fromDto: (dto) => ({
1369
- stopped: parseUint256(BigInt(dto.stopped), "SwapStatus.stopped"),
1370
- swapLevel: parseUint256(BigInt(dto.swap_level), "SwapStatus.swap_level")
1371
- })
1372
- };
1373
- var TokenAllowance = {
1374
- fromDto: (dto) => ({
1375
- allowance: parseUint256(BigInt(dto.allowance), "TokenAllowance.allowance")
1376
- })
1377
- };
1378
- var TokenBalance = {
1379
- fromDto: (dto) => ({
1380
- balance: parseUint256(BigInt(dto.balance), "TokenBalance.balance")
1381
- })
2369
+ /**
2370
+ * Maps the contract's `Status { uint32 flags; State state }` struct, where
2371
+ * `State` is `0 = Active | 1 = Paused | 2 = Stopped`.
2372
+ *
2373
+ * `flags` is carried onto the `paused` arm only. On the other two the
2374
+ * contract sets it to a self-identifying marker rather than to information -
2375
+ * so repeating it would invite a caller to read meaning into a constant.
2376
+ *
2377
+ * @throws ValidationError on a `state` outside the enum. A contract that has
2378
+ * grown a fourth state is one the SDK does not model, and guessing `active`
2379
+ * would let a halted swap read as a live one.
2380
+ */
2381
+ fromContract: (status) => {
2382
+ switch (status.state) {
2383
+ case 0:
2384
+ return { state: "active" };
2385
+ case 1:
2386
+ return { state: "paused", pausedLevels: PauseFlags(status.flags) };
2387
+ case 2:
2388
+ return { state: "stopped" };
2389
+ default:
2390
+ throw new ValidationError(
2391
+ `SwapStatus.state: unknown contract state (${status.state})`
2392
+ );
2393
+ }
2394
+ }
1382
2395
  };
1383
2396
  var AllowWalletResponse = {
1384
2397
  fromDto: (dto) => {
@@ -1403,84 +2416,6 @@ var AllowWalletResponse = {
1403
2416
  };
1404
2417
 
1405
2418
  // src/universal/api/frontline/providers/superstate/swap.ts
1406
- async function getSwapAuthorization(api, params) {
1407
- const dto = await api.send({
1408
- method: "GET",
1409
- url: "/v1/wallet/authorized",
1410
- queryParams: {
1411
- chain: params.chain,
1412
- contract_address: params.contractAddress,
1413
- wallet_address: params.walletAddress
1414
- },
1415
- attributes: Attributes.protected()
1416
- });
1417
- return SwapAuthorization.fromDto(dto);
1418
- }
1419
- async function getSwapOutputToken(api, params) {
1420
- const dto = await api.send({
1421
- method: "GET",
1422
- url: "/v1/swap/output-token",
1423
- queryParams: {
1424
- chain: params.chain,
1425
- contract_address: params.contractAddress
1426
- },
1427
- attributes: Attributes.protected()
1428
- });
1429
- return toErc20Asset(dto);
1430
- }
1431
- async function getSwapPreview(api, params) {
1432
- const dto = await api.send({
1433
- method: "GET",
1434
- url: "/v1/swap/preview",
1435
- queryParams: {
1436
- chain: params.chain,
1437
- contract_address: params.contractAddress,
1438
- input_token: params.inputToken,
1439
- amount: params.amount.toString()
1440
- },
1441
- attributes: Attributes.protected()
1442
- });
1443
- return SwapPreview.fromDto(dto);
1444
- }
1445
- async function getSwapStatus(api, params) {
1446
- const dto = await api.send({
1447
- method: "GET",
1448
- url: "/v1/swap/status",
1449
- queryParams: {
1450
- chain: params.chain,
1451
- contract_address: params.contractAddress
1452
- },
1453
- attributes: Attributes.protected()
1454
- });
1455
- return SwapStatus.fromDto(dto);
1456
- }
1457
- async function getTokenAllowance(api, params) {
1458
- const dto = await api.send({
1459
- method: "GET",
1460
- url: "/v1/token/allowance",
1461
- queryParams: {
1462
- chain: params.chain,
1463
- token_address: params.tokenAddress,
1464
- owner: params.owner,
1465
- spender: params.spender
1466
- },
1467
- attributes: Attributes.protected()
1468
- });
1469
- return TokenAllowance.fromDto(dto);
1470
- }
1471
- async function getTokenBalance(api, params) {
1472
- const dto = await api.send({
1473
- method: "GET",
1474
- url: "/v1/token/balance",
1475
- queryParams: {
1476
- chain: params.chain,
1477
- token_address: params.tokenAddress,
1478
- owner: params.owner
1479
- },
1480
- attributes: Attributes.protected()
1481
- });
1482
- return TokenBalance.fromDto(dto);
1483
- }
1484
2419
  async function allowWallet(api, params) {
1485
2420
  const dto = await api.send({
1486
2421
  method: "POST",
@@ -1494,11 +2429,53 @@ async function allowWallet(api, params) {
1494
2429
  });
1495
2430
  return AllowWalletResponse.fromDto(dto);
1496
2431
  }
1497
- function toErc20Asset(dto) {
2432
+
2433
+ // src/universal/api/rpc/providers/superstate/swap.ts
2434
+ async function getSwapAuthorization(clients, params) {
2435
+ return clients(params.chain).readContract({
2436
+ address: params.contractAddress,
2437
+ abi: SUPERSTATE_SWAP_ABI,
2438
+ functionName: "authorized",
2439
+ args: [params.walletAddress]
2440
+ });
2441
+ }
2442
+ async function getSwapPreview(clients, params) {
2443
+ const preview = await clients(params.chain).readContract({
2444
+ address: params.contractAddress,
2445
+ abi: SUPERSTATE_SWAP_ABI,
2446
+ functionName: "preview",
2447
+ args: [params.inputToken, params.amount]
2448
+ });
2449
+ return SwapPreview.fromContract(preview);
2450
+ }
2451
+ async function getSwapStatus(clients, params) {
2452
+ const status = await clients(params.chain).readContract({
2453
+ address: params.contractAddress,
2454
+ abi: SUPERSTATE_SWAP_ABI,
2455
+ functionName: "status"
2456
+ });
2457
+ return SwapStatus.fromContract(status);
2458
+ }
2459
+ async function getSwapOutputToken(clients, params) {
2460
+ const client = clients(params.chain);
2461
+ const tokenAddress = await client.readContract({
2462
+ address: params.contractAddress,
2463
+ abi: SUPERSTATE_SWAP_ABI,
2464
+ functionName: "outputToken"
2465
+ });
2466
+ const token = { address: EvmContractAddress(tokenAddress), abi: ERC20_ABI };
2467
+ const [name, symbol, decimals] = await client.multicall({
2468
+ contracts: [
2469
+ { ...token, functionName: "name" },
2470
+ { ...token, functionName: "symbol" },
2471
+ { ...token, functionName: "decimals" }
2472
+ ],
2473
+ allowFailure: false
2474
+ });
1498
2475
  return {
1499
- name: dto.name,
1500
- symbol: AssetSymbol(dto.symbol),
1501
- decimals: AssetDecimals(dto.decimals)
2476
+ name,
2477
+ symbol: AssetSymbol(symbol),
2478
+ decimals: AssetDecimals(decimals)
1502
2479
  };
1503
2480
  }
1504
2481
 
@@ -1509,28 +2486,32 @@ var SuperstateSwapNamespaceImpl = class {
1509
2486
  this.log = internalLogger(ctx.logger, "SUPERSTATE");
1510
2487
  }
1511
2488
  async getAuthorization(params) {
1512
- return this.log.wrap("getAuthorization", params, async () => {
1513
- await this.ctx.ensureUserAuthenticated();
1514
- return getSwapAuthorization(this.ctx.api, params);
1515
- });
2489
+ return this.log.wrap(
2490
+ "getAuthorization",
2491
+ params,
2492
+ async () => getSwapAuthorization(this.ctx.rpc, params)
2493
+ );
1516
2494
  }
1517
2495
  async getPreview(params) {
1518
- return this.log.wrap("getPreview", params, async () => {
1519
- await this.ctx.ensureUserAuthenticated();
1520
- return getSwapPreview(this.ctx.api, params);
1521
- });
2496
+ return this.log.wrap(
2497
+ "getPreview",
2498
+ params,
2499
+ async () => getSwapPreview(this.ctx.rpc, params)
2500
+ );
1522
2501
  }
1523
2502
  async getStatus(params) {
1524
- return this.log.wrap("getStatus", params, async () => {
1525
- await this.ctx.ensureUserAuthenticated();
1526
- return getSwapStatus(this.ctx.api, params);
1527
- });
2503
+ return this.log.wrap(
2504
+ "getStatus",
2505
+ params,
2506
+ async () => getSwapStatus(this.ctx.rpc, params)
2507
+ );
1528
2508
  }
1529
2509
  async getOutputToken(params) {
1530
- return this.log.wrap("getOutputToken", params, async () => {
1531
- await this.ctx.ensureUserAuthenticated();
1532
- return getSwapOutputToken(this.ctx.api, params);
1533
- });
2510
+ return this.log.wrap(
2511
+ "getOutputToken",
2512
+ params,
2513
+ async () => getSwapOutputToken(this.ctx.rpc, params)
2514
+ );
1534
2515
  }
1535
2516
  async allowWallet(params) {
1536
2517
  return this.log.wrap("allowWallet", params, async () => {
@@ -1715,6 +2696,26 @@ var RequirementsNamespaceImpl = class {
1715
2696
  }
1716
2697
  };
1717
2698
 
2699
+ // src/universal/api/rpc/erc20.ts
2700
+ async function getTokenAllowance(clients, params) {
2701
+ const allowance = await clients(params.chain).readContract({
2702
+ address: params.tokenAddress,
2703
+ abi: ERC20_ABI,
2704
+ functionName: "allowance",
2705
+ args: [params.owner, params.spender]
2706
+ });
2707
+ return parseUint256(allowance, "allowance");
2708
+ }
2709
+ async function getTokenBalance(clients, params) {
2710
+ const balance = await clients(params.chain).readContract({
2711
+ address: params.tokenAddress,
2712
+ abi: ERC20_ABI,
2713
+ functionName: "balanceOf",
2714
+ args: [params.owner]
2715
+ });
2716
+ return parseUint256(balance, "balanceOf");
2717
+ }
2718
+
1718
2719
  // src/universal/core/shared/blockchain/erc20/erc20-namespace.ts
1719
2720
  var Erc20NamespaceImpl = class {
1720
2721
  constructor(ctx) {
@@ -1722,16 +2723,18 @@ var Erc20NamespaceImpl = class {
1722
2723
  this.log = internalLogger(ctx.logger, "ERC20");
1723
2724
  }
1724
2725
  async getAllowance(params) {
1725
- return this.log.wrap("getAllowance", params, async () => {
1726
- await this.ctx.ensureUserAuthenticated();
1727
- return getTokenAllowance(this.ctx.api, params);
1728
- });
2726
+ return this.log.wrap(
2727
+ "getAllowance",
2728
+ params,
2729
+ async () => getTokenAllowance(this.ctx.rpc, params)
2730
+ );
1729
2731
  }
1730
2732
  async getBalance(params) {
1731
- return this.log.wrap("getBalance", params, async () => {
1732
- await this.ctx.ensureUserAuthenticated();
1733
- return getTokenBalance(this.ctx.api, params);
1734
- });
2733
+ return this.log.wrap(
2734
+ "getBalance",
2735
+ params,
2736
+ async () => getTokenBalance(this.ctx.rpc, params)
2737
+ );
1735
2738
  }
1736
2739
  };
1737
2740
 
@@ -1895,9 +2898,9 @@ var HttpClient = class {
1895
2898
  if (url.startsWith("http://") || url.startsWith("https://")) {
1896
2899
  return url;
1897
2900
  }
1898
- const base = this.config.baseUrl.replace(/\/$/, "");
2901
+ const base2 = this.config.baseUrl.replace(/\/$/, "");
1899
2902
  const path = url.startsWith("/") ? url : `/${url}`;
1900
- return base + path;
2903
+ return base2 + path;
1901
2904
  }
1902
2905
  async runBeforeRequestMiddleware(initialRequest) {
1903
2906
  let request = initialRequest;
@@ -2321,6 +3324,7 @@ export {
2321
3324
  describeErrorUnredacted,
2322
3325
  internalLogger,
2323
3326
  HttpClient,
3327
+ ERC20_ABI,
2324
3328
  fetchAllPages,
2325
3329
  Cursor,
2326
3330
  PaginatedResponse,
@@ -2386,6 +3390,7 @@ export {
2386
3390
  assetAmount,
2387
3391
  NA_AMOUNT_ASSET_UI,
2388
3392
  formattedUsdPrice,
3393
+ viemChain,
2389
3394
  getChainId,
2390
3395
  chainFromId,
2391
3396
  getNetworkName,
@@ -2397,11 +3402,10 @@ export {
2397
3402
  OndoBuyTransaction,
2398
3403
  OndoSellTransaction,
2399
3404
  OndoNamespaceImpl,
2400
- SwapAuthorization,
3405
+ SUPERSTATE_SWAP_ABI,
2401
3406
  SwapPreview,
3407
+ PauseFlags,
2402
3408
  SwapStatus,
2403
- TokenAllowance,
2404
- TokenBalance,
2405
3409
  AllowWalletResponse,
2406
3410
  SuperstateSwapNamespaceImpl,
2407
3411
  fetchOffers,
@@ -2433,4 +3437,4 @@ export {
2433
3437
  OAuthRefreshToken,
2434
3438
  OAuthSession
2435
3439
  };
2436
- //# sourceMappingURL=chunk-D42IQHQZ.js.map
3440
+ //# sourceMappingURL=chunk-2YEJXE2V.js.map