status-go/services/wallet/router/routes/router_path_test.go
Sale Djenic b91c5fd29c feat(wallet)!: allowing client to set custom values for fees, nonce, gas
Removed properties from `Path` type:
- `MaxFeesPerGas`, based on the sending flow progress appropriate new properties (`TxMaxFeesPerGas`, `ApprovalMaxFeesPerGas`) should be used

Added new properties to `Path` type:
- `RouterInputParamsUuid`, used to identify from which router input params this path was created
- `TxNonce`, used to set nonce for the tx
- `TxMaxFeesPerGas`, used to set max fees per gas for the tx
- `TxEstimatedTime`, used to estimate time for executing the tx
- `ApprovalTxNonce`, used to set nonce for the approval tx
- `ApprovalTxMaxFeesPerGas`, used to set max fees per gas for the approval tx
- `ApprovalTxEstimatedTime`, used to estimate time for executing the approval tx

New request types added:
- `PathTxCustomParams`, used to pass tx custom params from the client
- `PathTxIdentity`, used to uniquely identify path (tx) to which the custom params need to be applied

New endpoints added:
- `SetFeeMode` used to set fee mode (`GasFeeLow`, `GasFeeMedium` or `GasFeeHigh`)
- `SetCustomTxDetails` used to set custom fee mode (`SetCustomTxDetails`), if this mode is set, client needs to provide:
  - Max fees per gas
  - Max priority fee
  - Nonce
  - Gas amount
2025-01-08 17:22:50 +01:00

62 lines
2.2 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: &params.Network{ChainID: 1},
ToChain: &params.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)),
},
TxMaxFeesPerGas: (*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)),
TxEstimatedTime: fees.TransactionEstimation(100),
TxFee: (*hexutil.Big)(big.NewInt(100)),
TxL1Fee: (*hexutil.Big)(big.NewInt(100)),
ApprovalRequired: true,
ApprovalAmountRequired: (*hexutil.Big)(big.NewInt(100)),
ApprovalContractAddress: &addr,
ApprovalMaxFeesPerGas: (*hexutil.Big)(big.NewInt(100)),
ApprovalBaseFee: (*hexutil.Big)(big.NewInt(100)),
ApprovalPriorityFee: (*hexutil.Big)(big.NewInt(100)),
ApprovalGasAmount: 100,
ApprovalEstimatedTime: fees.TransactionEstimation(100),
ApprovalFee: (*hexutil.Big)(big.NewInt(100)),
ApprovalL1Fee: (*hexutil.Big)(big.NewInt(100)),
TxTotalFee: (*hexutil.Big)(big.NewInt(100)),
RequiredTokenBalance: big.NewInt(100),
RequiredNativeBalance: big.NewInt(100),
SubtractFees: true,
}
newPath := path.Copy()
assert.True(t, reflect.DeepEqual(path, newPath))
}