Skip to content

Commit

Permalink
Merge pull request #525 from AugurProject/backlog_issues
Browse files Browse the repository at this point in the history
Backlog issues
  • Loading branch information
nuevoalex committed Jan 9, 2018
2 parents 8336d72 + 7f2c3fc commit 7272124
Show file tree
Hide file tree
Showing 25 changed files with 367 additions and 112 deletions.
3 changes: 2 additions & 1 deletion source/contracts/Augur.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
pragma solidity 0.4.18;

import 'Controlled.sol';
import 'IAugur.sol';
import 'libraries/token/ERC20.sol';
import 'factories/UniverseFactory.sol';
import 'reporting/IUniverse.sol';
Expand All @@ -15,7 +16,7 @@ import 'libraries/Extractable.sol';


// Centralized approval authority and event emissions
contract Augur is Controlled, Extractable {
contract Augur is Controlled, Extractable, IAugur {
event MarketCreated(bytes32 indexed topic, string description, string extraInfo, address indexed universe, address market, address indexed marketCreator, bytes32[] outcomes, uint256 marketCreationFee, int256 minPrice, int256 maxPrice, IMarket.MarketType marketType);
event InitialReportSubmitted(address indexed universe, address indexed reporter, address indexed market, uint256 amountStaked, bool isDesignatedReporter, uint256[] payoutNumerators);
event DisputeCrowdsourcerCreated(address indexed universe, address indexed market, address disputeCrowdsourcer, uint256[] payoutNumerators, uint256 size);
Expand Down
5 changes: 3 additions & 2 deletions source/contracts/Controller.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pragma solidity 0.4.18;
* Initially, Augur will have a “dev mode” that that can be enabled to allow Augur’s team to suicide funds, extract Ether or Tokens from a specific contract (in case funds inadvertently get sent somewhere they shouldn’t have), and update the Controller of a target contract to a new Controller. Eventually, the plan is to remove this mode so that this functionality will no longer be available to anyone, including the Augur team. At that point, the `owner` address will only be able to the `emergencyStop` and `release` functions.
*/

import 'IAugur.sol';
import 'IController.sol';
import 'IControlled.sol';
import 'libraries/token/ERC20Basic.sol';
Expand Down Expand Up @@ -178,8 +179,8 @@ contract Controller is IController {
* Helper functions
*/

function getAugur() public view returns (Augur) {
return Augur(lookup("Augur"));
function getAugur() public view returns (IAugur) {
return IAugur(lookup("Augur"));
}

function getTimestamp() public view returns (uint256) {
Expand Down
45 changes: 45 additions & 0 deletions source/contracts/IAugur.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
pragma solidity 0.4.18;

import 'reporting/IUniverse.sol';
import 'libraries/token/ERC20.sol';
import 'reporting/IMarket.sol';
import 'trading/Order.sol';


contract IAugur {
function createChildUniverse(bytes32 _parentPayoutDistributionHash) public returns (IUniverse);
function isKnownUniverse(IUniverse _universe) public view returns (bool);
function trustedTransfer(ERC20 _token, address _from, address _to, uint256 _amount) public returns (bool);
function logMarketCreated(bytes32 _topic, string _description, string _extraInfo, IUniverse _universe, address _market, address _marketCreator, bytes32[] _outcomes, int256 _minPrice, int256 _maxPrice, IMarket.MarketType _marketType) public returns (bool);
function logMarketCreated(bytes32 _topic, string _description, string _extraInfo, IUniverse _universe, address _market, address _marketCreator, int256 _minPrice, int256 _maxPrice, IMarket.MarketType _marketType) public returns (bool);
function logInitialReportSubmitted(IUniverse _universe, address _reporter, address _market, uint256 _amountStaked, bool _isDesignatedReporter, uint256[] _payoutNumerators) public returns (bool);
function logDisputeCrowdsourcerCreated(IUniverse _universe, address _market, address _disputeCrowdsourcer, uint256[] _payoutNumerators, uint256 _size) public returns (bool);
function logDisputeCrowdsourcerContribution(IUniverse _universe, address _reporter, address _market, address _disputeCrowdsourcer, uint256 _amountStaked) public returns (bool);
function logDisputeCrowdsourcerCompleted(IUniverse _universe, address _market, address _disputeCrowdsourcer) public returns (bool);
function logWinningTokensRedeemed(IUniverse _universe, address _reporter, address _market, address _reportingParticipant, uint256 _amountRedeemed, uint256 _reportingFeesReceived, uint256[] _payoutNumerators) public returns (bool);
function logMarketFinalized(IUniverse _universe, address _market) public returns (bool);
function logOrderCanceled(IUniverse _universe, address _shareToken, address _sender, bytes32 _orderId, Order.Types _orderType, uint256 _tokenRefund, uint256 _sharesRefund) public returns (bool);
function logOrderCreated(Order.Types _orderType, uint256 _amount, uint256 _price, address _creator, uint256 _moneyEscrowed, uint256 _sharesEscrowed, bytes32 _tradeGroupId, bytes32 _orderId, IUniverse _universe, address _shareToken) public returns (bool);
function logOrderFilled(IUniverse _universe, address _shareToken, address _filler, bytes32 _orderId, uint256 _numCreatorShares, uint256 _numCreatorTokens, uint256 _numFillerShares, uint256 _numFillerTokens, uint256 _marketCreatorFees, uint256 _reporterFees, bytes32 _tradeGroupId) public returns (bool);
function logTradingProceedsClaimed(IUniverse _universe, address _shareToken, address _sender, address _market, uint256 _numShares, uint256 _numPayoutTokens, uint256 _finalTokenBalance) public returns (bool);
function logUniverseForked() public returns (bool);
function logUniverseCreated(IUniverse _childUniverse) public returns (bool);
function logFeeWindowTransferred(IUniverse _universe, address _from, address _to, uint256 _value) public returns (bool);
function logReputationTokensTransferred(IUniverse _universe, address _from, address _to, uint256 _value) public returns (bool);
function logDisputeCrowdsourcerTokensTransferred(IUniverse _universe, address _from, address _to, uint256 _value) public returns (bool);
function logShareTokensTransferred(IUniverse _universe, address _from, address _to, uint256 _value) public returns (bool);
function logReputationTokenBurned(IUniverse _universe, address _target, uint256 _amount) public returns (bool);
function logReputationTokenMinted(IUniverse _universe, address _target, uint256 _amount) public returns (bool);
function logShareTokenBurned(IUniverse _universe, address _target, uint256 _amount) public returns (bool);
function logShareTokenMinted(IUniverse _universe, address _target, uint256 _amount) public returns (bool);
function logFeeWindowBurned(IUniverse _universe, address _target, uint256 _amount) public returns (bool);
function logFeeWindowMinted(IUniverse _universe, address _target, uint256 _amount) public returns (bool);
function logDisputeCrowdsourcerTokensBurned(IUniverse _universe, address _target, uint256 _amount) public returns (bool);
function logDisputeCrowdsourcerTokensMinted(IUniverse _universe, address _target, uint256 _amount) public returns (bool);
function logFeeWindowCreated(IFeeWindow _feeWindow, uint256 _id) public returns (bool);
function logFeeTokenTransferred(IUniverse _universe, address _from, address _to, uint256 _value) public returns (bool);
function logFeeTokenBurned(IUniverse _universe, address _target, uint256 _amount) public returns (bool);
function logFeeTokenMinted(IUniverse _universe, address _target, uint256 _amount) public returns (bool);
function logContractAddedToWhitelist(address _addition) public returns (bool);
function logContractAddedToRegistry(bytes32 _key, address _address, bytes20 _commitHash, bytes32 _bytecodeHash) public returns (bool);
}
4 changes: 2 additions & 2 deletions source/contracts/IController.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pragma solidity 0.4.18;

import 'Augur.sol';
import 'IAugur.sol';


contract IController {
Expand All @@ -9,6 +9,6 @@ contract IController {
function assertOnlySpecifiedCaller(address _caller, bytes32 _allowedCaller) public view returns(bool);
function stopInEmergency() public view returns(bool);
function onlyInEmergency() public view returns(bool);
function getAugur() public view returns (Augur);
function getAugur() public view returns (IAugur);
function getTimestamp() public view returns (uint256);
}
1 change: 0 additions & 1 deletion source/contracts/factories/MarketFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import 'reporting/IMarket.sol';
import 'reporting/IReputationToken.sol';
import 'trading/ICash.sol';
import 'IController.sol';
import 'Augur.sol';


contract MarketFactory {
Expand Down
4 changes: 2 additions & 2 deletions source/contracts/libraries/CashAutoConverter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity 0.4.18;

import 'trading/ICash.sol';
import 'Controlled.sol';
import 'Augur.sol';
import 'IAugur.sol';


/**
Expand All @@ -30,7 +30,7 @@ contract CashAutoConverter is Controlled {
ICash _cash = ICash(controller.lookup("Cash"));
uint256 _tokenBalance = _cash.balanceOf(msg.sender);
if (_tokenBalance > 0) {
Augur augur = controller.getAugur();
IAugur augur = controller.getAugur();
augur.trustedTransfer(_cash, msg.sender, this, _tokenBalance);
_cash.withdrawEtherTo(msg.sender, _tokenBalance);
}
Expand Down
15 changes: 10 additions & 5 deletions source/contracts/reporting/FeeToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import 'reporting/IFeeToken.sol';
import 'reporting/IFeeWindow.sol';
import 'libraries/DelegationTarget.sol';
import 'libraries/token/VariableSupplyToken.sol';
import 'libraries/Extractable.sol';


contract FeeToken is DelegationTarget, VariableSupplyToken, IFeeToken {
contract FeeToken is DelegationTarget, Extractable, VariableSupplyToken, IFeeToken {
IFeeWindow private feeWindow;

function initialize(IFeeWindow _feeWindow) public beforeInitialized returns (bool) {
Expand All @@ -32,17 +33,21 @@ contract FeeToken is DelegationTarget, VariableSupplyToken, IFeeToken {
}

function onTokenTransfer(address _from, address _to, uint256 _value) internal returns (bool) {
feeWindow.getController().getAugur().logFeeTokenTransferred(feeWindow.getUniverse(), _from, _to, _value);
controller.getAugur().logFeeTokenTransferred(feeWindow.getUniverse(), _from, _to, _value);
return true;
}

function onMint(address _target, uint256 _amount) internal returns (bool) {
feeWindow.getController().getAugur().logFeeTokenMinted(feeWindow.getUniverse(), _target, _amount);
controller.getAugur().logFeeTokenMinted(feeWindow.getUniverse(), _target, _amount);
return true;
}

function onBurn(address _target, uint256 _amount) internal returns (bool) {
feeWindow.getController().getAugur().logFeeTokenBurned(feeWindow.getUniverse(), _target, _amount);
controller.getAugur().logFeeTokenBurned(feeWindow.getUniverse(), _target, _amount);
return true;
}
}

function getProtectedTokens() internal returns (address[] memory) {
return new address[](0);
}
}
3 changes: 1 addition & 2 deletions source/contracts/reporting/IFeeWindow.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ import 'reporting/IReputationToken.sol';
import 'reporting/IFeeToken.sol';
import 'trading/ICash.sol';
import 'libraries/token/ERC20.sol';
import 'IControlled.sol';


contract IFeeWindow is ITyped, IControlled, ERC20 {
contract IFeeWindow is ITyped, ERC20 {
function initialize(IUniverse _universe, uint256 _feeWindowId) public returns (bool);
function noteInitialReportingGasPrice() public returns (bool);
function getUniverse() public view returns (IUniverse);
Expand Down
11 changes: 10 additions & 1 deletion source/contracts/reporting/Mailbox.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import 'libraries/token/ERC20Basic.sol';
import 'libraries/Initializable.sol';
import 'reporting/IMailbox.sol';
import 'trading/ICash.sol';
import 'libraries/Extractable.sol';


contract Mailbox is DelegationTarget, Ownable, Initializable, IMailbox {
contract Mailbox is DelegationTarget, Extractable, Ownable, Initializable, IMailbox {
function initialize(address _owner) public onlyInGoodTimes beforeInitialized returns (bool) {
endInitialization();
owner = _owner;
Expand Down Expand Up @@ -39,4 +40,12 @@ contract Mailbox is DelegationTarget, Ownable, Initializable, IMailbox {
require(_token.transfer(owner, _balance));
return true;
}

function getProtectedTokens() internal returns (address[] memory) {
address[] memory _protectedTokens = new address[](2);
// address(1) is the sentinel value for Ether extraction
_protectedTokens[0] = address(1);
_protectedTokens[1] = ICash(controller.lookup("Cash"));
return _protectedTokens;
}
}
1 change: 0 additions & 1 deletion source/contracts/reporting/Market.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import 'factories/MailboxFactory.sol';
import 'reporting/IMailbox.sol';
import 'reporting/Reporting.sol';
import 'reporting/IInitialReporter.sol';
import 'Augur.sol';


contract Market is DelegationTarget, Extractable, ITyped, Initializable, Ownable, IMarket {
Expand Down
7 changes: 4 additions & 3 deletions source/contracts/reporting/Universe.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import 'reporting/IFeeToken.sol';
import 'reporting/Reporting.sol';
import 'reporting/IRepPriceOracle.sol';
import 'libraries/math/SafeMathUint256.sol';
import 'Augur.sol';
import 'IAugur.sol';
import 'libraries/Extractable.sol';


Expand Down Expand Up @@ -171,10 +171,11 @@ contract Universe is DelegationTarget, Extractable, ITyped, Initializable, IUniv
function createChildUniverse(uint256[] _parentPayoutNumerators, bool _parentInvalid) public returns (IUniverse) {
bytes32 _parentPayoutDistributionHash = forkingMarket.derivePayoutDistributionHash(_parentPayoutNumerators, _parentInvalid);
IUniverse _childUniverse = getChildUniverse(_parentPayoutDistributionHash);
IAugur _augur = controller.getAugur();
if (_childUniverse == IUniverse(0)) {
_childUniverse = controller.getAugur().createChildUniverse(_parentPayoutDistributionHash);
_childUniverse = _augur.createChildUniverse(_parentPayoutDistributionHash);
childUniverses[_parentPayoutDistributionHash] = _childUniverse;
controller.getAugur().logUniverseCreated(_childUniverse);
_augur.logUniverseCreated(_childUniverse);
}
return _childUniverse;
}
Expand Down
1 change: 0 additions & 1 deletion source/contracts/trading/CancelOrder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import 'trading/Order.sol';
import 'reporting/IMarket.sol';
import 'trading/ICash.sol';
import 'trading/IOrders.sol';
import 'Augur.sol';
import 'libraries/Extractable.sol';


Expand Down
1 change: 0 additions & 1 deletion source/contracts/trading/ClaimTradingProceeds.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import 'reporting/IMarket.sol';
import 'trading/ICash.sol';
import 'libraries/math/SafeMathUint256.sol';
import 'reporting/Reporting.sol';
import 'Augur.sol';
import 'libraries/Extractable.sol';


Expand Down
4 changes: 2 additions & 2 deletions source/contracts/trading/CompleteSets.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ pragma solidity 0.4.18;


import 'trading/ICompleteSets.sol';
import 'Augur.sol';
import 'IAugur.sol';
import 'Controlled.sol';
import 'libraries/ReentrancyGuard.sol';
import 'libraries/math/SafeMathUint256.sol';
Expand Down Expand Up @@ -30,7 +30,7 @@ contract CompleteSets is Controlled, Extractable, CashAutoConverter, ReentrancyG

uint8 _numOutcomes = _market.getNumberOfOutcomes();
ICash _denominationToken = _market.getDenominationToken();
Augur _augur = controller.getAugur();
IAugur _augur = controller.getAugur();

uint256 _cost = _amount.mul(_market.getNumTicks());
require(_augur.trustedTransfer(_denominationToken, _sender, _market, _cost));
Expand Down
5 changes: 2 additions & 3 deletions source/contracts/trading/FillOrder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ pragma solidity 0.4.18;


import 'trading/IFillOrder.sol';
import 'Augur.sol';
import 'Controlled.sol';
import 'libraries/ReentrancyGuard.sol';
import 'libraries/math/SafeMathUint256.sol';
Expand Down Expand Up @@ -32,7 +31,7 @@ library Trade {
ICash denominationToken;
IShareToken longShareToken;
IShareToken[] shortShareTokens;
Augur augur;
IAugur augur;
}

struct FilledOrder {
Expand Down Expand Up @@ -271,7 +270,7 @@ library Trade {
denominationToken: _market.getDenominationToken(),
longShareToken: _market.getShareToken(_outcome),
shortShareTokens: getShortShareTokens(_market, _outcome),
augur: Augur(_controller.lookup("Augur"))
augur: _controller.getAugur()
});
}

Expand Down
6 changes: 3 additions & 3 deletions source/contracts/trading/Order.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
pragma solidity 0.4.18;


import 'Augur.sol';
import 'IAugur.sol';
import 'IController.sol';
import 'libraries/math/SafeMathUint256.sol';
import 'reporting/IMarket.sol';
Expand All @@ -34,7 +34,7 @@ library Order {
// Contracts
IOrders orders;
IMarket market;
Augur augur;
IAugur augur;

// Order
bytes32 id;
Expand All @@ -59,7 +59,7 @@ library Order {
require(_price < _market.getNumTicks());

IOrders _orders = IOrders(_controller.lookup("Orders"));
Augur _augur = Augur(_controller.lookup("Augur"));
IAugur _augur = _controller.getAugur();

return Data({
orders: _orders,
Expand Down
1 change: 0 additions & 1 deletion source/contracts/trading/Orders.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import 'libraries/math/SafeMathInt256.sol';
import 'trading/Order.sol';
import 'reporting/IMarket.sol';
import 'trading/IOrdersFetcher.sol';
import 'Augur.sol';
import 'libraries/Extractable.sol';


Expand Down
7 changes: 3 additions & 4 deletions source/libraries/ContractCompiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,9 @@ export class ContractCompiler {
if (abi === undefined) continue;
const bytecode = compilerOutput.contracts[relativeFilePath][contractName].evm.bytecode.object;
if (bytecode === undefined) continue;
// don't include interfaces
if (/^I[A-Z].*/.test(contractName)) continue;
// TODO: turn this into an error once we establish naming convention for abstract methods
if (bytecode.length === 0) continue;
// don't include interfaces or Abstract contracts
if (/^(?:I|Base)[A-Z].*/.test(contractName)) continue;
if (bytecode.length === 0) throw new Error("Contract: " + contractName + " has no bytecode, but this is not expected. It probably doesn't implement all its abstract methods");

result.contracts[relativeFilePath] = {
[contractName]: {
Expand Down
Loading

0 comments on commit 7272124

Please sign in to comment.