chore_: checks per sending type added (part3)
This commit is contained in:
parent
7a016d0859
commit
4a1a29b6a5
|
@ -556,6 +556,10 @@ func (r *Router) SuggestedRoutes(
|
|||
continue
|
||||
}
|
||||
|
||||
if !sendType.isAvailableBetween(network, dest) {
|
||||
continue
|
||||
}
|
||||
|
||||
if len(preferedChainIDs) > 0 && !containsNetworkChainID(dest, preferedChainIDs) {
|
||||
continue
|
||||
}
|
||||
|
|
|
@ -103,6 +103,22 @@ func (s SendType) canUseBridge(b bridge.Bridge) bool {
|
|||
}
|
||||
}
|
||||
|
||||
func (s SendType) isAvailableBetween(from, to *params.Network) bool {
|
||||
if s.IsCollectiblesTransfer() {
|
||||
return from.ChainID == to.ChainID
|
||||
}
|
||||
|
||||
if s == Bridge {
|
||||
return from.ChainID != to.ChainID
|
||||
}
|
||||
|
||||
if s == Swap {
|
||||
return from.ChainID == to.ChainID
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func (s SendType) isAvailableFor(network *params.Network) bool {
|
||||
// Set of network ChainIDs allowed for any type of transaction
|
||||
allAllowedNetworks := map[uint64]bool{
|
||||
|
|
|
@ -407,6 +407,14 @@ func (r *Router) SuggestedRoutesV2(ctx context.Context, input *RouteInputParams)
|
|||
continue
|
||||
}
|
||||
|
||||
if !input.SendType.isAvailableFor(network) {
|
||||
continue
|
||||
}
|
||||
|
||||
if !input.SendType.isAvailableBetween(network, dest) {
|
||||
continue
|
||||
}
|
||||
|
||||
if len(input.PreferedChainIDs) > 0 && !containsNetworkChainID(dest, input.PreferedChainIDs) {
|
||||
continue
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue