From 5f40d418ed0c687c05f04dd43fcfa1b0524c8f6a Mon Sep 17 00:00:00 2001 From: "Ch3rry B@ry" Date: Fri, 8 Nov 2024 14:44:10 +0530 Subject: [PATCH] fix(backend): fix daily stats sync error --- apps/backend/src/libs/supply.ts | 6 ++---- apps/backend/src/services/dailyStatsNew.ts | 2 +- apps/backend/src/services/supply.ts | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/apps/backend/src/libs/supply.ts b/apps/backend/src/libs/supply.ts index f6133c010..dcd72eb7f 100644 --- a/apps/backend/src/libs/supply.ts +++ b/apps/backend/src/libs/supply.ts @@ -7,8 +7,6 @@ import { logger } from 'nb-logger'; import { Block } from 'nb-types'; import { retry } from 'nb-utils'; -import config from '#config'; - import knex from './knex.js'; import { nearBalance } from './near.js'; @@ -42,7 +40,7 @@ const getLockupAccounts = async () => { .select('accounts.account_id'); }; -export const circulatingSupply = async (block: Block) => { +export const circulatingSupply = async (block: Block, rpcUrl: string) => { let lockedAmount = Big(0); const foundationAccounts = ['contributors.near', 'lockup.near']; @@ -60,7 +58,7 @@ export const circulatingSupply = async (block: Block) => { await retry(async () => { try { const amount = await lockup.locked( - config.rpcUrl2, + rpcUrl, account.account_id, +block.block_height, block.block_timestamp, diff --git a/apps/backend/src/services/dailyStatsNew.ts b/apps/backend/src/services/dailyStatsNew.ts index 98f768c10..5b00a823d 100644 --- a/apps/backend/src/services/dailyStatsNew.ts +++ b/apps/backend/src/services/dailyStatsNew.ts @@ -69,7 +69,7 @@ const blockData = async (day: Dayjs) => { let supply: null | string = null; if (config.network === Network.MAINNET && lastBlock) { - supply = await circulatingSupply(lastBlock); + supply = await circulatingSupply(lastBlock, config.rpcUrl); } return { diff --git a/apps/backend/src/services/supply.ts b/apps/backend/src/services/supply.ts index ef99cd5d9..5dd8b477b 100644 --- a/apps/backend/src/services/supply.ts +++ b/apps/backend/src/services/supply.ts @@ -11,7 +11,7 @@ export const syncCirculatingSupply = async () => { .first(); if (config.network === Network.MAINNET && latestBlock) { - const supply = await circulatingSupply(latestBlock); + const supply = await circulatingSupply(latestBlock, config.rpcUrl2); await knex('stats').update({ circulating_supply: supply }); }