@swapkit/helpers 4.0.0-beta.33 → 4.0.0-beta.35

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 (251) hide show
  1. package/dist/api/index.js +2 -2
  2. package/dist/api/index.js.map +1 -1
  3. package/dist/{chunk-ganzk321.js → chunk-hm14bfyg.js} +3 -3
  4. package/dist/{chunk-fazw0jvt.js.map → chunk-hm14bfyg.js.map} +1 -1
  5. package/dist/chunk-vb4wtm2w.js +4 -0
  6. package/dist/{chunk-ganzk321.js.map → chunk-vb4wtm2w.js.map} +1 -1
  7. package/dist/contracts.cjs +4 -0
  8. package/dist/contracts.cjs.map +10 -0
  9. package/dist/contracts.js +4 -0
  10. package/dist/contracts.js.map +10 -0
  11. package/dist/index.cjs +3 -3
  12. package/dist/index.cjs.map +9 -9
  13. package/dist/index.js +3 -3
  14. package/dist/index.js.map +9 -9
  15. package/dist/tokens.cjs +4 -0
  16. package/dist/tokens.cjs.map +10 -0
  17. package/dist/tokens.js +4 -0
  18. package/dist/tokens.js.map +10 -0
  19. package/dist/types/api/index.d.ts +238 -0
  20. package/dist/types/api/index.d.ts.map +1 -0
  21. package/dist/types/api/microgard/endpoints.d.ts +25 -0
  22. package/dist/types/api/microgard/endpoints.d.ts.map +1 -0
  23. package/dist/types/api/microgard/types.d.ts +56 -0
  24. package/dist/types/api/microgard/types.d.ts.map +1 -0
  25. package/dist/types/api/midgard/endpoints.d.ts +35 -0
  26. package/dist/types/api/midgard/endpoints.d.ts.map +1 -0
  27. package/dist/types/api/midgard/types.d.ts +102 -0
  28. package/dist/types/api/midgard/types.d.ts.map +1 -0
  29. package/dist/types/api/swapkitApi/endpoints.d.ts +194 -0
  30. package/dist/types/api/swapkitApi/endpoints.d.ts.map +1 -0
  31. package/dist/types/api/swapkitApi/types.d.ts +7238 -0
  32. package/dist/types/api/swapkitApi/types.d.ts.map +1 -0
  33. package/dist/types/api/thornode/endpoints.d.ts +31 -0
  34. package/dist/types/api/thornode/endpoints.d.ts.map +1 -0
  35. package/dist/types/api/thornode/types.d.ts +264 -0
  36. package/dist/types/api/thornode/types.d.ts.map +1 -0
  37. package/dist/types/api/thorswapStatic/endpoints.d.ts +7 -0
  38. package/dist/types/api/thorswapStatic/endpoints.d.ts.map +1 -0
  39. package/dist/types/api/thorswapStatic/types.d.ts +22 -0
  40. package/dist/types/api/thorswapStatic/types.d.ts.map +1 -0
  41. package/dist/types/contracts.d.ts +2 -0
  42. package/dist/types/contracts.d.ts.map +1 -0
  43. package/{src/index.ts → dist/types/index.d.ts} +3 -4
  44. package/dist/types/index.d.ts.map +1 -0
  45. package/dist/types/modules/assetValue.d.ts +71 -0
  46. package/dist/types/modules/assetValue.d.ts.map +1 -0
  47. package/dist/types/modules/bigIntArithmetics.d.ts +56 -0
  48. package/dist/types/modules/bigIntArithmetics.d.ts.map +1 -0
  49. package/dist/types/modules/feeMultiplier.d.ts +45 -0
  50. package/dist/types/modules/feeMultiplier.d.ts.map +1 -0
  51. package/dist/types/modules/requestClient.d.ts +22 -0
  52. package/dist/types/modules/requestClient.d.ts.map +1 -0
  53. package/dist/types/modules/swapKitConfig.d.ts +98 -0
  54. package/dist/types/modules/swapKitConfig.d.ts.map +1 -0
  55. package/dist/types/modules/swapKitError.d.ts +829 -0
  56. package/dist/types/modules/swapKitError.d.ts.map +1 -0
  57. package/dist/types/modules/swapKitNumber.d.ts +7 -0
  58. package/dist/types/modules/swapKitNumber.d.ts.map +1 -0
  59. package/dist/types/tokens.d.ts +2 -0
  60. package/dist/types/tokens.d.ts.map +1 -0
  61. package/dist/types/types/chains.d.ts +187 -0
  62. package/dist/types/types/chains.d.ts.map +1 -0
  63. package/dist/types/types/commonTypes.d.ts +37 -0
  64. package/dist/types/types/commonTypes.d.ts.map +1 -0
  65. package/dist/types/types/derivationPath.d.ts +17 -0
  66. package/dist/types/types/derivationPath.d.ts.map +1 -0
  67. package/dist/types/types/errors/apiV1.d.ts +2 -0
  68. package/dist/types/types/errors/apiV1.d.ts.map +1 -0
  69. package/{src/types/index.ts → dist/types/types/index.d.ts} +1 -1
  70. package/dist/types/types/index.d.ts.map +1 -0
  71. package/dist/types/types/quotes.d.ts +170 -0
  72. package/dist/types/types/quotes.d.ts.map +1 -0
  73. package/dist/types/types/radix.d.ts +15 -0
  74. package/dist/types/types/radix.d.ts.map +1 -0
  75. package/dist/types/types/sdk.d.ts +35 -0
  76. package/dist/types/types/sdk.d.ts.map +1 -0
  77. package/dist/types/types/wallet.d.ts +122 -0
  78. package/dist/types/types/wallet.d.ts.map +1 -0
  79. package/dist/types/utils/asset.d.ts +40 -0
  80. package/dist/types/utils/asset.d.ts.map +1 -0
  81. package/dist/types/utils/derivationPath.d.ts +19 -0
  82. package/dist/types/utils/derivationPath.d.ts.map +1 -0
  83. package/dist/types/utils/explorerUrls.d.ts +10 -0
  84. package/dist/types/utils/explorerUrls.d.ts.map +1 -0
  85. package/dist/types/utils/liquidity.d.ts +59 -0
  86. package/dist/types/utils/liquidity.d.ts.map +1 -0
  87. package/dist/types/utils/memo.d.ts +65 -0
  88. package/dist/types/utils/memo.d.ts.map +1 -0
  89. package/dist/types/utils/others.d.ts +9 -0
  90. package/dist/types/utils/others.d.ts.map +1 -0
  91. package/dist/types/utils/validators.d.ts +3 -0
  92. package/dist/types/utils/validators.d.ts.map +1 -0
  93. package/dist/types/utils/wallets.d.ts +32 -0
  94. package/dist/types/utils/wallets.d.ts.map +1 -0
  95. package/package.json +14 -15
  96. package/dist/chunk-06q78xy3.js +0 -4
  97. package/dist/chunk-06q78xy3.js.map +0 -10
  98. package/dist/chunk-0q5vvg5c.js +0 -5
  99. package/dist/chunk-0q5vvg5c.js.map +0 -10
  100. package/dist/chunk-18bxh1n7.js +0 -5
  101. package/dist/chunk-18bxh1n7.js.map +0 -10
  102. package/dist/chunk-3qya5ng9.js +0 -4
  103. package/dist/chunk-3qya5ng9.js.map +0 -10
  104. package/dist/chunk-4yqymkbp.js +0 -5
  105. package/dist/chunk-4yqymkbp.js.map +0 -10
  106. package/dist/chunk-50gpwcq9.js +0 -4
  107. package/dist/chunk-50gpwcq9.js.map +0 -10
  108. package/dist/chunk-6atq9cs7.js +0 -4
  109. package/dist/chunk-6atq9cs7.js.map +0 -10
  110. package/dist/chunk-6m0d5pv4.js +0 -5
  111. package/dist/chunk-6m0d5pv4.js.map +0 -10
  112. package/dist/chunk-8x46g3wq.js +0 -5
  113. package/dist/chunk-8x46g3wq.js.map +0 -10
  114. package/dist/chunk-92sk0g47.js +0 -5
  115. package/dist/chunk-92sk0g47.js.map +0 -10
  116. package/dist/chunk-9f2b3enk.js +0 -5
  117. package/dist/chunk-9f2b3enk.js.map +0 -10
  118. package/dist/chunk-adrafsdk.js +0 -5
  119. package/dist/chunk-adrafsdk.js.map +0 -10
  120. package/dist/chunk-b1hang9z.js +0 -5
  121. package/dist/chunk-b1hang9z.js.map +0 -10
  122. package/dist/chunk-becdmywt.js +0 -4
  123. package/dist/chunk-becdmywt.js.map +0 -10
  124. package/dist/chunk-ehz0t9d1.js +0 -4
  125. package/dist/chunk-ehz0t9d1.js.map +0 -10
  126. package/dist/chunk-fazw0jvt.js +0 -4
  127. package/dist/chunk-fm9ycn0h.js +0 -5
  128. package/dist/chunk-fm9ycn0h.js.map +0 -10
  129. package/dist/chunk-g67e2r57.js +0 -4
  130. package/dist/chunk-g67e2r57.js.map +0 -10
  131. package/dist/chunk-he3vy8gt.js +0 -4
  132. package/dist/chunk-he3vy8gt.js.map +0 -10
  133. package/dist/chunk-jjayk2y5.js +0 -4
  134. package/dist/chunk-jjayk2y5.js.map +0 -10
  135. package/dist/chunk-mmyv2vsv.js +0 -5
  136. package/dist/chunk-mmyv2vsv.js.map +0 -10
  137. package/dist/chunk-phev7aw7.js +0 -4
  138. package/dist/chunk-phev7aw7.js.map +0 -10
  139. package/dist/chunk-rhqk87p2.js +0 -5
  140. package/dist/chunk-rhqk87p2.js.map +0 -10
  141. package/dist/chunk-rnv7fdjk.js +0 -4
  142. package/dist/chunk-rnv7fdjk.js.map +0 -10
  143. package/dist/chunk-rwh98p1c.js +0 -4
  144. package/dist/chunk-rwh98p1c.js.map +0 -10
  145. package/dist/chunk-v9zj2gsj.js +0 -5
  146. package/dist/chunk-v9zj2gsj.js.map +0 -10
  147. package/dist/chunk-vv5bgsn8.js +0 -4
  148. package/dist/chunk-vv5bgsn8.js.map +0 -10
  149. package/dist/chunk-vwh9jfxn.js +0 -5
  150. package/dist/chunk-vwh9jfxn.js.map +0 -10
  151. package/dist/chunk-x0rqy75t.js +0 -4
  152. package/dist/chunk-x0rqy75t.js.map +0 -10
  153. package/dist/contracts/index.cjs +0 -4
  154. package/dist/contracts/index.cjs.map +0 -38
  155. package/dist/contracts/index.js +0 -4
  156. package/dist/contracts/index.js.map +0 -38
  157. package/dist/tokens/index.cjs +0 -4
  158. package/dist/tokens/index.cjs.map +0 -10
  159. package/dist/tokens/index.js +0 -4
  160. package/dist/tokens/index.js.map +0 -10
  161. package/src/api/index.ts +0 -19
  162. package/src/api/microgard/endpoints.ts +0 -83
  163. package/src/api/microgard/types.ts +0 -57
  164. package/src/api/midgard/endpoints.ts +0 -90
  165. package/src/api/midgard/types.ts +0 -106
  166. package/src/api/swapkitApi/endpoints.ts +0 -193
  167. package/src/api/swapkitApi/types.ts +0 -635
  168. package/src/api/thornode/endpoints.ts +0 -116
  169. package/src/api/thornode/types.ts +0 -276
  170. package/src/api/thorswapStatic/endpoints.ts +0 -46
  171. package/src/api/thorswapStatic/types.ts +0 -18
  172. package/src/contracts/abis/avaxGeneric.ts +0 -92
  173. package/src/contracts/abis/avaxWoofi.ts +0 -145
  174. package/src/contracts/abis/bscGeneric.ts +0 -106
  175. package/src/contracts/abis/chainflipGateway.ts +0 -330
  176. package/src/contracts/abis/erc20.ts +0 -99
  177. package/src/contracts/abis/ethGeneric.ts +0 -92
  178. package/src/contracts/abis/mayaEvmVaults.ts +0 -331
  179. package/src/contracts/abis/pancakeV2.ts +0 -145
  180. package/src/contracts/abis/pangolin.ts +0 -120
  181. package/src/contracts/abis/sushiswap.ts +0 -120
  182. package/src/contracts/abis/tcEthVault.ts +0 -650
  183. package/src/contracts/abis/traderJoe.ts +0 -120
  184. package/src/contracts/abis/uniswapV2.ts +0 -120
  185. package/src/contracts/abis/uniswapV2Leg.ts +0 -128
  186. package/src/contracts/abis/uniswapV3_100.ts +0 -128
  187. package/src/contracts/abis/uniswapV3_10000.ts +0 -128
  188. package/src/contracts/abis/uniswapV3_3000.ts +0 -128
  189. package/src/contracts/abis/uniswapV3_500.ts +0 -128
  190. package/src/contracts/index.ts +0 -95
  191. package/src/contracts/routers/index.ts +0 -58
  192. package/src/contracts/routers/kyber.ts +0 -402
  193. package/src/contracts/routers/oneinch.ts +0 -2188
  194. package/src/contracts/routers/pancakeswap.ts +0 -340
  195. package/src/contracts/routers/pangolin.ts +0 -340
  196. package/src/contracts/routers/sushiswap.ts +0 -340
  197. package/src/contracts/routers/traderJoe.ts +0 -340
  198. package/src/contracts/routers/uniswapv2.ts +0 -340
  199. package/src/contracts/routers/uniswapv3.ts +0 -254
  200. package/src/contracts/routers/woofi.ts +0 -171
  201. package/src/modules/__tests__/assetValue.test.ts +0 -877
  202. package/src/modules/__tests__/bigIntArithmetics.test.ts +0 -30
  203. package/src/modules/__tests__/swapKitConfig.test.ts +0 -37
  204. package/src/modules/__tests__/swapKitNumber.test.ts +0 -560
  205. package/src/modules/assetValue.ts +0 -387
  206. package/src/modules/bigIntArithmetics.ts +0 -436
  207. package/src/modules/feeMultiplier.ts +0 -87
  208. package/src/modules/requestClient.ts +0 -83
  209. package/src/modules/swapKitConfig.ts +0 -143
  210. package/src/modules/swapKitError.ts +0 -442
  211. package/src/modules/swapKitNumber.ts +0 -16
  212. package/src/tokens/index.ts +0 -15
  213. package/src/tokens/lists/camelot_v3.ts +0 -16060
  214. package/src/tokens/lists/caviar_v1.ts +0 -1704
  215. package/src/tokens/lists/chainflip.ts +0 -104
  216. package/src/tokens/lists/index.ts +0 -14
  217. package/src/tokens/lists/jupiter.ts +0 -33563
  218. package/src/tokens/lists/mayachain.ts +0 -509
  219. package/src/tokens/lists/near.ts +0 -458
  220. package/src/tokens/lists/oneinch.ts +0 -15006
  221. package/src/tokens/lists/openocean_v2.ts +0 -12434
  222. package/src/tokens/lists/pancakeswap.ts +0 -6136
  223. package/src/tokens/lists/pangolin_v1.ts +0 -75
  224. package/src/tokens/lists/sushiswap_v2.ts +0 -595
  225. package/src/tokens/lists/thorchain.ts +0 -748
  226. package/src/tokens/lists/traderjoe_v2.ts +0 -594
  227. package/src/tokens/lists/uniswap_v2.ts +0 -11484
  228. package/src/tokens/lists/uniswap_v3.ts +0 -19424
  229. package/src/types/chains.ts +0 -555
  230. package/src/types/commonTypes.ts +0 -58
  231. package/src/types/derivationPath.ts +0 -58
  232. package/src/types/errors/apiV1.ts +0 -0
  233. package/src/types/quotes.ts +0 -172
  234. package/src/types/radix.ts +0 -14
  235. package/src/types/sdk.ts +0 -42
  236. package/src/types/tokens.ts +0 -17
  237. package/src/types/wallet.ts +0 -166
  238. package/src/utils/__tests__/asset.test.ts +0 -193
  239. package/src/utils/__tests__/derivationPath.test.ts +0 -16
  240. package/src/utils/__tests__/memo.test.ts +0 -103
  241. package/src/utils/__tests__/others.test.ts +0 -88
  242. package/src/utils/__tests__/validators.test.ts +0 -24
  243. package/src/utils/asset.ts +0 -231
  244. package/src/utils/derivationPath.ts +0 -98
  245. package/src/utils/liquidity.ts +0 -179
  246. package/src/utils/memo.ts +0 -143
  247. package/src/utils/others.ts +0 -86
  248. package/src/utils/plugin.ts +0 -13
  249. package/src/utils/tokens.ts +0 -73
  250. package/src/utils/validators.ts +0 -32
  251. package/src/utils/wallets.ts +0 -276
@@ -1,143 +0,0 @@
1
- import { createStore } from "zustand/vanilla";
2
- import { Chain, EXPLORER_URLS, NODE_URLS, RPC_URLS, WalletOption } from "../types";
3
- import type { FeeMultiplierConfig } from "./feeMultiplier";
4
-
5
- export type SKConfigIntegrations = {
6
- chainflip?: { useSDKBroker?: boolean; brokerUrl: string };
7
- coinbase?: {
8
- appName: string;
9
- appLogoUrl?: string | null;
10
- darkMode?: boolean;
11
- linkAPIUrl?: string;
12
- overrideIsMetaMask?: boolean;
13
- overrideIsCoinbaseWallet?: boolean;
14
- overrideIsCoinbaseBrowser?: boolean;
15
- headlessMode?: boolean;
16
- reloadOnDisconnect?: boolean;
17
- };
18
- trezor?: { email: string; appUrl: string };
19
- keepKey?: { name: string; imageUrl: string; basePath: string; url: string };
20
- radix: {
21
- dAppDefinitionAddress: string;
22
- applicationName: string;
23
- applicationVersion: string;
24
- network: { networkId: number; networkName: string; dashboardBase: string };
25
- };
26
- };
27
-
28
- const initialState = {
29
- // TODO: figure out how to type apis without using toolbox directly
30
- // Maybe move rpc/toolbox apis to helpers?
31
- apis: {} as { [key in Chain]: any },
32
- chains: Object.values(Chain),
33
- wallets: Object.values(WalletOption),
34
- explorerUrls: EXPLORER_URLS,
35
- nodeUrls: NODE_URLS,
36
- rpcUrls: RPC_URLS,
37
-
38
- apiKeys: {
39
- blockchair: "",
40
- keepKey: "",
41
- swapKit: "",
42
- walletConnectProjectId: "",
43
- xaman: "",
44
- },
45
-
46
- envs: {
47
- apiUrl: "https://api.swapkit.dev",
48
- devApiUrl: "https://dev-api.swapkit.dev",
49
- isDev: false,
50
- isStagenet: false,
51
- },
52
-
53
- integrations: {
54
- radix: {
55
- applicationName: "Swapkit Playground",
56
- applicationVersion: "0.0.1",
57
- dAppDefinitionAddress: "account_rdx128r289p58222hcvev7frs6kue76pl7pdcnw8725aw658v0zggkh9ws",
58
- network: {
59
- dashboardBase: "https://dashboard.radixdlt.com",
60
- networkId: 1,
61
- networkName: "mainnet",
62
- },
63
- },
64
- } as SKConfigIntegrations,
65
-
66
- feeMultipliers: undefined as FeeMultiplierConfig | undefined,
67
- };
68
- type SKState = typeof initialState;
69
-
70
- export type SKConfigState = {
71
- apiKeys?: Partial<SKState["apiKeys"]>;
72
- chains?: SKState["chains"];
73
- envs?: Partial<SKState["envs"]>;
74
- explorerUrls?: Partial<SKState["explorerUrls"]>;
75
- integrations?: Partial<SKConfigIntegrations>;
76
- nodeUrls?: Partial<SKState["nodeUrls"]>;
77
- rpcUrls?: Partial<SKState["rpcUrls"]>;
78
- wallets?: SKState["wallets"];
79
- feeMultipliers?: FeeMultiplierConfig;
80
- };
81
-
82
- type SwapKitConfigStore = SKState & {
83
- setApiKey: (key: keyof SKState["apiKeys"], apiKey: string) => void;
84
- setConfig: (config: SKConfigState) => void;
85
- setEnv: <T extends keyof SKState["envs"]>(key: T, value: SKState["envs"][T]) => void;
86
- setExplorerUrl: (chain: keyof SKState["explorerUrls"], url: string) => void;
87
- setNodeUrl: (chain: keyof SKState["nodeUrls"], url: string) => void;
88
- setRpcUrl: (chain: keyof SKState["rpcUrls"], url: string) => void;
89
- setIntegrationConfig: (
90
- integration: keyof SKState["integrations"],
91
- config: SKConfigIntegrations[keyof SKConfigIntegrations],
92
- ) => void;
93
- setFeeMultipliers: (multipliers: FeeMultiplierConfig) => void;
94
- };
95
-
96
- const swapKitState = createStore<SwapKitConfigStore>((set) => ({
97
- ...initialState,
98
-
99
- setApiKey: (key, apiKey) => set((s) => ({ apiKeys: { ...s.apiKeys, [key]: apiKey } })),
100
- setEnv: (key, value) => set((s) => ({ envs: { ...s.envs, [key]: value } })),
101
- setExplorerUrl: (chain, url) =>
102
- set((s) => ({ explorerUrls: { ...s.explorerUrls, [chain]: url } })),
103
- setNodeUrl: (chain, url) => set((s) => ({ nodeUrls: { ...s.nodeUrls, [chain]: url } })),
104
- setRpcUrl: (chain, url) => set((s) => ({ rpcUrls: { ...s.rpcUrls, [chain]: url } })),
105
- setIntegrationConfig: (integration, config) =>
106
- set((s) => ({ integrations: { ...s.integrations, [integration]: config } })),
107
- setFeeMultipliers: (multipliers) => set(() => ({ feeMultipliers: multipliers })),
108
- setConfig: (config) =>
109
- set((s) => ({
110
- apiKeys: { ...s.apiKeys, ...config.apiKeys },
111
- envs: { ...s.envs, ...config.envs },
112
- explorerUrls: { ...s.explorerUrls, ...config.explorerUrls },
113
- integrations: { ...s.integrations, ...config.integrations },
114
- nodeUrls: { ...s.nodeUrls, ...config.nodeUrls },
115
- rpcUrls: { ...s.rpcUrls, ...config.rpcUrls },
116
- feeMultipliers: config.feeMultipliers || s.feeMultipliers,
117
- chains: s.chains.concat(config.chains || []),
118
- wallets: s.wallets.concat(config.wallets || []),
119
- })),
120
- }));
121
-
122
- export const SKConfig = {
123
- getState: swapKitState.getState,
124
- get: <T extends keyof SKState>(key: T) => swapKitState.getState()[key],
125
- set: <T extends SKConfigState>(config: T) => swapKitState.getState().setConfig(config),
126
-
127
- setApiKey: <T extends keyof SKState["apiKeys"]>(key: T, apiKey: string) =>
128
- swapKitState.getState().setApiKey(key, apiKey),
129
- setEnv: <T extends keyof SKState["envs"]>(key: T, value: SKState["envs"][T]) =>
130
- swapKitState.getState().setEnv(key, value),
131
- setExplorerUrl: <T extends keyof SKState["explorerUrls"]>(chain: T, url: string) =>
132
- swapKitState.getState().setExplorerUrl(chain, url),
133
- setNodeUrl: <T extends keyof SKState["nodeUrls"]>(chain: T, url: string) =>
134
- swapKitState.getState().setNodeUrl(chain, url),
135
- setRpcUrl: <T extends keyof SKState["rpcUrls"]>(chain: T, url: string) =>
136
- swapKitState.getState().setRpcUrl(chain, url),
137
- setIntegrationConfig: <T extends keyof SKState["integrations"]>(
138
- integration: T,
139
- config: SKConfigIntegrations[T],
140
- ) => swapKitState.getState().setIntegrationConfig(integration, config),
141
- setFeeMultipliers: (multipliers: FeeMultiplierConfig) =>
142
- swapKitState.getState().setFeeMultipliers(multipliers),
143
- };
@@ -1,442 +0,0 @@
1
- const errorCodes = {
2
- /**
3
- * Core
4
- */
5
- core_estimated_max_spendable_chain_not_supported: 10001,
6
- core_extend_error: 10002,
7
- core_inbound_data_not_found: 10003,
8
- core_approve_asset_address_or_from_not_found: 10004,
9
- core_plugin_not_found: 10005,
10
- core_plugin_swap_not_found: 10006,
11
- core_approve_asset_target_invalid: 10007,
12
- core_explorer_unsupported_chain: 10008,
13
- core_verify_message_not_supported: 10009,
14
- core_chain_halted: 10010,
15
- /**
16
- * Core - Wallet
17
- */
18
- core_wallet_connection_not_found: 10101,
19
- core_wallet_ctrl_not_installed: 10102,
20
- core_wallet_evmwallet_not_installed: 10103,
21
- core_wallet_walletconnect_not_installed: 10104,
22
- core_wallet_keystore_not_installed: 10105,
23
- core_wallet_ledger_not_installed: 10106,
24
- core_wallet_trezor_not_installed: 10107,
25
- core_wallet_keplr_not_installed: 10108,
26
- core_wallet_okx_not_installed: 10109,
27
- core_wallet_keepkey_not_installed: 10110,
28
- core_wallet_talisman_not_installed: 10111,
29
- core_wallet_not_keypair_wallet: 10112,
30
- core_wallet_sign_message_not_supported: 10113,
31
- core_wallet_connection_failed: 10114,
32
- /**
33
- * Core - Swap
34
- */
35
- core_swap_invalid_params: 10201,
36
- core_swap_route_not_complete: 10202,
37
- core_swap_asset_not_recognized: 10203,
38
- core_swap_contract_not_found: 10204,
39
- core_swap_route_transaction_not_found: 10205,
40
- core_swap_contract_not_supported: 10206,
41
- core_swap_transaction_error: 10207,
42
- core_swap_quote_mode_not_supported: 10208,
43
- /**
44
- * Core - Transaction
45
- */
46
- core_transaction_deposit_error: 10301,
47
- core_transaction_create_liquidity_base_error: 10302,
48
- core_transaction_create_liquidity_asset_error: 10303,
49
- core_transaction_create_liquidity_invalid_params: 10304,
50
- core_transaction_add_liquidity_invalid_params: 10305,
51
- core_transaction_add_liquidity_base_address: 10306,
52
- core_transaction_add_liquidity_base_error: 10307,
53
- core_transaction_add_liquidity_asset_error: 10308,
54
- core_transaction_withdraw_error: 10309,
55
- core_transaction_deposit_to_pool_error: 10310,
56
- core_transaction_deposit_insufficient_funds_error: 10311,
57
- core_transaction_deposit_gas_error: 10312,
58
- core_transaction_invalid_sender_address: 10313,
59
- core_transaction_deposit_server_error: 10314,
60
- core_transaction_user_rejected: 10315,
61
- core_transaction_failed: 10316,
62
- core_transaction_invalid_recipient_address: 10317,
63
- /**
64
- * Wallets - General
65
- */
66
- wallet_connection_rejected_by_user: 20001,
67
- wallet_missing_api_key: 20002,
68
- wallet_chain_not_supported: 20003,
69
- wallet_missing_params: 20004,
70
- wallet_provider_not_found: 20005,
71
- wallet_failed_to_add_or_switch_network: 20006,
72
- /**
73
- * Wallets - Ledger
74
- */
75
- wallet_ledger_connection_error: 20101,
76
- wallet_ledger_connection_claimed: 20102,
77
- wallet_ledger_get_address_error: 20103,
78
- wallet_ledger_device_not_found: 20104,
79
- wallet_ledger_device_locked: 20105,
80
- wallet_ledger_transport_error: 20106,
81
- wallet_ledger_public_key_error: 20107,
82
- wallet_ledger_derivation_path_error: 20108,
83
- wallet_ledger_signing_error: 20109,
84
- wallet_ledger_app_not_open: 20110,
85
- wallet_ledger_invalid_response: 20111,
86
- wallet_ledger_method_not_supported: 20112,
87
- wallet_ledger_invalid_params: 20113,
88
- wallet_ledger_invalid_signature: 20114,
89
- wallet_ledger_no_provider: 20115,
90
- wallet_ledger_pubkey_not_found: 20116,
91
- wallet_ledger_transport_not_defined: 20117,
92
- wallet_ledger_webusb_not_supported: 20118,
93
- wallet_ledger_chain_not_supported: 20119,
94
- wallet_ledger_invalid_asset: 20120,
95
- wallet_ledger_invalid_account: 20121,
96
- wallet_ledger_address_not_found: 20122,
97
- wallet_ledger_failed_to_get_address: 20123,
98
- /**
99
- * Wallets - Phantom
100
- */
101
- wallet_phantom_not_found: 20201,
102
- /**
103
- * Wallets - Ctrl
104
- */
105
- wallet_ctrl_not_found: 20301,
106
- wallet_ctrl_send_transaction_no_address: 20302,
107
- wallet_ctrl_contract_address_not_provided: 20303,
108
- wallet_ctrl_asset_not_defined: 20304,
109
- /**
110
- * Wallets - WalletConnect
111
- */
112
- wallet_walletconnect_project_id_not_specified: 20401,
113
- wallet_walletconnect_connection_not_established: 20402,
114
- wallet_walletconnect_namespace_not_supported: 20403,
115
- wallet_walletconnect_chain_not_supported: 20404,
116
- wallet_walletconnect_invalid_method: 20405,
117
- wallet_walletconnect_method_not_supported: 20406,
118
- /**
119
- * Wallets - Trezor
120
- */
121
- wallet_trezor_failed_to_sign_transaction: 20501,
122
- wallet_trezor_derivation_path_not_supported: 20502,
123
- wallet_trezor_failed_to_get_address: 20503,
124
- wallet_trezor_transport_error: 20504,
125
- wallet_trezor_method_not_supported: 20505,
126
- /**
127
- * Wallets - Talisman
128
- */
129
- wallet_talisman_not_enabled: 20601,
130
- wallet_talisman_not_found: 20602,
131
- /**
132
- * Wallets - Polkadot
133
- */
134
- wallet_polkadot_not_found: 20701,
135
- /**
136
- * Wallets - Radix
137
- */
138
- wallet_radix_not_found: 20801,
139
- wallet_radix_transaction_failed: 20802,
140
- wallet_radix_invalid_manifest: 20803,
141
- wallet_radix_method_not_supported: 20804,
142
- wallet_radix_no_account: 20805,
143
- /**
144
- * Wallets - KeepKey
145
- */
146
- wallet_keepkey_not_found: 20901,
147
- wallet_keepkey_asset_not_defined: 20902,
148
- wallet_keepkey_contract_address_not_provided: 20903,
149
- wallet_keepkey_send_transaction_no_address: 20904,
150
- wallet_keepkey_derivation_path_error: 20905,
151
- wallet_keepkey_signing_error: 20906,
152
- wallet_keepkey_transport_error: 20907,
153
- wallet_keepkey_unsupported_chain: 20908,
154
- wallet_keepkey_invalid_response: 20909,
155
- wallet_keepkey_chain_not_supported: 20910,
156
- wallet_keepkey_signer_not_found: 20911,
157
- wallet_keepkey_no_accounts: 20912,
158
- wallet_keepkey_method_not_supported: 20913,
159
- wallet_keepkey_invalid_params: 20914,
160
- wallet_keepkey_config_not_found: 20915,
161
- wallet_keepkey_no_provider: 20916,
162
- wallet_keepkey_account_not_found: 20917,
163
- /**
164
- * Wallets - BitKeep/BitGet
165
- */
166
- wallet_bitkeep_not_found: 21001,
167
- wallet_bitkeep_failed_to_switch_network: 21002,
168
- wallet_bitkeep_no_accounts: 21003,
169
- /**
170
- * Wallets - Exodus
171
- */
172
- wallet_exodus_sign_transaction_error: 21101,
173
- wallet_exodus_not_found: 21102,
174
- wallet_exodus_no_address: 21103,
175
- wallet_exodus_request_canceled: 21104,
176
- wallet_exodus_signature_canceled: 21105,
177
- wallet_exodus_failed_to_switch_network: 21106,
178
- wallet_exodus_chain_not_supported: 21107,
179
- wallet_exodus_instance_missing: 21108,
180
- /**
181
- * Wallets - OneKey
182
- */
183
- wallet_onekey_not_found: 21201,
184
- wallet_onekey_sign_transaction_error: 21202,
185
- /**
186
- * Wallets - OKX
187
- */
188
- wallet_okx_not_found: 21301,
189
- wallet_okx_chain_not_supported: 21302,
190
- wallet_okx_failed_to_switch_network: 21303,
191
- wallet_okx_no_accounts: 21304,
192
- /**
193
- * Wallets - Keplr
194
- */
195
- wallet_keplr_not_found: 21401,
196
- wallet_keplr_chain_not_supported: 21402,
197
- wallet_keplr_signer_not_found: 21403,
198
- wallet_keplr_no_accounts: 21404,
199
- /**
200
- * Wallets - Cosmostation
201
- */
202
- wallet_cosmostation_not_found: 21501,
203
- wallet_cosmostation_chain_not_supported: 21502,
204
- wallet_cosmostation_evm_provider_not_found: 21503,
205
- wallet_cosmostation_keplr_provider_not_found: 21504,
206
- wallet_cosmostation_no_accounts: 21505,
207
- wallet_cosmostation_no_evm_accounts: 21506,
208
- wallet_cosmostation_no_evm_address: 21507,
209
- wallet_cosmostation_signer_not_found: 21508,
210
- /**
211
- * Wallets - XDefi
212
- */
213
- wallet_xdefi_not_found: 21601,
214
- wallet_xdefi_chain_not_supported: 21602,
215
- /**
216
- * Wallets - Coinbase
217
- */
218
- wallet_coinbase_not_found: 21701,
219
- wallet_coinbase_chain_not_supported: 21702,
220
- wallet_coinbase_method_not_supported: 21703,
221
- wallet_coinbase_no_accounts: 21704,
222
- /**
223
- * Wallets - EVM Extensions
224
- */
225
- wallet_evm_extensions_failed_to_switch_network: 21801,
226
- wallet_evm_extensions_no_provider: 21802,
227
- wallet_evm_extensions_not_found: 21803,
228
- /**
229
- * Wallets - Keystore
230
- */
231
- wallet_keystore_invalid_password: 21901,
232
- wallet_keystore_unsupported_version: 21902,
233
- /**
234
- * Wallets - Near Extensions
235
- */
236
- wallet_near_extensions_failed_to_switch_network: 22001,
237
- wallet_near_extensions_no_provider: 22002,
238
- wallet_near_extensions_not_found: 22003,
239
- wallet_near_method_not_supported: 22003,
240
-
241
- /**
242
- * Wallets - Vultisig
243
- */
244
- wallet_vultisig_not_found: 22101,
245
- wallet_vultisig_contract_address_not_provided: 22102,
246
- wallet_vultisig_asset_not_defined: 22103,
247
- wallet_vultisig_send_transaction_no_address: 22104,
248
-
249
- /**
250
- * Wallets - Xaman
251
- */
252
- wallet_xaman_not_configured: 23001,
253
- wallet_xaman_not_connected: 23002,
254
- wallet_xaman_auth_failed: 23003,
255
- wallet_xaman_connection_failed: 23004,
256
- wallet_xaman_transaction_failed: 23005,
257
- wallet_xaman_monitoring_failed: 23006,
258
-
259
- /**
260
- * Chainflip
261
- */
262
- chainflip_channel_error: 30001,
263
- chainflip_unknown_asset: 30002,
264
- /**
265
- * Chainflip - Broker
266
- */
267
- chainflip_broker_invalid_params: 30101,
268
- chainflip_broker_recipient_error: 30102,
269
- chainflip_broker_register: 30103,
270
- chainflip_broker_tx_error: 30104,
271
- chainflip_broker_withdraw: 30105,
272
- chainflip_broker_fund_only_flip_supported: 30106,
273
- chainflip_broker_fund_invalid_address: 30107,
274
- /**
275
- * THORChain
276
- */
277
- thorchain_chain_halted: 40001,
278
- thorchain_trading_halted: 40002,
279
- thorchain_asset_is_not_tcy: 40003,
280
- /**
281
- * THORChain - Swap
282
- */
283
- thorchain_swapin_router_required: 40101,
284
- thorchain_swapin_vault_required: 40102,
285
- thorchain_swapin_memo_required: 40103,
286
- thorchain_swapin_token_required: 40104,
287
- thorchain_preferred_asset_payout_required: 40105,
288
- /**
289
- * Toolboxes - Cosmos
290
- */
291
- toolbox_cosmos_account_not_found: 50101,
292
- toolbox_cosmos_invalid_fee: 50102,
293
- toolbox_cosmos_invalid_params: 50103,
294
- toolbox_cosmos_no_signer: 50104,
295
- toolbox_cosmos_not_supported: 50105,
296
- toolbox_cosmos_signer_not_defined: 50106,
297
- toolbox_cosmos_validate_address_prefix_not_found: 50107,
298
- toolbox_cosmos_verify_signature_no_pubkey: 50108,
299
- /**
300
- * Toolboxes - EVM
301
- */
302
- toolbox_evm_error_estimating_gas_limit: 50201,
303
- toolbox_evm_error_sending_transaction: 50202,
304
- toolbox_evm_gas_estimation_error: 50203,
305
- toolbox_evm_invalid_gas_asset_address: 50204,
306
- toolbox_evm_invalid_params: 50205,
307
- toolbox_evm_invalid_transaction: 50206,
308
- toolbox_evm_no_abi_fragment: 50207,
309
- toolbox_evm_no_contract_address: 50208,
310
- toolbox_evm_no_fee_data: 50209,
311
- toolbox_evm_no_from_address: 50210,
312
- toolbox_evm_no_gas_price: 50211,
313
- toolbox_evm_no_signer_address: 50212,
314
- toolbox_evm_no_signer: 50213,
315
- toolbox_evm_no_to_address: 50214,
316
- toolbox_evm_not_supported: 50215,
317
- toolbox_evm_provider_not_eip1193_compatible: 50216,
318
- /**
319
- * Toolboxes - UTXO
320
- */
321
- toolbox_utxo_api_error: 50301,
322
- toolbox_utxo_broadcast_failed: 50302,
323
- toolbox_utxo_insufficient_balance: 50303,
324
- toolbox_utxo_invalid_address: 50304,
325
- toolbox_utxo_invalid_params: 50305,
326
- toolbox_utxo_invalid_transaction: 50306,
327
- toolbox_utxo_no_signer: 50307,
328
- toolbox_utxo_not_supported: 50308,
329
- /**
330
- * Toolboxes - Solana
331
- */
332
- toolbox_solana_no_signer: 50401,
333
- toolbox_solana_fee_estimation_failed: 50402,
334
- /**
335
- * Toolboxes - Substrate
336
- */
337
- toolbox_substrate_not_supported: 50501,
338
- /**
339
- * Toolboxes - Radix
340
- */
341
- toolbox_radix_method_not_supported: 50601,
342
- /**
343
- * Toolboxes - Ripple
344
- */
345
- toolbox_ripple_get_balance_error: 50701,
346
- toolbox_ripple_rpc_not_configured: 50702,
347
- toolbox_ripple_signer_not_found: 50703,
348
- toolbox_ripple_asset_not_supported: 50704,
349
- toolbox_ripple_broadcast_error: 50705,
350
- /**
351
- * Toolboxes - Tron
352
- */
353
- toolbox_tron_no_signer: 50801,
354
- toolbox_tron_invalid_token_identifier: 50802,
355
- toolbox_tron_token_transfer_failed: 50803,
356
- toolbox_tron_transaction_creation_failed: 50804,
357
- toolbox_tron_fee_estimation_failed: 50805,
358
- toolbox_tron_trongrid_api_error: 50806,
359
- toolbox_tron_approve_failed: 50807,
360
- toolbox_tron_invalid_token_contract: 50808,
361
- toolbox_tron_allowance_check_failed: 50809,
362
- /**
363
- * Toolboxes - Near
364
- */
365
- toolbox_near_no_signer: 90601,
366
- toolbox_near_invalid_address: 90602,
367
- toolbox_near_invalid_amount: 90603,
368
- toolbox_near_transfer_failed: 90604,
369
- toolbox_near_access_key_error: 90605,
370
- toolbox_near_no_rpc_url: 90606,
371
- toolbox_near_empty_batch: 90607,
372
- toolbox_near_balance_failed: 90608,
373
- toolbox_near_invalid_name: 90609,
374
- toolbox_near_missing_contract_address: 90610,
375
- toolbox_near_no_account: 90611,
376
- toolbox_near_invalid_gas_params: 90612,
377
- /**
378
- * Toolboxes - General
379
- */
380
- toolbox_not_supported: 59901,
381
- /**
382
- * NEAR Plugin
383
- */
384
- plugin_near_invalid_name: 41001,
385
- plugin_near_no_connection: 41002,
386
- plugin_near_name_unavailable: 41003,
387
- plugin_near_registration_failed: 41004,
388
- plugin_near_transfer_failed: 41005,
389
- /**
390
- * SwapKit API
391
- */
392
- api_v2_invalid_response: 60001,
393
- api_v2_server_error: 60002,
394
- api_v2_invalid_method_key_hash: 60003,
395
- /**
396
- * Helpers
397
- */
398
- helpers_invalid_number_different_decimals: 70001,
399
- helpers_invalid_number_of_years: 70002,
400
- helpers_invalid_identifier: 70003,
401
- helpers_invalid_asset_url: 70004,
402
- helpers_invalid_asset_identifier: 70005,
403
- helpers_invalid_memo_type: 70006,
404
- helpers_failed_to_switch_network: 70007,
405
- helpers_not_found_provider: 70008,
406
- helpers_chain_not_supported: 70009,
407
- helpers_invalid_params: 70010,
408
- helpers_invalid_response: 70011,
409
- /**
410
- * Anything else
411
- */
412
- not_implemented: 99999,
413
- } as const;
414
-
415
- export type ErrorKeys = keyof typeof errorCodes;
416
-
417
- export class SwapKitError extends Error {
418
- static ErrorCode = errorCodes;
419
-
420
- constructor(
421
- errorOrErrorKey: ErrorKeys | { errorKey: ErrorKeys; info?: Record<string, any> },
422
- sourceErrorOrInfo?: any,
423
- ) {
424
- const isErrorString = typeof errorOrErrorKey === "string";
425
- const errorKey = isErrorString ? errorOrErrorKey : errorOrErrorKey.errorKey;
426
- const info = isErrorString ? undefined : errorOrErrorKey.info;
427
- const message = `${errorKey}${info ? `: ${JSON.stringify(info)}` : ""}`;
428
-
429
- super(message);
430
- Object.setPrototypeOf(this, SwapKitError.prototype);
431
-
432
- this.name = "SwapKitError";
433
- this.cause = sourceErrorOrInfo;
434
-
435
- // Log errors for debugging - bundlers can strip this in production if needed
436
- if (sourceErrorOrInfo) {
437
- console.error(`SwapKitError [${errorKey}]:`, sourceErrorOrInfo);
438
- } else if (info) {
439
- console.error(`SwapKitError [${errorKey}]:`, info);
440
- }
441
- }
442
- }
@@ -1,16 +0,0 @@
1
- import { BigIntArithmetics, formatBigIntToSafeValue } from "./bigIntArithmetics";
2
-
3
- export type SwapKitValueType = BigIntArithmetics | string | number;
4
-
5
- export class SwapKitNumber extends BigIntArithmetics {
6
- eq(value: SwapKitValueType) {
7
- return this.eqValue(value);
8
- }
9
-
10
- static fromBigInt(value: bigint, decimal?: number) {
11
- return new SwapKitNumber({
12
- decimal,
13
- value: formatBigIntToSafeValue({ value, bigIntDecimal: decimal, decimal }),
14
- });
15
- }
16
- }
@@ -1,15 +0,0 @@
1
- import * as tokenLists from "./lists";
2
-
3
- export function getTokenIcon(identifier: string): string | undefined {
4
- // Search through all lists for a matching token
5
- for (const list of Object.values(tokenLists)) {
6
- const token = list.tokens.find((token) => token.identifier === identifier);
7
- if (token?.logoURI) {
8
- return token.logoURI;
9
- }
10
- }
11
-
12
- return undefined;
13
- }
14
-
15
- export { tokenLists };