Skip to content

Commit

Permalink
fix: convert properly before using BigInt
Browse files Browse the repository at this point in the history
  • Loading branch information
0xMillz committed Feb 6, 2025
1 parent 4439ec6 commit 297d189
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions apps/web/src/pages/api/og/dao.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,24 @@ const ptRootBold = fetch(
).then((res) => res.arrayBuffer())

const getTreasuryBalance = async (chainId: CHAIN_ID, address: string) => {
// query balance directly from the rpc (edge runtime compatible)
// Generate a random request ID
const requestId = Math.floor(Math.random() * 1_000_000)

// Query balance directly from the RPC (edge runtime compatible)
const { result } = await fetch(RPC_URL[chainId], {
method: 'POST',
body: JSON.stringify({
jsonrpc: '2.0',
method: 'eth_getBalance',
params: [address, 'latest'],
id: 1,
id: requestId,
}),
}).then((x) => x.json())

//covert to eth value
const eth = BigInt(formatEther(result))
const data = formatCryptoVal(eth)
// Convert to ETH value
const balanceInWei = BigInt(result)
const balanceInEth = formatEther(balanceInWei)
const data = formatCryptoVal(balanceInEth)

return data
}
Expand Down

0 comments on commit 297d189

Please sign in to comment.