Skip to content

Commit

Permalink
fix error when get block
Browse files Browse the repository at this point in the history
  • Loading branch information
dtmkeng committed Jul 21, 2023
1 parent 6d5a679 commit de7662c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion helpers/getBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,13 @@ async function getBlock(timestamp: number, chain: Chain, chainBlocks: ChainBlock
block = Number((await retry(async () => (await axios.get(`https://nodes.wavesnodes.com/blocks/heightByTimestamp/${timestamp}`).catch((e) => {
throw new Error(`Error getting block: ${chain} ${timestamp} ${e.message}`)
}))?.data?.height)));
if (chain === CHAIN.LINEA)
else if (chain === CHAIN.LINEA)
block = Number((await retry(async () => (await axios.get("https://explorer.linea.build/api?module=block&action=getblocknobytime&timestamp=" + timestamp + "&closest=before").catch((e) => {
throw new Error(`Error getting block: ${chain} ${timestamp} ${e.message}`)
}))?.data?.result?.blockNumber)));
else
block = Number((await retry(async () => (await axios.get(`https://coins.llama.fi/block/${chain}/${timestamp}`).catch((e) => {
console.log(`Error getting block: ${chain} ${timestamp} ${e.message}`)
throw new Error(`Error getting block: ${chain} ${timestamp} ${e.message}`)
}))?.data?.height)));
if (block) chainBlocks[chain] = block
Expand Down

0 comments on commit de7662c

Please sign in to comment.