Skip to content

Commit

Permalink
add: custom base url and dex for init from backend
Browse files Browse the repository at this point in the history
  • Loading branch information
vuonghuuhung committed Nov 28, 2024
1 parent ed8f3e6 commit dcacd70
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions packages/common/src/chain-infos/chain-info-reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions packages/common/src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit dcacd70

Please sign in to comment.