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

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]) => {