Skip to content

Commit

Permalink
fix(wallet)_: applied custom tx changes to the path
Browse files Browse the repository at this point in the history
Before this change, custom parameters were applied only after the next fee update, now they will
be updated appropriately and immediately.
  • Loading branch information
saledjenic authored and alaibe committed Feb 13, 2025
1 parent 1e0afc5 commit 088e351
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
20 changes: 20 additions & 0 deletions services/wallet/router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,26 @@ func (r *Router) setCustomTxDetails(pathTxIdentity *requests.PathTxIdentity, pat
continue
}

if pathTxIdentity.IsApprovalTx {
path.ApprovalGasFeeMode = pathTxCustomParams.GasFeeMode
if pathTxCustomParams.GasFeeMode == fees.GasFeeCustom {
path.ApprovalTxNonce = (*hexutil.Uint64)(&pathTxCustomParams.Nonce)
path.ApprovalGasAmount = pathTxCustomParams.GasAmount
path.ApprovalMaxFeesPerGas = pathTxCustomParams.MaxFeesPerGas
path.ApprovalBaseFee = (*hexutil.Big)(new(big.Int).Sub(pathTxCustomParams.MaxFeesPerGas.ToInt(), pathTxCustomParams.PriorityFee.ToInt()))
path.ApprovalPriorityFee = pathTxCustomParams.PriorityFee
}
} else {
path.TxGasFeeMode = pathTxCustomParams.GasFeeMode
if pathTxCustomParams.GasFeeMode == fees.GasFeeCustom {
path.TxNonce = (*hexutil.Uint64)(&pathTxCustomParams.Nonce)
path.TxGasAmount = pathTxCustomParams.GasAmount
path.TxMaxFeesPerGas = pathTxCustomParams.MaxFeesPerGas
path.TxBaseFee = (*hexutil.Big)(new(big.Int).Sub(pathTxCustomParams.MaxFeesPerGas.ToInt(), pathTxCustomParams.PriorityFee.ToInt()))
path.TxPriorityFee = pathTxCustomParams.PriorityFee
}
}

r.lastInputParamsMutex.Lock()
if r.lastInputParams.PathTxCustomParams == nil {
r.lastInputParams.PathTxCustomParams = make(map[string]*requests.PathTxCustomParams)
Expand Down
22 changes: 18 additions & 4 deletions services/wallet/router/routes/router_path.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,24 @@ func (p *Path) Copy() *Path {
}

if p.SuggestedLevelsForMaxFeesPerGas != nil {
newPath.SuggestedLevelsForMaxFeesPerGas = &fees.MaxFeesLevels{
Low: (*hexutil.Big)(big.NewInt(0).Set(p.SuggestedLevelsForMaxFeesPerGas.Low.ToInt())),
Medium: (*hexutil.Big)(big.NewInt(0).Set(p.SuggestedLevelsForMaxFeesPerGas.Medium.ToInt())),
High: (*hexutil.Big)(big.NewInt(0).Set(p.SuggestedLevelsForMaxFeesPerGas.High.ToInt())),
newPath.SuggestedLevelsForMaxFeesPerGas = &fees.MaxFeesLevels{}
if p.SuggestedLevelsForMaxFeesPerGas.Low != nil {
newPath.SuggestedLevelsForMaxFeesPerGas.Low = (*hexutil.Big)(big.NewInt(0).Set(p.SuggestedLevelsForMaxFeesPerGas.Low.ToInt()))
}
if p.SuggestedLevelsForMaxFeesPerGas.LowPriority != nil {
newPath.SuggestedLevelsForMaxFeesPerGas.LowPriority = (*hexutil.Big)(big.NewInt(0).Set(p.SuggestedLevelsForMaxFeesPerGas.LowPriority.ToInt()))
}
if p.SuggestedLevelsForMaxFeesPerGas.Medium != nil {
newPath.SuggestedLevelsForMaxFeesPerGas.Medium = (*hexutil.Big)(big.NewInt(0).Set(p.SuggestedLevelsForMaxFeesPerGas.Medium.ToInt()))
}
if p.SuggestedLevelsForMaxFeesPerGas.MediumPriority != nil {
newPath.SuggestedLevelsForMaxFeesPerGas.MediumPriority = (*hexutil.Big)(big.NewInt(0).Set(p.SuggestedLevelsForMaxFeesPerGas.MediumPriority.ToInt()))
}
if p.SuggestedLevelsForMaxFeesPerGas.High != nil {
newPath.SuggestedLevelsForMaxFeesPerGas.High = (*hexutil.Big)(big.NewInt(0).Set(p.SuggestedLevelsForMaxFeesPerGas.High.ToInt()))
}
if p.SuggestedLevelsForMaxFeesPerGas.HighPriority != nil {
newPath.SuggestedLevelsForMaxFeesPerGas.HighPriority = (*hexutil.Big)(big.NewInt(0).Set(p.SuggestedLevelsForMaxFeesPerGas.HighPriority.ToInt()))
}
}

Expand Down

0 comments on commit 088e351

Please sign in to comment.