Skip to content

Commit 7272124

Browse files
authored
Merge pull request #525 from AugurProject/backlog_issues
Backlog issues
2 parents 8336d72 + 7f2c3fc commit 7272124

25 files changed

+367
-112
lines changed

source/contracts/Augur.sol

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
pragma solidity 0.4.18;
22

33
import 'Controlled.sol';
4+
import 'IAugur.sol';
45
import 'libraries/token/ERC20.sol';
56
import 'factories/UniverseFactory.sol';
67
import 'reporting/IUniverse.sol';
@@ -15,7 +16,7 @@ import 'libraries/Extractable.sol';
1516

1617

1718
// Centralized approval authority and event emissions
18-
contract Augur is Controlled, Extractable {
19+
contract Augur is Controlled, Extractable, IAugur {
1920
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);
2021
event InitialReportSubmitted(address indexed universe, address indexed reporter, address indexed market, uint256 amountStaked, bool isDesignatedReporter, uint256[] payoutNumerators);
2122
event DisputeCrowdsourcerCreated(address indexed universe, address indexed market, address disputeCrowdsourcer, uint256[] payoutNumerators, uint256 size);

source/contracts/Controller.sol

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ pragma solidity 0.4.18;
88
* 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.
99
*/
1010

11+
import 'IAugur.sol';
1112
import 'IController.sol';
1213
import 'IControlled.sol';
1314
import 'libraries/token/ERC20Basic.sol';
@@ -178,8 +179,8 @@ contract Controller is IController {
178179
* Helper functions
179180
*/
180181

181-
function getAugur() public view returns (Augur) {
182-
return Augur(lookup("Augur"));
182+
function getAugur() public view returns (IAugur) {
183+
return IAugur(lookup("Augur"));
183184
}
184185

185186
function getTimestamp() public view returns (uint256) {

source/contracts/IAugur.sol

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
pragma solidity 0.4.18;
2+
3+
import 'reporting/IUniverse.sol';
4+
import 'libraries/token/ERC20.sol';
5+
import 'reporting/IMarket.sol';
6+
import 'trading/Order.sol';
7+
8+
9+
contract IAugur {
10+
function createChildUniverse(bytes32 _parentPayoutDistributionHash) public returns (IUniverse);
11+
function isKnownUniverse(IUniverse _universe) public view returns (bool);
12+
function trustedTransfer(ERC20 _token, address _from, address _to, uint256 _amount) public returns (bool);
13+
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);
14+
function logMarketCreated(bytes32 _topic, string _description, string _extraInfo, IUniverse _universe, address _market, address _marketCreator, int256 _minPrice, int256 _maxPrice, IMarket.MarketType _marketType) public returns (bool);
15+
function logInitialReportSubmitted(IUniverse _universe, address _reporter, address _market, uint256 _amountStaked, bool _isDesignatedReporter, uint256[] _payoutNumerators) public returns (bool);
16+
function logDisputeCrowdsourcerCreated(IUniverse _universe, address _market, address _disputeCrowdsourcer, uint256[] _payoutNumerators, uint256 _size) public returns (bool);
17+
function logDisputeCrowdsourcerContribution(IUniverse _universe, address _reporter, address _market, address _disputeCrowdsourcer, uint256 _amountStaked) public returns (bool);
18+
function logDisputeCrowdsourcerCompleted(IUniverse _universe, address _market, address _disputeCrowdsourcer) public returns (bool);
19+
function logWinningTokensRedeemed(IUniverse _universe, address _reporter, address _market, address _reportingParticipant, uint256 _amountRedeemed, uint256 _reportingFeesReceived, uint256[] _payoutNumerators) public returns (bool);
20+
function logMarketFinalized(IUniverse _universe, address _market) public returns (bool);
21+
function logOrderCanceled(IUniverse _universe, address _shareToken, address _sender, bytes32 _orderId, Order.Types _orderType, uint256 _tokenRefund, uint256 _sharesRefund) public returns (bool);
22+
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);
23+
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);
24+
function logTradingProceedsClaimed(IUniverse _universe, address _shareToken, address _sender, address _market, uint256 _numShares, uint256 _numPayoutTokens, uint256 _finalTokenBalance) public returns (bool);
25+
function logUniverseForked() public returns (bool);
26+
function logUniverseCreated(IUniverse _childUniverse) public returns (bool);
27+
function logFeeWindowTransferred(IUniverse _universe, address _from, address _to, uint256 _value) public returns (bool);
28+
function logReputationTokensTransferred(IUniverse _universe, address _from, address _to, uint256 _value) public returns (bool);
29+
function logDisputeCrowdsourcerTokensTransferred(IUniverse _universe, address _from, address _to, uint256 _value) public returns (bool);
30+
function logShareTokensTransferred(IUniverse _universe, address _from, address _to, uint256 _value) public returns (bool);
31+
function logReputationTokenBurned(IUniverse _universe, address _target, uint256 _amount) public returns (bool);
32+
function logReputationTokenMinted(IUniverse _universe, address _target, uint256 _amount) public returns (bool);
33+
function logShareTokenBurned(IUniverse _universe, address _target, uint256 _amount) public returns (bool);
34+
function logShareTokenMinted(IUniverse _universe, address _target, uint256 _amount) public returns (bool);
35+
function logFeeWindowBurned(IUniverse _universe, address _target, uint256 _amount) public returns (bool);
36+
function logFeeWindowMinted(IUniverse _universe, address _target, uint256 _amount) public returns (bool);
37+
function logDisputeCrowdsourcerTokensBurned(IUniverse _universe, address _target, uint256 _amount) public returns (bool);
38+
function logDisputeCrowdsourcerTokensMinted(IUniverse _universe, address _target, uint256 _amount) public returns (bool);
39+
function logFeeWindowCreated(IFeeWindow _feeWindow, uint256 _id) public returns (bool);
40+
function logFeeTokenTransferred(IUniverse _universe, address _from, address _to, uint256 _value) public returns (bool);
41+
function logFeeTokenBurned(IUniverse _universe, address _target, uint256 _amount) public returns (bool);
42+
function logFeeTokenMinted(IUniverse _universe, address _target, uint256 _amount) public returns (bool);
43+
function logContractAddedToWhitelist(address _addition) public returns (bool);
44+
function logContractAddedToRegistry(bytes32 _key, address _address, bytes20 _commitHash, bytes32 _bytecodeHash) public returns (bool);
45+
}

source/contracts/IController.sol

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
pragma solidity 0.4.18;
22

3-
import 'Augur.sol';
3+
import 'IAugur.sol';
44

55

66
contract IController {
@@ -9,6 +9,6 @@ contract IController {
99
function assertOnlySpecifiedCaller(address _caller, bytes32 _allowedCaller) public view returns(bool);
1010
function stopInEmergency() public view returns(bool);
1111
function onlyInEmergency() public view returns(bool);
12-
function getAugur() public view returns (Augur);
12+
function getAugur() public view returns (IAugur);
1313
function getTimestamp() public view returns (uint256);
1414
}

source/contracts/factories/MarketFactory.sol

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import 'reporting/IMarket.sol';
66
import 'reporting/IReputationToken.sol';
77
import 'trading/ICash.sol';
88
import 'IController.sol';
9-
import 'Augur.sol';
109

1110

1211
contract MarketFactory {

source/contracts/libraries/CashAutoConverter.sol

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ pragma solidity 0.4.18;
33

44
import 'trading/ICash.sol';
55
import 'Controlled.sol';
6-
import 'Augur.sol';
6+
import 'IAugur.sol';
77

88

99
/**
@@ -30,7 +30,7 @@ contract CashAutoConverter is Controlled {
3030
ICash _cash = ICash(controller.lookup("Cash"));
3131
uint256 _tokenBalance = _cash.balanceOf(msg.sender);
3232
if (_tokenBalance > 0) {
33-
Augur augur = controller.getAugur();
33+
IAugur augur = controller.getAugur();
3434
augur.trustedTransfer(_cash, msg.sender, this, _tokenBalance);
3535
_cash.withdrawEtherTo(msg.sender, _tokenBalance);
3636
}

source/contracts/reporting/FeeToken.sol

+10-5
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ import 'reporting/IFeeToken.sol';
44
import 'reporting/IFeeWindow.sol';
55
import 'libraries/DelegationTarget.sol';
66
import 'libraries/token/VariableSupplyToken.sol';
7+
import 'libraries/Extractable.sol';
78

89

9-
contract FeeToken is DelegationTarget, VariableSupplyToken, IFeeToken {
10+
contract FeeToken is DelegationTarget, Extractable, VariableSupplyToken, IFeeToken {
1011
IFeeWindow private feeWindow;
1112

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

3435
function onTokenTransfer(address _from, address _to, uint256 _value) internal returns (bool) {
35-
feeWindow.getController().getAugur().logFeeTokenTransferred(feeWindow.getUniverse(), _from, _to, _value);
36+
controller.getAugur().logFeeTokenTransferred(feeWindow.getUniverse(), _from, _to, _value);
3637
return true;
3738
}
3839

3940
function onMint(address _target, uint256 _amount) internal returns (bool) {
40-
feeWindow.getController().getAugur().logFeeTokenMinted(feeWindow.getUniverse(), _target, _amount);
41+
controller.getAugur().logFeeTokenMinted(feeWindow.getUniverse(), _target, _amount);
4142
return true;
4243
}
4344

4445
function onBurn(address _target, uint256 _amount) internal returns (bool) {
45-
feeWindow.getController().getAugur().logFeeTokenBurned(feeWindow.getUniverse(), _target, _amount);
46+
controller.getAugur().logFeeTokenBurned(feeWindow.getUniverse(), _target, _amount);
4647
return true;
4748
}
48-
}
49+
50+
function getProtectedTokens() internal returns (address[] memory) {
51+
return new address[](0);
52+
}
53+
}

source/contracts/reporting/IFeeWindow.sol

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@ import 'reporting/IReputationToken.sol';
88
import 'reporting/IFeeToken.sol';
99
import 'trading/ICash.sol';
1010
import 'libraries/token/ERC20.sol';
11-
import 'IControlled.sol';
1211

1312

14-
contract IFeeWindow is ITyped, IControlled, ERC20 {
13+
contract IFeeWindow is ITyped, ERC20 {
1514
function initialize(IUniverse _universe, uint256 _feeWindowId) public returns (bool);
1615
function noteInitialReportingGasPrice() public returns (bool);
1716
function getUniverse() public view returns (IUniverse);

source/contracts/reporting/Mailbox.sol

+10-1
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ import 'libraries/token/ERC20Basic.sol';
66
import 'libraries/Initializable.sol';
77
import 'reporting/IMailbox.sol';
88
import 'trading/ICash.sol';
9+
import 'libraries/Extractable.sol';
910

1011

11-
contract Mailbox is DelegationTarget, Ownable, Initializable, IMailbox {
12+
contract Mailbox is DelegationTarget, Extractable, Ownable, Initializable, IMailbox {
1213
function initialize(address _owner) public onlyInGoodTimes beforeInitialized returns (bool) {
1314
endInitialization();
1415
owner = _owner;
@@ -39,4 +40,12 @@ contract Mailbox is DelegationTarget, Ownable, Initializable, IMailbox {
3940
require(_token.transfer(owner, _balance));
4041
return true;
4142
}
43+
44+
function getProtectedTokens() internal returns (address[] memory) {
45+
address[] memory _protectedTokens = new address[](2);
46+
// address(1) is the sentinel value for Ether extraction
47+
_protectedTokens[0] = address(1);
48+
_protectedTokens[1] = ICash(controller.lookup("Cash"));
49+
return _protectedTokens;
50+
}
4251
}

source/contracts/reporting/Market.sol

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import 'factories/MailboxFactory.sol';
2424
import 'reporting/IMailbox.sol';
2525
import 'reporting/Reporting.sol';
2626
import 'reporting/IInitialReporter.sol';
27-
import 'Augur.sol';
2827

2928

3029
contract Market is DelegationTarget, Extractable, ITyped, Initializable, Ownable, IMarket {

source/contracts/reporting/Universe.sol

+4-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import 'reporting/IFeeToken.sol';
1515
import 'reporting/Reporting.sol';
1616
import 'reporting/IRepPriceOracle.sol';
1717
import 'libraries/math/SafeMathUint256.sol';
18-
import 'Augur.sol';
18+
import 'IAugur.sol';
1919
import 'libraries/Extractable.sol';
2020

2121

@@ -171,10 +171,11 @@ contract Universe is DelegationTarget, Extractable, ITyped, Initializable, IUniv
171171
function createChildUniverse(uint256[] _parentPayoutNumerators, bool _parentInvalid) public returns (IUniverse) {
172172
bytes32 _parentPayoutDistributionHash = forkingMarket.derivePayoutDistributionHash(_parentPayoutNumerators, _parentInvalid);
173173
IUniverse _childUniverse = getChildUniverse(_parentPayoutDistributionHash);
174+
IAugur _augur = controller.getAugur();
174175
if (_childUniverse == IUniverse(0)) {
175-
_childUniverse = controller.getAugur().createChildUniverse(_parentPayoutDistributionHash);
176+
_childUniverse = _augur.createChildUniverse(_parentPayoutDistributionHash);
176177
childUniverses[_parentPayoutDistributionHash] = _childUniverse;
177-
controller.getAugur().logUniverseCreated(_childUniverse);
178+
_augur.logUniverseCreated(_childUniverse);
178179
}
179180
return _childUniverse;
180181
}

source/contracts/trading/CancelOrder.sol

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import 'trading/Order.sol';
1414
import 'reporting/IMarket.sol';
1515
import 'trading/ICash.sol';
1616
import 'trading/IOrders.sol';
17-
import 'Augur.sol';
1817
import 'libraries/Extractable.sol';
1918

2019

source/contracts/trading/ClaimTradingProceeds.sol

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import 'reporting/IMarket.sol';
1010
import 'trading/ICash.sol';
1111
import 'libraries/math/SafeMathUint256.sol';
1212
import 'reporting/Reporting.sol';
13-
import 'Augur.sol';
1413
import 'libraries/Extractable.sol';
1514

1615

source/contracts/trading/CompleteSets.sol

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ pragma solidity 0.4.18;
22

33

44
import 'trading/ICompleteSets.sol';
5-
import 'Augur.sol';
5+
import 'IAugur.sol';
66
import 'Controlled.sol';
77
import 'libraries/ReentrancyGuard.sol';
88
import 'libraries/math/SafeMathUint256.sol';
@@ -30,7 +30,7 @@ contract CompleteSets is Controlled, Extractable, CashAutoConverter, ReentrancyG
3030

3131
uint8 _numOutcomes = _market.getNumberOfOutcomes();
3232
ICash _denominationToken = _market.getDenominationToken();
33-
Augur _augur = controller.getAugur();
33+
IAugur _augur = controller.getAugur();
3434

3535
uint256 _cost = _amount.mul(_market.getNumTicks());
3636
require(_augur.trustedTransfer(_denominationToken, _sender, _market, _cost));

source/contracts/trading/FillOrder.sol

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ pragma solidity 0.4.18;
22

33

44
import 'trading/IFillOrder.sol';
5-
import 'Augur.sol';
65
import 'Controlled.sol';
76
import 'libraries/ReentrancyGuard.sol';
87
import 'libraries/math/SafeMathUint256.sol';
@@ -32,7 +31,7 @@ library Trade {
3231
ICash denominationToken;
3332
IShareToken longShareToken;
3433
IShareToken[] shortShareTokens;
35-
Augur augur;
34+
IAugur augur;
3635
}
3736

3837
struct FilledOrder {
@@ -271,7 +270,7 @@ library Trade {
271270
denominationToken: _market.getDenominationToken(),
272271
longShareToken: _market.getShareToken(_outcome),
273272
shortShareTokens: getShortShareTokens(_market, _outcome),
274-
augur: Augur(_controller.lookup("Augur"))
273+
augur: _controller.getAugur()
275274
});
276275
}
277276

source/contracts/trading/Order.sol

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
pragma solidity 0.4.18;
1010

1111

12-
import 'Augur.sol';
12+
import 'IAugur.sol';
1313
import 'IController.sol';
1414
import 'libraries/math/SafeMathUint256.sol';
1515
import 'reporting/IMarket.sol';
@@ -34,7 +34,7 @@ library Order {
3434
// Contracts
3535
IOrders orders;
3636
IMarket market;
37-
Augur augur;
37+
IAugur augur;
3838

3939
// Order
4040
bytes32 id;
@@ -59,7 +59,7 @@ library Order {
5959
require(_price < _market.getNumTicks());
6060

6161
IOrders _orders = IOrders(_controller.lookup("Orders"));
62-
Augur _augur = Augur(_controller.lookup("Augur"));
62+
IAugur _augur = _controller.getAugur();
6363

6464
return Data({
6565
orders: _orders,

source/contracts/trading/Orders.sol

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import 'libraries/math/SafeMathInt256.sol';
88
import 'trading/Order.sol';
99
import 'reporting/IMarket.sol';
1010
import 'trading/IOrdersFetcher.sol';
11-
import 'Augur.sol';
1211
import 'libraries/Extractable.sol';
1312

1413

source/libraries/ContractCompiler.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,9 @@ export class ContractCompiler {
103103
if (abi === undefined) continue;
104104
const bytecode = compilerOutput.contracts[relativeFilePath][contractName].evm.bytecode.object;
105105
if (bytecode === undefined) continue;
106-
// don't include interfaces
107-
if (/^I[A-Z].*/.test(contractName)) continue;
108-
// TODO: turn this into an error once we establish naming convention for abstract methods
109-
if (bytecode.length === 0) continue;
106+
// don't include interfaces or Abstract contracts
107+
if (/^(?:I|Base)[A-Z].*/.test(contractName)) continue;
108+
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");
110109

111110
result.contracts[relativeFilePath] = {
112111
[contractName]: {

0 commit comments

Comments
 (0)