-
Notifications
You must be signed in to change notification settings - Fork 249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Router clean up #5778
Router clean up #5778
Changes from all commits
aed621b
488038a
70476c5
599b49e
e4f58a0
900ad9b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ import ( | |
"github.com/status-im/status-go/services/wallet/onramp" | ||
"github.com/status-im/status-go/services/wallet/requests" | ||
"github.com/status-im/status-go/services/wallet/router" | ||
"github.com/status-im/status-go/services/wallet/router/fees" | ||
"github.com/status-im/status-go/services/wallet/router/pathprocessor" | ||
"github.com/status-im/status-go/services/wallet/thirdparty" | ||
"github.com/status-im/status-go/services/wallet/token" | ||
|
@@ -468,7 +469,7 @@ func (api *API) FetchTokenDetails(ctx context.Context, symbols []string) (map[st | |
return api.s.marketManager.FetchTokenDetails(symbols) | ||
} | ||
|
||
func (api *API) GetSuggestedFees(ctx context.Context, chainID uint64) (*router.SuggestedFeesGwei, error) { | ||
func (api *API) GetSuggestedFees(ctx context.Context, chainID uint64) (*fees.SuggestedFeesGwei, error) { | ||
log.Debug("call to GetSuggestedFees") | ||
return api.router.GetFeesManager().SuggestedFeesGwei(ctx, chainID) | ||
} | ||
|
@@ -478,7 +479,7 @@ func (api *API) GetEstimatedLatestBlockNumber(ctx context.Context, chainID uint6 | |
return api.s.blockChainState.GetEstimatedLatestBlockNumber(ctx, chainID) | ||
} | ||
|
||
func (api *API) GetTransactionEstimatedTime(ctx context.Context, chainID uint64, maxFeePerGas *big.Float) (router.TransactionEstimation, error) { | ||
func (api *API) GetTransactionEstimatedTime(ctx context.Context, chainID uint64, maxFeePerGas *big.Float) (fees.TransactionEstimation, error) { | ||
log.Debug("call to getTransactionEstimatedTime") | ||
return api.router.GetFeesManager().TransactionEstimatedTime(ctx, chainID, gweiToWei(maxFeePerGas)), nil | ||
} | ||
|
@@ -488,47 +489,28 @@ func gweiToWei(val *big.Float) *big.Int { | |
return res | ||
} | ||
|
||
func (api *API) GetSuggestedRoutes( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just mark it as deprecated and return an error for now. And remove the function when the clients are updated. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But I wanted to clean the api, not to keep things around, that's why we added the same names with V2 suffixes, to not make breaking changes. Also I plan to sync with @alwx (actually we already chat in the wallet channel) on this and don't plan to merge this before mobile is ready for this change, then we will sync and merge changes at the same time. |
||
ctx context.Context, | ||
sendType router.SendType, | ||
addrFrom common.Address, | ||
addrTo common.Address, | ||
amountIn *hexutil.Big, | ||
tokenID string, | ||
toTokenID string, | ||
disabledFromChainIDs, | ||
disabledToChainIDs, | ||
preferedChainIDs []uint64, | ||
gasFeeMode router.GasFeeMode, | ||
fromLockedAmount map[uint64]*hexutil.Big, | ||
) (*router.SuggestedRoutes, error) { | ||
func (api *API) GetSuggestedRoutes(ctx context.Context, input *requests.RouteInputParams) (*router.SuggestedRoutes, error) { | ||
log.Debug("call to GetSuggestedRoutes") | ||
|
||
testnetMode, err := api.s.rpcClient.NetworkManager.GetTestNetworksEnabled() | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return api.router.SuggestedRoutes(ctx, sendType, addrFrom, addrTo, amountIn.ToInt(), tokenID, toTokenID, disabledFromChainIDs, | ||
disabledToChainIDs, preferedChainIDs, gasFeeMode, fromLockedAmount, testnetMode) | ||
return api.router.SuggestedRoutes(ctx, input) | ||
} | ||
|
||
func (api *API) GetSuggestedRoutesV2(ctx context.Context, input *router.RouteInputParams) (*router.SuggestedRoutesV2, error) { | ||
log.Debug("call to GetSuggestedRoutesV2") | ||
func (api *API) GetSuggestedRoutesAsync(ctx context.Context, input *requests.RouteInputParams) { | ||
log.Debug("call to GetSuggestedRoutesAsync") | ||
|
||
return api.router.SuggestedRoutesV2(ctx, input) | ||
api.router.SuggestedRoutesAsync(input) | ||
} | ||
|
||
func (api *API) GetSuggestedRoutesV2Async(ctx context.Context, input *router.RouteInputParams) { | ||
log.Debug("call to GetSuggestedRoutesV2Async") | ||
func (api *API) StopSuggestedRoutesAsyncCalculation(ctx context.Context) { | ||
log.Debug("call to StopSuggestedRoutesAsyncCalculation") | ||
|
||
api.router.SuggestedRoutesV2Async(input) | ||
api.router.StopSuggestedRoutesAsyncCalculation() | ||
} | ||
|
||
func (api *API) StopSuggestedRoutesV2AsyncCalcualtion(ctx context.Context) { | ||
log.Debug("call to StopSuggestedRoutesV2AsyncCalcualtion") | ||
func (api *API) StopSuggestedRoutesCalculation(ctx context.Context) { | ||
log.Debug("call to StopSuggestedRoutesCalculation") | ||
|
||
api.router.StopSuggestedRoutesV2AsyncCalcualtion() | ||
api.router.StopSuggestedRoutesCalculation() | ||
} | ||
|
||
// Generates addresses for the provided paths, response doesn't include `HasActivity` value (if you need it check `GetAddressDetails` function) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why is this needed.
router
? Will it beRouterV2
orRouterV3
then?I believe this breaking change is very unnecessary.
Same about renaming files. Why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Router V2 was just a replacement for the old router, to not mess up with the code, while we're improving it. Also I don't like V2 in endpoint names, if we really want to have versioning then it should be done another way and passed as a property of input params.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or even have a separate service for this 🤔
Not a big deal. If the desktop/mobile will be adapted then it's 90% ok IMO.
Just in general, it's important to have a mindset of not introducing any breaking changes, I guess that's my point