bug: useBalance fails when token has bytes32 symbol
Is there an existing issue for this?
- [X] I have searched the existing issues
Package Version
0.6.6
Current Behavior
useBalance fails on tokens that have their symbol as bytes32, unable to decode the bytes32 result of the function call. For example, useBalance with Maker (0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2) returns:
Failed to decode contract function result.
Config:
{
"addressOrName": "0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2",
"contractInterface": "...",
"functionName": "symbol",
"chainId": 1
}
Details: call revert exception [ See: https://links.ethers.org/v5-errors-CALL_EXCEPTION ] (method="symbol()", data="0x4d4b520000000000000000000000000000000000000000000000000000000000", errorArgs=null, errorName=null, errorSignature=null, reason=null, code=CALL_EXCEPTION, version=abi/5.7.0)
Expected Behavior
Would like to be able to use the useBalance hook and get a balance value back whether the other values are returned or not. symbol, in this case, doesn't seem like it should block the core function of the hook.
Steps To Reproduce
import { erc20ABI } from 'wagmi';
const chainId = 1;
const tokenAddress = '0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2';
const { data: balance, error } = useBalance({
addressOrName: accountAddress,
chainId,
token: tokenAddress,
});
Link to Minimal Reproducible Example (CodeSandbox, StackBlitz, etc.)
No response
Anything else?
No response
Is there an EIP that states symbol can be bytes32? Not really sure why this contract deviates from EIP-20's symbol type (a string).
I mean sure, we could probably support this case if it's a common one, but feels a bit strange since 0x4d4b520000000000000000000000000000000000000000000000000000000000 evaluates to MKR anyway lol.
Hmm, they list it as a gotcha in their docs: https://docs.makerdao.com/smart-contract-modules/mkr-module#4.-gotchas-potential-source-of-user-error
Yeah, we may have to support it. Can take a look!
Fixed in #993, but will close this issue when released.
Published 0.6.8 that includes this fix!
This issue has been locked since it has been closed for more than 14 days.
If you found a concrete bug or regression related to it, please open a new bug report with a reproduction against the latest wagmi version. If you have any other comments you can create a new discussion.