2024-09-23 09:19:00 +02:00
|
|
|
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)),
|
|
|
|
},
|
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
2024-11-26 12:29:00 +01:00
|
|
|
TxMaxFeesPerGas: (*hexutil.Big)(big.NewInt(100)),
|
2024-09-23 09:19:00 +02:00
|
|
|
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)),
|
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
2024-11-26 12:29:00 +01:00
|
|
|
TxEstimatedTime: fees.TransactionEstimation(100),
|
2024-09-23 09:19:00 +02:00
|
|
|
TxFee: (*hexutil.Big)(big.NewInt(100)),
|
|
|
|
TxL1Fee: (*hexutil.Big)(big.NewInt(100)),
|
|
|
|
ApprovalRequired: true,
|
|
|
|
ApprovalAmountRequired: (*hexutil.Big)(big.NewInt(100)),
|
|
|
|
ApprovalContractAddress: &addr,
|
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
2024-11-26 12:29:00 +01:00
|
|
|
ApprovalMaxFeesPerGas: (*hexutil.Big)(big.NewInt(100)),
|
2024-09-23 09:19:00 +02:00
|
|
|
ApprovalBaseFee: (*hexutil.Big)(big.NewInt(100)),
|
|
|
|
ApprovalPriorityFee: (*hexutil.Big)(big.NewInt(100)),
|
|
|
|
ApprovalGasAmount: 100,
|
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
2024-11-26 12:29:00 +01:00
|
|
|
ApprovalEstimatedTime: fees.TransactionEstimation(100),
|
2024-09-23 09:19:00 +02:00
|
|
|
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))
|
|
|
|
}
|