This commit is contained in:
TheJuze
2024-03-19 17:34:00 +03:00
parent 5296ecbc3d
commit edc3586166
8 changed files with 19 additions and 118 deletions

4
package-lock.json generated
View File

@@ -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": {

View File

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

View File

@@ -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<Partial<Record<SupportedChainId, Unit>>>((acc, [chainId, networkConfig]) => {

View File

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

View File

@@ -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/"
}
}
}

View File

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

View File

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

View File

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