@sodax/sdk 0.0.1-rc.4 → 0.0.1-rc.41

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 (304) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +176 -11
  3. package/dist/index.cjs +18618 -0
  4. package/dist/index.cjs.map +1 -0
  5. package/dist/index.d.cts +11181 -0
  6. package/dist/index.d.ts +11180 -9
  7. package/dist/index.mjs +18348 -0
  8. package/dist/index.mjs.map +1 -0
  9. package/package.json +32 -32
  10. package/dist/abis/asset-manager.abi.d.ts +0 -418
  11. package/dist/abis/asset-manager.abi.d.ts.map +0 -1
  12. package/dist/abis/asset-manager.abi.js +0 -542
  13. package/dist/abis/asset-manager.abi.js.map +0 -1
  14. package/dist/abis/connection.abi.d.ts +0 -72
  15. package/dist/abis/connection.abi.d.ts.map +0 -1
  16. package/dist/abis/connection.abi.js +0 -92
  17. package/dist/abis/connection.abi.js.map +0 -1
  18. package/dist/abis/erc20.abi.d.ts +0 -236
  19. package/dist/abis/erc20.abi.d.ts.map +0 -1
  20. package/dist/abis/erc20.abi.js +0 -311
  21. package/dist/abis/erc20.abi.js.map +0 -1
  22. package/dist/abis/index.d.ts +0 -10
  23. package/dist/abis/index.d.ts.map +0 -1
  24. package/dist/abis/index.js +0 -10
  25. package/dist/abis/index.js.map +0 -1
  26. package/dist/abis/intents.abi.d.ts +0 -901
  27. package/dist/abis/intents.abi.d.ts.map +0 -1
  28. package/dist/abis/intents.abi.js +0 -1158
  29. package/dist/abis/intents.abi.js.map +0 -1
  30. package/dist/abis/pool.abi.d.ts +0 -626
  31. package/dist/abis/pool.abi.d.ts.map +0 -1
  32. package/dist/abis/pool.abi.js +0 -812
  33. package/dist/abis/pool.abi.js.map +0 -1
  34. package/dist/abis/spokeAssetManager.abi.d.ts +0 -169
  35. package/dist/abis/spokeAssetManager.abi.d.ts.map +0 -1
  36. package/dist/abis/spokeAssetManager.abi.js +0 -217
  37. package/dist/abis/spokeAssetManager.abi.js.map +0 -1
  38. package/dist/abis/uiPoolData.abi.d.ts +0 -369
  39. package/dist/abis/uiPoolData.abi.d.ts.map +0 -1
  40. package/dist/abis/uiPoolData.abi.js +0 -476
  41. package/dist/abis/uiPoolData.abi.js.map +0 -1
  42. package/dist/abis/vaultToken.abi.d.ts +0 -816
  43. package/dist/abis/vaultToken.abi.d.ts.map +0 -1
  44. package/dist/abis/vaultToken.abi.js +0 -1062
  45. package/dist/abis/vaultToken.abi.js.map +0 -1
  46. package/dist/abis/walletFactory.abi.d.ts +0 -20
  47. package/dist/abis/walletFactory.abi.d.ts.map +0 -1
  48. package/dist/abis/walletFactory.abi.js +0 -27
  49. package/dist/abis/walletFactory.abi.js.map +0 -1
  50. package/dist/constants.d.ts +0 -550
  51. package/dist/constants.d.ts.map +0 -1
  52. package/dist/constants.js +0 -1196
  53. package/dist/constants.js.map +0 -1
  54. package/dist/constants.test.d.ts +0 -2
  55. package/dist/constants.test.d.ts.map +0 -1
  56. package/dist/constants.test.js +0 -129
  57. package/dist/constants.test.js.map +0 -1
  58. package/dist/entities/Providers.d.ts +0 -54
  59. package/dist/entities/Providers.d.ts.map +0 -1
  60. package/dist/entities/Providers.js +0 -51
  61. package/dist/entities/Providers.js.map +0 -1
  62. package/dist/entities/Sodax.d.ts +0 -23
  63. package/dist/entities/Sodax.d.ts.map +0 -1
  64. package/dist/entities/Sodax.js +0 -29
  65. package/dist/entities/Sodax.js.map +0 -1
  66. package/dist/entities/Sodax.test.d.ts +0 -2
  67. package/dist/entities/Sodax.test.d.ts.map +0 -1
  68. package/dist/entities/Sodax.test.js +0 -392
  69. package/dist/entities/Sodax.test.js.map +0 -1
  70. package/dist/entities/cosmos/CW20Token.d.ts +0 -39
  71. package/dist/entities/cosmos/CW20Token.d.ts.map +0 -1
  72. package/dist/entities/cosmos/CW20Token.js +0 -65
  73. package/dist/entities/cosmos/CW20Token.js.map +0 -1
  74. package/dist/entities/cosmos/CWSpokeProvider.d.ts +0 -92
  75. package/dist/entities/cosmos/CWSpokeProvider.d.ts.map +0 -1
  76. package/dist/entities/cosmos/CWSpokeProvider.js +0 -143
  77. package/dist/entities/cosmos/CWSpokeProvider.js.map +0 -1
  78. package/dist/entities/cosmos/CosmosWalletProvider.d.ts +0 -28
  79. package/dist/entities/cosmos/CosmosWalletProvider.d.ts.map +0 -1
  80. package/dist/entities/cosmos/CosmosWalletProvider.js +0 -102
  81. package/dist/entities/cosmos/CosmosWalletProvider.js.map +0 -1
  82. package/dist/entities/cosmos/InjectiveWalletProvider.d.ts +0 -25
  83. package/dist/entities/cosmos/InjectiveWalletProvider.d.ts.map +0 -1
  84. package/dist/entities/cosmos/InjectiveWalletProvider.js +0 -76
  85. package/dist/entities/cosmos/InjectiveWalletProvider.js.map +0 -1
  86. package/dist/entities/icon/HanaWalletConnector.d.ts +0 -36
  87. package/dist/entities/icon/HanaWalletConnector.d.ts.map +0 -1
  88. package/dist/entities/icon/HanaWalletConnector.js +0 -92
  89. package/dist/entities/icon/HanaWalletConnector.js.map +0 -1
  90. package/dist/entities/icon/IconSpokeProvider.d.ts +0 -10
  91. package/dist/entities/icon/IconSpokeProvider.d.ts.map +0 -1
  92. package/dist/entities/icon/IconSpokeProvider.js +0 -12
  93. package/dist/entities/icon/IconSpokeProvider.js.map +0 -1
  94. package/dist/entities/icon/index.d.ts +0 -4
  95. package/dist/entities/icon/index.d.ts.map +0 -1
  96. package/dist/entities/icon/index.js +0 -4
  97. package/dist/entities/icon/index.js.map +0 -1
  98. package/dist/entities/icon/utils.d.ts +0 -3
  99. package/dist/entities/icon/utils.d.ts.map +0 -1
  100. package/dist/entities/icon/utils.js +0 -4
  101. package/dist/entities/icon/utils.js.map +0 -1
  102. package/dist/entities/index.d.ts +0 -7
  103. package/dist/entities/index.d.ts.map +0 -1
  104. package/dist/entities/index.js +0 -7
  105. package/dist/entities/index.js.map +0 -1
  106. package/dist/entities/solana/Configs.d.ts +0 -10
  107. package/dist/entities/solana/Configs.d.ts.map +0 -1
  108. package/dist/entities/solana/Configs.js +0 -50
  109. package/dist/entities/solana/Configs.js.map +0 -1
  110. package/dist/entities/solana/SolanaSpokeProvider.d.ts +0 -9
  111. package/dist/entities/solana/SolanaSpokeProvider.d.ts.map +0 -1
  112. package/dist/entities/solana/SolanaSpokeProvider.js +0 -9
  113. package/dist/entities/solana/SolanaSpokeProvider.js.map +0 -1
  114. package/dist/entities/solana/SolanaWalletProvider.d.ts +0 -20
  115. package/dist/entities/solana/SolanaWalletProvider.d.ts.map +0 -1
  116. package/dist/entities/solana/SolanaWalletProvider.js +0 -53
  117. package/dist/entities/solana/SolanaWalletProvider.js.map +0 -1
  118. package/dist/entities/solana/index.d.ts +0 -4
  119. package/dist/entities/solana/index.d.ts.map +0 -1
  120. package/dist/entities/solana/index.js +0 -4
  121. package/dist/entities/solana/index.js.map +0 -1
  122. package/dist/entities/solana/pda/pda.d.ts +0 -45
  123. package/dist/entities/solana/pda/pda.d.ts.map +0 -1
  124. package/dist/entities/solana/pda/pda.js +0 -44
  125. package/dist/entities/solana/pda/pda.js.map +0 -1
  126. package/dist/entities/solana/types/asset_manager.d.ts +0 -919
  127. package/dist/entities/solana/types/asset_manager.d.ts.map +0 -1
  128. package/dist/entities/solana/types/asset_manager.js +0 -2
  129. package/dist/entities/solana/types/asset_manager.js.map +0 -1
  130. package/dist/entities/solana/types/connection.d.ts +0 -446
  131. package/dist/entities/solana/types/connection.d.ts.map +0 -1
  132. package/dist/entities/solana/types/connection.js +0 -2
  133. package/dist/entities/solana/types/connection.js.map +0 -1
  134. package/dist/entities/solana/types/rate_limit_contract.d.ts +0 -348
  135. package/dist/entities/solana/types/rate_limit_contract.d.ts.map +0 -1
  136. package/dist/entities/solana/types/rate_limit_contract.js +0 -2
  137. package/dist/entities/solana/types/rate_limit_contract.js.map +0 -1
  138. package/dist/entities/solana/utils/utils.d.ts +0 -6
  139. package/dist/entities/solana/utils/utils.d.ts.map +0 -1
  140. package/dist/entities/solana/utils/utils.js +0 -18
  141. package/dist/entities/solana/utils/utils.js.map +0 -1
  142. package/dist/entities/stellar/StellarSpokeProvider.d.ts +0 -17
  143. package/dist/entities/stellar/StellarSpokeProvider.d.ts.map +0 -1
  144. package/dist/entities/stellar/StellarSpokeProvider.js +0 -125
  145. package/dist/entities/stellar/StellarSpokeProvider.js.map +0 -1
  146. package/dist/entities/sui/SuiSpokeProvider.d.ts +0 -35
  147. package/dist/entities/sui/SuiSpokeProvider.d.ts.map +0 -1
  148. package/dist/entities/sui/SuiSpokeProvider.js +0 -145
  149. package/dist/entities/sui/SuiSpokeProvider.js.map +0 -1
  150. package/dist/errors.d.ts +0 -2
  151. package/dist/errors.d.ts.map +0 -1
  152. package/dist/errors.js +0 -2
  153. package/dist/errors.js.map +0 -1
  154. package/dist/guards.d.ts +0 -25
  155. package/dist/guards.d.ts.map +0 -1
  156. package/dist/guards.js +0 -110
  157. package/dist/guards.js.map +0 -1
  158. package/dist/index.d.ts.map +0 -1
  159. package/dist/index.js +0 -10
  160. package/dist/index.js.map +0 -1
  161. package/dist/services/hub/EvmAssetManagerService.d.ts +0 -61
  162. package/dist/services/hub/EvmAssetManagerService.d.ts.map +0 -1
  163. package/dist/services/hub/EvmAssetManagerService.js +0 -103
  164. package/dist/services/hub/EvmAssetManagerService.js.map +0 -1
  165. package/dist/services/hub/EvmVaultTokenService.d.ts +0 -81
  166. package/dist/services/hub/EvmVaultTokenService.d.ts.map +0 -1
  167. package/dist/services/hub/EvmVaultTokenService.js +0 -161
  168. package/dist/services/hub/EvmVaultTokenService.js.map +0 -1
  169. package/dist/services/hub/EvmWalletAbstraction.d.ts +0 -9
  170. package/dist/services/hub/EvmWalletAbstraction.d.ts.map +0 -1
  171. package/dist/services/hub/EvmWalletAbstraction.js +0 -14
  172. package/dist/services/hub/EvmWalletAbstraction.js.map +0 -1
  173. package/dist/services/hub/index.d.ts +0 -4
  174. package/dist/services/hub/index.d.ts.map +0 -1
  175. package/dist/services/hub/index.js +0 -4
  176. package/dist/services/hub/index.js.map +0 -1
  177. package/dist/services/index.d.ts +0 -7
  178. package/dist/services/index.d.ts.map +0 -1
  179. package/dist/services/index.js +0 -7
  180. package/dist/services/index.js.map +0 -1
  181. package/dist/services/intentRelay/IntentRelayApiService.d.ts +0 -112
  182. package/dist/services/intentRelay/IntentRelayApiService.d.ts.map +0 -1
  183. package/dist/services/intentRelay/IntentRelayApiService.js +0 -160
  184. package/dist/services/intentRelay/IntentRelayApiService.js.map +0 -1
  185. package/dist/services/intentRelay/IntentRelayApiService.test.d.ts +0 -2
  186. package/dist/services/intentRelay/IntentRelayApiService.test.d.ts.map +0 -1
  187. package/dist/services/intentRelay/IntentRelayApiService.test.js +0 -134
  188. package/dist/services/intentRelay/IntentRelayApiService.test.js.map +0 -1
  189. package/dist/services/intentRelay/index.d.ts +0 -2
  190. package/dist/services/intentRelay/index.d.ts.map +0 -1
  191. package/dist/services/intentRelay/index.js +0 -2
  192. package/dist/services/intentRelay/index.js.map +0 -1
  193. package/dist/services/moneyMarket/MoneyMarketService.d.ts +0 -525
  194. package/dist/services/moneyMarket/MoneyMarketService.d.ts.map +0 -1
  195. package/dist/services/moneyMarket/MoneyMarketService.js +0 -814
  196. package/dist/services/moneyMarket/MoneyMarketService.js.map +0 -1
  197. package/dist/services/moneyMarket/MoneyMarketService.test.d.ts +0 -2
  198. package/dist/services/moneyMarket/MoneyMarketService.test.d.ts.map +0 -1
  199. package/dist/services/moneyMarket/MoneyMarketService.test.js +0 -262
  200. package/dist/services/moneyMarket/MoneyMarketService.test.js.map +0 -1
  201. package/dist/services/moneyMarket/index.d.ts +0 -2
  202. package/dist/services/moneyMarket/index.d.ts.map +0 -1
  203. package/dist/services/moneyMarket/index.js +0 -2
  204. package/dist/services/moneyMarket/index.js.map +0 -1
  205. package/dist/services/shared/Erc20Service.d.ts +0 -42
  206. package/dist/services/shared/Erc20Service.d.ts.map +0 -1
  207. package/dist/services/shared/Erc20Service.js +0 -108
  208. package/dist/services/shared/Erc20Service.js.map +0 -1
  209. package/dist/services/shared/index.d.ts +0 -2
  210. package/dist/services/shared/index.d.ts.map +0 -1
  211. package/dist/services/shared/index.js +0 -2
  212. package/dist/services/shared/index.js.map +0 -1
  213. package/dist/services/solver/EvmSolverService.d.ts +0 -125
  214. package/dist/services/solver/EvmSolverService.d.ts.map +0 -1
  215. package/dist/services/solver/EvmSolverService.js +0 -166
  216. package/dist/services/solver/EvmSolverService.js.map +0 -1
  217. package/dist/services/solver/SolverApiService.d.ts +0 -40
  218. package/dist/services/solver/SolverApiService.d.ts.map +0 -1
  219. package/dist/services/solver/SolverApiService.js +0 -157
  220. package/dist/services/solver/SolverApiService.js.map +0 -1
  221. package/dist/services/solver/SolverApiService.test.d.ts +0 -2
  222. package/dist/services/solver/SolverApiService.test.d.ts.map +0 -1
  223. package/dist/services/solver/SolverApiService.test.js +0 -181
  224. package/dist/services/solver/SolverApiService.test.js.map +0 -1
  225. package/dist/services/solver/SolverService.d.ts +0 -295
  226. package/dist/services/solver/SolverService.d.ts.map +0 -1
  227. package/dist/services/solver/SolverService.js +0 -429
  228. package/dist/services/solver/SolverService.js.map +0 -1
  229. package/dist/services/solver/SolverService.test.d.ts +0 -2
  230. package/dist/services/solver/SolverService.test.d.ts.map +0 -1
  231. package/dist/services/solver/SolverService.test.js +0 -439
  232. package/dist/services/solver/SolverService.test.js.map +0 -1
  233. package/dist/services/solver/index.d.ts +0 -3
  234. package/dist/services/solver/index.d.ts.map +0 -1
  235. package/dist/services/solver/index.js +0 -3
  236. package/dist/services/solver/index.js.map +0 -1
  237. package/dist/services/spoke/CWSpokeService.d.ts +0 -67
  238. package/dist/services/spoke/CWSpokeService.d.ts.map +0 -1
  239. package/dist/services/spoke/CWSpokeService.js +0 -75
  240. package/dist/services/spoke/CWSpokeService.js.map +0 -1
  241. package/dist/services/spoke/EvmSpokeService.d.ts +0 -62
  242. package/dist/services/spoke/EvmSpokeService.d.ts.map +0 -1
  243. package/dist/services/spoke/EvmSpokeService.js +0 -120
  244. package/dist/services/spoke/EvmSpokeService.js.map +0 -1
  245. package/dist/services/spoke/IconSpokeService.d.ts +0 -56
  246. package/dist/services/spoke/IconSpokeService.d.ts.map +0 -1
  247. package/dist/services/spoke/IconSpokeService.js +0 -124
  248. package/dist/services/spoke/IconSpokeService.js.map +0 -1
  249. package/dist/services/spoke/SolanaSpokeService.d.ts +0 -46
  250. package/dist/services/spoke/SolanaSpokeService.d.ts.map +0 -1
  251. package/dist/services/spoke/SolanaSpokeService.js +0 -170
  252. package/dist/services/spoke/SolanaSpokeService.js.map +0 -1
  253. package/dist/services/spoke/SpokeService.d.ts +0 -34
  254. package/dist/services/spoke/SpokeService.d.ts.map +0 -1
  255. package/dist/services/spoke/SpokeService.js +0 -102
  256. package/dist/services/spoke/SpokeService.js.map +0 -1
  257. package/dist/services/spoke/StellarSpokeService.d.ts +0 -35
  258. package/dist/services/spoke/StellarSpokeService.d.ts.map +0 -1
  259. package/dist/services/spoke/StellarSpokeService.js +0 -39
  260. package/dist/services/spoke/StellarSpokeService.js.map +0 -1
  261. package/dist/services/spoke/SuiSpokeService.d.ts +0 -69
  262. package/dist/services/spoke/SuiSpokeService.d.ts.map +0 -1
  263. package/dist/services/spoke/SuiSpokeService.js +0 -74
  264. package/dist/services/spoke/SuiSpokeService.js.map +0 -1
  265. package/dist/services/spoke/index.d.ts +0 -3
  266. package/dist/services/spoke/index.d.ts.map +0 -1
  267. package/dist/services/spoke/index.js +0 -3
  268. package/dist/services/spoke/index.js.map +0 -1
  269. package/dist/tests/services/hub/EvmAssetManagerService.test.d.ts +0 -2
  270. package/dist/tests/services/hub/EvmAssetManagerService.test.d.ts.map +0 -1
  271. package/dist/tests/services/hub/EvmAssetManagerService.test.js +0 -138
  272. package/dist/tests/services/hub/EvmAssetManagerService.test.js.map +0 -1
  273. package/dist/tests/services/hub/EvmMoneyMarketService.test.d.ts +0 -2
  274. package/dist/tests/services/hub/EvmMoneyMarketService.test.d.ts.map +0 -1
  275. package/dist/tests/services/hub/EvmMoneyMarketService.test.js +0 -121
  276. package/dist/tests/services/hub/EvmMoneyMarketService.test.js.map +0 -1
  277. package/dist/tests/services/hub/EvmVaultTokenService.test.d.ts +0 -2
  278. package/dist/tests/services/hub/EvmVaultTokenService.test.d.ts.map +0 -1
  279. package/dist/tests/services/hub/EvmVaultTokenService.test.js +0 -98
  280. package/dist/tests/services/hub/EvmVaultTokenService.test.js.map +0 -1
  281. package/dist/tests/services/spoke/EvmSpokeService.test.d.ts +0 -2
  282. package/dist/tests/services/spoke/EvmSpokeService.test.d.ts.map +0 -1
  283. package/dist/tests/services/spoke/EvmSpokeService.test.js +0 -198
  284. package/dist/tests/services/spoke/EvmSpokeService.test.js.map +0 -1
  285. package/dist/types.d.ts +0 -352
  286. package/dist/types.d.ts.map +0 -1
  287. package/dist/types.js +0 -30
  288. package/dist/types.js.map +0 -1
  289. package/dist/utils/evm-utils.d.ts +0 -10
  290. package/dist/utils/evm-utils.d.ts.map +0 -1
  291. package/dist/utils/evm-utils.js +0 -15
  292. package/dist/utils/evm-utils.js.map +0 -1
  293. package/dist/utils/index.d.ts +0 -3
  294. package/dist/utils/index.d.ts.map +0 -1
  295. package/dist/utils/index.js +0 -3
  296. package/dist/utils/index.js.map +0 -1
  297. package/dist/utils/shared-utils.d.ts +0 -20
  298. package/dist/utils/shared-utils.d.ts.map +0 -1
  299. package/dist/utils/shared-utils.js +0 -69
  300. package/dist/utils/shared-utils.js.map +0 -1
  301. package/dist/utils/shared-utils.test.d.ts +0 -2
  302. package/dist/utils/shared-utils.test.d.ts.map +0 -1
  303. package/dist/utils/shared-utils.test.js +0 -63
  304. package/dist/utils/shared-utils.test.js.map +0 -1
@@ -1,145 +0,0 @@
1
- import { bcs } from '@mysten/sui/bcs';
2
- import { Transaction } from '@mysten/sui/transactions';
3
- import { toHex } from 'viem';
4
- export class SuiSpokeProvider {
5
- walletProvider;
6
- chainConfig;
7
- constructor(config, wallet_provider) {
8
- this.chainConfig = config;
9
- this.walletProvider = wallet_provider;
10
- }
11
- async getBalance(token) {
12
- const assetmanager = this.splitAddress(this.chainConfig.addresses.assetManager);
13
- const tx = new Transaction();
14
- const result = await this.walletProvider.viewContract(tx, assetmanager.packageId, assetmanager.moduleId, 'get_token_balance', [tx.object(assetmanager.stateId)], [token]);
15
- if (!Array.isArray(result?.returnValues) ||
16
- !Array.isArray(result.returnValues[0]) ||
17
- result.returnValues[0][0] === undefined) {
18
- throw new Error('Failed to get Balance');
19
- }
20
- const val = result.returnValues[0][0];
21
- const str_u64 = bcs.U64.parse(Uint8Array.from(val));
22
- return BigInt(str_u64);
23
- }
24
- async transfer(token, amount, to, data, raw) {
25
- const isNative = token.toLowerCase() === this.chainConfig.nativeToken.toLowerCase();
26
- const tx = new Transaction();
27
- const walletAddress = await this.walletProvider.getWalletAddressBytes();
28
- const coin = isNative
29
- ? await this.getNativeCoin(tx, amount)
30
- : await this.getCoin(tx, token, amount, walletAddress);
31
- const connection = this.splitAddress(this.chainConfig.addresses.connection);
32
- const assetManager = this.splitAddress(this.chainConfig.addresses.assetManager);
33
- // Call transfer function
34
- tx.moveCall({
35
- target: `${assetManager.packageId}::${assetManager.moduleId}::transfer`,
36
- typeArguments: [token],
37
- arguments: [
38
- tx.object(assetManager.stateId),
39
- tx.object(connection.stateId), // Connection state object
40
- coin,
41
- tx.pure(bcs.vector(bcs.u8()).serialize(to)),
42
- tx.pure(bcs.vector(bcs.u8()).serialize(data)),
43
- ],
44
- });
45
- if (raw) {
46
- const transactionRaw = await tx.build();
47
- const transactionRawBase64String = Buffer.from(transactionRaw).toString('base64');
48
- return {
49
- from: walletAddress,
50
- to: `${assetManager.packageId}::${assetManager.moduleId}::transfer`,
51
- value: amount,
52
- data: transactionRawBase64String,
53
- };
54
- }
55
- // Execute transaction
56
- return this.walletProvider.signAndExecuteTxn(tx);
57
- }
58
- async getNativeCoin(tx, amount) {
59
- const coin = tx.splitCoins(tx.gas, [tx.pure.u64(amount)])[0];
60
- if (coin === undefined) {
61
- return Promise.reject(Error('[SuiIntentService.getNativeCoin] coin undefined'));
62
- }
63
- return coin;
64
- }
65
- async getCoin(tx, coin, amount, address) {
66
- const coins = await this.walletProvider.getCoins(address, coin);
67
- const objects = [];
68
- let totalAmount = BigInt(0);
69
- for (const coin of coins.data) {
70
- totalAmount += BigInt(coin.balance);
71
- objects.push(coin.coinObjectId);
72
- if (totalAmount >= amount) {
73
- break;
74
- }
75
- }
76
- const firstObject = objects[0];
77
- if (!firstObject) {
78
- throw new Error(`[SuiIntentService.getCoin] Coin=${coin} not found for address=${address} and amount=${amount}`);
79
- }
80
- if (objects.length > 1) {
81
- tx.mergeCoins(firstObject, objects.slice(1));
82
- }
83
- if (totalAmount === amount) {
84
- return tx.object(firstObject);
85
- }
86
- return tx.splitCoins(firstObject, [amount]);
87
- }
88
- splitAddress(address) {
89
- const parts = address.split('::');
90
- if (parts.length === 3) {
91
- if (parts[0] && parts[1] && parts[2]) {
92
- return { packageId: parts[0], moduleId: parts[1], stateId: parts[2] };
93
- }
94
- throw new Error('Invalid package address');
95
- }
96
- throw new Error('Invalid package address');
97
- }
98
- async sendMessage(dst_chain_id, dst_address, data, raw) {
99
- const txb = new Transaction();
100
- const connection = this.splitAddress(this.chainConfig.addresses.connection);
101
- // Perform send message transaction
102
- txb.moveCall({
103
- target: `${connection.packageId}::${connection.moduleId}::send_message_ua`,
104
- arguments: [
105
- txb.object(connection.stateId),
106
- txb.pure.u256(dst_chain_id),
107
- txb.pure(bcs.vector(bcs.u8()).serialize(dst_address)),
108
- txb.pure(bcs.vector(bcs.u8()).serialize(data)),
109
- ],
110
- });
111
- if (raw) {
112
- const transactionRaw = await txb.build();
113
- const transactionRawBase64String = Buffer.from(transactionRaw).toString('base64');
114
- const walletAddress = await this.walletProvider.getWalletAddressBytes();
115
- return {
116
- from: walletAddress,
117
- to: `${connection.packageId}::${connection.moduleId}::send_message_ua`,
118
- value: 0n,
119
- data: transactionRawBase64String,
120
- };
121
- }
122
- return this.walletProvider.signAndExecuteTxn(txb);
123
- }
124
- async configureAssetManagerHub(hubNetworkId, hubAssetManager) {
125
- const tx = new Transaction();
126
- const assetmanager = this.splitAddress(this.chainConfig.addresses.assetManager);
127
- tx.moveCall({
128
- target: `${assetmanager.packageId}::${assetmanager.moduleId}::set_hub_details`,
129
- arguments: [tx.object(assetmanager.stateId), tx.pure.u64(hubNetworkId), tx.pure.vector('u8', hubAssetManager)],
130
- });
131
- const result = await this.walletProvider.signAndExecuteTxn(tx);
132
- return result;
133
- }
134
- async getWalletAddress() {
135
- return this.walletProvider.getWalletAddress();
136
- }
137
- async getWalletAddressBytes() {
138
- const address = await this.getWalletAddress();
139
- return SuiSpokeProvider.getAddressBCSBytes(address);
140
- }
141
- static getAddressBCSBytes(suiaddress) {
142
- return toHex(bcs.Address.serialize(suiaddress).toBytes());
143
- }
144
- }
145
- //# sourceMappingURL=SuiSpokeProvider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SuiSpokeProvider.js","sourceRoot":"","sources":["../../../src/entities/sui/SuiSpokeProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AACtC,OAAO,EAAE,WAAW,EAA0B,MAAM,0BAA0B,CAAC;AAC/E,OAAO,EAAY,KAAK,EAAE,MAAM,MAAM,CAAC;AAOvC,MAAM,OAAO,gBAAgB;IACX,cAAc,CAAqB;IAC5C,WAAW,CAAsB;IAExC,YAAY,MAA2B,EAAE,eAAmC;QAC1E,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC;QAC1B,IAAI,CAAC,cAAc,GAAG,eAAe,CAAC;IACxC,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,KAAa;QAC5B,MAAM,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;QAChF,MAAM,EAAE,GAAG,IAAI,WAAW,EAAE,CAAC;QAC7B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,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AAI,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC;SAC/G,CAAC,CAAC;QAEH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC;QAC/D,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,OAAO,IAAI,CAAC,cAAc,CAAC,gBAAgB,EAAE,CAAC;IAChD,CAAC;IAED,KAAK,CAAC,qBAAqB;QACzB,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAC9C,OAAO,gBAAgB,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;IACtD,CAAC;IAED,MAAM,CAAC,kBAAkB,CAAC,UAAkB;QAC1C,OAAO,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;IAC5D,CAAC;CACF"}
package/dist/errors.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=errors.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":""}
package/dist/errors.js DELETED
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=errors.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":""}
package/dist/guards.d.ts DELETED
@@ -1,25 +0,0 @@
1
- import type { JsonRpcPayloadResponse, ResponseAddressType, ResponseSigningType } from './entities/icon/HanaWalletConnector.js';
2
- import { CWSpokeProvider, IconSpokeProvider, SolanaSpokeProvider, StellarSpokeProvider, SuiSpokeProvider, type EvmUninitializedConfig, type EvmInitializedConfig, type EvmUninitializedPrivateKeyConfig, type EvmUninitializedBrowserConfig, type SpokeProvider, EvmSpokeProvider } from './entities/index.js';
3
- import { type EvmHubChainConfig, type EvmSpokeChainConfig, type HubChainConfig, type IconAddress, type IntentRelayChainId, type MoneyMarketConfig, type MoneyMarketConfigParams, type Optional, type PartnerFeeAmount, type PartnerFeeConfig, type PartnerFeePercentage, type Prettify, type SolverConfig, type SolverConfigParams, type SpokeChainConfig } from './index.js';
4
- export declare function isEvmHubChainConfig(value: HubChainConfig): value is EvmHubChainConfig;
5
- export declare function isEvmSpokeChainConfig(value: SpokeChainConfig): value is EvmSpokeChainConfig;
6
- export declare function isEvmUninitializedConfig(value: EvmUninitializedConfig | EvmInitializedConfig): value is EvmUninitializedConfig;
7
- export declare function isEvmInitializedConfig(value: EvmUninitializedConfig | EvmInitializedConfig): value is EvmInitializedConfig;
8
- export declare function isEvmUninitializedBrowserConfig(value: EvmUninitializedConfig): value is EvmUninitializedBrowserConfig;
9
- export declare function isEvmUninitializedPrivateKeyConfig(value: EvmUninitializedConfig): value is EvmUninitializedPrivateKeyConfig;
10
- export declare function isIconAddress(value: unknown): value is IconAddress;
11
- export declare function isResponseAddressType(value: unknown): value is ResponseAddressType;
12
- export declare function isResponseSigningType(value: unknown): value is ResponseSigningType;
13
- export declare function isJsonRpcPayloadResponse(value: unknown): value is JsonRpcPayloadResponse;
14
- export declare function isIntentRelayChainId(value: bigint): value is IntentRelayChainId;
15
- export declare function isPartnerFeeAmount(value: unknown): value is PartnerFeeAmount;
16
- export declare function isPartnerFeePercentage(value: unknown): value is PartnerFeePercentage;
17
- export declare function isEvmSpokeProvider(value: SpokeProvider): value is EvmSpokeProvider;
18
- export declare function isSolanaSpokeProvider(value: SpokeProvider): value is SolanaSpokeProvider;
19
- export declare function isStellarSpokeProvider(value: SpokeProvider): value is StellarSpokeProvider;
20
- export declare function isCWSpokeProvider(value: SpokeProvider): value is CWSpokeProvider;
21
- export declare function isIconSpokeProvider(value: SpokeProvider): value is IconSpokeProvider;
22
- export declare function isSuiSpokeProvider(value: SpokeProvider): value is SuiSpokeProvider;
23
- export declare function isConfiguredSolverConfig(value: SolverConfigParams): value is Prettify<SolverConfig & Optional<PartnerFeeConfig, 'partnerFee'>>;
24
- export declare function isConfiguredMoneyMarketConfig(value: MoneyMarketConfigParams): value is Prettify<MoneyMarketConfig & Optional<PartnerFeeConfig, 'partnerFee'>>;
25
- //# sourceMappingURL=guards.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"guards.d.ts","sourceRoot":"","sources":["../src/guards.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,gBAAgB,EAChB,KAAK,sBAAsB,EAC3B,KAAK,oBAAoB,EACzB,KAAK,gCAAgC,EACrC,KAAK,6BAA6B,EAClC,KAAK,aAAa,EAClB,gBAAgB,EACjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,EAC5B,KAAK,QAAQ,EACb,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,QAAQ,EACb,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACtB,MAAM,YAAY,CAAC;AAEpB,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,cAAc,GAAG,KAAK,IAAI,iBAAiB,CAErF;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,gBAAgB,GAAG,KAAK,IAAI,mBAAmB,CAE3F;AAED,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,sBAAsB,GAAG,oBAAoB,GACnD,KAAK,IAAI,sBAAsB,CAEjC;AAED,wBA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,aAAa,GAAG,KAAK,IAAI,gBAAgB,CAOlF;AAED,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,kBAAkB,GACxB,KAAK,IAAI,QAAQ,CAAC,YAAY,GAAG,QAAQ,CAAC,gBAAgB,EAAE,YAAY,CAAC,CAAC,CAQ5E;AAED,wBAAgB,6BAA6B,CAC3C,KAAK,EAAE,uBAAuB,GAC7B,KAAK,IAAI,QAAQ,CAAC,iBAAiB,GAAG,QAAQ,CAAC,gBAAgB,EAAE,YAAY,CAAC,CAAC,CAUjF"}
package/dist/guards.js DELETED
@@ -1,110 +0,0 @@
1
- import { CWSpokeProvider, IconSpokeProvider, SolanaSpokeProvider, StellarSpokeProvider, SuiSpokeProvider, EvmSpokeProvider, } from './entities/index.js';
2
- import { INTENT_RELAY_CHAIN_IDS, } from './index.js';
3
- export function isEvmHubChainConfig(value) {
4
- return typeof value === 'object' && value.chain.type === 'EVM';
5
- }
6
- export function isEvmSpokeChainConfig(value) {
7
- return typeof value === 'object' && value.chain.type === 'EVM';
8
- }
9
- export function isEvmUninitializedConfig(value) {
10
- return typeof value === 'object' && 'chain' in value;
11
- }
12
- export function isEvmInitializedConfig(value) {
13
- return typeof value === 'object' && 'walletClient' in value && 'publicClient' in value;
14
- }
15
- export function isEvmUninitializedBrowserConfig(value) {
16
- return typeof value === 'object' && 'userAddress' in value && 'chain' in value && 'provider' in value;
17
- }
18
- export function isEvmUninitializedPrivateKeyConfig(value) {
19
- return typeof value === 'object' && 'chain' in value && 'privateKey' in value;
20
- }
21
- export function isIconAddress(value) {
22
- return typeof value === 'string' && /^hx[a-f0-9]{40}$|^cx[a-f0-9]{40}$/.test(value);
23
- }
24
- export function isResponseAddressType(value) {
25
- return (typeof value === 'object' &&
26
- value !== null &&
27
- 'type' in value &&
28
- 'payload' in value &&
29
- value.type === 'RESPONSE_ADDRESS' &&
30
- isIconAddress(value.payload));
31
- }
32
- export function isResponseSigningType(value) {
33
- return (typeof value === 'object' &&
34
- value !== null &&
35
- 'type' in value &&
36
- 'payload' in value &&
37
- value.type === 'RESPONSE_SIGNING' &&
38
- typeof value.payload === 'string');
39
- }
40
- export function isJsonRpcPayloadResponse(value) {
41
- return (typeof value === 'object' &&
42
- value !== null &&
43
- 'id' in value &&
44
- 'result' in value &&
45
- typeof value.result === 'string');
46
- }
47
- export function isIntentRelayChainId(value) {
48
- return (typeof value === 'bigint' &&
49
- value >= 0n &&
50
- Object.values(INTENT_RELAY_CHAIN_IDS).includes(value));
51
- }
52
- export function isPartnerFeeAmount(value) {
53
- return typeof value === 'object' && value !== null && 'address' in value && 'amount' in value;
54
- }
55
- export function isPartnerFeePercentage(value) {
56
- return typeof value === 'object' && value !== null && 'address' in value && 'percentage' in value;
57
- }
58
- export function isEvmSpokeProvider(value) {
59
- return (typeof value === 'object' &&
60
- value !== null &&
61
- value instanceof EvmSpokeProvider &&
62
- value.chainConfig.chain.type === 'EVM');
63
- }
64
- export function isSolanaSpokeProvider(value) {
65
- return (typeof value === 'object' &&
66
- value !== null &&
67
- value instanceof SolanaSpokeProvider &&
68
- value.chainConfig.chain.type === 'SOLANA');
69
- }
70
- export function isStellarSpokeProvider(value) {
71
- return (typeof value === 'object' &&
72
- value !== null &&
73
- value instanceof StellarSpokeProvider &&
74
- value.chainConfig.chain.type === 'STELLAR');
75
- }
76
- export function isCWSpokeProvider(value) {
77
- return (typeof value === 'object' &&
78
- value !== null &&
79
- value instanceof CWSpokeProvider &&
80
- value.chainConfig.chain.type === 'INJECTIVE');
81
- }
82
- export function isIconSpokeProvider(value) {
83
- return (typeof value === 'object' &&
84
- value !== null &&
85
- value instanceof IconSpokeProvider &&
86
- value.chainConfig.chain.type === 'ICON');
87
- }
88
- export function isSuiSpokeProvider(value) {
89
- return (typeof value === 'object' &&
90
- value !== null &&
91
- value instanceof SuiSpokeProvider &&
92
- value.chainConfig.chain.type === 'SUI');
93
- }
94
- export function isConfiguredSolverConfig(value) {
95
- return (typeof value === 'object' &&
96
- value !== null &&
97
- 'intentsContract' in value &&
98
- 'solverApiEndpoint' in value &&
99
- 'relayerApiEndpoint' in value);
100
- }
101
- export function isConfiguredMoneyMarketConfig(value) {
102
- return (typeof value === 'object' &&
103
- value !== null &&
104
- 'lendingPool' in value &&
105
- 'uiPoolDataProvider' in value &&
106
- 'poolAddressesProvider' in value &&
107
- 'bnUSD' in value &&
108
- 'bnUSDVault' in value);
109
- }
110
- //# sourceMappingURL=guards.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"guards.js","sourceRoot":"","sources":["../src/guards.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,gBAAgB,EAMhB,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,sBAAsB,GAgBvB,MAAM,YAAY,CAAC;AAEpB,MAAM,UAAU,mBAAmB,CAAC,KAAqB;IACvD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC;AACjE,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,KAAuB;IAC3D,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC;AACjE,CAAC;AAED,MAAM,UAAU,wBAAwB,CACtC,KAAoD;IAEpD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,IAAI,KAAK,CAAC;AACvD,CAAC;AAED,MAAM,UAAU,sBAAsB,CACpC,KAAoD;IAEpD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,cAAc,IAAI,KAAK,IAAI,cAAc,IAAI,KAAK,CAAC;AACzF,CAAC;AAED,MAAM,UAAU,+BAA+B,CAAC,KAA6B;IAC3E,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,aAAa,IAAI,KAAK,IAAI,OAAO,IAAI,KAAK,IAAI,UAAU,IAAI,KAAK,CAAC;AACxG,CAA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O,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,KAAK,YAAY,iBAAiB;QAClC,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,KAAK,MAAM,CACxC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,KAAoB;IACrD,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,KAAK,YAAY,gBAAgB;QACjC,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,KAAK,KAAK,CACvC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,wBAAwB,CACtC,KAAyB;IAEzB,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,iBAAiB,IAAI,KAAK;QAC1B,mBAAmB,IAAI,KAAK;QAC5B,oBAAoB,IAAI,KAAK,CAC9B,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,6BAA6B,CAC3C,KAA8B;IAE9B,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,aAAa,IAAI,KAAK;QACtB,oBAAoB,IAAI,KAAK;QAC7B,uBAAuB,IAAI,KAAK;QAChC,OAAO,IAAI,KAAK;QAChB,YAAY,IAAI,KAAK,CACtB,CAAC;AACJ,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC"}
package/dist/index.js DELETED
@@ -1,10 +0,0 @@
1
- export * from './abis/index.js';
2
- export * from './entities/index.js';
3
- export * from './services/index.js';
4
- export * from './utils/index.js';
5
- export * from './constants.js';
6
- export * from './guards.js';
7
- export * from './errors.js';
8
- export * from './types.js';
9
- export * from '@sodax/types';
10
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC"}
@@ -1,61 +0,0 @@
1
- import { type Address, type Hex, type PublicClient } from 'viem';
2
- import type { EvmHubProvider } from '../../entities/Providers.js';
3
- import type { AssetInfo, EvmContractCall } from '../../types.js';
4
- import type { SpokeChainId } from '@sodax/types';
5
- export type EvmDepositToDataParams = {
6
- token: Hex | string;
7
- to: Address;
8
- amount: bigint;
9
- };
10
- export type EvmWithdrawAssetDataParams = {
11
- token: Hex | string;
12
- to: Hex;
13
- amount: bigint;
14
- };
15
- export declare class EvmAssetManagerService {
16
- private constructor();
17
- /**
18
- * Get asset information for a given asset address
19
- * @param asset - The address of the asset contract
20
- * @param assetManager - The address of the asset manager contract
21
- * @param client - The Viem public client
22
- * @returns Object containing chainID and spoke address for the asset
23
- */
24
- static getAssetInfo(asset: Address, assetManager: Address, client: PublicClient): Promise<AssetInfo>;
25
- /**
26
- * Encodes a transfer transaction for an asset.
27
- * @param token - The address of the token.
28
- * @param to - The address to transfer the token to.
29
- * @param amount - The amount of the token to transfer.
30
- * @param assetManager
31
- * @returns The encoded contract call.
32
- */
33
- static encodeTransfer(token: Address, to: Address, amount: bigint, assetManager: Address): EvmContractCall;
34
- /**
35
- * Constructs the data for depositing tokens to the spoke chain.
36
- * @param {EvmDepositToDataParams} params - The address of the token to deposit.
37
- * @param {EvmSpokeProvider} spokeProvider - The provider for the spoke chain.
38
- * @returns {Hex} Encoded contract calls for the deposit transaction.
39
- * @throws Will throw an error if the asset or vault address is not found.
40
- */
41
- static depositToData(params: EvmDepositToDataParams, spokeChainId: SpokeChainId): Hex;
42
- /**
43
- * Withdraw tokens from the spoke chain.
44
- * @param {EvmWithdrawAssetDataParams} params - Parameters for the withdrawal.
45
- * @param {EvmSpokeProvider} spokeProvider - The provider for the spoke chain.
46
- * @param {EvmHubProvider} hubProvider - The provider for the hub chain.
47
- * @returns {Hex} Encoded contract calls for the withdrawal transaction.
48
- * @throws Will throw an error if the asset address is not found.
49
- */
50
- static withdrawAssetData(params: EvmWithdrawAssetDataParams, hubProvider: EvmHubProvider, spokeChainId: SpokeChainId): Hex;
51
- /**
52
- * Get asset address for a given chain ID and spoke address
53
- * @param chainId Chain ID where the asset exists
54
- * @param spokeAddress Address of the asset on the spoke chain
55
- * @param assetManager Address of the asset manager contract
56
- * @param client The Viem public client
57
- * @returns The asset's address on the hub chain
58
- */
59
- getAssetAddress(chainId: bigint, spokeAddress: Address, assetManager: Address, client: PublicClient): Promise<Address>;
60
- }
61
- //# sourceMappingURL=EvmAssetManagerService.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EvmAssetManagerService.d.ts","sourceRoot":"","sources":["../../../src/services/hub/EvmAssetManagerService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK,YAAY,EAAsB,MAAM,MAAM,CAAC;AAGrF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAIjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,MAAM,MAAM,sBAAsB,GAAG;IACnC,KAAK,EAAE,GAAG,GAAG,MAAM,CAAC;IACpB,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG;IACvC,KAAK,EAAE,GAAG,GAAG,MAAM,CAAC;IACpB,EAAE,EAAE,GAAG,CAAC;IACR,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,qBAAa,sBAAsB;IACjC,OAAO;IAEP;;;;;;OAMG;WACiB,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,SAAS,CAAC;IAcjH;;;;;;;OAOG;WACW,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,GAAG,eAAe;IAYjH;;;;;;OAMG;WACW,aAAa,CAAC,MAAM,EAAE,sBAAsB,EAAE,YAAY,EAAE,YAAY,GAAG,GAAG;IAmB5F;;;;;;;OAOG;WACW,iBAAiB,CAC7B,MAAM,EAAE,0BAA0B,EAClC,WAAW,EAAE,cAAc,EAC3B,YAAY,EAAE,YAAY,GACzB,GAAG;IAsBN;;;;;;;OAOG;IACG,eAAe,CACnB,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,OAAO,EACrB,YAAY,EAAE,OAAO,EACrB,MAAM,EAAE,YAAY,GACnB,OAAO,CAAC,OAAO,CAAC;CAQpB"}
@@ -1,103 +0,0 @@
1
- import { encodeFunctionData } from 'viem';
2
- import { assetManagerAbi } from '../../abis/index.js';
3
- import { getHubAssetInfo } from '../../constants.js';
4
- import { encodeContractCalls } from '../../utils/evm-utils.js';
5
- import { Erc20Service } from '../shared/Erc20Service.js';
6
- import { EvmVaultTokenService } from './EvmVaultTokenService.js';
7
- export class EvmAssetManagerService {
8
- constructor() { }
9
- /**
10
- * Get asset information for a given asset address
11
- * @param asset - The address of the asset contract
12
- * @param assetManager - The address of the asset manager contract
13
- * @param client - The Viem public client
14
- * @returns Object containing chainID and spoke address for the asset
15
- */
16
- static async getAssetInfo(asset, assetManager, client) {
17
- const [chainId, spokeAddress] = await client.readContract({
18
- address: assetManager,
19
- abi: assetManagerAbi,
20
- functionName: 'assetInfo',
21
- args: [asset],
22
- });
23
- return {
24
- chainId,
25
- spokeAddress,
26
- };
27
- }
28
- /**
29
- * Encodes a transfer transaction for an asset.
30
- * @param token - The address of the token.
31
- * @param to - The address to transfer the token to.
32
- * @param amount - The amount of the token to transfer.
33
- * @param assetManager
34
- * @returns The encoded contract call.
35
- */
36
- static encodeTransfer(token, to, amount, assetManager) {
37
- return {
38
- address: assetManager,
39
- value: 0n,
40
- data: encodeFunctionData({
41
- abi: assetManagerAbi,
42
- functionName: 'transfer',
43
- args: [token, to, amount, '0x'],
44
- }),
45
- };
46
- }
47
- /**
48
- * Constructs the data for depositing tokens to the spoke chain.
49
- * @param {EvmDepositToDataParams} params - The address of the token to deposit.
50
- * @param {EvmSpokeProvider} spokeProvider - The provider for the spoke chain.
51
- * @returns {Hex} Encoded contract calls for the deposit transaction.
52
- * @throws Will throw an error if the asset or vault address is not found.
53
- */
54
- static depositToData(params, spokeChainId) {
55
- const calls = [];
56
- const assetConfig = getHubAssetInfo(spokeChainId, params.token);
57
- if (!assetConfig) {
58
- throw new Error('[depositToData] Hub asset not found');
59
- }
60
- const assetAddress = assetConfig.asset;
61
- const vaultAddress = assetConfig.vault;
62
- calls.push(Erc20Service.encodeApprove(assetAddress, vaultAddress, params.amount));
63
- calls.push(EvmVaultTokenService.encodeDeposit(vaultAddress, assetAddress, params.amount));
64
- const translatedAmount = EvmVaultTokenService.translateIncomingDecimals(assetConfig.decimal, params.amount);
65
- calls.push(Erc20Service.encodeTansfer(vaultAddress, params.to, translatedAmount));
66
- return encodeContractCalls(calls);
67
- }
68
- /**
69
- * Withdraw tokens from the spoke chain.
70
- * @param {EvmWithdrawAssetDataParams} params - Parameters for the withdrawal.
71
- * @param {EvmSpokeProvider} spokeProvider - The provider for the spoke chain.
72
- * @param {EvmHubProvider} hubProvider - The provider for the hub chain.
73
- * @returns {Hex} Encoded contract calls for the withdrawal transaction.
74
- * @throws Will throw an error if the asset address is not found.
75
- */
76
- static withdrawAssetData(params, hubProvider, spokeChainId) {
77
- const calls = [];
78
- const assetConfig = getHubAssetInfo(spokeChainId, params.token);
79
- if (!assetConfig) {
80
- throw new Error('[withdrawAssetData] Hub asset not found');
81
- }
82
- const assetAddress = assetConfig.asset;
83
- calls.push(EvmAssetManagerService.encodeTransfer(assetAddress, params.to, params.amount, hubProvider.chainConfig.addresses.assetManager));
84
- return encodeContractCalls(calls);
85
- }
86
- /**
87
- * Get asset address for a given chain ID and spoke address
88
- * @param chainId Chain ID where the asset exists
89
- * @param spokeAddress Address of the asset on the spoke chain
90
- * @param assetManager Address of the asset manager contract
91
- * @param client The Viem public client
92
- * @returns The asset's address on the hub chain
93
- */
94
- async getAssetAddress(chainId, spokeAddress, assetManager, client) {
95
- return client.readContract({
96
- address: assetManager,
97
- abi: assetManagerAbi,
98
- functionName: 'assets',
99
- args: [chainId, spokeAddress],
100
- });
101
- }
102
- }
103
- //# sourceMappingURL=EvmAssetManagerService.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EvmAssetManagerService.js","sourceRoot":"","sources":["../../../src/services/hub/EvmAssetManagerService.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6C,kBAAkB,EAAE,MAAM,MAAM,CAAC;AACrF,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAGrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAejE,MAAM,OAAO,sBAAsB;IACjC,gBAAuB,CAAC;IAExB;;;;;;OAMG;IACI,MAAM,CAAC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ransport, type PublicClient } from 'viem';
2
- import type { EvmContractCall, TokenInfo, VaultReserves } from '../../types.js';
3
- import type { IEvmWalletProvider } from '../../index.js';
4
- export declare class EvmVaultTokenService {
5
- private constructor();
6
- /**
7
- * Fetches token information for a specific token in the vault.
8
- * @param vault - The address of the vault.
9
- * @param token - The address of the token.
10
- * @param publicClient - PublicClient<HttpTransport>
11
- * @returns Token information as a TokenInfo object.
12
- */
13
- static getTokenInfo(vault: Address, token: Address, publicClient: PublicClient<HttpTransport>): Promise<TokenInfo>;
14
- /**
15
- * Retrieves the reserves of the vault.
16
- * @param vault - The address of the vault.
17
- * @param publicClient - PublicClient<HttpTransport>
18
- * @returns An object containing tokens and their balances.
19
- */
20
- static getVaultReserves(vault: Address, publicClient: PublicClient<HttpTransport>): Promise<VaultReserves>;
21
- /**
22
- * Retrieves all token information for the vault.
23
- * @param vault - The address of the vault.
24
- * @param publicClient - PublicClient<HttpTransport>
25
- * @returns A promise that resolves to an object containing tokens, their infos, and reserves.
26
- */
27
- getAllTokenInfo(vault: Address, publicClient: PublicClient<HttpTransport>): Promise<{
28
- tokens: readonly Address[];
29
- infos: readonly TokenInfo[];
30
- reserves: readonly bigint[];
31
- }>;
32
- /**
33
- * Deposits a specified amount of a token into the vault.
34
- * @param vault - The address of the vault.
35
- * @param token - The address of the token to deposit.
36
- * @param amount - The amount of the token to deposit.
37
- * @param walletProvider - IEvmWalletProvider
38
- * @returns Transaction hash
39
- */
40
- static deposit(vault: Address, token: Address, amount: bigint, walletProvider: IEvmWalletProvider): Promise<Hash>;
41
- /**
42
- * Withdraws a specified amount of a token from the vault.
43
- * @param vault - The address of the vault.
44
- * @param token - The address of the token to withdraw.
45
- * @param amount - The amount of the token to withdraw.
46
- * @param provider - EvmWalletProvider
47
- * @returns Transaction hash
48
- */
49
- static withdraw(vault: Address, token: Address, amount: bigint, provider: IEvmWalletProvider): Promise<Hash>;
50
- /**
51
- * Encodes the deposit transaction data for the vault.
52
- * @param vault - The address of the vault.
53
- * @param token - The address of the token to deposit.
54
- * @param amount - The amount of the token to deposit.
55
- * @returns The encoded contract call data.
56
- */
57
- static encodeDeposit(vault: Address, token: Address, amount: bigint): EvmContractCall;
58
- /**
59
- * Encodes the withdraw transaction data for the vault.
60
- * @param vault - The address of the vault.
61
- * @param token - The address of the token to withdraw.
62
- * @param amount - The amount of the token to withdraw.
63
- * @returns The encoded contract call data.
64
- */
65
- static encodeWithdraw(vault: Address, token: Address, amount: bigint): EvmContractCall;
66
- /**
67
- * Translates token amounts from their native decimals to 18 decimals
68
- * @param decimals - The number of decimals of the token
69
- * @param amount - The amount to translate
70
- * @returns The translated amount
71
- */
72
- static translateIncomingDecimals(decimals: number, amount: bigint): bigint;
73
- /**
74
- * Translates token amounts from 18 decimals back to their native decimals
75
- * @param decimals - The number of decimals of the token
76
- * @param amount - The amount to translate
77
- * @returns The translated amount
78
- */
79
- static translateOutgoingDecimals(decimals: number, amount: bigint): bigint;
80
- }
81
- //# sourceMappingURL=EvmVaultTokenService.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EvmVaultTokenService.d.ts","sourceRoot":"","sources":["../../../src/services/hub/EvmVaultTokenService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,IAAI,EAAE,KAAK,aAAa,EAAE,KAAK,YAAY,EAAsB,MAAM,MAAM,CAAC;AAE1G,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAChF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEzD,qBAAa,oBAAoB;IAC/B,OAAO;IAEP;;;;;;OAMG;WACiB,YAAY,CAC9B,KAAK,EAAE,OAAO,EACd,KAAK,EAAE,OAAO,EACd,YAAY,EAAE,YAAY,CAAC,aAAa,CAAC,GACxC,OAAO,CAAC,SAAS,CAAC;IAWrB;;;;;OAKG;WACiB,gBAAgB,CAClC,KAAK,EAAE,OAAO,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