diff --git a/package.json b/package.json index 642fb4c..5da92bc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@orionprotocol/sdk", - "version": "0.17.14", + "version": "0.17.15", "description": "Orion Protocol SDK", "main": "./lib/esm/index.js", "module": "./lib/esm/index.js", diff --git a/src/config/schemas/pureEnvSchema.ts b/src/config/schemas/pureEnvSchema.ts index d17fe8b..e3d1ceb 100644 --- a/src/config/schemas/pureEnvSchema.ts +++ b/src/config/schemas/pureEnvSchema.ts @@ -28,7 +28,9 @@ export const pureEnvPayloadSchema = z.object({ ), }); +export const knownEnvs = ['production', 'staging', 'testing'] as const; + export const pureEnvSchema = z.record( - z.enum(['production', 'staging', 'testing']).or(z.string()), + z.enum(knownEnvs).or(z.string()), pureEnvPayloadSchema, ); diff --git a/src/types.ts b/src/types.ts index bf15f3d..75b521e 100644 --- a/src/types.ts +++ b/src/types.ts @@ -2,6 +2,7 @@ import type BigNumber from 'bignumber.js'; import type exchanges from './constants/exchanges'; import type subOrderStatuses from './constants/subOrderStatuses'; import type positionStatuses from './constants/positionStatuses'; +import type { knownEnvs } from './config/schemas'; export type DeepPartial = T extends object ? { [P in keyof T]?: DeepPartial; @@ -284,4 +285,4 @@ export type VerboseOrionUnitConfig = { } } -export type KnownEnv = 'testing' | 'staging' | 'production'; +export type KnownEnv = typeof knownEnvs[number]; diff --git a/src/utils/index.ts b/src/utils/index.ts index 93c2948..40b8c70 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -4,7 +4,6 @@ export { default as calculateNetworkFeeInFeeAsset } from './calculateNetworkFeeI export { default as calculateOrionFeeInFeeAsset } from './calculateOrionFeeInFeeAsset'; export { default as checkIsToken } from './checkIsToken'; export { default as generateSecret } from './generateSecret'; -export { default as isValidChainId } from './isValidChainId'; export { default as denormalizeNumber } from './denormalizeNumber'; export { default as normalizeNumber } from './normalizeNumber'; export { default as isNetworkCodeInEnvironment } from './isNetworkCodeInEnvironment'; @@ -14,6 +13,8 @@ export { default as toLowerCase } from './toLowerCase'; export { default as isUppercasedNetworkCode } from './isUppercasedNetworkCode'; export { default as getNativeCryptocurrency } from './getNativeCryptocurrency'; +export { default as isValidChainId } from './isValidChainId'; +export { default as isKnownEnv } from './isKnownEnv'; // export { default as HttpError } from './httpError'; export * from './typeHelpers'; diff --git a/src/utils/isKnownEnv.ts b/src/utils/isKnownEnv.ts new file mode 100644 index 0000000..3a1a03e --- /dev/null +++ b/src/utils/isKnownEnv.ts @@ -0,0 +1,8 @@ +import { knownEnvs } from '../config/schemas'; +import type { KnownEnv, } from '../types'; + +const isKnownEnv = (env: string): env is KnownEnv => { + return knownEnvs.some((knownEnv) => knownEnv === env); +} + +export default isKnownEnv;