Merge branch 'master' of github.com:InstaDApp/sa-resolvers

This commit is contained in:
Thrilok Kumar 2020-04-10 23:15:31 +05:30
commit 289290c391

21
protocols/balances.sol Normal file
View File

@ -0,0 +1,21 @@
pragma solidity ^0.6.0;
interface TokenInterface {
function balanceOf(address) external view returns (uint);
}
contract InstaBalanceResolver {
function getBalances(address owner, address[] memory tknAddress) public view returns (uint[] memory) {
uint[] memory tokensBal = new uint[](tknAddress.length);
for (uint i = 0; i < tknAddress.length; i++) {
if (tknAddress[i] == 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE) {
tokensBal[i] = owner.balance;
} else {
TokenInterface token = TokenInterface(tknAddress[i]);
tokensBal[i] = token.balanceOf(owner);
}
}
return tokensBal;
}
}