Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/services/bakingBad/delegations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,32 @@ export const getTokenVoteWeight = async (tokenAddress: string, account: string,
EnvKey.REACT_APP_LITE_API_URL
)}/network/${network}/token/${tokenAddress}/token-id/0/voting-power?userAddress=${account}&level=${level}`
const response = await fetch(url)

let fullTezBalance = new BigNumber(0)
const fullTezBalanceResp = await fetch(
`https://tcinfra.net/rpc/tezos/${networkNameMap[network]}/chains/main/blocks/${level}/context/contracts/${account}/full_balance`
)

if (fullTezBalanceResp.ok) {
const balanceStr = await fullTezBalanceResp.json() // e.g., "123456789"
fullTezBalance = fullTezBalance.plus(new BigNumber(balanceStr ?? 0))
console.log(fullTezBalance)
} else {
const fullTezBalanceRespData = await fullTezBalanceResp.json()
throw new Error(fullTezBalanceRespData.message)
}

if (!response.ok) {
const data = await response.json()
throw new Error(data.message)
}

const result: { votingWeight: string; votingXTZWeight: string } = await response.json()

if (result) {
return {
votingWeight: new BigNumber(result.votingWeight),
votingXTZWeight: new BigNumber(result.votingXTZWeight)
votingXTZWeight: fullTezBalance
}
}

Expand Down
Loading