-
Notifications
You must be signed in to change notification settings - Fork 102
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 #36 from AndrewDrury/master
Adding original contract code for ethereum network
- Loading branch information
Showing
41 changed files
with
8,551 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module.exports = { | ||
norpc: false, | ||
testCommand: '../node_modules/.bin/truffle test --network coverage', | ||
compileCommand: '../node_modules/.bin/truffle compile', | ||
skipFiles: [ | ||
'Migrations.sol', | ||
'mocks' | ||
] | ||
} |
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,24 @@ | ||
This repository has the orginal contracts that implement the wrapped btc token. | ||
The contracts in this repo are NOT deployed. You can find the deployed contracts | ||
for the wrapped btc token on the Ethereum network in [ethereumV2/README.md](../ethereumV2/README.md). | ||
|
||
# Installation | ||
|
||
npm install | ||
|
||
# Compilation | ||
|
||
node_modules/.bin/truffle compile | ||
|
||
# Testing | ||
|
||
node_modules/.bin/truffle test | ||
|
||
# Testing Coverage | ||
|
||
node node_modules/.bin/solidity-coverage | ||
|
||
# Deployment | ||
|
||
node scripts/deployer.js --input-file [file] --gas-price-gwei [gwei] --rpc-url [url] | ||
|
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,23 @@ | ||
pragma solidity ^0.4.23; | ||
|
||
contract Migrations { | ||
address public owner; | ||
uint public last_completed_migration; | ||
|
||
constructor() public { | ||
owner = msg.sender; | ||
} | ||
|
||
modifier restricted() { | ||
if (msg.sender == owner) _; | ||
} | ||
|
||
function setCompleted(uint completed) public restricted { | ||
last_completed_migration = completed; | ||
} | ||
|
||
function upgrade(address new_address) public restricted { | ||
Migrations upgraded = Migrations(new_address); | ||
upgraded.setCompleted(last_completed_migration); | ||
} | ||
} |
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,93 @@ | ||
pragma solidity 0.4.24; | ||
|
||
import "../utils/OwnableContract.sol"; | ||
import "../utils/OwnableContractOwner.sol"; | ||
import "../controller/ControllerInterface.sol"; | ||
import "../token/WBTC.sol"; | ||
import "../factory/MembersInterface.sol"; | ||
|
||
|
||
contract Controller is ControllerInterface, OwnableContract, OwnableContractOwner { | ||
|
||
WBTC public token; | ||
MembersInterface public members; | ||
address public factory; | ||
|
||
constructor(WBTC _token) public { | ||
require(_token != address(0), "invalid _token address"); | ||
token = _token; | ||
} | ||
|
||
modifier onlyFactory() { | ||
require(msg.sender == factory, "sender not authorized for minting or burning."); | ||
_; | ||
} | ||
|
||
// setters | ||
event MembersSet(MembersInterface indexed members); | ||
|
||
function setMembers(MembersInterface _members) external onlyOwner returns (bool) { | ||
require(_members != address(0), "invalid _members address"); | ||
members = _members; | ||
emit MembersSet(members); | ||
return true; | ||
} | ||
|
||
event FactorySet(address indexed factory); | ||
|
||
function setFactory(address _factory) external onlyOwner returns (bool) { | ||
require(_factory != address(0), "invalid _factory address"); | ||
factory = _factory; | ||
emit FactorySet(factory); | ||
return true; | ||
} | ||
|
||
// only owner actions on token | ||
event Paused(); | ||
|
||
function pause() external onlyOwner returns (bool) { | ||
token.pause(); | ||
emit Paused(); | ||
return true; | ||
} | ||
|
||
event Unpaused(); | ||
|
||
function unpause() external onlyOwner returns (bool) { | ||
token.unpause(); | ||
emit Unpaused(); | ||
return true; | ||
} | ||
|
||
// only factory actions on token | ||
function mint(address to, uint amount) external onlyFactory returns (bool) { | ||
require(to != address(0), "invalid to address"); | ||
require(!token.paused(), "token is paused."); | ||
require(token.mint(to, amount), "minting failed."); | ||
return true; | ||
} | ||
|
||
function burn(uint value) external onlyFactory returns (bool) { | ||
require(!token.paused(), "token is paused."); | ||
token.burn(value); | ||
return true; | ||
} | ||
|
||
// all accessible | ||
function isCustodian(address addr) external view returns (bool) { | ||
return members.isCustodian(addr); | ||
} | ||
|
||
function isMerchant(address addr) external view returns (bool) { | ||
return members.isMerchant(addr); | ||
} | ||
|
||
function getWBTC() external view returns (ERC20) { | ||
return token; | ||
} | ||
|
||
// overriding | ||
function renounceOwnership() public onlyOwner { | ||
revert("renouncing ownership is blocked."); | ||
} | ||
} |
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,12 @@ | ||
pragma solidity 0.4.24; | ||
|
||
import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol"; | ||
|
||
|
||
interface ControllerInterface { | ||
function mint(address to, uint amount) external returns (bool); | ||
function burn(uint value) external returns (bool); | ||
function isCustodian(address addr) external view returns (bool); | ||
function isMerchant(address addr) external view returns (bool); | ||
function getWBTC() external view returns (ERC20); | ||
} |
Oops, something went wrong.