diff --git a/services/communitytokens/api.go b/services/communitytokens/api.go index 7f6c3c6e0..43e6165aa 100644 --- a/services/communitytokens/api.go +++ b/services/communitytokens/api.go @@ -107,7 +107,7 @@ func (api *API) DeployCollectibles(ctx context.Context, chainID uint64, deployme if err != nil { return DeploymentDetails{}, err } - transactOpts := txArgs.ToTransactOpts(utils.GetSigner(chainID, api.s.accountsManager, api.s.config.KeyStoreDir, txArgs.From, password)) + transactOpts := txArgs.ToTransactOpts(utils.VerifyPasswordAndGetSigner(chainID, api.s.accountsManager, api.s.config.KeyStoreDir, txArgs.From, password)) ethClient, err := api.s.manager.rpcClient.EthClient(chainID) if err != nil { @@ -196,7 +196,7 @@ func (api *API) DeployOwnerToken(ctx context.Context, chainID uint64, return DeploymentDetails{}, err } - transactOpts := txArgs.ToTransactOpts(utils.GetSigner(chainID, api.s.accountsManager, api.s.config.KeyStoreDir, txArgs.From, password)) + transactOpts := txArgs.ToTransactOpts(utils.VerifyPasswordAndGetSigner(chainID, api.s.accountsManager, api.s.config.KeyStoreDir, txArgs.From, password)) deployerContractInst, err := api.NewCommunityTokenDeployerInstance(chainID) if err != nil { @@ -280,7 +280,7 @@ func (api *API) DeployAssets(ctx context.Context, chainID uint64, deploymentPara return DeploymentDetails{}, err } - transactOpts := txArgs.ToTransactOpts(utils.GetSigner(chainID, api.s.accountsManager, api.s.config.KeyStoreDir, txArgs.From, password)) + transactOpts := txArgs.ToTransactOpts(utils.VerifyPasswordAndGetSigner(chainID, api.s.accountsManager, api.s.config.KeyStoreDir, txArgs.From, password)) ethClient, err := api.s.manager.rpcClient.EthClient(chainID) if err != nil { @@ -384,7 +384,7 @@ func (api *API) MintTokens(ctx context.Context, chainID uint64, contractAddress return "", err } - transactOpts := txArgs.ToTransactOpts(utils.GetSigner(chainID, api.s.accountsManager, api.s.config.KeyStoreDir, txArgs.From, password)) + transactOpts := txArgs.ToTransactOpts(utils.VerifyPasswordAndGetSigner(chainID, api.s.accountsManager, api.s.config.KeyStoreDir, txArgs.From, password)) contractInst, err := NewTokenInstance(api.s, chainID, contractAddress) if err != nil { @@ -446,7 +446,7 @@ func (api *API) RemoteBurn(ctx context.Context, chainID uint64, contractAddress return "", err } - transactOpts := txArgs.ToTransactOpts(utils.GetSigner(chainID, api.s.accountsManager, api.s.config.KeyStoreDir, txArgs.From, password)) + transactOpts := txArgs.ToTransactOpts(utils.VerifyPasswordAndGetSigner(chainID, api.s.accountsManager, api.s.config.KeyStoreDir, txArgs.From, password)) var tempTokenIds []*big.Int for _, v := range tokenIds { @@ -498,7 +498,7 @@ func (api *API) Burn(ctx context.Context, chainID uint64, contractAddress string return "", err } - transactOpts := txArgs.ToTransactOpts(utils.GetSigner(chainID, api.s.accountsManager, api.s.config.KeyStoreDir, txArgs.From, password)) + transactOpts := txArgs.ToTransactOpts(utils.VerifyPasswordAndGetSigner(chainID, api.s.accountsManager, api.s.config.KeyStoreDir, txArgs.From, password)) newMaxSupply, err := api.s.prepareNewMaxSupply(ctx, chainID, contractAddress, burnAmount) if err != nil { diff --git a/services/communitytokens/service.go b/services/communitytokens/service.go index 8b339e4ce..bacc43137 100644 --- a/services/communitytokens/service.go +++ b/services/communitytokens/service.go @@ -508,7 +508,7 @@ func (s *Service) SetSignerPubKey(ctx context.Context, chainID uint64, contractA return "", fmt.Errorf("signerPubKey is empty") } - transactOpts := txArgs.ToTransactOpts(utils.GetSigner(chainID, s.accountsManager, s.config.KeyStoreDir, txArgs.From, password)) + transactOpts := txArgs.ToTransactOpts(utils.VerifyPasswordAndGetSigner(chainID, s.accountsManager, s.config.KeyStoreDir, txArgs.From, password)) contractInst, err := s.NewOwnerTokenInstance(chainID, contractAddress) if err != nil { diff --git a/services/ens/api.go b/services/ens/api.go index 52f67bc11..193a6a179 100644 --- a/services/ens/api.go +++ b/services/ens/api.go @@ -154,7 +154,7 @@ func (api *API) Release(ctx context.Context, chainID uint64, txArgs wallettypes. return "", err } - signFn := utils.GetSigner(chainID, api.accountsManager, api.config.KeyStoreDir, txArgs.From, password) + signFn := utils.VerifyPasswordAndGetSigner(chainID, api.accountsManager, api.config.KeyStoreDir, txArgs.From, password) tx, err := api.ensResolver.Release(ctx, chainID, registryAddr, txArgs, username, signFn) if err != nil { return "", err @@ -239,7 +239,7 @@ func (api *API) Register(ctx context.Context, chainID uint64, txArgs wallettypes return "", err } - signFn := utils.GetSigner(chainID, api.accountsManager, api.config.KeyStoreDir, txArgs.From, password) + signFn := utils.VerifyPasswordAndGetSigner(chainID, api.accountsManager, api.config.KeyStoreDir, txArgs.From, password) tx, err := api.ensResolver.Register(ctx, chainID, registryAddr, txArgs, username, pubkey, signFn) if err != nil { @@ -350,7 +350,7 @@ func (api *API) SetPubKey(ctx context.Context, chainID uint64, txArgs wallettype return "", err } - signFn := utils.GetSigner(chainID, api.accountsManager, api.config.KeyStoreDir, txArgs.From, password) + signFn := utils.VerifyPasswordAndGetSigner(chainID, api.accountsManager, api.config.KeyStoreDir, txArgs.From, password) tx, err := api.ensResolver.SetPubKey(ctx, chainID, resolverAddress, txArgs, username, pubkey, signFn) if err != nil { return "", err diff --git a/services/utils/utils.go b/services/utils/utils.go index 8f9b3162e..b5248dccd 100644 --- a/services/utils/utils.go +++ b/services/utils/utils.go @@ -1,6 +1,7 @@ package utils import ( + "crypto/ecdsa" "math/big" "strings" @@ -14,7 +15,14 @@ import ( prot_common "github.com/status-im/status-go/protocol/common" ) -func GetSigner(chainID uint64, accountsManager *account.GethManager, keyStoreDir string, from types.Address, password string) bind.SignerFn { +func GetSigner(chainID uint64, from types.Address, privateKey *ecdsa.PrivateKey) bind.SignerFn { + return func(addr common.Address, tx *ethTypes.Transaction) (*ethTypes.Transaction, error) { + s := ethTypes.NewLondonSigner(new(big.Int).SetUint64(chainID)) + return ethTypes.SignTx(tx, s, privateKey) + } +} + +func VerifyPasswordAndGetSigner(chainID uint64, accountsManager *account.GethManager, keyStoreDir string, from types.Address, password string) bind.SignerFn { return func(addr common.Address, tx *ethTypes.Transaction) (*ethTypes.Transaction, error) { selectedAccount, err := accountsManager.VerifyAccountPassword(keyStoreDir, from.Hex(), password) if err != nil { diff --git a/services/wallet/common/const.go b/services/wallet/common/const.go index 57adb2724..ca2d888a2 100644 --- a/services/wallet/common/const.go +++ b/services/wallet/common/const.go @@ -22,17 +22,6 @@ const ( SttSymbol = "STT" UsdcSymbol = "USDC" HopSymbol = "HOP" - - ProcessorTransferName = "Transfer" - ProcessorBridgeHopName = "Hop" - ProcessorBridgeCelerName = "CBridge" - ProcessorSwapParaswapName = "Paraswap" - ProcessorERC721Name = "ERC721Transfer" - ProcessorERC1155Name = "ERC1155Transfer" - ProcessorENSRegisterName = "ENSRegister" - ProcessorENSReleaseName = "ENSRelease" - ProcessorENSPublicKeyName = "ENSPublicKey" - ProcessorStickersBuyName = "StickersBuy" ) type ChainID uint64 diff --git a/services/wallet/common/helpers.go b/services/wallet/common/helpers.go index d275abdca..1fb139001 100644 --- a/services/wallet/common/helpers.go +++ b/services/wallet/common/helpers.go @@ -10,14 +10,16 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" "github.com/status-im/status-go/contracts/ierc20" + + pathProcessorCommon "github.com/status-im/status-go/services/wallet/router/pathprocessor/common" ) func IsProcessorBridge(name string) bool { - return name == ProcessorBridgeHopName || name == ProcessorBridgeCelerName + return name == pathProcessorCommon.ProcessorBridgeHopName || name == pathProcessorCommon.ProcessorBridgeCelerName } func IsProcessorSwap(name string) bool { - return name == ProcessorSwapParaswapName + return name == pathProcessorCommon.ProcessorSwapParaswapName } func PackApprovalInputData(amountIn *big.Int, approvalContractAddress *common.Address) ([]byte, error) { diff --git a/services/wallet/routeexecution/manager.go b/services/wallet/routeexecution/manager.go index 823c6b13d..87fa4a840 100644 --- a/services/wallet/routeexecution/manager.go +++ b/services/wallet/routeexecution/manager.go @@ -14,11 +14,11 @@ import ( status_common "github.com/status-im/status-go/common" statusErrors "github.com/status-im/status-go/errors" - walletCommon "github.com/status-im/status-go/services/wallet/common" "github.com/status-im/status-go/services/wallet/requests" "github.com/status-im/status-go/services/wallet/responses" "github.com/status-im/status-go/services/wallet/routeexecution/storage" "github.com/status-im/status-go/services/wallet/router" + pathProcessorCommon "github.com/status-im/status-go/services/wallet/router/pathprocessor/common" "github.com/status-im/status-go/services/wallet/router/sendtype" "github.com/status-im/status-go/services/wallet/transfer" "github.com/status-im/status-go/services/wallet/wallettypes" @@ -118,9 +118,9 @@ func (m *Manager) SendRouterTransactionsWithSignatures(ctx context.Context, send clearLocalData := true if routeInputParams.SendType == sendtype.Swap { // in case of swap don't clear local data if an approval is placed, but swap tx is not sent yet - if m.transactionManager.ApprovalRequiredForPath(walletCommon.ProcessorSwapParaswapName) && - m.transactionManager.ApprovalPlacedForPath(walletCommon.ProcessorSwapParaswapName) && - !m.transactionManager.TxPlacedForPath(walletCommon.ProcessorSwapParaswapName) { + if m.transactionManager.ApprovalRequiredForPath(pathProcessorCommon.ProcessorSwapParaswapName) && + m.transactionManager.ApprovalPlacedForPath(pathProcessorCommon.ProcessorSwapParaswapName) && + !m.transactionManager.TxPlacedForPath(pathProcessorCommon.ProcessorSwapParaswapName) { clearLocalData = false } } diff --git a/services/wallet/router/pathprocessor/common.go b/services/wallet/router/pathprocessor/common.go deleted file mode 100644 index 718cd503a..000000000 --- a/services/wallet/router/pathprocessor/common.go +++ /dev/null @@ -1,41 +0,0 @@ -package pathprocessor - -import ( - "fmt" - "math/big" - "strings" - - ethTypes "github.com/ethereum/go-ethereum/core/types" - - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" - "github.com/status-im/status-go/account" - "github.com/status-im/status-go/eth-node/types" - walletCommon "github.com/status-im/status-go/services/wallet/common" -) - -func getSigner(chainID uint64, from types.Address, verifiedAccount *account.SelectedExtKey) bind.SignerFn { - return func(addr common.Address, tx *ethTypes.Transaction) (*ethTypes.Transaction, error) { - s := ethTypes.NewLondonSigner(new(big.Int).SetUint64(chainID)) - return ethTypes.SignTx(tx, s, verifiedAccount.AccountKey.PrivateKey) - } -} - -func makeKey(fromChain, toChain uint64, fromTokenSymbol, toTokenSymbol string, amount *big.Int) string { - key := fmt.Sprintf("%d-%d", fromChain, toChain) - if fromTokenSymbol != "" || toTokenSymbol != "" { - key = fmt.Sprintf("%s-%s-%s", key, fromTokenSymbol, toTokenSymbol) - } - if amount != nil { - key = fmt.Sprintf("%s-%s", key, amount.String()) - } - return key -} - -func getNameFromEnsUsername(ensUsername string) string { - suffix := "." + walletCommon.StatusDomain - if strings.HasSuffix(ensUsername, suffix) { - return ensUsername[:len(ensUsername)-len(suffix)] - } - return ensUsername -} diff --git a/services/wallet/router/pathprocessor/common/common.go b/services/wallet/router/pathprocessor/common/common.go new file mode 100644 index 000000000..cc4534b17 --- /dev/null +++ b/services/wallet/router/pathprocessor/common/common.go @@ -0,0 +1,27 @@ +package common + +import ( + "fmt" + "math/big" + "strings" + // walletCommon "github.com/status-im/status-go/services/wallet/common" +) + +func MakeKey(fromChain, toChain uint64, fromTokenSymbol, toTokenSymbol string, amount *big.Int) string { + key := fmt.Sprintf("%d-%d", fromChain, toChain) + if fromTokenSymbol != "" || toTokenSymbol != "" { + key = fmt.Sprintf("%s-%s-%s", key, fromTokenSymbol, toTokenSymbol) + } + if amount != nil { + key = fmt.Sprintf("%s-%s", key, amount.String()) + } + return key +} + +func GetNameFromEnsUsername(ensUsername string) string { + suffix := "." //+ walletCommon.StatusDomain + if strings.HasSuffix(ensUsername, suffix) { + return ensUsername[:len(ensUsername)-len(suffix)] + } + return ensUsername +} diff --git a/services/wallet/router/pathprocessor/common_test.go b/services/wallet/router/pathprocessor/common/common_test.go similarity index 66% rename from services/wallet/router/pathprocessor/common_test.go rename to services/wallet/router/pathprocessor/common/common_test.go index ea0a5f3ef..884aaf1f8 100644 --- a/services/wallet/router/pathprocessor/common_test.go +++ b/services/wallet/router/pathprocessor/common/common_test.go @@ -1,4 +1,4 @@ -package pathprocessor +package common import ( "testing" @@ -8,14 +8,14 @@ import ( func TestGettingNameFromEnsUsername(t *testing.T) { ensName := "test" - name := getNameFromEnsUsername(ensName) + name := GetNameFromEnsUsername(ensName) require.Equal(t, ensName, name) ensStatusName := "test.stateofus.eth" - name = getNameFromEnsUsername(ensStatusName) + name = GetNameFromEnsUsername(ensStatusName) require.Equal(t, ensName, name) ensNotStatusName := "test.eth" - name = getNameFromEnsUsername(ensNotStatusName) + name = GetNameFromEnsUsername(ensNotStatusName) require.Equal(t, ensNotStatusName, name) } diff --git a/services/wallet/router/pathprocessor/common/constants.go b/services/wallet/router/pathprocessor/common/constants.go new file mode 100644 index 000000000..522fd32c2 --- /dev/null +++ b/services/wallet/router/pathprocessor/common/constants.go @@ -0,0 +1,17 @@ +package common + +const ( + IncreaseEstimatedGasFactor = 1.2 + SevenDaysInSeconds = 60 * 60 * 24 * 7 + + ProcessorTransferName = "Transfer" + ProcessorBridgeHopName = "Hop" + ProcessorBridgeCelerName = "CBridge" + ProcessorSwapParaswapName = "Paraswap" + ProcessorERC721Name = "ERC721Transfer" + ProcessorERC1155Name = "ERC1155Transfer" + ProcessorENSRegisterName = "ENSRegister" + ProcessorENSReleaseName = "ENSRelease" + ProcessorENSPublicKeyName = "ENSPublicKey" + ProcessorStickersBuyName = "StickersBuy" +) diff --git a/services/wallet/router/pathprocessor/constants.go b/services/wallet/router/pathprocessor/constants.go deleted file mode 100644 index c1ce112c0..000000000 --- a/services/wallet/router/pathprocessor/constants.go +++ /dev/null @@ -1,6 +0,0 @@ -package pathprocessor - -const ( - IncreaseEstimatedGasFactor = 1.2 - SevenDaysInSeconds = 60 * 60 * 24 * 7 -) diff --git a/services/wallet/router/pathprocessor/errors.go b/services/wallet/router/pathprocessor/errors.go index 0a76834e7..0b9ae01f1 100644 --- a/services/wallet/router/pathprocessor/errors.go +++ b/services/wallet/router/pathprocessor/errors.go @@ -4,7 +4,8 @@ import ( "context" "github.com/status-im/status-go/errors" - walletCommon "github.com/status-im/status-go/services/wallet/common" + + pathProcessorCommon "github.com/status-im/status-go/services/wallet/router/pathprocessor/common" ) // Abbreviartion `WPP` for the error code stands for `Wallet Path Processor` @@ -70,25 +71,25 @@ func createErrorResponse(processorName string, err error) error { var customErrResp *errors.ErrorResponse switch processorName { - case walletCommon.ProcessorTransferName: + case pathProcessorCommon.ProcessorTransferName: customErrResp = ErrTransferCustomError - case walletCommon.ProcessorERC721Name: + case pathProcessorCommon.ProcessorERC721Name: customErrResp = ErrERC721TransferCustomError - case walletCommon.ProcessorERC1155Name: + case pathProcessorCommon.ProcessorERC1155Name: customErrResp = ErrERC1155TransferCustomError - case walletCommon.ProcessorBridgeHopName: + case pathProcessorCommon.ProcessorBridgeHopName: customErrResp = ErrBridgeHopCustomError - case walletCommon.ProcessorBridgeCelerName: + case pathProcessorCommon.ProcessorBridgeCelerName: customErrResp = ErrBridgeCellerCustomError - case walletCommon.ProcessorSwapParaswapName: + case pathProcessorCommon.ProcessorSwapParaswapName: customErrResp = ErrSwapParaswapCustomError - case walletCommon.ProcessorENSRegisterName: + case pathProcessorCommon.ProcessorENSRegisterName: customErrResp = ErrENSRegisterCustomError - case walletCommon.ProcessorENSReleaseName: + case pathProcessorCommon.ProcessorENSReleaseName: customErrResp = ErrENSReleaseCustomError - case walletCommon.ProcessorENSPublicKeyName: + case pathProcessorCommon.ProcessorENSPublicKeyName: customErrResp = ErrENSPublicKeyCustomError - case walletCommon.ProcessorStickersBuyName: + case pathProcessorCommon.ProcessorStickersBuyName: customErrResp = ErrStickersBuyCustomError default: return genericErrResp diff --git a/services/wallet/router/pathprocessor/errors_test.go b/services/wallet/router/pathprocessor/errors_test.go index 364cd0967..f9455e1ae 100644 --- a/services/wallet/router/pathprocessor/errors_test.go +++ b/services/wallet/router/pathprocessor/errors_test.go @@ -7,7 +7,7 @@ import ( s_errors "github.com/status-im/status-go/errors" - walletCommon "github.com/status-im/status-go/services/wallet/common" + "github.com/status-im/status-go/services/wallet/router/pathprocessor/common" "github.com/stretchr/testify/require" ) @@ -17,17 +17,17 @@ func TestPlainError(t *testing.T) { err := errors.New(errString) processorNames := []string{ - walletCommon.ProcessorTransferName, - walletCommon.ProcessorTransferName, - walletCommon.ProcessorBridgeHopName, - walletCommon.ProcessorBridgeCelerName, - walletCommon.ProcessorSwapParaswapName, - walletCommon.ProcessorERC721Name, - walletCommon.ProcessorERC1155Name, - walletCommon.ProcessorENSRegisterName, - walletCommon.ProcessorENSReleaseName, - walletCommon.ProcessorENSPublicKeyName, - walletCommon.ProcessorStickersBuyName, + common.ProcessorTransferName, + common.ProcessorTransferName, + common.ProcessorBridgeHopName, + common.ProcessorBridgeCelerName, + common.ProcessorSwapParaswapName, + common.ProcessorERC721Name, + common.ProcessorERC1155Name, + common.ProcessorENSRegisterName, + common.ProcessorENSReleaseName, + common.ProcessorENSPublicKeyName, + common.ProcessorStickersBuyName, } for _, processorName := range processorNames { @@ -64,7 +64,7 @@ func TestNonGenericErrorResponse(t *testing.T) { Details: "Not Generic Error Response", } err := s_errors.CreateErrorResponseFromError(errResp) - ppErrResp := createErrorResponse(walletCommon.ProcessorTransferName, err) + ppErrResp := createErrorResponse(common.ProcessorTransferName, err) castPPErrResp := ppErrResp.(*s_errors.ErrorResponse) require.Equal(t, errResp.Code, castPPErrResp.Code) diff --git a/services/wallet/router/pathprocessor/processor_bridge_celar.go b/services/wallet/router/pathprocessor/processor_bridge_celar.go index cf1871710..56258d600 100644 --- a/services/wallet/router/pathprocessor/processor_bridge_celar.go +++ b/services/wallet/router/pathprocessor/processor_bridge_celar.go @@ -23,8 +23,10 @@ import ( "github.com/status-im/status-go/rpc" "github.com/status-im/status-go/params" + "github.com/status-im/status-go/services/utils" walletCommon "github.com/status-im/status-go/services/wallet/common" "github.com/status-im/status-go/services/wallet/router/pathprocessor/cbridge" + pathProcessorCommon "github.com/status-im/status-go/services/wallet/router/pathprocessor/common" "github.com/status-im/status-go/services/wallet/thirdparty" "github.com/status-im/status-go/services/wallet/token" "github.com/status-im/status-go/services/wallet/wallettypes" @@ -65,11 +67,11 @@ func NewCelerBridgeProcessor(rpcClient *rpc.Client, transactor transactions.Tran } func createBridgeCellerErrorResponse(err error) error { - return createErrorResponse(walletCommon.ProcessorBridgeCelerName, err) + return createErrorResponse(pathProcessorCommon.ProcessorBridgeCelerName, err) } func (s *CelerBridgeProcessor) Name() string { - return walletCommon.ProcessorBridgeCelerName + return pathProcessorCommon.ProcessorBridgeCelerName } func (s *CelerBridgeProcessor) estimateAmt(from, to *params.Network, amountIn *big.Int, symbol string) (*cbridge.EstimateAmtResponse, error) { @@ -281,7 +283,7 @@ func (s *CelerBridgeProcessor) EstimateGas(params ProcessorInputParams) (uint64, return 0, createBridgeCellerErrorResponse(err) } } - increasedEstimation := float64(estimation) * IncreaseEstimatedGasFactor + increasedEstimation := float64(estimation) * pathProcessorCommon.IncreaseEstimatedGasFactor return uint64(increasedEstimation), nil } @@ -429,7 +431,7 @@ func (s *CelerBridgeProcessor) sendOrBuildV2(sendArgs *wallettypes.SendTxArgs, s } func (s *CelerBridgeProcessor) Send(sendArgs *MultipathProcessorTxArgs, lastUsedNonce int64, verifiedAccount *account.SelectedExtKey) (types.Hash, uint64, error) { - tx, err := s.sendOrBuild(sendArgs, getSigner(sendArgs.ChainID, sendArgs.CbridgeTx.From, verifiedAccount), lastUsedNonce) + tx, err := s.sendOrBuild(sendArgs, utils.GetSigner(sendArgs.ChainID, sendArgs.CbridgeTx.From, verifiedAccount.AccountKey.PrivateKey), lastUsedNonce) if err != nil { return types.HexToHash(""), 0, createBridgeCellerErrorResponse(err) } diff --git a/services/wallet/router/pathprocessor/processor_bridge_hop.go b/services/wallet/router/pathprocessor/processor_bridge_hop.go index e86d39117..aef0f458a 100644 --- a/services/wallet/router/pathprocessor/processor_bridge_hop.go +++ b/services/wallet/router/pathprocessor/processor_bridge_hop.go @@ -31,8 +31,10 @@ import ( "github.com/status-im/status-go/rpc" "github.com/status-im/status-go/rpc/chain" "github.com/status-im/status-go/rpc/network" + "github.com/status-im/status-go/services/utils" "github.com/status-im/status-go/services/wallet/bigint" walletCommon "github.com/status-im/status-go/services/wallet/common" + pathProcessorCommon "github.com/status-im/status-go/services/wallet/router/pathprocessor/common" "github.com/status-im/status-go/services/wallet/thirdparty" "github.com/status-im/status-go/services/wallet/token" "github.com/status-im/status-go/services/wallet/wallettypes" @@ -127,11 +129,11 @@ func NewHopBridgeProcessor(rpcClient rpc.ClientInterface, transactor transaction } func createBridgeHopErrorResponse(err error) error { - return createErrorResponse(walletCommon.ProcessorBridgeHopName, err) + return createErrorResponse(pathProcessorCommon.ProcessorBridgeHopName, err) } func (h *HopBridgeProcessor) Name() string { - return walletCommon.ProcessorBridgeHopName + return pathProcessorCommon.ProcessorBridgeHopName } func (h *HopBridgeProcessor) Clear() { @@ -202,7 +204,7 @@ func (h *HopBridgeProcessor) packTxInputDataInternally(params ProcessorInputPara return []byte{}, createBridgeHopErrorResponse(err) } - bonderKey := makeKey(params.FromChain.ChainID, params.ToChain.ChainID, "", "", params.AmountIn) + bonderKey := pathProcessorCommon.MakeKey(params.FromChain.ChainID, params.ToChain.ChainID, "", "", params.AmountIn) bonderFeeIns, ok := h.bonderFee.Load(bonderKey) if !ok { return nil, ErrNoBonderFeeFound @@ -274,7 +276,7 @@ func (h *HopBridgeProcessor) EstimateGas(params ProcessorInputParams) (uint64, e } } - increasedEstimation := float64(estimation) * IncreaseEstimatedGasFactor + increasedEstimation := float64(estimation) * pathProcessorCommon.IncreaseEstimatedGasFactor return uint64(increasedEstimation), nil } @@ -320,7 +322,7 @@ func (h *HopBridgeProcessor) sendOrBuild(sendArgs *MultipathProcessorTxArgs, sig return tx, createBridgeHopErrorResponse(err) } - bonderKey := makeKey(sendArgs.HopTx.ChainID, sendArgs.HopTx.ChainIDTo, "", "", (*big.Int)(sendArgs.HopTx.Amount)) + bonderKey := pathProcessorCommon.MakeKey(sendArgs.HopTx.ChainID, sendArgs.HopTx.ChainIDTo, "", "", (*big.Int)(sendArgs.HopTx.Amount)) bonderFeeIns, ok := h.bonderFee.Load(bonderKey) if !ok { return nil, ErrNoBonderFeeFound @@ -387,7 +389,7 @@ func (h *HopBridgeProcessor) sendOrBuildV2(sendArgs *wallettypes.SendTxArgs, sig return tx, createBridgeHopErrorResponse(err) } - bonderKey := makeKey(sendArgs.FromChainID, sendArgs.ToChainID, "", "", (*big.Int)(sendArgs.ValueIn)) + bonderKey := pathProcessorCommon.MakeKey(sendArgs.FromChainID, sendArgs.ToChainID, "", "", (*big.Int)(sendArgs.ValueIn)) bonderFeeIns, ok := h.bonderFee.Load(bonderKey) if !ok { return nil, ErrNoBonderFeeFound @@ -419,7 +421,7 @@ func (h *HopBridgeProcessor) sendOrBuildV2(sendArgs *wallettypes.SendTxArgs, sig } func (h *HopBridgeProcessor) Send(sendArgs *MultipathProcessorTxArgs, lastUsedNonce int64, verifiedAccount *account.SelectedExtKey) (hash types.Hash, nonce uint64, err error) { - tx, err := h.sendOrBuild(sendArgs, getSigner(sendArgs.HopTx.ChainID, sendArgs.HopTx.From, verifiedAccount), lastUsedNonce) + tx, err := h.sendOrBuild(sendArgs, utils.GetSigner(sendArgs.HopTx.ChainID, sendArgs.HopTx.From, verifiedAccount.AccountKey.PrivateKey), lastUsedNonce) if err != nil { return types.Hash{}, 0, createBridgeHopErrorResponse(err) } @@ -443,7 +445,7 @@ func (h *HopBridgeProcessor) BuildTransactionV2(sendArgs *wallettypes.SendTxArgs } func (h *HopBridgeProcessor) CalculateFees(params ProcessorInputParams) (*big.Int, *big.Int, error) { - bonderKey := makeKey(params.FromChain.ChainID, params.ToChain.ChainID, "", "", params.AmountIn) + bonderKey := pathProcessorCommon.MakeKey(params.FromChain.ChainID, params.ToChain.ChainID, "", "", params.AmountIn) if params.TestsMode { if val, ok := params.TestBonderFeeMap[params.FromToken.Symbol]; ok { res := new(big.Int).Sub(params.AmountIn, val) @@ -454,7 +456,7 @@ func (h *HopBridgeProcessor) CalculateFees(params ProcessorInputParams) (*big.In DestinationAmountOutMin: &bigint.BigInt{Int: res}, BonderFee: &bigint.BigInt{Int: val}, EstimatedRecieved: &bigint.BigInt{Int: res}, - Deadline: time.Now().Add(SevenDaysInSeconds).Unix(), + Deadline: time.Now().Add(pathProcessorCommon.SevenDaysInSeconds).Unix(), } h.bonderFee.Store(bonderKey, bonderFee) return val, walletCommon.ZeroBigIntValue(), nil @@ -508,7 +510,7 @@ func (h *HopBridgeProcessor) CalculateFees(params ProcessorInputParams) (*big.In } func (h *HopBridgeProcessor) CalculateAmountOut(params ProcessorInputParams) (*big.Int, error) { - bonderKey := makeKey(params.FromChain.ChainID, params.ToChain.ChainID, "", "", params.AmountIn) + bonderKey := pathProcessorCommon.MakeKey(params.FromChain.ChainID, params.ToChain.ChainID, "", "", params.AmountIn) bonderFeeIns, ok := h.bonderFee.Load(bonderKey) if !ok { return nil, ErrNoBonderFeeFound diff --git a/services/wallet/router/pathprocessor/processor_ens_public_key.go b/services/wallet/router/pathprocessor/processor_ens_public_key.go index f513b230f..d49fea77f 100644 --- a/services/wallet/router/pathprocessor/processor_ens_public_key.go +++ b/services/wallet/router/pathprocessor/processor_ens_public_key.go @@ -16,6 +16,7 @@ import ( "github.com/status-im/status-go/rpc" "github.com/status-im/status-go/services/ens/ensresolver" walletCommon "github.com/status-im/status-go/services/wallet/common" + pathProcessorCommon "github.com/status-im/status-go/services/wallet/router/pathprocessor/common" "github.com/status-im/status-go/services/wallet/wallettypes" "github.com/status-im/status-go/transactions" ) @@ -37,11 +38,11 @@ func NewENSPublicKeyProcessor(rpcClient *rpc.Client, transactor transactions.Tra } func createENSPublicKeyErrorResponse(err error) error { - return createErrorResponse(walletCommon.ProcessorENSPublicKeyName, err) + return createErrorResponse(pathProcessorCommon.ProcessorENSPublicKeyName, err) } func (s *ENSPublicKeyProcessor) Name() string { - return walletCommon.ProcessorENSPublicKeyName + return pathProcessorCommon.ProcessorENSPublicKeyName } func (s *ENSPublicKeyProcessor) AvailableFor(params ProcessorInputParams) (bool, error) { @@ -99,7 +100,7 @@ func (s *ENSPublicKeyProcessor) EstimateGas(params ProcessorInputParams) (uint64 return 0, createENSPublicKeyErrorResponse(err) } - increasedEstimation := float64(estimation) * IncreaseEstimatedGasFactor + increasedEstimation := float64(estimation) * pathProcessorCommon.IncreaseEstimatedGasFactor return uint64(increasedEstimation), nil } diff --git a/services/wallet/router/pathprocessor/processor_ens_register.go b/services/wallet/router/pathprocessor/processor_ens_register.go index 9a2b8ae34..8dfbaad90 100644 --- a/services/wallet/router/pathprocessor/processor_ens_register.go +++ b/services/wallet/router/pathprocessor/processor_ens_register.go @@ -18,6 +18,7 @@ import ( "github.com/status-im/status-go/rpc" "github.com/status-im/status-go/services/ens/ensresolver" walletCommon "github.com/status-im/status-go/services/wallet/common" + pathProcessorCommon "github.com/status-im/status-go/services/wallet/router/pathprocessor/common" "github.com/status-im/status-go/services/wallet/wallettypes" "github.com/status-im/status-go/transactions" ) @@ -39,11 +40,11 @@ func NewENSRegisterProcessor(rpcClient *rpc.Client, transactor transactions.Tran } func createENSRegisterProcessorErrorResponse(err error) error { - return createErrorResponse(walletCommon.ProcessorENSRegisterName, err) + return createErrorResponse(pathProcessorCommon.ProcessorENSRegisterName, err) } func (s *ENSRegisterProcessor) Name() string { - return walletCommon.ProcessorENSRegisterName + return pathProcessorCommon.ProcessorENSRegisterName } func (s *ENSRegisterProcessor) GetPriceForRegisteringEnsName(chainID uint64) (*big.Int, error) { @@ -135,7 +136,7 @@ func (s *ENSRegisterProcessor) EstimateGas(params ProcessorInputParams) (uint64, return 0, createENSRegisterProcessorErrorResponse(err) } - increasedEstimation := float64(estimation) * IncreaseEstimatedGasFactor + increasedEstimation := float64(estimation) * pathProcessorCommon.IncreaseEstimatedGasFactor return uint64(increasedEstimation), nil } diff --git a/services/wallet/router/pathprocessor/processor_ens_release.go b/services/wallet/router/pathprocessor/processor_ens_release.go index 88bdc2603..7d0dbdfee 100644 --- a/services/wallet/router/pathprocessor/processor_ens_release.go +++ b/services/wallet/router/pathprocessor/processor_ens_release.go @@ -16,6 +16,7 @@ import ( "github.com/status-im/status-go/rpc" "github.com/status-im/status-go/services/ens/ensresolver" walletCommon "github.com/status-im/status-go/services/wallet/common" + pathProcessorCommon "github.com/status-im/status-go/services/wallet/router/pathprocessor/common" "github.com/status-im/status-go/services/wallet/wallettypes" "github.com/status-im/status-go/transactions" ) @@ -37,11 +38,11 @@ func NewENSReleaseProcessor(rpcClient *rpc.Client, transactor transactions.Trans } func createENSReleaseErrorResponse(err error) error { - return createErrorResponse(walletCommon.ProcessorENSReleaseName, err) + return createErrorResponse(pathProcessorCommon.ProcessorENSReleaseName, err) } func (s *ENSReleaseProcessor) Name() string { - return walletCommon.ProcessorENSReleaseName + return pathProcessorCommon.ProcessorENSReleaseName } func (s *ENSReleaseProcessor) AvailableFor(params ProcessorInputParams) (bool, error) { @@ -58,7 +59,7 @@ func (s *ENSReleaseProcessor) PackTxInputData(params ProcessorInputParams) ([]by return []byte{}, createENSReleaseErrorResponse(err) } - name := getNameFromEnsUsername(params.Username) + name := pathProcessorCommon.GetNameFromEnsUsername(params.Username) return registrarABI.Pack("release", walletCommon.UsernameToLabel(name)) } @@ -99,7 +100,7 @@ func (s *ENSReleaseProcessor) EstimateGas(params ProcessorInputParams) (uint64, return 0, createENSReleaseErrorResponse(err) } - increasedEstimation := float64(estimation) * IncreaseEstimatedGasFactor + increasedEstimation := float64(estimation) * pathProcessorCommon.IncreaseEstimatedGasFactor return uint64(increasedEstimation), nil } diff --git a/services/wallet/router/pathprocessor/processor_erc1155.go b/services/wallet/router/pathprocessor/processor_erc1155.go index 912b1f3b4..9c5edfa14 100644 --- a/services/wallet/router/pathprocessor/processor_erc1155.go +++ b/services/wallet/router/pathprocessor/processor_erc1155.go @@ -15,7 +15,9 @@ import ( "github.com/status-im/status-go/contracts/ierc1155" "github.com/status-im/status-go/eth-node/types" "github.com/status-im/status-go/rpc" + "github.com/status-im/status-go/services/utils" walletCommon "github.com/status-im/status-go/services/wallet/common" + pathProcessorCommon "github.com/status-im/status-go/services/wallet/router/pathprocessor/common" "github.com/status-im/status-go/services/wallet/wallettypes" "github.com/status-im/status-go/transactions" ) @@ -37,11 +39,11 @@ func NewERC1155Processor(rpcClient *rpc.Client, transactor transactions.Transact } func createERC1155ErrorResponse(err error) error { - return createErrorResponse(walletCommon.ProcessorERC1155Name, err) + return createErrorResponse(pathProcessorCommon.ProcessorERC1155Name, err) } func (s *ERC1155Processor) Name() string { - return walletCommon.ProcessorERC1155Name + return pathProcessorCommon.ProcessorERC1155Name } func (s *ERC1155Processor) AvailableFor(params ProcessorInputParams) (bool, error) { @@ -105,7 +107,7 @@ func (s *ERC1155Processor) EstimateGas(params ProcessorInputParams) (uint64, err if err != nil { return 0, createERC1155ErrorResponse(err) } - increasedEstimation := float64(estimation) * IncreaseEstimatedGasFactor + increasedEstimation := float64(estimation) * pathProcessorCommon.IncreaseEstimatedGasFactor return uint64(increasedEstimation), nil } @@ -153,7 +155,7 @@ func (s *ERC1155Processor) sendOrBuild(sendArgs *MultipathProcessorTxArgs, signe } func (s *ERC1155Processor) Send(sendArgs *MultipathProcessorTxArgs, lastUsedNonce int64, verifiedAccount *account.SelectedExtKey) (hash types.Hash, usedNonce uint64, err error) { - tx, err := s.sendOrBuild(sendArgs, getSigner(sendArgs.ChainID, sendArgs.ERC1155TransferTx.From, verifiedAccount), lastUsedNonce) + tx, err := s.sendOrBuild(sendArgs, utils.GetSigner(sendArgs.ChainID, sendArgs.ERC1155TransferTx.From, verifiedAccount.AccountKey.PrivateKey), lastUsedNonce) if err != nil { return hash, 0, createERC1155ErrorResponse(err) } diff --git a/services/wallet/router/pathprocessor/processor_erc721.go b/services/wallet/router/pathprocessor/processor_erc721.go index 2cc9c8114..a436fe9b1 100644 --- a/services/wallet/router/pathprocessor/processor_erc721.go +++ b/services/wallet/router/pathprocessor/processor_erc721.go @@ -17,7 +17,9 @@ import ( "github.com/status-im/status-go/eth-node/types" "github.com/status-im/status-go/params" "github.com/status-im/status-go/rpc" + "github.com/status-im/status-go/services/utils" walletCommon "github.com/status-im/status-go/services/wallet/common" + pathProcessorCommon "github.com/status-im/status-go/services/wallet/router/pathprocessor/common" "github.com/status-im/status-go/services/wallet/token" "github.com/status-im/status-go/services/wallet/wallettypes" "github.com/status-im/status-go/transactions" @@ -44,11 +46,11 @@ func NewERC721Processor(rpcClient *rpc.Client, transactor transactions.Transacto } func createERC721ErrorResponse(err error) error { - return createErrorResponse(walletCommon.ProcessorERC721Name, err) + return createErrorResponse(pathProcessorCommon.ProcessorERC721Name, err) } func (s *ERC721Processor) Name() string { - return walletCommon.ProcessorERC721Name + return pathProcessorCommon.ProcessorERC721Name } func (s *ERC721Processor) AvailableFor(params ProcessorInputParams) (bool, error) { @@ -143,7 +145,7 @@ func (s *ERC721Processor) EstimateGas(params ProcessorInputParams) (uint64, erro return 0, createERC721ErrorResponse(err) } - increasedEstimation := float64(estimation) * IncreaseEstimatedGasFactor + increasedEstimation := float64(estimation) * pathProcessorCommon.IncreaseEstimatedGasFactor return uint64(increasedEstimation), nil } @@ -211,7 +213,7 @@ func (s *ERC721Processor) sendOrBuild(sendArgs *MultipathProcessorTxArgs, signer } func (s *ERC721Processor) Send(sendArgs *MultipathProcessorTxArgs, lastUsedNonce int64, verifiedAccount *account.SelectedExtKey) (hash types.Hash, usedNonce uint64, err error) { - tx, err := s.sendOrBuild(sendArgs, getSigner(sendArgs.ChainID, sendArgs.ERC721TransferTx.From, verifiedAccount), lastUsedNonce) + tx, err := s.sendOrBuild(sendArgs, utils.GetSigner(sendArgs.ChainID, sendArgs.ERC721TransferTx.From, verifiedAccount.AccountKey.PrivateKey), lastUsedNonce) if err != nil { return hash, 0, createERC721ErrorResponse(err) } diff --git a/services/wallet/router/pathprocessor/processor_stickers_buy.go b/services/wallet/router/pathprocessor/processor_stickers_buy.go index ed222a3bc..ddd1d8a0f 100644 --- a/services/wallet/router/pathprocessor/processor_stickers_buy.go +++ b/services/wallet/router/pathprocessor/processor_stickers_buy.go @@ -17,6 +17,7 @@ import ( "github.com/status-im/status-go/eth-node/types" "github.com/status-im/status-go/rpc" walletCommon "github.com/status-im/status-go/services/wallet/common" + pathProcessorCommon "github.com/status-im/status-go/services/wallet/router/pathprocessor/common" "github.com/status-im/status-go/services/wallet/wallettypes" "github.com/status-im/status-go/transactions" ) @@ -36,11 +37,11 @@ func NewStickersBuyProcessor(rpcClient *rpc.Client, transactor transactions.Tran } func createStickersBuyErrorResponse(err error) error { - return createErrorResponse(walletCommon.ProcessorStickersBuyName, err) + return createErrorResponse(pathProcessorCommon.ProcessorStickersBuyName, err) } func (s *StickersBuyProcessor) Name() string { - return walletCommon.ProcessorStickersBuyName + return pathProcessorCommon.ProcessorStickersBuyName } func (s *StickersBuyProcessor) AvailableFor(params ProcessorInputParams) (bool, error) { @@ -124,7 +125,7 @@ func (s *StickersBuyProcessor) EstimateGas(params ProcessorInputParams) (uint64, return 0, createStickersBuyErrorResponse(err) } - increasedEstimation := float64(estimation) * IncreaseEstimatedGasFactor + increasedEstimation := float64(estimation) * pathProcessorCommon.IncreaseEstimatedGasFactor return uint64(increasedEstimation), nil } diff --git a/services/wallet/router/pathprocessor/processor_swap_paraswap.go b/services/wallet/router/pathprocessor/processor_swap_paraswap.go index 691a9fc8f..9ceb94c4d 100644 --- a/services/wallet/router/pathprocessor/processor_swap_paraswap.go +++ b/services/wallet/router/pathprocessor/processor_swap_paraswap.go @@ -13,6 +13,7 @@ import ( "github.com/status-im/status-go/eth-node/types" "github.com/status-im/status-go/rpc" walletCommon "github.com/status-im/status-go/services/wallet/common" + pathProcessorCommon "github.com/status-im/status-go/services/wallet/router/pathprocessor/common" "github.com/status-im/status-go/services/wallet/thirdparty/paraswap" walletToken "github.com/status-im/status-go/services/wallet/token" "github.com/status-im/status-go/services/wallet/wallettypes" @@ -77,11 +78,11 @@ func createSwapParaswapErrorResponse(err error) error { case "ESTIMATED_LOSS_GREATER_THAN_MAX_IMPACT": return ErrPriceImpactTooHigh } - return createErrorResponse(walletCommon.ProcessorSwapParaswapName, err) + return createErrorResponse(pathProcessorCommon.ProcessorSwapParaswapName, err) } func (s *SwapParaswapProcessor) Name() string { - return walletCommon.ProcessorSwapParaswapName + return pathProcessorCommon.ProcessorSwapParaswapName } func (s *SwapParaswapProcessor) Clear() { @@ -191,14 +192,14 @@ func (s *SwapParaswapProcessor) EstimateGas(params ProcessorInputParams) (uint64 return 0, createSwapParaswapErrorResponse(err) } - key := makeKey(params.FromChain.ChainID, params.ToChain.ChainID, params.FromToken.Symbol, params.ToToken.Symbol, params.AmountIn) + key := pathProcessorCommon.MakeKey(params.FromChain.ChainID, params.ToChain.ChainID, params.FromToken.Symbol, params.ToToken.Symbol, params.AmountIn) s.priceRoute.Store(key, &priceRoute) return priceRoute.GasCost.Uint64(), nil } func (s *SwapParaswapProcessor) GetContractAddress(params ProcessorInputParams) (address common.Address, err error) { - key := makeKey(params.FromChain.ChainID, params.ToChain.ChainID, params.FromToken.Symbol, params.ToToken.Symbol, params.AmountIn) + key := pathProcessorCommon.MakeKey(params.FromChain.ChainID, params.ToChain.ChainID, params.FromToken.Symbol, params.ToToken.Symbol, params.AmountIn) priceRouteIns, ok := s.priceRoute.Load(key) if !ok { err = ErrPriceRouteNotFound @@ -213,7 +214,7 @@ func (s *SwapParaswapProcessor) GetContractAddress(params ProcessorInputParams) func (s *SwapParaswapProcessor) prepareTransaction(sendArgs *MultipathProcessorTxArgs) error { slippageBP := uint(sendArgs.SwapTx.SlippagePercentage * 100) // convert to basis points - key := makeKey(sendArgs.SwapTx.ChainID, sendArgs.SwapTx.ChainIDTo, sendArgs.SwapTx.TokenIDFrom, sendArgs.SwapTx.TokenIDTo, sendArgs.SwapTx.ValueIn.ToInt()) + key := pathProcessorCommon.MakeKey(sendArgs.SwapTx.ChainID, sendArgs.SwapTx.ChainIDTo, sendArgs.SwapTx.TokenIDFrom, sendArgs.SwapTx.TokenIDTo, sendArgs.SwapTx.ValueIn.ToInt()) priceRouteIns, ok := s.priceRoute.Load(key) if !ok { return ErrPriceRouteNotFound @@ -259,7 +260,7 @@ func (s *SwapParaswapProcessor) prepareTransaction(sendArgs *MultipathProcessorT func (s *SwapParaswapProcessor) prepareTransactionV2(sendArgs *wallettypes.SendTxArgs) error { slippageBP := uint(sendArgs.SlippagePercentage * 100) // convert to basis points - key := makeKey(sendArgs.FromChainID, sendArgs.ToChainID, sendArgs.FromTokenID, sendArgs.ToTokenID, sendArgs.ValueIn.ToInt()) + key := pathProcessorCommon.MakeKey(sendArgs.FromChainID, sendArgs.ToChainID, sendArgs.FromTokenID, sendArgs.ToTokenID, sendArgs.ValueIn.ToInt()) priceRouteIns, ok := s.priceRoute.Load(key) if !ok { return ErrPriceRouteNotFound @@ -327,7 +328,7 @@ func (s *SwapParaswapProcessor) Send(sendArgs *MultipathProcessorTxArgs, lastUse } func (s *SwapParaswapProcessor) CalculateAmountOut(params ProcessorInputParams) (*big.Int, error) { - key := makeKey(params.FromChain.ChainID, params.ToChain.ChainID, params.FromToken.Symbol, params.ToToken.Symbol, params.AmountIn) + key := pathProcessorCommon.MakeKey(params.FromChain.ChainID, params.ToChain.ChainID, params.FromToken.Symbol, params.ToToken.Symbol, params.AmountIn) priceRouteIns, ok := s.priceRoute.Load(key) if !ok { return nil, ErrPriceRouteNotFound diff --git a/services/wallet/router/pathprocessor/processor_swap_paraswap_test.go b/services/wallet/router/pathprocessor/processor_swap_paraswap_test.go index ae4593e00..63d088d3f 100644 --- a/services/wallet/router/pathprocessor/processor_swap_paraswap_test.go +++ b/services/wallet/router/pathprocessor/processor_swap_paraswap_test.go @@ -12,6 +12,7 @@ import ( "github.com/status-im/status-go/params" "github.com/status-im/status-go/services/wallet/bigint" walletCommon "github.com/status-im/status-go/services/wallet/common" + pathProcessorCommon "github.com/status-im/status-go/services/wallet/router/pathprocessor/common" "github.com/status-im/status-go/services/wallet/thirdparty/paraswap" mock_paraswap "github.com/status-im/status-go/services/wallet/thirdparty/paraswap/mock" "github.com/status-im/status-go/services/wallet/token" @@ -44,7 +45,7 @@ func TestParaswapWithPartnerFee(t *testing.T) { chainIDs := []uint64{walletCommon.EthereumMainnet, walletCommon.ArbitrumMainnet, walletCommon.OptimismMainnet, walletCommon.UnknownChainID} for _, chainID := range chainIDs { - key := makeKey(chainID, chainID, fromToken.Symbol, toToken.Symbol, testPriceRoute.SrcAmount.Int) + key := pathProcessorCommon.MakeKey(chainID, chainID, fromToken.Symbol, toToken.Symbol, testPriceRoute.SrcAmount.Int) processor.priceRoute.Store(key, testPriceRoute) testInputParams := ProcessorInputParams{ diff --git a/services/wallet/router/pathprocessor/processor_test.go b/services/wallet/router/pathprocessor/processor_test.go index 596ca6dd6..049da1210 100644 --- a/services/wallet/router/pathprocessor/processor_test.go +++ b/services/wallet/router/pathprocessor/processor_test.go @@ -7,6 +7,7 @@ import ( "github.com/status-im/status-go/params" walletCommon "github.com/status-im/status-go/services/wallet/common" "github.com/status-im/status-go/services/wallet/requests" + pathProcessorCommon "github.com/status-im/status-go/services/wallet/router/pathprocessor/common" "github.com/status-im/status-go/services/wallet/token" "github.com/stretchr/testify/assert" @@ -45,9 +46,9 @@ var optimism = params.Network{ } var testEstimationMap = map[string]requests.Estimation{ - walletCommon.ProcessorTransferName: {Value: uint64(1000)}, - walletCommon.ProcessorBridgeHopName: {Value: uint64(5000)}, - walletCommon.ProcessorSwapParaswapName: {Value: uint64(2000)}, + pathProcessorCommon.ProcessorTransferName: {Value: uint64(1000)}, + pathProcessorCommon.ProcessorBridgeHopName: {Value: uint64(5000)}, + pathProcessorCommon.ProcessorSwapParaswapName: {Value: uint64(2000)}, } type expectedResult struct { @@ -68,15 +69,15 @@ func TestPathProcessors(t *testing.T) { TestsMode: true, }, expected: map[string]expectedResult{ - walletCommon.ProcessorTransferName: { + pathProcessorCommon.ProcessorTransferName: { expected: false, expectedError: ErrNoChainSet, }, - walletCommon.ProcessorBridgeHopName: { + pathProcessorCommon.ProcessorBridgeHopName: { expected: false, expectedError: ErrNoChainSet, }, - walletCommon.ProcessorSwapParaswapName: { + pathProcessorCommon.ProcessorSwapParaswapName: { expected: false, expectedError: ErrNoChainSet, }, @@ -91,15 +92,15 @@ func TestPathProcessors(t *testing.T) { TestEstimationMap: testEstimationMap, }, expected: map[string]expectedResult{ - walletCommon.ProcessorTransferName: { + pathProcessorCommon.ProcessorTransferName: { expected: false, expectedError: ErrNoTokenSet, }, - walletCommon.ProcessorBridgeHopName: { + pathProcessorCommon.ProcessorBridgeHopName: { expected: false, expectedError: ErrNoTokenSet, }, - walletCommon.ProcessorSwapParaswapName: { + pathProcessorCommon.ProcessorSwapParaswapName: { expected: false, expectedError: ErrToAndFromTokensMustBeSet, }, @@ -117,15 +118,15 @@ func TestPathProcessors(t *testing.T) { TestEstimationMap: testEstimationMap, }, expected: map[string]expectedResult{ - walletCommon.ProcessorTransferName: { + pathProcessorCommon.ProcessorTransferName: { expected: true, expectedError: nil, }, - walletCommon.ProcessorBridgeHopName: { + pathProcessorCommon.ProcessorBridgeHopName: { expected: false, expectedError: ErrFromAndToChainsMustBeDifferent, }, - walletCommon.ProcessorSwapParaswapName: { + pathProcessorCommon.ProcessorSwapParaswapName: { expected: false, expectedError: ErrToAndFromTokensMustBeSet, }, @@ -146,15 +147,15 @@ func TestPathProcessors(t *testing.T) { TestEstimationMap: testEstimationMap, }, expected: map[string]expectedResult{ - walletCommon.ProcessorTransferName: { + pathProcessorCommon.ProcessorTransferName: { expected: false, expectedError: ErrToTokenShouldNotBeSet, }, - walletCommon.ProcessorBridgeHopName: { + pathProcessorCommon.ProcessorBridgeHopName: { expected: false, expectedError: ErrToTokenShouldNotBeSet, }, - walletCommon.ProcessorSwapParaswapName: { + pathProcessorCommon.ProcessorSwapParaswapName: { expected: false, expectedError: ErrFromAndToTokensMustBeDifferent, }, @@ -175,15 +176,15 @@ func TestPathProcessors(t *testing.T) { TestEstimationMap: testEstimationMap, }, expected: map[string]expectedResult{ - walletCommon.ProcessorTransferName: { + pathProcessorCommon.ProcessorTransferName: { expected: false, expectedError: ErrToTokenShouldNotBeSet, }, - walletCommon.ProcessorBridgeHopName: { + pathProcessorCommon.ProcessorBridgeHopName: { expected: false, expectedError: ErrToTokenShouldNotBeSet, }, - walletCommon.ProcessorSwapParaswapName: { + pathProcessorCommon.ProcessorSwapParaswapName: { expected: true, expectedError: nil, }, @@ -198,15 +199,15 @@ func TestPathProcessors(t *testing.T) { TestEstimationMap: testEstimationMap, }, expected: map[string]expectedResult{ - walletCommon.ProcessorTransferName: { + pathProcessorCommon.ProcessorTransferName: { expected: false, expectedError: ErrNoTokenSet, }, - walletCommon.ProcessorBridgeHopName: { + pathProcessorCommon.ProcessorBridgeHopName: { expected: false, expectedError: ErrNoTokenSet, }, - walletCommon.ProcessorSwapParaswapName: { + pathProcessorCommon.ProcessorSwapParaswapName: { expected: false, expectedError: ErrFromAndToChainsMustBeSame, }, @@ -224,15 +225,15 @@ func TestPathProcessors(t *testing.T) { TestEstimationMap: testEstimationMap, }, expected: map[string]expectedResult{ - walletCommon.ProcessorTransferName: { + pathProcessorCommon.ProcessorTransferName: { expected: false, expectedError: nil, }, - walletCommon.ProcessorBridgeHopName: { + pathProcessorCommon.ProcessorBridgeHopName: { expected: true, expectedError: nil, }, - walletCommon.ProcessorSwapParaswapName: { + pathProcessorCommon.ProcessorSwapParaswapName: { expected: false, expectedError: ErrFromAndToChainsMustBeSame, }, @@ -253,15 +254,15 @@ func TestPathProcessors(t *testing.T) { TestEstimationMap: testEstimationMap, }, expected: map[string]expectedResult{ - walletCommon.ProcessorTransferName: { + pathProcessorCommon.ProcessorTransferName: { expected: false, expectedError: ErrToTokenShouldNotBeSet, }, - walletCommon.ProcessorBridgeHopName: { + pathProcessorCommon.ProcessorBridgeHopName: { expected: false, expectedError: ErrToTokenShouldNotBeSet, }, - walletCommon.ProcessorSwapParaswapName: { + pathProcessorCommon.ProcessorSwapParaswapName: { expected: false, expectedError: ErrFromAndToChainsMustBeSame, }, @@ -282,15 +283,15 @@ func TestPathProcessors(t *testing.T) { TestEstimationMap: testEstimationMap, }, expected: map[string]expectedResult{ - walletCommon.ProcessorTransferName: { + pathProcessorCommon.ProcessorTransferName: { expected: false, expectedError: ErrToTokenShouldNotBeSet, }, - walletCommon.ProcessorBridgeHopName: { + pathProcessorCommon.ProcessorBridgeHopName: { expected: false, expectedError: ErrToTokenShouldNotBeSet, }, - walletCommon.ProcessorSwapParaswapName: { + pathProcessorCommon.ProcessorSwapParaswapName: { expected: false, expectedError: ErrFromAndToChainsMustBeSame, }, @@ -303,11 +304,11 @@ func TestPathProcessors(t *testing.T) { t.Run(fmt.Sprintf("%s[%s]", processorName, tt.name), func(t *testing.T) { var processor PathProcessor - if processorName == walletCommon.ProcessorTransferName { + if processorName == pathProcessorCommon.ProcessorTransferName { processor = NewTransferProcessor(nil, nil) - } else if processorName == walletCommon.ProcessorBridgeHopName { + } else if processorName == pathProcessorCommon.ProcessorBridgeHopName { processor = NewHopBridgeProcessor(nil, nil, nil, nil) - } else if processorName == walletCommon.ProcessorSwapParaswapName { + } else if processorName == pathProcessorCommon.ProcessorSwapParaswapName { processor = NewSwapParaswapProcessor(nil, nil, nil) } diff --git a/services/wallet/router/pathprocessor/processor_transfer.go b/services/wallet/router/pathprocessor/processor_transfer.go index 52583efbd..0f1f13de3 100644 --- a/services/wallet/router/pathprocessor/processor_transfer.go +++ b/services/wallet/router/pathprocessor/processor_transfer.go @@ -14,6 +14,7 @@ import ( "github.com/status-im/status-go/eth-node/types" "github.com/status-im/status-go/rpc" walletCommon "github.com/status-im/status-go/services/wallet/common" + pathProcessorCommon "github.com/status-im/status-go/services/wallet/router/pathprocessor/common" "github.com/status-im/status-go/services/wallet/wallettypes" "github.com/status-im/status-go/transactions" ) @@ -28,11 +29,11 @@ func NewTransferProcessor(rpcClient *rpc.Client, transactor transactions.Transac } func createTransferErrorResponse(err error) error { - return createErrorResponse(walletCommon.ProcessorTransferName, err) + return createErrorResponse(pathProcessorCommon.ProcessorTransferName, err) } func (s *TransferProcessor) Name() string { - return walletCommon.ProcessorTransferName + return pathProcessorCommon.ProcessorTransferName } func (s *TransferProcessor) AvailableFor(params ProcessorInputParams) (bool, error) { @@ -111,7 +112,7 @@ func (s *TransferProcessor) EstimateGas(params ProcessorInputParams) (uint64, er } - increasedEstimation := float64(estimation) * IncreaseEstimatedGasFactor + increasedEstimation := float64(estimation) * pathProcessorCommon.IncreaseEstimatedGasFactor return uint64(increasedEstimation), nil } diff --git a/services/wallet/router/router.go b/services/wallet/router/router.go index 85a44343e..3cff0162e 100644 --- a/services/wallet/router/router.go +++ b/services/wallet/router/router.go @@ -24,6 +24,7 @@ import ( "github.com/status-im/status-go/services/wallet/responses" "github.com/status-im/status-go/services/wallet/router/fees" "github.com/status-im/status-go/services/wallet/router/pathprocessor" + pathProcessorCommon "github.com/status-im/status-go/services/wallet/router/pathprocessor/common" "github.com/status-im/status-go/services/wallet/router/routes" "github.com/status-im/status-go/services/wallet/router/sendtype" "github.com/status-im/status-go/services/wallet/token" @@ -840,7 +841,7 @@ func (r *Router) checkBalancesForTheBestRoute(ctx context.Context, bestRoute rou } } - if path.ProcessorName == walletCommon.ProcessorBridgeHopName { + if path.ProcessorName == pathProcessorCommon.ProcessorBridgeHopName { if path.TxBonderFees.ToInt().Cmp(path.AmountOut.ToInt()) > 0 { return hasPositiveBalance, ErrLowAmountInForHopBridge } diff --git a/services/wallet/router/router_test_data.go b/services/wallet/router/router_test_data.go index 61899bb24..d30e437b9 100644 --- a/services/wallet/router/router_test_data.go +++ b/services/wallet/router/router_test_data.go @@ -14,6 +14,7 @@ import ( walletCommon "github.com/status-im/status-go/services/wallet/common" "github.com/status-im/status-go/services/wallet/requests" "github.com/status-im/status-go/services/wallet/router/fees" + pathProcessorCommon "github.com/status-im/status-go/services/wallet/router/pathprocessor/common" "github.com/status-im/status-go/services/wallet/router/routes" "github.com/status-im/status-go/services/wallet/router/sendtype" "github.com/status-im/status-go/services/wallet/token" @@ -51,8 +52,8 @@ const ( var ( testEstimationMap = map[string]requests.Estimation{ - walletCommon.ProcessorTransferName: {Value: uint64(1000), Err: nil}, - walletCommon.ProcessorBridgeHopName: {Value: uint64(5000), Err: nil}, + pathProcessorCommon.ProcessorTransferName: {Value: uint64(1000), Err: nil}, + pathProcessorCommon.ProcessorBridgeHopName: {Value: uint64(5000), Err: nil}, } testBBonderFeeMap = map[string]*big.Int{ @@ -188,7 +189,7 @@ func getNormalTestParamsList() []normalTestParams { SuggestedFees: testSuggestedFees, BalanceMap: testBalanceMapPerChain, EstimationMap: map[string]requests.Estimation{ - walletCommon.ProcessorTransferName: { + pathProcessorCommon.ProcessorTransferName: { Value: uint64(0), Err: fmt.Errorf("failed with 50000000 gas: insufficient funds for gas * price + value: address %s have 68251537427723 want 100000000000000", common.HexToAddress("0x1")), }, @@ -233,19 +234,19 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: walletCommon.ProcessorTransferName, + ProcessorName: pathProcessorCommon.ProcessorTransferName, FromChain: &mainnet, ToChain: &mainnet, ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorTransferName, + ProcessorName: pathProcessorCommon.ProcessorTransferName, FromChain: &optimism, ToChain: &optimism, ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorTransferName, + ProcessorName: pathProcessorCommon.ProcessorTransferName, FromChain: &arbitrum, ToChain: &arbitrum, ApprovalRequired: false, @@ -281,55 +282,55 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: walletCommon.ProcessorTransferName, + ProcessorName: pathProcessorCommon.ProcessorTransferName, FromChain: &mainnet, ToChain: &mainnet, ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorTransferName, + ProcessorName: pathProcessorCommon.ProcessorTransferName, FromChain: &optimism, ToChain: &optimism, ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorTransferName, + ProcessorName: pathProcessorCommon.ProcessorTransferName, FromChain: &arbitrum, ToChain: &arbitrum, ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &mainnet, ToChain: &optimism, ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &mainnet, ToChain: &arbitrum, ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &optimism, ToChain: &mainnet, ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &optimism, ToChain: &arbitrum, ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &mainnet, ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &optimism, ApprovalRequired: false, @@ -367,19 +368,19 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: walletCommon.ProcessorTransferName, + ProcessorName: pathProcessorCommon.ProcessorTransferName, FromChain: &mainnet, ToChain: &mainnet, ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &optimism, ToChain: &mainnet, ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &mainnet, ApprovalRequired: false, @@ -417,37 +418,37 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: walletCommon.ProcessorTransferName, + ProcessorName: pathProcessorCommon.ProcessorTransferName, FromChain: &optimism, ToChain: &optimism, ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorTransferName, + ProcessorName: pathProcessorCommon.ProcessorTransferName, FromChain: &arbitrum, ToChain: &arbitrum, ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &mainnet, ToChain: &optimism, ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &mainnet, ToChain: &arbitrum, ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &optimism, ToChain: &arbitrum, ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &optimism, ApprovalRequired: false, @@ -486,19 +487,19 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: walletCommon.ProcessorTransferName, + ProcessorName: pathProcessorCommon.ProcessorTransferName, FromChain: &arbitrum, ToChain: &arbitrum, ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &mainnet, ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &optimism, ApprovalRequired: false, @@ -536,37 +537,37 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: walletCommon.ProcessorTransferName, + ProcessorName: pathProcessorCommon.ProcessorTransferName, FromChain: &optimism, ToChain: &optimism, ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorTransferName, + ProcessorName: pathProcessorCommon.ProcessorTransferName, FromChain: &arbitrum, ToChain: &arbitrum, ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &optimism, ToChain: &mainnet, ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &optimism, ToChain: &arbitrum, ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &mainnet, ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &optimism, ApprovalRequired: false, @@ -605,7 +606,7 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: walletCommon.ProcessorTransferName, + ProcessorName: pathProcessorCommon.ProcessorTransferName, FromChain: &arbitrum, ToChain: &arbitrum, ApprovalRequired: false, @@ -644,7 +645,7 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &mainnet, ApprovalRequired: false, @@ -683,7 +684,7 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: walletCommon.ProcessorTransferName, + ProcessorName: pathProcessorCommon.ProcessorTransferName, FromChain: &arbitrum, ToChain: &arbitrum, ApprovalRequired: false, @@ -722,25 +723,25 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: walletCommon.ProcessorTransferName, + ProcessorName: pathProcessorCommon.ProcessorTransferName, FromChain: &mainnet, ToChain: &mainnet, ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorTransferName, + ProcessorName: pathProcessorCommon.ProcessorTransferName, FromChain: &arbitrum, ToChain: &arbitrum, ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &mainnet, ToChain: &arbitrum, ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &mainnet, ApprovalRequired: false, @@ -779,7 +780,7 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &mainnet, ApprovalRequired: false, @@ -853,63 +854,63 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: walletCommon.ProcessorTransferName, + ProcessorName: pathProcessorCommon.ProcessorTransferName, FromChain: &mainnet, ToChain: &mainnet, AmountOut: (*hexutil.Big)(big.NewInt(testAmount0Point2ETHInWei)), ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorTransferName, + ProcessorName: pathProcessorCommon.ProcessorTransferName, FromChain: &optimism, ToChain: &optimism, AmountOut: (*hexutil.Big)(big.NewInt(testAmount0Point8ETHInWei)), ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorTransferName, + ProcessorName: pathProcessorCommon.ProcessorTransferName, FromChain: &arbitrum, ToChain: &arbitrum, AmountOut: (*hexutil.Big)(big.NewInt(testAmount0Point8ETHInWei)), ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &mainnet, ToChain: &optimism, AmountOut: (*hexutil.Big)(big.NewInt(testAmount0Point2ETHInWei - testBonderFeeETH)), ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &mainnet, ToChain: &arbitrum, AmountOut: (*hexutil.Big)(big.NewInt(testAmount0Point2ETHInWei - testBonderFeeETH)), ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &optimism, ToChain: &mainnet, AmountOut: (*hexutil.Big)(big.NewInt(testAmount0Point8ETHInWei - testBonderFeeETH)), ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &optimism, ToChain: &arbitrum, AmountOut: (*hexutil.Big)(big.NewInt(testAmount0Point8ETHInWei - testBonderFeeETH)), ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &mainnet, AmountOut: (*hexutil.Big)(big.NewInt(testAmount0Point8ETHInWei - testBonderFeeETH)), ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &optimism, AmountOut: (*hexutil.Big)(big.NewInt(testAmount0Point8ETHInWei - testBonderFeeETH)), @@ -952,21 +953,21 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: walletCommon.ProcessorTransferName, + ProcessorName: pathProcessorCommon.ProcessorTransferName, FromChain: &optimism, ToChain: &optimism, AmountOut: (*hexutil.Big)(big.NewInt(testAmount1ETHInWei - testAmount0Point2ETHInWei - testAmount0Point3ETHInWei)), ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &mainnet, ToChain: &optimism, AmountOut: (*hexutil.Big)(big.NewInt(testAmount0Point2ETHInWei - testBonderFeeETH)), //(*hexutil.Big)(big.NewInt(testAmount0Point2ETHInWei)), //(big.NewInt(testAmount0Point2ETHInWei - testBonderFeeETH)), ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &optimism, AmountOut: (*hexutil.Big)(big.NewInt(testAmount0Point3ETHInWei - testBonderFeeETH)), //(*hexutil.Big)(big.NewInt(testAmount0Point3ETHInWei)), @@ -1008,63 +1009,63 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: walletCommon.ProcessorTransferName, + ProcessorName: pathProcessorCommon.ProcessorTransferName, FromChain: &mainnet, ToChain: &mainnet, AmountOut: (*hexutil.Big)(big.NewInt(testAmount0Point2ETHInWei)), ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorTransferName, + ProcessorName: pathProcessorCommon.ProcessorTransferName, FromChain: &optimism, ToChain: &optimism, AmountOut: (*hexutil.Big)(big.NewInt(testAmount0Point3ETHInWei)), ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorTransferName, + ProcessorName: pathProcessorCommon.ProcessorTransferName, FromChain: &arbitrum, ToChain: &arbitrum, AmountOut: (*hexutil.Big)(big.NewInt(testAmount0Point5ETHInWei)), ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &mainnet, ToChain: &optimism, AmountOut: (*hexutil.Big)(big.NewInt(testAmount0Point2ETHInWei - testBonderFeeETH)), ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &mainnet, ToChain: &arbitrum, AmountOut: (*hexutil.Big)(big.NewInt(testAmount0Point2ETHInWei - testBonderFeeETH)), ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &optimism, ToChain: &mainnet, AmountOut: (*hexutil.Big)(big.NewInt(testAmount0Point3ETHInWei - testBonderFeeETH)), ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &optimism, ToChain: &arbitrum, AmountOut: (*hexutil.Big)(big.NewInt(testAmount0Point3ETHInWei - testBonderFeeETH)), ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &mainnet, AmountOut: (*hexutil.Big)(big.NewInt(testAmount0Point5ETHInWei - testBonderFeeETH)), ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &optimism, AmountOut: (*hexutil.Big)(big.NewInt(testAmount0Point5ETHInWei - testBonderFeeETH)), @@ -1107,63 +1108,63 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: walletCommon.ProcessorTransferName, + ProcessorName: pathProcessorCommon.ProcessorTransferName, FromChain: &mainnet, ToChain: &mainnet, AmountOut: (*hexutil.Big)(big.NewInt(testAmount0Point2ETHInWei)), ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorTransferName, + ProcessorName: pathProcessorCommon.ProcessorTransferName, FromChain: &optimism, ToChain: &optimism, AmountOut: (*hexutil.Big)(big.NewInt(testAmount0Point3ETHInWei)), ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorTransferName, + ProcessorName: pathProcessorCommon.ProcessorTransferName, FromChain: &arbitrum, ToChain: &arbitrum, AmountOut: (*hexutil.Big)(big.NewInt(testAmount0Point5ETHInWei)), ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &mainnet, ToChain: &optimism, AmountOut: (*hexutil.Big)(big.NewInt(testAmount0Point2ETHInWei - testBonderFeeETH)), ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &mainnet, ToChain: &arbitrum, AmountOut: (*hexutil.Big)(big.NewInt(testAmount0Point2ETHInWei - testBonderFeeETH)), ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &optimism, ToChain: &mainnet, AmountOut: (*hexutil.Big)(big.NewInt(testAmount0Point3ETHInWei - testBonderFeeETH)), ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &optimism, ToChain: &arbitrum, AmountOut: (*hexutil.Big)(big.NewInt(testAmount0Point3ETHInWei - testBonderFeeETH)), ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &mainnet, AmountOut: (*hexutil.Big)(big.NewInt(testAmount0Point5ETHInWei - testBonderFeeETH)), ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &optimism, AmountOut: (*hexutil.Big)(big.NewInt(testAmount0Point5ETHInWei - testBonderFeeETH)), @@ -1272,55 +1273,55 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: walletCommon.ProcessorTransferName, + ProcessorName: pathProcessorCommon.ProcessorTransferName, FromChain: &mainnet, ToChain: &mainnet, ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorTransferName, + ProcessorName: pathProcessorCommon.ProcessorTransferName, FromChain: &optimism, ToChain: &optimism, ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorTransferName, + ProcessorName: pathProcessorCommon.ProcessorTransferName, FromChain: &arbitrum, ToChain: &arbitrum, ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &mainnet, ToChain: &optimism, ApprovalRequired: true, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &mainnet, ToChain: &arbitrum, ApprovalRequired: true, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &optimism, ToChain: &mainnet, ApprovalRequired: true, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &optimism, ToChain: &arbitrum, ApprovalRequired: true, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &mainnet, ApprovalRequired: true, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &optimism, ApprovalRequired: true, @@ -1358,19 +1359,19 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: walletCommon.ProcessorTransferName, + ProcessorName: pathProcessorCommon.ProcessorTransferName, FromChain: &mainnet, ToChain: &mainnet, ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &optimism, ToChain: &mainnet, ApprovalRequired: true, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &mainnet, ApprovalRequired: true, @@ -1408,37 +1409,37 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: walletCommon.ProcessorTransferName, + ProcessorName: pathProcessorCommon.ProcessorTransferName, FromChain: &optimism, ToChain: &optimism, ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorTransferName, + ProcessorName: pathProcessorCommon.ProcessorTransferName, FromChain: &arbitrum, ToChain: &arbitrum, ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &mainnet, ToChain: &optimism, ApprovalRequired: true, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &mainnet, ToChain: &arbitrum, ApprovalRequired: true, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &optimism, ToChain: &arbitrum, ApprovalRequired: true, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &optimism, ApprovalRequired: true, @@ -1476,19 +1477,19 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: walletCommon.ProcessorTransferName, + ProcessorName: pathProcessorCommon.ProcessorTransferName, FromChain: &arbitrum, ToChain: &arbitrum, ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &mainnet, ApprovalRequired: true, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &optimism, ApprovalRequired: true, @@ -1526,37 +1527,37 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: walletCommon.ProcessorTransferName, + ProcessorName: pathProcessorCommon.ProcessorTransferName, FromChain: &optimism, ToChain: &optimism, ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorTransferName, + ProcessorName: pathProcessorCommon.ProcessorTransferName, FromChain: &arbitrum, ToChain: &arbitrum, ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &optimism, ToChain: &mainnet, ApprovalRequired: true, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &optimism, ToChain: &arbitrum, ApprovalRequired: true, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &mainnet, ApprovalRequired: true, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &optimism, ApprovalRequired: true, @@ -1595,7 +1596,7 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: walletCommon.ProcessorTransferName, + ProcessorName: pathProcessorCommon.ProcessorTransferName, FromChain: &arbitrum, ToChain: &arbitrum, ApprovalRequired: false, @@ -1634,7 +1635,7 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &mainnet, ApprovalRequired: true, @@ -1673,7 +1674,7 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: walletCommon.ProcessorTransferName, + ProcessorName: pathProcessorCommon.ProcessorTransferName, FromChain: &arbitrum, ToChain: &arbitrum, ApprovalRequired: false, @@ -1712,25 +1713,25 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: walletCommon.ProcessorTransferName, + ProcessorName: pathProcessorCommon.ProcessorTransferName, FromChain: &mainnet, ToChain: &mainnet, ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorTransferName, + ProcessorName: pathProcessorCommon.ProcessorTransferName, FromChain: &arbitrum, ToChain: &arbitrum, ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &mainnet, ToChain: &arbitrum, ApprovalRequired: true, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &mainnet, ApprovalRequired: true, @@ -1769,7 +1770,7 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &mainnet, ApprovalRequired: true, @@ -1839,168 +1840,168 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: walletCommon.ProcessorTransferName, + ProcessorName: pathProcessorCommon.ProcessorTransferName, FromChain: &mainnet, ToChain: &mainnet, AmountOut: (*hexutil.Big)(big.NewInt(2.5 * testAmount100USDC)), ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorTransferName, + ProcessorName: pathProcessorCommon.ProcessorTransferName, FromChain: &mainnet, ToChain: &mainnet, AmountOut: (*hexutil.Big)(big.NewInt(testAmount100USDC)), ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &mainnet, ToChain: &optimism, AmountOut: (*hexutil.Big)(big.NewInt(2.5*testAmount100USDC - testBonderFeeUSDC)), ApprovalRequired: true, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &mainnet, ToChain: &optimism, AmountOut: (*hexutil.Big)(big.NewInt(testAmount100USDC - testBonderFeeUSDC)), ApprovalRequired: true, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &mainnet, ToChain: &arbitrum, AmountOut: (*hexutil.Big)(big.NewInt(2.5*testAmount100USDC - testBonderFeeUSDC)), ApprovalRequired: true, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &mainnet, ToChain: &arbitrum, AmountOut: (*hexutil.Big)(big.NewInt(testAmount100USDC - testBonderFeeUSDC)), ApprovalRequired: true, }, { - ProcessorName: walletCommon.ProcessorTransferName, + ProcessorName: pathProcessorCommon.ProcessorTransferName, FromChain: &optimism, ToChain: &optimism, AmountOut: (*hexutil.Big)(big.NewInt(0.5 * testAmount100USDC)), ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorTransferName, + ProcessorName: pathProcessorCommon.ProcessorTransferName, FromChain: &optimism, ToChain: &optimism, AmountOut: (*hexutil.Big)(big.NewInt(testAmount100USDC)), ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorTransferName, + ProcessorName: pathProcessorCommon.ProcessorTransferName, FromChain: &optimism, ToChain: &optimism, AmountOut: (*hexutil.Big)(big.NewInt(2.5 * testAmount100USDC)), ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &optimism, ToChain: &mainnet, AmountOut: (*hexutil.Big)(big.NewInt(0.5*testAmount100USDC - testBonderFeeUSDC)), ApprovalRequired: true, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &optimism, ToChain: &mainnet, AmountOut: (*hexutil.Big)(big.NewInt(testAmount100USDC - testBonderFeeUSDC)), ApprovalRequired: true, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &optimism, ToChain: &mainnet, AmountOut: (*hexutil.Big)(big.NewInt(2.5*testAmount100USDC - testBonderFeeUSDC)), ApprovalRequired: true, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &optimism, ToChain: &arbitrum, AmountOut: (*hexutil.Big)(big.NewInt(0.5*testAmount100USDC - testBonderFeeUSDC)), ApprovalRequired: true, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &optimism, ToChain: &arbitrum, AmountOut: (*hexutil.Big)(big.NewInt(testAmount100USDC - testBonderFeeUSDC)), ApprovalRequired: true, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &optimism, ToChain: &arbitrum, AmountOut: (*hexutil.Big)(big.NewInt(2.5*testAmount100USDC - testBonderFeeUSDC)), ApprovalRequired: true, }, { - ProcessorName: walletCommon.ProcessorTransferName, + ProcessorName: pathProcessorCommon.ProcessorTransferName, FromChain: &arbitrum, ToChain: &arbitrum, AmountOut: (*hexutil.Big)(big.NewInt(0.5 * testAmount100USDC)), ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorTransferName, + ProcessorName: pathProcessorCommon.ProcessorTransferName, FromChain: &arbitrum, ToChain: &arbitrum, AmountOut: (*hexutil.Big)(big.NewInt(testAmount100USDC)), ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorTransferName, + ProcessorName: pathProcessorCommon.ProcessorTransferName, FromChain: &arbitrum, ToChain: &arbitrum, AmountOut: (*hexutil.Big)(big.NewInt(2.5 * testAmount100USDC)), ApprovalRequired: false, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &mainnet, AmountOut: (*hexutil.Big)(big.NewInt(0.5*testAmount100USDC - testBonderFeeUSDC)), ApprovalRequired: true, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &mainnet, AmountOut: (*hexutil.Big)(big.NewInt(testAmount100USDC - testBonderFeeUSDC)), ApprovalRequired: true, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &mainnet, AmountOut: (*hexutil.Big)(big.NewInt(2.5*testAmount100USDC - testBonderFeeUSDC)), ApprovalRequired: true, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &optimism, AmountOut: (*hexutil.Big)(big.NewInt(0.5*testAmount100USDC - testBonderFeeUSDC)), ApprovalRequired: true, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &optimism, AmountOut: (*hexutil.Big)(big.NewInt(testAmount100USDC - testBonderFeeUSDC)), ApprovalRequired: true, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &optimism, AmountOut: (*hexutil.Big)(big.NewInt(2.5*testAmount100USDC - testBonderFeeUSDC)), @@ -2038,37 +2039,37 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &mainnet, ToChain: &optimism, ApprovalRequired: true, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &mainnet, ToChain: &arbitrum, ApprovalRequired: true, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &optimism, ToChain: &mainnet, ApprovalRequired: true, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &optimism, ToChain: &arbitrum, ApprovalRequired: true, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &mainnet, ApprovalRequired: true, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &optimism, ApprovalRequired: true, @@ -2106,13 +2107,13 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &optimism, ToChain: &mainnet, ApprovalRequired: true, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &mainnet, ApprovalRequired: true, @@ -2150,25 +2151,25 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &mainnet, ToChain: &optimism, ApprovalRequired: true, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &mainnet, ToChain: &arbitrum, ApprovalRequired: true, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &optimism, ToChain: &arbitrum, ApprovalRequired: true, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &optimism, ApprovalRequired: true, @@ -2206,13 +2207,13 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &mainnet, ApprovalRequired: true, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &optimism, ApprovalRequired: true, @@ -2250,25 +2251,25 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &optimism, ToChain: &mainnet, ApprovalRequired: true, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &optimism, ToChain: &arbitrum, ApprovalRequired: true, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &mainnet, ApprovalRequired: true, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &optimism, ApprovalRequired: true, @@ -2340,7 +2341,7 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &mainnet, ApprovalRequired: true, @@ -2412,13 +2413,13 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &mainnet, ToChain: &arbitrum, ApprovalRequired: true, }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &mainnet, ApprovalRequired: true, @@ -2457,7 +2458,7 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &mainnet, ApprovalRequired: true, @@ -2532,7 +2533,7 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &mainnet, ToChain: &optimism, ApprovalRequired: false, @@ -2574,7 +2575,7 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &mainnet, ToChain: &optimism, ApprovalRequired: true, @@ -2614,7 +2615,7 @@ func getNormalTestParamsList() []normalTestParams { expectedError: ErrLowAmountInForHopBridge, expectedCandidates: routes.Route{ { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &mainnet, ApprovalRequired: true, @@ -2705,7 +2706,7 @@ func getNoBalanceTestParamsList() []noBalanceTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: walletCommon.ProcessorTransferName, + ProcessorName: pathProcessorCommon.ProcessorTransferName, FromChain: &optimism, ToChain: &optimism, ApprovalRequired: false, @@ -2792,13 +2793,13 @@ func getNoBalanceTestParamsList() []noBalanceTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &mainnet, ToChain: &optimism, ApprovalRequired: true, }, { - ProcessorName: walletCommon.ProcessorTransferName, + ProcessorName: pathProcessorCommon.ProcessorTransferName, FromChain: &optimism, ToChain: &optimism, ApprovalRequired: false, @@ -2806,7 +2807,7 @@ func getNoBalanceTestParamsList() []noBalanceTestParams { RequiredNativeBalance: big.NewInt((testBaseFee + testPriorityFeeLow) * testApprovalGasEstimation), }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &optimism, ApprovalRequired: true, @@ -2846,13 +2847,13 @@ func getNoBalanceTestParamsList() []noBalanceTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &mainnet, ToChain: &optimism, ApprovalRequired: true, }, { - ProcessorName: walletCommon.ProcessorTransferName, + ProcessorName: pathProcessorCommon.ProcessorTransferName, FromChain: &optimism, ToChain: &optimism, ApprovalRequired: false, @@ -2860,7 +2861,7 @@ func getNoBalanceTestParamsList() []noBalanceTestParams { RequiredNativeBalance: big.NewInt((testBaseFee + testPriorityFeeLow) * testApprovalGasEstimation), }, { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &optimism, ApprovalRequired: true, @@ -2868,7 +2869,7 @@ func getNoBalanceTestParamsList() []noBalanceTestParams { }, expectedBest: routes.Route{ { - ProcessorName: walletCommon.ProcessorBridgeHopName, + ProcessorName: pathProcessorCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &optimism, ApprovalRequired: true, diff --git a/services/wallet/router/sendtype/send_type.go b/services/wallet/router/sendtype/send_type.go index 161284da2..cf17007b8 100644 --- a/services/wallet/router/sendtype/send_type.go +++ b/services/wallet/router/sendtype/send_type.go @@ -5,6 +5,7 @@ import ( "github.com/status-im/status-go/params" walletCommon "github.com/status-im/status-go/services/wallet/common" + pathProcessorCommon "github.com/status-im/status-go/services/wallet/router/pathprocessor/common" ) type SendType int @@ -37,24 +38,24 @@ func (s SendType) IsStickersTransfer() bool { func (s SendType) CanUseProcessor(pathProcessorName string) bool { switch s { case Transfer: - return pathProcessorName == walletCommon.ProcessorTransferName || + return pathProcessorName == pathProcessorCommon.ProcessorTransferName || walletCommon.IsProcessorBridge(pathProcessorName) case Bridge: return walletCommon.IsProcessorBridge(pathProcessorName) case Swap: return walletCommon.IsProcessorSwap(pathProcessorName) case ERC721Transfer: - return pathProcessorName == walletCommon.ProcessorERC721Name + return pathProcessorName == pathProcessorCommon.ProcessorERC721Name case ERC1155Transfer: - return pathProcessorName == walletCommon.ProcessorERC1155Name + return pathProcessorName == pathProcessorCommon.ProcessorERC1155Name case ENSRegister: - return pathProcessorName == walletCommon.ProcessorENSRegisterName + return pathProcessorName == pathProcessorCommon.ProcessorENSRegisterName case ENSRelease: - return pathProcessorName == walletCommon.ProcessorENSReleaseName + return pathProcessorName == pathProcessorCommon.ProcessorENSReleaseName case ENSSetPubKey: - return pathProcessorName == walletCommon.ProcessorENSPublicKeyName + return pathProcessorName == pathProcessorCommon.ProcessorENSPublicKeyName case StickersBuy: - return pathProcessorName == walletCommon.ProcessorStickersBuyName + return pathProcessorName == pathProcessorCommon.ProcessorStickersBuyName default: return true } @@ -63,7 +64,7 @@ func (s SendType) CanUseProcessor(pathProcessorName string) bool { func (s SendType) ProcessZeroAmountInProcessor(amountIn *big.Int, amountOut *big.Int, processorName string) bool { if amountIn.Cmp(walletCommon.ZeroBigIntValue()) == 0 { if s == Transfer { - if processorName != walletCommon.ProcessorTransferName { + if processorName != pathProcessorCommon.ProcessorTransferName { return false } } else if s == Swap { diff --git a/services/wallet/transfer/transaction_manager_route.go b/services/wallet/transfer/transaction_manager_route.go index 893930dc9..a919b797e 100644 --- a/services/wallet/transfer/transaction_manager_route.go +++ b/services/wallet/transfer/transaction_manager_route.go @@ -16,6 +16,7 @@ import ( "github.com/status-im/status-go/services/wallet/requests" "github.com/status-im/status-go/services/wallet/responses" "github.com/status-im/status-go/services/wallet/router/pathprocessor" + pathProcessorCommon "github.com/status-im/status-go/services/wallet/router/pathprocessor/common" "github.com/status-im/status-go/services/wallet/router/routes" "github.com/status-im/status-go/services/wallet/wallettypes" "github.com/status-im/status-go/transactions" @@ -180,13 +181,13 @@ func buildTxForPath(transactor transactions.TransactorIface, path *routes.Path, if !path.FromToken.IsNative() { sendArgs.Value = (*hexutil.Big)(big.NewInt(0)) - if path.ProcessorName == walletCommon.ProcessorTransferName || - path.ProcessorName == walletCommon.ProcessorStickersBuyName || - path.ProcessorName == walletCommon.ProcessorENSRegisterName || - path.ProcessorName == walletCommon.ProcessorENSReleaseName || - path.ProcessorName == walletCommon.ProcessorENSPublicKeyName || - path.ProcessorName == walletCommon.ProcessorERC721Name || - path.ProcessorName == walletCommon.ProcessorERC1155Name { + if path.ProcessorName == pathProcessorCommon.ProcessorTransferName || + path.ProcessorName == pathProcessorCommon.ProcessorStickersBuyName || + path.ProcessorName == pathProcessorCommon.ProcessorENSRegisterName || + path.ProcessorName == pathProcessorCommon.ProcessorENSReleaseName || + path.ProcessorName == pathProcessorCommon.ProcessorENSPublicKeyName || + path.ProcessorName == pathProcessorCommon.ProcessorERC721Name || + path.ProcessorName == pathProcessorCommon.ProcessorERC1155Name { // TODO: update functions from `TransactorIface` to use `ToContractAddress` (as an address of the contract a transaction should be sent to) // and `To` (as the destination address, recipient) of `SendTxArgs` struct appropriately toContractAddr := types.Address(path.FromToken.Address) @@ -250,7 +251,7 @@ func (tm *TransactionManager) BuildTransactionsFromRoute(route routes.Route, pat response.Hashes = append(response.Hashes, txDetails.ApprovalTxData.HashToSign) // if approval is needed for swap, we cannot build the swap tx before the approval tx is mined - if path.ProcessorName == walletCommon.ProcessorSwapParaswapName { + if path.ProcessorName == pathProcessorCommon.ProcessorSwapParaswapName { continue } } @@ -367,7 +368,7 @@ func (tm *TransactionManager) SendRouterTransactions(ctx context.Context, multiT transactions = append(transactions, response) // if approval is needed for swap, then we need to wait for the approval tx to be mined before sending the swap tx - if desc.RouterPath.ProcessorName == walletCommon.ProcessorSwapParaswapName { + if desc.RouterPath.ProcessorName == pathProcessorCommon.ProcessorSwapParaswapName { continue } }