-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from rstormsf/master
Create Governance based bridge contracts
- Loading branch information
Showing
25 changed files
with
2,193 additions
and
265 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# EditorConfig is awesome: http://EditorConfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
end_of_line = lf | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.ts] | ||
indent_style = tab | ||
|
||
[{package.json,.travis.yml}] | ||
indent_style = space | ||
indent_size = 4 |
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,15 @@ | ||
# Dependencies | ||
```bash | ||
npm install | ||
``` | ||
|
||
# To Deploy | ||
Check `truffle.js` for networks and their ports | ||
```bash | ||
NETWORK=sokol npm run deploy | ||
``` | ||
|
||
# To Flatten | ||
```bash | ||
npm run flatten | ||
``` |
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,10 @@ | ||
pragma solidity ^0.4.19; | ||
|
||
|
||
contract BridgeDeploymentAddressStorage { | ||
uint256 public deployedAtBlock; | ||
|
||
function BridgeDeploymentAddressStorage() public { | ||
deployedAtBlock = block.number; | ||
} | ||
} |
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,52 +1,58 @@ | ||
pragma solidity ^0.4.18; | ||
|
||
import 'zeppelin-solidity/contracts/ownership/Ownable.sol'; | ||
|
||
contract BridgeValidators is Ownable { | ||
|
||
// Event created on validator gets added | ||
event ValidatorAdded (address validator); | ||
event ValidatorRemoved (address validator); | ||
uint8 requiredValidators = 0; | ||
uint256 public validatorCount = 0; | ||
|
||
mapping (address => bool) public validators; | ||
|
||
function BridgeValidators(uint8 _requiredValidators,address[] _initialValidators) public { | ||
require(_requiredValidators != 0); | ||
require(_initialValidators.length >= _requiredValidators); | ||
setRequiredValidators(_requiredValidators); | ||
for (uint i = 0; i < _initialValidators.length; i++) { | ||
require(!isValidator(_initialValidators[i]) && _initialValidators[i] != address(0)); | ||
addValidator(_initialValidators[i]); | ||
} | ||
validatorCount = _initialValidators.length; | ||
} | ||
|
||
function addValidator(address _validator) public onlyOwner { | ||
assert(validators[_validator] != true); | ||
validatorCount++; | ||
validators[_validator] = true; | ||
ValidatorAdded(_validator); | ||
} | ||
|
||
function removeValidator(address _validator) public onlyOwner { | ||
require(validatorCount > requiredValidators); | ||
validators[_validator] = false; | ||
validatorCount--; | ||
ValidatorRemoved(_validator); | ||
} | ||
|
||
function setRequiredValidators(uint8 _requiredValidators) public onlyOwner { | ||
require(validatorCount >= _requiredValidators); | ||
requiredValidators = _requiredValidators; | ||
} | ||
|
||
function isValidator(address _validator) public view returns(bool) { | ||
return (validators[_validator] == true); | ||
} | ||
|
||
function onlyValidator(address _validator) public view returns(bool) { | ||
return validators[_validator] == true; | ||
} | ||
import "zeppelin-solidity/contracts/ownership/Ownable.sol"; | ||
import "./IBridgeValidators.sol"; | ||
|
||
|
||
contract BridgeValidators is Ownable, IBridgeValidators { | ||
|
||
// Event created on validator gets added | ||
event ValidatorAdded (address validator); | ||
event ValidatorRemoved (address validator); | ||
uint8 requiredValidators = 0; | ||
uint256 public validatorCount = 0; | ||
|
||
mapping (address => bool) public validators; | ||
|
||
function BridgeValidators(uint8 _requiredValidators, address[] _initialValidators) public Ownable() { | ||
require(_requiredValidators != 0); | ||
require(_initialValidators.length >= _requiredValidators); | ||
validatorCount = _initialValidators.length; | ||
for (uint i = 0; i < _initialValidators.length; i++) { | ||
require(!isValidator(_initialValidators[i]) && _initialValidators[i] != address(0)); | ||
addValidator(_initialValidators[i]); | ||
} | ||
setRequiredValidators(_requiredValidators); | ||
} | ||
|
||
function addValidator(address _validator) public onlyOwner { | ||
assert(validators[_validator] != true); | ||
validatorCount++; | ||
validators[_validator] = true; | ||
ValidatorAdded(_validator); | ||
} | ||
|
||
function removeValidator(address _validator) public onlyOwner { | ||
require(validatorCount > requiredValidators); | ||
validators[_validator] = false; | ||
validatorCount--; | ||
ValidatorRemoved(_validator); | ||
} | ||
|
||
function setRequiredValidators(uint8 _requiredValidators) public onlyOwner { | ||
require(validatorCount >= _requiredValidators); | ||
requiredValidators = _requiredValidators; | ||
} | ||
|
||
function isValidator(address _validator) public view returns(bool) { | ||
return validators[_validator] == true; | ||
} | ||
|
||
function requiredSignatures() public view returns(uint8) { | ||
return requiredValidators; | ||
} | ||
|
||
function currentOwner() public view returns(address) { | ||
return owner; | ||
} | ||
} |
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,10 @@ | ||
pragma solidity 0.4.19; | ||
import "zeppelin-solidity/contracts/token/ERC20/ERC20.sol"; | ||
|
||
|
||
contract ERC677 is ERC20 { | ||
event Transfer(address indexed from, address indexed to, uint value, bytes data); | ||
|
||
function transferAndCall(address, uint, bytes) public returns (bool); | ||
|
||
} |
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,6 @@ | ||
pragma solidity ^0.4.19; | ||
|
||
|
||
contract ERC677Receiver { | ||
function onTokenTransfer(address _from, uint _value, bytes _data) external returns(bool); | ||
} |
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.