chore(wallet)_: path processor specific const and functions moved to path processors' common package
This commit is contained in:
parent
9f5f29513c
commit
4062b6a1cb
|
@ -107,7 +107,7 @@ func (api *API) DeployCollectibles(ctx context.Context, chainID uint64, deployme
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return DeploymentDetails{}, err
|
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)
|
ethClient, err := api.s.manager.rpcClient.EthClient(chainID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -196,7 +196,7 @@ func (api *API) DeployOwnerToken(ctx context.Context, chainID uint64,
|
||||||
return DeploymentDetails{}, err
|
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)
|
deployerContractInst, err := api.NewCommunityTokenDeployerInstance(chainID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -280,7 +280,7 @@ func (api *API) DeployAssets(ctx context.Context, chainID uint64, deploymentPara
|
||||||
return DeploymentDetails{}, err
|
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)
|
ethClient, err := api.s.manager.rpcClient.EthClient(chainID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -384,7 +384,7 @@ func (api *API) MintTokens(ctx context.Context, chainID uint64, contractAddress
|
||||||
return "", err
|
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)
|
contractInst, err := NewTokenInstance(api.s, chainID, contractAddress)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -446,7 +446,7 @@ func (api *API) RemoteBurn(ctx context.Context, chainID uint64, contractAddress
|
||||||
return "", err
|
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
|
var tempTokenIds []*big.Int
|
||||||
for _, v := range tokenIds {
|
for _, v := range tokenIds {
|
||||||
|
@ -498,7 +498,7 @@ func (api *API) Burn(ctx context.Context, chainID uint64, contractAddress string
|
||||||
return "", err
|
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)
|
newMaxSupply, err := api.s.prepareNewMaxSupply(ctx, chainID, contractAddress, burnAmount)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -508,7 +508,7 @@ func (s *Service) SetSignerPubKey(ctx context.Context, chainID uint64, contractA
|
||||||
return "", fmt.Errorf("signerPubKey is empty")
|
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)
|
contractInst, err := s.NewOwnerTokenInstance(chainID, contractAddress)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -154,7 +154,7 @@ func (api *API) Release(ctx context.Context, chainID uint64, txArgs wallettypes.
|
||||||
return "", err
|
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)
|
tx, err := api.ensResolver.Release(ctx, chainID, registryAddr, txArgs, username, signFn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
@ -239,7 +239,7 @@ func (api *API) Register(ctx context.Context, chainID uint64, txArgs wallettypes
|
||||||
return "", err
|
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)
|
tx, err := api.ensResolver.Register(ctx, chainID, registryAddr, txArgs, username, pubkey, signFn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -350,7 +350,7 @@ func (api *API) SetPubKey(ctx context.Context, chainID uint64, txArgs wallettype
|
||||||
return "", err
|
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)
|
tx, err := api.ensResolver.SetPubKey(ctx, chainID, resolverAddress, txArgs, username, pubkey, signFn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package utils
|
package utils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/ecdsa"
|
||||||
"math/big"
|
"math/big"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
@ -14,7 +15,14 @@ import (
|
||||||
prot_common "github.com/status-im/status-go/protocol/common"
|
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) {
|
return func(addr common.Address, tx *ethTypes.Transaction) (*ethTypes.Transaction, error) {
|
||||||
selectedAccount, err := accountsManager.VerifyAccountPassword(keyStoreDir, from.Hex(), password)
|
selectedAccount, err := accountsManager.VerifyAccountPassword(keyStoreDir, from.Hex(), password)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -22,17 +22,6 @@ const (
|
||||||
SttSymbol = "STT"
|
SttSymbol = "STT"
|
||||||
UsdcSymbol = "USDC"
|
UsdcSymbol = "USDC"
|
||||||
HopSymbol = "HOP"
|
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
|
type ChainID uint64
|
||||||
|
|
|
@ -10,14 +10,16 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
"github.com/status-im/status-go/contracts/ierc20"
|
"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 {
|
func IsProcessorBridge(name string) bool {
|
||||||
return name == ProcessorBridgeHopName || name == ProcessorBridgeCelerName
|
return name == pathProcessorCommon.ProcessorBridgeHopName || name == pathProcessorCommon.ProcessorBridgeCelerName
|
||||||
}
|
}
|
||||||
|
|
||||||
func IsProcessorSwap(name string) bool {
|
func IsProcessorSwap(name string) bool {
|
||||||
return name == ProcessorSwapParaswapName
|
return name == pathProcessorCommon.ProcessorSwapParaswapName
|
||||||
}
|
}
|
||||||
|
|
||||||
func PackApprovalInputData(amountIn *big.Int, approvalContractAddress *common.Address) ([]byte, error) {
|
func PackApprovalInputData(amountIn *big.Int, approvalContractAddress *common.Address) ([]byte, error) {
|
||||||
|
|
|
@ -14,11 +14,11 @@ import (
|
||||||
|
|
||||||
status_common "github.com/status-im/status-go/common"
|
status_common "github.com/status-im/status-go/common"
|
||||||
statusErrors "github.com/status-im/status-go/errors"
|
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/requests"
|
||||||
"github.com/status-im/status-go/services/wallet/responses"
|
"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/routeexecution/storage"
|
||||||
"github.com/status-im/status-go/services/wallet/router"
|
"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/router/sendtype"
|
||||||
"github.com/status-im/status-go/services/wallet/transfer"
|
"github.com/status-im/status-go/services/wallet/transfer"
|
||||||
"github.com/status-im/status-go/services/wallet/wallettypes"
|
"github.com/status-im/status-go/services/wallet/wallettypes"
|
||||||
|
@ -118,9 +118,9 @@ func (m *Manager) SendRouterTransactionsWithSignatures(ctx context.Context, send
|
||||||
clearLocalData := true
|
clearLocalData := true
|
||||||
if routeInputParams.SendType == sendtype.Swap {
|
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
|
// 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) &&
|
if m.transactionManager.ApprovalRequiredForPath(pathProcessorCommon.ProcessorSwapParaswapName) &&
|
||||||
m.transactionManager.ApprovalPlacedForPath(walletCommon.ProcessorSwapParaswapName) &&
|
m.transactionManager.ApprovalPlacedForPath(pathProcessorCommon.ProcessorSwapParaswapName) &&
|
||||||
!m.transactionManager.TxPlacedForPath(walletCommon.ProcessorSwapParaswapName) {
|
!m.transactionManager.TxPlacedForPath(pathProcessorCommon.ProcessorSwapParaswapName) {
|
||||||
clearLocalData = false
|
clearLocalData = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
|
||||||
}
|
|
|
@ -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
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package pathprocessor
|
package common
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -8,14 +8,14 @@ import (
|
||||||
|
|
||||||
func TestGettingNameFromEnsUsername(t *testing.T) {
|
func TestGettingNameFromEnsUsername(t *testing.T) {
|
||||||
ensName := "test"
|
ensName := "test"
|
||||||
name := getNameFromEnsUsername(ensName)
|
name := GetNameFromEnsUsername(ensName)
|
||||||
require.Equal(t, ensName, name)
|
require.Equal(t, ensName, name)
|
||||||
|
|
||||||
ensStatusName := "test.stateofus.eth"
|
ensStatusName := "test.stateofus.eth"
|
||||||
name = getNameFromEnsUsername(ensStatusName)
|
name = GetNameFromEnsUsername(ensStatusName)
|
||||||
require.Equal(t, ensName, name)
|
require.Equal(t, ensName, name)
|
||||||
|
|
||||||
ensNotStatusName := "test.eth"
|
ensNotStatusName := "test.eth"
|
||||||
name = getNameFromEnsUsername(ensNotStatusName)
|
name = GetNameFromEnsUsername(ensNotStatusName)
|
||||||
require.Equal(t, ensNotStatusName, name)
|
require.Equal(t, ensNotStatusName, name)
|
||||||
}
|
}
|
|
@ -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"
|
||||||
|
)
|
|
@ -1,6 +0,0 @@
|
||||||
package pathprocessor
|
|
||||||
|
|
||||||
const (
|
|
||||||
IncreaseEstimatedGasFactor = 1.2
|
|
||||||
SevenDaysInSeconds = 60 * 60 * 24 * 7
|
|
||||||
)
|
|
|
@ -4,7 +4,8 @@ import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/status-im/status-go/errors"
|
"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`
|
// 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
|
var customErrResp *errors.ErrorResponse
|
||||||
switch processorName {
|
switch processorName {
|
||||||
case walletCommon.ProcessorTransferName:
|
case pathProcessorCommon.ProcessorTransferName:
|
||||||
customErrResp = ErrTransferCustomError
|
customErrResp = ErrTransferCustomError
|
||||||
case walletCommon.ProcessorERC721Name:
|
case pathProcessorCommon.ProcessorERC721Name:
|
||||||
customErrResp = ErrERC721TransferCustomError
|
customErrResp = ErrERC721TransferCustomError
|
||||||
case walletCommon.ProcessorERC1155Name:
|
case pathProcessorCommon.ProcessorERC1155Name:
|
||||||
customErrResp = ErrERC1155TransferCustomError
|
customErrResp = ErrERC1155TransferCustomError
|
||||||
case walletCommon.ProcessorBridgeHopName:
|
case pathProcessorCommon.ProcessorBridgeHopName:
|
||||||
customErrResp = ErrBridgeHopCustomError
|
customErrResp = ErrBridgeHopCustomError
|
||||||
case walletCommon.ProcessorBridgeCelerName:
|
case pathProcessorCommon.ProcessorBridgeCelerName:
|
||||||
customErrResp = ErrBridgeCellerCustomError
|
customErrResp = ErrBridgeCellerCustomError
|
||||||
case walletCommon.ProcessorSwapParaswapName:
|
case pathProcessorCommon.ProcessorSwapParaswapName:
|
||||||
customErrResp = ErrSwapParaswapCustomError
|
customErrResp = ErrSwapParaswapCustomError
|
||||||
case walletCommon.ProcessorENSRegisterName:
|
case pathProcessorCommon.ProcessorENSRegisterName:
|
||||||
customErrResp = ErrENSRegisterCustomError
|
customErrResp = ErrENSRegisterCustomError
|
||||||
case walletCommon.ProcessorENSReleaseName:
|
case pathProcessorCommon.ProcessorENSReleaseName:
|
||||||
customErrResp = ErrENSReleaseCustomError
|
customErrResp = ErrENSReleaseCustomError
|
||||||
case walletCommon.ProcessorENSPublicKeyName:
|
case pathProcessorCommon.ProcessorENSPublicKeyName:
|
||||||
customErrResp = ErrENSPublicKeyCustomError
|
customErrResp = ErrENSPublicKeyCustomError
|
||||||
case walletCommon.ProcessorStickersBuyName:
|
case pathProcessorCommon.ProcessorStickersBuyName:
|
||||||
customErrResp = ErrStickersBuyCustomError
|
customErrResp = ErrStickersBuyCustomError
|
||||||
default:
|
default:
|
||||||
return genericErrResp
|
return genericErrResp
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
|
|
||||||
s_errors "github.com/status-im/status-go/errors"
|
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"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
@ -17,17 +17,17 @@ func TestPlainError(t *testing.T) {
|
||||||
err := errors.New(errString)
|
err := errors.New(errString)
|
||||||
|
|
||||||
processorNames := []string{
|
processorNames := []string{
|
||||||
walletCommon.ProcessorTransferName,
|
common.ProcessorTransferName,
|
||||||
walletCommon.ProcessorTransferName,
|
common.ProcessorTransferName,
|
||||||
walletCommon.ProcessorBridgeHopName,
|
common.ProcessorBridgeHopName,
|
||||||
walletCommon.ProcessorBridgeCelerName,
|
common.ProcessorBridgeCelerName,
|
||||||
walletCommon.ProcessorSwapParaswapName,
|
common.ProcessorSwapParaswapName,
|
||||||
walletCommon.ProcessorERC721Name,
|
common.ProcessorERC721Name,
|
||||||
walletCommon.ProcessorERC1155Name,
|
common.ProcessorERC1155Name,
|
||||||
walletCommon.ProcessorENSRegisterName,
|
common.ProcessorENSRegisterName,
|
||||||
walletCommon.ProcessorENSReleaseName,
|
common.ProcessorENSReleaseName,
|
||||||
walletCommon.ProcessorENSPublicKeyName,
|
common.ProcessorENSPublicKeyName,
|
||||||
walletCommon.ProcessorStickersBuyName,
|
common.ProcessorStickersBuyName,
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, processorName := range processorNames {
|
for _, processorName := range processorNames {
|
||||||
|
@ -64,7 +64,7 @@ func TestNonGenericErrorResponse(t *testing.T) {
|
||||||
Details: "Not Generic Error Response",
|
Details: "Not Generic Error Response",
|
||||||
}
|
}
|
||||||
err := s_errors.CreateErrorResponseFromError(errResp)
|
err := s_errors.CreateErrorResponseFromError(errResp)
|
||||||
ppErrResp := createErrorResponse(walletCommon.ProcessorTransferName, err)
|
ppErrResp := createErrorResponse(common.ProcessorTransferName, err)
|
||||||
|
|
||||||
castPPErrResp := ppErrResp.(*s_errors.ErrorResponse)
|
castPPErrResp := ppErrResp.(*s_errors.ErrorResponse)
|
||||||
require.Equal(t, errResp.Code, castPPErrResp.Code)
|
require.Equal(t, errResp.Code, castPPErrResp.Code)
|
||||||
|
|
|
@ -23,8 +23,10 @@ import (
|
||||||
"github.com/status-im/status-go/rpc"
|
"github.com/status-im/status-go/rpc"
|
||||||
|
|
||||||
"github.com/status-im/status-go/params"
|
"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"
|
walletCommon "github.com/status-im/status-go/services/wallet/common"
|
||||||
"github.com/status-im/status-go/services/wallet/router/pathprocessor/cbridge"
|
"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/thirdparty"
|
||||||
"github.com/status-im/status-go/services/wallet/token"
|
"github.com/status-im/status-go/services/wallet/token"
|
||||||
"github.com/status-im/status-go/services/wallet/wallettypes"
|
"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 {
|
func createBridgeCellerErrorResponse(err error) error {
|
||||||
return createErrorResponse(walletCommon.ProcessorBridgeCelerName, err)
|
return createErrorResponse(pathProcessorCommon.ProcessorBridgeCelerName, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *CelerBridgeProcessor) Name() string {
|
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) {
|
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)
|
return 0, createBridgeCellerErrorResponse(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
increasedEstimation := float64(estimation) * IncreaseEstimatedGasFactor
|
increasedEstimation := float64(estimation) * pathProcessorCommon.IncreaseEstimatedGasFactor
|
||||||
return uint64(increasedEstimation), nil
|
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) {
|
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 {
|
if err != nil {
|
||||||
return types.HexToHash(""), 0, createBridgeCellerErrorResponse(err)
|
return types.HexToHash(""), 0, createBridgeCellerErrorResponse(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,8 +31,10 @@ import (
|
||||||
"github.com/status-im/status-go/rpc"
|
"github.com/status-im/status-go/rpc"
|
||||||
"github.com/status-im/status-go/rpc/chain"
|
"github.com/status-im/status-go/rpc/chain"
|
||||||
"github.com/status-im/status-go/rpc/network"
|
"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"
|
"github.com/status-im/status-go/services/wallet/bigint"
|
||||||
walletCommon "github.com/status-im/status-go/services/wallet/common"
|
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/thirdparty"
|
||||||
"github.com/status-im/status-go/services/wallet/token"
|
"github.com/status-im/status-go/services/wallet/token"
|
||||||
"github.com/status-im/status-go/services/wallet/wallettypes"
|
"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 {
|
func createBridgeHopErrorResponse(err error) error {
|
||||||
return createErrorResponse(walletCommon.ProcessorBridgeHopName, err)
|
return createErrorResponse(pathProcessorCommon.ProcessorBridgeHopName, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *HopBridgeProcessor) Name() string {
|
func (h *HopBridgeProcessor) Name() string {
|
||||||
return walletCommon.ProcessorBridgeHopName
|
return pathProcessorCommon.ProcessorBridgeHopName
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *HopBridgeProcessor) Clear() {
|
func (h *HopBridgeProcessor) Clear() {
|
||||||
|
@ -202,7 +204,7 @@ func (h *HopBridgeProcessor) packTxInputDataInternally(params ProcessorInputPara
|
||||||
return []byte{}, createBridgeHopErrorResponse(err)
|
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)
|
bonderFeeIns, ok := h.bonderFee.Load(bonderKey)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, ErrNoBonderFeeFound
|
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
|
return uint64(increasedEstimation), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -320,7 +322,7 @@ func (h *HopBridgeProcessor) sendOrBuild(sendArgs *MultipathProcessorTxArgs, sig
|
||||||
return tx, createBridgeHopErrorResponse(err)
|
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)
|
bonderFeeIns, ok := h.bonderFee.Load(bonderKey)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, ErrNoBonderFeeFound
|
return nil, ErrNoBonderFeeFound
|
||||||
|
@ -387,7 +389,7 @@ func (h *HopBridgeProcessor) sendOrBuildV2(sendArgs *wallettypes.SendTxArgs, sig
|
||||||
return tx, createBridgeHopErrorResponse(err)
|
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)
|
bonderFeeIns, ok := h.bonderFee.Load(bonderKey)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, ErrNoBonderFeeFound
|
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) {
|
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 {
|
if err != nil {
|
||||||
return types.Hash{}, 0, createBridgeHopErrorResponse(err)
|
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) {
|
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 params.TestsMode {
|
||||||
if val, ok := params.TestBonderFeeMap[params.FromToken.Symbol]; ok {
|
if val, ok := params.TestBonderFeeMap[params.FromToken.Symbol]; ok {
|
||||||
res := new(big.Int).Sub(params.AmountIn, val)
|
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},
|
DestinationAmountOutMin: &bigint.BigInt{Int: res},
|
||||||
BonderFee: &bigint.BigInt{Int: val},
|
BonderFee: &bigint.BigInt{Int: val},
|
||||||
EstimatedRecieved: &bigint.BigInt{Int: res},
|
EstimatedRecieved: &bigint.BigInt{Int: res},
|
||||||
Deadline: time.Now().Add(SevenDaysInSeconds).Unix(),
|
Deadline: time.Now().Add(pathProcessorCommon.SevenDaysInSeconds).Unix(),
|
||||||
}
|
}
|
||||||
h.bonderFee.Store(bonderKey, bonderFee)
|
h.bonderFee.Store(bonderKey, bonderFee)
|
||||||
return val, walletCommon.ZeroBigIntValue(), nil
|
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) {
|
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)
|
bonderFeeIns, ok := h.bonderFee.Load(bonderKey)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, ErrNoBonderFeeFound
|
return nil, ErrNoBonderFeeFound
|
||||||
|
|
|
@ -16,6 +16,7 @@ import (
|
||||||
"github.com/status-im/status-go/rpc"
|
"github.com/status-im/status-go/rpc"
|
||||||
"github.com/status-im/status-go/services/ens/ensresolver"
|
"github.com/status-im/status-go/services/ens/ensresolver"
|
||||||
walletCommon "github.com/status-im/status-go/services/wallet/common"
|
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/services/wallet/wallettypes"
|
||||||
"github.com/status-im/status-go/transactions"
|
"github.com/status-im/status-go/transactions"
|
||||||
)
|
)
|
||||||
|
@ -37,11 +38,11 @@ func NewENSPublicKeyProcessor(rpcClient *rpc.Client, transactor transactions.Tra
|
||||||
}
|
}
|
||||||
|
|
||||||
func createENSPublicKeyErrorResponse(err error) error {
|
func createENSPublicKeyErrorResponse(err error) error {
|
||||||
return createErrorResponse(walletCommon.ProcessorENSPublicKeyName, err)
|
return createErrorResponse(pathProcessorCommon.ProcessorENSPublicKeyName, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ENSPublicKeyProcessor) Name() string {
|
func (s *ENSPublicKeyProcessor) Name() string {
|
||||||
return walletCommon.ProcessorENSPublicKeyName
|
return pathProcessorCommon.ProcessorENSPublicKeyName
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ENSPublicKeyProcessor) AvailableFor(params ProcessorInputParams) (bool, error) {
|
func (s *ENSPublicKeyProcessor) AvailableFor(params ProcessorInputParams) (bool, error) {
|
||||||
|
@ -99,7 +100,7 @@ func (s *ENSPublicKeyProcessor) EstimateGas(params ProcessorInputParams) (uint64
|
||||||
return 0, createENSPublicKeyErrorResponse(err)
|
return 0, createENSPublicKeyErrorResponse(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
increasedEstimation := float64(estimation) * IncreaseEstimatedGasFactor
|
increasedEstimation := float64(estimation) * pathProcessorCommon.IncreaseEstimatedGasFactor
|
||||||
|
|
||||||
return uint64(increasedEstimation), nil
|
return uint64(increasedEstimation), nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ import (
|
||||||
"github.com/status-im/status-go/rpc"
|
"github.com/status-im/status-go/rpc"
|
||||||
"github.com/status-im/status-go/services/ens/ensresolver"
|
"github.com/status-im/status-go/services/ens/ensresolver"
|
||||||
walletCommon "github.com/status-im/status-go/services/wallet/common"
|
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/services/wallet/wallettypes"
|
||||||
"github.com/status-im/status-go/transactions"
|
"github.com/status-im/status-go/transactions"
|
||||||
)
|
)
|
||||||
|
@ -39,11 +40,11 @@ func NewENSRegisterProcessor(rpcClient *rpc.Client, transactor transactions.Tran
|
||||||
}
|
}
|
||||||
|
|
||||||
func createENSRegisterProcessorErrorResponse(err error) error {
|
func createENSRegisterProcessorErrorResponse(err error) error {
|
||||||
return createErrorResponse(walletCommon.ProcessorENSRegisterName, err)
|
return createErrorResponse(pathProcessorCommon.ProcessorENSRegisterName, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ENSRegisterProcessor) Name() string {
|
func (s *ENSRegisterProcessor) Name() string {
|
||||||
return walletCommon.ProcessorENSRegisterName
|
return pathProcessorCommon.ProcessorENSRegisterName
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ENSRegisterProcessor) GetPriceForRegisteringEnsName(chainID uint64) (*big.Int, error) {
|
func (s *ENSRegisterProcessor) GetPriceForRegisteringEnsName(chainID uint64) (*big.Int, error) {
|
||||||
|
@ -135,7 +136,7 @@ func (s *ENSRegisterProcessor) EstimateGas(params ProcessorInputParams) (uint64,
|
||||||
return 0, createENSRegisterProcessorErrorResponse(err)
|
return 0, createENSRegisterProcessorErrorResponse(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
increasedEstimation := float64(estimation) * IncreaseEstimatedGasFactor
|
increasedEstimation := float64(estimation) * pathProcessorCommon.IncreaseEstimatedGasFactor
|
||||||
|
|
||||||
return uint64(increasedEstimation), nil
|
return uint64(increasedEstimation), nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ import (
|
||||||
"github.com/status-im/status-go/rpc"
|
"github.com/status-im/status-go/rpc"
|
||||||
"github.com/status-im/status-go/services/ens/ensresolver"
|
"github.com/status-im/status-go/services/ens/ensresolver"
|
||||||
walletCommon "github.com/status-im/status-go/services/wallet/common"
|
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/services/wallet/wallettypes"
|
||||||
"github.com/status-im/status-go/transactions"
|
"github.com/status-im/status-go/transactions"
|
||||||
)
|
)
|
||||||
|
@ -37,11 +38,11 @@ func NewENSReleaseProcessor(rpcClient *rpc.Client, transactor transactions.Trans
|
||||||
}
|
}
|
||||||
|
|
||||||
func createENSReleaseErrorResponse(err error) error {
|
func createENSReleaseErrorResponse(err error) error {
|
||||||
return createErrorResponse(walletCommon.ProcessorENSReleaseName, err)
|
return createErrorResponse(pathProcessorCommon.ProcessorENSReleaseName, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ENSReleaseProcessor) Name() string {
|
func (s *ENSReleaseProcessor) Name() string {
|
||||||
return walletCommon.ProcessorENSReleaseName
|
return pathProcessorCommon.ProcessorENSReleaseName
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ENSReleaseProcessor) AvailableFor(params ProcessorInputParams) (bool, error) {
|
func (s *ENSReleaseProcessor) AvailableFor(params ProcessorInputParams) (bool, error) {
|
||||||
|
@ -58,7 +59,7 @@ func (s *ENSReleaseProcessor) PackTxInputData(params ProcessorInputParams) ([]by
|
||||||
return []byte{}, createENSReleaseErrorResponse(err)
|
return []byte{}, createENSReleaseErrorResponse(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
name := getNameFromEnsUsername(params.Username)
|
name := pathProcessorCommon.GetNameFromEnsUsername(params.Username)
|
||||||
return registrarABI.Pack("release", walletCommon.UsernameToLabel(name))
|
return registrarABI.Pack("release", walletCommon.UsernameToLabel(name))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,7 +100,7 @@ func (s *ENSReleaseProcessor) EstimateGas(params ProcessorInputParams) (uint64,
|
||||||
return 0, createENSReleaseErrorResponse(err)
|
return 0, createENSReleaseErrorResponse(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
increasedEstimation := float64(estimation) * IncreaseEstimatedGasFactor
|
increasedEstimation := float64(estimation) * pathProcessorCommon.IncreaseEstimatedGasFactor
|
||||||
|
|
||||||
return uint64(increasedEstimation), nil
|
return uint64(increasedEstimation), nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,9 @@ import (
|
||||||
"github.com/status-im/status-go/contracts/ierc1155"
|
"github.com/status-im/status-go/contracts/ierc1155"
|
||||||
"github.com/status-im/status-go/eth-node/types"
|
"github.com/status-im/status-go/eth-node/types"
|
||||||
"github.com/status-im/status-go/rpc"
|
"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"
|
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/services/wallet/wallettypes"
|
||||||
"github.com/status-im/status-go/transactions"
|
"github.com/status-im/status-go/transactions"
|
||||||
)
|
)
|
||||||
|
@ -37,11 +39,11 @@ func NewERC1155Processor(rpcClient *rpc.Client, transactor transactions.Transact
|
||||||
}
|
}
|
||||||
|
|
||||||
func createERC1155ErrorResponse(err error) error {
|
func createERC1155ErrorResponse(err error) error {
|
||||||
return createErrorResponse(walletCommon.ProcessorERC1155Name, err)
|
return createErrorResponse(pathProcessorCommon.ProcessorERC1155Name, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ERC1155Processor) Name() string {
|
func (s *ERC1155Processor) Name() string {
|
||||||
return walletCommon.ProcessorERC1155Name
|
return pathProcessorCommon.ProcessorERC1155Name
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ERC1155Processor) AvailableFor(params ProcessorInputParams) (bool, error) {
|
func (s *ERC1155Processor) AvailableFor(params ProcessorInputParams) (bool, error) {
|
||||||
|
@ -105,7 +107,7 @@ func (s *ERC1155Processor) EstimateGas(params ProcessorInputParams) (uint64, err
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, createERC1155ErrorResponse(err)
|
return 0, createERC1155ErrorResponse(err)
|
||||||
}
|
}
|
||||||
increasedEstimation := float64(estimation) * IncreaseEstimatedGasFactor
|
increasedEstimation := float64(estimation) * pathProcessorCommon.IncreaseEstimatedGasFactor
|
||||||
return uint64(increasedEstimation), nil
|
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) {
|
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 {
|
if err != nil {
|
||||||
return hash, 0, createERC1155ErrorResponse(err)
|
return hash, 0, createERC1155ErrorResponse(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,9 @@ import (
|
||||||
"github.com/status-im/status-go/eth-node/types"
|
"github.com/status-im/status-go/eth-node/types"
|
||||||
"github.com/status-im/status-go/params"
|
"github.com/status-im/status-go/params"
|
||||||
"github.com/status-im/status-go/rpc"
|
"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"
|
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/token"
|
||||||
"github.com/status-im/status-go/services/wallet/wallettypes"
|
"github.com/status-im/status-go/services/wallet/wallettypes"
|
||||||
"github.com/status-im/status-go/transactions"
|
"github.com/status-im/status-go/transactions"
|
||||||
|
@ -44,11 +46,11 @@ func NewERC721Processor(rpcClient *rpc.Client, transactor transactions.Transacto
|
||||||
}
|
}
|
||||||
|
|
||||||
func createERC721ErrorResponse(err error) error {
|
func createERC721ErrorResponse(err error) error {
|
||||||
return createErrorResponse(walletCommon.ProcessorERC721Name, err)
|
return createErrorResponse(pathProcessorCommon.ProcessorERC721Name, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ERC721Processor) Name() string {
|
func (s *ERC721Processor) Name() string {
|
||||||
return walletCommon.ProcessorERC721Name
|
return pathProcessorCommon.ProcessorERC721Name
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ERC721Processor) AvailableFor(params ProcessorInputParams) (bool, error) {
|
func (s *ERC721Processor) AvailableFor(params ProcessorInputParams) (bool, error) {
|
||||||
|
@ -143,7 +145,7 @@ func (s *ERC721Processor) EstimateGas(params ProcessorInputParams) (uint64, erro
|
||||||
return 0, createERC721ErrorResponse(err)
|
return 0, createERC721ErrorResponse(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
increasedEstimation := float64(estimation) * IncreaseEstimatedGasFactor
|
increasedEstimation := float64(estimation) * pathProcessorCommon.IncreaseEstimatedGasFactor
|
||||||
return uint64(increasedEstimation), nil
|
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) {
|
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 {
|
if err != nil {
|
||||||
return hash, 0, createERC721ErrorResponse(err)
|
return hash, 0, createERC721ErrorResponse(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ import (
|
||||||
"github.com/status-im/status-go/eth-node/types"
|
"github.com/status-im/status-go/eth-node/types"
|
||||||
"github.com/status-im/status-go/rpc"
|
"github.com/status-im/status-go/rpc"
|
||||||
walletCommon "github.com/status-im/status-go/services/wallet/common"
|
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/services/wallet/wallettypes"
|
||||||
"github.com/status-im/status-go/transactions"
|
"github.com/status-im/status-go/transactions"
|
||||||
)
|
)
|
||||||
|
@ -36,11 +37,11 @@ func NewStickersBuyProcessor(rpcClient *rpc.Client, transactor transactions.Tran
|
||||||
}
|
}
|
||||||
|
|
||||||
func createStickersBuyErrorResponse(err error) error {
|
func createStickersBuyErrorResponse(err error) error {
|
||||||
return createErrorResponse(walletCommon.ProcessorStickersBuyName, err)
|
return createErrorResponse(pathProcessorCommon.ProcessorStickersBuyName, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *StickersBuyProcessor) Name() string {
|
func (s *StickersBuyProcessor) Name() string {
|
||||||
return walletCommon.ProcessorStickersBuyName
|
return pathProcessorCommon.ProcessorStickersBuyName
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *StickersBuyProcessor) AvailableFor(params ProcessorInputParams) (bool, error) {
|
func (s *StickersBuyProcessor) AvailableFor(params ProcessorInputParams) (bool, error) {
|
||||||
|
@ -124,7 +125,7 @@ func (s *StickersBuyProcessor) EstimateGas(params ProcessorInputParams) (uint64,
|
||||||
return 0, createStickersBuyErrorResponse(err)
|
return 0, createStickersBuyErrorResponse(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
increasedEstimation := float64(estimation) * IncreaseEstimatedGasFactor
|
increasedEstimation := float64(estimation) * pathProcessorCommon.IncreaseEstimatedGasFactor
|
||||||
|
|
||||||
return uint64(increasedEstimation), nil
|
return uint64(increasedEstimation), nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ import (
|
||||||
"github.com/status-im/status-go/eth-node/types"
|
"github.com/status-im/status-go/eth-node/types"
|
||||||
"github.com/status-im/status-go/rpc"
|
"github.com/status-im/status-go/rpc"
|
||||||
walletCommon "github.com/status-im/status-go/services/wallet/common"
|
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"
|
"github.com/status-im/status-go/services/wallet/thirdparty/paraswap"
|
||||||
walletToken "github.com/status-im/status-go/services/wallet/token"
|
walletToken "github.com/status-im/status-go/services/wallet/token"
|
||||||
"github.com/status-im/status-go/services/wallet/wallettypes"
|
"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":
|
case "ESTIMATED_LOSS_GREATER_THAN_MAX_IMPACT":
|
||||||
return ErrPriceImpactTooHigh
|
return ErrPriceImpactTooHigh
|
||||||
}
|
}
|
||||||
return createErrorResponse(walletCommon.ProcessorSwapParaswapName, err)
|
return createErrorResponse(pathProcessorCommon.ProcessorSwapParaswapName, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SwapParaswapProcessor) Name() string {
|
func (s *SwapParaswapProcessor) Name() string {
|
||||||
return walletCommon.ProcessorSwapParaswapName
|
return pathProcessorCommon.ProcessorSwapParaswapName
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SwapParaswapProcessor) Clear() {
|
func (s *SwapParaswapProcessor) Clear() {
|
||||||
|
@ -191,14 +192,14 @@ func (s *SwapParaswapProcessor) EstimateGas(params ProcessorInputParams) (uint64
|
||||||
return 0, createSwapParaswapErrorResponse(err)
|
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)
|
s.priceRoute.Store(key, &priceRoute)
|
||||||
|
|
||||||
return priceRoute.GasCost.Uint64(), nil
|
return priceRoute.GasCost.Uint64(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SwapParaswapProcessor) GetContractAddress(params ProcessorInputParams) (address common.Address, err error) {
|
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)
|
priceRouteIns, ok := s.priceRoute.Load(key)
|
||||||
if !ok {
|
if !ok {
|
||||||
err = ErrPriceRouteNotFound
|
err = ErrPriceRouteNotFound
|
||||||
|
@ -213,7 +214,7 @@ func (s *SwapParaswapProcessor) GetContractAddress(params ProcessorInputParams)
|
||||||
func (s *SwapParaswapProcessor) prepareTransaction(sendArgs *MultipathProcessorTxArgs) error {
|
func (s *SwapParaswapProcessor) prepareTransaction(sendArgs *MultipathProcessorTxArgs) error {
|
||||||
slippageBP := uint(sendArgs.SwapTx.SlippagePercentage * 100) // convert to basis points
|
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)
|
priceRouteIns, ok := s.priceRoute.Load(key)
|
||||||
if !ok {
|
if !ok {
|
||||||
return ErrPriceRouteNotFound
|
return ErrPriceRouteNotFound
|
||||||
|
@ -259,7 +260,7 @@ func (s *SwapParaswapProcessor) prepareTransaction(sendArgs *MultipathProcessorT
|
||||||
func (s *SwapParaswapProcessor) prepareTransactionV2(sendArgs *wallettypes.SendTxArgs) error {
|
func (s *SwapParaswapProcessor) prepareTransactionV2(sendArgs *wallettypes.SendTxArgs) error {
|
||||||
slippageBP := uint(sendArgs.SlippagePercentage * 100) // convert to basis points
|
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)
|
priceRouteIns, ok := s.priceRoute.Load(key)
|
||||||
if !ok {
|
if !ok {
|
||||||
return ErrPriceRouteNotFound
|
return ErrPriceRouteNotFound
|
||||||
|
@ -327,7 +328,7 @@ func (s *SwapParaswapProcessor) Send(sendArgs *MultipathProcessorTxArgs, lastUse
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SwapParaswapProcessor) CalculateAmountOut(params ProcessorInputParams) (*big.Int, error) {
|
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)
|
priceRouteIns, ok := s.priceRoute.Load(key)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, ErrPriceRouteNotFound
|
return nil, ErrPriceRouteNotFound
|
||||||
|
|
|
@ -12,6 +12,7 @@ import (
|
||||||
"github.com/status-im/status-go/params"
|
"github.com/status-im/status-go/params"
|
||||||
"github.com/status-im/status-go/services/wallet/bigint"
|
"github.com/status-im/status-go/services/wallet/bigint"
|
||||||
walletCommon "github.com/status-im/status-go/services/wallet/common"
|
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"
|
"github.com/status-im/status-go/services/wallet/thirdparty/paraswap"
|
||||||
mock_paraswap "github.com/status-im/status-go/services/wallet/thirdparty/paraswap/mock"
|
mock_paraswap "github.com/status-im/status-go/services/wallet/thirdparty/paraswap/mock"
|
||||||
"github.com/status-im/status-go/services/wallet/token"
|
"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}
|
chainIDs := []uint64{walletCommon.EthereumMainnet, walletCommon.ArbitrumMainnet, walletCommon.OptimismMainnet, walletCommon.UnknownChainID}
|
||||||
|
|
||||||
for _, chainID := range chainIDs {
|
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)
|
processor.priceRoute.Store(key, testPriceRoute)
|
||||||
|
|
||||||
testInputParams := ProcessorInputParams{
|
testInputParams := ProcessorInputParams{
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"github.com/status-im/status-go/params"
|
"github.com/status-im/status-go/params"
|
||||||
walletCommon "github.com/status-im/status-go/services/wallet/common"
|
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/requests"
|
||||||
|
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/token"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
@ -45,9 +46,9 @@ var optimism = params.Network{
|
||||||
}
|
}
|
||||||
|
|
||||||
var testEstimationMap = map[string]requests.Estimation{
|
var testEstimationMap = map[string]requests.Estimation{
|
||||||
walletCommon.ProcessorTransferName: {Value: uint64(1000)},
|
pathProcessorCommon.ProcessorTransferName: {Value: uint64(1000)},
|
||||||
walletCommon.ProcessorBridgeHopName: {Value: uint64(5000)},
|
pathProcessorCommon.ProcessorBridgeHopName: {Value: uint64(5000)},
|
||||||
walletCommon.ProcessorSwapParaswapName: {Value: uint64(2000)},
|
pathProcessorCommon.ProcessorSwapParaswapName: {Value: uint64(2000)},
|
||||||
}
|
}
|
||||||
|
|
||||||
type expectedResult struct {
|
type expectedResult struct {
|
||||||
|
@ -68,15 +69,15 @@ func TestPathProcessors(t *testing.T) {
|
||||||
TestsMode: true,
|
TestsMode: true,
|
||||||
},
|
},
|
||||||
expected: map[string]expectedResult{
|
expected: map[string]expectedResult{
|
||||||
walletCommon.ProcessorTransferName: {
|
pathProcessorCommon.ProcessorTransferName: {
|
||||||
expected: false,
|
expected: false,
|
||||||
expectedError: ErrNoChainSet,
|
expectedError: ErrNoChainSet,
|
||||||
},
|
},
|
||||||
walletCommon.ProcessorBridgeHopName: {
|
pathProcessorCommon.ProcessorBridgeHopName: {
|
||||||
expected: false,
|
expected: false,
|
||||||
expectedError: ErrNoChainSet,
|
expectedError: ErrNoChainSet,
|
||||||
},
|
},
|
||||||
walletCommon.ProcessorSwapParaswapName: {
|
pathProcessorCommon.ProcessorSwapParaswapName: {
|
||||||
expected: false,
|
expected: false,
|
||||||
expectedError: ErrNoChainSet,
|
expectedError: ErrNoChainSet,
|
||||||
},
|
},
|
||||||
|
@ -91,15 +92,15 @@ func TestPathProcessors(t *testing.T) {
|
||||||
TestEstimationMap: testEstimationMap,
|
TestEstimationMap: testEstimationMap,
|
||||||
},
|
},
|
||||||
expected: map[string]expectedResult{
|
expected: map[string]expectedResult{
|
||||||
walletCommon.ProcessorTransferName: {
|
pathProcessorCommon.ProcessorTransferName: {
|
||||||
expected: false,
|
expected: false,
|
||||||
expectedError: ErrNoTokenSet,
|
expectedError: ErrNoTokenSet,
|
||||||
},
|
},
|
||||||
walletCommon.ProcessorBridgeHopName: {
|
pathProcessorCommon.ProcessorBridgeHopName: {
|
||||||
expected: false,
|
expected: false,
|
||||||
expectedError: ErrNoTokenSet,
|
expectedError: ErrNoTokenSet,
|
||||||
},
|
},
|
||||||
walletCommon.ProcessorSwapParaswapName: {
|
pathProcessorCommon.ProcessorSwapParaswapName: {
|
||||||
expected: false,
|
expected: false,
|
||||||
expectedError: ErrToAndFromTokensMustBeSet,
|
expectedError: ErrToAndFromTokensMustBeSet,
|
||||||
},
|
},
|
||||||
|
@ -117,15 +118,15 @@ func TestPathProcessors(t *testing.T) {
|
||||||
TestEstimationMap: testEstimationMap,
|
TestEstimationMap: testEstimationMap,
|
||||||
},
|
},
|
||||||
expected: map[string]expectedResult{
|
expected: map[string]expectedResult{
|
||||||
walletCommon.ProcessorTransferName: {
|
pathProcessorCommon.ProcessorTransferName: {
|
||||||
expected: true,
|
expected: true,
|
||||||
expectedError: nil,
|
expectedError: nil,
|
||||||
},
|
},
|
||||||
walletCommon.ProcessorBridgeHopName: {
|
pathProcessorCommon.ProcessorBridgeHopName: {
|
||||||
expected: false,
|
expected: false,
|
||||||
expectedError: ErrFromAndToChainsMustBeDifferent,
|
expectedError: ErrFromAndToChainsMustBeDifferent,
|
||||||
},
|
},
|
||||||
walletCommon.ProcessorSwapParaswapName: {
|
pathProcessorCommon.ProcessorSwapParaswapName: {
|
||||||
expected: false,
|
expected: false,
|
||||||
expectedError: ErrToAndFromTokensMustBeSet,
|
expectedError: ErrToAndFromTokensMustBeSet,
|
||||||
},
|
},
|
||||||
|
@ -146,15 +147,15 @@ func TestPathProcessors(t *testing.T) {
|
||||||
TestEstimationMap: testEstimationMap,
|
TestEstimationMap: testEstimationMap,
|
||||||
},
|
},
|
||||||
expected: map[string]expectedResult{
|
expected: map[string]expectedResult{
|
||||||
walletCommon.ProcessorTransferName: {
|
pathProcessorCommon.ProcessorTransferName: {
|
||||||
expected: false,
|
expected: false,
|
||||||
expectedError: ErrToTokenShouldNotBeSet,
|
expectedError: ErrToTokenShouldNotBeSet,
|
||||||
},
|
},
|
||||||
walletCommon.ProcessorBridgeHopName: {
|
pathProcessorCommon.ProcessorBridgeHopName: {
|
||||||
expected: false,
|
expected: false,
|
||||||
expectedError: ErrToTokenShouldNotBeSet,
|
expectedError: ErrToTokenShouldNotBeSet,
|
||||||
},
|
},
|
||||||
walletCommon.ProcessorSwapParaswapName: {
|
pathProcessorCommon.ProcessorSwapParaswapName: {
|
||||||
expected: false,
|
expected: false,
|
||||||
expectedError: ErrFromAndToTokensMustBeDifferent,
|
expectedError: ErrFromAndToTokensMustBeDifferent,
|
||||||
},
|
},
|
||||||
|
@ -175,15 +176,15 @@ func TestPathProcessors(t *testing.T) {
|
||||||
TestEstimationMap: testEstimationMap,
|
TestEstimationMap: testEstimationMap,
|
||||||
},
|
},
|
||||||
expected: map[string]expectedResult{
|
expected: map[string]expectedResult{
|
||||||
walletCommon.ProcessorTransferName: {
|
pathProcessorCommon.ProcessorTransferName: {
|
||||||
expected: false,
|
expected: false,
|
||||||
expectedError: ErrToTokenShouldNotBeSet,
|
expectedError: ErrToTokenShouldNotBeSet,
|
||||||
},
|
},
|
||||||
walletCommon.ProcessorBridgeHopName: {
|
pathProcessorCommon.ProcessorBridgeHopName: {
|
||||||
expected: false,
|
expected: false,
|
||||||
expectedError: ErrToTokenShouldNotBeSet,
|
expectedError: ErrToTokenShouldNotBeSet,
|
||||||
},
|
},
|
||||||
walletCommon.ProcessorSwapParaswapName: {
|
pathProcessorCommon.ProcessorSwapParaswapName: {
|
||||||
expected: true,
|
expected: true,
|
||||||
expectedError: nil,
|
expectedError: nil,
|
||||||
},
|
},
|
||||||
|
@ -198,15 +199,15 @@ func TestPathProcessors(t *testing.T) {
|
||||||
TestEstimationMap: testEstimationMap,
|
TestEstimationMap: testEstimationMap,
|
||||||
},
|
},
|
||||||
expected: map[string]expectedResult{
|
expected: map[string]expectedResult{
|
||||||
walletCommon.ProcessorTransferName: {
|
pathProcessorCommon.ProcessorTransferName: {
|
||||||
expected: false,
|
expected: false,
|
||||||
expectedError: ErrNoTokenSet,
|
expectedError: ErrNoTokenSet,
|
||||||
},
|
},
|
||||||
walletCommon.ProcessorBridgeHopName: {
|
pathProcessorCommon.ProcessorBridgeHopName: {
|
||||||
expected: false,
|
expected: false,
|
||||||
expectedError: ErrNoTokenSet,
|
expectedError: ErrNoTokenSet,
|
||||||
},
|
},
|
||||||
walletCommon.ProcessorSwapParaswapName: {
|
pathProcessorCommon.ProcessorSwapParaswapName: {
|
||||||
expected: false,
|
expected: false,
|
||||||
expectedError: ErrFromAndToChainsMustBeSame,
|
expectedError: ErrFromAndToChainsMustBeSame,
|
||||||
},
|
},
|
||||||
|
@ -224,15 +225,15 @@ func TestPathProcessors(t *testing.T) {
|
||||||
TestEstimationMap: testEstimationMap,
|
TestEstimationMap: testEstimationMap,
|
||||||
},
|
},
|
||||||
expected: map[string]expectedResult{
|
expected: map[string]expectedResult{
|
||||||
walletCommon.ProcessorTransferName: {
|
pathProcessorCommon.ProcessorTransferName: {
|
||||||
expected: false,
|
expected: false,
|
||||||
expectedError: nil,
|
expectedError: nil,
|
||||||
},
|
},
|
||||||
walletCommon.ProcessorBridgeHopName: {
|
pathProcessorCommon.ProcessorBridgeHopName: {
|
||||||
expected: true,
|
expected: true,
|
||||||
expectedError: nil,
|
expectedError: nil,
|
||||||
},
|
},
|
||||||
walletCommon.ProcessorSwapParaswapName: {
|
pathProcessorCommon.ProcessorSwapParaswapName: {
|
||||||
expected: false,
|
expected: false,
|
||||||
expectedError: ErrFromAndToChainsMustBeSame,
|
expectedError: ErrFromAndToChainsMustBeSame,
|
||||||
},
|
},
|
||||||
|
@ -253,15 +254,15 @@ func TestPathProcessors(t *testing.T) {
|
||||||
TestEstimationMap: testEstimationMap,
|
TestEstimationMap: testEstimationMap,
|
||||||
},
|
},
|
||||||
expected: map[string]expectedResult{
|
expected: map[string]expectedResult{
|
||||||
walletCommon.ProcessorTransferName: {
|
pathProcessorCommon.ProcessorTransferName: {
|
||||||
expected: false,
|
expected: false,
|
||||||
expectedError: ErrToTokenShouldNotBeSet,
|
expectedError: ErrToTokenShouldNotBeSet,
|
||||||
},
|
},
|
||||||
walletCommon.ProcessorBridgeHopName: {
|
pathProcessorCommon.ProcessorBridgeHopName: {
|
||||||
expected: false,
|
expected: false,
|
||||||
expectedError: ErrToTokenShouldNotBeSet,
|
expectedError: ErrToTokenShouldNotBeSet,
|
||||||
},
|
},
|
||||||
walletCommon.ProcessorSwapParaswapName: {
|
pathProcessorCommon.ProcessorSwapParaswapName: {
|
||||||
expected: false,
|
expected: false,
|
||||||
expectedError: ErrFromAndToChainsMustBeSame,
|
expectedError: ErrFromAndToChainsMustBeSame,
|
||||||
},
|
},
|
||||||
|
@ -282,15 +283,15 @@ func TestPathProcessors(t *testing.T) {
|
||||||
TestEstimationMap: testEstimationMap,
|
TestEstimationMap: testEstimationMap,
|
||||||
},
|
},
|
||||||
expected: map[string]expectedResult{
|
expected: map[string]expectedResult{
|
||||||
walletCommon.ProcessorTransferName: {
|
pathProcessorCommon.ProcessorTransferName: {
|
||||||
expected: false,
|
expected: false,
|
||||||
expectedError: ErrToTokenShouldNotBeSet,
|
expectedError: ErrToTokenShouldNotBeSet,
|
||||||
},
|
},
|
||||||
walletCommon.ProcessorBridgeHopName: {
|
pathProcessorCommon.ProcessorBridgeHopName: {
|
||||||
expected: false,
|
expected: false,
|
||||||
expectedError: ErrToTokenShouldNotBeSet,
|
expectedError: ErrToTokenShouldNotBeSet,
|
||||||
},
|
},
|
||||||
walletCommon.ProcessorSwapParaswapName: {
|
pathProcessorCommon.ProcessorSwapParaswapName: {
|
||||||
expected: false,
|
expected: false,
|
||||||
expectedError: ErrFromAndToChainsMustBeSame,
|
expectedError: ErrFromAndToChainsMustBeSame,
|
||||||
},
|
},
|
||||||
|
@ -303,11 +304,11 @@ func TestPathProcessors(t *testing.T) {
|
||||||
t.Run(fmt.Sprintf("%s[%s]", processorName, tt.name), func(t *testing.T) {
|
t.Run(fmt.Sprintf("%s[%s]", processorName, tt.name), func(t *testing.T) {
|
||||||
|
|
||||||
var processor PathProcessor
|
var processor PathProcessor
|
||||||
if processorName == walletCommon.ProcessorTransferName {
|
if processorName == pathProcessorCommon.ProcessorTransferName {
|
||||||
processor = NewTransferProcessor(nil, nil)
|
processor = NewTransferProcessor(nil, nil)
|
||||||
} else if processorName == walletCommon.ProcessorBridgeHopName {
|
} else if processorName == pathProcessorCommon.ProcessorBridgeHopName {
|
||||||
processor = NewHopBridgeProcessor(nil, nil, nil, nil)
|
processor = NewHopBridgeProcessor(nil, nil, nil, nil)
|
||||||
} else if processorName == walletCommon.ProcessorSwapParaswapName {
|
} else if processorName == pathProcessorCommon.ProcessorSwapParaswapName {
|
||||||
processor = NewSwapParaswapProcessor(nil, nil, nil)
|
processor = NewSwapParaswapProcessor(nil, nil, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ import (
|
||||||
"github.com/status-im/status-go/eth-node/types"
|
"github.com/status-im/status-go/eth-node/types"
|
||||||
"github.com/status-im/status-go/rpc"
|
"github.com/status-im/status-go/rpc"
|
||||||
walletCommon "github.com/status-im/status-go/services/wallet/common"
|
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/services/wallet/wallettypes"
|
||||||
"github.com/status-im/status-go/transactions"
|
"github.com/status-im/status-go/transactions"
|
||||||
)
|
)
|
||||||
|
@ -28,11 +29,11 @@ func NewTransferProcessor(rpcClient *rpc.Client, transactor transactions.Transac
|
||||||
}
|
}
|
||||||
|
|
||||||
func createTransferErrorResponse(err error) error {
|
func createTransferErrorResponse(err error) error {
|
||||||
return createErrorResponse(walletCommon.ProcessorTransferName, err)
|
return createErrorResponse(pathProcessorCommon.ProcessorTransferName, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *TransferProcessor) Name() string {
|
func (s *TransferProcessor) Name() string {
|
||||||
return walletCommon.ProcessorTransferName
|
return pathProcessorCommon.ProcessorTransferName
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *TransferProcessor) AvailableFor(params ProcessorInputParams) (bool, error) {
|
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
|
return uint64(increasedEstimation), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ import (
|
||||||
"github.com/status-im/status-go/services/wallet/responses"
|
"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/fees"
|
||||||
"github.com/status-im/status-go/services/wallet/router/pathprocessor"
|
"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/routes"
|
||||||
"github.com/status-im/status-go/services/wallet/router/sendtype"
|
"github.com/status-im/status-go/services/wallet/router/sendtype"
|
||||||
"github.com/status-im/status-go/services/wallet/token"
|
"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 {
|
if path.TxBonderFees.ToInt().Cmp(path.AmountOut.ToInt()) > 0 {
|
||||||
return hasPositiveBalance, ErrLowAmountInForHopBridge
|
return hasPositiveBalance, ErrLowAmountInForHopBridge
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -5,6 +5,7 @@ import (
|
||||||
|
|
||||||
"github.com/status-im/status-go/params"
|
"github.com/status-im/status-go/params"
|
||||||
walletCommon "github.com/status-im/status-go/services/wallet/common"
|
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
|
type SendType int
|
||||||
|
@ -37,24 +38,24 @@ func (s SendType) IsStickersTransfer() bool {
|
||||||
func (s SendType) CanUseProcessor(pathProcessorName string) bool {
|
func (s SendType) CanUseProcessor(pathProcessorName string) bool {
|
||||||
switch s {
|
switch s {
|
||||||
case Transfer:
|
case Transfer:
|
||||||
return pathProcessorName == walletCommon.ProcessorTransferName ||
|
return pathProcessorName == pathProcessorCommon.ProcessorTransferName ||
|
||||||
walletCommon.IsProcessorBridge(pathProcessorName)
|
walletCommon.IsProcessorBridge(pathProcessorName)
|
||||||
case Bridge:
|
case Bridge:
|
||||||
return walletCommon.IsProcessorBridge(pathProcessorName)
|
return walletCommon.IsProcessorBridge(pathProcessorName)
|
||||||
case Swap:
|
case Swap:
|
||||||
return walletCommon.IsProcessorSwap(pathProcessorName)
|
return walletCommon.IsProcessorSwap(pathProcessorName)
|
||||||
case ERC721Transfer:
|
case ERC721Transfer:
|
||||||
return pathProcessorName == walletCommon.ProcessorERC721Name
|
return pathProcessorName == pathProcessorCommon.ProcessorERC721Name
|
||||||
case ERC1155Transfer:
|
case ERC1155Transfer:
|
||||||
return pathProcessorName == walletCommon.ProcessorERC1155Name
|
return pathProcessorName == pathProcessorCommon.ProcessorERC1155Name
|
||||||
case ENSRegister:
|
case ENSRegister:
|
||||||
return pathProcessorName == walletCommon.ProcessorENSRegisterName
|
return pathProcessorName == pathProcessorCommon.ProcessorENSRegisterName
|
||||||
case ENSRelease:
|
case ENSRelease:
|
||||||
return pathProcessorName == walletCommon.ProcessorENSReleaseName
|
return pathProcessorName == pathProcessorCommon.ProcessorENSReleaseName
|
||||||
case ENSSetPubKey:
|
case ENSSetPubKey:
|
||||||
return pathProcessorName == walletCommon.ProcessorENSPublicKeyName
|
return pathProcessorName == pathProcessorCommon.ProcessorENSPublicKeyName
|
||||||
case StickersBuy:
|
case StickersBuy:
|
||||||
return pathProcessorName == walletCommon.ProcessorStickersBuyName
|
return pathProcessorName == pathProcessorCommon.ProcessorStickersBuyName
|
||||||
default:
|
default:
|
||||||
return true
|
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 {
|
func (s SendType) ProcessZeroAmountInProcessor(amountIn *big.Int, amountOut *big.Int, processorName string) bool {
|
||||||
if amountIn.Cmp(walletCommon.ZeroBigIntValue()) == 0 {
|
if amountIn.Cmp(walletCommon.ZeroBigIntValue()) == 0 {
|
||||||
if s == Transfer {
|
if s == Transfer {
|
||||||
if processorName != walletCommon.ProcessorTransferName {
|
if processorName != pathProcessorCommon.ProcessorTransferName {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
} else if s == Swap {
|
} else if s == Swap {
|
||||||
|
|
|
@ -16,6 +16,7 @@ import (
|
||||||
"github.com/status-im/status-go/services/wallet/requests"
|
"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/responses"
|
||||||
"github.com/status-im/status-go/services/wallet/router/pathprocessor"
|
"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/routes"
|
||||||
"github.com/status-im/status-go/services/wallet/wallettypes"
|
"github.com/status-im/status-go/services/wallet/wallettypes"
|
||||||
"github.com/status-im/status-go/transactions"
|
"github.com/status-im/status-go/transactions"
|
||||||
|
@ -180,13 +181,13 @@ func buildTxForPath(transactor transactions.TransactorIface, path *routes.Path,
|
||||||
if !path.FromToken.IsNative() {
|
if !path.FromToken.IsNative() {
|
||||||
sendArgs.Value = (*hexutil.Big)(big.NewInt(0))
|
sendArgs.Value = (*hexutil.Big)(big.NewInt(0))
|
||||||
|
|
||||||
if path.ProcessorName == walletCommon.ProcessorTransferName ||
|
if path.ProcessorName == pathProcessorCommon.ProcessorTransferName ||
|
||||||
path.ProcessorName == walletCommon.ProcessorStickersBuyName ||
|
path.ProcessorName == pathProcessorCommon.ProcessorStickersBuyName ||
|
||||||
path.ProcessorName == walletCommon.ProcessorENSRegisterName ||
|
path.ProcessorName == pathProcessorCommon.ProcessorENSRegisterName ||
|
||||||
path.ProcessorName == walletCommon.ProcessorENSReleaseName ||
|
path.ProcessorName == pathProcessorCommon.ProcessorENSReleaseName ||
|
||||||
path.ProcessorName == walletCommon.ProcessorENSPublicKeyName ||
|
path.ProcessorName == pathProcessorCommon.ProcessorENSPublicKeyName ||
|
||||||
path.ProcessorName == walletCommon.ProcessorERC721Name ||
|
path.ProcessorName == pathProcessorCommon.ProcessorERC721Name ||
|
||||||
path.ProcessorName == walletCommon.ProcessorERC1155Name {
|
path.ProcessorName == pathProcessorCommon.ProcessorERC1155Name {
|
||||||
// TODO: update functions from `TransactorIface` to use `ToContractAddress` (as an address of the contract a transaction should be sent to)
|
// 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
|
// and `To` (as the destination address, recipient) of `SendTxArgs` struct appropriately
|
||||||
toContractAddr := types.Address(path.FromToken.Address)
|
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)
|
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 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
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -367,7 +368,7 @@ func (tm *TransactionManager) SendRouterTransactions(ctx context.Context, multiT
|
||||||
transactions = append(transactions, response)
|
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 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
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue