Skip to content

Commit ccda3dd

Browse files
authored
Merge pull request #636 from JoinColony/maint/bump-version
Bump Colony version to 2
2 parents a4a8f74 + 5954725 commit ccda3dd

File tree

7 files changed

+35
-11
lines changed

7 files changed

+35
-11
lines changed

contracts/Colony.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ contract Colony is ColonyStorage, PatriciaTreeProofs {
2626

2727
// This function, exactly as defined, is used in build scripts. Take care when updating.
2828
// Version number should be upped with every change in Colony or its dependency contracts or libraries.
29-
function version() public pure returns (uint256 colonyVersion) { return 1; }
29+
function version() public pure returns (uint256 colonyVersion) { return 2; }
3030

3131
function setRootRole(address _user, bool _setTo) public stoppable auth {
3232
ColonyAuthority(address(authority)).setUserRole(_user, uint8(ColonyRole.Root), _setTo);

contracts/ColonyNetwork.sol

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,13 +182,14 @@ contract ColonyNetwork is ColonyNetworkStorage {
182182
emit ColonyVersionAdded(_version, _resolver);
183183
}
184184

185-
function initialise(address _resolver) public
185+
function initialise(address _resolver, uint256 _version) public
186186
stoppable
187187
auth
188188
{
189189
require(currentColonyVersion == 0, "colony-network-already-initialised");
190-
colonyVersionResolver[1] = _resolver;
191-
currentColonyVersion = 1;
190+
require(_version > 0, "colony-network-invalid-version");
191+
colonyVersionResolver[_version] = _resolver;
192+
currentColonyVersion = _version;
192193

193194
emit ColonyNetworkInitialised(_resolver);
194195
}

contracts/IColonyNetwork.sol

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,9 @@ contract IColonyNetwork is ColonyNetworkDataTypes, IRecovery {
142142

143143
/// @notice Initialises the colony network by setting the first Colony version resolver to `_resolver` address.
144144
/// @dev Only allowed to be run once, by the Network owner before any Colony versions are added.
145-
/// @param _resolver Address of the resolver for Colony contract version 1
146-
function initialise(address _resolver) public;
145+
/// @param _resolver Address of the resolver for Colony contract
146+
/// @param _version Version of the Colony contract the resolver represents
147+
function initialise(address _resolver, uint256 _version) public;
147148

148149
/// @notice Get a colony address by its Id in the network.
149150
/// @param _id Id of the colony to get

docs/_Interface_IColonyNetwork.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,8 @@ Initialises the colony network by setting the first Colony version resolver to `
428428

429429
|Name|Type|Description|
430430
|---|---|---|
431-
|_resolver|address|Address of the resolver for Colony contract version 1
431+
|_resolver|address|Address of the resolver for Colony contract
432+
|_version|uint256|Version of the Colony contract the resolver represents
432433

433434

434435
### `initialiseReputationMining`

helpers/test-data-generator.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,8 @@ export async function setupColonyNetwork() {
344344

345345
const colonyNetwork = await IColonyNetwork.at(etherRouter.address);
346346
await setupColonyVersionResolver(colonyTemplate, colonyTask, colonyPayment, colonyFunding, contractRecovery, resolver);
347-
await colonyNetwork.initialise(resolver.address);
347+
const version = await colonyTemplate.version();
348+
await colonyNetwork.initialise(resolver.address, version);
348349
// Jumping through these hoops to avoid the need to rewire ReputationMiningCycleResolver.
349350
const deployedColonyNetwork = await IColonyNetwork.at(EtherRouter.address);
350351
const reputationMiningCycleResolverAddress = await deployedColonyNetwork.getMiningResolver();

migrations/4_setup_colony_version_resolver.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ module.exports = async function(deployer) {
2828

2929
// Register the new Colony contract version with the newly setup Resolver
3030
await setupColonyVersionResolver(colony, colonyTask, colonyPayment, colonyFunding, contractRecovery, resolver);
31-
await colonyNetwork.initialise(resolver.address);
31+
await colonyNetwork.initialise(resolver.address, version);
3232

3333
console.log("### Colony version", version.toString(), "set to Resolver", resolver.address);
3434
};

test/contracts-network/colony-network.js

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ contract("Colony Network", accounts => {
4848

4949
it("should have the correct current Colony version set", async () => {
5050
const currentColonyVersion = await colonyNetwork.getCurrentColonyVersion();
51-
expect(currentColonyVersion).to.eq.BN(1);
51+
expect(currentColonyVersion).to.eq.BN(2);
5252
});
5353

5454
it("should have the Resolver for current Colony version set", async () => {
@@ -80,7 +80,7 @@ contract("Colony Network", accounts => {
8080
});
8181

8282
it("should not be able to initialise network twice", async () => {
83-
await checkErrorRevert(colonyNetwork.initialise("0xDde1400C69752A6596a7B2C1f2420Fb9A71c1FDA"), "colony-network-already-initialised");
83+
await checkErrorRevert(colonyNetwork.initialise("0xDde1400C69752A6596a7B2C1f2420Fb9A71c1FDA", 3), "colony-network-already-initialised");
8484
});
8585

8686
it("should not be able to create a colony if the network is not initialised", async () => {
@@ -94,6 +94,26 @@ contract("Colony Network", accounts => {
9494
"colony-network-not-initialised-cannot-create-colony"
9595
);
9696
});
97+
98+
it("should not be able to initialise the network with colony version number 0", async () => {
99+
const resolverColonyNetworkDeployed = await Resolver.deployed();
100+
const etherRouter = await EtherRouter.new();
101+
await etherRouter.setResolver(resolverColonyNetworkDeployed.address);
102+
const colonyNetworkNew = await IColonyNetwork.at(etherRouter.address);
103+
104+
await checkErrorRevert(colonyNetworkNew.initialise("0xDde1400C69752A6596a7B2C1f2420Fb9A71c1FDA", 0), "colony-network-invalid-version");
105+
});
106+
107+
it("should be able to initialise the network with any colony version number greater than 0", async () => {
108+
const resolverColonyNetworkDeployed = await Resolver.deployed();
109+
const etherRouter = await EtherRouter.new();
110+
await etherRouter.setResolver(resolverColonyNetworkDeployed.address);
111+
const colonyNetworkNew = await IColonyNetwork.at(etherRouter.address);
112+
113+
await colonyNetworkNew.initialise("0xDde1400C69752A6596a7B2C1f2420Fb9A71c1FDA", 79);
114+
const currentColonyVersion = await colonyNetworkNew.getCurrentColonyVersion();
115+
expect(currentColonyVersion).to.eq.BN(79);
116+
});
97117
});
98118

99119
describe("when managing the mining process", () => {

0 commit comments

Comments
 (0)