-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(global): makes it working and rm husky
- Loading branch information
1 parent
3d5cad8
commit be4b362
Showing
9 changed files
with
80 additions
and
1,810 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,26 @@ | ||
// NOTE: taken from here: https://etherscan.io/address/0xb1f8e55c7f64d203c1400b9d8555d050f94adf39#code | ||
pragma solidity ^0.4.21; | ||
pragma solidity ^0.7.3; | ||
|
||
interface ERC20 { | ||
function balanceOf(address) public view returns (uint256); | ||
} | ||
import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; | ||
|
||
contract BalanceChecker { | ||
function() public payable { | ||
revert(); | ||
} | ||
|
||
function tokenBalance(address user, address token) public view returns (uint256) { | ||
uint256 tokenCode; | ||
assembly { | ||
tokenCode := extcodesize(token) | ||
} | ||
|
||
if (tokenCode > 0 && token.call(bytes4(0x70a08231), user)) { | ||
return ERC20(token).balanceOf(user); | ||
} else { | ||
return 0; | ||
} | ||
} | ||
|
||
function balances(address[] users, address[] tokens) external view returns (uint256[]) { | ||
uint256[] memory addrBalances = new uint256[](tokens.length * users.length); | ||
function balances(address[] calldata _users, address[] calldata _tokens) external view returns (uint256[] memory) { | ||
uint256[] memory addrBalances = new uint256[](_tokens.length * _users.length); | ||
|
||
for (uint256 i = 0; i < users.length; i++) { | ||
for (uint256 j = 0; j < tokens.length; j++) { | ||
uint256 addrIdx = j + tokens.length * i; | ||
if (tokens[j] != address(0x0)) { | ||
addrBalances[addrIdx] = tokenBalance(users[i], tokens[j]); | ||
for (uint256 i = 0; i < _users.length; i++) { | ||
for (uint256 j = 0; j < _tokens.length; j++) { | ||
uint256 addrIdx = j + _tokens.length * i; | ||
if (_tokens[j] != address(0x0000000000000000000000000000000000000000)) { | ||
addrBalances[addrIdx] = IERC20(_tokens[j]).balanceOf(_users[i]); | ||
} else { | ||
addrBalances[addrIdx] = users[i].balance; | ||
addrBalances[addrIdx] = address(_users[i]).balance; | ||
} | ||
} | ||
} | ||
|
||
return addrBalances; | ||
} | ||
|
||
fallback() external payable { | ||
revert("This contract does not accept ethers"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
pragma solidity ^0.4.21; | ||
pragma solidity ^0.7.3; | ||
|
||
contract Factory { | ||
event Deployed(address addr, uint256 salt); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.