Skip to content

Commit

Permalink
Add support for deprecated interface
Browse files Browse the repository at this point in the history
  • Loading branch information
kronosapiens committed Jun 29, 2021
1 parent b709c03 commit d96e4b8
Show file tree
Hide file tree
Showing 8 changed files with 283 additions and 17 deletions.
30 changes: 25 additions & 5 deletions contracts/colony/Colony.sol
Original file line number Diff line number Diff line change
Expand Up @@ -345,23 +345,43 @@ contract Colony is ColonyStorage, PatriciaTreeProofs, MultiChain {
function installExtension(bytes32 _extensionId, uint256 _version)
public stoppable auth returns (address)
{
address extension = IColonyNetwork(colonyNetworkAddress).installExtension(_extensionId, _version);
return extension;
return IColonyNetwork(colonyNetworkAddress).installExtension(_extensionId, _version);
}

function upgradeExtension(address payable _extension, uint256 _newVersion)
// Deprecated
function upgradeExtension(bytes32 _extensionId, uint256 _newVersion)
public stoppable auth
{
IColonyNetwork(colonyNetworkAddress).upgradeExtension(_extensionId, _newVersion);
}

function upgradeExtension(address _extension, uint256 _newVersion)
public stoppable auth
{
IColonyNetwork(colonyNetworkAddress).upgradeExtension(_extension, _newVersion);
}

function deprecateExtension(address payable _extension, bool _deprecated)
// Deprecated
function deprecateExtension(bytes32 _extensionId, bool _deprecated)
public stoppable auth
{
IColonyNetwork(colonyNetworkAddress).deprecateExtension(_extensionId, _deprecated);
}

function deprecateExtension(address _extension, bool _deprecated)
public stoppable auth
{
IColonyNetwork(colonyNetworkAddress).deprecateExtension(_extension, _deprecated);
}

function uninstallExtension(address payable _extension)
// Deprecated
function uninstallExtension(bytes32 _extensionId)
public stoppable auth
{
IColonyNetwork(colonyNetworkAddress).uninstallExtension(_extensionId);
}

function uninstallExtension(address _extension)
public stoppable auth
{
IColonyNetwork(colonyNetworkAddress).uninstallExtension(_extension);
Expand Down
25 changes: 22 additions & 3 deletions contracts/colony/IColony.sol
Original file line number Diff line number Diff line change
Expand Up @@ -250,21 +250,40 @@ interface IColony is ColonyDataTypes, IRecovery {
/// @return extension The address of the extension installation
function installExtension(bytes32 extensionId, uint256 version) external returns (address extension);

/// @dev DEPRECATED
/// @notice Upgrade an extension in a colony. Secured function to authorised members.
/// @param extensionId keccak256 hash of the extension name, used as an indentifier
/// @param newVersion The version to upgrade to (must be one larger than the current version)
function upgradeExtension(bytes32 extensionId, uint256 newVersion) external;

/// @notice Upgrade an extension in a colony. Secured function to authorised members.
/// @param extension The address of the extension installation
/// @param newVersion The version to upgrade to (must be one larger than the current version)
function upgradeExtension(address payable extension, uint256 newVersion) external;
function upgradeExtension(address extension, uint256 newVersion) external;

/// @dev DEPRECATED
/// @notice Set the deprecation of an extension in a colony. Secured function to authorised members.
/// @param extensionId keccak256 hash of the extension name, used as an indentifier
/// @param deprecated Whether to deprecate the extension or not
function deprecateExtension(bytes32 extensionId, bool deprecated) external;

/// @notice Set the deprecation of an extension in a colony. Secured function to authorised members.
/// @param extension The address of the extension installation
/// @param deprecated Whether to deprecate the extension or not
function deprecateExtension(address payable extension, bool deprecated) external;
function deprecateExtension(address extension, bool deprecated) external;

/// @dev DEPRECATED
/// @notice Uninstall an extension from a colony. Secured function to authorised members.
/// @dev This is a permanent action -- re-installing the extension will deploy a new contract
/// @dev It is recommended to deprecate an extension before uninstalling to allow active objects to be resolved
/// @param extensionId keccak256 hash of the extension name, used as an indentifier
function uninstallExtension(bytes32 extensionId) external;

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

/// @notice Add a colony domain, and its respective local skill under skill with id `_parentSkillId`.
/// New funding pot is created and associated with the domain here.
Expand Down
20 changes: 20 additions & 0 deletions contracts/colonyNetwork/ColonyNetworkDataTypes.sol
Original file line number Diff line number Diff line change
Expand Up @@ -121,18 +121,38 @@ interface ColonyNetworkDataTypes {
/// @param version The version of the extension
event ExtensionInstalled(bytes32 indexed extensionId, address indexed extension, address indexed colony, uint256 version);

/// @dev DEPRECATED
/// @notice Event logged when an extension is upgraded in a colony
/// @param extensionId The identifier for the extension
/// @param colony The address of the colony
/// @param version The new version of the extension
event ExtensionUpgraded(bytes32 indexed extensionId, address indexed colony, uint256 version);

/// @notice Event logged when an extension is upgraded in a colony
/// @param extension Address of the extension installation
/// @param colony The address of the colony
/// @param version The new version of the extension
event ExtensionUpgraded(address indexed extension, address indexed colony, uint256 version);

/// @dev DEPRECATED
/// @notice Event logged when an extension is (un)deprecated in a colony
/// @param extensionId The identifier for the extension
/// @param colony The address of the colony
/// @param deprecated Whether the extension is deprecated or not
event ExtensionDeprecated(bytes32 indexed extensionId, address indexed colony, bool deprecated);

/// @notice Event logged when an extension is (un)deprecated in a colony
/// @param extension Address of the extension installation
/// @param colony The address of the colony
/// @param deprecated Whether the extension is deprecated or not
event ExtensionDeprecated(address indexed extension, address indexed colony, bool deprecated);

/// @dev DEPRECATED
/// @notice Event logged when an extension is uninstalled from a colony
/// @param extensionId The identifier for the extension
/// @param colony The address of the colony
event ExtensionUninstalled(bytes32 indexed extensionId, address indexed colony);

/// @notice Event logged when an extension is uninstalled from a colony
/// @param extension Address of the extension installation
/// @param colony The address of the colony
Expand Down
49 changes: 45 additions & 4 deletions contracts/colonyNetwork/ColonyNetworkExtensions.sol
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,18 @@ contract ColonyNetworkExtensions is ColonyNetworkStorage {
return address(extension);
}

function upgradeExtension(address payable _extension, uint256 _newVersion)
// Deprecated
function upgradeExtension(bytes32 _extensionId, uint256 _newVersion)
public
stoppable
{
address extension = migrateToMultiExtension(_extensionId);
upgradeExtension(extension, _newVersion);

emit ExtensionUpgraded(_extensionId, msg.sender, _newVersion);
}

function upgradeExtension(address _extension, uint256 _newVersion)
public
stoppable
calledByColony
Expand All @@ -77,15 +88,26 @@ contract ColonyNetworkExtensions is ColonyNetworkStorage {
require(_newVersion == ColonyExtension(_extension).version() + 1, "colony-network-extension-bad-increment");
require(resolvers[extensionId][_newVersion] != address(0x0), "colony-network-extension-bad-version");

EtherRouter(_extension).setResolver(resolvers[extensionId][_newVersion]);
EtherRouter(payable(_extension)).setResolver(resolvers[extensionId][_newVersion]);
ColonyExtension(_extension).finishUpgrade();

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

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

function deprecateExtension(address payable _extension, bool _deprecated)
// Deprecated
function deprecateExtension(bytes32 _extensionId, bool _deprecated)
public
stoppable
{
address extension = migrateToMultiExtension(_extensionId);
deprecateExtension(extension, _deprecated);

emit ExtensionDeprecated(_extensionId, msg.sender, _deprecated);
}

function deprecateExtension(address _extension, bool _deprecated)
public
stoppable
calledByColony
Expand All @@ -95,7 +117,18 @@ contract ColonyNetworkExtensions is ColonyNetworkStorage {
emit ExtensionDeprecated(_extension, msg.sender, _deprecated);
}

function uninstallExtension(address payable _extension)
// Deprecated
function uninstallExtension(bytes32 _extensionId)
public
stoppable
{
address extension = migrateToMultiExtension(_extensionId);
uninstallExtension(extension);

emit ExtensionUninstalled(_extensionId, msg.sender);
}

function uninstallExtension(address _extension)
public
stoppable
calledByColony
Expand Down Expand Up @@ -150,4 +183,12 @@ contract ColonyNetworkExtensions is ColonyNetworkStorage {
address extension = Resolver(_resolver).lookup(VERSION_SIG);
return ColonyExtension(extension).version();
}

function migrateToMultiExtension(bytes32 _extensionId) internal returns (address) {
address extension = installations[_extensionId][msg.sender];
require(extension != address(0x0), "colony-network-extension-not-installed");

multiInstallations[extension] = msg.sender;
return extension;
}
}
23 changes: 20 additions & 3 deletions contracts/colonyNetwork/IColonyNetwork.sol
Original file line number Diff line number Diff line change
Expand Up @@ -319,19 +319,36 @@ interface IColonyNetwork is ColonyNetworkDataTypes, IRecovery {
/// @return extension The address of the extension installation
function installExtension(bytes32 extensionId, uint256 version) external returns (address extension);

/// @dev DEPRECATED
/// @notice Upgrade an extension in a colony. Can only be called by a Colony.
/// @param extensionId keccak256 hash of the extension name, used as an indentifier
/// @param newVersion Version of the extension to upgrade to (must be one greater than current)
function upgradeExtension(bytes32 extensionId, uint256 newVersion) external;

/// @notice Upgrade an extension in a colony. Can only be called by a Colony.
/// @param extension Address of the extension installation
/// @param newVersion Version of the extension to upgrade to (must be one greater than current)
function upgradeExtension(address payable extension, uint256 newVersion) external;
function upgradeExtension(address extension, uint256 newVersion) external;

/// @dev DEPRECATED
/// @notice Set the deprecation of an extension in a colony. Can only be called by a Colony.
/// @param extensionId keccak256 hash of the extension name, used as an indentifier
/// @param deprecated Whether to deprecate the extension or not
function deprecateExtension(bytes32 extensionId, bool deprecated) external;

/// @notice Set the deprecation of an extension in a colony. Can only be called by a Colony.
/// @param extension Address of the extension installation
/// @param deprecated Whether to deprecate the extension or not
function deprecateExtension(address payable extension, bool deprecated) external;
function deprecateExtension(address extension, bool deprecated) external;

/// @dev DEPRECATED
/// @notice Uninstall an extension in a colony. Can only be called by a Colony.
/// @param extensionId keccak256 hash of the extension name, used as an indentifier
function uninstallExtension(bytes32 extensionId) external;

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

/// @notice Get an extension's resolver.
/// @param extensionId keccak256 hash of the extension name, used as an indentifier
Expand Down
39 changes: 39 additions & 0 deletions docs/_Interface_IColony.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,19 @@ Set the deprecation of an extension in a colony. Secured function to authorised
|deprecated|bool|Whether to deprecate the extension or not


### `deprecateExtension`

Set the deprecation of an extension in a colony. Secured function to authorised members.


**Parameters**

|Name|Type|Description|
|---|---|---|
|extensionId|bytes32|keccak256 hash of the extension name, used as an indentifier
|deprecated|bool|Whether to deprecate the extension or not


### `editColony`

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
Expand Down Expand Up @@ -1761,6 +1774,19 @@ Uninstall an extension from a colony. Secured function to authorised members.
|extension|address|The address of the extension installation


### `uninstallExtension`

Uninstall an extension from a colony. Secured function to authorised members.

*Note: This is a permanent action -- re-installing the extension will deploy a new contract*

**Parameters**

|Name|Type|Description|
|---|---|---|
|extensionId|bytes32|keccak256 hash of the extension name, used as an indentifier


### `unlockToken`

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


### `upgradeExtension`

Upgrade an extension in a colony. Secured function to authorised members.


**Parameters**

|Name|Type|Description|
|---|---|---|
|extensionId|bytes32|keccak256 hash of the extension name, used as an indentifier
|newVersion|uint256|The version to upgrade to (must be one larger than the current version)


### `userCanSetRoles`

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
Expand Down
38 changes: 38 additions & 0 deletions docs/_Interface_IColonyNetwork.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,19 @@ Set the deprecation of an extension in a colony. Can only be called by a Colony.
|deprecated|bool|Whether to deprecate the extension or not


### `deprecateExtension`

Set the deprecation of an extension in a colony. Can only be called by a Colony.


**Parameters**

|Name|Type|Description|
|---|---|---|
|extensionId|bytes32|keccak256 hash of the extension name, used as an indentifier
|deprecated|bool|Whether to deprecate the extension or not


### `deprecateSkill`

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


### `uninstallExtension`

Uninstall an extension in a colony. Can only be called by a Colony.


**Parameters**

|Name|Type|Description|
|---|---|---|
|extensionId|bytes32|keccak256 hash of the extension name, used as an indentifier


### `unstakeForMining`

Unstake CLNY currently staked for reputation mining.
Expand Down Expand Up @@ -1005,4 +1030,17 @@ Upgrade an extension in a colony. Can only be called by a Colony.
|Name|Type|Description|
|---|---|---|
|extension|address|Address of the extension installation
|newVersion|uint256|Version of the extension to upgrade to (must be one greater than current)


### `upgradeExtension`

Upgrade an extension in a colony. Can only be called by a Colony.


**Parameters**

|Name|Type|Description|
|---|---|---|
|extensionId|bytes32|keccak256 hash of the extension name, used as an indentifier
|newVersion|uint256|Version of the extension to upgrade to (must be one greater than current)
Loading

0 comments on commit d96e4b8

Please sign in to comment.