From dcacd707160c279c48aaaa7c4009c8f4f7e220b9 Mon Sep 17 00:00:00 2001 From: vuonghuuhung Date: Thu, 28 Nov 2024 16:52:37 +0700 Subject: [PATCH] add: custom base url and dex for init from backend --- packages/common/src/chain-infos/chain-info-reader.ts | 6 ++++-- packages/common/src/common.ts | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/common/src/chain-infos/chain-info-reader.ts b/packages/common/src/chain-infos/chain-info-reader.ts index 55bd4ab..82ceb12 100644 --- a/packages/common/src/chain-infos/chain-info-reader.ts +++ b/packages/common/src/chain-infos/chain-info-reader.ts @@ -12,14 +12,16 @@ import { import path from "path"; export class ChainInfoReaderFromBackend implements ChainInfoReader { + constructor(private readonly baseUrl?: string, private readonly dex?: string) {} + async readChainInfos() { const chains = (await ( await fetchRetry( - CHAIN_REGISTRY_BACKEND_ENDPOINTS.BASE_URL + + this.baseUrl ?? CHAIN_REGISTRY_BACKEND_ENDPOINTS.BASE_URL + path.join( CHAIN_REGISTRY_BACKEND_ENDPOINTS.BASE_ENDPOINT, CHAIN_REGISTRY_BACKEND_ENDPOINTS.CHAIN_INFOS - ) + ) + "?dex=" + this.dex ) ).json()) as CustomChainInfo[]; return chains; diff --git a/packages/common/src/common.ts b/packages/common/src/common.ts index 2686d11..0e98662 100644 --- a/packages/common/src/common.ts +++ b/packages/common/src/common.ts @@ -29,8 +29,8 @@ export class OraiCommon { return OraiCommon.initializeFromCustomChainInfos(customChainInfos); } - static async initializeFromBackend() { - const reader = new ChainInfoReaderFromBackend(); + static async initializeFromBackend(baseUrl?: string, dex?: string) { + const reader = new ChainInfoReaderFromBackend(baseUrl, dex); return OraiCommon.initializeFromChainInfoReader(reader); }