Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
254 additions
and
209 deletions.
There are no files selected for viewing
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
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
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
pragma solidity 0.4.24; | ||
|
||
import "../interfaces/IBlockReward.sol"; | ||
import "../upgradeability/EternalStorage.sol"; | ||
import "openzeppelin-solidity/contracts/AddressUtils.sol"; | ||
|
||
contract BlockRewardBridge is EternalStorage { | ||
bytes32 internal constant BLOCK_REWARD_CONTRACT = keccak256(abi.encodePacked("blockRewardContract")); | ||
bytes4 internal constant BLOCK_REWARD_CONTRACT_ID = 0x2ee57f8d; // blockRewardContractId() | ||
bytes4 internal constant BRIDGES_ALLOWED_LENGTH = 0x10f2ee7c; // bridgesAllowedLength() | ||
|
||
function _blockRewardContract() internal view returns (IBlockReward) { | ||
return IBlockReward(addressStorage[BLOCK_REWARD_CONTRACT]); | ||
} | ||
|
||
function _setBlockRewardContract(address _blockReward) internal { | ||
require(AddressUtils.isContract(_blockReward)); | ||
|
||
// Before store the contract we need to make sure that it is the block reward contract in actual fact, | ||
// call a specific method from the contract that should return a specific value | ||
bool isBlockRewardContract = false; | ||
if (_blockReward.call(BLOCK_REWARD_CONTRACT_ID)) { | ||
isBlockRewardContract = | ||
IBlockReward(_blockReward).blockRewardContractId() == bytes4(keccak256("blockReward")); | ||
} else if (_blockReward.call(BRIDGES_ALLOWED_LENGTH)) { | ||
isBlockRewardContract = IBlockReward(_blockReward).bridgesAllowedLength() != 0; | ||
} | ||
require(isBlockRewardContract); | ||
addressStorage[BLOCK_REWARD_CONTRACT] = _blockReward; | ||
} | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
pragma solidity 0.4.24; | ||
|
||
import "../upgradeability/EternalStorage.sol"; | ||
import "openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol"; | ||
import "openzeppelin-solidity/contracts/AddressUtils.sol"; | ||
|
||
contract ERC20Bridge is EternalStorage { | ||
bytes32 internal constant ERC20_TOKEN = keccak256(abi.encodePacked("erc20token")); | ||
|
||
function erc20token() public view returns (ERC20Basic) { | ||
return ERC20Basic(addressStorage[ERC20_TOKEN]); | ||
} | ||
|
||
function setErc20token(address _token) internal { | ||
require(AddressUtils.isContract(_token)); | ||
addressStorage[ERC20_TOKEN] = _token; | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
pragma solidity 0.4.24; | ||
|
||
contract ERC677Storage { | ||
bytes32 internal constant ERC677_TOKEN = keccak256(abi.encodePacked("erc677token")); | ||
} |
Oops, something went wrong.