mirror of
https://github.com/orionprotocol/sdk.git
synced 2026-03-16 16:21:32 +03:00
Added isNetworkCodeInEnvironment
This commit is contained in:
12
src/utils/isNetworkCodeInEnvironment.ts
Normal file
12
src/utils/isNetworkCodeInEnvironment.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { chains, envs } from '../config';
|
||||
|
||||
export default function isNetworkCodeInEnvironment(networkCode: string, env: string) {
|
||||
if (!(env in envs)) {
|
||||
throw new Error(`Env ${env} is not supported. Available environments is: ${Object.keys(envs).join(', ')}`);
|
||||
}
|
||||
const envInfo = envs[env];
|
||||
const envNetworks = envInfo?.networks;
|
||||
return Object.values(chains)
|
||||
.some((chain) => chain.code.toLowerCase() === networkCode.toLowerCase()
|
||||
&& chain.chainId in envNetworks);
|
||||
}
|
||||
Reference in New Issue
Block a user