chore_: checks per sending type added (part3)

This commit is contained in:
Sale Djenic 2024-05-16 12:22:32 +02:00 committed by saledjenic
parent 7a016d0859
commit 4a1a29b6a5
3 changed files with 28 additions and 0 deletions

View File

@ -556,6 +556,10 @@ func (r *Router) SuggestedRoutes(
continue continue
} }
if !sendType.isAvailableBetween(network, dest) {
continue
}
if len(preferedChainIDs) > 0 && !containsNetworkChainID(dest, preferedChainIDs) { if len(preferedChainIDs) > 0 && !containsNetworkChainID(dest, preferedChainIDs) {
continue continue
} }

View File

@ -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 { func (s SendType) isAvailableFor(network *params.Network) bool {
// Set of network ChainIDs allowed for any type of transaction // Set of network ChainIDs allowed for any type of transaction
allAllowedNetworks := map[uint64]bool{ allAllowedNetworks := map[uint64]bool{

View File

@ -407,6 +407,14 @@ func (r *Router) SuggestedRoutesV2(ctx context.Context, input *RouteInputParams)
continue continue
} }
if !input.SendType.isAvailableFor(network) {
continue
}
if !input.SendType.isAvailableBetween(network, dest) {
continue
}
if len(input.PreferedChainIDs) > 0 && !containsNetworkChainID(dest, input.PreferedChainIDs) { if len(input.PreferedChainIDs) > 0 && !containsNetworkChainID(dest, input.PreferedChainIDs) {
continue continue
} }