@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.
- package/README.md +3 -1
- package/dist/index.cjs +11147 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +6831 -0
- package/dist/index.d.ts +6830 -9
- package/dist/index.mjs +10991 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +20 -6
- package/dist/abis/asset-manager.abi.d.ts +0 -418
- package/dist/abis/asset-manager.abi.d.ts.map +0 -1
- package/dist/abis/asset-manager.abi.js +0 -542
- package/dist/abis/asset-manager.abi.js.map +0 -1
- package/dist/abis/connection.abi.d.ts +0 -72
- package/dist/abis/connection.abi.d.ts.map +0 -1
- package/dist/abis/connection.abi.js +0 -92
- package/dist/abis/connection.abi.js.map +0 -1
- package/dist/abis/erc20.abi.d.ts +0 -236
- package/dist/abis/erc20.abi.d.ts.map +0 -1
- package/dist/abis/erc20.abi.js +0 -311
- package/dist/abis/erc20.abi.js.map +0 -1
- package/dist/abis/index.d.ts +0 -10
- package/dist/abis/index.d.ts.map +0 -1
- package/dist/abis/index.js +0 -10
- package/dist/abis/index.js.map +0 -1
- package/dist/abis/intents.abi.d.ts +0 -901
- package/dist/abis/intents.abi.d.ts.map +0 -1
- package/dist/abis/intents.abi.js +0 -1158
- package/dist/abis/intents.abi.js.map +0 -1
- package/dist/abis/pool.abi.d.ts +0 -626
- package/dist/abis/pool.abi.d.ts.map +0 -1
- package/dist/abis/pool.abi.js +0 -812
- package/dist/abis/pool.abi.js.map +0 -1
- package/dist/abis/spokeAssetManager.abi.d.ts +0 -169
- package/dist/abis/spokeAssetManager.abi.d.ts.map +0 -1
- package/dist/abis/spokeAssetManager.abi.js +0 -217
- package/dist/abis/spokeAssetManager.abi.js.map +0 -1
- package/dist/abis/uiPoolData.abi.d.ts +0 -369
- package/dist/abis/uiPoolData.abi.d.ts.map +0 -1
- package/dist/abis/uiPoolData.abi.js +0 -476
- package/dist/abis/uiPoolData.abi.js.map +0 -1
- package/dist/abis/vaultToken.abi.d.ts +0 -816
- package/dist/abis/vaultToken.abi.d.ts.map +0 -1
- package/dist/abis/vaultToken.abi.js +0 -1062
- package/dist/abis/vaultToken.abi.js.map +0 -1
- package/dist/abis/walletFactory.abi.d.ts +0 -20
- package/dist/abis/walletFactory.abi.d.ts.map +0 -1
- package/dist/abis/walletFactory.abi.js +0 -27
- package/dist/abis/walletFactory.abi.js.map +0 -1
- package/dist/constants.d.ts +0 -550
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js +0 -1196
- package/dist/constants.js.map +0 -1
- package/dist/constants.test.d.ts +0 -2
- package/dist/constants.test.d.ts.map +0 -1
- package/dist/constants.test.js +0 -129
- package/dist/constants.test.js.map +0 -1
- package/dist/entities/Providers.d.ts +0 -54
- package/dist/entities/Providers.d.ts.map +0 -1
- package/dist/entities/Providers.js +0 -51
- package/dist/entities/Providers.js.map +0 -1
- package/dist/entities/Sodax.d.ts +0 -23
- package/dist/entities/Sodax.d.ts.map +0 -1
- package/dist/entities/Sodax.js +0 -29
- package/dist/entities/Sodax.js.map +0 -1
- package/dist/entities/Sodax.test.d.ts +0 -2
- package/dist/entities/Sodax.test.d.ts.map +0 -1
- package/dist/entities/Sodax.test.js +0 -392
- package/dist/entities/Sodax.test.js.map +0 -1
- package/dist/entities/cosmos/CW20Token.d.ts +0 -39
- package/dist/entities/cosmos/CW20Token.d.ts.map +0 -1
- package/dist/entities/cosmos/CW20Token.js +0 -65
- package/dist/entities/cosmos/CW20Token.js.map +0 -1
- package/dist/entities/cosmos/CWSpokeProvider.d.ts +0 -92
- package/dist/entities/cosmos/CWSpokeProvider.d.ts.map +0 -1
- package/dist/entities/cosmos/CWSpokeProvider.js +0 -143
- package/dist/entities/cosmos/CWSpokeProvider.js.map +0 -1
- package/dist/entities/cosmos/CosmosWalletProvider.d.ts +0 -28
- package/dist/entities/cosmos/CosmosWalletProvider.d.ts.map +0 -1
- package/dist/entities/cosmos/CosmosWalletProvider.js +0 -102
- package/dist/entities/cosmos/CosmosWalletProvider.js.map +0 -1
- package/dist/entities/cosmos/InjectiveWalletProvider.d.ts +0 -25
- package/dist/entities/cosmos/InjectiveWalletProvider.d.ts.map +0 -1
- package/dist/entities/cosmos/InjectiveWalletProvider.js +0 -76
- package/dist/entities/cosmos/InjectiveWalletProvider.js.map +0 -1
- package/dist/entities/icon/HanaWalletConnector.d.ts +0 -36
- package/dist/entities/icon/HanaWalletConnector.d.ts.map +0 -1
- package/dist/entities/icon/HanaWalletConnector.js +0 -92
- package/dist/entities/icon/HanaWalletConnector.js.map +0 -1
- package/dist/entities/icon/IconSpokeProvider.d.ts +0 -10
- package/dist/entities/icon/IconSpokeProvider.d.ts.map +0 -1
- package/dist/entities/icon/IconSpokeProvider.js +0 -12
- package/dist/entities/icon/IconSpokeProvider.js.map +0 -1
- package/dist/entities/icon/index.d.ts +0 -4
- package/dist/entities/icon/index.d.ts.map +0 -1
- package/dist/entities/icon/index.js +0 -4
- package/dist/entities/icon/index.js.map +0 -1
- package/dist/entities/icon/utils.d.ts +0 -3
- package/dist/entities/icon/utils.d.ts.map +0 -1
- package/dist/entities/icon/utils.js +0 -4
- package/dist/entities/icon/utils.js.map +0 -1
- package/dist/entities/index.d.ts +0 -7
- package/dist/entities/index.d.ts.map +0 -1
- package/dist/entities/index.js +0 -7
- package/dist/entities/index.js.map +0 -1
- package/dist/entities/solana/Configs.d.ts +0 -38
- package/dist/entities/solana/Configs.d.ts.map +0 -1
- package/dist/entities/solana/Configs.js +0 -149
- package/dist/entities/solana/Configs.js.map +0 -1
- package/dist/entities/solana/SolanaSpokeProvider.d.ts +0 -9
- package/dist/entities/solana/SolanaSpokeProvider.d.ts.map +0 -1
- package/dist/entities/solana/SolanaSpokeProvider.js +0 -9
- package/dist/entities/solana/SolanaSpokeProvider.js.map +0 -1
- package/dist/entities/solana/SolanaWalletProvider.d.ts +0 -20
- package/dist/entities/solana/SolanaWalletProvider.d.ts.map +0 -1
- package/dist/entities/solana/SolanaWalletProvider.js +0 -53
- package/dist/entities/solana/SolanaWalletProvider.js.map +0 -1
- package/dist/entities/solana/index.d.ts +0 -4
- package/dist/entities/solana/index.d.ts.map +0 -1
- package/dist/entities/solana/index.js +0 -4
- package/dist/entities/solana/index.js.map +0 -1
- package/dist/entities/solana/pda/pda.d.ts +0 -45
- package/dist/entities/solana/pda/pda.d.ts.map +0 -1
- package/dist/entities/solana/pda/pda.js +0 -44
- package/dist/entities/solana/pda/pda.js.map +0 -1
- package/dist/entities/solana/types/asset_manager.d.ts +0 -919
- package/dist/entities/solana/types/asset_manager.d.ts.map +0 -1
- package/dist/entities/solana/types/asset_manager.js +0 -2
- package/dist/entities/solana/types/asset_manager.js.map +0 -1
- package/dist/entities/solana/types/connection.d.ts +0 -446
- package/dist/entities/solana/types/connection.d.ts.map +0 -1
- package/dist/entities/solana/types/connection.js +0 -2
- package/dist/entities/solana/types/connection.js.map +0 -1
- package/dist/entities/solana/types/rate_limit_contract.d.ts +0 -348
- package/dist/entities/solana/types/rate_limit_contract.d.ts.map +0 -1
- package/dist/entities/solana/types/rate_limit_contract.js +0 -2
- package/dist/entities/solana/types/rate_limit_contract.js.map +0 -1
- package/dist/entities/solana/utils/utils.d.ts +0 -6
- package/dist/entities/solana/utils/utils.d.ts.map +0 -1
- package/dist/entities/solana/utils/utils.js +0 -18
- package/dist/entities/solana/utils/utils.js.map +0 -1
- package/dist/entities/stellar/StellarSpokeProvider.d.ts +0 -17
- package/dist/entities/stellar/StellarSpokeProvider.d.ts.map +0 -1
- package/dist/entities/stellar/StellarSpokeProvider.js +0 -125
- package/dist/entities/stellar/StellarSpokeProvider.js.map +0 -1
- package/dist/entities/sui/SuiSpokeProvider.d.ts +0 -35
- package/dist/entities/sui/SuiSpokeProvider.d.ts.map +0 -1
- package/dist/entities/sui/SuiSpokeProvider.js +0 -145
- package/dist/entities/sui/SuiSpokeProvider.js.map +0 -1
- package/dist/errors.d.ts +0 -2
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js +0 -2
- package/dist/errors.js.map +0 -1
- package/dist/guards.d.ts +0 -25
- package/dist/guards.d.ts.map +0 -1
- package/dist/guards.js +0 -110
- package/dist/guards.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -10
- package/dist/index.js.map +0 -1
- package/dist/services/hub/EvmAssetManagerService.d.ts +0 -61
- package/dist/services/hub/EvmAssetManagerService.d.ts.map +0 -1
- package/dist/services/hub/EvmAssetManagerService.js +0 -103
- package/dist/services/hub/EvmAssetManagerService.js.map +0 -1
- package/dist/services/hub/EvmVaultTokenService.d.ts +0 -81
- package/dist/services/hub/EvmVaultTokenService.d.ts.map +0 -1
- package/dist/services/hub/EvmVaultTokenService.js +0 -161
- package/dist/services/hub/EvmVaultTokenService.js.map +0 -1
- package/dist/services/hub/EvmWalletAbstraction.d.ts +0 -9
- package/dist/services/hub/EvmWalletAbstraction.d.ts.map +0 -1
- package/dist/services/hub/EvmWalletAbstraction.js +0 -14
- package/dist/services/hub/EvmWalletAbstraction.js.map +0 -1
- package/dist/services/hub/index.d.ts +0 -4
- package/dist/services/hub/index.d.ts.map +0 -1
- package/dist/services/hub/index.js +0 -4
- package/dist/services/hub/index.js.map +0 -1
- package/dist/services/index.d.ts +0 -7
- package/dist/services/index.d.ts.map +0 -1
- package/dist/services/index.js +0 -7
- package/dist/services/index.js.map +0 -1
- package/dist/services/intentRelay/IntentRelayApiService.d.ts +0 -112
- package/dist/services/intentRelay/IntentRelayApiService.d.ts.map +0 -1
- package/dist/services/intentRelay/IntentRelayApiService.js +0 -160
- package/dist/services/intentRelay/IntentRelayApiService.js.map +0 -1
- package/dist/services/intentRelay/IntentRelayApiService.test.d.ts +0 -2
- package/dist/services/intentRelay/IntentRelayApiService.test.d.ts.map +0 -1
- package/dist/services/intentRelay/IntentRelayApiService.test.js +0 -134
- package/dist/services/intentRelay/IntentRelayApiService.test.js.map +0 -1
- package/dist/services/intentRelay/index.d.ts +0 -2
- package/dist/services/intentRelay/index.d.ts.map +0 -1
- package/dist/services/intentRelay/index.js +0 -2
- package/dist/services/intentRelay/index.js.map +0 -1
- package/dist/services/moneyMarket/MoneyMarketService.d.ts +0 -525
- package/dist/services/moneyMarket/MoneyMarketService.d.ts.map +0 -1
- package/dist/services/moneyMarket/MoneyMarketService.js +0 -814
- package/dist/services/moneyMarket/MoneyMarketService.js.map +0 -1
- package/dist/services/moneyMarket/MoneyMarketService.test.d.ts +0 -2
- package/dist/services/moneyMarket/MoneyMarketService.test.d.ts.map +0 -1
- package/dist/services/moneyMarket/MoneyMarketService.test.js +0 -262
- package/dist/services/moneyMarket/MoneyMarketService.test.js.map +0 -1
- package/dist/services/moneyMarket/index.d.ts +0 -2
- package/dist/services/moneyMarket/index.d.ts.map +0 -1
- package/dist/services/moneyMarket/index.js +0 -2
- package/dist/services/moneyMarket/index.js.map +0 -1
- package/dist/services/shared/Erc20Service.d.ts +0 -42
- package/dist/services/shared/Erc20Service.d.ts.map +0 -1
- package/dist/services/shared/Erc20Service.js +0 -108
- package/dist/services/shared/Erc20Service.js.map +0 -1
- package/dist/services/shared/index.d.ts +0 -2
- package/dist/services/shared/index.d.ts.map +0 -1
- package/dist/services/shared/index.js +0 -2
- package/dist/services/shared/index.js.map +0 -1
- package/dist/services/solver/EvmSolverService.d.ts +0 -125
- package/dist/services/solver/EvmSolverService.d.ts.map +0 -1
- package/dist/services/solver/EvmSolverService.js +0 -166
- package/dist/services/solver/EvmSolverService.js.map +0 -1
- package/dist/services/solver/SolverApiService.d.ts +0 -40
- package/dist/services/solver/SolverApiService.d.ts.map +0 -1
- package/dist/services/solver/SolverApiService.js +0 -157
- package/dist/services/solver/SolverApiService.js.map +0 -1
- package/dist/services/solver/SolverApiService.test.d.ts +0 -2
- package/dist/services/solver/SolverApiService.test.d.ts.map +0 -1
- package/dist/services/solver/SolverApiService.test.js +0 -181
- package/dist/services/solver/SolverApiService.test.js.map +0 -1
- package/dist/services/solver/SolverService.d.ts +0 -295
- package/dist/services/solver/SolverService.d.ts.map +0 -1
- package/dist/services/solver/SolverService.js +0 -429
- package/dist/services/solver/SolverService.js.map +0 -1
- package/dist/services/solver/SolverService.test.d.ts +0 -2
- package/dist/services/solver/SolverService.test.d.ts.map +0 -1
- package/dist/services/solver/SolverService.test.js +0 -439
- package/dist/services/solver/SolverService.test.js.map +0 -1
- package/dist/services/solver/index.d.ts +0 -3
- package/dist/services/solver/index.d.ts.map +0 -1
- package/dist/services/solver/index.js +0 -3
- package/dist/services/solver/index.js.map +0 -1
- package/dist/services/spoke/CWSpokeService.d.ts +0 -67
- package/dist/services/spoke/CWSpokeService.d.ts.map +0 -1
- package/dist/services/spoke/CWSpokeService.js +0 -75
- package/dist/services/spoke/CWSpokeService.js.map +0 -1
- package/dist/services/spoke/EvmSpokeService.d.ts +0 -62
- package/dist/services/spoke/EvmSpokeService.d.ts.map +0 -1
- package/dist/services/spoke/EvmSpokeService.js +0 -120
- package/dist/services/spoke/EvmSpokeService.js.map +0 -1
- package/dist/services/spoke/IconSpokeService.d.ts +0 -56
- package/dist/services/spoke/IconSpokeService.d.ts.map +0 -1
- package/dist/services/spoke/IconSpokeService.js +0 -124
- package/dist/services/spoke/IconSpokeService.js.map +0 -1
- package/dist/services/spoke/SolanaSpokeService.d.ts +0 -46
- package/dist/services/spoke/SolanaSpokeService.d.ts.map +0 -1
- package/dist/services/spoke/SolanaSpokeService.js +0 -156
- package/dist/services/spoke/SolanaSpokeService.js.map +0 -1
- package/dist/services/spoke/SpokeService.d.ts +0 -34
- package/dist/services/spoke/SpokeService.d.ts.map +0 -1
- package/dist/services/spoke/SpokeService.js +0 -101
- package/dist/services/spoke/SpokeService.js.map +0 -1
- package/dist/services/spoke/StellarSpokeService.d.ts +0 -35
- package/dist/services/spoke/StellarSpokeService.d.ts.map +0 -1
- package/dist/services/spoke/StellarSpokeService.js +0 -39
- package/dist/services/spoke/StellarSpokeService.js.map +0 -1
- package/dist/services/spoke/SuiSpokeService.d.ts +0 -69
- package/dist/services/spoke/SuiSpokeService.d.ts.map +0 -1
- package/dist/services/spoke/SuiSpokeService.js +0 -73
- package/dist/services/spoke/SuiSpokeService.js.map +0 -1
- package/dist/services/spoke/index.d.ts +0 -3
- package/dist/services/spoke/index.d.ts.map +0 -1
- package/dist/services/spoke/index.js +0 -3
- package/dist/services/spoke/index.js.map +0 -1
- package/dist/tests/services/hub/EvmAssetManagerService.test.d.ts +0 -2
- package/dist/tests/services/hub/EvmAssetManagerService.test.d.ts.map +0 -1
- package/dist/tests/services/hub/EvmAssetManagerService.test.js +0 -138
- package/dist/tests/services/hub/EvmAssetManagerService.test.js.map +0 -1
- package/dist/tests/services/hub/EvmMoneyMarketService.test.d.ts +0 -2
- package/dist/tests/services/hub/EvmMoneyMarketService.test.d.ts.map +0 -1
- package/dist/tests/services/hub/EvmMoneyMarketService.test.js +0 -121
- package/dist/tests/services/hub/EvmMoneyMarketService.test.js.map +0 -1
- package/dist/tests/services/hub/EvmVaultTokenService.test.d.ts +0 -2
- package/dist/tests/services/hub/EvmVaultTokenService.test.d.ts.map +0 -1
- package/dist/tests/services/hub/EvmVaultTokenService.test.js +0 -98
- package/dist/tests/services/hub/EvmVaultTokenService.test.js.map +0 -1
- package/dist/tests/services/spoke/EvmSpokeService.test.d.ts +0 -2
- package/dist/tests/services/spoke/EvmSpokeService.test.d.ts.map +0 -1
- package/dist/tests/services/spoke/EvmSpokeService.test.js +0 -198
- package/dist/tests/services/spoke/EvmSpokeService.test.js.map +0 -1
- package/dist/types.d.ts +0 -352
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -30
- package/dist/types.js.map +0 -1
- package/dist/utils/evm-utils.d.ts +0 -10
- package/dist/utils/evm-utils.d.ts.map +0 -1
- package/dist/utils/evm-utils.js +0 -15
- package/dist/utils/evm-utils.js.map +0 -1
- package/dist/utils/index.d.ts +0 -3
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js +0 -3
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/shared-utils.d.ts +0 -20
- package/dist/utils/shared-utils.d.ts.map +0 -1
- package/dist/utils/shared-utils.js +0 -69
- package/dist/utils/shared-utils.js.map +0 -1
- package/dist/utils/shared-utils.test.d.ts +0 -2
- package/dist/utils/shared-utils.test.d.ts.map +0 -1
- package/dist/utils/shared-utils.test.js +0 -63
- package/dist/utils/shared-utils.test.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SpokeService.d.ts","sourceRoot":"","sources":["../../../src/services/spoke/SpokeService.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,cAAc,EAGnB,KAAK,aAAa,EAGnB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,yBAAyB,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnG,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAgB7D;;;GAGG;AAEH,qBAAa,YAAY;IACvB;;;;;;OAMG;WACiB,OAAO,CAAC,CAAC,SAAS,aAAa,GAAG,aAAa,EAAE,CAAC,SAAS,OAAO,GAAG,KAAK,EAC5F,MAAM,EAAE,yBAAyB,CAAC,CAAC,CAAC,EACpC,aAAa,EAAE,CAAC,EAChB,WAAW,EAAE,cAAc,EAC3B,GAAG,CAAC,EAAE,CAAC,GACN,OAAO,CAAC,mBAAmB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAuDrC;;;;;OAKG;WACW,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC;IAuBvF;;;;;;;OAOG;WACiB,UAAU,CAAC,CAAC,SAAS,aAAa,GAAG,aAAa,EAAE,CAAC,SAAS,OAAO,GAAG,KAAK,EAC/F,IAAI,EAAE,UAAU,EAChB,OAAO,EAAE,GAAG,EACZ,aAAa,EAAE,CAAC,EAChB,WAAW,EAAE,cAAc,EAC3B,GAAG,CAAC,EAAE,CAAC,GACN,OAAO,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;CA2C/B"}
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { CWSpokeProvider } from '../../entities/cosmos/CWSpokeProvider.js';
|
|
2
|
-
import { IconSpokeProvider } from '../../entities/icon/IconSpokeProvider.js';
|
|
3
|
-
import { EvmSpokeProvider, SolanaSpokeProvider, StellarSpokeProvider, SuiSpokeProvider, } from '../../entities/index.js';
|
|
4
|
-
import { CWSpokeService } from './CWSpokeService.js';
|
|
5
|
-
import { EvmSpokeService } from './EvmSpokeService.js';
|
|
6
|
-
import { IconSpokeService } from './IconSpokeService.js';
|
|
7
|
-
import { SolanaSpokeService } from './SolanaSpokeService.js';
|
|
8
|
-
import { StellarSpokeService } from './StellarSpokeService.js';
|
|
9
|
-
import { SuiSpokeService } from './SuiSpokeService.js';
|
|
10
|
-
import { isCWSpokeProvider, isEvmSpokeProvider, isIconSpokeProvider, isSolanaSpokeProvider, isStellarSpokeProvider, isSuiSpokeProvider, } from '../../guards.js';
|
|
11
|
-
/**
|
|
12
|
-
* SpokeService is a main class that provides functionalities for dealing with spoke chains.
|
|
13
|
-
* It uses command pattern to execute different spoke chain operations.
|
|
14
|
-
*/
|
|
15
|
-
export class SpokeService {
|
|
16
|
-
/**
|
|
17
|
-
* Deposit tokens to the spoke chain.
|
|
18
|
-
* @param {GetSpokeDepositParamsType<T extends SpokeProvider>} params - The parameters for the deposit, including the user's address, token address, amount, and additional data.
|
|
19
|
-
* @param {SpokeProvider} spokeProvider - The provider for the spoke chain.
|
|
20
|
-
* @param {EvmHubProvider} hubProvider - The provider for the hub chain.
|
|
21
|
-
* @returns {Promise<Hash>} A promise that resolves to the transaction hash.
|
|
22
|
-
*/
|
|
23
|
-
static async deposit(params, spokeProvider, hubProvider, raw) {
|
|
24
|
-
if (spokeProvider instanceof EvmSpokeProvider) {
|
|
25
|
-
return EvmSpokeService.deposit(params, spokeProvider, hubProvider, raw);
|
|
26
|
-
}
|
|
27
|
-
if (spokeProvider instanceof CWSpokeProvider) {
|
|
28
|
-
return CWSpokeService.deposit(params, spokeProvider, hubProvider, raw);
|
|
29
|
-
}
|
|
30
|
-
if (spokeProvider instanceof IconSpokeProvider) {
|
|
31
|
-
return IconSpokeService.deposit(params, spokeProvider, hubProvider, raw);
|
|
32
|
-
}
|
|
33
|
-
if (spokeProvider instanceof SuiSpokeProvider) {
|
|
34
|
-
return SuiSpokeService.deposit(params, spokeProvider, hubProvider, raw);
|
|
35
|
-
}
|
|
36
|
-
if (spokeProvider instanceof SolanaSpokeProvider) {
|
|
37
|
-
return SolanaSpokeService.deposit(params, spokeProvider, hubProvider, raw);
|
|
38
|
-
}
|
|
39
|
-
if (spokeProvider instanceof StellarSpokeProvider) {
|
|
40
|
-
return StellarSpokeService.deposit(params, spokeProvider, hubProvider, raw);
|
|
41
|
-
}
|
|
42
|
-
throw new Error('Invalid spoke provider');
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Get the balance of the token in the spoke chain.
|
|
46
|
-
* @param {Address} token - The address of the token to get the balance of.
|
|
47
|
-
* @param {SpokeProvider} spokeProvider - The spoke provider.
|
|
48
|
-
* @returns {Promise<bigint>} The balance of the token.
|
|
49
|
-
*/
|
|
50
|
-
static getDeposit(token, spokeProvider) {
|
|
51
|
-
if (spokeProvider instanceof EvmSpokeProvider) {
|
|
52
|
-
return EvmSpokeService.getDeposit(token, spokeProvider);
|
|
53
|
-
}
|
|
54
|
-
if (spokeProvider instanceof CWSpokeProvider) {
|
|
55
|
-
return CWSpokeService.getDeposit(token, spokeProvider);
|
|
56
|
-
}
|
|
57
|
-
if (spokeProvider instanceof StellarSpokeProvider) {
|
|
58
|
-
return StellarSpokeService.getDeposit(token, spokeProvider);
|
|
59
|
-
}
|
|
60
|
-
if (spokeProvider instanceof SuiSpokeProvider) {
|
|
61
|
-
return SuiSpokeService.getDeposit(token, spokeProvider);
|
|
62
|
-
}
|
|
63
|
-
if (spokeProvider instanceof IconSpokeProvider) {
|
|
64
|
-
return IconSpokeService.getDeposit(token, spokeProvider);
|
|
65
|
-
}
|
|
66
|
-
if (spokeProvider instanceof SolanaSpokeProvider) {
|
|
67
|
-
return SolanaSpokeService.getDeposit(token, spokeProvider);
|
|
68
|
-
}
|
|
69
|
-
throw new Error('Invalid spoke provider');
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Calls a contract on the spoke chain using the user's wallet.
|
|
73
|
-
* @param {HubAddress} from - The address of the user on the hub chain.
|
|
74
|
-
* @param {Hex} payload - The payload to send to the contract.
|
|
75
|
-
* @param {SpokeProvider} spokeProvider - The provider for the spoke chain.
|
|
76
|
-
* @param {EvmHubProvider} hubProvider - The provider for the hub chain.
|
|
77
|
-
* @returns {Promise<Hash>} A promise that resolves to the transaction hash.
|
|
78
|
-
*/
|
|
79
|
-
static async callWallet(from, payload, spokeProvider, hubProvider, raw) {
|
|
80
|
-
if (isEvmSpokeProvider(spokeProvider)) {
|
|
81
|
-
return (await EvmSpokeService.callWallet(from, payload, spokeProvider, hubProvider));
|
|
82
|
-
}
|
|
83
|
-
if (isCWSpokeProvider(spokeProvider)) {
|
|
84
|
-
return (await CWSpokeService.callWallet(from, payload, spokeProvider, hubProvider, raw));
|
|
85
|
-
}
|
|
86
|
-
if (isIconSpokeProvider(spokeProvider)) {
|
|
87
|
-
return (await IconSpokeService.callWallet(from, payload, spokeProvider, hubProvider, raw));
|
|
88
|
-
}
|
|
89
|
-
if (isSuiSpokeProvider(spokeProvider)) {
|
|
90
|
-
return (await SuiSpokeService.callWallet(from, payload, spokeProvider, hubProvider, raw));
|
|
91
|
-
}
|
|
92
|
-
if (isSolanaSpokeProvider(spokeProvider)) {
|
|
93
|
-
return (await SolanaSpokeService.callWallet(from, payload, spokeProvider, hubProvider, raw));
|
|
94
|
-
}
|
|
95
|
-
if (isStellarSpokeProvider(spokeProvider)) {
|
|
96
|
-
return (await StellarSpokeService.callWallet(from, payload, spokeProvider, hubProvider));
|
|
97
|
-
}
|
|
98
|
-
throw new Error('Invalid spoke provider');
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
//# sourceMappingURL=SpokeService.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SpokeService.js","sourceRoot":"","sources":["../../../src/services/spoke/SpokeService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAC7E,OAAO,EAEL,gBAAgB,EAChB,mBAAmB,EAEnB,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EACtB,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AAEzB;;;GAGG;AAEH,MAAM,OAAO,YAAY;IACvB;;;;;;OAMG;IACI,MAAM,CAAC,KAAK,CAAC,OAAO,CACzB,MAAoC,EACpC,aAAgB,EAChB,WAA2B,EAC3B,GAAO;QAEP,IAAI,aAAa,YAAY,gBAAgB,EAAE,CAAC;YAC9C,OAAO,eAAe,CAAC,OAAO,CAC5B,MAAqD,EACrD,aAAa,EACb,WAAW,EACX,GAAG,CACyB,CAAC;QACjC,CAAC;QACD,IAAI,aAAa,YAAY,eAA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CAGjE,CAAC;QAC1B,CAAC;QACD,IAAI,qBAAqB,CAAC,aAAa,CAAC,EAAE,CAAC;YACzC,OAAO,CAAC,MAAM,kBAAkB,CAAC,UAAU,CACzC,IAAI,EACJ,OAAO,EACP,aAAa,EACb,WAAW,EACX,GAAG,CACJ,CAAsE,CAAC;QAC1E,CAAC;QACD,IAAI,sBAAsB,CAAC,aAAa,CAAC,EAAE,CAAC;YAC1C,OAAO,CAAC,MAAM,mBAAmB,CAAC,UAAU,CAAC,IAAI,EAAE,OAAO,EAAE,aAAa,EAAE,WAAW,CAAC,CAGhE,CAAC;QAC1B,CAAC;QAED,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAC5C,CAAC;CACF"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { type Address, type Hex } from 'viem';
|
|
2
|
-
import type { EvmHubProvider } from '../../entities/index.js';
|
|
3
|
-
import type { StellarSpokeProvider } from '../../entities/stellar/StellarSpokeProvider.js';
|
|
4
|
-
import { type HubAddress, type PromiseStellarTxReturnType } from '../../index.js';
|
|
5
|
-
export type StellarSpokeDepositParams = {
|
|
6
|
-
from: Hex;
|
|
7
|
-
to?: HubAddress;
|
|
8
|
-
token: string;
|
|
9
|
-
amount: bigint;
|
|
10
|
-
data: Hex;
|
|
11
|
-
};
|
|
12
|
-
export type TransferToHubParams = {
|
|
13
|
-
token: string;
|
|
14
|
-
recipient: Address;
|
|
15
|
-
amount: bigint;
|
|
16
|
-
data: Hex;
|
|
17
|
-
};
|
|
18
|
-
export declare class StellarSpokeService {
|
|
19
|
-
private constructor();
|
|
20
|
-
static deposit<R extends boolean = false>(params: StellarSpokeDepositParams, spokeProvider: StellarSpokeProvider, hubProvider: EvmHubProvider, raw?: R): PromiseStellarTxReturnType<R>;
|
|
21
|
-
static getDeposit(token: string, spokeProvider: StellarSpokeProvider): Promise<bigint>;
|
|
22
|
-
/**
|
|
23
|
-
* Calls a contract on the spoke chain using the user's wallet.
|
|
24
|
-
* @param from - The address of the user on the hub chain.
|
|
25
|
-
* @param payload - The payload to send to the contract.
|
|
26
|
-
* @param spokeProvider - The spoke provider.
|
|
27
|
-
* @param hubProvider - The hub provider.
|
|
28
|
-
* @param raw - Whether to return the raw transaction data.
|
|
29
|
-
* @returns The transaction result.
|
|
30
|
-
*/
|
|
31
|
-
static callWallet<R extends boolean = false>(from: HubAddress, payload: Hex, spokeProvider: StellarSpokeProvider, hubProvider: EvmHubProvider, raw?: R): PromiseStellarTxReturnType<R>;
|
|
32
|
-
private static transfer;
|
|
33
|
-
private static call;
|
|
34
|
-
}
|
|
35
|
-
//# sourceMappingURL=StellarSpokeService.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"StellarSpokeService.d.ts","sourceRoot":"","sources":["../../../src/services/spoke/StellarSpokeService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,GAAG,EAAW,MAAM,MAAM,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gDAAgD,CAAC;AAC3F,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,0BAA0B,EAAyB,MAAM,gBAAgB,CAAC;AAGzG,MAAM,MAAM,yBAAyB,GAAG;IACtC,IAAI,EAAE,GAAG,CAAC;IACV,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,mBAAmB;IAC9B,OAAO;WAEa,OAAO,CAAC,CAAC,SAAS,OAAO,GAAG,KAAK,EACnD,MAAM,EAAE,yBAAyB,EACjC,aAAa,EAAE,oBAAoB,EACnC,WAAW,EAAE,cAAc,EAC3B,GAAG,CAAC,EAAE,CAAC,GACN,0BAA0B,CAAC,CAAC,CAAC;WAqBZ,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,oBAAoB,GAAG,OAAO,CAAC,MAAM,CAAC;IAInG;;;;;;;;OAQG;WACiB,UAAU,CAAC,CAAC,SAAS,OAAO,GAAG,KAAK,EACtD,IAAI,EAAE,UAAU,EAChB,OAAO,EAAE,GAAG,EACZ,aAAa,EAAE,oBAAoB,EACnC,WAAW,EAAE,cAAc,EAC3B,GAAG,CAAC,EAAE,CAAC,GACN,0BAA0B,CAAC,CAAC,CAAC;mBAKX,QAAQ;mBAcR,IAAI;CAc1B"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { fromHex } from 'viem';
|
|
2
|
-
import { getIntentRelayChainId } from '../../index.js';
|
|
3
|
-
import { EvmWalletAbstraction } from '../hub/index.js';
|
|
4
|
-
export class StellarSpokeService {
|
|
5
|
-
constructor() { }
|
|
6
|
-
static async deposit(params, spokeProvider, hubProvider, raw) {
|
|
7
|
-
const userWallet = params.to ??
|
|
8
|
-
(await EvmWalletAbstraction.getUserHubWalletAddress(spokeProvider.chainConfig.chain.id, params.from, hubProvider));
|
|
9
|
-
return StellarSpokeService.transfer({
|
|
10
|
-
token: params.token,
|
|
11
|
-
recipient: userWallet,
|
|
12
|
-
amount: params.amount,
|
|
13
|
-
data: params.data,
|
|
14
|
-
}, spokeProvider, raw);
|
|
15
|
-
}
|
|
16
|
-
static async getDeposit(token, spokeProvider) {
|
|
17
|
-
return BigInt(await spokeProvider.getBalance(token));
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Calls a contract on the spoke chain using the user's wallet.
|
|
21
|
-
* @param from - The address of the user on the hub chain.
|
|
22
|
-
* @param payload - The payload to send to the contract.
|
|
23
|
-
* @param spokeProvider - The spoke provider.
|
|
24
|
-
* @param hubProvider - The hub provider.
|
|
25
|
-
* @param raw - Whether to return the raw transaction data.
|
|
26
|
-
* @returns The transaction result.
|
|
27
|
-
*/
|
|
28
|
-
static async callWallet(from, payload, spokeProvider, hubProvider, raw) {
|
|
29
|
-
const relayId = getIntentRelayChainId(hubProvider.chainConfig.chain.id);
|
|
30
|
-
return StellarSpokeService.call(BigInt(relayId), from, payload, spokeProvider, raw);
|
|
31
|
-
}
|
|
32
|
-
static async transfer({ token, recipient, amount, data = '0x' }, spokeProvider, raw) {
|
|
33
|
-
return await spokeProvider.deposit(token, amount.toString(), fromHex(recipient, 'bytes'), fromHex(data, 'bytes'), raw);
|
|
34
|
-
}
|
|
35
|
-
static async call(dstChainId, dstAddress, payload, spokeProvider, raw) {
|
|
36
|
-
return await spokeProvider.sendMessage(dstChainId.toString(), fromHex(dstAddress, 'bytes'), fromHex(payload, 'bytes'), raw);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
//# sourceMappingURL=StellarSpokeService.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"StellarSpokeService.js","sourceRoot":"","sources":["../../../src/services/spoke/StellarSpokeService.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,OAAO,EAAE,MAAM,MAAM,CAAC;AAGvD,OAAO,EAAoD,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACzG,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAiBvD,MAAM,OAAO,mBAAmB;IAC9B,gBAAuB,CAAC;IAEjB,MAAM,CAAC,KAAK,CAAC,OAAO,CACzB,MAAiC,EACjC,aAAmC,EACnC,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,MAAM,CAAC,IAAI,EACX,WAAW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C,QAAQ,EAAE,EACrB,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,EAC5B,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,EACzB,GAAG,CACJ,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { type Address, type Hex } from 'viem';
|
|
2
|
-
import type { EvmHubProvider } from '../../entities/index.js';
|
|
3
|
-
import type { SuiSpokeProvider } from '../../entities/sui/SuiSpokeProvider.js';
|
|
4
|
-
import { type HubAddress, type PromiseSuiTxReturnType } from '../../index.js';
|
|
5
|
-
export type SuiSpokeDepositParams = {
|
|
6
|
-
from: Hex;
|
|
7
|
-
to?: HubAddress;
|
|
8
|
-
token: string;
|
|
9
|
-
amount: bigint;
|
|
10
|
-
data: Hex;
|
|
11
|
-
};
|
|
12
|
-
export type TransferToHubParams = {
|
|
13
|
-
token: string;
|
|
14
|
-
recipient: Address;
|
|
15
|
-
amount: bigint;
|
|
16
|
-
data: Hex;
|
|
17
|
-
};
|
|
18
|
-
export declare class SuiSpokeService {
|
|
19
|
-
private constructor();
|
|
20
|
-
/**
|
|
21
|
-
* Deposit tokens to the spoke chain.
|
|
22
|
-
* @param {CWSpokeDepositParams} params - The parameters for the deposit, including the user's address, token address, amount, and additional data.
|
|
23
|
-
* @param {SuiSpokeProvider} 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 {PromiseSuiTxReturnType<R>} A promise that resolves to the transaction hash or raw transaction base64 string.
|
|
27
|
-
*/
|
|
28
|
-
static deposit<R extends boolean = false>(params: SuiSpokeDepositParams, spokeProvider: SuiSpokeProvider, hubProvider: EvmHubProvider, raw?: R): PromiseSuiTxReturnType<R>;
|
|
29
|
-
/**
|
|
30
|
-
* Get the balance of the token in the spoke chain.
|
|
31
|
-
* @param {Address} token - The address of the token to get the balance of.
|
|
32
|
-
* @param {SuiSpokeProvider} spokeProvider - The spoke provider.
|
|
33
|
-
* @returns {Promise<bigint>} The balance of the token.
|
|
34
|
-
*/
|
|
35
|
-
static getDeposit(token: string, spokeProvider: SuiSpokeProvider): 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 spoke chain.
|
|
39
|
-
* @param {Hex} payload - The payload to send to the contract.
|
|
40
|
-
* @param {SuiSpokeProvider} 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 {PromiseSuiTxReturnType<R>} A promise that resolves to the transaction hash or raw transaction base64 string.
|
|
44
|
-
*/
|
|
45
|
-
static callWallet<R extends boolean = false>(from: HubAddress, payload: Hex, spokeProvider: SuiSpokeProvider, hubProvider: EvmHubProvider, raw?: R): PromiseSuiTxReturnType<R>;
|
|
46
|
-
/**
|
|
47
|
-
* Transfers tokens to the hub chain.
|
|
48
|
-
* @param {TransferToHubParams} params - The parameters for the transfer, including:
|
|
49
|
-
* - {string} token: The address of the token to transfer (use address(0) for native token).
|
|
50
|
-
* - {Uint8Array} recipient: The recipient address on the hub chain.
|
|
51
|
-
* - {string} amount: The amount to transfer.
|
|
52
|
-
* - {Uint8Array} [data=new Uint8Array([])]: Additional data for the transfer.
|
|
53
|
-
* @param {SuiSpokeProvider} spokeProvider - The provider for the spoke chain.
|
|
54
|
-
* @param {boolean} raw - The return type raw or just transaction hash
|
|
55
|
-
* @returns {PromiseSuiTxReturnType<R>} A promise that resolves to the transaction hash or raw transaction base64 string.
|
|
56
|
-
*/
|
|
57
|
-
private static transfer;
|
|
58
|
-
/**
|
|
59
|
-
* Sends a message to the hub chain.
|
|
60
|
-
* @param {bigint} dstChainId - The chain ID of the hub chain.
|
|
61
|
-
* @param {HubAddress} dstAddress - The address on the hub chain.
|
|
62
|
-
* @param {Hex} payload - The payload to send.
|
|
63
|
-
* @param {SuiSpokeProvider} spokeProvider - The provider for the spoke chain.
|
|
64
|
-
* @param {boolean} raw - The return type raw or just transaction hash
|
|
65
|
-
* @returns {PromiseSuiTxReturnType<R>} A promise that resolves to the transaction hash or raw transaction base64 string.
|
|
66
|
-
*/
|
|
67
|
-
private static call;
|
|
68
|
-
}
|
|
69
|
-
//# sourceMappingURL=SuiSpokeService.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SuiSpokeService.d.ts","sourceRoot":"","sources":["../../../src/services/spoke/SuiSpokeService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,GAAG,EAAW,MAAM,MAAM,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC/E,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,sBAAsB,EAAyB,MAAM,gBAAgB,CAAC;AAGrG,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,EAAE,GAAG,CAAC;IACV,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,eAAe;IAC1B,OAAO;IAEP;;;;;;;OAOG;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,MAAM,EAAE,aAAa,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC;IAI/F;;;;;;;;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,sBAAsB,CAAC,CAAC,CAAC;IAK5B;;;;;;;;;;OAUG;mBACkB,QAAQ;IAQ7B;;;;;;;;OAQG;mBACkB,IAAI;CAS1B"}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { fromHex } from 'viem';
|
|
2
|
-
import { getIntentRelayChainId } from '../../index.js';
|
|
3
|
-
import { EvmWalletAbstraction } from '../hub/index.js';
|
|
4
|
-
export class SuiSpokeService {
|
|
5
|
-
constructor() { }
|
|
6
|
-
/**
|
|
7
|
-
* Deposit tokens to the spoke chain.
|
|
8
|
-
* @param {CWSpokeDepositParams} params - The parameters for the deposit, including the user's address, token address, amount, and additional data.
|
|
9
|
-
* @param {SuiSpokeProvider} spokeProvider - The provider for the spoke chain.
|
|
10
|
-
* @param {EvmHubProvider} hubProvider - The provider for the hub chain.
|
|
11
|
-
* @param {boolean} raw - The return type raw or just transaction hash
|
|
12
|
-
* @returns {PromiseSuiTxReturnType<R>} A promise that resolves to the transaction hash or raw transaction base64 string.
|
|
13
|
-
*/
|
|
14
|
-
static async deposit(params, spokeProvider, hubProvider, raw) {
|
|
15
|
-
const userWallet = params.to ??
|
|
16
|
-
(await EvmWalletAbstraction.getUserHubWalletAddress(spokeProvider.chainConfig.chain.id, params.from, hubProvider));
|
|
17
|
-
return SuiSpokeService.transfer({
|
|
18
|
-
token: params.token,
|
|
19
|
-
recipient: userWallet,
|
|
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 {SuiSpokeProvider} spokeProvider - The spoke provider.
|
|
28
|
-
* @returns {Promise<bigint>} The balance of the token.
|
|
29
|
-
*/
|
|
30
|
-
static async getDeposit(token, spokeProvider) {
|
|
31
|
-
return spokeProvider.getBalance(token);
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Calls a contract on the spoke chain using the user's wallet.
|
|
35
|
-
* @param {HubAddress} from - The address of the user on the spoke chain.
|
|
36
|
-
* @param {Hex} payload - The payload to send to the contract.
|
|
37
|
-
* @param {SuiSpokeProvider} spokeProvider - The provider for the spoke chain.
|
|
38
|
-
* @param {EvmHubProvider} hubProvider - The provider for the hub chain.
|
|
39
|
-
* @param {boolean} raw - The return type raw or just transaction hash
|
|
40
|
-
* @returns {PromiseSuiTxReturnType<R>} A promise that resolves to the transaction hash or raw transaction base64 string.
|
|
41
|
-
*/
|
|
42
|
-
static async callWallet(from, payload, spokeProvider, hubProvider, raw) {
|
|
43
|
-
const relayId = getIntentRelayChainId(hubProvider.chainConfig.chain.id);
|
|
44
|
-
return SuiSpokeService.call(BigInt(relayId), from, payload, spokeProvider, raw);
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Transfers tokens to the hub chain.
|
|
48
|
-
* @param {TransferToHubParams} params - The parameters for the transfer, including:
|
|
49
|
-
* - {string} token: The address of the token to transfer (use address(0) for native token).
|
|
50
|
-
* - {Uint8Array} recipient: The recipient address on the hub chain.
|
|
51
|
-
* - {string} amount: The amount to transfer.
|
|
52
|
-
* - {Uint8Array} [data=new Uint8Array([])]: Additional data for the transfer.
|
|
53
|
-
* @param {SuiSpokeProvider} spokeProvider - The provider for the spoke chain.
|
|
54
|
-
* @param {boolean} raw - The return type raw or just transaction hash
|
|
55
|
-
* @returns {PromiseSuiTxReturnType<R>} A promise that resolves to the transaction hash or raw transaction base64 string.
|
|
56
|
-
*/
|
|
57
|
-
static async transfer({ token, recipient, amount, data = '0x' }, spokeProvider, raw) {
|
|
58
|
-
return spokeProvider.transfer(token, amount, fromHex(recipient, 'bytes'), fromHex(data, 'bytes'), raw);
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Sends a message to the hub chain.
|
|
62
|
-
* @param {bigint} dstChainId - The chain ID of the hub chain.
|
|
63
|
-
* @param {HubAddress} dstAddress - The address on the hub chain.
|
|
64
|
-
* @param {Hex} payload - The payload to send.
|
|
65
|
-
* @param {SuiSpokeProvider} spokeProvider - The provider for the spoke chain.
|
|
66
|
-
* @param {boolean} raw - The return type raw or just transaction hash
|
|
67
|
-
* @returns {PromiseSuiTxReturnType<R>} A promise that resolves to the transaction hash or raw transaction base64 string.
|
|
68
|
-
*/
|
|
69
|
-
static async call(dstChainId, dstAddress, payload, spokeProvider, raw) {
|
|
70
|
-
return spokeProvider.sendMessage(dstChainId, fromHex(dstAddress, 'bytes'), fromHex(payload, 'bytes'), raw);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
//# sourceMappingURL=SuiSpokeService.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SuiSpokeService.js","sourceRoot":"","sources":["../../../src/services/spoke/SuiSpokeService.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,OAAO,EAAE,MAAM,MAAM,CAAC;AAGvD,OAAO,EAAgD,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACrG,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAiBvD,MAAM,OAAO,eAAe;IAC1B,gBAAuB,CAAC;IAExB;;;;;;;OAOG;IACI,MAAM,CAAC,KAAK,CAAC,OAAO,CACzB,MAA6B,EAC7B,aAA+B,EAC/B,WAA2B,EAC3B,GAAO;Q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;;;;;;;OAQG;IACK,MAAM,CAAC,KAAK,CAAC,IAAI,CACvB,UAAkB,EAClB,UAAsB,EACtB,OAAY,EACZ,aAA+B,EAC/B,GAAO;QAEP,OAAO,aAAa,CAAC,WAAW,CAAC,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,GAAG,CAAC,CAAC;IAC7G,CAAC;CACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/spoke/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/spoke/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EvmAssetManagerService.test.d.ts","sourceRoot":"","sources":["../../../../src/tests/services/hub/EvmAssetManagerService.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
-
import { decodeFunctionData } from 'viem';
|
|
3
|
-
import { assetManagerAbi } from '../../../abis/index.js';
|
|
4
|
-
import { EvmAssetManagerService, EvmSpokeProvider, spokeChainConfig, getHubChainConfig, EvmHubProvider, } from '../../../index.js';
|
|
5
|
-
import { BSC_MAINNET_CHAIN_ID, SONIC_MAINNET_CHAIN_ID } from '@sodax/types';
|
|
6
|
-
describe('EvmAssetManagerService', () => {
|
|
7
|
-
const bscEthToken = '0x2170Ed0880ac9A755fd29B2688956BD959F933F8';
|
|
8
|
-
const mockEvmWalletProvider = {
|
|
9
|
-
sendTransaction: vi.fn(),
|
|
10
|
-
getWalletAddress: vi.fn().mockResolvedValue('0x9999999999999999999999999999999999999999'),
|
|
11
|
-
getWalletAddressBytes: vi.fn().mockResolvedValue('0x9999999999999999999999999999999999999999'),
|
|
12
|
-
waitForTransactionReceipt: vi.fn(),
|
|
13
|
-
};
|
|
14
|
-
const mockBscSpokeProvider = new EvmSpokeProvider(mockEvmWalletProvider, spokeChainConfig[BSC_MAINNET_CHAIN_ID]);
|
|
15
|
-
const mockHubConfig = {
|
|
16
|
-
hubRpcUrl: 'https://rpc.soniclabs.com',
|
|
17
|
-
chainConfig: getHubChainConfig(SONIC_MAINNET_CHAIN_ID),
|
|
18
|
-
};
|
|
19
|
-
const mockHubProvider = new EvmHubProvider(mockHubConfig);
|
|
20
|
-
describe('getAssetInfo', () => {
|
|
21
|
-
it('should correctly fetch asset information', async () => {
|
|
22
|
-
const mockResponse = [
|
|
23
|
-
mockBscSpokeProvider.chainConfig.chain.id,
|
|
24
|
-
mockBscSpokeProvider.chainConfig.addresses.spokeAddress,
|
|
25
|
-
];
|
|
26
|
-
vi.spyOn(mockBscSpokeProvider.publicClient, 'readContract').mockResolvedValueOnce(mockResponse);
|
|
27
|
-
const result = await EvmAssetManagerService.getAssetInfo(bscEthToken, mockBscSpokeProvider.chainConfig.addresses.assetManager, mockBscSpokeProvider.publicClient);
|
|
28
|
-
expect(mockBscSpokeProvider.publicClient.readContract).toHaveBeenCalledWith({
|
|
29
|
-
address: mockBscSpokeProvider.chainConfig.addresses.assetManager,
|
|
30
|
-
abi: assetManagerAbi,
|
|
31
|
-
functionName: 'assetInfo',
|
|
32
|
-
args: [bscEthToken],
|
|
33
|
-
});
|
|
34
|
-
expect(result).toEqual({
|
|
35
|
-
chainId: mockBscSpokeProvider.chainConfig.chain.id,
|
|
36
|
-
spokeAddress: mockBscSpokeProvider.chainConfig.addresses.spokeAddress,
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
it('should handle zero values', async () => {
|
|
40
|
-
const mockResponse = [0n, '0x0000000000000000000000000000000000000000'];
|
|
41
|
-
vi.spyOn(mockBscSpokeProvider.publicClient, 'readContract').mockResolvedValueOnce(mockResponse);
|
|
42
|
-
const result = await EvmAssetManagerService.getAssetInfo(bscEthToken, mockBscSpokeProvider.chainConfig.addresses.assetManager, mockBscSpokeProvider.publicClient);
|
|
43
|
-
expect(result).toEqual({
|
|
44
|
-
chainId: 0n,
|
|
45
|
-
spokeAddress: '0x0000000000000000000000000000000000000000',
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
describe('encodeTransfer', () => {
|
|
50
|
-
it('should correctly encode transfer transaction data', async () => {
|
|
51
|
-
const walletAddress = (await mockEvmWalletProvider.getWalletAddress());
|
|
52
|
-
const encodedCall = EvmAssetManagerService.encodeTransfer(bscEthToken, walletAddress, 1000000000000000000n, mockBscSpokeProvider.chainConfig.addresses.assetManager);
|
|
53
|
-
expect(encodedCall).toEqual({
|
|
54
|
-
address: mockBscSpokeProvider.chainConfig.addresses.assetManager,
|
|
55
|
-
value: 0n,
|
|
56
|
-
data: expect.any(String),
|
|
57
|
-
});
|
|
58
|
-
const decoded = decodeFunctionData({
|
|
59
|
-
abi: assetManagerAbi,
|
|
60
|
-
data: encodedCall.data,
|
|
61
|
-
});
|
|
62
|
-
expect(decoded.functionName).toBe('transfer');
|
|
63
|
-
expect(decoded.args).toEqual([bscEthToken, walletAddress, 1000000000000000000n, '0x']);
|
|
64
|
-
});
|
|
65
|
-
it('should handle zero amount transfers', async () => {
|
|
66
|
-
const walletAddress = (await mockEvmWalletProvider.getWalletAddress());
|
|
67
|
-
const encodedCall = EvmAssetManagerService.encodeTransfer(bscEthToken, walletAddress, 0n, mockBscSpokeProvider.chainConfig.addresses.assetManager);
|
|
68
|
-
const decoded = decodeFunctionData({
|
|
69
|
-
abi: assetManagerAbi,
|
|
70
|
-
data: encodedCall.data,
|
|
71
|
-
});
|
|
72
|
-
expect(decoded.args).toEqual([bscEthToken, walletAddress, 0n, '0x']);
|
|
73
|
-
});
|
|
74
|
-
it('should handle maximum uint256 amount', async () => {
|
|
75
|
-
const walletAddress = (await mockEvmWalletProvider.getWalletAddress());
|
|
76
|
-
const maxUint256 = 2n ** 256n - 1n;
|
|
77
|
-
const encodedCall = EvmAssetManagerService.encodeTransfer(bscEthToken, walletAddress, maxUint256, mockBscSpokeProvider.chainConfig.addresses.assetManager);
|
|
78
|
-
const decoded = decodeFunctionData({
|
|
79
|
-
abi: assetManagerAbi,
|
|
80
|
-
data: encodedCall.data,
|
|
81
|
-
});
|
|
82
|
-
expect(decoded.args?.[2]).toBe(maxUint256);
|
|
83
|
-
});
|
|
84
|
-
it('should maintain data precision for large numbers', async () => {
|
|
85
|
-
const walletAddress = (await mockEvmWalletProvider.getWalletAddress());
|
|
86
|
-
const largeAmount = 2n ** 128n;
|
|
87
|
-
const encodedCall = EvmAssetManagerService.encodeTransfer(bscEthToken, walletAddress, largeAmount, mockBscSpokeProvider.chainConfig.addresses.assetManager);
|
|
88
|
-
const decoded = decodeFunctionData({
|
|
89
|
-
abi: assetManagerAbi,
|
|
90
|
-
data: encodedCall.data,
|
|
91
|
-
});
|
|
92
|
-
expect(decoded.args?.[2]).toBe(largeAmount);
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
describe('depositToData', () => {
|
|
96
|
-
let depositParams;
|
|
97
|
-
beforeEach(async () => {
|
|
98
|
-
const walletAddress = (await mockEvmWalletProvider.getWalletAddress());
|
|
99
|
-
depositParams = {
|
|
100
|
-
token: bscEthToken,
|
|
101
|
-
to: walletAddress,
|
|
102
|
-
amount: 1000000000000000000n,
|
|
103
|
-
};
|
|
104
|
-
});
|
|
105
|
-
it('should correctly encode deposit transaction data', async () => {
|
|
106
|
-
const result = EvmAssetManagerService.depositToData(depositParams, mockBscSpokeProvider.chainConfig.chain.id);
|
|
107
|
-
expect(result).toBe('0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000022000000000000000000000000057fc2ac5701e463ae261adbd6c99fbeb48ce5293000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000044095ea7b30000000000000000000000004effb5813271699683c25c734f4dabc45b3637090000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000000000000000000000000000004effb5813271699683c25c734f4dabc45b36370900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000004447e7ef2400000000000000000000000057fc2ac5701e463ae261adbd6c99fbeb48ce52930000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000000000000000000000000000004effb5813271699683c25c734f4dabc45b363709000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000044a9059cbb00000000000000000000000099999999999999999999999999999999999999990000000000000000000000000000000000000000000000000de0b6b3a764000000000000000000000000000000000000000000000000000000000000');
|
|
108
|
-
});
|
|
109
|
-
it('should throw error if asset config not found', async () => {
|
|
110
|
-
const walletAddress = (await mockEvmWalletProvider.getWalletAddress());
|
|
111
|
-
const invalidToken = '0x9999999999999999999999999999999999999999';
|
|
112
|
-
const invalidParams = { ...depositParams, token: invalidToken, to: walletAddress };
|
|
113
|
-
expect(() => EvmAssetManagerService.depositToData(invalidParams, mockBscSpokeProvider.chainConfig.chain.id)).toThrow('[depositToData] Hub asset not found');
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
describe('withdrawAssetData', () => {
|
|
117
|
-
let withdrawParams;
|
|
118
|
-
beforeEach(async () => {
|
|
119
|
-
const walletAddress = (await mockEvmWalletProvider.getWalletAddress());
|
|
120
|
-
withdrawParams = {
|
|
121
|
-
token: bscEthToken,
|
|
122
|
-
to: walletAddress,
|
|
123
|
-
amount: 1000000000000000000n,
|
|
124
|
-
};
|
|
125
|
-
});
|
|
126
|
-
it('should correctly encode withdraw transaction data', async () => {
|
|
127
|
-
const result = EvmAssetManagerService.withdrawAssetData(withdrawParams, mockHubProvider, mockBscSpokeProvider.chainConfig.chain.id);
|
|
128
|
-
expect(result).toBe('0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000060c5681bd1db4e50735c4ca3386005a4ba4937c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000e4c6b4180b00000000000000000000000057fc2ac5701e463ae261adbd6c99fbeb48ce529300000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000de0b6b3a764000000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000149999999999999999999999999999999999999999000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
|
|
129
|
-
});
|
|
130
|
-
it('should throw error if asset config not found', async () => {
|
|
131
|
-
const walletAddress = (await mockEvmWalletProvider.getWalletAddress());
|
|
132
|
-
const invalidToken = '0x9999999999999999999999999999999999999999';
|
|
133
|
-
const invalidParams = { ...withdrawParams, token: invalidToken, to: walletAddress };
|
|
134
|
-
expect(() => EvmAssetManagerService.withdrawAssetData(invalidParams, mockHubProvider, mockBscSpokeProvider.chainConfig.chain.id)).toThrow('[withdrawAssetData] Hub asset not found');
|
|
135
|
-
});
|
|
136
|
-
});
|
|
137
|
-
});
|
|
138
|
-
//# sourceMappingURL=EvmAssetManagerService.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EvmAssetManagerService.test.js","sourceRoot":"","sources":["../../../../src/tests/services/hub/EvmAssetManagerService.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAC9D,OAAO,EAAE,kBAAkB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pB,MAAM,aAAa,GAAG,CAAC,MAAM,qBAAqB,CAAC,gBAAgB,EAAE,CAAkB,CAAC;YACxF,cAAc,GAAG;gBACf,KAAK,EAAE,WAAW;gBAClB,EAAE,EAAE,aAAa;gBACjB,MAAM,EAAE,oBAAoB;aAC7B,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,mDAAmD,EAAE,KAAK,IAAI,EAAE;YACjE,MAAM,MAAM,GAAG,sBAAsB,CAAC,iBAAiB,CACrD,cAAc,EACd,eAAe,EACf,oBAAoB,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,CAC1C,CAAC;YACF,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CACjB,o8BAAo8B,CACr8B,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,8CAA8C,EAAE,KAAK,IAAI,EAAE;YAC5D,MAAM,aAAa,GAAG,CAAC,MAAM,qBAAqB,CAAC,gBAAgB,EAAE,CAAkB,CAAC;YACxF,MAAM,YAAY,GAAG,4CAAuD,CAAC;YAC7E,MAAM,aAAa,GAAG,EAAE,GAAG,cAAc,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE,EAAE,aAAa,EAAE,CAAC;YAEpF,MAAM,CAAC,GAAG,EAAE,CACV,sBAAsB,CAAC,iBAAiB,CACtC,aAAa,EACb,eAAe,EACf,oBAAoB,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,CAC1C,CACF,CAAC,OAAO,CAAC,yCAAyC,CAAC,CAAC;QACvD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EvmMoneyMarketService.test.d.ts","sourceRoot":"","sources":["../../../../src/tests/services/hub/EvmMoneyMarketService.test.ts"],"names":[],"mappings":""}
|