Skip to content

Commit f96a680

Browse files
committed
Add support for deprecated interface
1 parent b709c03 commit f96a680

16 files changed

+348
-64
lines changed

contracts/colony/Colony.sol

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -345,23 +345,43 @@ contract Colony is ColonyStorage, PatriciaTreeProofs, MultiChain {
345345
function installExtension(bytes32 _extensionId, uint256 _version)
346346
public stoppable auth returns (address)
347347
{
348-
address extension = IColonyNetwork(colonyNetworkAddress).installExtension(_extensionId, _version);
349-
return extension;
348+
return IColonyNetwork(colonyNetworkAddress).installExtension(_extensionId, _version);
350349
}
351350

352-
function upgradeExtension(address payable _extension, uint256 _newVersion)
351+
// Deprecated
352+
function upgradeExtension(bytes32 _extensionId, uint256 _newVersion)
353+
public stoppable auth
354+
{
355+
IColonyNetwork(colonyNetworkAddress).upgradeExtension(_extensionId, _newVersion);
356+
}
357+
358+
function upgradeExtension(address _extension, uint256 _newVersion)
353359
public stoppable auth
354360
{
355361
IColonyNetwork(colonyNetworkAddress).upgradeExtension(_extension, _newVersion);
356362
}
357363

358-
function deprecateExtension(address payable _extension, bool _deprecated)
364+
// Deprecated
365+
function deprecateExtension(bytes32 _extensionId, bool _deprecated)
366+
public stoppable auth
367+
{
368+
IColonyNetwork(colonyNetworkAddress).deprecateExtension(_extensionId, _deprecated);
369+
}
370+
371+
function deprecateExtension(address _extension, bool _deprecated)
359372
public stoppable auth
360373
{
361374
IColonyNetwork(colonyNetworkAddress).deprecateExtension(_extension, _deprecated);
362375
}
363376

364-
function uninstallExtension(address payable _extension)
377+
// Deprecated
378+
function uninstallExtension(bytes32 _extensionId)
379+
public stoppable auth
380+
{
381+
IColonyNetwork(colonyNetworkAddress).uninstallExtension(_extensionId);
382+
}
383+
384+
function uninstallExtension(address _extension)
365385
public stoppable auth
366386
{
367387
IColonyNetwork(colonyNetworkAddress).uninstallExtension(_extension);

contracts/colony/IColony.sol

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,21 +250,40 @@ interface IColony is ColonyDataTypes, IRecovery {
250250
/// @return extension The address of the extension installation
251251
function installExtension(bytes32 extensionId, uint256 version) external returns (address extension);
252252

253+
/// @dev DEPRECATED
254+
/// @notice Upgrade an extension in a colony. Secured function to authorised members.
255+
/// @param extensionId keccak256 hash of the extension name, used as an indentifier
256+
/// @param newVersion The version to upgrade to (must be one larger than the current version)
257+
function upgradeExtension(bytes32 extensionId, uint256 newVersion) external;
258+
253259
/// @notice Upgrade an extension in a colony. Secured function to authorised members.
254260
/// @param extension The address of the extension installation
255261
/// @param newVersion The version to upgrade to (must be one larger than the current version)
256-
function upgradeExtension(address payable extension, uint256 newVersion) external;
262+
function upgradeExtension(address extension, uint256 newVersion) external;
263+
264+
/// @dev DEPRECATED
265+
/// @notice Set the deprecation of an extension in a colony. Secured function to authorised members.
266+
/// @param extensionId keccak256 hash of the extension name, used as an indentifier
267+
/// @param deprecated Whether to deprecate the extension or not
268+
function deprecateExtension(bytes32 extensionId, bool deprecated) external;
257269

258270
/// @notice Set the deprecation of an extension in a colony. Secured function to authorised members.
259271
/// @param extension The address of the extension installation
260272
/// @param deprecated Whether to deprecate the extension or not
261-
function deprecateExtension(address payable extension, bool deprecated) external;
273+
function deprecateExtension(address extension, bool deprecated) external;
274+
275+
/// @dev DEPRECATED
276+
/// @notice Uninstall an extension from a colony. Secured function to authorised members.
277+
/// @dev This is a permanent action -- re-installing the extension will deploy a new contract
278+
/// @dev It is recommended to deprecate an extension before uninstalling to allow active objects to be resolved
279+
/// @param extensionId keccak256 hash of the extension name, used as an indentifier
280+
function uninstallExtension(bytes32 extensionId) external;
262281

263282
/// @notice Uninstall an extension from a colony. Secured function to authorised members.
264283
/// @dev This is a permanent action -- re-installing the extension will deploy a new contract
265284
/// @dev It is recommended to deprecate an extension before uninstalling to allow active objects to be resolved
266285
/// @param extension The address of the extension installation
267-
function uninstallExtension(address payable extension) external;
286+
function uninstallExtension(address extension) external;
268287

269288
/// @notice Add a colony domain, and its respective local skill under skill with id `_parentSkillId`.
270289
/// New funding pot is created and associated with the domain here.

contracts/colonyNetwork/ColonyNetworkDataTypes.sol

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,18 +121,38 @@ interface ColonyNetworkDataTypes {
121121
/// @param version The version of the extension
122122
event ExtensionInstalled(bytes32 indexed extensionId, address indexed extension, address indexed colony, uint256 version);
123123

124+
/// @dev DEPRECATED
125+
/// @notice Event logged when an extension is upgraded in a colony
126+
/// @param extensionId The identifier for the extension
127+
/// @param colony The address of the colony
128+
/// @param version The new version of the extension
129+
event ExtensionUpgraded(bytes32 indexed extensionId, address indexed colony, uint256 version);
130+
124131
/// @notice Event logged when an extension is upgraded in a colony
125132
/// @param extension Address of the extension installation
126133
/// @param colony The address of the colony
127134
/// @param version The new version of the extension
128135
event ExtensionUpgraded(address indexed extension, address indexed colony, uint256 version);
129136

137+
/// @dev DEPRECATED
138+
/// @notice Event logged when an extension is (un)deprecated in a colony
139+
/// @param extensionId The identifier for the extension
140+
/// @param colony The address of the colony
141+
/// @param deprecated Whether the extension is deprecated or not
142+
event ExtensionDeprecated(bytes32 indexed extensionId, address indexed colony, bool deprecated);
143+
130144
/// @notice Event logged when an extension is (un)deprecated in a colony
131145
/// @param extension Address of the extension installation
132146
/// @param colony The address of the colony
133147
/// @param deprecated Whether the extension is deprecated or not
134148
event ExtensionDeprecated(address indexed extension, address indexed colony, bool deprecated);
135149

150+
/// @dev DEPRECATED
151+
/// @notice Event logged when an extension is uninstalled from a colony
152+
/// @param extensionId The identifier for the extension
153+
/// @param colony The address of the colony
154+
event ExtensionUninstalled(bytes32 indexed extensionId, address indexed colony);
155+
136156
/// @notice Event logged when an extension is uninstalled from a colony
137157
/// @param extension Address of the extension installation
138158
/// @param colony The address of the colony

contracts/colonyNetwork/ColonyNetworkExtensions.sol

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,18 @@ contract ColonyNetworkExtensions is ColonyNetworkStorage {
6565
return address(extension);
6666
}
6767

68-
function upgradeExtension(address payable _extension, uint256 _newVersion)
68+
// Deprecated
69+
function upgradeExtension(bytes32 _extensionId, uint256 _newVersion)
70+
public
71+
stoppable
72+
{
73+
address extension = migrateToMultiExtension(_extensionId);
74+
upgradeExtension(extension, _newVersion);
75+
76+
emit ExtensionUpgraded(_extensionId, msg.sender, _newVersion);
77+
}
78+
79+
function upgradeExtension(address _extension, uint256 _newVersion)
6980
public
7081
stoppable
7182
calledByColony
@@ -77,15 +88,26 @@ contract ColonyNetworkExtensions is ColonyNetworkStorage {
7788
require(_newVersion == ColonyExtension(_extension).version() + 1, "colony-network-extension-bad-increment");
7889
require(resolvers[extensionId][_newVersion] != address(0x0), "colony-network-extension-bad-version");
7990

80-
EtherRouter(_extension).setResolver(resolvers[extensionId][_newVersion]);
91+
EtherRouter(payable(_extension)).setResolver(resolvers[extensionId][_newVersion]);
8192
ColonyExtension(_extension).finishUpgrade();
8293

8394
assert(ColonyExtension(_extension).version() == _newVersion);
8495

8596
emit ExtensionUpgraded(_extension, msg.sender, _newVersion);
8697
}
8798

88-
function deprecateExtension(address payable _extension, bool _deprecated)
99+
// Deprecated
100+
function deprecateExtension(bytes32 _extensionId, bool _deprecated)
101+
public
102+
stoppable
103+
{
104+
address extension = migrateToMultiExtension(_extensionId);
105+
deprecateExtension(extension, _deprecated);
106+
107+
emit ExtensionDeprecated(_extensionId, msg.sender, _deprecated);
108+
}
109+
110+
function deprecateExtension(address _extension, bool _deprecated)
89111
public
90112
stoppable
91113
calledByColony
@@ -95,7 +117,18 @@ contract ColonyNetworkExtensions is ColonyNetworkStorage {
95117
emit ExtensionDeprecated(_extension, msg.sender, _deprecated);
96118
}
97119

98-
function uninstallExtension(address payable _extension)
120+
// Deprecated
121+
function uninstallExtension(bytes32 _extensionId)
122+
public
123+
stoppable
124+
{
125+
address extension = migrateToMultiExtension(_extensionId);
126+
uninstallExtension(extension);
127+
128+
emit ExtensionUninstalled(_extensionId, msg.sender);
129+
}
130+
131+
function uninstallExtension(address _extension)
99132
public
100133
stoppable
101134
calledByColony
@@ -150,4 +183,12 @@ contract ColonyNetworkExtensions is ColonyNetworkStorage {
150183
address extension = Resolver(_resolver).lookup(VERSION_SIG);
151184
return ColonyExtension(extension).version();
152185
}
186+
187+
function migrateToMultiExtension(bytes32 _extensionId) internal returns (address) {
188+
address extension = installations[_extensionId][msg.sender];
189+
require(extension != address(0x0), "colony-network-extension-not-installed");
190+
191+
multiInstallations[extension] = msg.sender;
192+
return extension;
193+
}
153194
}

contracts/colonyNetwork/IColonyNetwork.sol

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,19 +319,36 @@ interface IColonyNetwork is ColonyNetworkDataTypes, IRecovery {
319319
/// @return extension The address of the extension installation
320320
function installExtension(bytes32 extensionId, uint256 version) external returns (address extension);
321321

322+
/// @dev DEPRECATED
323+
/// @notice Upgrade an extension in a colony. Can only be called by a Colony.
324+
/// @param extensionId keccak256 hash of the extension name, used as an indentifier
325+
/// @param newVersion Version of the extension to upgrade to (must be one greater than current)
326+
function upgradeExtension(bytes32 extensionId, uint256 newVersion) external;
327+
322328
/// @notice Upgrade an extension in a colony. Can only be called by a Colony.
323329
/// @param extension Address of the extension installation
324330
/// @param newVersion Version of the extension to upgrade to (must be one greater than current)
325-
function upgradeExtension(address payable extension, uint256 newVersion) external;
331+
function upgradeExtension(address extension, uint256 newVersion) external;
332+
333+
/// @dev DEPRECATED
334+
/// @notice Set the deprecation of an extension in a colony. Can only be called by a Colony.
335+
/// @param extensionId keccak256 hash of the extension name, used as an indentifier
336+
/// @param deprecated Whether to deprecate the extension or not
337+
function deprecateExtension(bytes32 extensionId, bool deprecated) external;
326338

327339
/// @notice Set the deprecation of an extension in a colony. Can only be called by a Colony.
328340
/// @param extension Address of the extension installation
329341
/// @param deprecated Whether to deprecate the extension or not
330-
function deprecateExtension(address payable extension, bool deprecated) external;
342+
function deprecateExtension(address extension, bool deprecated) external;
343+
344+
/// @dev DEPRECATED
345+
/// @notice Uninstall an extension in a colony. Can only be called by a Colony.
346+
/// @param extensionId keccak256 hash of the extension name, used as an indentifier
347+
function uninstallExtension(bytes32 extensionId) external;
331348

332349
/// @notice Uninstall an extension in a colony. Can only be called by a Colony.
333350
/// @param extension Address of the extension installation
334-
function uninstallExtension(address payable extension) external;
351+
function uninstallExtension(address extension) external;
335352

336353
/// @notice Get an extension's resolver.
337354
/// @param extensionId keccak256 hash of the extension name, used as an indentifier

docs/_Interface_IColony.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,19 @@ Set the deprecation of an extension in a colony. Secured function to authorised
261261
|deprecated|bool|Whether to deprecate the extension or not
262262

263263

264+
### `deprecateExtension`
265+
266+
Set the deprecation of an extension in a colony. Secured function to authorised members.
267+
268+
269+
**Parameters**
270+
271+
|Name|Type|Description|
272+
|---|---|---|
273+
|extensionId|bytes32|keccak256 hash of the extension name, used as an indentifier
274+
|deprecated|bool|Whether to deprecate the extension or not
275+
276+
264277
### `editColony`
265278

266279
Called to change the metadata associated with a colony. Expected to be a IPFS hash of a JSON blob, but not enforced to any degree by the contracts
@@ -1761,6 +1774,19 @@ Uninstall an extension from a colony. Secured function to authorised members.
17611774
|extension|address|The address of the extension installation
17621775

17631776

1777+
### `uninstallExtension`
1778+
1779+
Uninstall an extension from a colony. Secured function to authorised members.
1780+
1781+
*Note: This is a permanent action -- re-installing the extension will deploy a new contract*
1782+
1783+
**Parameters**
1784+
1785+
|Name|Type|Description|
1786+
|---|---|---|
1787+
|extensionId|bytes32|keccak256 hash of the extension name, used as an indentifier
1788+
1789+
17641790
### `unlockToken`
17651791

17661792
unlock the native colony token, if possible
@@ -1832,6 +1858,19 @@ Upgrade an extension in a colony. Secured function to authorised members.
18321858
|newVersion|uint256|The version to upgrade to (must be one larger than the current version)
18331859

18341860

1861+
### `upgradeExtension`
1862+
1863+
Upgrade an extension in a colony. Secured function to authorised members.
1864+
1865+
1866+
**Parameters**
1867+
1868+
|Name|Type|Description|
1869+
|---|---|---|
1870+
|extensionId|bytes32|keccak256 hash of the extension name, used as an indentifier
1871+
|newVersion|uint256|The version to upgrade to (must be one larger than the current version)
1872+
1873+
18351874
### `userCanSetRoles`
18361875

18371876
Check whether a given user can modify roles in the target domain `_childDomainId`. Mostly a convenience function to provide a uniform interface for extension contracts validating permissions

docs/_Interface_IColonyNetwork.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,19 @@ Set the deprecation of an extension in a colony. Can only be called by a Colony.
234234
|deprecated|bool|Whether to deprecate the extension or not
235235

236236

237+
### `deprecateExtension`
238+
239+
Set the deprecation of an extension in a colony. Can only be called by a Colony.
240+
241+
242+
**Parameters**
243+
244+
|Name|Type|Description|
245+
|---|---|---|
246+
|extensionId|bytes32|keccak256 hash of the extension name, used as an indentifier
247+
|deprecated|bool|Whether to deprecate the extension or not
248+
249+
237250
### `deprecateSkill`
238251

239252
Mark a global skill as deprecated which stops new tasks and payments from using it.
@@ -959,6 +972,18 @@ Uninstall an extension in a colony. Can only be called by a Colony.
959972
|extension|address|Address of the extension installation
960973

961974

975+
### `uninstallExtension`
976+
977+
Uninstall an extension in a colony. Can only be called by a Colony.
978+
979+
980+
**Parameters**
981+
982+
|Name|Type|Description|
983+
|---|---|---|
984+
|extensionId|bytes32|keccak256 hash of the extension name, used as an indentifier
985+
986+
962987
### `unstakeForMining`
963988

964989
Unstake CLNY currently staked for reputation mining.
@@ -1005,4 +1030,17 @@ Upgrade an extension in a colony. Can only be called by a Colony.
10051030
|Name|Type|Description|
10061031
|---|---|---|
10071032
|extension|address|Address of the extension installation
1033+
|newVersion|uint256|Version of the extension to upgrade to (must be one greater than current)
1034+
1035+
1036+
### `upgradeExtension`
1037+
1038+
Upgrade an extension in a colony. Can only be called by a Colony.
1039+
1040+
1041+
**Parameters**
1042+
1043+
|Name|Type|Description|
1044+
|---|---|---|
1045+
|extensionId|bytes32|keccak256 hash of the extension name, used as an indentifier
10081046
|newVersion|uint256|Version of the extension to upgrade to (must be one greater than current)

test/contracts-network/colony-arbitrary-transactions.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { ethers } from "ethers";
66
import { soliditySha3 } from "web3-utils";
77

88
import { UINT256_MAX, WAD } from "../../helpers/constants";
9-
import { checkErrorRevert, encodeTxData } from "../../helpers/test-helper";
9+
import { checkErrorRevert, encodeTxData, getExtensionAddressFromTx } from "../../helpers/test-helper";
1010
import { setupRandomColony, fundColonyWithTokens } from "../../helpers/test-data-generator";
1111

1212
const { expect } = chai;
@@ -159,9 +159,9 @@ contract("Colony Arbitrary Transactions", (accounts) => {
159159

160160
it("should not be able to make arbitrary transactions to the colony's own extensions", async () => {
161161
const COIN_MACHINE = soliditySha3("CoinMachine");
162-
await colony.installExtension(COIN_MACHINE, 2);
162+
const tx = await colony.installExtension(COIN_MACHINE, 2);
163163

164-
const coinMachineAddress = await colonyNetwork.getExtensionInstallation(COIN_MACHINE, colony.address);
164+
const coinMachineAddress = getExtensionAddressFromTx(tx);
165165
const coinMachine = await CoinMachine.at(coinMachineAddress);
166166
await coinMachine.initialise(token.address, ethers.constants.AddressZero, 60 * 60, 10, WAD, WAD, WAD, WAD, ADDRESS_ZERO);
167167
await token.mint(coinMachine.address, WAD);

0 commit comments

Comments
 (0)