mirror of
https://github.com/status-im/status-go.git
synced 2025-01-24 21:49:54 +00:00
28506bcd17
This commit simplifies the sending process of the best route suggested by the router. It also makes the sending process the same for accounts (key pairs) migrated to a keycard and those stored locally in local keystore files. Deprecated endpoints: - `CreateMultiTransaction` - `ProceedWithTransactionsSignatures` Deprecated signal: - `wallet.sign.transactions` New endpoints: - `BuildTransactionsFromRoute` - `SendRouterTransactionsWithSignatures` The flow for sending the best router suggested by the router: - call `BuildTransactionsFromRoute` - wait for the `wallet.router.sign-transactions` signal - sign received hashes using `SignMessage` call or sign on keycard - call `SendRouterTransactionsWithSignatures` with the signatures of signed hashes from the previous step - `wallet.router.transactions-sent` signal will be sent after transactions are sent or if an error occurs New signals: - `wallet.router.sending-transactions-started` // notifies client that the sending transactions process started - `wallet.router.sign-transactions` // notifies client about the list of transactions that need to be signed - `wallet.router.transactions-sent` // notifies client about transactions that are sent - `wallet.transaction.status-changed` // notifies about status of sent transactions
60 lines
2.1 KiB
Go
60 lines
2.1 KiB
Go
package routes
|
|
|
|
import (
|
|
"math/big"
|
|
"reflect"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/ethereum/go-ethereum/common"
|
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
|
"github.com/status-im/status-go/params"
|
|
"github.com/status-im/status-go/services/wallet/router/fees"
|
|
"github.com/status-im/status-go/services/wallet/token"
|
|
)
|
|
|
|
func TestCopyPath(t *testing.T) {
|
|
addr := common.HexToAddress("0x123")
|
|
path := &Path{
|
|
ProcessorName: "test",
|
|
FromChain: ¶ms.Network{ChainID: 1},
|
|
ToChain: ¶ms.Network{ChainID: 2},
|
|
FromToken: &token.Token{Symbol: "symbol1"},
|
|
ToToken: &token.Token{Symbol: "symbol2"},
|
|
AmountIn: (*hexutil.Big)(big.NewInt(100)),
|
|
AmountInLocked: true,
|
|
AmountOut: (*hexutil.Big)(big.NewInt(200)),
|
|
SuggestedLevelsForMaxFeesPerGas: &fees.MaxFeesLevels{
|
|
Low: (*hexutil.Big)(big.NewInt(100)),
|
|
Medium: (*hexutil.Big)(big.NewInt(200)),
|
|
High: (*hexutil.Big)(big.NewInt(300)),
|
|
},
|
|
MaxFeesPerGas: (*hexutil.Big)(big.NewInt(100)),
|
|
TxBaseFee: (*hexutil.Big)(big.NewInt(100)),
|
|
TxPriorityFee: (*hexutil.Big)(big.NewInt(100)),
|
|
TxGasAmount: 100,
|
|
TxBonderFees: (*hexutil.Big)(big.NewInt(100)),
|
|
TxTokenFees: (*hexutil.Big)(big.NewInt(100)),
|
|
TxFee: (*hexutil.Big)(big.NewInt(100)),
|
|
TxL1Fee: (*hexutil.Big)(big.NewInt(100)),
|
|
ApprovalRequired: true,
|
|
ApprovalAmountRequired: (*hexutil.Big)(big.NewInt(100)),
|
|
ApprovalContractAddress: &addr,
|
|
ApprovalBaseFee: (*hexutil.Big)(big.NewInt(100)),
|
|
ApprovalPriorityFee: (*hexutil.Big)(big.NewInt(100)),
|
|
ApprovalGasAmount: 100,
|
|
ApprovalFee: (*hexutil.Big)(big.NewInt(100)),
|
|
ApprovalL1Fee: (*hexutil.Big)(big.NewInt(100)),
|
|
TxTotalFee: (*hexutil.Big)(big.NewInt(100)),
|
|
EstimatedTime: fees.TransactionEstimation(100),
|
|
RequiredTokenBalance: big.NewInt(100),
|
|
RequiredNativeBalance: big.NewInt(100),
|
|
SubtractFees: true,
|
|
}
|
|
|
|
newPath := path.Copy()
|
|
|
|
assert.True(t, reflect.DeepEqual(path, newPath))
|
|
}
|