Skip to content

Commit

Permalink
Deprecate makeArbitraryTransactions
Browse files Browse the repository at this point in the history
  • Loading branch information
kronosapiens committed Oct 31, 2024
1 parent 1511692 commit 7a82029
Show file tree
Hide file tree
Showing 11 changed files with 61 additions and 171 deletions.
28 changes: 2 additions & 26 deletions contracts/colony/ColonyArbitraryTransaction.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,34 +34,10 @@ contract ColonyArbitraryTransaction is ColonyStorage {
bytes4 constant BURN_SIG = bytes4(keccak256("burn(uint256)"));
bytes4 constant BURN_GUY_SIG = bytes4(keccak256("burn(address,uint256)"));

function makeArbitraryTransactions(
address[] memory _targets,
bytes[] memory _actions,
bool _strict
) public stoppable auth returns (bool) {
require(_targets.length == _actions.length, "colony-targets-and-actions-length-mismatch");
for (uint256 i; i < _targets.length; i += 1) {
bool success = true;
// slither-disable-next-line unused-return
try this.makeSingleArbitraryTransaction(_targets[i], _actions[i]) returns (bool ret) {
if (_strict) {
success = ret;
}
} catch Error(string memory _err) {
// We failed in a require, which is only okay if we're not in strict mode
if (_strict) {
revert(_err);
}
}
require(success, "colony-arbitrary-transaction-failed");
}
return true;
}

function makeSingleArbitraryTransaction(
function makeArbitraryTransaction(
address _to,
bytes memory _action
) external stoppable self returns (bool) {
) public stoppable auth returns (bool) {
// Prevent transactions to network contracts
require(_to != address(this), "colony-cannot-target-self");
require(_to != colonyNetworkAddress, "colony-cannot-target-network");
Expand Down
4 changes: 2 additions & 2 deletions contracts/colony/ColonyAuthority.sol
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ contract ColonyAuthority is CommonAuthority {
addRoleCapability(ROOT_ROLE, "upgradeExtension(bytes32,uint256)");
addRoleCapability(ROOT_ROLE, "deprecateExtension(bytes32,bool)");
addRoleCapability(ROOT_ROLE, "uninstallExtension(bytes32)");
addRoleCapability(ROOT_ROLE, "makeArbitraryTransaction(address,bytes)"); // Deprecated
addRoleCapability(ROOT_ROLE, "makeArbitraryTransaction(address,bytes)");
addRoleCapability(ROOT_ROLE, "emitDomainReputationReward(uint256,address,int256)");
addRoleCapability(ROOT_ROLE, "emitSkillReputationReward(uint256,address,int256)");
addRoleCapability(ARBITRATION_ROLE, "transferStake(uint256,uint256,address,address,uint256,uint256,address)");
Expand All @@ -116,7 +116,7 @@ contract ColonyAuthority is CommonAuthority {
addRoleCapability(FUNDING_ROLE, "moveFundsBetweenPots(uint256,uint256,uint256,uint256,uint256,uint256,uint256,uint256,address)");

// Added in colony v8 (ebony-lwss)
addRoleCapability(ROOT_ROLE, "makeArbitraryTransactions(address[],bytes[],bool)");
addRoleCapability(ROOT_ROLE, "makeArbitraryTransactions(address[],bytes[],bool)"); // Deprecated
addRoleCapability(ROOT_ROLE, "setDefaultGlobalClaimDelay(uint256)");
addRoleCapability(ARBITRATION_ROLE, "setExpenditureMetadata(uint256,uint256,uint256,string)");

Expand Down
17 changes: 2 additions & 15 deletions contracts/colony/IColony.sol
Original file line number Diff line number Diff line change
Expand Up @@ -51,24 +51,11 @@ interface IColony is IDSAuth, ColonyDataTypes, IRecovery, IBasicMetaTransaction,
/// @return tokenAddress Address of the token contract
function getToken() external view returns (address tokenAddress);

/// @notice Execute arbitrary transactions on behalf of the Colony in series
/// @param _targets Array of addressed to be targeted
/// @param _actions Array of Bytes arrays encoding the function calls and arguments
/// @param _strict Boolean indicating whether if one transaction fails, the whole call to this function should fail.
/// @return success Boolean indicating whether the transactions succeeded
function makeArbitraryTransactions(
address[] memory _targets,
bytes[] memory _actions,
bool _strict
) external returns (bool success);

/// @notice Executes a single arbitrary transaction
/// @dev Only callable by the colony itself. If you wish to use this functionality, you should
/// use the makeAbitraryTransactions function
/// @notice Executes an arbitrary transaction
/// @param _target Contract to receive the function call
/// @param _action Bytes array encoding the function call and arguments
/// @return success Boolean indicating whether the transactions succeeded
function makeSingleArbitraryTransaction(
function makeArbitraryTransaction(
address _target,
bytes memory _action
) external returns (bool success);
Expand Down
28 changes: 4 additions & 24 deletions docs/interfaces/icolony.md
Original file line number Diff line number Diff line change
Expand Up @@ -1049,18 +1049,17 @@ Lock the colony's token. Can only be called by a network-managed extension.
|---|---|---|
|timesLocked|uint256|The amount of times the token was locked

### `makeArbitraryTransactions(address[] memory _targets, bytes[] memory _actions, bool _strict):bool success`
### `makeArbitraryTransaction(address _target, bytes memory _action):bool success`

Execute arbitrary transactions on behalf of the Colony in series
Executes an arbitrary transaction


**Parameters**

|Name|Type|Description|
|---|---|---|
|_targets|address[]|Array of addressed to be targeted
|_actions|bytes[]|Array of Bytes arrays encoding the function calls and arguments
|_strict|bool|Boolean indicating whether if one transaction fails, the whole call to this function should fail.
|_target|address|Contract to receive the function call
|_action|bytes|Bytes array encoding the function call and arguments

**Return Parameters**

Expand All @@ -1087,25 +1086,6 @@ Add a new expenditure in the colony. Secured function to authorised members.
|---|---|---|
|expenditureId|uint256|Identifier of the newly created expenditure

### `makeSingleArbitraryTransaction(address _target, bytes memory _action):bool success`

Executes a single arbitrary transaction

*Note: Only callable by the colony itself. If you wish to use this functionality, you should use the makeAbitraryTransactions function*

**Parameters**

|Name|Type|Description|
|---|---|---|
|_target|address|Contract to receive the function call
|_action|bytes|Bytes array encoding the function call and arguments

**Return Parameters**

|Name|Type|Description|
|---|---|---|
|success|bool|Boolean indicating whether the transactions succeeded

### `mintTokens(uint256 _wad)`

Mint `_wad` amount of colony tokens. Secured function to authorised members.
Expand Down
28 changes: 4 additions & 24 deletions docs/interfaces/imetacolony.md
Original file line number Diff line number Diff line change
Expand Up @@ -1087,18 +1087,17 @@ Lock the colony's token. Can only be called by a network-managed extension.
|---|---|---|
|timesLocked|uint256|The amount of times the token was locked

### `makeArbitraryTransactions(address[] memory _targets, bytes[] memory _actions, bool _strict):bool success`
### `makeArbitraryTransaction(address _target, bytes memory _action):bool success`

Execute arbitrary transactions on behalf of the Colony in series
Executes an arbitrary transaction


**Parameters**

|Name|Type|Description|
|---|---|---|
|_targets|address[]|Array of addressed to be targeted
|_actions|bytes[]|Array of Bytes arrays encoding the function calls and arguments
|_strict|bool|Boolean indicating whether if one transaction fails, the whole call to this function should fail.
|_target|address|Contract to receive the function call
|_action|bytes|Bytes array encoding the function call and arguments

**Return Parameters**

Expand All @@ -1125,25 +1124,6 @@ Add a new expenditure in the colony. Secured function to authorised members.
|---|---|---|
|expenditureId|uint256|Identifier of the newly created expenditure

### `makeSingleArbitraryTransaction(address _target, bytes memory _action):bool success`

Executes a single arbitrary transaction

*Note: Only callable by the colony itself. If you wish to use this functionality, you should use the makeAbitraryTransactions function*

**Parameters**

|Name|Type|Description|
|---|---|---|
|_target|address|Contract to receive the function call
|_action|bytes|Bytes array encoding the function call and arguments

**Return Parameters**

|Name|Type|Description|
|---|---|---|
|success|bool|Boolean indicating whether the transactions succeeded

### `mintTokens(uint256 _wad)`

Mint `_wad` amount of colony tokens. Secured function to authorised members.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,12 @@ class MetatransactionBroadcaster {
async isColonyFamilyTransactionAllowed(target, txData, userAddress) {
const colonyDef = await this.loader.load({ contractDir: "colony", contractName: "IColony" });

// Add the old makeArbitraryTransaction to the abi
const iface = new ethers.utils.Interface(["function makeArbitraryTransaction(address,bytes)"]);
// Add the old makeSingleArbitraryTransaction and makeArbitraryTransactions to the abi
const iface = new ethers.utils.Interface([
"function makeSingleArbitraryTransaction(address,bytes)",
"function makeArbitraryTransactions(address[],bytes[],bool)",
]);

const oldJsonAbi = JSON.parse(iface.format(ethers.utils.FormatTypes.json));
oldJsonAbi[0].inputs = oldJsonAbi[0].inputs.map((x) => {
return { ...x, internalType: x.type };
Expand Down
Loading

0 comments on commit 7a82029

Please sign in to comment.