Created
August 9, 2019 10:18
-
-
Save 0xAshish/240b5bc745bcc34b8fa4122b7c783469 to your computer and use it in GitHub Desktop.
This file contains hidden or 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.4.24; | |
contract RootChain { | |
// | |
// Constructor | |
// | |
constructor () public { | |
// set current header block | |
} | |
// | |
// Events | |
// | |
// deposit ETH by sending to this contract | |
function () public payable { | |
depositEthers(); | |
} | |
// | |
// External functions | |
// | |
function submitHeaderBlock(bytes vote, bytes sigs, bytes extradata) external { | |
// TODO add rewards | |
} | |
// | |
// Public functions | |
// | |
// delete exit | |
function deleteExit(uint256 exitId) public { | |
// withdrawManager.deleteExit(exitId); | |
} | |
// set Exit NFT contract | |
function setExitNFTContract(address _nftContract) public { | |
// depositManager.setExitNFTContract(_nftContract); | |
// withdrawManager.setExitNFTContract(_nftContract); | |
} | |
// set WETH | |
function setWETHToken(address _token) public { | |
} | |
// map child token to root token | |
function mapToken(address _rootToken, address _childToken, bool _isERC721) public { | |
} | |
// change child chain contract | |
function setChildContract(address newChildChain) public { | |
} | |
// add validator | |
function addProofValidator(address _validator) public { | |
} | |
// remove validator | |
function removeProofValidator(address _validator) public { | |
} | |
function currentChildBlock() public view returns(uint256) { | |
} | |
function currentHeaderBlock() public view returns (uint256) { | |
// return _currentHeaderBlock; | |
} | |
function headerBlock(uint256 _headerNumber) public view returns ( | |
bytes32 _root, | |
uint256 _start, | |
uint256 _end, | |
uint256 _createdAt | |
) { | |
} | |
// Get deposit block | |
function depositBlock(uint256 _depositCount) public view returns ( | |
uint256, | |
address, | |
address, | |
uint256, | |
uint256 | |
) { | |
// return depositManager.depositBlock(_depositCount); | |
} | |
// set stake manager | |
function setStakeManager(address _stakeManager) public { | |
// require(_stakeManager != address(0)); | |
// stakeManager = StakeManager(_stakeManager); | |
} | |
// set deposit manager | |
function setDepositManager(address _depositManager) public { | |
// require(_depositManager != address(0)); | |
// depositManager = DepositManager(_depositManager); | |
} | |
// set withdraw manager | |
function setWithdrawManager(address _withdrawManager) public { | |
// require(_withdrawManager != address(0)); | |
// withdrawManager = WithdrawManager(_withdrawManager); | |
} | |
// deposit ethers | |
function depositEthers() public payable { | |
// // retrieve ether amount | |
// uint256 _amount = msg.value; | |
// // get weth token | |
// address wethToken = depositManager.wethToken(); | |
// // transfer ethers to this contract (through WETH) | |
// WETH t = WETH(wethToken); | |
// t.deposit.value(_amount)(); | |
// // generate deposit block and udpate counter | |
// depositManager.createDepositBlock(_currentHeaderBlock, wethToken, msg.sender, _amount); | |
} | |
// deposit erc721 | |
function depositERC721( | |
address _token, | |
address _user, | |
uint256 _tokenId) public {} | |
function onERC721Received(address operator, address from, uint256 tokenId, bytes data) public returns (bytes4) { | |
// depositManager.createDepositBlock(_currentHeaderBlock, msg.sender, from, tokenId); | |
return 0x150b7a02; | |
} | |
// deposit tokens for another user | |
function deposit( | |
address _token, | |
address _user, | |
uint256 _amount | |
) public { | |
// transfer tokens to current contract | |
// require(ERC20(_token).transferFrom(msg.sender, address(this), _amount)); | |
// // generate deposit block and udpate counter | |
// depositManager.createDepositBlock(_currentHeaderBlock, _token, _user, _amount); | |
} | |
// transfer tokens to user | |
function transferAmount( | |
address _token, | |
address _user, | |
uint256 _amount | |
) public returns(bool) { | |
// address wethToken = depositManager.wethToken(); | |
// // transfer to user TODO: use pull for transfer | |
// if (depositManager.isERC721(_token)) { | |
// ERC721(_token).transferFrom(address(this), _user, _amount); | |
// } else if (_token == wethToken) { | |
// WETH t = WETH(_token); | |
// t.withdraw(_amount, _user); | |
// } else { | |
// require(ERC20(_token).transfer(_user, _amount)); | |
// } | |
return true; | |
} | |
/** | |
* @dev Accept ERC223 compatible tokens | |
* @param _user address The address that is transferring the tokens | |
* @param _amount uint256 the amount of the specified token | |
* @param _data Bytes The data passed from the caller. | |
*/ | |
function tokenFallback(address _user, uint256 _amount, bytes _data) public { | |
// address _token = msg.sender; | |
// // create deposit block with token fallback | |
// depositManager.createDepositBlock(_currentHeaderBlock, _token, _user, _amount); | |
} | |
// finalize commit | |
function finalizeCommit(uint256) public {} | |
// slash stakers if fraud is detected | |
function slash() public { | |
// TODO pass block/proposer | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment