feat: Add logic to re caculate route for sending a transaction based on networks disabled by the user (#2742)
This commit is contained in:
parent
35c4001e57
commit
b2ce92fd41
|
@ -323,9 +323,9 @@ func (api *API) GetTransactionEstimatedTime(ctx context.Context, chainID uint64,
|
||||||
return api.s.feesManager.transactionEstimatedTime(ctx, chainID, maxFeePerGas), nil
|
return api.s.feesManager.transactionEstimatedTime(ctx, chainID, maxFeePerGas), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (api *API) GetSuggestedRoutes(ctx context.Context, account common.Address, amount float64, tokenSymbol string) (*SuggestedRoutes, error) {
|
func (api *API) GetSuggestedRoutes(ctx context.Context, account common.Address, amount float64, tokenSymbol string, disabledChainIDs []uint64) (*SuggestedRoutes, error) {
|
||||||
log.Debug("call to GetSuggestedRoutes")
|
log.Debug("call to GetSuggestedRoutes")
|
||||||
return api.router.suggestedRoutes(ctx, account, amount, tokenSymbol)
|
return api.router.suggestedRoutes(ctx, account, amount, tokenSymbol, disabledChainIDs)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (api *API) GetDerivedAddressesForPath(ctx context.Context, password string, derivedFrom string, path string, pageSize int, pageNumber int) ([]*DerivedAddress, error) {
|
func (api *API) GetDerivedAddressesForPath(ctx context.Context, password string, derivedFrom string, path string, pageSize int, pageNumber int) ([]*DerivedAddress, error) {
|
||||||
|
|
|
@ -49,7 +49,7 @@ func (r *Router) suitableTokenExists(ctx context.Context, network *params.Networ
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Router) suggestedRoutes(ctx context.Context, account common.Address, amount float64, tokenSymbol string) (*SuggestedRoutes, error) {
|
func (r *Router) suggestedRoutes(ctx context.Context, account common.Address, amount float64, tokenSymbol string, disabledChainIDs []uint64) (*SuggestedRoutes, error) {
|
||||||
areTestNetworksEnabled, err := r.s.accountsDB.GetTestNetworksEnabled()
|
areTestNetworksEnabled, err := r.s.accountsDB.GetTestNetworksEnabled()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -71,6 +71,19 @@ func (r *Router) suggestedRoutes(ctx context.Context, account common.Address, am
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
networkFound := false
|
||||||
|
for _, chainID := range disabledChainIDs {
|
||||||
|
networkFound = false
|
||||||
|
if chainID == network.ChainID {
|
||||||
|
networkFound = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// This is network cannot be used as a suggestedRoute as the user has disabled it
|
||||||
|
if networkFound {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
group.Add(func(c context.Context) error {
|
group.Add(func(c context.Context) error {
|
||||||
if tokenSymbol == network.NativeCurrencySymbol {
|
if tokenSymbol == network.NativeCurrencySymbol {
|
||||||
tokens := []*Token{&Token{
|
tokens := []*Token{&Token{
|
||||||
|
|
Loading…
Reference in New Issue