Created
October 8, 2019 20:46
-
-
Save thodges-gh/497f35090f7ecd214b68ec350a7e7462 to your computer and use it in GitHub Desktop.
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
pragma solidity 0.5.0; | |
interface LinkTokenInterface { | |
function balanceOf(address owner) external returns (uint256 balance); | |
function transfer(address to, uint256 value) external returns (bool success); | |
function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool success); | |
} | |
interface CoordinatorInterface { | |
function withdraw(address recipient, uint256 amount) external; | |
function balanceOf(address account) external view returns (uint256); | |
} | |
contract DepositTester { | |
LinkTokenInterface public link; | |
address public owner; | |
constructor(address _link) public { | |
link = LinkTokenInterface(_link); | |
owner = msg.sender; | |
} | |
function depositToCoord(address _coord, uint256 _amount) public onlyOwner { | |
LinkTokenInterface(link).transferAndCall( | |
_coord, | |
_amount, | |
getPayload(address(this), _amount) | |
); | |
} | |
function getPayload(address _to, uint256 _amount) public pure returns (bytes memory) { | |
return abi.encodeWithSelector( | |
bytes4(keccak256("depositFunds(address,uint256)")), | |
_to, | |
_amount | |
); | |
} | |
function getCoordinatorBalanceFor(address _coord, address _for) public view returns (uint256) { | |
return CoordinatorInterface(_coord).balanceOf(_for); | |
} | |
function withdrawFromCoord(address _coord, uint256 _amount) public onlyOwner { | |
CoordinatorInterface(_coord).withdraw(address(this), _amount); | |
} | |
function withdrawLINK() public onlyOwner { | |
link.transfer(address(owner), link.balanceOf(address(this))); | |
} | |
modifier onlyOwner() { | |
require(msg.sender == address(owner), "Not owner"); | |
_; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment