Closed micahalcorn closed 2 years ago
Above error happens at balances.service.js because the provider returns error.
if (balanceResponseData.error === null) {
balanceData[contractData.name] =
balanceResponseData.tokenBalance === '0x'
? '0'
: ethers.utils.formatUnits(
balanceResponseData.tokenBalance,
contractData.decimals
)
} else {
console.error(
`Can not load balance for ${contractData.name} reason: ${balanceResponseData.error}`
)
}
ETHEREUM_RPC_PROVIDER
isn't the alchemy endpoint. Actually there is a part to check the response to validate whether this rpc is the one provided by alchemy or not. --- this is just assumption. const data = {
jsonrpc: '2.0',
method: '_**alchemy_getTokenBalances**_',
params: [
account,
allContractData.map((contractData) => contractData.address),
],
id: jsonCallId.toString(),
}
jsonCallId++
const response = await fetch(**_process.env.ETHEREUM_RPC_PROVIDER_**, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
referrerPolicy: 'no-referrer',
body: JSON.stringify(data),
})
if (!response.ok) {
throw new Error(
`Could not fetch balances from Alchemy http status: ${response.status}`
)
}
This service seems to be just limited to alchemy provider, but there are other kinds of rpc providers like infura. moralis, quicknode, etc. So I think that would be more powerful to allow any kinds of rpc providers to get balances. Another suggestion is to use multicall which uses 1 number of rpc calls to get a bunch of token balances.
I will appreciate it if my debug/suggestion might help a little bit to fix this issue.
Thanks for your research @0xcodercrane, that was helpful.
I managed to replicate this issue locally and fix it with https://github.com/OriginProtocol/origin-dollar/pull/1075
I am glad if it was helpful
A user reported that the balance is not showing properly while the pending yield and lifetime earnings are.
I was able to reproduce the issue and saw some errors in the console.