Fix: network codes

This commit is contained in:
Aleksandr Kraiz
2023-02-10 17:28:52 +04:00
parent bd1c8077bb
commit 7882b66871
5 changed files with 11 additions and 8 deletions

View File

@@ -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",

View File

@@ -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<EnvConfig>
);
@@ -43,7 +44,7 @@ export default class Orion {
// TODO: bridge
constructor(
envOrConfig: string | EnvConfig = 'production',
envOrConfig: KnownEnv | EnvConfig = 'production',
overrides?: DeepPartial<EnvConfig>
) {
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;

View File

@@ -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;

View File

@@ -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(),

View File

@@ -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 & {