dsa-resolvers-deprecated/contracts/protocols/erc20.sol

44 lines
1.4 KiB
Solidity
Raw Normal View History

2020-04-10 17:40:02 +00:00
pragma solidity ^0.6.0;
interface TokenInterface {
function balanceOf(address) external view returns (uint);
2020-06-25 14:29:53 +00:00
function allowance(address owner, address spender) external view returns (uint256);
2020-04-10 17:40:02 +00:00
}
2020-06-25 15:28:53 +00:00
contract Resolver {
2020-04-10 17:40:02 +00:00
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;
}
2020-06-25 14:29:53 +00:00
2020-06-25 14:30:36 +00:00
function getAllowances(address owner, address spender, address[] memory tknAddress) public view returns (uint[] memory) {
2020-06-25 14:29:53 +00:00
uint[] memory tokenAllowances = new uint[](tknAddress.length);
for (uint i = 0; i < tknAddress.length; i++) {
if (tknAddress[i] == 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE) {
2020-06-25 15:28:53 +00:00
tokenAllowances[i] = 0;
2020-06-25 14:29:53 +00:00
} else {
TokenInterface token = TokenInterface(tknAddress[i]);
tokenAllowances[i] = token.allowance(owner, spender);
}
}
return tokenAllowances;
}
2020-06-25 15:28:53 +00:00
}
contract InstaERC20Resolver is Resolver {
string public constant name = "ERC20-Resolver-v1";
2020-04-10 17:40:02 +00:00
}