mirror of
https://github.com/orionprotocol/sdk.git
synced 2026-03-25 23:27:41 +03:00
Added isNetworkCodeInEnvironment
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@orionprotocol/sdk",
|
||||
"version": "0.5.11",
|
||||
"version": "0.5.12",
|
||||
"description": "Orion Protocol SDK",
|
||||
"main": "./lib/esm/index.js",
|
||||
"module": "./lib/esm/index.js",
|
||||
|
||||
@@ -9,6 +9,7 @@ export { default as denormalizeNumber } from './denormalizeNumber';
|
||||
export { default as normalizeNumber } from './normalizeNumber';
|
||||
export { default as getSwapPair } from './getSwapPair';
|
||||
export { default as getSwapSide } from './getSwapSide';
|
||||
export { default as isNetworkCodeInEnvironment } from './isNetworkCodeInEnvironment';
|
||||
|
||||
// export { default as HttpError } from './httpError';
|
||||
|
||||
|
||||
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