@sodax/sdk 0.0.1-rc.7 → 0.0.1-rc.9

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 (295) hide show
  1. package/README.md +3 -1
  2. package/dist/index.cjs +11147 -0
  3. package/dist/index.cjs.map +1 -0
  4. package/dist/index.d.cts +6831 -0
  5. package/dist/index.d.ts +6830 -9
  6. package/dist/index.mjs +10991 -0
  7. package/dist/index.mjs.map +1 -0
  8. package/package.json +20 -5
  9. package/dist/abis/asset-manager.abi.d.ts +0 -418
  10. package/dist/abis/asset-manager.abi.d.ts.map +0 -1
  11. package/dist/abis/asset-manager.abi.js +0 -542
  12. package/dist/abis/asset-manager.abi.js.map +0 -1
  13. package/dist/abis/connection.abi.d.ts +0 -72
  14. package/dist/abis/connection.abi.d.ts.map +0 -1
  15. package/dist/abis/connection.abi.js +0 -92
  16. package/dist/abis/connection.abi.js.map +0 -1
  17. package/dist/abis/erc20.abi.d.ts +0 -236
  18. package/dist/abis/erc20.abi.d.ts.map +0 -1
  19. package/dist/abis/erc20.abi.js +0 -311
  20. package/dist/abis/erc20.abi.js.map +0 -1
  21. package/dist/abis/index.d.ts +0 -10
  22. package/dist/abis/index.d.ts.map +0 -1
  23. package/dist/abis/index.js +0 -10
  24. package/dist/abis/index.js.map +0 -1
  25. package/dist/abis/intents.abi.d.ts +0 -901
  26. package/dist/abis/intents.abi.d.ts.map +0 -1
  27. package/dist/abis/intents.abi.js +0 -1158
  28. package/dist/abis/intents.abi.js.map +0 -1
  29. package/dist/abis/pool.abi.d.ts +0 -626
  30. package/dist/abis/pool.abi.d.ts.map +0 -1
  31. package/dist/abis/pool.abi.js +0 -812
  32. package/dist/abis/pool.abi.js.map +0 -1
  33. package/dist/abis/spokeAssetManager.abi.d.ts +0 -169
  34. package/dist/abis/spokeAssetManager.abi.d.ts.map +0 -1
  35. package/dist/abis/spokeAssetManager.abi.js +0 -217
  36. package/dist/abis/spokeAssetManager.abi.js.map +0 -1
  37. package/dist/abis/uiPoolData.abi.d.ts +0 -369
  38. package/dist/abis/uiPoolData.abi.d.ts.map +0 -1
  39. package/dist/abis/uiPoolData.abi.js +0 -476
  40. package/dist/abis/uiPoolData.abi.js.map +0 -1
  41. package/dist/abis/vaultToken.abi.d.ts +0 -816
  42. package/dist/abis/vaultToken.abi.d.ts.map +0 -1
  43. package/dist/abis/vaultToken.abi.js +0 -1062
  44. package/dist/abis/vaultToken.abi.js.map +0 -1
  45. package/dist/abis/walletFactory.abi.d.ts +0 -20
  46. package/dist/abis/walletFactory.abi.d.ts.map +0 -1
  47. package/dist/abis/walletFactory.abi.js +0 -27
  48. package/dist/abis/walletFactory.abi.js.map +0 -1
  49. package/dist/constants.d.ts +0 -550
  50. package/dist/constants.d.ts.map +0 -1
  51. package/dist/constants.js +0 -1189
  52. package/dist/constants.js.map +0 -1
  53. package/dist/constants.test.d.ts +0 -2
  54. package/dist/constants.test.d.ts.map +0 -1
  55. package/dist/constants.test.js +0 -129
  56. package/dist/constants.test.js.map +0 -1
  57. package/dist/entities/Providers.d.ts +0 -52
  58. package/dist/entities/Providers.d.ts.map +0 -1
  59. package/dist/entities/Providers.js +0 -49
  60. package/dist/entities/Providers.js.map +0 -1
  61. package/dist/entities/Sodax.d.ts +0 -23
  62. package/dist/entities/Sodax.d.ts.map +0 -1
  63. package/dist/entities/Sodax.js +0 -29
  64. package/dist/entities/Sodax.js.map +0 -1
  65. package/dist/entities/Sodax.test.d.ts +0 -2
  66. package/dist/entities/Sodax.test.d.ts.map +0 -1
  67. package/dist/entities/Sodax.test.js +0 -392
  68. package/dist/entities/Sodax.test.js.map +0 -1
  69. package/dist/entities/cosmos/CW20Token.d.ts +0 -39
  70. package/dist/entities/cosmos/CW20Token.d.ts.map +0 -1
  71. package/dist/entities/cosmos/CW20Token.js +0 -65
  72. package/dist/entities/cosmos/CW20Token.js.map +0 -1
  73. package/dist/entities/cosmos/CWSpokeProvider.d.ts +0 -78
  74. package/dist/entities/cosmos/CWSpokeProvider.d.ts.map +0 -1
  75. package/dist/entities/cosmos/CWSpokeProvider.js +0 -127
  76. package/dist/entities/cosmos/CWSpokeProvider.js.map +0 -1
  77. package/dist/entities/icon/HanaWalletConnector.d.ts +0 -36
  78. package/dist/entities/icon/HanaWalletConnector.d.ts.map +0 -1
  79. package/dist/entities/icon/HanaWalletConnector.js +0 -92
  80. package/dist/entities/icon/HanaWalletConnector.js.map +0 -1
  81. package/dist/entities/icon/IconSpokeProvider.d.ts +0 -10
  82. package/dist/entities/icon/IconSpokeProvider.d.ts.map +0 -1
  83. package/dist/entities/icon/IconSpokeProvider.js +0 -12
  84. package/dist/entities/icon/IconSpokeProvider.js.map +0 -1
  85. package/dist/entities/icon/index.d.ts +0 -4
  86. package/dist/entities/icon/index.d.ts.map +0 -1
  87. package/dist/entities/icon/index.js +0 -4
  88. package/dist/entities/icon/index.js.map +0 -1
  89. package/dist/entities/icon/utils.d.ts +0 -3
  90. package/dist/entities/icon/utils.d.ts.map +0 -1
  91. package/dist/entities/icon/utils.js +0 -4
  92. package/dist/entities/icon/utils.js.map +0 -1
  93. package/dist/entities/index.d.ts +0 -7
  94. package/dist/entities/index.d.ts.map +0 -1
  95. package/dist/entities/index.js +0 -7
  96. package/dist/entities/index.js.map +0 -1
  97. package/dist/entities/solana/Configs.d.ts +0 -10
  98. package/dist/entities/solana/Configs.d.ts.map +0 -1
  99. package/dist/entities/solana/Configs.js +0 -50
  100. package/dist/entities/solana/Configs.js.map +0 -1
  101. package/dist/entities/solana/SolanaSpokeProvider.d.ts +0 -9
  102. package/dist/entities/solana/SolanaSpokeProvider.d.ts.map +0 -1
  103. package/dist/entities/solana/SolanaSpokeProvider.js +0 -9
  104. package/dist/entities/solana/SolanaSpokeProvider.js.map +0 -1
  105. package/dist/entities/solana/SolanaWalletProvider.d.ts +0 -20
  106. package/dist/entities/solana/SolanaWalletProvider.d.ts.map +0 -1
  107. package/dist/entities/solana/SolanaWalletProvider.js +0 -53
  108. package/dist/entities/solana/SolanaWalletProvider.js.map +0 -1
  109. package/dist/entities/solana/index.d.ts +0 -4
  110. package/dist/entities/solana/index.d.ts.map +0 -1
  111. package/dist/entities/solana/index.js +0 -4
  112. package/dist/entities/solana/index.js.map +0 -1
  113. package/dist/entities/solana/pda/pda.d.ts +0 -45
  114. package/dist/entities/solana/pda/pda.d.ts.map +0 -1
  115. package/dist/entities/solana/pda/pda.js +0 -44
  116. package/dist/entities/solana/pda/pda.js.map +0 -1
  117. package/dist/entities/solana/types/asset_manager.d.ts +0 -919
  118. package/dist/entities/solana/types/asset_manager.d.ts.map +0 -1
  119. package/dist/entities/solana/types/asset_manager.js +0 -2
  120. package/dist/entities/solana/types/asset_manager.js.map +0 -1
  121. package/dist/entities/solana/types/connection.d.ts +0 -446
  122. package/dist/entities/solana/types/connection.d.ts.map +0 -1
  123. package/dist/entities/solana/types/connection.js +0 -2
  124. package/dist/entities/solana/types/connection.js.map +0 -1
  125. package/dist/entities/solana/types/rate_limit_contract.d.ts +0 -348
  126. package/dist/entities/solana/types/rate_limit_contract.d.ts.map +0 -1
  127. package/dist/entities/solana/types/rate_limit_contract.js +0 -2
  128. package/dist/entities/solana/types/rate_limit_contract.js.map +0 -1
  129. package/dist/entities/solana/utils/utils.d.ts +0 -6
  130. package/dist/entities/solana/utils/utils.d.ts.map +0 -1
  131. package/dist/entities/solana/utils/utils.js +0 -18
  132. package/dist/entities/solana/utils/utils.js.map +0 -1
  133. package/dist/entities/stellar/StellarSpokeProvider.d.ts +0 -17
  134. package/dist/entities/stellar/StellarSpokeProvider.d.ts.map +0 -1
  135. package/dist/entities/stellar/StellarSpokeProvider.js +0 -125
  136. package/dist/entities/stellar/StellarSpokeProvider.js.map +0 -1
  137. package/dist/entities/sui/SuiSpokeProvider.d.ts +0 -35
  138. package/dist/entities/sui/SuiSpokeProvider.d.ts.map +0 -1
  139. package/dist/entities/sui/SuiSpokeProvider.js +0 -145
  140. package/dist/entities/sui/SuiSpokeProvider.js.map +0 -1
  141. package/dist/errors.d.ts +0 -2
  142. package/dist/errors.d.ts.map +0 -1
  143. package/dist/errors.js +0 -2
  144. package/dist/errors.js.map +0 -1
  145. package/dist/guards.d.ts +0 -25
  146. package/dist/guards.d.ts.map +0 -1
  147. package/dist/guards.js +0 -110
  148. package/dist/guards.js.map +0 -1
  149. package/dist/index.d.ts.map +0 -1
  150. package/dist/index.js +0 -10
  151. package/dist/index.js.map +0 -1
  152. package/dist/services/hub/EvmAssetManagerService.d.ts +0 -61
  153. package/dist/services/hub/EvmAssetManagerService.d.ts.map +0 -1
  154. package/dist/services/hub/EvmAssetManagerService.js +0 -103
  155. package/dist/services/hub/EvmAssetManagerService.js.map +0 -1
  156. package/dist/services/hub/EvmVaultTokenService.d.ts +0 -81
  157. package/dist/services/hub/EvmVaultTokenService.d.ts.map +0 -1
  158. package/dist/services/hub/EvmVaultTokenService.js +0 -161
  159. package/dist/services/hub/EvmVaultTokenService.js.map +0 -1
  160. package/dist/services/hub/EvmWalletAbstraction.d.ts +0 -9
  161. package/dist/services/hub/EvmWalletAbstraction.d.ts.map +0 -1
  162. package/dist/services/hub/EvmWalletAbstraction.js +0 -14
  163. package/dist/services/hub/EvmWalletAbstraction.js.map +0 -1
  164. package/dist/services/hub/index.d.ts +0 -4
  165. package/dist/services/hub/index.d.ts.map +0 -1
  166. package/dist/services/hub/index.js +0 -4
  167. package/dist/services/hub/index.js.map +0 -1
  168. package/dist/services/index.d.ts +0 -7
  169. package/dist/services/index.d.ts.map +0 -1
  170. package/dist/services/index.js +0 -7
  171. package/dist/services/index.js.map +0 -1
  172. package/dist/services/intentRelay/IntentRelayApiService.d.ts +0 -112
  173. package/dist/services/intentRelay/IntentRelayApiService.d.ts.map +0 -1
  174. package/dist/services/intentRelay/IntentRelayApiService.js +0 -160
  175. package/dist/services/intentRelay/IntentRelayApiService.js.map +0 -1
  176. package/dist/services/intentRelay/IntentRelayApiService.test.d.ts +0 -2
  177. package/dist/services/intentRelay/IntentRelayApiService.test.d.ts.map +0 -1
  178. package/dist/services/intentRelay/IntentRelayApiService.test.js +0 -134
  179. package/dist/services/intentRelay/IntentRelayApiService.test.js.map +0 -1
  180. package/dist/services/intentRelay/index.d.ts +0 -2
  181. package/dist/services/intentRelay/index.d.ts.map +0 -1
  182. package/dist/services/intentRelay/index.js +0 -2
  183. package/dist/services/intentRelay/index.js.map +0 -1
  184. package/dist/services/moneyMarket/MoneyMarketService.d.ts +0 -525
  185. package/dist/services/moneyMarket/MoneyMarketService.d.ts.map +0 -1
  186. package/dist/services/moneyMarket/MoneyMarketService.js +0 -814
  187. package/dist/services/moneyMarket/MoneyMarketService.js.map +0 -1
  188. package/dist/services/moneyMarket/MoneyMarketService.test.d.ts +0 -2
  189. package/dist/services/moneyMarket/MoneyMarketService.test.d.ts.map +0 -1
  190. package/dist/services/moneyMarket/MoneyMarketService.test.js +0 -262
  191. package/dist/services/moneyMarket/MoneyMarketService.test.js.map +0 -1
  192. package/dist/services/moneyMarket/index.d.ts +0 -2
  193. package/dist/services/moneyMarket/index.d.ts.map +0 -1
  194. package/dist/services/moneyMarket/index.js +0 -2
  195. package/dist/services/moneyMarket/index.js.map +0 -1
  196. package/dist/services/shared/Erc20Service.d.ts +0 -42
  197. package/dist/services/shared/Erc20Service.d.ts.map +0 -1
  198. package/dist/services/shared/Erc20Service.js +0 -108
  199. package/dist/services/shared/Erc20Service.js.map +0 -1
  200. package/dist/services/shared/index.d.ts +0 -2
  201. package/dist/services/shared/index.d.ts.map +0 -1
  202. package/dist/services/shared/index.js +0 -2
  203. package/dist/services/shared/index.js.map +0 -1
  204. package/dist/services/solver/EvmSolverService.d.ts +0 -125
  205. package/dist/services/solver/EvmSolverService.d.ts.map +0 -1
  206. package/dist/services/solver/EvmSolverService.js +0 -166
  207. package/dist/services/solver/EvmSolverService.js.map +0 -1
  208. package/dist/services/solver/SolverApiService.d.ts +0 -40
  209. package/dist/services/solver/SolverApiService.d.ts.map +0 -1
  210. package/dist/services/solver/SolverApiService.js +0 -157
  211. package/dist/services/solver/SolverApiService.js.map +0 -1
  212. package/dist/services/solver/SolverApiService.test.d.ts +0 -2
  213. package/dist/services/solver/SolverApiService.test.d.ts.map +0 -1
  214. package/dist/services/solver/SolverApiService.test.js +0 -181
  215. package/dist/services/solver/SolverApiService.test.js.map +0 -1
  216. package/dist/services/solver/SolverService.d.ts +0 -295
  217. package/dist/services/solver/SolverService.d.ts.map +0 -1
  218. package/dist/services/solver/SolverService.js +0 -429
  219. package/dist/services/solver/SolverService.js.map +0 -1
  220. package/dist/services/solver/SolverService.test.d.ts +0 -2
  221. package/dist/services/solver/SolverService.test.d.ts.map +0 -1
  222. package/dist/services/solver/SolverService.test.js +0 -439
  223. package/dist/services/solver/SolverService.test.js.map +0 -1
  224. package/dist/services/solver/index.d.ts +0 -3
  225. package/dist/services/solver/index.d.ts.map +0 -1
  226. package/dist/services/solver/index.js +0 -3
  227. package/dist/services/solver/index.js.map +0 -1
  228. package/dist/services/spoke/CWSpokeService.d.ts +0 -67
  229. package/dist/services/spoke/CWSpokeService.d.ts.map +0 -1
  230. package/dist/services/spoke/CWSpokeService.js +0 -75
  231. package/dist/services/spoke/CWSpokeService.js.map +0 -1
  232. package/dist/services/spoke/EvmSpokeService.d.ts +0 -62
  233. package/dist/services/spoke/EvmSpokeService.d.ts.map +0 -1
  234. package/dist/services/spoke/EvmSpokeService.js +0 -120
  235. package/dist/services/spoke/EvmSpokeService.js.map +0 -1
  236. package/dist/services/spoke/IconSpokeService.d.ts +0 -56
  237. package/dist/services/spoke/IconSpokeService.d.ts.map +0 -1
  238. package/dist/services/spoke/IconSpokeService.js +0 -127
  239. package/dist/services/spoke/IconSpokeService.js.map +0 -1
  240. package/dist/services/spoke/SolanaSpokeService.d.ts +0 -46
  241. package/dist/services/spoke/SolanaSpokeService.d.ts.map +0 -1
  242. package/dist/services/spoke/SolanaSpokeService.js +0 -164
  243. package/dist/services/spoke/SolanaSpokeService.js.map +0 -1
  244. package/dist/services/spoke/SpokeService.d.ts +0 -34
  245. package/dist/services/spoke/SpokeService.d.ts.map +0 -1
  246. package/dist/services/spoke/SpokeService.js +0 -101
  247. package/dist/services/spoke/SpokeService.js.map +0 -1
  248. package/dist/services/spoke/StellarSpokeService.d.ts +0 -35
  249. package/dist/services/spoke/StellarSpokeService.d.ts.map +0 -1
  250. package/dist/services/spoke/StellarSpokeService.js +0 -39
  251. package/dist/services/spoke/StellarSpokeService.js.map +0 -1
  252. package/dist/services/spoke/SuiSpokeService.d.ts +0 -69
  253. package/dist/services/spoke/SuiSpokeService.d.ts.map +0 -1
  254. package/dist/services/spoke/SuiSpokeService.js +0 -73
  255. package/dist/services/spoke/SuiSpokeService.js.map +0 -1
  256. package/dist/services/spoke/index.d.ts +0 -3
  257. package/dist/services/spoke/index.d.ts.map +0 -1
  258. package/dist/services/spoke/index.js +0 -3
  259. package/dist/services/spoke/index.js.map +0 -1
  260. package/dist/tests/services/hub/EvmAssetManagerService.test.d.ts +0 -2
  261. package/dist/tests/services/hub/EvmAssetManagerService.test.d.ts.map +0 -1
  262. package/dist/tests/services/hub/EvmAssetManagerService.test.js +0 -138
  263. package/dist/tests/services/hub/EvmAssetManagerService.test.js.map +0 -1
  264. package/dist/tests/services/hub/EvmMoneyMarketService.test.d.ts +0 -2
  265. package/dist/tests/services/hub/EvmMoneyMarketService.test.d.ts.map +0 -1
  266. package/dist/tests/services/hub/EvmMoneyMarketService.test.js +0 -121
  267. package/dist/tests/services/hub/EvmMoneyMarketService.test.js.map +0 -1
  268. package/dist/tests/services/hub/EvmVaultTokenService.test.d.ts +0 -2
  269. package/dist/tests/services/hub/EvmVaultTokenService.test.d.ts.map +0 -1
  270. package/dist/tests/services/hub/EvmVaultTokenService.test.js +0 -98
  271. package/dist/tests/services/hub/EvmVaultTokenService.test.js.map +0 -1
  272. package/dist/tests/services/spoke/EvmSpokeService.test.d.ts +0 -2
  273. package/dist/tests/services/spoke/EvmSpokeService.test.d.ts.map +0 -1
  274. package/dist/tests/services/spoke/EvmSpokeService.test.js +0 -198
  275. package/dist/tests/services/spoke/EvmSpokeService.test.js.map +0 -1
  276. package/dist/types.d.ts +0 -345
  277. package/dist/types.d.ts.map +0 -1
  278. package/dist/types.js +0 -30
  279. package/dist/types.js.map +0 -1
  280. package/dist/utils/evm-utils.d.ts +0 -10
  281. package/dist/utils/evm-utils.d.ts.map +0 -1
  282. package/dist/utils/evm-utils.js +0 -15
  283. package/dist/utils/evm-utils.js.map +0 -1
  284. package/dist/utils/index.d.ts +0 -3
  285. package/dist/utils/index.d.ts.map +0 -1
  286. package/dist/utils/index.js +0 -3
  287. package/dist/utils/index.js.map +0 -1
  288. package/dist/utils/shared-utils.d.ts +0 -20
  289. package/dist/utils/shared-utils.d.ts.map +0 -1
  290. package/dist/utils/shared-utils.js +0 -69
  291. package/dist/utils/shared-utils.js.map +0 -1
  292. package/dist/utils/shared-utils.test.d.ts +0 -2
  293. package/dist/utils/shared-utils.test.d.ts.map +0 -1
  294. package/dist/utils/shared-utils.test.js +0 -63
  295. package/dist/utils/shared-utils.test.js.map +0 -1
@@ -1,161 +0,0 @@
1
- import { encodeFunctionData } from 'viem';
2
- import { vaultTokenAbi } from '../../abis/index.js';
3
- export class EvmVaultTokenService {
4
- constructor() { }
5
- /**
6
- * Fetches token information for a specific token in the vault.
7
- * @param vault - The address of the vault.
8
- * @param token - The address of the token.
9
- * @param publicClient - PublicClient<HttpTransport>
10
- * @returns Token information as a TokenInfo object.
11
- */
12
- static async getTokenInfo(vault, token, publicClient) {
13
- const [decimals, depositFee, withdrawalFee, maxDeposit, isSupported] = await publicClient.readContract({
14
- address: vault,
15
- abi: vaultTokenAbi,
16
- functionName: 'tokenInfo',
17
- args: [token],
18
- });
19
- return { decimals, depositFee, withdrawalFee, maxDeposit, isSupported };
20
- }
21
- /**
22
- * Retrieves the reserves of the vault.
23
- * @param vault - The address of the vault.
24
- * @param publicClient - PublicClient<HttpTransport>
25
- * @returns An object containing tokens and their balances.
26
- */
27
- static async getVaultReserves(vault, publicClient) {
28
- const [tokens, balances] = await publicClient.readContract({
29
- address: vault,
30
- abi: vaultTokenAbi,
31
- functionName: 'getVaultReserves',
32
- args: [],
33
- });
34
- return {
35
- tokens,
36
- balances,
37
- };
38
- }
39
- /**
40
- * Retrieves all token information for the vault.
41
- * @param vault - The address of the vault.
42
- * @param publicClient - PublicClient<HttpTransport>
43
- * @returns A promise that resolves to an object containing tokens, their infos, and reserves.
44
- */
45
- async getAllTokenInfo(vault, publicClient) {
46
- const [tokens, infos, reserves] = await publicClient.readContract({
47
- address: vault,
48
- abi: vaultTokenAbi,
49
- functionName: 'getAllTokenInfo',
50
- args: [],
51
- });
52
- return {
53
- tokens,
54
- infos,
55
- reserves,
56
- };
57
- }
58
- /**
59
- * Deposits a specified amount of a token into the vault.
60
- * @param vault - The address of the vault.
61
- * @param token - The address of the token to deposit.
62
- * @param amount - The amount of the token to deposit.
63
- * @param walletProvider - IEvmWalletProvider
64
- * @returns Transaction hash
65
- */
66
- static async deposit(vault, token, amount, walletProvider) {
67
- const from = (await walletProvider.getWalletAddress());
68
- return walletProvider.sendTransaction({
69
- from,
70
- to: vault,
71
- value: 0n,
72
- data: encodeFunctionData({
73
- abi: vaultTokenAbi,
74
- functionName: 'deposit',
75
- args: [token, amount],
76
- }),
77
- });
78
- }
79
- /**
80
- * Withdraws a specified amount of a token from the vault.
81
- * @param vault - The address of the vault.
82
- * @param token - The address of the token to withdraw.
83
- * @param amount - The amount of the token to withdraw.
84
- * @param provider - EvmWalletProvider
85
- * @returns Transaction hash
86
- */
87
- static async withdraw(vault, token, amount, provider) {
88
- const from = (await provider.getWalletAddress());
89
- return provider.sendTransaction({
90
- from,
91
- to: vault,
92
- value: 0n,
93
- data: encodeFunctionData({
94
- abi: vaultTokenAbi,
95
- functionName: 'withdraw',
96
- args: [token, amount],
97
- }),
98
- });
99
- }
100
- /**
101
- * Encodes the deposit transaction data for the vault.
102
- * @param vault - The address of the vault.
103
- * @param token - The address of the token to deposit.
104
- * @param amount - The amount of the token to deposit.
105
- * @returns The encoded contract call data.
106
- */
107
- static encodeDeposit(vault, token, amount) {
108
- return {
109
- address: vault,
110
- value: 0n,
111
- data: encodeFunctionData({
112
- abi: vaultTokenAbi,
113
- functionName: 'deposit',
114
- args: [token, amount],
115
- }),
116
- };
117
- }
118
- /**
119
- * Encodes the withdraw transaction data for the vault.
120
- * @param vault - The address of the vault.
121
- * @param token - The address of the token to withdraw.
122
- * @param amount - The amount of the token to withdraw.
123
- * @returns The encoded contract call data.
124
- */
125
- static encodeWithdraw(vault, token, amount) {
126
- return {
127
- address: vault,
128
- value: 0n,
129
- data: encodeFunctionData({
130
- abi: vaultTokenAbi,
131
- functionName: 'withdraw',
132
- args: [token, amount],
133
- }),
134
- };
135
- }
136
- /**
137
- * Translates token amounts from their native decimals to 18 decimals
138
- * @param decimals - The number of decimals of the token
139
- * @param amount - The amount to translate
140
- * @returns The translated amount
141
- */
142
- static translateIncomingDecimals(decimals, amount) {
143
- if (decimals <= 18) {
144
- return amount * BigInt(10 ** (18 - decimals));
145
- }
146
- return amount / BigInt(10 ** (decimals - 18));
147
- }
148
- /**
149
- * Translates token amounts from 18 decimals back to their native decimals
150
- * @param decimals - The number of decimals of the token
151
- * @param amount - The amount to translate
152
- * @returns The translated amount
153
- */
154
- static translateOutgoingDecimals(decimals, amount) {
155
- if (decimals <= 18) {
156
- return amount / BigInt(10 ** (18 - decimals));
157
- }
158
- return amount * BigInt(10 ** (decimals - 18));
159
- }
160
- }
161
- //# sourceMappingURL=EvmVaultTokenService.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EvmVaultTokenService.js","sourceRoot":"","sources":["../../../src/services/hub/EvmVaultTokenService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkE,kBAAkB,EAAE,MAAM,MAAM,CAAC;AAC1G,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAIpD,MAAM,OAAO,oBAAoB;IAC/B,gBAAuB,CAAC;IAExB;;;;;;OAMG;IACI,MAAM,CAAC,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;gBACxB,IAAI,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC;aACtB,CAAC;SACH,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,yBAAyB,CAAC,QAAgB,EAAE,MAAc;QACtE,IAAI,QAAQ,IAAI,EAAE,EAAE,CAAC;YACnB,OAAO,MAAM,GAAG,MAAM,CAAC,EAAE,IAAI,CAAC,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC;QAChD,CAAC;QACD,OAAO,MAAM,GAAG,MAAM,CAAC,EAAE,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC,CAAC,CAAC;IAChD,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,yBAAyB,CAAC,QAAgB,EAAE,MAAc;QACtE,IAAI,QAAQ,IAAI,EAAE,EAAE,CAAC;YACnB,OAAO,MAAM,GAAG,MAAM,CAAC,EAAE,IAAI,CAAC,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC;QAChD,CAAC;QACD,OAAO,MAAM,GAAG,MAAM,CAAC,EAAE,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC,CAAC,CAAC;IAChD,CAAC;CACF"}
@@ -1,9 +0,0 @@
1
- import type { Address } from 'viem';
2
- import type { EvmHubProvider } from '../../entities/index.js';
3
- import { type Hex } from '../../index.js';
4
- import type { SpokeChainId } from '@sodax/types';
5
- export declare class EvmWalletAbstraction {
6
- private constructor();
7
- static getUserHubWalletAddress(chainId: SpokeChainId, address: Hex, hubProvider: EvmHubProvider): Promise<Address>;
8
- }
9
- //# sourceMappingURL=EvmWalletAbstraction.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EvmWalletAbstraction.d.ts","sourceRoot":"","sources":["../../../src/services/hub/EvmWalletAbstraction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,KAAK,GAAG,EAAyB,MAAM,gBAAgB,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,qBAAa,oBAAoB;IAC/B,OAAO;WAEa,uBAAuB,CACzC,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,GAAG,EACZ,WAAW,EAAE,cAAc,GAC1B,OAAO,CAAC,OAAO,CAAC;CAQpB"}
@@ -1,14 +0,0 @@
1
- import { walletFactoryAbi } from '../../abis/index.js';
2
- import { getIntentRelayChainId } from '../../index.js';
3
- export class EvmWalletAbstraction {
4
- constructor() { }
5
- static async getUserHubWalletAddress(chainId, address, hubProvider) {
6
- return hubProvider.publicClient.readContract({
7
- address: hubProvider.chainConfig.addresses.hubWallet,
8
- abi: walletFactoryAbi,
9
- functionName: 'getDeployedAddress',
10
- args: [BigInt(getIntentRelayChainId(chainId)), address],
11
- });
12
- }
13
- }
14
- //# sourceMappingURL=EvmWalletAbstraction.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EvmWalletAbstraction.js","sourceRoot":"","sources":["../../../src/services/hub/EvmWalletAbstraction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,EAAY,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAGjE,MAAM,OAAO,oBAAoB;IAC/B,gBAAuB,CAAC;IAEjB,MAAM,CAAC,KAAK,CAAC,uBAAuB,CACzC,OAAqB,EACrB,OAAY,EACZ,WAA2B;QAE3B,OAAO,WAAW,CAAC,YAAY,CAAC,YAAY,CAAC;YAC3C,OAAO,EAAE,WAAW,CAAC,WAAW,CAAC,SAAS,CAAC,SAAS;YACpD,GAAG,EAAE,gBAAgB;YACrB,YAAY,EAAE,oBAAoB;YAClC,IAAI,EAAE,CAAC,MAAM,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC,EAAE,OAAO,CAAC;SACxD,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -1,4 +0,0 @@
1
- export * from './EvmAssetManagerService.js';
2
- export * from './EvmWalletAbstraction.js';
3
- export * from './EvmVaultTokenService.js';
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/hub/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC"}
@@ -1,4 +0,0 @@
1
- export * from './EvmAssetManagerService.js';
2
- export * from './EvmWalletAbstraction.js';
3
- export * from './EvmVaultTokenService.js';
4
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/hub/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC"}
@@ -1,7 +0,0 @@
1
- export * from './hub/index.js';
2
- export * from './moneyMarket/index.js';
3
- export * from './shared/index.js';
4
- export * from './spoke/index.js';
5
- export * from './intentRelay/index.js';
6
- export * from './solver/index.js';
7
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC"}
@@ -1,7 +0,0 @@
1
- export * from './hub/index.js';
2
- export * from './moneyMarket/index.js';
3
- export * from './shared/index.js';
4
- export * from './spoke/index.js';
5
- export * from './intentRelay/index.js';
6
- export * from './solver/index.js';
7
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC"}
@@ -1,112 +0,0 @@
1
- import type { HttpUrl, Result } from '../../types.js';
2
- import type { Hex } from '@sodax/types';
3
- import type { IntentSubmitError } from '../solver/SolverService.js';
4
- import type { SpokeProvider } from '../../entities/Providers.js';
5
- /**
6
- * The action type for the intent relay service.
7
- * submit - submit a transaction to the intent relay service
8
- * get_transaction_packets - get transaction packets from the intent relay service
9
- * get_packet - get a packet from the intent relay service
10
- */
11
- export type RelayAction = 'submit' | 'get_transaction_packets' | 'get_packet';
12
- /**
13
- * The status of the relay transaction.
14
- * pending - no signatures
15
- * validating - not enough signatures
16
- * executing - enough signatures,no confirmed txn-hash
17
- * executed - has confirmed transaction-hash
18
- */
19
- export type RelayTxStatus = 'pending' | 'validating' | 'executing' | 'executed';
20
- export type RelayErrorCode = 'UNKNOWN' | 'SUBMIT_TX_FAILED' | 'POST_EXECUTION_FAILED' | 'TIMEOUT';
21
- export type RelayError = {
22
- code: RelayErrorCode;
23
- error: unknown;
24
- };
25
- export type SubmitTxParams = {
26
- chain_id: string;
27
- tx_hash: string;
28
- };
29
- export type GetTransactionPacketsParams = {
30
- chain_id: string;
31
- tx_hash: string;
32
- };
33
- export type GetPacketParams = {
34
- chain_id: string;
35
- tx_hash: string;
36
- conn_sn: string;
37
- };
38
- export type SubmitTxResponse = {
39
- success: boolean;
40
- message: string;
41
- };
42
- export type PacketData = {
43
- src_chain_id: number;
44
- src_tx_hash: string;
45
- src_address: string;
46
- status: RelayTxStatus;
47
- dst_chain_id: number;
48
- conn_sn: number;
49
- dst_address: string;
50
- dst_tx_hash: string;
51
- signatures: string[];
52
- payload: string;
53
- };
54
- export type GetTransactionPacketsResponse = {
55
- success: boolean;
56
- data: PacketData[];
57
- };
58
- export type GetPacketResponse = {
59
- success: true;
60
- data: PacketData;
61
- } | {
62
- success: false;
63
- message: string;
64
- };
65
- export type GetRelayRequestParamType<T extends RelayAction> = T extends 'submit' ? SubmitTxParams : T extends 'get_transaction_packets' ? GetTransactionPacketsParams : T extends 'get_packet' ? GetPacketParams : never;
66
- export type GetRelayResponse<T extends RelayAction> = T extends 'submit' ? SubmitTxResponse : T extends 'get_transaction_packets' ? GetTransactionPacketsResponse : T extends 'get_packet' ? GetPacketResponse : never;
67
- export type IntentRelayRequestParams = SubmitTxParams | GetTransactionPacketsParams | GetPacketParams;
68
- export type WaitUntilIntentExecutedPayload = {
69
- intentRelayChainId: string;
70
- spokeTxHash: string;
71
- timeout: number;
72
- apiUrl: HttpUrl;
73
- };
74
- /**
75
- * Represents the request payload for submitting a transaction to the intent relay service.
76
- * Contains the action type and parameters including chain ID and transaction hash.
77
- */
78
- export type IntentRelayRequest<T extends RelayAction> = {
79
- action: T;
80
- params: GetRelayRequestParamType<T>;
81
- };
82
- /**
83
- * Submits a transaction to the intent relay service.
84
- * @param payload - The request payload containing the 'submit' action type and parameters.
85
- * @param apiUrl - The URL of the intent relay service.
86
- * @returns The response from the intent relay service.
87
- */
88
- export declare function submitTransaction(payload: IntentRelayRequest<'submit'>, apiUrl: HttpUrl): Promise<GetRelayResponse<'submit'>>;
89
- /**
90
- * Retrieves transaction packets from the intent relay service.
91
- * @param payload - The request payload containing the 'get_transaction_packets' action type and parameters.
92
- * @param apiUrl - The URL of the intent relay service.
93
- * @returns The response from the intent relay service.
94
- */
95
- export declare function getTransactionPackets(payload: IntentRelayRequest<'get_transaction_packets'>, apiUrl: HttpUrl): Promise<GetRelayResponse<'get_transaction_packets'>>;
96
- /**
97
- * Retrieves a packet from the intent relay service.
98
- * @param payload - The request payload containing the 'get_packet' action type and parameters.
99
- * @param apiUrl - The URL of the intent relay service.
100
- * @returns The response from the intent relay service.
101
- */
102
- export declare function getPacket(payload: IntentRelayRequest<'get_packet'>, apiUrl: HttpUrl): Promise<GetRelayResponse<'get_packet'>>;
103
- export declare function waitUntilIntentExecuted(payload: WaitUntilIntentExecutedPayload): Promise<Result<PacketData, IntentSubmitError<'TIMEOUT'>>>;
104
- /**
105
- * Submit the transaction to the Solver API and wait for it to be executed
106
- * @param spokeTxHash - The transaction hash to submit.
107
- * @param spokeProvider - The spoke provider.
108
- * @param timeout - The timeout in milliseconds for the transaction. Default is 20 seconds.
109
- * @returns The transaction hash.
110
- */
111
- export declare function relayTxAndWaitPacket<S extends SpokeProvider>(spokeTxHash: Hex, spokeProvider: S, relayerApiEndpoint: HttpUrl, timeout?: number): Promise<Result<PacketData, RelayError>>;
112
- //# sourceMappingURL=IntentRelayApiService.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IntentRelayApiService.d.ts","sourceRoot":"","sources":["../../../src/services/intentRelay/IntentRelayApiService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAGxC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAEpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAEjE;;;;;GAKG;AACH,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,yBAAyB,GAAG,YAAY,CAAC;AAE9E;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,YAAY,GAAG,WAAW,GAAG,UAAU,CAAC;AAEhF,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,kBAAkB,GAAG,uBAAuB,GAAG,SAAS,CAAC;AAElG,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,cAAc,CAAC;IACrB,KAAK,EAAE,OAAO,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB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AAC,CAAC,SAAS,aAAa,EAChE,WAAW,EAAE,GAAG,EAChB,aAAa,EAAE,CAAC,EAChB,kBAAkB,EAAE,OAAO,EAC3B,OAAO,SAA2B,GACjC,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC,CAsDzC"}
@@ -1,160 +0,0 @@
1
- import invariant from 'tiny-invariant';
2
- import { retry } from '../../utils/shared-utils.js';
3
- import { DEFAULT_RELAY_TX_TIMEOUT, getIntentRelayChainId } from '../../constants.js';
4
- async function postRequest(payload, apiUrl) {
5
- const response = await retry(() => fetch(apiUrl, {
6
- method: 'POST',
7
- headers: {
8
- 'Content-Type': 'application/json',
9
- },
10
- body: JSON.stringify(payload),
11
- }));
12
- return response.json();
13
- }
14
- /**
15
- * Submits a transaction to the intent relay service.
16
- * @param payload - The request payload containing the 'submit' action type and parameters.
17
- * @param apiUrl - The URL of the intent relay service.
18
- * @returns The response from the intent relay service.
19
- */
20
- export async function submitTransaction(payload, apiUrl) {
21
- invariant(payload.params.chain_id.length > 0, 'Invalid input parameters. source_chain_id empty');
22
- invariant(payload.params.tx_hash.length > 0, 'Invalid input parameters. tx_hash empty');
23
- return postRequest(payload, apiUrl);
24
- }
25
- /**
26
- * Retrieves transaction packets from the intent relay service.
27
- * @param payload - The request payload containing the 'get_transaction_packets' action type and parameters.
28
- * @param apiUrl - The URL of the intent relay service.
29
- * @returns The response from the intent relay service.
30
- */
31
- export async function getTransactionPackets(payload, apiUrl) {
32
- invariant(payload.params.chain_id.length > 0, 'Invalid input parameters. source_chain_id empty');
33
- invariant(payload.params.tx_hash.length > 0, 'Invalid input parameters. tx_hash empty');
34
- return postRequest(payload, apiUrl);
35
- }
36
- /**
37
- * Retrieves a packet from the intent relay service.
38
- * @param payload - The request payload containing the 'get_packet' action type and parameters.
39
- * @param apiUrl - The URL of the intent relay service.
40
- * @returns The response from the intent relay service.
41
- */
42
- export async function getPacket(payload, apiUrl) {
43
- invariant(payload.params.chain_id.length > 0, 'Invalid input parameters. source_chain_id empty');
44
- invariant(payload.params.tx_hash.length > 0, 'Invalid input parameters. tx_hash empty');
45
- invariant(payload.params.conn_sn.length > 0, 'Invalid input parameters. conn_sn empty');
46
- return postRequest(payload, apiUrl);
47
- }
48
- export async function waitUntilIntentExecuted(payload) {
49
- try {
50
- const startTime = Date.now();
51
- while (Date.now() - startTime < payload.timeout) {
52
- try {
53
- const txPackets = await getTransactionPackets({
54
- action: 'get_transaction_packets',
55
- params: {
56
- chain_id: payload.intentRelayChainId,
57
- tx_hash: payload.spokeTxHash,
58
- },
59
- }, payload.apiUrl);
60
- if (txPackets.success && txPackets.data.length > 0) {
61
- const packet = txPackets.data.find(packet => packet.src_tx_hash.toLowerCase() === payload.spokeTxHash.toLowerCase());
62
- if (txPackets.success && txPackets.data.length > 0 && packet && packet.status === 'executed') {
63
- return {
64
- ok: true,
65
- value: packet,
66
- };
67
- }
68
- }
69
- }
70
- catch (e) {
71
- console.error('Error getting transaction packets', e);
72
- }
73
- // wait one second before retrying
74
- await new Promise(resolve => setTimeout(resolve, 1000));
75
- }
76
- return {
77
- ok: false,
78
- error: {
79
- code: 'TIMEOUT',
80
- data: {
81
- payload: payload,
82
- error: {
83
- payload: payload,
84
- error: undefined,
85
- },
86
- },
87
- },
88
- };
89
- }
90
- catch (e) {
91
- return {
92
- ok: false,
93
- error: {
94
- code: 'TIMEOUT',
95
- data: {
96
- payload: payload,
97
- error: e,
98
- },
99
- },
100
- };
101
- }
102
- }
103
- /**
104
- * Submit the transaction to the Solver API and wait for it to be executed
105
- * @param spokeTxHash - The transaction hash to submit.
106
- * @param spokeProvider - The spoke provider.
107
- * @param timeout - The timeout in milliseconds for the transaction. Default is 20 seconds.
108
- * @returns The transaction hash.
109
- */
110
- export async function relayTxAndWaitPacket(spokeTxHash, spokeProvider, relayerApiEndpoint, timeout = DEFAULT_RELAY_TX_TIMEOUT) {
111
- try {
112
- const intentRelayChainId = getIntentRelayChainId(spokeProvider.chainConfig.chain.id).toString();
113
- const submitPayload = {
114
- action: 'submit',
115
- params: {
116
- chain_id: intentRelayChainId,
117
- tx_hash: spokeTxHash,
118
- },
119
- };
120
- const submitResult = await submitTransaction(submitPayload, relayerApiEndpoint);
121
- if (!submitResult.success) {
122
- return {
123
- ok: false,
124
- error: {
125
- code: 'SUBMIT_TX_FAILED',
126
- error: submitResult.message,
127
- },
128
- };
129
- }
130
- const packet = await waitUntilIntentExecuted({
131
- intentRelayChainId,
132
- spokeTxHash,
133
- timeout,
134
- apiUrl: relayerApiEndpoint,
135
- });
136
- if (!packet.ok) {
137
- return {
138
- ok: false,
139
- error: {
140
- code: 'TIMEOUT',
141
- error: packet.error,
142
- },
143
- };
144
- }
145
- return {
146
- ok: true,
147
- value: packet.value,
148
- };
149
- }
150
- catch (error) {
151
- return {
152
- ok: false,
153
- error: {
154
- code: 'UNKNOWN',
155
- error: error,
156
- },
157
- };
158
- }
159
- }
160
- //# sourceMappingURL=IntentRelayApiService.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IntentRelayApiService.js","sourceRoot":"","sources":["../../../src/services/intentRelay/IntentRelayApiService.ts"],"names":[],"mappings":"AAEA,OAAO,SAAS,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAEpD,OAAO,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AA8GrF,KAAK,UAAU,WAAW,CACxB,OAA8B,EAC9B,MAAc;IAEd,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE,CAChC,KAAK,CAAC,MAAM,EAAE;QACZ,MAAM,EAAE,MAAM;QACd,OAAO,EAAE;YACP,cAAc,EAAE,kBAAkB;SACnC;QACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;KAC9B,CAAC,CACH,CAAC;IAEF,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;AACzB,CAAC;AAED;;;;;GAKG;AACH,MAAM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AK;iBACpB;aACF,CAAC;QACJ,CAAC;QAED,OAAO;YACL,EAAE,EAAE,IAAI;YACR,KAAK,EAAE,MAAM,CAAC,KAAK;SACpB,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,EAAE,EAAE,KAAK;YACT,KAAK,EAAE;gBACL,IAAI,EAAE,SAAS;gBACf,KAAK,EAAE,KAAK;aACb;SACF,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=IntentRelayApiService.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IntentRelayApiService.test.d.ts","sourceRoot":"","sources":["../../../src/services/intentRelay/IntentRelayApiService.test.ts"],"names":[],"mappings":""}