From edc3586166ffcc602698bf7da8a37f77fbbca6fd Mon Sep 17 00:00:00 2001 From: TheJuze Date: Tue, 19 Mar 2024 17:34:00 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=97=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 4 +- package.json | 2 +- src/Orion/index.ts | 12 ++-- src/Unit/index.ts | 11 +--- src/config/envs.json | 98 ++--------------------------- src/config/index.ts | 2 +- src/config/schemas/pureEnvSchema.ts | 4 +- src/types.ts | 4 +- 8 files changed, 19 insertions(+), 118 deletions(-) diff --git a/package-lock.json b/package-lock.json index 39633be..c7495b1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@orionprotocol/sdk", - "version": "0.20.74-rc103", + "version": "0.20.74-rc104", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@orionprotocol/sdk", - "version": "0.20.74-rc103", + "version": "0.20.74-rc104", "hasInstallScript": true, "license": "ISC", "dependencies": { diff --git a/package.json b/package.json index 0279c4d..4d28ebf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@orionprotocol/sdk", - "version": "0.20.74-rc103", + "version": "0.20.74-rc104", "description": "Orion Protocol SDK", "main": "./lib/index.cjs", "module": "./lib/index.js", diff --git a/src/Orion/index.ts b/src/Orion/index.ts index 7a266d5..25ef84d 100644 --- a/src/Orion/index.ts +++ b/src/Orion/index.ts @@ -1,8 +1,8 @@ import { merge } from 'merge-anything'; -import { chains, envs } from '../config/index.js'; +import { chains, envs } from '../config'; import type { networkCodes } from '../constants/index.js'; import Unit from '../Unit/index.js'; -import { ReferralSystem } from '../services/ReferralSystem/index.js'; +import { ReferralSystem } from '../services/ReferralSystem'; import type { SupportedChainId, DeepPartial, @@ -14,6 +14,7 @@ import type { import { isValidChainId } from '../utils/index.js'; import { simpleFetch } from 'simple-typed-fetch'; import Bridge from './bridge/index.js'; +import { FrontageService } from '../services/Frontage'; export default class Orion { public readonly env?: string; @@ -22,6 +23,8 @@ export default class Orion { public readonly referralSystem: ReferralSystem; + public readonly frontage: FrontageService; + public readonly bridge: Bridge; // TODO: get tradable assets (aggregated) @@ -42,6 +45,7 @@ export default class Orion { config = { analyticsAPI: envConfig?.analyticsAPI, referralAPI: envConfig.referralAPI, + frontageAPI: envConfig.frontageAPI, networks: Object.entries(envConfig.networks).map(([chainId, networkConfig]) => { if (!isValidChainId(chainId)) throw new Error(`Invalid chainId: ${chainId}`); const chainConfig = chains[chainId]; @@ -67,9 +71,6 @@ export default class Orion { }, indexer: { api: networkConfig.api + networkConfig.services.indexer?.http, - }, - frontage: { - api: networkConfig.api + networkConfig.services.frontage.http, } }, }; @@ -89,6 +90,7 @@ export default class Orion { } this.referralSystem = new ReferralSystem(config.referralAPI); + this.frontage = new FrontageService(config.frontageAPI); this.units = Object.entries(config.networks) .reduce>>((acc, [chainId, networkConfig]) => { diff --git a/src/Unit/index.ts b/src/Unit/index.ts index 8c906e1..19c27e4 100644 --- a/src/Unit/index.ts +++ b/src/Unit/index.ts @@ -3,7 +3,6 @@ import { Aggregator } from '../services/Aggregator'; import { BlockchainService } from '../services/BlockchainService'; import { PriceFeed } from '../services/PriceFeed'; import { IndexerService } from '../services/Indexer'; -import { FrontageService } from '../services/Frontage'; import type { KnownEnv, SupportedChainId, @@ -30,8 +29,6 @@ export default class Unit { public readonly indexer: IndexerService | undefined; - public readonly frontage: FrontageService; - public readonly aggregator: Aggregator; public readonly pmm: Pmm; @@ -90,10 +87,7 @@ export default class Unit { }, indexer: { api: networkConfig.api + networkConfig.services.indexer?.http, - }, - frontage: { - api: networkConfig.api + networkConfig.services.frontage?.http, - }, + } }, }; } else { @@ -121,9 +115,6 @@ export default class Unit { intNetwork ) : undefined; - this.frontage = new FrontageService( - this.config.services.frontage.api, - ); this.aggregator = new Aggregator( this.config.services.aggregator.http, this.config.services.aggregator.ws, diff --git a/src/config/envs.json b/src/config/envs.json index 55a72bf..a6ce4d0 100644 --- a/src/config/envs.json +++ b/src/config/envs.json @@ -1,6 +1,7 @@ { "production": { "referralAPI": "https://trade.orion.xyz/referral-api", + "frontageAPI": "https://trade.orion.xyz/frontage", "networks": { "1": { "api": "https://trade.orion.xyz/eth-mainnet", @@ -17,9 +18,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage/" } }, "liquidityMigratorAddress": "0x23a1820a47BcD022E29f6058a5FD224242F50D1A" @@ -39,9 +37,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage/" } } }, @@ -60,9 +55,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage/" } } }, @@ -81,9 +73,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage/" } } }, @@ -102,9 +91,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage/" } } }, @@ -123,9 +109,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage/" } } }, @@ -144,9 +127,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage/" } } }, @@ -165,9 +145,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage/" } } }, @@ -186,9 +163,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage/" } } } @@ -196,6 +170,7 @@ }, "testing": { "referralAPI": "https://testing.orion.xyz/referral-api", + "frontageAPI": "https://testing.orion.xyz/frontage", "networks": { "97": { "api": "https://testing.orion.xyz/bsc-testnet", @@ -212,9 +187,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage/" } }, "liquidityMigratorAddress": "0x01b10dds12478C88A5E18e2707E729906bC25CfF6" @@ -234,9 +206,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage/" } } }, @@ -255,9 +224,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage/" } } }, @@ -276,9 +242,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage/" } } }, @@ -297,9 +260,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage/" } } }, @@ -318,9 +278,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage/" } } } @@ -328,6 +285,7 @@ }, "staging": { "referralAPI": "https://staging.orion.xyz/referral-api", + "frontageAPI": "https://staging.orion.xyz/frontage", "networks": { "1": { "api": "https://staging.orion.xyz/eth-mainnet", @@ -344,9 +302,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage/" } } }, @@ -365,9 +320,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage/" } } }, @@ -386,9 +338,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage/" } } }, @@ -407,9 +356,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage/" } } }, @@ -428,9 +374,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage/" } } }, @@ -449,9 +392,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage/" } } }, @@ -470,9 +410,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage/" } } }, @@ -491,9 +428,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage/" } } }, @@ -512,9 +446,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage/" } } } @@ -522,6 +453,7 @@ }, "experimental": { "referralAPI": "https://testing.orion.xyz/referral-api", + "frontageAPI": "https://testing.orion.xyz/frontage", "networks": { "97": { "api": "https://dn-dev.orion.xyz/bsc-testnet", @@ -538,9 +470,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage/" } } }, @@ -559,9 +488,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage/" } } } @@ -569,6 +495,7 @@ }, "kucoin-production": { "referralAPI": "https://trade.orion.xyz/referral-api", + "frontageAPI": "https://trade.orion.xyz/frontage", "networks": { "1": { "api": "https://trade.orion.xyz/eth-mainnet", @@ -585,9 +512,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage/" } }, "liquidityMigratorAddress": "0x23a1820a47BcD022E29f6058a5FD224242F50D1A" @@ -607,9 +531,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage/" } } }, @@ -628,9 +549,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage/" } } }, @@ -649,9 +567,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage/" } } }, @@ -670,9 +585,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage/" } } } diff --git a/src/config/index.ts b/src/config/index.ts index aab5746..d97b366 100644 --- a/src/config/index.ts +++ b/src/config/index.ts @@ -1,6 +1,6 @@ import jsonChains from './chains.json' assert { type: 'json' }; import jsonEnvs from './envs.json' assert { type: 'json' }; -import { pureEnvSchema, pureChainInfoSchema } from './schemas/index.js'; +import { pureEnvSchema, pureChainInfoSchema } from './schemas'; const chains = pureChainInfoSchema.parse(jsonChains); const envs = pureEnvSchema.parse(jsonEnvs); diff --git a/src/config/schemas/pureEnvSchema.ts b/src/config/schemas/pureEnvSchema.ts index 31f503c..55a25ee 100644 --- a/src/config/schemas/pureEnvSchema.ts +++ b/src/config/schemas/pureEnvSchema.ts @@ -17,9 +17,6 @@ export const pureEnvNetworksSchema = z.object({ indexer: z.object({ http: z.string(), }).optional(), - frontage: z.object({ - http: z.string(), - }), }), rpc: z.string().optional(), liquidityMigratorAddress: z.string().optional(), @@ -28,6 +25,7 @@ export const pureEnvNetworksSchema = z.object({ export const pureEnvPayloadSchema = z.object({ analyticsAPI: z.string().url().optional(), referralAPI: z.string().url(), + frontageAPI: z.string().url(), networks: z.record( z.nativeEnum(SupportedChainId), pureEnvNetworksSchema diff --git a/src/types.ts b/src/types.ts index c4a935f..cdd181b 100644 --- a/src/types.ts +++ b/src/types.ts @@ -264,9 +264,6 @@ export type VerboseUnitConfig = { // http://10.23.5.11:3003/, // https://price-feed:3003/ } - frontage: { - api: string - } indexer?: { api: string // For example: @@ -284,6 +281,7 @@ export type Json = string | number | boolean | null | Json[] | { [key: string]: export type EnvConfig = { analyticsAPI: string | undefined referralAPI: string + frontageAPI: string networks: Partial< Record< SupportedChainId,