@sodax/sdk 0.0.1-rc.6 → 0.0.1-rc.8

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 (303) 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 -6
  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 -1196
  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 -54
  58. package/dist/entities/Providers.d.ts.map +0 -1
  59. package/dist/entities/Providers.js +0 -51
  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 -92
  74. package/dist/entities/cosmos/CWSpokeProvider.d.ts.map +0 -1
  75. package/dist/entities/cosmos/CWSpokeProvider.js +0 -143
  76. package/dist/entities/cosmos/CWSpokeProvider.js.map +0 -1
  77. package/dist/entities/cosmos/CosmosWalletProvider.d.ts +0 -28
  78. package/dist/entities/cosmos/CosmosWalletProvider.d.ts.map +0 -1
  79. package/dist/entities/cosmos/CosmosWalletProvider.js +0 -102
  80. package/dist/entities/cosmos/CosmosWalletProvider.js.map +0 -1
  81. package/dist/entities/cosmos/InjectiveWalletProvider.d.ts +0 -25
  82. package/dist/entities/cosmos/InjectiveWalletProvider.d.ts.map +0 -1
  83. package/dist/entities/cosmos/InjectiveWalletProvider.js +0 -76
  84. package/dist/entities/cosmos/InjectiveWalletProvider.js.map +0 -1
  85. package/dist/entities/icon/HanaWalletConnector.d.ts +0 -36
  86. package/dist/entities/icon/HanaWalletConnector.d.ts.map +0 -1
  87. package/dist/entities/icon/HanaWalletConnector.js +0 -92
  88. package/dist/entities/icon/HanaWalletConnector.js.map +0 -1
  89. package/dist/entities/icon/IconSpokeProvider.d.ts +0 -10
  90. package/dist/entities/icon/IconSpokeProvider.d.ts.map +0 -1
  91. package/dist/entities/icon/IconSpokeProvider.js +0 -12
  92. package/dist/entities/icon/IconSpokeProvider.js.map +0 -1
  93. package/dist/entities/icon/index.d.ts +0 -4
  94. package/dist/entities/icon/index.d.ts.map +0 -1
  95. package/dist/entities/icon/index.js +0 -4
  96. package/dist/entities/icon/index.js.map +0 -1
  97. package/dist/entities/icon/utils.d.ts +0 -3
  98. package/dist/entities/icon/utils.d.ts.map +0 -1
  99. package/dist/entities/icon/utils.js +0 -4
  100. package/dist/entities/icon/utils.js.map +0 -1
  101. package/dist/entities/index.d.ts +0 -7
  102. package/dist/entities/index.d.ts.map +0 -1
  103. package/dist/entities/index.js +0 -7
  104. package/dist/entities/index.js.map +0 -1
  105. package/dist/entities/solana/Configs.d.ts +0 -38
  106. package/dist/entities/solana/Configs.d.ts.map +0 -1
  107. package/dist/entities/solana/Configs.js +0 -149
  108. package/dist/entities/solana/Configs.js.map +0 -1
  109. package/dist/entities/solana/SolanaSpokeProvider.d.ts +0 -9
  110. package/dist/entities/solana/SolanaSpokeProvider.d.ts.map +0 -1
  111. package/dist/entities/solana/SolanaSpokeProvider.js +0 -9
  112. package/dist/entities/solana/SolanaSpokeProvider.js.map +0 -1
  113. package/dist/entities/solana/SolanaWalletProvider.d.ts +0 -20
  114. package/dist/entities/solana/SolanaWalletProvider.d.ts.map +0 -1
  115. package/dist/entities/solana/SolanaWalletProvider.js +0 -53
  116. package/dist/entities/solana/SolanaWalletProvider.js.map +0 -1
  117. package/dist/entities/solana/index.d.ts +0 -4
  118. package/dist/entities/solana/index.d.ts.map +0 -1
  119. package/dist/entities/solana/index.js +0 -4
  120. package/dist/entities/solana/index.js.map +0 -1
  121. package/dist/entities/solana/pda/pda.d.ts +0 -45
  122. package/dist/entities/solana/pda/pda.d.ts.map +0 -1
  123. package/dist/entities/solana/pda/pda.js +0 -44
  124. package/dist/entities/solana/pda/pda.js.map +0 -1
  125. package/dist/entities/solana/types/asset_manager.d.ts +0 -919
  126. package/dist/entities/solana/types/asset_manager.d.ts.map +0 -1
  127. package/dist/entities/solana/types/asset_manager.js +0 -2
  128. package/dist/entities/solana/types/asset_manager.js.map +0 -1
  129. package/dist/entities/solana/types/connection.d.ts +0 -446
  130. package/dist/entities/solana/types/connection.d.ts.map +0 -1
  131. package/dist/entities/solana/types/connection.js +0 -2
  132. package/dist/entities/solana/types/connection.js.map +0 -1
  133. package/dist/entities/solana/types/rate_limit_contract.d.ts +0 -348
  134. package/dist/entities/solana/types/rate_limit_contract.d.ts.map +0 -1
  135. package/dist/entities/solana/types/rate_limit_contract.js +0 -2
  136. package/dist/entities/solana/types/rate_limit_contract.js.map +0 -1
  137. package/dist/entities/solana/utils/utils.d.ts +0 -6
  138. package/dist/entities/solana/utils/utils.d.ts.map +0 -1
  139. package/dist/entities/solana/utils/utils.js +0 -18
  140. package/dist/entities/solana/utils/utils.js.map +0 -1
  141. package/dist/entities/stellar/StellarSpokeProvider.d.ts +0 -17
  142. package/dist/entities/stellar/StellarSpokeProvider.d.ts.map +0 -1
  143. package/dist/entities/stellar/StellarSpokeProvider.js +0 -125
  144. package/dist/entities/stellar/StellarSpokeProvider.js.map +0 -1
  145. package/dist/entities/sui/SuiSpokeProvider.d.ts +0 -35
  146. package/dist/entities/sui/SuiSpokeProvider.d.ts.map +0 -1
  147. package/dist/entities/sui/SuiSpokeProvider.js +0 -145
  148. package/dist/entities/sui/SuiSpokeProvider.js.map +0 -1
  149. package/dist/errors.d.ts +0 -2
  150. package/dist/errors.d.ts.map +0 -1
  151. package/dist/errors.js +0 -2
  152. package/dist/errors.js.map +0 -1
  153. package/dist/guards.d.ts +0 -25
  154. package/dist/guards.d.ts.map +0 -1
  155. package/dist/guards.js +0 -110
  156. package/dist/guards.js.map +0 -1
  157. package/dist/index.d.ts.map +0 -1
  158. package/dist/index.js +0 -10
  159. package/dist/index.js.map +0 -1
  160. package/dist/services/hub/EvmAssetManagerService.d.ts +0 -61
  161. package/dist/services/hub/EvmAssetManagerService.d.ts.map +0 -1
  162. package/dist/services/hub/EvmAssetManagerService.js +0 -103
  163. package/dist/services/hub/EvmAssetManagerService.js.map +0 -1
  164. package/dist/services/hub/EvmVaultTokenService.d.ts +0 -81
  165. package/dist/services/hub/EvmVaultTokenService.d.ts.map +0 -1
  166. package/dist/services/hub/EvmVaultTokenService.js +0 -161
  167. package/dist/services/hub/EvmVaultTokenService.js.map +0 -1
  168. package/dist/services/hub/EvmWalletAbstraction.d.ts +0 -9
  169. package/dist/services/hub/EvmWalletAbstraction.d.ts.map +0 -1
  170. package/dist/services/hub/EvmWalletAbstraction.js +0 -14
  171. package/dist/services/hub/EvmWalletAbstraction.js.map +0 -1
  172. package/dist/services/hub/index.d.ts +0 -4
  173. package/dist/services/hub/index.d.ts.map +0 -1
  174. package/dist/services/hub/index.js +0 -4
  175. package/dist/services/hub/index.js.map +0 -1
  176. package/dist/services/index.d.ts +0 -7
  177. package/dist/services/index.d.ts.map +0 -1
  178. package/dist/services/index.js +0 -7
  179. package/dist/services/index.js.map +0 -1
  180. package/dist/services/intentRelay/IntentRelayApiService.d.ts +0 -112
  181. package/dist/services/intentRelay/IntentRelayApiService.d.ts.map +0 -1
  182. package/dist/services/intentRelay/IntentRelayApiService.js +0 -160
  183. package/dist/services/intentRelay/IntentRelayApiService.js.map +0 -1
  184. package/dist/services/intentRelay/IntentRelayApiService.test.d.ts +0 -2
  185. package/dist/services/intentRelay/IntentRelayApiService.test.d.ts.map +0 -1
  186. package/dist/services/intentRelay/IntentRelayApiService.test.js +0 -134
  187. package/dist/services/intentRelay/IntentRelayApiService.test.js.map +0 -1
  188. package/dist/services/intentRelay/index.d.ts +0 -2
  189. package/dist/services/intentRelay/index.d.ts.map +0 -1
  190. package/dist/services/intentRelay/index.js +0 -2
  191. package/dist/services/intentRelay/index.js.map +0 -1
  192. package/dist/services/moneyMarket/MoneyMarketService.d.ts +0 -525
  193. package/dist/services/moneyMarket/MoneyMarketService.d.ts.map +0 -1
  194. package/dist/services/moneyMarket/MoneyMarketService.js +0 -814
  195. package/dist/services/moneyMarket/MoneyMarketService.js.map +0 -1
  196. package/dist/services/moneyMarket/MoneyMarketService.test.d.ts +0 -2
  197. package/dist/services/moneyMarket/MoneyMarketService.test.d.ts.map +0 -1
  198. package/dist/services/moneyMarket/MoneyMarketService.test.js +0 -262
  199. package/dist/services/moneyMarket/MoneyMarketService.test.js.map +0 -1
  200. package/dist/services/moneyMarket/index.d.ts +0 -2
  201. package/dist/services/moneyMarket/index.d.ts.map +0 -1
  202. package/dist/services/moneyMarket/index.js +0 -2
  203. package/dist/services/moneyMarket/index.js.map +0 -1
  204. package/dist/services/shared/Erc20Service.d.ts +0 -42
  205. package/dist/services/shared/Erc20Service.d.ts.map +0 -1
  206. package/dist/services/shared/Erc20Service.js +0 -108
  207. package/dist/services/shared/Erc20Service.js.map +0 -1
  208. package/dist/services/shared/index.d.ts +0 -2
  209. package/dist/services/shared/index.d.ts.map +0 -1
  210. package/dist/services/shared/index.js +0 -2
  211. package/dist/services/shared/index.js.map +0 -1
  212. package/dist/services/solver/EvmSolverService.d.ts +0 -125
  213. package/dist/services/solver/EvmSolverService.d.ts.map +0 -1
  214. package/dist/services/solver/EvmSolverService.js +0 -166
  215. package/dist/services/solver/EvmSolverService.js.map +0 -1
  216. package/dist/services/solver/SolverApiService.d.ts +0 -40
  217. package/dist/services/solver/SolverApiService.d.ts.map +0 -1
  218. package/dist/services/solver/SolverApiService.js +0 -157
  219. package/dist/services/solver/SolverApiService.js.map +0 -1
  220. package/dist/services/solver/SolverApiService.test.d.ts +0 -2
  221. package/dist/services/solver/SolverApiService.test.d.ts.map +0 -1
  222. package/dist/services/solver/SolverApiService.test.js +0 -181
  223. package/dist/services/solver/SolverApiService.test.js.map +0 -1
  224. package/dist/services/solver/SolverService.d.ts +0 -295
  225. package/dist/services/solver/SolverService.d.ts.map +0 -1
  226. package/dist/services/solver/SolverService.js +0 -429
  227. package/dist/services/solver/SolverService.js.map +0 -1
  228. package/dist/services/solver/SolverService.test.d.ts +0 -2
  229. package/dist/services/solver/SolverService.test.d.ts.map +0 -1
  230. package/dist/services/solver/SolverService.test.js +0 -439
  231. package/dist/services/solver/SolverService.test.js.map +0 -1
  232. package/dist/services/solver/index.d.ts +0 -3
  233. package/dist/services/solver/index.d.ts.map +0 -1
  234. package/dist/services/solver/index.js +0 -3
  235. package/dist/services/solver/index.js.map +0 -1
  236. package/dist/services/spoke/CWSpokeService.d.ts +0 -67
  237. package/dist/services/spoke/CWSpokeService.d.ts.map +0 -1
  238. package/dist/services/spoke/CWSpokeService.js +0 -75
  239. package/dist/services/spoke/CWSpokeService.js.map +0 -1
  240. package/dist/services/spoke/EvmSpokeService.d.ts +0 -62
  241. package/dist/services/spoke/EvmSpokeService.d.ts.map +0 -1
  242. package/dist/services/spoke/EvmSpokeService.js +0 -120
  243. package/dist/services/spoke/EvmSpokeService.js.map +0 -1
  244. package/dist/services/spoke/IconSpokeService.d.ts +0 -56
  245. package/dist/services/spoke/IconSpokeService.d.ts.map +0 -1
  246. package/dist/services/spoke/IconSpokeService.js +0 -124
  247. package/dist/services/spoke/IconSpokeService.js.map +0 -1
  248. package/dist/services/spoke/SolanaSpokeService.d.ts +0 -46
  249. package/dist/services/spoke/SolanaSpokeService.d.ts.map +0 -1
  250. package/dist/services/spoke/SolanaSpokeService.js +0 -156
  251. package/dist/services/spoke/SolanaSpokeService.js.map +0 -1
  252. package/dist/services/spoke/SpokeService.d.ts +0 -34
  253. package/dist/services/spoke/SpokeService.d.ts.map +0 -1
  254. package/dist/services/spoke/SpokeService.js +0 -101
  255. package/dist/services/spoke/SpokeService.js.map +0 -1
  256. package/dist/services/spoke/StellarSpokeService.d.ts +0 -35
  257. package/dist/services/spoke/StellarSpokeService.d.ts.map +0 -1
  258. package/dist/services/spoke/StellarSpokeService.js +0 -39
  259. package/dist/services/spoke/StellarSpokeService.js.map +0 -1
  260. package/dist/services/spoke/SuiSpokeService.d.ts +0 -69
  261. package/dist/services/spoke/SuiSpokeService.d.ts.map +0 -1
  262. package/dist/services/spoke/SuiSpokeService.js +0 -73
  263. package/dist/services/spoke/SuiSpokeService.js.map +0 -1
  264. package/dist/services/spoke/index.d.ts +0 -3
  265. package/dist/services/spoke/index.d.ts.map +0 -1
  266. package/dist/services/spoke/index.js +0 -3
  267. package/dist/services/spoke/index.js.map +0 -1
  268. package/dist/tests/services/hub/EvmAssetManagerService.test.d.ts +0 -2
  269. package/dist/tests/services/hub/EvmAssetManagerService.test.d.ts.map +0 -1
  270. package/dist/tests/services/hub/EvmAssetManagerService.test.js +0 -138
  271. package/dist/tests/services/hub/EvmAssetManagerService.test.js.map +0 -1
  272. package/dist/tests/services/hub/EvmMoneyMarketService.test.d.ts +0 -2
  273. package/dist/tests/services/hub/EvmMoneyMarketService.test.d.ts.map +0 -1
  274. package/dist/tests/services/hub/EvmMoneyMarketService.test.js +0 -121
  275. package/dist/tests/services/hub/EvmMoneyMarketService.test.js.map +0 -1
  276. package/dist/tests/services/hub/EvmVaultTokenService.test.d.ts +0 -2
  277. package/dist/tests/services/hub/EvmVaultTokenService.test.d.ts.map +0 -1
  278. package/dist/tests/services/hub/EvmVaultTokenService.test.js +0 -98
  279. package/dist/tests/services/hub/EvmVaultTokenService.test.js.map +0 -1
  280. package/dist/tests/services/spoke/EvmSpokeService.test.d.ts +0 -2
  281. package/dist/tests/services/spoke/EvmSpokeService.test.d.ts.map +0 -1
  282. package/dist/tests/services/spoke/EvmSpokeService.test.js +0 -198
  283. package/dist/tests/services/spoke/EvmSpokeService.test.js.map +0 -1
  284. package/dist/types.d.ts +0 -352
  285. package/dist/types.d.ts.map +0 -1
  286. package/dist/types.js +0 -30
  287. package/dist/types.js.map +0 -1
  288. package/dist/utils/evm-utils.d.ts +0 -10
  289. package/dist/utils/evm-utils.d.ts.map +0 -1
  290. package/dist/utils/evm-utils.js +0 -15
  291. package/dist/utils/evm-utils.js.map +0 -1
  292. package/dist/utils/index.d.ts +0 -3
  293. package/dist/utils/index.d.ts.map +0 -1
  294. package/dist/utils/index.js +0 -3
  295. package/dist/utils/index.js.map +0 -1
  296. package/dist/utils/shared-utils.d.ts +0 -20
  297. package/dist/utils/shared-utils.d.ts.map +0 -1
  298. package/dist/utils/shared-utils.js +0 -69
  299. package/dist/utils/shared-utils.js.map +0 -1
  300. package/dist/utils/shared-utils.test.d.ts +0 -2
  301. package/dist/utils/shared-utils.test.d.ts.map +0 -1
  302. package/dist/utils/shared-utils.test.js +0 -63
  303. package/dist/utils/shared-utils.test.js.map +0 -1
@@ -1,62 +0,0 @@
1
- import { type Address } from 'viem';
2
- import type { EvmHubProvider, EvmSpokeProvider } from '../../entities/index.js';
3
- import type { PromiseEvmTxReturnType, TxReturnType } from '../../types.js';
4
- import type { Hex, HubAddress } from '@sodax/types';
5
- export type EvmSpokeDepositParams = {
6
- from: Address;
7
- to?: HubAddress;
8
- token: Hex;
9
- amount: bigint;
10
- data: Hex;
11
- };
12
- export declare class EvmSpokeService {
13
- private constructor();
14
- /**
15
- * Deposit tokens to the spoke chain.
16
- * @param {EvmSpokeDepositParams} params - The parameters for the deposit, including the user's address, token address, amount, and additional data.
17
- * @param {EvmSpokeProvider} spokeProvider - The provider for the spoke chain.
18
- * @param {EvmHubProvider} hubProvider - The provider for the hub chain.
19
- * @returns {PromiseEvmTxReturnType<R>} A promise that resolves to the transaction hash.
20
- */
21
- static deposit<R extends boolean = false>(params: EvmSpokeDepositParams, spokeProvider: EvmSpokeProvider, hubProvider: EvmHubProvider, raw?: R): PromiseEvmTxReturnType<R>;
22
- /**
23
- * Get the balance of the token in the spoke chain.
24
- * @param {Address} token - The address of the token to get the balance of.
25
- * @param {EvmSpokeProvider} spokeProvider - The spoke provider.
26
- * @returns {Promise<bigint>} The balance of the token.
27
- */
28
- static getDeposit(token: Address, spokeProvider: EvmSpokeProvider): Promise<bigint>;
29
- /**
30
- * Calls a contract on the spoke chain using the user's wallet.
31
- * @param {HubAddress} from - The address of the user on the hub chain.
32
- * @param {Hex} payload - The payload to send to the contract.
33
- * @param {EvmSpokeProvider} spokeProvider - The provider for the spoke chain.
34
- * @param {EvmHubProvider} hubProvider - The provider for the hub chain.
35
- * @param {boolean} raw - The return type raw or just transaction hash
36
- * @returns {PromiseEvmTxReturnType<R>} A promise that resolves to the transaction hash.
37
- */
38
- static callWallet<R extends boolean = false>(from: HubAddress, payload: Hex, spokeProvider: EvmSpokeProvider, hubProvider: EvmHubProvider, raw?: R): Promise<TxReturnType<EvmSpokeProvider, R>>;
39
- /**
40
- * Transfers tokens to the hub chain.
41
- * @param {EvmTransferToHubParams} params - The parameters for the transfer, including:
42
- * - {Address} token: The address of the token to transfer (use address(0) for native token).
43
- * - {Address} recipient: The recipient address on the hub chain.
44
- * - {bigint} amount: The amount to transfer.
45
- * - {Hex} [data="0x"]: Additional data for the transfer.
46
- * @param {EvmSpokeProvider} spokeProvider - The provider for the spoke chain.
47
- * @param {boolean} raw - The return type raw or just transaction hash
48
- * @returns {PromiseEvmTxReturnType<R>} A promise that resolves to the transaction hash.
49
- */
50
- private static transfer;
51
- /**
52
- * Sends a message to the hub chain.
53
- * @param {bigint} dstChainId - The chain ID of the hub chain.
54
- * @param {Address} dstAddress - The address on the hub chain.
55
- * @param {Hex} payload - The payload to send.
56
- * @param {EvmSpokeProvider} spokeProvider - The provider for the spoke chain.
57
- * @param {boolean} raw - The return type raw or just transaction hash
58
- * @returns {PromiseEvmTxReturnType<R>} A promise that resolves to the transaction hash.
59
- */
60
- private static call;
61
- }
62
- //# sourceMappingURL=EvmSpokeService.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EvmSpokeService.d.ts","sourceRoot":"","sources":["../../../src/services/spoke/EvmSpokeService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAsB,MAAM,MAAM,CAAC;AAExD,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhF,OAAO,KAAK,EAAyC,sBAAsB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAClH,OAAO,KAAK,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAGpD,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,EAAE,OAAO,CAAC;IACd,EAAE,CAAC,EAAE,UAAU,CAAC;IAChB,KAAK,EAAE,GAAG,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,GAAG,CAAC;CACX,CAAC;AAEF,qBAAa,eAAe;IAC1B,OAAO;IAEP;;;;;;OAMG;WACiB,OAAO,CAAC,CAAC,SAAS,OAAO,GAAG,KAAK,EACnD,MAAM,EAAE,qBAAqB,EAC7B,aAAa,EAAE,gBAAgB,EAC/B,WAAW,EAAE,cAAc,EAC3B,GAAG,CAAC,EAAE,CAAC,GACN,sBAAsB,CAAC,CAAC,CAAC;IAqB5B;;;;;OAKG;WACiB,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC;IAShG;;;;;;;;OAQG;WACiB,UAAU,CAAC,CAAC,SAAS,OAAO,GAAG,KAAK,EACtD,IAAI,EAAE,UAAU,EAChB,OAAO,EAAE,GAAG,EACZ,aAAa,EAAE,gBAAgB,EAC/B,WAAW,EAAE,cAAc,EAC3B,GAAG,CAAC,EAAE,CAAC,GACN,OAAO,CAAC,YAAY,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC;IAO7C;;;;;;;;;;OAUG;mBACkB,QAAQ;IAgC7B;;;;;;;;OAQG;mBACkB,IAAI;CAgC1B"}
@@ -1,120 +0,0 @@
1
- import { encodeFunctionData } from 'viem';
2
- import { erc20Abi, spokeAssetManagerAbi } from '../../abis/index.js';
3
- import { connectionAbi, getIntentRelayChainId } from '../../index.js';
4
- import { EvmWalletAbstraction } from '../hub/index.js';
5
- export class EvmSpokeService {
6
- constructor() { }
7
- /**
8
- * Deposit tokens to the spoke chain.
9
- * @param {EvmSpokeDepositParams} params - The parameters for the deposit, including the user's address, token address, amount, and additional data.
10
- * @param {EvmSpokeProvider} spokeProvider - The provider for the spoke chain.
11
- * @param {EvmHubProvider} hubProvider - The provider for the hub chain.
12
- * @returns {PromiseEvmTxReturnType<R>} A promise that resolves to the transaction hash.
13
- */
14
- static async deposit(params, spokeProvider, hubProvider, raw) {
15
- const to = params.to ??
16
- (await EvmWalletAbstraction.getUserHubWalletAddress(spokeProvider.chainConfig.chain.id, params.from, hubProvider));
17
- return EvmSpokeService.transfer({
18
- token: params.token,
19
- recipient: to,
20
- amount: params.amount,
21
- data: params.data,
22
- }, spokeProvider, raw);
23
- }
24
- /**
25
- * Get the balance of the token in the spoke chain.
26
- * @param {Address} token - The address of the token to get the balance of.
27
- * @param {EvmSpokeProvider} spokeProvider - The spoke provider.
28
- * @returns {Promise<bigint>} The balance of the token.
29
- */
30
- static async getDeposit(token, spokeProvider) {
31
- return spokeProvider.publicClient.readContract({
32
- address: token,
33
- abi: erc20Abi,
34
- functionName: 'balanceOf',
35
- args: [token],
36
- });
37
- }
38
- /**
39
- * Calls a contract on the spoke chain using the user's wallet.
40
- * @param {HubAddress} from - The address of the user on the hub chain.
41
- * @param {Hex} payload - The payload to send to the contract.
42
- * @param {EvmSpokeProvider} spokeProvider - The provider for the spoke chain.
43
- * @param {EvmHubProvider} hubProvider - The provider for the hub chain.
44
- * @param {boolean} raw - The return type raw or just transaction hash
45
- * @returns {PromiseEvmTxReturnType<R>} A promise that resolves to the transaction hash.
46
- */
47
- static async callWallet(from, payload, spokeProvider, hubProvider, raw) {
48
- const relayId = getIntentRelayChainId(hubProvider.chainConfig.chain.id);
49
- const result = await EvmSpokeService.call(BigInt(relayId), from, payload, spokeProvider, raw);
50
- return result;
51
- }
52
- /**
53
- * Transfers tokens to the hub chain.
54
- * @param {EvmTransferToHubParams} params - The parameters for the transfer, including:
55
- * - {Address} token: The address of the token to transfer (use address(0) for native token).
56
- * - {Address} recipient: The recipient address on the hub chain.
57
- * - {bigint} amount: The amount to transfer.
58
- * - {Hex} [data="0x"]: Additional data for the transfer.
59
- * @param {EvmSpokeProvider} spokeProvider - The provider for the spoke chain.
60
- * @param {boolean} raw - The return type raw or just transaction hash
61
- * @returns {PromiseEvmTxReturnType<R>} A promise that resolves to the transaction hash.
62
- */
63
- static async transfer({ token, recipient, amount, data = '0x' }, spokeProvider, raw) {
64
- const txPayload = {
65
- address: spokeProvider.chainConfig.addresses.assetManager,
66
- abi: spokeAssetManagerAbi,
67
- functionName: 'transfer',
68
- args: [token, recipient, amount, data],
69
- value: token.toLowerCase() === spokeProvider.chainConfig.nativeToken.toLowerCase() ? amount : undefined,
70
- };
71
- const from = (await spokeProvider.walletProvider.getWalletAddress());
72
- const rawTx = {
73
- from,
74
- to: txPayload.address,
75
- value: txPayload.value ?? 0n,
76
- data: encodeFunctionData({
77
- abi: spokeAssetManagerAbi,
78
- functionName: 'transfer',
79
- args: [token, recipient, amount, data],
80
- }),
81
- };
82
- if (raw) {
83
- return rawTx;
84
- }
85
- return spokeProvider.walletProvider.sendTransaction(rawTx);
86
- }
87
- /**
88
- * Sends a message to the hub chain.
89
- * @param {bigint} dstChainId - The chain ID of the hub chain.
90
- * @param {Address} dstAddress - The address on the hub chain.
91
- * @param {Hex} payload - The payload to send.
92
- * @param {EvmSpokeProvider} spokeProvider - The provider for the spoke chain.
93
- * @param {boolean} raw - The return type raw or just transaction hash
94
- * @returns {PromiseEvmTxReturnType<R>} A promise that resolves to the transaction hash.
95
- */
96
- static async call(dstChainId, dstAddress, payload, spokeProvider, raw) {
97
- const txPayload = {
98
- address: spokeProvider.chainConfig.addresses.connection,
99
- abi: connectionAbi,
100
- functionName: 'sendMessage',
101
- args: [dstChainId, dstAddress, payload],
102
- };
103
- const from = (await spokeProvider.walletProvider.getWalletAddress());
104
- const rawTx = {
105
- from,
106
- to: txPayload.address,
107
- value: 0n,
108
- data: encodeFunctionData({
109
- abi: connectionAbi,
110
- functionName: 'sendMessage',
111
- args: [dstChainId, dstAddress, payload],
112
- }),
113
- };
114
- if (raw) {
115
- return rawTx;
116
- }
117
- return spokeProvider.walletProvider.sendTransaction(rawTx);
118
- }
119
- }
120
- //# sourceMappingURL=EvmSpokeService.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EvmSpokeService.js","sourceRoot":"","sources":["../../../src/services/spoke/EvmSpokeService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,kBAAkB,EAAE,MAAM,MAAM,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAErE,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAGtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAUvD,MAAM,OAAO,eAAe;IAC1B,gBAAuB,CAAC;IAExB;;;;;;OAMG;IACI,MAAM,CAAC,KAAK,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AAU,EAAE,UAAU,EAAE,OAAO,CAAC;SAC/B,CAAC;QAEX,MAAM,IAAI,GAAG,CAAC,MAAM,aAAa,CAAC,cAAc,CAAC,gBAAgB,EAAE,CAAkB,CAAC;QACtF,MAAM,KAAK,GAAG;YACZ,IAAI;YACJ,EAAE,EAAE,SAAS,CAAC,OAAO;YACrB,KAAK,EAAE,EAAE;YACT,IAAI,EAAE,kBAAkB,CAAC;gBACvB,GAAG,EAAE,aAAa;gBAClB,YAAY,EAAE,aAAa;gBAC3B,IAAI,EAAE,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,CAAC;aACxC,CAAC;SAC2B,CAAC;QAEhC,IAAI,GAAG,EAAE,CAAC;YACR,OAAO,KAAyB,CAAC;QACnC,CAAC;QAED,OAAO,aAAa,CAAC,cAAc,CAAC,eAAe,CAAC,KAAK,CAA8B,CAAC;IAC1F,CAAC;CACF"}
@@ -1,56 +0,0 @@
1
- import type { Address, Hex } from 'viem';
2
- import type { IconSpokeProvider } from '../../entities/icon/IconSpokeProvider.js';
3
- import type { EvmHubProvider } from '../../entities/index.js';
4
- import type { IconAddress, PromiseIconTxReturnType } from '../../types.js';
5
- import type { HubAddress } from '@sodax/types';
6
- export type IconSpokeDepositParams = {
7
- from: IconAddress;
8
- to?: HubAddress;
9
- token: string;
10
- amount: bigint;
11
- data: Hex;
12
- };
13
- export type TransferToHubParams = {
14
- token: string;
15
- recipient: Address;
16
- amount: bigint;
17
- data: Hex;
18
- };
19
- export declare class IconSpokeService {
20
- private constructor();
21
- /**
22
- * Deposit tokens to the spoke chain.
23
- * @param {IconSpokeDepositParams} params - The parameters for the deposit
24
- * @param {IconWalletProvider} spokeProvider - The provider for the spoke chain
25
- * @param {EvmHubProvider} hubProvider - The provider for the hub chain
26
- * @param {boolean} raw - The return type raw or just transaction hash
27
- * @returns {Promise<Result<string>>} A promise that resolves to the transaction hash
28
- */
29
- static deposit<R extends boolean = false>(params: IconSpokeDepositParams, spokeProvider: IconSpokeProvider, hubProvider: EvmHubProvider, raw?: R): PromiseIconTxReturnType<R>;
30
- /**
31
- * Get the balance of the token in the spoke chain.
32
- * @param {string} token - The address of the token to get the balance of
33
- * @param {IconWalletProvider} spokeProvider - The spoke provider
34
- * @returns {Promise<bigint>} The balance of the token
35
- */
36
- static getDeposit(token: string, spokeProvider: IconSpokeProvider): Promise<bigint>;
37
- /**
38
- * Calls a contract on the spoke chain using the user's wallet.
39
- * @param {HubAddress} from - The address of the user on the hub chain
40
- * @param {Hex} payload - The payload to send to the contract
41
- * @param {IconWalletProvider} spokeProvider - The provider for the spoke chain
42
- * @param {EvmHubProvider} hubProvider - The provider for the hub chain
43
- * @param {boolean} raw - The return type raw or just transaction hash
44
- * @returns {Promise<Result<string>>} A promise that resolves to the transaction hash
45
- */
46
- static callWallet<R extends boolean = false>(from: HubAddress, payload: Hex, spokeProvider: IconSpokeProvider, hubProvider: EvmHubProvider, raw?: R): PromiseIconTxReturnType<R>;
47
- /**
48
- * Transfers tokens to the hub chain.
49
- */
50
- private static transfer;
51
- /**
52
- * Sends a message to the hub chain.
53
- */
54
- private static call;
55
- }
56
- //# sourceMappingURL=IconSpokeService.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IconSpokeService.d.ts","sourceRoot":"","sources":["../../../src/services/spoke/IconSpokeService.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AACzC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAElF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAE9D,OAAO,KAAK,EAAE,WAAW,EAAkB,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAC3F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG/C,MAAM,MAAM,sBAAsB,GAAG;IACnC,IAAI,EAAE,WAAW,CAAC;IAClB,EAAE,CAAC,EAAE,UAAU,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,GAAG,CAAC;CACX,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,GAAG,CAAC;CACX,CAAC;AAEF,qBAAa,gBAAgB;IAC3B,OAAO;IAEP;;;;;;;OAOG;WACiB,OAAO,CAAC,CAAC,SAAS,OAAO,GAAG,KAAK,EACnD,MAAM,EAAE,sBAAsB,EAC9B,aAAa,EAAE,iBAAiB,EAChC,WAAW,EAAE,cAAc,EAC3B,GAAG,CAAC,EAAE,CAAC,GACN,uBAAuB,CAAC,CAAC,CAAC;IAqB7B;;;;;OAKG;WACiB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC;IAUhG;;;;;;;;OAQG;WACiB,UAAU,CAAC,CAAC,SAAS,OAAO,GAAG,KAAK,EACtD,IAAI,EAAE,UAAU,EAChB,OAAO,EAAE,GAAG,EACZ,aAAa,EAAE,iBAAiB,EAChC,WAAW,EAAE,cAAc,EAC3B,GAAG,CAAC,EAAE,CAAC,GACN,uBAAuB,CAAC,CAAC,CAAC;IAK7B;;OAEG;mBACkB,QAAQ;IA6C7B;;OAEG;mBACkB,IAAI;CAuC1B"}
@@ -1,124 +0,0 @@
1
- import IconService from 'icon-sdk-js';
2
- import * as rlp from 'rlp';
3
- import { getIconAddressBytes } from '../../entities/icon/utils.js';
4
- import { BigIntToHex, getIntentRelayChainId, isNativeToken } from '../../index.js';
5
- import { EvmWalletAbstraction } from '../hub/index.js';
6
- export class IconSpokeService {
7
- constructor() { }
8
- /**
9
- * Deposit tokens to the spoke chain.
10
- * @param {IconSpokeDepositParams} params - The parameters for the deposit
11
- * @param {IconWalletProvider} spokeProvider - The provider for the spoke chain
12
- * @param {EvmHubProvider} hubProvider - The provider for the hub chain
13
- * @param {boolean} raw - The return type raw or just transaction hash
14
- * @returns {Promise<Result<string>>} A promise that resolves to the transaction hash
15
- */
16
- static async deposit(params, spokeProvider, hubProvider, raw) {
17
- const userWallet = params.to ??
18
- (await EvmWalletAbstraction.getUserHubWalletAddress(spokeProvider.chainConfig.chain.id, getIconAddressBytes(params.from), hubProvider));
19
- return IconSpokeService.transfer({
20
- token: params.token,
21
- recipient: userWallet,
22
- amount: params.amount,
23
- data: params.data,
24
- }, spokeProvider, raw);
25
- }
26
- /**
27
- * Get the balance of the token in the spoke chain.
28
- * @param {string} token - The address of the token to get the balance of
29
- * @param {IconWalletProvider} spokeProvider - The spoke provider
30
- * @returns {Promise<bigint>} The balance of the token
31
- */
32
- static async getDeposit(token, spokeProvider) {
33
- const transaction = new IconService.CallBuilder()
34
- .to(token)
35
- .method('balanceOf')
36
- .params({ _owner: spokeProvider.chainConfig.addresses.assetManager })
37
- .build();
38
- const result = await spokeProvider.iconService.call(transaction).execute();
39
- return BigInt(result.value);
40
- }
41
- /**
42
- * Calls a contract on the spoke chain using the user's wallet.
43
- * @param {HubAddress} from - The address of the user on the hub chain
44
- * @param {Hex} payload - The payload to send to the contract
45
- * @param {IconWalletProvider} spokeProvider - The provider for the spoke chain
46
- * @param {EvmHubProvider} hubProvider - The provider for the hub chain
47
- * @param {boolean} raw - The return type raw or just transaction hash
48
- * @returns {Promise<Result<string>>} A promise that resolves to the transaction hash
49
- */
50
- static async callWallet(from, payload, spokeProvider, hubProvider, raw) {
51
- const relayId = getIntentRelayChainId(hubProvider.chainConfig.chain.id);
52
- return IconSpokeService.call(BigInt(relayId), from, payload, spokeProvider, raw);
53
- }
54
- /**
55
- * Transfers tokens to the hub chain.
56
- */
57
- static async transfer({ token, recipient, amount, data }, spokeProvider, raw) {
58
- const rlpInput = [data, recipient];
59
- const rlpEncodedData = rlp.encode(rlpInput);
60
- const hexData = `0x${Buffer.from(rlpEncodedData).toString('hex')}`;
61
- const params = {
62
- _to: spokeProvider.chainConfig.addresses.assetManager,
63
- _value: BigIntToHex(amount),
64
- _data: hexData,
65
- };
66
- const value = isNativeToken(spokeProvider.chainConfig.chain.id, token) ? BigIntToHex(amount) : '0x0';
67
- const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
68
- const rawTransaction = IconService.Converter.toRawTransaction(new IconService.CallTransactionBuilder()
69
- .from(walletAddress)
70
- .to(token)
71
- .stepLimit(IconService.Converter.toBigNumber('2000000'))
72
- .nid(spokeProvider.chainConfig.nid)
73
- .version('0x3')
74
- .timestamp(new Date().getTime() * 1000)
75
- .value(value)
76
- .method('transfer')
77
- .params(params)
78
- .build());
79
- if (raw) {
80
- return rawTransaction;
81
- }
82
- return spokeProvider.walletProvider.sendTransaction({
83
- from: walletAddress,
84
- to: token,
85
- value: value,
86
- nid: spokeProvider.chainConfig.nid,
87
- method: 'transfer',
88
- params: params,
89
- });
90
- }
91
- /**
92
- * Sends a message to the hub chain.
93
- */
94
- static async call(dstChainId, dstAddress, payload, spokeProvider, raw) {
95
- const params = {
96
- dstChainId: dstChainId.toString(),
97
- dstAddress: dstAddress,
98
- payload: payload,
99
- };
100
- const walletAddressBytes = await spokeProvider.walletProvider.getWalletAddressBytes();
101
- const transaction = new IconService.CallTransactionBuilder()
102
- .from(walletAddressBytes)
103
- .to(spokeProvider.chainConfig.addresses.connection)
104
- .stepLimit(IconService.Converter.toBigNumber('2000000'))
105
- .nid(spokeProvider.chainConfig.nid)
106
- .version('0x3')
107
- .timestamp(new Date().getTime() * 1000)
108
- .method('sendMessage')
109
- .params(params)
110
- .build();
111
- if (raw) {
112
- return IconService.Converter.toRawTransaction(transaction);
113
- }
114
- return spokeProvider.walletProvider.sendTransaction({
115
- from: walletAddressBytes,
116
- to: spokeProvider.chainConfig.addresses.connection,
117
- nid: spokeProvider.chainConfig.nid,
118
- value: '0x0',
119
- method: 'sendMessage',
120
- params: params,
121
- });
122
- }
123
- }
124
- //# sourceMappingURL=IconSpokeService.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IconSpokeService.js","sourceRoot":"","sources":["../../../src/services/spoke/IconSpokeService.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAG3B,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAEnE,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAGnF,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAiBvD,MAAM,OAAO,gBAAgB;IAC3B,gBAAuB,CAAC;IAExB;;;;;;;OAOG;IACI,MAAM,CAAC,KAAK,CAAC,OAAO,CACzB,MAA8B,EAC9B,aAAgC,EAChC,WAA2B,EAC3B,GAAO;QAEP,MAAM,UAAU,GACd,MAAM,CAAC,EAAE;YACT,CAAC,MAAM,oBAAoB,CAAC,uBAAuB,CACjD,aAAa,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,EAClC,mBAAmB,CAAC,MAAM,CAAC,IAAI,CAAC,EAChC,WAAW,CACZ,CAAC,CAAC;QAEL,OAAO,gBAAgB,CAAC,QAAQ,CAC9B;YACE,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,SAAS,EAAE,UAAU;YACrB,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,IAAI,EAAE,MAAM,CAAC,IAAI;SAClB,EACD,aAAa,EACb,GAAG,CACJ,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,KAAa,EAAE,aAAgC;QAC5E,MAAM,WAAW,GAAG,IAAI,WAAW,CAAC,WAAW,EAAE;aAC9C,EAAE,CAAC,KAAK,CAAC;aACT,MAAM,CAAC,WAAW,CAAC;aACnB,MAAM,CAAC,EAAE,MAAM,EAAE,aAAa,CAAC,WAAW,CAAC,SAAS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B,EAAE,CAAC;QAEtF,MAAM,WAAW,GAAG,IAAI,WAAW,CAAC,sBAAsB,EAAE;aACzD,IAAI,CAAC,kBAAkB,CAAC;aACxB,EAAE,CAAC,aAAa,CAAC,WAAW,CAAC,SAAS,CAAC,UAAU,CAAC;aAClD,SAAS,CAAC,WAAW,CAAC,SAAS,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;aACvD,GAAG,CAAC,aAAa,CAAC,WAAW,CAAC,GAAG,CAAC;aAClC,OAAO,CAAC,KAAK,CAAC;aACd,SAAS,CAAC,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC;aACtC,MAAM,CAAC,aAAa,CAAC;aACrB,MAAM,CAAC,MAAM,CAAC;aACd,KAAK,EAAE,CAAC;QAEX,IAAI,GAAG,EAAE,CAAC;YACR,OAAO,WAAW,CAAC,SAAS,CAAC,gBAAgB,CAAC,WAAW,CAAsB,CAAC;QAClF,CAAC;QAED,OAAO,aAAa,CAAC,cAAc,CAAC,eAAe,CAAC;YAClD,IAAI,EAAE,kBAAkB;YACxB,EAAE,EAAE,aAAa,CAAC,WAAW,CAAC,SAAS,CAAC,UAAU;YAClD,GAAG,EAAE,aAAa,CAAC,WAAW,CAAC,GAAG;YAClC,KAAK,EAAE,KAAK;YACZ,MAAM,EAAE,aAAa;YACrB,MAAM,EAAE,MAAM;SACf,CAAwE,CAAC;IAC5E,CAAC;CACF"}
@@ -1,46 +0,0 @@
1
- import { PublicKey } from '@solana/web3.js';
2
- import { type Hex } from 'viem';
3
- import type { EvmHubProvider } from '../../entities/index.js';
4
- import type { SolanaSpokeProvider } from '../../entities/solana/SolanaSpokeProvider.js';
5
- import type { PromiseSolanaTxReturnType } from '../../types.js';
6
- import type { HubAddress } from '@sodax/types';
7
- export type SolanaSpokeDepositParams = {
8
- from: PublicKey;
9
- to?: HubAddress;
10
- token: PublicKey;
11
- amount: bigint;
12
- data: Hex;
13
- };
14
- export type TransferToHubParams = {
15
- token: PublicKey;
16
- recipient: string;
17
- amount: string;
18
- data: Hex;
19
- };
20
- export declare class SolanaSpokeService {
21
- private constructor();
22
- static deposit<R extends boolean = false>(params: SolanaSpokeDepositParams, spokeProvider: SolanaSpokeProvider, hubProvider: EvmHubProvider, raw?: R): PromiseSolanaTxReturnType<R>;
23
- static getDeposit(token: string, spokeProvider: SolanaSpokeProvider): Promise<bigint>;
24
- /**
25
- * Calls a contract on the spoke chain using the user's wallet.
26
- * @param from - The address of the user on the hub chain.
27
- * @param payload - The payload to send to the contract.
28
- * @param spokeProvider - The spoke provider.
29
- * @param hubProvider - The hub provider.
30
- * @param raw - Whether to return the raw transaction data.
31
- * @returns The transaction result.
32
- */
33
- static callWallet<R extends boolean = false>(from: HubAddress, payload: Hex, spokeProvider: SolanaSpokeProvider, hubProvider: EvmHubProvider, raw?: R): PromiseSolanaTxReturnType<R>;
34
- private static transfer;
35
- /**
36
- * Sends a message to the hub chain.
37
- * @param dstChainId - The chain ID of the hub chain.
38
- * @param dstAddress - The address on the hub chain.
39
- * @param payload - The payload to send.
40
- * @param spokeProvider - The spoke provider.
41
- * @param raw - Whether to return the raw transaction data.
42
- * @returns The transaction result.
43
- */
44
- private static call;
45
- }
46
- //# sourceMappingURL=SolanaSpokeService.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SolanaSpokeService.d.ts","sourceRoot":"","sources":["../../../src/services/spoke/SolanaSpokeService.ts"],"names":[],"mappings":"AACA,OAAO,EAAwB,SAAS,EAA8C,MAAM,iBAAiB,CAAC;AAC9G,OAAO,EAAgB,KAAK,GAAG,EAAS,MAAM,MAAM,CAAC;AAErD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAE9D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8CAA8C,CAAC;AAGxF,OAAO,KAAK,EAAE,yBAAyB,EAAoB,MAAM,gBAAgB,CAAC;AAClF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAI/C,MAAM,MAAM,wBAAwB,GAAG;IACrC,IAAI,EAAE,SAAS,CAAC;IAChB,EAAE,CAAC,EAAE,UAAU,CAAC;IAChB,KAAK,EAAE,SAAS,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,GAAG,CAAC;CACX,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,KAAK,EAAE,SAAS,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,GAAG,CAAC;CACX,CAAC;AAEF,qBAAa,kBAAkB;IAC7B,OAAO;WAEa,OAAO,CAAC,CAAC,SAAS,OAAO,GAAG,KAAK,EACnD,MAAM,EAAE,wBAAwB,EAChC,aAAa,EAAE,mBAAmB,EAClC,WAAW,EAAE,cAAc,EAC3B,GAAG,CAAC,EAAE,CAAC,GACN,yBAAyB,CAAC,CAAC,CAAC;WAqBX,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC;IAkBlG;;;;;;;;OAQG;WACiB,UAAU,CAAC,CAAC,SAAS,OAAO,GAAG,KAAK,EACtD,IAAI,EAAE,UAAU,EAChB,OAAO,EAAE,GAAG,EACZ,aAAa,EAAE,mBAAmB,EAClC,WAAW,EAAE,cAAc,EAC3B,GAAG,CAAC,EAAE,CAAC,GACN,yBAAyB,CAAC,CAAC,CAAC;mBAKV,QAAQ;IAmG7B;;;;;;;;OAQG;mBACkB,IAAI;CAmD1B"}
@@ -1,156 +0,0 @@
1
- import { TOKEN_PROGRAM_ID } from '@solana/spl-token';
2
- import { ComputeBudgetProgram, PublicKey, SystemProgram } from '@solana/web3.js';
3
- import { toHex } from 'viem';
4
- import { getIntentRelayChainId } from '../../constants.js';
5
- import { getAssetManagerProgram, getConnectionProgram } from '../../entities/solana/Configs.js';
6
- import { AssetManagerPDA, ConnectionConfigPDA } from '../../entities/solana/pda/pda.js';
7
- import { isNative } from '../../entities/solana/utils/utils.js';
8
- import { EvmWalletAbstraction } from '../hub/index.js';
9
- import BN from 'bn.js';
10
- export class SolanaSpokeService {
11
- constructor() { }
12
- static async deposit(params, spokeProvider, hubProvider, raw) {
13
- const userWallet = params.to ??
14
- (await EvmWalletAbstraction.getUserHubWalletAddress(spokeProvider.chainConfig.chain.id, toHex(params.from.toBytes()), hubProvider));
15
- return SolanaSpokeService.transfer({
16
- token: params.token,
17
- recipient: userWallet,
18
- amount: params.amount.toString(),
19
- data: params.data,
20
- }, spokeProvider, raw);
21
- }
22
- static async getDeposit(token, spokeProvider) {
23
- const assetManagerProgram = await getAssetManagerProgram(spokeProvider.walletProvider.getWallet(), spokeProvider.chainConfig.rpcUrl, spokeProvider.chainConfig.wsUrl, spokeProvider.chainConfig.addresses.assetManager);
24
- const solToken = new PublicKey(Buffer.from(token, 'hex'));
25
- if (isNative(new PublicKey(solToken))) {
26
- const vaultNative = AssetManagerPDA.vault_native(assetManagerProgram.programId);
27
- const balance = await spokeProvider.walletProvider.connection.getBalance(vaultNative.pda);
28
- return BigInt(balance);
29
- }
30
- const vaultToken = AssetManagerPDA.vault_token(assetManagerProgram.programId, new PublicKey(solToken));
31
- const tokenAccount = await spokeProvider.walletProvider.connection.getTokenAccountBalance(vaultToken.pda);
32
- return BigInt(tokenAccount.value.amount);
33
- }
34
- /**
35
- * Calls a contract on the spoke chain using the user's wallet.
36
- * @param from - The address of the user on the hub chain.
37
- * @param payload - The payload to send to the contract.
38
- * @param spokeProvider - The spoke provider.
39
- * @param hubProvider - The hub provider.
40
- * @param raw - Whether to return the raw transaction data.
41
- * @returns The transaction result.
42
- */
43
- static async callWallet(from, payload, spokeProvider, hubProvider, raw) {
44
- const relayId = getIntentRelayChainId(hubProvider.chainConfig.chain.id);
45
- return SolanaSpokeService.call(BigInt(relayId), from, payload, spokeProvider, raw);
46
- }
47
- static async transfer({ token, recipient, amount, data }, spokeProvider, raw) {
48
- let depositInstruction;
49
- const amountBN = new BN(amount);
50
- const { walletProvider, chainConfig } = spokeProvider;
51
- const { rpcUrl, wsUrl, addresses } = chainConfig;
52
- const assetManagerProgram = await getAssetManagerProgram(walletProvider.getWallet(), rpcUrl, wsUrl, addresses.assetManager);
53
- const walletPublicKey = walletProvider.getAddress();
54
- const connectionProgram = await getConnectionProgram(walletProvider.getWallet(), rpcUrl, wsUrl, addresses.connection);
55
- if (isNative(token)) {
56
- depositInstruction = await assetManagerProgram.methods.transfer(amountBN, Buffer.from(recipient.slice(2), 'hex'), Buffer.from(data.slice(2), 'hex')).accountsStrict({
57
- signer: walletPublicKey,
58
- systemProgram: SystemProgram.programId,
59
- config: AssetManagerPDA.config(assetManagerProgram.programId).pda,
60
- nativeVaultAccount: AssetManagerPDA.vault_native(assetManagerProgram.programId).pda,
61
- tokenVaultAccount: null,
62
- signerTokenAccount: null,
63
- authority: AssetManagerPDA.authority(assetManagerProgram.programId).pda,
64
- mint: null,
65
- connection: connectionProgram.programId,
66
- tokenProgram: TOKEN_PROGRAM_ID,
67
- }).remainingAccounts([
68
- {
69
- pubkey: ConnectionConfigPDA.config(connectionProgram.programId).pda,
70
- isSigner: false,
71
- isWritable: true,
72
- },
73
- ]).instruction();
74
- }
75
- else {
76
- const signerTokenAccount = await spokeProvider.walletProvider.getAssociatedTokenAddress(token);
77
- depositInstruction = await assetManagerProgram.methods.transfer(amountBN, Buffer.from(recipient.slice(2), 'hex'), Buffer.from(data.slice(2), 'hex')).accountsStrict({
78
- signer: walletPublicKey,
79
- systemProgram: SystemProgram.programId,
80
- config: AssetManagerPDA.config(assetManagerProgram.programId).pda,
81
- nativeVaultAccount: null,
82
- tokenVaultAccount: AssetManagerPDA.vault_token(assetManagerProgram.programId, token).pda,
83
- signerTokenAccount: signerTokenAccount,
84
- authority: AssetManagerPDA.authority(assetManagerProgram.programId).pda,
85
- mint: token,
86
- connection: connectionProgram.programId,
87
- tokenProgram: TOKEN_PROGRAM_ID,
88
- }).remainingAccounts([
89
- {
90
- pubkey: ConnectionConfigPDA.config(connectionProgram.programId).pda,
91
- isSigner: false,
92
- isWritable: true,
93
- },
94
- ]).instruction();
95
- }
96
- const modifyComputeUnits = ComputeBudgetProgram.setComputeUnitLimit({
97
- units: 1_400_000,
98
- });
99
- const addPriorityFee = ComputeBudgetProgram.setComputeUnitPrice({
100
- microLamports: 0,
101
- });
102
- const transaction = await spokeProvider.walletProvider.buildV0Txn([modifyComputeUnits, addPriorityFee, depositInstruction], [spokeProvider.walletProvider.getWallet()]);
103
- if (raw) {
104
- const serializedTxn = transaction.serialize();
105
- const base64Txn = Buffer.from(serializedTxn).toString('base64');
106
- return {
107
- from: spokeProvider.walletProvider.getAddress(),
108
- to: assetManagerProgram.programId,
109
- value: BigInt(amountBN.toString()),
110
- data: base64Txn,
111
- };
112
- }
113
- const tx = spokeProvider.walletProvider.sendTransaction(transaction);
114
- return tx;
115
- }
116
- /**
117
- * Sends a message to the hub chain.
118
- * @param dstChainId - The chain ID of the hub chain.
119
- * @param dstAddress - The address on the hub chain.
120
- * @param payload - The payload to send.
121
- * @param spokeProvider - The spoke provider.
122
- * @param raw - Whether to return the raw transaction data.
123
- * @returns The transaction result.
124
- */
125
- static async call(dstChainId, dstAddress, payload, spokeProvider, raw) {
126
- const { walletProvider, chainConfig } = spokeProvider;
127
- const { rpcUrl, wsUrl, addresses } = chainConfig;
128
- const connectionProgram = await getConnectionProgram(walletProvider.getWallet(), rpcUrl, wsUrl, addresses.connection);
129
- const walletPublicKey = walletProvider.getAddress();
130
- const sendMessageInstruction = await connectionProgram.methods.sendMessage(new BN(dstChainId.toString()), Buffer.from(dstAddress.slice(2), 'hex'), Buffer.from(payload.slice(2), 'hex')).accounts({
131
- signer: walletPublicKey,
132
- dapp: null,
133
- config: ConnectionConfigPDA.config(connectionProgram.programId).pda,
134
- systemProgram: SystemProgram.programId,
135
- }).instruction();
136
- const modifyComputeUnits = ComputeBudgetProgram.setComputeUnitLimit({
137
- units: 1000000,
138
- });
139
- const addPriorityFee = ComputeBudgetProgram.setComputeUnitPrice({
140
- microLamports: 0,
141
- });
142
- const transaction = await spokeProvider.walletProvider.buildV0Txn([modifyComputeUnits, addPriorityFee, sendMessageInstruction], [spokeProvider.walletProvider.getWallet()]);
143
- if (raw) {
144
- const serializedTxn = transaction.serialize();
145
- const base64Txn = Buffer.from(serializedTxn).toString('base64');
146
- return {
147
- from: walletPublicKey,
148
- to: connectionProgram.programId,
149
- value: 0n,
150
- data: base64Txn,
151
- };
152
- }
153
- return spokeProvider.walletProvider.sendTransaction(transaction);
154
- }
155
- }
156
- //# sourceMappingURL=SolanaSpokeService.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SolanaSpokeService.js","sourceRoot":"","sources":["../../../src/services/spoke/SolanaSpokeService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAE,aAAa,EAA+B,MAAM,iBAAiB,CAAC;AAC9G,OAAO,EAA0B,KAAK,EAAE,MAAM,MAAM,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAEhG,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACxF,OAAO,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAGhE,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,MAAM,OAAO,CAAC;AAiBvB,MAAM,OAAO,kBAAkB;IAC7B,gBAAuB,CAAC;IAEjB,MAAM,CAAC,KAAK,CAAC,OAAO,CACzB,MAAgC,EAChC,aAAkC,EAClC,WAA2B,EAC3B,GAAO;QAEP,MAAM,UAAU,GACd,MAAM,CAAC,EAAE;YACT,CAAC,MAAM,oBAAoB,CAAC,uBAAuB,CACjD,aA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BAAmB,CAAC,MAAM,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC,GAAG;YACnE,aAAa,EAAE,aAAa,CAAC,SAAS;SACvC,CAAC,CAAC,WAAW,EAAE,CAAC;QAEjB,MAAM,kBAAkB,GAAG,oBAAoB,CAAC,mBAAmB,CAAC;YAClE,KAAK,EAAE,OAAO;SACf,CAAC,CAAC;QAEH,MAAM,cAAc,GAAG,oBAAoB,CAAC,mBAAmB,CAAC;YAC9D,aAAa,EAAE,CAAC;SACjB,CAAC,CAAC;QAEH,MAAM,WAAW,GAAG,MAAM,aAAa,CAAC,cAAc,CAAC,UAAU,CAC/D,CAAC,kBAAkB,EAAE,cAAc,EAAE,sBAAsB,CAAC,EAC5D,CAAC,aAAa,CAAC,cAAc,CAAC,SAAS,EAAE,CAAC,CAC3C,CAAC;QACF,IAAI,GAAG,EAAE,CAAC;YACR,MAAM,aAAa,GAAG,WAAW,CAAC,SAAS,EAAE,CAAC;YAC9C,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;YAChE,OAAO;gBACL,IAAI,EAAE,eAAe;gBACrB,EAAE,EAAE,iBAAiB,CAAC,SAAS;gBAC/B,KAAK,EAAE,EAAE;gBACT,IAAI,EAAE,SAAS;aACO,CAAC;QAC3B,CAAC;QACD,OAAO,aAAa,CAAC,cAAc,CAAC,eAAe,CAAC,WAAW,CAAiC,CAAC;IACnG,CAAC;CACF"}
@@ -1,34 +0,0 @@
1
- import { type EvmHubProvider, type SpokeProvider } from '../../entities/index.js';
2
- import type { GetSpokeDepositParamsType, PromiseTxReturnType, TxReturnType } from '../../types.js';
3
- import type { Address, Hex, HubAddress } from '@sodax/types';
4
- /**
5
- * SpokeService is a main class that provides functionalities for dealing with spoke chains.
6
- * It uses command pattern to execute different spoke chain operations.
7
- */
8
- export declare class SpokeService {
9
- /**
10
- * Deposit tokens to the spoke chain.
11
- * @param {GetSpokeDepositParamsType<T extends SpokeProvider>} params - The parameters for the deposit, including the user's address, token address, amount, and additional data.
12
- * @param {SpokeProvider} spokeProvider - The provider for the spoke chain.
13
- * @param {EvmHubProvider} hubProvider - The provider for the hub chain.
14
- * @returns {Promise<Hash>} A promise that resolves to the transaction hash.
15
- */
16
- static deposit<T extends SpokeProvider = SpokeProvider, R extends boolean = false>(params: GetSpokeDepositParamsType<T>, spokeProvider: T, hubProvider: EvmHubProvider, raw?: R): Promise<PromiseTxReturnType<T, R>>;
17
- /**
18
- * Get the balance of the token in the spoke chain.
19
- * @param {Address} token - The address of the token to get the balance of.
20
- * @param {SpokeProvider} spokeProvider - The spoke provider.
21
- * @returns {Promise<bigint>} The balance of the token.
22
- */
23
- static getDeposit(token: Address, spokeProvider: SpokeProvider): Promise<bigint>;
24
- /**
25
- * Calls a contract on the spoke chain using the user's wallet.
26
- * @param {HubAddress} from - The address of the user on the hub chain.
27
- * @param {Hex} payload - The payload to send to the contract.
28
- * @param {SpokeProvider} spokeProvider - The provider for the spoke chain.
29
- * @param {EvmHubProvider} hubProvider - The provider for the hub chain.
30
- * @returns {Promise<Hash>} A promise that resolves to the transaction hash.
31
- */
32
- static callWallet<T extends SpokeProvider = SpokeProvider, R extends boolean = false>(from: HubAddress, payload: Hex, spokeProvider: T, hubProvider: EvmHubProvider, raw?: R): Promise<TxReturnType<T, R>>;
33
- }
34
- //# sourceMappingURL=SpokeService.d.ts.map