-
-
Notifications
You must be signed in to change notification settings - Fork 268
Open
Labels
Description
In the following, contract.balances and result are implicitly typed as any, because the Contract class doesn't have a balances method.
import { Contract } from '@ethersproject/contracts';
...
async getBalancesInSingleCall(
...
) {
...
const contract = new Contract(
contractAddress,
abiSingleCallBalancesContract,
provider,
);
const result = await contract.balances([selectedAddress], tokensToDetect);
const nonZeroBalances: BalanceMap = {};
/* istanbul ignore else */
if (result.length > 0) {
tokensToDetect.forEach((tokenAddress, index) => {
const balance: BN = result[index];
/* istanbul ignore else */
if (String(balance) !== '0') {
nonZeroBalances[tokenAddress] = balance;
}
});
}
return nonZeroBalances;
}
}All tests for getBalancesInSingleCall only check for toBeDefined() or strictEquals({}), with the exception of the following:
'should track and use the currently selected chain ID and provider when getting balances in a single call'
The fact that this test passes at runtime suggests that either this bug is only an issue at the type level, or there is a fallback method being called instead.