-
Notifications
You must be signed in to change notification settings - Fork 247
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: 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
- Loading branch information
1 parent
ee7f4d2
commit 38e658a
Showing
16 changed files
with
424 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package requests | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/ethereum/go-ethereum/common/hexutil" | ||
"github.com/status-im/status-go/errors" | ||
"github.com/status-im/status-go/services/wallet/router/fees" | ||
) | ||
|
||
var ( | ||
ErrMaxFeesPerGasRequired = &errors.ErrorResponse{Code: errors.ErrorCode("WRC-001"), Details: "maxFeesPerGas is required"} | ||
ErrPriorityFeeRequired = &errors.ErrorResponse{Code: errors.ErrorCode("WRC-002"), Details: "priorityFee is required"} | ||
) | ||
|
||
type PathTxCustomParams struct { | ||
GasFeeMode fees.GasFeeMode `json:"gasFeeMode" validate:"required"` | ||
Nonce uint64 `json:"nonce"` | ||
GasAmount uint64 `json:"gasAmount"` | ||
MaxFeesPerGas *hexutil.Big `json:"maxFeesPerGas"` | ||
PriorityFee *hexutil.Big `json:"priorityFee"` | ||
} | ||
|
||
type PathTxIdentity struct { | ||
RouterInputParamsUuid string `json:"routerInputParamsUuid" validate:"required"` | ||
PathName string `json:"pathName" validate:"required"` | ||
ChainID uint64 `json:"chainID" validate:"required"` | ||
IsApprovalTx bool `json:"isApprovalTx"` | ||
} | ||
|
||
func (p *PathTxIdentity) PathIdentity() string { | ||
return fmt.Sprintf("%s-%s-%d", p.RouterInputParamsUuid, p.PathName, p.ChainID) | ||
} | ||
|
||
func (p *PathTxIdentity) TxIdentityKey() string { | ||
return fmt.Sprintf("%s-%v", p.PathIdentity(), p.IsApprovalTx) | ||
} | ||
|
||
func (p *PathTxCustomParams) Validate() error { | ||
if p.GasFeeMode != fees.GasFeeCustom { | ||
return nil | ||
} | ||
if p.MaxFeesPerGas == nil { | ||
return ErrMaxFeesPerGasRequired | ||
} | ||
if p.PriorityFee == nil { | ||
return ErrPriorityFeeRequired | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.