@sodax/sdk 0.0.1-rc.2 → 0.0.1-rc.20

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 (315) hide show
  1. package/README.md +166 -11
  2. package/dist/index.cjs +14914 -0
  3. package/dist/index.cjs.map +1 -0
  4. package/dist/index.d.cts +9031 -0
  5. package/dist/index.d.ts +9031 -10
  6. package/dist/index.mjs +14717 -0
  7. package/dist/index.mjs.map +1 -0
  8. package/package.json +31 -32
  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 -565
  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 -128
  56. package/dist/constants.test.js.map +0 -1
  57. package/dist/entities/Providers.d.ts +0 -61
  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 -376
  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 -91
  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 -8
  90. package/dist/entities/icon/IconSpokeProvider.d.ts.map +0 -1
  91. package/dist/entities/icon/IconSpokeProvider.js +0 -9
  92. package/dist/entities/icon/IconSpokeProvider.js.map +0 -1
  93. package/dist/entities/icon/IconWalletProvider.d.ts +0 -12
  94. package/dist/entities/icon/IconWalletProvider.d.ts.map +0 -1
  95. package/dist/entities/icon/IconWalletProvider.js +0 -34
  96. package/dist/entities/icon/IconWalletProvider.js.map +0 -1
  97. package/dist/entities/icon/index.d.ts +0 -5
  98. package/dist/entities/icon/index.d.ts.map +0 -1
  99. package/dist/entities/icon/index.js +0 -5
  100. package/dist/entities/icon/index.js.map +0 -1
  101. package/dist/entities/icon/utils.d.ts +0 -3
  102. package/dist/entities/icon/utils.d.ts.map +0 -1
  103. package/dist/entities/icon/utils.js +0 -4
  104. package/dist/entities/icon/utils.js.map +0 -1
  105. package/dist/entities/index.d.ts +0 -8
  106. package/dist/entities/index.d.ts.map +0 -1
  107. package/dist/entities/index.js +0 -8
  108. package/dist/entities/index.js.map +0 -1
  109. package/dist/entities/solana/Configs.d.ts +0 -10
  110. package/dist/entities/solana/Configs.d.ts.map +0 -1
  111. package/dist/entities/solana/Configs.js +0 -50
  112. package/dist/entities/solana/Configs.js.map +0 -1
  113. package/dist/entities/solana/SolanaSpokeProvider.d.ts +0 -9
  114. package/dist/entities/solana/SolanaSpokeProvider.d.ts.map +0 -1
  115. package/dist/entities/solana/SolanaSpokeProvider.js +0 -9
  116. package/dist/entities/solana/SolanaSpokeProvider.js.map +0 -1
  117. package/dist/entities/solana/SolanaWalletProvider.d.ts +0 -20
  118. package/dist/entities/solana/SolanaWalletProvider.d.ts.map +0 -1
  119. package/dist/entities/solana/SolanaWalletProvider.js +0 -53
  120. package/dist/entities/solana/SolanaWalletProvider.js.map +0 -1
  121. package/dist/entities/solana/index.d.ts +0 -4
  122. package/dist/entities/solana/index.d.ts.map +0 -1
  123. package/dist/entities/solana/index.js +0 -4
  124. package/dist/entities/solana/index.js.map +0 -1
  125. package/dist/entities/solana/pda/pda.d.ts +0 -45
  126. package/dist/entities/solana/pda/pda.d.ts.map +0 -1
  127. package/dist/entities/solana/pda/pda.js +0 -44
  128. package/dist/entities/solana/pda/pda.js.map +0 -1
  129. package/dist/entities/solana/types/asset_manager.d.ts +0 -919
  130. package/dist/entities/solana/types/asset_manager.d.ts.map +0 -1
  131. package/dist/entities/solana/types/asset_manager.js +0 -2
  132. package/dist/entities/solana/types/asset_manager.js.map +0 -1
  133. package/dist/entities/solana/types/connection.d.ts +0 -446
  134. package/dist/entities/solana/types/connection.d.ts.map +0 -1
  135. package/dist/entities/solana/types/connection.js +0 -2
  136. package/dist/entities/solana/types/connection.js.map +0 -1
  137. package/dist/entities/solana/types/rate_limit_contract.d.ts +0 -348
  138. package/dist/entities/solana/types/rate_limit_contract.d.ts.map +0 -1
  139. package/dist/entities/solana/types/rate_limit_contract.js +0 -2
  140. package/dist/entities/solana/types/rate_limit_contract.js.map +0 -1
  141. package/dist/entities/solana/utils/utils.d.ts +0 -6
  142. package/dist/entities/solana/utils/utils.d.ts.map +0 -1
  143. package/dist/entities/solana/utils/utils.js +0 -17
  144. package/dist/entities/solana/utils/utils.js.map +0 -1
  145. package/dist/entities/stellar/StellarSpokeProvider.d.ts +0 -24
  146. package/dist/entities/stellar/StellarSpokeProvider.d.ts.map +0 -1
  147. package/dist/entities/stellar/StellarSpokeProvider.js +0 -129
  148. package/dist/entities/stellar/StellarSpokeProvider.js.map +0 -1
  149. package/dist/entities/sui/SuiSpokeProvider.d.ts +0 -34
  150. package/dist/entities/sui/SuiSpokeProvider.d.ts.map +0 -1
  151. package/dist/entities/sui/SuiSpokeProvider.js +0 -143
  152. package/dist/entities/sui/SuiSpokeProvider.js.map +0 -1
  153. package/dist/entities/sui/SuiWalletProvider.d.ts +0 -15
  154. package/dist/entities/sui/SuiWalletProvider.d.ts.map +0 -1
  155. package/dist/entities/sui/SuiWalletProvider.js +0 -43
  156. package/dist/entities/sui/SuiWalletProvider.js.map +0 -1
  157. package/dist/errors.d.ts +0 -2
  158. package/dist/errors.d.ts.map +0 -1
  159. package/dist/errors.js +0 -2
  160. package/dist/errors.js.map +0 -1
  161. package/dist/guards.d.ts +0 -25
  162. package/dist/guards.d.ts.map +0 -1
  163. package/dist/guards.js +0 -110
  164. package/dist/guards.js.map +0 -1
  165. package/dist/index.d.ts.map +0 -1
  166. package/dist/index.js +0 -10
  167. package/dist/index.js.map +0 -1
  168. package/dist/interfaces.d.ts +0 -8
  169. package/dist/interfaces.d.ts.map +0 -1
  170. package/dist/interfaces.js +0 -2
  171. package/dist/interfaces.js.map +0 -1
  172. package/dist/services/hub/EvmAssetManagerService.d.ts +0 -60
  173. package/dist/services/hub/EvmAssetManagerService.d.ts.map +0 -1
  174. package/dist/services/hub/EvmAssetManagerService.js +0 -103
  175. package/dist/services/hub/EvmAssetManagerService.js.map +0 -1
  176. package/dist/services/hub/EvmVaultTokenService.d.ts +0 -81
  177. package/dist/services/hub/EvmVaultTokenService.d.ts.map +0 -1
  178. package/dist/services/hub/EvmVaultTokenService.js +0 -159
  179. package/dist/services/hub/EvmVaultTokenService.js.map +0 -1
  180. package/dist/services/hub/EvmWalletAbstraction.d.ts +0 -8
  181. package/dist/services/hub/EvmWalletAbstraction.d.ts.map +0 -1
  182. package/dist/services/hub/EvmWalletAbstraction.js +0 -14
  183. package/dist/services/hub/EvmWalletAbstraction.js.map +0 -1
  184. package/dist/services/hub/index.d.ts +0 -4
  185. package/dist/services/hub/index.d.ts.map +0 -1
  186. package/dist/services/hub/index.js +0 -4
  187. package/dist/services/hub/index.js.map +0 -1
  188. package/dist/services/index.d.ts +0 -7
  189. package/dist/services/index.d.ts.map +0 -1
  190. package/dist/services/index.js +0 -7
  191. package/dist/services/index.js.map +0 -1
  192. package/dist/services/intentRelay/IntentRelayApiService.d.ts +0 -111
  193. package/dist/services/intentRelay/IntentRelayApiService.d.ts.map +0 -1
  194. package/dist/services/intentRelay/IntentRelayApiService.js +0 -160
  195. package/dist/services/intentRelay/IntentRelayApiService.js.map +0 -1
  196. package/dist/services/intentRelay/IntentRelayApiService.test.d.ts +0 -2
  197. package/dist/services/intentRelay/IntentRelayApiService.test.d.ts.map +0 -1
  198. package/dist/services/intentRelay/IntentRelayApiService.test.js +0 -134
  199. package/dist/services/intentRelay/IntentRelayApiService.test.js.map +0 -1
  200. package/dist/services/intentRelay/index.d.ts +0 -2
  201. package/dist/services/intentRelay/index.d.ts.map +0 -1
  202. package/dist/services/intentRelay/index.js +0 -2
  203. package/dist/services/intentRelay/index.js.map +0 -1
  204. package/dist/services/moneyMarket/MoneyMarketService.d.ts +0 -321
  205. package/dist/services/moneyMarket/MoneyMarketService.d.ts.map +0 -1
  206. package/dist/services/moneyMarket/MoneyMarketService.js +0 -604
  207. package/dist/services/moneyMarket/MoneyMarketService.js.map +0 -1
  208. package/dist/services/moneyMarket/MoneyMarketService.test.d.ts +0 -2
  209. package/dist/services/moneyMarket/MoneyMarketService.test.d.ts.map +0 -1
  210. package/dist/services/moneyMarket/MoneyMarketService.test.js +0 -245
  211. package/dist/services/moneyMarket/MoneyMarketService.test.js.map +0 -1
  212. package/dist/services/moneyMarket/index.d.ts +0 -2
  213. package/dist/services/moneyMarket/index.d.ts.map +0 -1
  214. package/dist/services/moneyMarket/index.js +0 -2
  215. package/dist/services/moneyMarket/index.js.map +0 -1
  216. package/dist/services/shared/Erc20Service.d.ts +0 -41
  217. package/dist/services/shared/Erc20Service.d.ts.map +0 -1
  218. package/dist/services/shared/Erc20Service.js +0 -107
  219. package/dist/services/shared/Erc20Service.js.map +0 -1
  220. package/dist/services/shared/index.d.ts +0 -2
  221. package/dist/services/shared/index.d.ts.map +0 -1
  222. package/dist/services/shared/index.js +0 -2
  223. package/dist/services/shared/index.js.map +0 -1
  224. package/dist/services/solver/EvmSolverService.d.ts +0 -125
  225. package/dist/services/solver/EvmSolverService.d.ts.map +0 -1
  226. package/dist/services/solver/EvmSolverService.js +0 -166
  227. package/dist/services/solver/EvmSolverService.js.map +0 -1
  228. package/dist/services/solver/SolverApiService.d.ts +0 -40
  229. package/dist/services/solver/SolverApiService.d.ts.map +0 -1
  230. package/dist/services/solver/SolverApiService.js +0 -157
  231. package/dist/services/solver/SolverApiService.js.map +0 -1
  232. package/dist/services/solver/SolverApiService.test.d.ts +0 -2
  233. package/dist/services/solver/SolverApiService.test.d.ts.map +0 -1
  234. package/dist/services/solver/SolverApiService.test.js +0 -180
  235. package/dist/services/solver/SolverApiService.test.js.map +0 -1
  236. package/dist/services/solver/SolverService.d.ts +0 -194
  237. package/dist/services/solver/SolverService.d.ts.map +0 -1
  238. package/dist/services/solver/SolverService.js +0 -324
  239. package/dist/services/solver/SolverService.js.map +0 -1
  240. package/dist/services/solver/SolverService.test.d.ts +0 -2
  241. package/dist/services/solver/SolverService.test.d.ts.map +0 -1
  242. package/dist/services/solver/SolverService.test.js +0 -493
  243. package/dist/services/solver/SolverService.test.js.map +0 -1
  244. package/dist/services/solver/index.d.ts +0 -3
  245. package/dist/services/solver/index.d.ts.map +0 -1
  246. package/dist/services/solver/index.js +0 -3
  247. package/dist/services/solver/index.js.map +0 -1
  248. package/dist/services/spoke/CWSpokeService.d.ts +0 -67
  249. package/dist/services/spoke/CWSpokeService.d.ts.map +0 -1
  250. package/dist/services/spoke/CWSpokeService.js +0 -75
  251. package/dist/services/spoke/CWSpokeService.js.map +0 -1
  252. package/dist/services/spoke/EvmSpokeService.d.ts +0 -61
  253. package/dist/services/spoke/EvmSpokeService.d.ts.map +0 -1
  254. package/dist/services/spoke/EvmSpokeService.js +0 -118
  255. package/dist/services/spoke/EvmSpokeService.js.map +0 -1
  256. package/dist/services/spoke/IconSpokeService.d.ts +0 -55
  257. package/dist/services/spoke/IconSpokeService.d.ts.map +0 -1
  258. package/dist/services/spoke/IconSpokeService.js +0 -111
  259. package/dist/services/spoke/IconSpokeService.js.map +0 -1
  260. package/dist/services/spoke/SolanaSpokeService.d.ts +0 -45
  261. package/dist/services/spoke/SolanaSpokeService.d.ts.map +0 -1
  262. package/dist/services/spoke/SolanaSpokeService.js +0 -170
  263. package/dist/services/spoke/SolanaSpokeService.js.map +0 -1
  264. package/dist/services/spoke/SpokeService.d.ts +0 -33
  265. package/dist/services/spoke/SpokeService.d.ts.map +0 -1
  266. package/dist/services/spoke/SpokeService.js +0 -102
  267. package/dist/services/spoke/SpokeService.js.map +0 -1
  268. package/dist/services/spoke/StellarSpokeService.d.ts +0 -35
  269. package/dist/services/spoke/StellarSpokeService.d.ts.map +0 -1
  270. package/dist/services/spoke/StellarSpokeService.js +0 -39
  271. package/dist/services/spoke/StellarSpokeService.js.map +0 -1
  272. package/dist/services/spoke/SuiSpokeService.d.ts +0 -69
  273. package/dist/services/spoke/SuiSpokeService.d.ts.map +0 -1
  274. package/dist/services/spoke/SuiSpokeService.js +0 -74
  275. package/dist/services/spoke/SuiSpokeService.js.map +0 -1
  276. package/dist/services/spoke/index.d.ts +0 -3
  277. package/dist/services/spoke/index.d.ts.map +0 -1
  278. package/dist/services/spoke/index.js +0 -3
  279. package/dist/services/spoke/index.js.map +0 -1
  280. package/dist/tests/services/hub/EvmAssetManagerService.test.d.ts +0 -2
  281. package/dist/tests/services/hub/EvmAssetManagerService.test.d.ts.map +0 -1
  282. package/dist/tests/services/hub/EvmAssetManagerService.test.js +0 -123
  283. package/dist/tests/services/hub/EvmAssetManagerService.test.js.map +0 -1
  284. package/dist/tests/services/hub/EvmMoneyMarketService.test.d.ts +0 -2
  285. package/dist/tests/services/hub/EvmMoneyMarketService.test.d.ts.map +0 -1
  286. package/dist/tests/services/hub/EvmMoneyMarketService.test.js +0 -121
  287. package/dist/tests/services/hub/EvmMoneyMarketService.test.js.map +0 -1
  288. package/dist/tests/services/hub/EvmVaultTokenService.test.d.ts +0 -2
  289. package/dist/tests/services/hub/EvmVaultTokenService.test.d.ts.map +0 -1
  290. package/dist/tests/services/hub/EvmVaultTokenService.test.js +0 -98
  291. package/dist/tests/services/hub/EvmVaultTokenService.test.js.map +0 -1
  292. package/dist/tests/services/spoke/EvmSpokeService.test.d.ts +0 -2
  293. package/dist/tests/services/spoke/EvmSpokeService.test.d.ts.map +0 -1
  294. package/dist/tests/services/spoke/EvmSpokeService.test.js +0 -197
  295. package/dist/tests/services/spoke/EvmSpokeService.test.js.map +0 -1
  296. package/dist/types.d.ts +0 -395
  297. package/dist/types.d.ts.map +0 -1
  298. package/dist/types.js +0 -30
  299. package/dist/types.js.map +0 -1
  300. package/dist/utils/evm-utils.d.ts +0 -10
  301. package/dist/utils/evm-utils.d.ts.map +0 -1
  302. package/dist/utils/evm-utils.js +0 -15
  303. package/dist/utils/evm-utils.js.map +0 -1
  304. package/dist/utils/index.d.ts +0 -3
  305. package/dist/utils/index.d.ts.map +0 -1
  306. package/dist/utils/index.js +0 -3
  307. package/dist/utils/index.js.map +0 -1
  308. package/dist/utils/shared-utils.d.ts +0 -19
  309. package/dist/utils/shared-utils.d.ts.map +0 -1
  310. package/dist/utils/shared-utils.js +0 -66
  311. package/dist/utils/shared-utils.js.map +0 -1
  312. package/dist/utils/shared-utils.test.d.ts +0 -2
  313. package/dist/utils/shared-utils.test.d.ts.map +0 -1
  314. package/dist/utils/shared-utils.test.js +0 -63
  315. package/dist/utils/shared-utils.test.js.map +0 -1
@@ -1,75 +0,0 @@
1
- import { toHex } from 'viem';
2
- import { CWSpokeProvider } from '../../entities/cosmos/CWSpokeProvider.js';
3
- import { getIntentRelayChainId } from '../../index.js';
4
- import { EvmWalletAbstraction } from '../hub/index.js';
5
- export class CWSpokeService {
6
- constructor() { }
7
- /**
8
- * Deposit tokens to the spoke chain.
9
- * @param {CWSpokeDepositParams} params - The parameters for the deposit, including the user's address, token address, amount, and additional data.
10
- * @param {CWSpokeProvider} spokeProvider - The provider for the spoke chain.
11
- * @param {EvmHubProvider} hubProvider - The provider for the hub chain.
12
- * @param {boolean} raw - The return type raw or just transaction hash
13
- * @returns {PromiseCWTxReturnType<R>} A promise that resolves to the transaction hash.
14
- */
15
- static async deposit(params, spokeProvider, hubProvider, raw) {
16
- const userWallet = params.to ??
17
- (await EvmWalletAbstraction.getUserHubWalletAddress(spokeProvider.chainConfig.chain.id, toHex(Buffer.from(params.from, 'utf-8')), hubProvider));
18
- return CWSpokeService.transfer({
19
- token: params.token,
20
- recipient: userWallet,
21
- amount: params.amount.toString(),
22
- data: params.data,
23
- }, spokeProvider, raw);
24
- }
25
- /**
26
- * Get the balance of the token in the spoke chain.
27
- * @param {Address} token - The address of the token to get the balance of.
28
- * @param {CWSpokeProvider} spokeProvider - The spoke provider.
29
- * @returns {Promise<bigint>} The balance of the token.
30
- */
31
- static async getDeposit(token, spokeProvider) {
32
- const bal = await spokeProvider.getBalance(token);
33
- return BigInt(bal);
34
- }
35
- /**
36
- * Calls a contract on the spoke chain using the user's wallet.
37
- * @param {HubAddress} from - The address of the user on the hub chain.
38
- * @param {Hex} payload - The payload to send to the contract.
39
- * @param {CWSpokeProvider} spokeProvider - The provider for the spoke chain.
40
- * @param {EvmHubProvider} hubProvider - The provider for the hub chain.
41
- * @returns {PromiseCWTxReturnType<R>} A promise that resolves to the transaction hash.
42
- */
43
- static async callWallet(from, payload, spokeProvider, hubProvider, raw) {
44
- const relayId = getIntentRelayChainId(hubProvider.chainConfig.chain.id);
45
- return CWSpokeService.call(BigInt(relayId), from, payload, spokeProvider, raw);
46
- }
47
- /**
48
- * Transfers tokens to the hub chain.
49
- * @param {TransferToHubParams} params - The parameters for the transfer, including:
50
- * - {string} token: The address of the token to transfer (use address(0) for native token).
51
- * - {Uint8Array} recipient: The recipient address on the hub chain.
52
- * - {string} amount: The amount to transfer.
53
- * - {Uint8Array} [data=new Uint8Array([])]: Additional data for the transfer.
54
- * @param {CWSpokeProvider} spokeProvider - The provider for the spoke chain.
55
- * @param {boolean} raw - The return type raw or just transaction hash
56
- * @returns {PromiseCWTxReturnType<R>} A promise that resolves to the transaction hash.
57
- */
58
- static async transfer({ token, recipient, amount, data = '0x' }, spokeProvider, raw) {
59
- const sender = spokeProvider.walletProvider.getWalletAddress();
60
- return CWSpokeProvider.deposit(sender, token, recipient, amount, data, spokeProvider, raw);
61
- }
62
- /**
63
- * Sends a message to the hub chain.
64
- * @param {bigint} dstChainId - The chain ID of the hub chain.
65
- * @param {Address} dstAddress - The address on the hub chain.
66
- * @param {Hex} payload - The payload to send.
67
- * @param {CWSpokeProvider} spokeProvider - The provider for the spoke chain.
68
- * @returns {PromiseCWTxReturnType<R>} A promise that resolves to the transaction hash.
69
- */
70
- static async call(dstChainId, dstAddress, payload, spokeProvider, raw) {
71
- const sender = spokeProvider.walletProvider.getWalletAddress();
72
- return spokeProvider.send_message(sender, dstChainId.toString(), dstAddress, payload, raw);
73
- }
74
- }
75
- //# sourceMappingURL=CWSpokeService.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CWSpokeService.js","sourceRoot":"","sources":["../../../src/services/spoke/CWSpokeService.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,KAAK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C,CAAC;QACxE,OAAO,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,aAAa,EAAE,GAAG,CAAC,CAAC;IACjF,CAAC;IAED;;;;;;;;;;OAUG;IACK,MAAM,CAAC,KAAK,CAAC,QAAQ,CAC3B,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,GAAG,IAAI,EAAuB,EAC9D,aAA8B,EAC9B,GAAO;QAEP,MAAM,MAAM,GAAG,aAAa,CAAC,cAAc,CAAC,gBAAgB,EAAE,CAAC;QAC/D,OAAO,eAAe,CAAC,OAAO,CAAC,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,GAAG,CAAC,CAAC;IAC7F,CAAC;IAED;;;;;;;OAOG;IACK,MAAM,CAAC,KAAK,CAAC,IAAI,CACvB,UAAkB,EAClB,UAAe,EACf,OAAY,EACZ,aAA8B,EAC9B,GAAO;QAEP,MAAM,MAAM,GAAG,aAAa,CAAC,cAAc,CAAC,gBAAgB,EAAE,CAAC;QAC/D,OAAO,aAAa,CAAC,YAAY,CAAC,MAAM,EAAE,UAAU,CAAC,QAAQ,EAAE,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;IAC7F,CAAC;CACF"}
@@ -1,61 +0,0 @@
1
- import { type Address } from 'viem';
2
- import type { EvmHubProvider, EvmSpokeProvider } from '../../entities/index.js';
3
- import type { Hex, HubAddress, PromiseEvmTxReturnType, TxReturnType } from '../../types.js';
4
- export type EvmSpokeDepositParams = {
5
- from: Address;
6
- to?: Hex;
7
- token: Hex;
8
- amount: bigint;
9
- data: Hex;
10
- };
11
- export declare class EvmSpokeService {
12
- private constructor();
13
- /**
14
- * Deposit tokens to the spoke chain.
15
- * @param {EvmSpokeDepositParams} params - The parameters for the deposit, including the user's address, token address, amount, and additional data.
16
- * @param {EvmSpokeProvider} spokeProvider - The provider for the spoke chain.
17
- * @param {EvmHubProvider} hubProvider - The provider for the hub chain.
18
- * @returns {PromiseEvmTxReturnType<R>} A promise that resolves to the transaction hash.
19
- */
20
- static deposit<R extends boolean = false>(params: EvmSpokeDepositParams, spokeProvider: EvmSpokeProvider, hubProvider: EvmHubProvider, raw?: R): PromiseEvmTxReturnType<R>;
21
- /**
22
- * Get the balance of the token in the spoke chain.
23
- * @param {Address} token - The address of the token to get the balance of.
24
- * @param {EvmSpokeProvider} spokeProvider - The spoke provider.
25
- * @returns {Promise<bigint>} The balance of the token.
26
- */
27
- static getDeposit(token: Address, spokeProvider: EvmSpokeProvider): Promise<bigint>;
28
- /**
29
- * Calls a contract on the spoke chain using the user's wallet.
30
- * @param {HubAddress} from - The address of the user on the hub chain.
31
- * @param {Hex} payload - The payload to send to the contract.
32
- * @param {EvmSpokeProvider} spokeProvider - The provider for the spoke chain.
33
- * @param {EvmHubProvider} hubProvider - The provider for the hub chain.
34
- * @param {boolean} raw - The return type raw or just transaction hash
35
- * @returns {PromiseEvmTxReturnType<R>} A promise that resolves to the transaction hash.
36
- */
37
- static callWallet<R extends boolean = false>(from: HubAddress, payload: Hex, spokeProvider: EvmSpokeProvider, hubProvider: EvmHubProvider, raw?: R): Promise<TxReturnType<EvmSpokeProvider, R>>;
38
- /**
39
- * Transfers tokens to the hub chain.
40
- * @param {EvmTransferToHubParams} params - The parameters for the transfer, including:
41
- * - {Address} token: The address of the token to transfer (use address(0) for native token).
42
- * - {Address} recipient: The recipient address on the hub chain.
43
- * - {bigint} amount: The amount to transfer.
44
- * - {Hex} [data="0x"]: Additional data for the transfer.
45
- * @param {EvmSpokeProvider} spokeProvider - The provider for the spoke chain.
46
- * @param {boolean} raw - The return type raw or just transaction hash
47
- * @returns {PromiseEvmTxReturnType<R>} A promise that resolves to the transaction hash.
48
- */
49
- private static transfer;
50
- /**
51
- * Sends a message to the hub chain.
52
- * @param {bigint} dstChainId - The chain ID of the hub chain.
53
- * @param {Address} dstAddress - The address on the hub chain.
54
- * @param {Hex} payload - The payload to send.
55
- * @param {EvmSpokeProvider} spokeProvider - The provider for the spoke chain.
56
- * @param {boolean} raw - The return type raw or just transaction hash
57
- * @returns {PromiseEvmTxReturnType<R>} A promise that resolves to the transaction hash.
58
- */
59
- private static call;
60
- }
61
- //# 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,EAGV,GAAG,EACH,UAAU,EACV,sBAAsB,EACtB,YAAY,EACb,MAAM,gBAAgB,CAAC;AAGxB,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,EAAE,OAAO,CAAC;IACd,EAAE,CAAC,EAAE,GAAG,CAAC;IACT,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;IAiC7B;;;;;;;;OAQG;mBACkB,IAAI;CAiC1B"}
@@ -1,118 +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 rawTx = {
72
- from: spokeProvider.walletProvider.getWalletAddress(),
73
- to: txPayload.address,
74
- value: txPayload.value ?? 0n,
75
- data: encodeFunctionData({
76
- abi: spokeAssetManagerAbi,
77
- functionName: 'transfer',
78
- args: [token, recipient, amount, data],
79
- }),
80
- };
81
- if (raw) {
82
- return rawTx;
83
- }
84
- return spokeProvider.walletProvider.sendTransaction(rawTx);
85
- }
86
- /**
87
- * Sends a message to the hub chain.
88
- * @param {bigint} dstChainId - The chain ID of the hub chain.
89
- * @param {Address} dstAddress - The address on the hub chain.
90
- * @param {Hex} payload - The payload to send.
91
- * @param {EvmSpokeProvider} spokeProvider - The provider for the spoke chain.
92
- * @param {boolean} raw - The return type raw or just transaction hash
93
- * @returns {PromiseEvmTxReturnType<R>} A promise that resolves to the transaction hash.
94
- */
95
- static async call(dstChainId, dstAddress, payload, spokeProvider, raw) {
96
- const txPayload = {
97
- address: spokeProvider.chainConfig.addresses.connection,
98
- abi: connectionAbi,
99
- functionName: 'sendMessage',
100
- args: [dstChainId, dstAddress, payload],
101
- };
102
- const rawTx = {
103
- from: spokeProvider.walletProvider.getWalletAddress(),
104
- to: txPayload.address,
105
- value: 0n,
106
- data: encodeFunctionData({
107
- abi: connectionAbi,
108
- functionName: 'sendMessage',
109
- args: [dstChainId, dstAddress, payload],
110
- }),
111
- };
112
- if (raw) {
113
- return rawTx;
114
- }
115
- return spokeProvider.walletProvider.sendTransaction(rawTx);
116
- }
117
- }
118
- //# 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;AAStE,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAUvD,MAAM,OAAO,eAAe;IAC1B,gBAAuB,CAAC;IAExB;;;;;;OAMG;IACI,MAAM,CAAC,KAAK,CAAC,OAAO,CACzB,MAA6B,EAC7B,aAA+B,EAC/B,WAA2B,EAC3B,GAAO;QAEP,MAAM,EAAE,GACN,MAAM,CAAC,EAAE;YACT,CAAC,MAAM,oBAAoB,CAAC,uBAAuB,CACjD,aAAa,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,EAClC,MAAM,CAAC,IAAI,EACX,WAAW,CACZ,CAAC,CAAC;QAEL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AAU,EAAE,UAAU,EAAE,OAAO,CAAC;aACxC,CAAC;SAC4C,CAAC;QAEjD,IAAI,GAAG,EAAE,CAAC;YACR,OAAO,KAA0C,CAAC;QACpD,CAAC;QAED,OAAO,aAAa,CAAC,cAAc,CAAC,eAAe,CACjD,KAAK,CAC+D,CAAC;IACzE,CAAC;CACF"}
@@ -1,55 +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 { HubAddress, IconAddress, PromiseIconTxReturnType } from '../../types.js';
5
- export type IconSpokeDepositParams = {
6
- from: IconAddress;
7
- to?: Hex;
8
- token: string;
9
- amount: bigint;
10
- data: Hex;
11
- };
12
- export type TransferToHubParams = {
13
- token: string;
14
- recipient: Address;
15
- amount: string;
16
- data: Hex;
17
- };
18
- export declare class IconSpokeService {
19
- private constructor();
20
- /**
21
- * Deposit tokens to the spoke chain.
22
- * @param {IconSpokeDepositParams} params - The parameters for the deposit
23
- * @param {IconWalletProvider} spokeProvider - The provider for the spoke chain
24
- * @param {EvmHubProvider} hubProvider - The provider for the hub chain
25
- * @param {boolean} raw - The return type raw or just transaction hash
26
- * @returns {Promise<Result<string>>} A promise that resolves to the transaction hash
27
- */
28
- static deposit<R extends boolean = false>(params: IconSpokeDepositParams, spokeProvider: IconSpokeProvider, hubProvider: EvmHubProvider, raw?: R): PromiseIconTxReturnType<R>;
29
- /**
30
- * Get the balance of the token in the spoke chain.
31
- * @param {string} token - The address of the token to get the balance of
32
- * @param {IconWalletProvider} spokeProvider - The spoke provider
33
- * @returns {Promise<bigint>} The balance of the token
34
- */
35
- static getDeposit(token: string, spokeProvider: IconSpokeProvider): Promise<bigint>;
36
- /**
37
- * Calls a contract on the spoke chain using the user's wallet.
38
- * @param {HubAddress} from - The address of the user on the hub chain
39
- * @param {Hex} payload - The payload to send to the contract
40
- * @param {IconWalletProvider} spokeProvider - The provider for the spoke chain
41
- * @param {EvmHubProvider} hubProvider - The provider for the hub chain
42
- * @param {boolean} raw - The return type raw or just transaction hash
43
- * @returns {Promise<Result<string>>} A promise that resolves to the transaction hash
44
- */
45
- static callWallet<R extends boolean = false>(from: HubAddress, payload: Hex, spokeProvider: IconSpokeProvider, hubProvider: EvmHubProvider, raw?: R): PromiseIconTxReturnType<R>;
46
- /**
47
- * Transfers tokens to the hub chain.
48
- */
49
- private static transfer;
50
- /**
51
- * Sends a message to the hub chain.
52
- */
53
- private static call;
54
- }
55
- //# 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,UAAU,EAAE,WAAW,EAAkB,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAGvG,MAAM,MAAM,sBAAsB,GAAG;IACnC,IAAI,EAAE,WAAW,CAAC;IAClB,EAAE,CAAC,EAAE,GAAG,CAAC;IACT,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;IAqC7B;;OAEG;mBACkB,IAAI;CA4B1B"}
@@ -1,111 +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 { getIntentRelayChainId } 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.toString(),
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.walletProvider.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: amount,
64
- _data: hexData,
65
- };
66
- let value = '0x0';
67
- if (token === spokeProvider.chainConfig.nativeToken) {
68
- value = amount;
69
- }
70
- const transaction = new IconService.CallTransactionBuilder()
71
- .from(spokeProvider.walletProvider.getWalletAddress())
72
- .to(token)
73
- .stepLimit(IconService.Converter.toBigNumber('2000000'))
74
- .nid(spokeProvider.chainConfig.nid)
75
- .version('0x3')
76
- .timestamp(new Date().getTime() * 1000)
77
- .value(value)
78
- .method('transfer')
79
- .params(params)
80
- .build();
81
- if (raw) {
82
- return IconService.Converter.toRawTransaction(transaction);
83
- }
84
- return spokeProvider.walletProvider.sendTransaction(transaction);
85
- }
86
- /**
87
- * Sends a message to the hub chain.
88
- */
89
- static async call(dstChainId, dstAddress, payload, spokeProvider, raw) {
90
- const params = {
91
- dstChainId: dstChainId.toString(),
92
- dstAddress: dstAddress,
93
- payload: payload,
94
- };
95
- const transaction = new IconService.CallTransactionBuilder()
96
- .from(spokeProvider.walletProvider.getWalletAddressBytes())
97
- .to(spokeProvider.chainConfig.addresses.connection)
98
- .stepLimit(IconService.Converter.toBigNumber('2000000'))
99
- .nid(spokeProvider.chainConfig.nid)
100
- .version('0x3')
101
- .timestamp(new Date().getTime() * 1000)
102
- .method('sendMessage')
103
- .params(params)
104
- .build();
105
- if (raw) {
106
- return IconService.Converter.toRawTransaction(transaction);
107
- }
108
- return spokeProvider.walletProvider.sendTransaction(transaction);
109
- }
110
- }
111
- //# 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,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,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,IA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EG;IACK,MAAM,CAAC,KAAK,CAAC,IAAI,CACvB,UAAkB,EAClB,UAAsB,EACtB,OAAY,EACZ,aAAgC,EAChC,GAAO;QAEP,MAAM,MAAM,GAAG;YACb,UAAU,EAAE,UAAU,CAAC,QAAQ,EAAE;YACjC,UAAU,EAAE,UAAU;YACtB,OAAO,EAAE,OAAO;SACjB,CAAC;QAEF,MAAM,WAAW,GAAG,IAAI,WAAW,CAAC,sBAAsB,EAAE;aACzD,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC,qBAAqB,EAAE,CAAC;aAC1D,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;QACX,IAAI,GAAG,EAAE,CAAC;YACR,OAAO,WAAW,CAAC,SAAS,CAAC,gBAAgB,CAAC,WAAW,CAAsB,CAAC;QAClF,CAAC;QACD,OAAO,aAAa,CAAC,cAAc,CAAC,eAAe,CAAC,WAAW,CAA+B,CAAC;IACjG,CAAC;CACF"}
@@ -1,45 +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 { HubAddress, PromiseSolanaTxReturnType } from '../../types.js';
6
- export type SolanaSpokeDepositParams = {
7
- from: PublicKey;
8
- to?: Hex;
9
- token: PublicKey;
10
- amount: bigint;
11
- data: Hex;
12
- };
13
- export type TransferToHubParams = {
14
- token: PublicKey;
15
- recipient: string;
16
- amount: string;
17
- data: Hex;
18
- };
19
- export declare class SolanaSpokeService {
20
- private constructor();
21
- static deposit<R extends boolean = false>(params: SolanaSpokeDepositParams, spokeProvider: SolanaSpokeProvider, hubProvider: EvmHubProvider, raw?: R): PromiseSolanaTxReturnType<R>;
22
- static getDeposit(token: string, spokeProvider: SolanaSpokeProvider): Promise<bigint>;
23
- /**
24
- * Calls a contract on the spoke chain using the user's wallet.
25
- * @param from - The address of the user on the hub chain.
26
- * @param payload - The payload to send to the contract.
27
- * @param spokeProvider - The spoke provider.
28
- * @param hubProvider - The hub provider.
29
- * @param raw - Whether to return the raw transaction data.
30
- * @returns The transaction result.
31
- */
32
- static callWallet<R extends boolean = false>(from: HubAddress, payload: Hex, spokeProvider: SolanaSpokeProvider, hubProvider: EvmHubProvider, raw?: R): PromiseSolanaTxReturnType<R>;
33
- private static transfer;
34
- /**
35
- * Sends a message to the hub chain.
36
- * @param dstChainId - The chain ID of the hub chain.
37
- * @param dstAddress - The address on the hub chain.
38
- * @param payload - The payload to send.
39
- * @param spokeProvider - The spoke provider.
40
- * @param raw - Whether to return the raw transaction data.
41
- * @returns The transaction result.
42
- */
43
- private static call;
44
- }
45
- //# sourceMappingURL=SolanaSpokeService.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SolanaSpokeService.d.ts","sourceRoot":"","sources":["../../../src/services/spoke/SolanaSpokeService.ts"],"names":[],"mappings":"AAEA,OAAO,EAAwB,SAAS,EAA8C,MAAM,iBAAiB,CAAC;AAE9G,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,UAAU,EAAE,yBAAyB,EAAoB,MAAM,gBAAgB,CAAC;AAG9F,MAAM,MAAM,wBAAwB,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