Skip to content

Commit

Permalink
Use the "/status" endpoint to get the latest chain id
Browse files Browse the repository at this point in the history
  • Loading branch information
Thunnini committed Sep 13, 2021
1 parent b1c60e8 commit 99ba5e4
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions packages/background/src/updater/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,17 @@ export class ChainUpdaterService {
baseURL: chainInfo.rpc,
});

// Get the latest block.
// Get the status to get the chain id.
const result = await instance.get<{
result: {
block: {
header: {
chain_id: string;
};
node_info: {
network: "osmosis-1";
};
};
}>("/block");
}>("/status");

const currentVersion = ChainIdHelper.parse(chainInfo.chainId);
const fetchedChainId = result.data.result.block.header.chain_id;
const fetchedChainId = result.data.result.node_info.network;
const fetchedVersion = ChainIdHelper.parse(fetchedChainId);

if (
Expand Down Expand Up @@ -207,18 +205,16 @@ export class ChainUpdaterService {
baseURL: chainInfo.rpc,
});

// Get the latest block.
// Get the status to get the chain id.
const result = await instance.get<{
result: {
block: {
header: {
chain_id: string;
};
node_info: {
network: "osmosis-1";
};
};
}>("/block");
}>("/status");

const resultChainId = result.data.result.block.header.chain_id;
const resultChainId = result.data.result.node_info.network;

const version = ChainIdHelper.parse(chainId);
const fetchedVersion = ChainIdHelper.parse(resultChainId);
Expand Down

0 comments on commit 99ba5e4

Please sign in to comment.