diff --git a/src/calculators/circulation-supply.js b/src/calculators/circulation-supply.js index 2fe18ba..ccfcda9 100644 --- a/src/calculators/circulation-supply.js +++ b/src/calculators/circulation-supply.js @@ -18,10 +18,10 @@ import { totalSupply } from './total-supply.js'; const STAKING_HEX = '0x7374616b696e6720'; -async function getKeys(prefix) { - const result = await api.rpc.state.getKeysPaged(prefix, 1000, prefix); +async function getKeys(prefix, startKey = null) { + const result = await api.rpc.state.getKeysPaged(prefix, 1000, startKey); if (result.length === 1000) { - const moreKeys = await getKeys(prefix); + const moreKeys = await getKeys(prefix, result[result.length - 1]); result.push(...moreKeys); } return result; diff --git a/src/calculators/total-supply.js b/src/calculators/total-supply.js index de97356..1c7aac3 100644 --- a/src/calculators/total-supply.js +++ b/src/calculators/total-supply.js @@ -5,5 +5,6 @@ export async function totalSupply() { const total = await api.query.balances.totalIssuance(); const bigint = total.toBigInt() / BigInt(10 ** DECIMALS); + return Number(bigint); } diff --git a/src/node.js b/src/node.js index bd03b2e..b03a5ed 100644 --- a/src/node.js +++ b/src/node.js @@ -22,7 +22,9 @@ export async function getBalance(addr) { export async function getBalances(addresses) { const accounts = await api.queryMulti(addresses.map((addr) => [api.query.system.account, addr])); - return accounts.map(({ data: { free } }) => Number(free.toBigInt() / BigInt(10 ** 12))); + const result = accounts.map(({ data: { free } }) => Number(free.toBigInt() / BigInt(10 ** 12))); + + return result; } export const deriveAddr = (addr) => {