2023-11-14 17:16:39 +00:00
|
|
|
package common
|
|
|
|
|
2024-06-06 19:57:29 +00:00
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"github.com/status-im/status-go/params"
|
|
|
|
)
|
2023-11-14 17:16:39 +00:00
|
|
|
|
|
|
|
// ShouldCancel returns true if the context has been cancelled and task should be aborted
|
|
|
|
func ShouldCancel(ctx context.Context) bool {
|
|
|
|
select {
|
|
|
|
case <-ctx.Done():
|
|
|
|
return true
|
|
|
|
default:
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
2024-06-06 19:57:29 +00:00
|
|
|
|
|
|
|
func NetworksToChainIDs(networks []*params.Network) []uint64 {
|
|
|
|
chainIDs := make([]uint64, 0)
|
|
|
|
for _, network := range networks {
|
|
|
|
chainIDs = append(chainIDs, network.ChainID)
|
|
|
|
}
|
|
|
|
|
|
|
|
return chainIDs
|
|
|
|
}
|