feat(wallet)!: return routerV2 suggested routes whenever available, on top of error if the best route doesn't pass all checks
This commit is contained in:
parent
a006d80acf
commit
21101c9444
|
@ -133,9 +133,13 @@ type SuggestedRoutesV2 struct {
|
|||
NativeChainTokenPrice float64
|
||||
}
|
||||
|
||||
type ErrorResponseWithUUID struct {
|
||||
Uuid string
|
||||
ErrorResponse error
|
||||
type SuggestedRoutesV2Response struct {
|
||||
Uuid string `json:"Uuid"`
|
||||
Best []*PathV2 `json:"Best,omitempty"`
|
||||
Candidates []*PathV2 `json:"Candidates,omitempty"`
|
||||
TokenPrice *float64 `json:"TokenPrice,omitempty"`
|
||||
NativeChainTokenPrice *float64 `json:"NativeChainTokenPrice,omitempty"`
|
||||
ErrorResponse *errors.ErrorResponse `json:"ErrorResponse,omitempty"`
|
||||
}
|
||||
|
||||
type GraphV2 []*NodeV2
|
||||
|
@ -449,15 +453,23 @@ func (r *Router) SuggestedRoutesV2Async(input *RouteInputParams) {
|
|||
r.scheduler.Enqueue(routerTask, func(ctx context.Context) (interface{}, error) {
|
||||
return r.SuggestedRoutesV2(ctx, input)
|
||||
}, func(result interface{}, taskType async.TaskType, err error) {
|
||||
if err != nil {
|
||||
errResponse := &ErrorResponseWithUUID{
|
||||
routesResponse := SuggestedRoutesV2Response{
|
||||
Uuid: input.Uuid,
|
||||
ErrorResponse: errors.CreateErrorResponseFromError(err),
|
||||
}
|
||||
signal.SendWalletEvent(signal.SuggestedRoutes, errResponse)
|
||||
return
|
||||
|
||||
if err != nil {
|
||||
errorResponse := errors.CreateErrorResponseFromError(err)
|
||||
routesResponse.ErrorResponse = errorResponse.(*errors.ErrorResponse)
|
||||
}
|
||||
signal.SendWalletEvent(signal.SuggestedRoutes, result)
|
||||
|
||||
if suggestedRoutes, ok := result.(*SuggestedRoutesV2); ok && suggestedRoutes != nil {
|
||||
routesResponse.Best = suggestedRoutes.Best
|
||||
routesResponse.Candidates = suggestedRoutes.Candidates
|
||||
routesResponse.TokenPrice = &suggestedRoutes.TokenPrice
|
||||
routesResponse.NativeChainTokenPrice = &suggestedRoutes.NativeChainTokenPrice
|
||||
}
|
||||
|
||||
signal.SendWalletEvent(signal.SuggestedRoutes, routesResponse)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue