diff --git a/package.json b/package.json index 924250f..7657eea 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@orionprotocol/sdk", - "version": "0.17.2", + "version": "0.17.3", "description": "Orion Protocol SDK", "main": "./lib/esm/index.js", "module": "./lib/esm/index.js", diff --git a/src/Orion/index.ts b/src/Orion/index.ts index af3264a..0585634 100644 --- a/src/Orion/index.ts +++ b/src/Orion/index.ts @@ -1,5 +1,6 @@ import { merge } from 'merge-anything'; import { chains, envs } from '../config'; +import { networkCodes } from '../constants'; import OrionUnit from '../OrionUnit'; import OrionAnalytics from '../services/OrionAnalytics'; import { ReferralSystem } from '../services/ReferralSystem'; @@ -17,7 +18,7 @@ type EnvConfig = { >; } -// type KnownEnv = 'testing' | 'staging' | 'production'; +type KnownEnv = 'testing' | 'staging' | 'production'; export default class Orion { public readonly env?: string; @@ -30,7 +31,7 @@ export default class Orion { constructor(); constructor( - env: string, + env: KnownEnv, overrides?: DeepPartial ); @@ -43,7 +44,7 @@ export default class Orion { // TODO: bridge constructor( - envOrConfig: string | EnvConfig = 'production', + envOrConfig: KnownEnv | EnvConfig = 'production', overrides?: DeepPartial ) { let config: EnvConfig; @@ -120,7 +121,7 @@ export default class Orion { getUnit(chainId: SupportedChainId): OrionUnit; - getUnit(networkCode: string): OrionUnit; + getUnit(networkCode: typeof networkCodes[number]): OrionUnit; getUnit(networkCodeOrChainId: string): OrionUnit { let unit: OrionUnit | undefined; diff --git a/src/OrionUnit/index.ts b/src/OrionUnit/index.ts index 1396f76..6dd3272 100644 --- a/src/OrionUnit/index.ts +++ b/src/OrionUnit/index.ts @@ -6,6 +6,7 @@ import type { SupportedChainId, VerboseOrionUnitConfig } from '../types'; import Exchange from './Exchange'; import FarmingManager from './FarmingManager'; import { chains } from '../config'; +import { networkCodes } from '../constants'; // type KnownConfig = { // env: string; @@ -17,7 +18,7 @@ import { chains } from '../config'; export default class OrionUnit { // public readonly env?: string; - public readonly networkCode: string; + public readonly networkCode: typeof networkCodes[number]; public readonly chainId: SupportedChainId; diff --git a/src/config/schemas/pureChainSchema.ts b/src/config/schemas/pureChainSchema.ts index 7d86751..03be363 100644 --- a/src/config/schemas/pureChainSchema.ts +++ b/src/config/schemas/pureChainSchema.ts @@ -1,11 +1,12 @@ import { z } from 'zod'; +import { networkCodes } from '../../constants'; import { SupportedChainId } from '../../types'; export const pureChainInfoPayloadSchema = z.object({ chainId: z.nativeEnum(SupportedChainId), label: z.string(), shortName: z.string(), - code: z.string(), + code: z.enum(networkCodes), explorer: z.string(), rpc: z.string(), baseCurrencyName: z.string(), diff --git a/src/services/OrionBlockchain/index.ts b/src/services/OrionBlockchain/index.ts index 14bc387..415e0e0 100644 --- a/src/services/OrionBlockchain/index.ts +++ b/src/services/OrionBlockchain/index.ts @@ -40,7 +40,7 @@ type AtomicSwapHistoryBaseQuery = { receiver?: string, used?: 0 | 1, page?: number, - sourceNetworkCode?: 'ftm' | 'bsc' | 'eth' | 'polygon' | 'okc', + sourceNetworkCode?: typeof networkCodes[number], } type AtomicSwapHistorySourceQuery = AtomicSwapHistoryBaseQuery & {