Skip to content

Commit 14057cf

Browse files
nuevoalexnuevoalex
authored andcommitted
License changes. Log when contracts are added to the registry
1 parent ff20a98 commit 14057cf

18 files changed

+93
-113
lines changed

CRIBBED_CODE.txt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
Licensing inclusion for the following files which were originally taken from the OpenZeppelin Solidity token contracts and later modified by us:
2+
3+
source/libraries/token/BasicToken.sol
4+
source/libraries/token/ERC20.sol
5+
source/libraries/token/ERC20Basic.sol
6+
source/libraries/token/StandardToken.sol
7+
8+
The MIT License (MIT)
9+
10+
Copyright (c) 2016 Smart Contract Solutions, Inc.
11+
12+
Permission is hereby granted, free of charge, to any person obtaining
13+
a copy of this software and associated documentation files (the
14+
"Software"), to deal in the Software without restriction, including
15+
without limitation the rights to use, copy, modify, merge, publish,
16+
distribute, sublicense, and/or sell copies of the Software, and to
17+
permit persons to whom the Software is furnished to do so, subject to
18+
the following conditions:
19+
20+
The above copyright notice and this permission notice shall be included
21+
in all copies or substantial portions of the Software.
22+
23+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
26+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
27+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
28+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
29+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

source/contracts/Augur.sol

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ contract Augur is Controlled, Extractable {
3535
event TokensBurned(address indexed universe, address indexed token, address indexed target, uint256 amount);
3636
event FeeWindowCreated(address indexed universe, address feeWindow, uint256 startTime, uint256 endTime, uint256 id);
3737
event WhitelistAddition(address addition);
38+
event RegistryAddition(bytes32 key, address addition, bytes20 commitHash, bytes32 bytecodeHash);
3839

3940
mapping(address => bool) private universes;
4041

@@ -285,6 +286,11 @@ contract Augur is Controlled, Extractable {
285286
return true;
286287
}
287288

289+
function logContractAddedToRegistry(bytes32 _key, address _address, bytes20 _commitHash, bytes32 _bytecodeHash) public onlyControllerCaller returns (bool) {
290+
RegistryAddition(_key, _address, _commitHash, _bytecodeHash);
291+
return true;
292+
}
293+
288294
function getProtectedTokens() internal returns (address[] memory) {
289295
return new address[](0);
290296
}

source/contracts/Controller.sol

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ contract Controller is IController {
8686

8787
function registerContract(bytes32 _key, address _address, bytes20 _commitHash, bytes32 _bytecodeHash) public onlyOwnerCaller returns (bool) {
8888
registry[_key] = ContractDetails(_key, _address, _commitHash, _bytecodeHash);
89+
getAugur().logContractAddedToRegistry(_key, _address, _commitHash, _bytecodeHash);
8990
return true;
9091
}
9192

source/contracts/libraries/Delegator.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ contract Delegator is DelegationTarget {
2323
assembly {
2424
//0x40 is the address where the next free memory slot is stored in Solidity
2525
let _calldataMemoryOffset := mload(0x40)
26-
// Update the pointer at 0x40 to point at new free memory location so any theoretical allocation doesn't stomp our memory in this call
26+
// new "memory end" including padding. The bitwise operations here ensure we get rounded up to the nearest 32 byte boundary
2727
let _size := and(add(calldatasize, 0x1f), not(0x1f))
28+
// Update the pointer at 0x40 to point at new free memory location so any theoretical allocation doesn't stomp our memory in this call
2829
mstore(0x40, add(_calldataMemoryOffset, _size))
2930
// Copy method signature and parameters of this call into memory
3031
calldatacopy(_calldataMemoryOffset, 0x0, calldatasize)

source/contracts/libraries/token/BasicToken.sol

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,3 @@
1-
/*
2-
The MIT License (MIT)
3-
4-
Copyright (c) 2016 Smart Contract Solutions, Inc.
5-
6-
Permission is hereby granted, free of charge, to any person obtaining
7-
a copy of this software and associated documentation files (the
8-
"Software"), to deal in the Software without restriction, including
9-
without limitation the rights to use, copy, modify, merge, publish,
10-
distribute, sublicense, and/or sell copies of the Software, and to
11-
permit persons to whom the Software is furnished to do so, subject to
12-
the following conditions:
13-
14-
The above copyright notice and this permission notice shall be included
15-
in all copies or substantial portions of the Software.
16-
17-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18-
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24-
*/
25-
261
pragma solidity 0.4.18;
272

283

source/contracts/libraries/token/ERC20.sol

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,3 @@
1-
/*
2-
The MIT License (MIT)
3-
4-
Copyright (c) 2016 Smart Contract Solutions, Inc.
5-
6-
Permission is hereby granted, free of charge, to any person obtaining
7-
a copy of this software and associated documentation files (the
8-
"Software"), to deal in the Software without restriction, including
9-
without limitation the rights to use, copy, modify, merge, publish,
10-
distribute, sublicense, and/or sell copies of the Software, and to
11-
permit persons to whom the Software is furnished to do so, subject to
12-
the following conditions:
13-
14-
The above copyright notice and this permission notice shall be included
15-
in all copies or substantial portions of the Software.
16-
17-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18-
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24-
*/
25-
261
pragma solidity 0.4.18;
272

283

source/contracts/libraries/token/ERC20Basic.sol

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,3 @@
1-
/*
2-
The MIT License (MIT)
3-
4-
Copyright (c) 2016 Smart Contract Solutions, Inc.
5-
6-
Permission is hereby granted, free of charge, to any person obtaining
7-
a copy of this software and associated documentation files (the
8-
"Software"), to deal in the Software without restriction, including
9-
without limitation the rights to use, copy, modify, merge, publish,
10-
distribute, sublicense, and/or sell copies of the Software, and to
11-
permit persons to whom the Software is furnished to do so, subject to
12-
the following conditions:
13-
14-
The above copyright notice and this permission notice shall be included
15-
in all copies or substantial portions of the Software.
16-
17-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18-
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24-
*/
25-
261
pragma solidity 0.4.18;
272

283

source/contracts/libraries/token/StandardToken.sol

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,3 @@
1-
/*
2-
The MIT License (MIT)
3-
4-
Copyright (c) 2016 Smart Contract Solutions, Inc.
5-
6-
Permission is hereby granted, free of charge, to any person obtaining
7-
a copy of this software and associated documentation files (the
8-
"Software"), to deal in the Software without restriction, including
9-
without limitation the rights to use, copy, modify, merge, publish,
10-
distribute, sublicense, and/or sell copies of the Software, and to
11-
permit persons to whom the Software is furnished to do so, subject to
12-
the following conditions:
13-
14-
The above copyright notice and this permission notice shall be included
15-
in all copies or substantial portions of the Software.
16-
17-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18-
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24-
*/
25-
261
pragma solidity 0.4.18;
272

283

source/libraries/ContractDeployer.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export class ContractDeployer {
3030

3131
public async deploy(): Promise<void> {
3232
this.controller = await this.uploadController();
33+
await this.uploadAugur();
3334
await this.uploadAllContracts();
3435
await this.initializeAllContracts();
3536
await this.whitelistTradingContracts();
@@ -87,6 +88,19 @@ export class ContractDeployer {
8788
return controller;
8889
}
8990

91+
private async uploadAugur(): Promise<void> {
92+
// We have to upload and initialize Augur first so it can log the registration and whitelisting of other contracts
93+
const contract = await this.contracts.get("Augur");
94+
const address = await this.construct(contract, [], `Uploading ${contract.contractName}`);
95+
const commitHash = await ContractDeployer.getGitCommit();
96+
const bytecodeHash = await ContractDeployer.getBytecodeSha(contract.bytecode);
97+
const augur = new Augur(this.connector, this.accountManager, address, this.configuration.gasPrice);
98+
contract.address = address;
99+
const setControllerTransactionHash = await augur.setController(this.controller.address);
100+
await this.connector.waitForTransactionReceipt(setControllerTransactionHash, `Initializing Augur.`);
101+
await this.controller.registerContract(stringTo32ByteHex("Augur"), address, commitHash, bytecodeHash);
102+
}
103+
90104
private async uploadAllContracts(): Promise<void> {
91105
console.log('Uploading contracts...');
92106
const promises = [...this.contracts].map(contract => this.upload(contract));
@@ -99,6 +113,7 @@ export class ContractDeployer {
99113
if (contractName === 'Controller') return;
100114
if (contractName === 'Delegator') return;
101115
if (contractName === 'TimeControlled') return;
116+
if (contractName === 'Augur') return;
102117
if (contractName === 'Time') contract = this.configuration.useNormalTime ? contract: this.contracts.get('TimeControlled');
103118
if (contract.relativeFilePath.startsWith('legacy_reputation/')) return;
104119
if (contract.relativeFilePath.startsWith('libraries/')) return;
@@ -182,7 +197,7 @@ export class ContractDeployer {
182197

183198
private async initializeAllContracts(): Promise<void> {
184199
console.log('Initializing contracts...');
185-
const contractsToInitialize = ["Augur","CompleteSets","CreateOrder","FillOrder","CancelOrder","Trade","ClaimTradingProceeds","OrdersFetcher","Time"];
200+
const contractsToInitialize = ["CompleteSets","CreateOrder","FillOrder","CancelOrder","Trade","ClaimTradingProceeds","OrdersFetcher","Time"];
186201
const promises: Array<Promise<any>> = [];
187202
for (let contractName of contractsToInitialize) {
188203
promises.push(this.initializeContract(contractName));

tests/conftest.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ def uploadAllContracts(self):
266266
extension = path.splitext(filename)[1]
267267
if extension != '.sol': continue
268268
if name == 'controller': continue
269+
if name == 'Augur': continue
269270
if name == 'Time': continue # In testing and development we swap the Time library for a ControlledTime version which lets us manage block timestamp
270271
contractsToDelegate = ['Orders', 'TradingEscapeHatch', 'Cash']
271272
if name in contractsToDelegate:
@@ -300,7 +301,7 @@ def whitelistTradingContracts(self):
300301
self.contracts['Controller'].addToWhitelist(self.contracts[name].address)
301302

302303
def initializeAllContracts(self):
303-
contractsToInitialize = ['Augur','CompleteSets','CreateOrder','FillOrder','CancelOrder','Trade','ClaimTradingProceeds','OrdersFetcher', 'Time']
304+
contractsToInitialize = ['CompleteSets','CreateOrder','FillOrder','CancelOrder','Trade','ClaimTradingProceeds','OrdersFetcher', 'Time']
304305
for contractName in contractsToInitialize:
305306
if getattr(self.contracts[contractName], "setController", None):
306307
self.contracts[contractName].setController(self.contracts['Controller'].address)
@@ -326,6 +327,13 @@ def approveCentralAuthority(self):
326327
for contractName in contractsToApprove:
327328
self.contracts[contractName].approve(authority.address, 2**254, sender=testerKey)
328329

330+
def uploadAugur(self):
331+
# We have to upload Augur first so it can log when contracts are added to the registry
332+
augur = self.upload("../source/contracts/Augur.sol")
333+
self.contracts["Augur"].setController(self.contracts['Controller'].address)
334+
self.contracts['Controller'].registerContract("Augur".ljust(32, '\x00'), augur.address, garbageBytes20, garbageBytes32)
335+
return augur
336+
329337
def uploadShareToken(self, controllerAddress = None):
330338
controllerAddress = controllerAddress if controllerAddress else self.contracts['Controller'].address
331339
self.ensureShareTokenDependencies()
@@ -426,6 +434,7 @@ def controllerSnapshot(fixture, baseSnapshot):
426434
@pytest.fixture(scope="session")
427435
def augurInitializedSnapshot(fixture, controllerSnapshot):
428436
fixture.resetToSnapshot(controllerSnapshot)
437+
fixture.uploadAugur()
429438
fixture.uploadAllContracts()
430439
fixture.initializeAllContracts()
431440
fixture.whitelistTradingContracts()

0 commit comments

Comments
 (0)