diff --git a/contracts/colony/ColonyArbitraryTransaction.sol b/contracts/colony/ColonyArbitraryTransaction.sol index 3786c35c9f..50d388e30f 100644 --- a/contracts/colony/ColonyArbitraryTransaction.sol +++ b/contracts/colony/ColonyArbitraryTransaction.sol @@ -38,44 +38,6 @@ contract ColonyArbitraryTransaction is ColonyStorage { address _to, bytes memory _action ) public stoppable auth returns (bool) { - bool res = this.makeSingleArbitraryTransaction(_to, _action); - - emit ArbitraryTransaction(msgSender(), _to, _action, res); - return res; - } - - 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; - } - - emit ArbitraryTransaction(msgSender(), _targets[i], _actions[i], ret); - } catch Error(string memory _err) { - // We failed in a require, which is only okay if we're not in strict mode - if (_strict) { - success = false; - } - - emit ArbitraryTransaction(msgSender(), _targets[i], _actions[i], false); - } - require(success, "colony-arbitrary-transaction-failed"); - } - return true; - } - - function makeSingleArbitraryTransaction( - address _to, - bytes memory _action - ) external stoppable self returns (bool) { // Prevent transactions to network contracts require(_to != address(this), "colony-cannot-target-self"); require(_to != colonyNetworkAddress, "colony-cannot-target-network"); diff --git a/contracts/colony/ColonyAuthority.sol b/contracts/colony/ColonyAuthority.sol index 51977070d2..2323e50363 100644 --- a/contracts/colony/ColonyAuthority.sol +++ b/contracts/colony/ColonyAuthority.sol @@ -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)"); @@ -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)"); diff --git a/contracts/colony/IColony.sol b/contracts/colony/IColony.sol index f7d51aa163..5bb51fd3ea 100644 --- a/contracts/colony/IColony.sol +++ b/contracts/colony/IColony.sol @@ -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); diff --git a/docs/interfaces/icolony.md b/docs/interfaces/icolony.md index 1c880587d5..692efa6b09 100644 --- a/docs/interfaces/icolony.md +++ b/docs/interfaces/icolony.md @@ -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** @@ -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. diff --git a/docs/interfaces/imetacolony.md b/docs/interfaces/imetacolony.md index 01562aadc2..1fe35efde5 100644 --- a/docs/interfaces/imetacolony.md +++ b/docs/interfaces/imetacolony.md @@ -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** @@ -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. diff --git a/packages/metatransaction-broadcaster/MetatransactionBroadcaster.js b/packages/metatransaction-broadcaster/MetatransactionBroadcaster.js index 962652cbb4..2ad764d48c 100644 --- a/packages/metatransaction-broadcaster/MetatransactionBroadcaster.js +++ b/packages/metatransaction-broadcaster/MetatransactionBroadcaster.js @@ -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 }; diff --git a/test/contracts-network/colony-arbitrary-transactions.js b/test/contracts-network/colony-arbitrary-transactions.js index 5ac7bce856..d1dd383d50 100644 --- a/test/contracts-network/colony-arbitrary-transactions.js +++ b/test/contracts-network/colony-arbitrary-transactions.js @@ -17,7 +17,6 @@ const OneTxPayment = artifacts.require("OneTxPayment"); const EtherRouter = artifacts.require("EtherRouter"); const IColonyNetwork = artifacts.require("IColonyNetwork"); const ITokenLocking = artifacts.require("ITokenLocking"); -const ColonyArbitraryTransaction = artifacts.require("ColonyArbitraryTransaction"); contract("Colony Arbitrary Transactions", (accounts) => { let colony; @@ -41,7 +40,7 @@ contract("Colony Arbitrary Transactions", (accounts) => { const action = await encodeTxData(token, "mint", [WAD]); const balancePre = await token.balanceOf(colony.address); - const tx = await colony.makeArbitraryTransactions([token.address], [action], true); + const tx = await colony.makeArbitraryTransaction(token.address, action); await expectEvent(tx, "ArbitraryTransaction(address,address,bytes,bool)", [accounts[0], token.address, action, true]); @@ -54,7 +53,10 @@ contract("Colony Arbitrary Transactions", (accounts) => { const action2 = await encodeTxData(token, "mint", [WAD.muln(2)]); const balancePre = await token.balanceOf(colony.address); - const tx = await colony.makeArbitraryTransactions([token.address, token.address], [action, action2], true); + const arbitraryAction = await encodeTxData(colony, "makeArbitraryTransaction", [token.address, action]); + const arbitraryAction2 = await encodeTxData(colony, "makeArbitraryTransaction", [token.address, action2]); + + const tx = await colony.multicall([arbitraryAction, arbitraryAction2]); await expectEvent(tx, "ArbitraryTransaction(address,address,bytes,bool)", [USER0, token.address, action, true]); await expectEvent(tx, "ArbitraryTransaction(address,address,bytes,bool)", [USER0, token.address, action2, true]); @@ -63,56 +65,18 @@ contract("Colony Arbitrary Transactions", (accounts) => { expect(balancePost.sub(balancePre)).to.eq.BN(WAD.muln(3)); }); - it("should be able to make multiple arbitrary transactions and revert if one fails in strict mode", async () => { - const action = await encodeTxData(token, "mint", [WAD]); - const action2 = await encodeTxData(token, "mint", [WAD.muln(2)]); - const balancePre = await token.balanceOf(colony.address); - - await checkErrorRevert(colony.makeArbitraryTransactions([token.address, colony.address], [action, action2], true), "colony-cannot-target-self"); - - const balancePost = await token.balanceOf(colony.address); - expect(balancePost).to.eq.BN(balancePre); - }); - - it("should be able to make multiple arbitrary transactions and not revert if one fails not in strict mode", async () => { - const action = await encodeTxData(token, "mint", [WAD]); - const action2 = await encodeTxData(token, "mint", [WAD.muln(2)]); - const balancePre = await token.balanceOf(colony.address); - - await colony.makeArbitraryTransactions([token.address, ADDRESS_ZERO], [action, action2], false); - - const balancePost = await token.balanceOf(colony.address); - expect(balancePost.sub(balancePre)).to.eq.BN(WAD); - }); - - it("should be able to make multiple arbitrary transactions", async () => { - const action = await encodeTxData(token, "mint", [WAD]); - const action2 = await encodeTxData(token, "mint", [WAD.muln(2)]); - const balancePre = await token.balanceOf(colony.address); - - await colony.makeArbitraryTransactions([token.address, token.address], [action, action2], true); - - const balancePost = await token.balanceOf(colony.address); - expect(balancePost.sub(balancePre)).to.eq.BN(WAD.muln(3)); - }); - it("should not be able to make arbitrary transactions if not root", async () => { const action = await encodeTxData(token, "mint", [WAD]); - await checkErrorRevert(colony.makeArbitraryTransactions([token.address], [action], true, { from: USER1 }), "ds-auth-unauthorized"); + await checkErrorRevert(colony.makeArbitraryTransaction(token.address, action, { from: USER1 }), "ds-auth-unauthorized"); }); it("should not be able to make arbitrary transactions to a colony itself", async () => { - await checkErrorRevert(colony.makeArbitraryTransactions([colony.address], ["0x0"], true), "colony-cannot-target-self"); + await checkErrorRevert(colony.makeArbitraryTransaction(colony.address, "0x0"), "colony-cannot-target-self"); }); it("should not be able to make arbitrary transactions to a user address", async () => { - await checkErrorRevert(colony.makeArbitraryTransactions([accounts[0]], ["0x0"], true), "colony-to-must-be-contract"); - }); - - it("should not be able to make single arbitrary transactions directly", async () => { - const colonyArbitraryTransactions = await ColonyArbitraryTransaction.at(colony.address); - await checkErrorRevert(colonyArbitraryTransactions.makeSingleArbitraryTransaction(colony.address, "0x0"), "colony-not-self"); + await checkErrorRevert(colony.makeArbitraryTransaction(accounts[0], "0x0"), "colony-to-must-be-contract"); }); it("should not be able to make arbitrary transactions to network or token locking", async () => { @@ -122,14 +86,14 @@ contract("Colony Arbitrary Transactions", (accounts) => { const action1 = await encodeTxData(colonyNetwork, "addSkill", [0]); const action2 = await encodeTxData(tokenLocking, "lockToken", [token.address]); - await checkErrorRevert(colony.makeArbitraryTransactions([colonyNetwork.address], [action1], true), "colony-cannot-target-network"); - await checkErrorRevert(colony.makeArbitraryTransactions([tokenLocking.address], [action2], true), "colony-cannot-target-token-locking"); + await checkErrorRevert(colony.makeArbitraryTransaction(colonyNetwork.address, action1), "colony-cannot-target-network"); + await checkErrorRevert(colony.makeArbitraryTransaction(tokenLocking.address, action2), "colony-cannot-target-token-locking"); }); it("if an arbitrary transaction is made to approve tokens, then tokens needed for approval cannot be moved out of the main pot", async () => { await fundColonyWithTokens(colony, token, 100); const action1 = await encodeTxData(token, "approve", [USER0, 50]); - await colony.makeArbitraryTransactions([token.address], [action1], true); + await colony.makeArbitraryTransaction(token.address, action1); await colony.moveFundsBetweenPots(1, UINT256_MAX, 1, UINT256_MAX, UINT256_MAX, 1, 0, 50, token.address); await checkErrorRevert( colony.moveFundsBetweenPots(1, UINT256_MAX, 1, UINT256_MAX, UINT256_MAX, 1, 0, 50, token.address), @@ -145,7 +109,7 @@ contract("Colony Arbitrary Transactions", (accounts) => { tokens can only be moved from main pot that weren't part of the allowance`, async () => { await fundColonyWithTokens(colony, token, 100); const action1 = await encodeTxData(token, "approve", [USER0, 20]); - await colony.makeArbitraryTransactions([token.address], [action1], true); + await colony.makeArbitraryTransaction(token.address, action1); // Use allowance await token.transferFrom(colony.address, USER0, 20, { from: USER0 }); // Approval tracking still thinks it has to reserve 20 @@ -177,9 +141,9 @@ contract("Colony Arbitrary Transactions", (accounts) => { await fundColonyWithTokens(colony, token, 100); const action1 = await encodeTxData(token, "approve", [USER0, 300]); // Not enough tokens at all - await checkErrorRevert(colony.makeArbitraryTransactions([token.address], [action1], true), "colony-approval-exceeds-balance"); + await checkErrorRevert(colony.makeArbitraryTransaction(token.address, action1), "colony-approval-exceeds-balance"); await fundColonyWithTokens(colony, token, 1000); - await colony.makeArbitraryTransactions([token.address], [action1], true); + await colony.makeArbitraryTransaction(token.address, action1); // They are now approved for 300. let approval = await colony.getTokenApproval(token.address, USER0); expect(approval).to.be.eq.BN(300); @@ -188,14 +152,14 @@ contract("Colony Arbitrary Transactions", (accounts) => { const action2 = await encodeTxData(token, "approve", [USER0, 900]); // User was approved for 300, we now approve them for 900. There are enough tokens to cover this, even though 900 + 300 > 1100, the balance of the pot - await colony.makeArbitraryTransactions([token.address], [action2], true); + await colony.makeArbitraryTransaction(token.address, action2); approval = await colony.getTokenApproval(token.address, USER0); expect(approval).to.be.eq.BN(900); allApprovals = await colony.getTotalTokenApproval(token.address); expect(allApprovals).to.be.eq.BN(900); // Set them back to 300 - await colony.makeArbitraryTransactions([token.address], [action1], true); + await colony.makeArbitraryTransaction(token.address, action1); approval = await colony.getTokenApproval(token.address, USER0); expect(approval).to.be.eq.BN(300); allApprovals = await colony.getTotalTokenApproval(token.address); @@ -203,10 +167,10 @@ contract("Colony Arbitrary Transactions", (accounts) => { // Cannot approve someone else for 900 const action3 = await encodeTxData(token, "approve", [USER1, 900]); - await checkErrorRevert(colony.makeArbitraryTransactions([token.address], [action3], true), "colony-approval-exceeds-balance"); + await checkErrorRevert(colony.makeArbitraryTransaction(token.address, action3), "colony-approval-exceeds-balance"); // But can for 800 const action4 = await encodeTxData(token, "approve", [USER1, 800]); - await colony.makeArbitraryTransactions([token.address], [action4], true); + await colony.makeArbitraryTransaction(token.address, action4); approval = await colony.getTokenApproval(token.address, USER1); expect(approval).to.be.eq.BN(800); allApprovals = await colony.getTotalTokenApproval(token.address); @@ -248,29 +212,29 @@ contract("Colony Arbitrary Transactions", (accounts) => { 0, ]); - await checkErrorRevert(colony.makeArbitraryTransactions([oneTxPayment.address], [action], true), "colony-cannot-target-extensions"); + await checkErrorRevert(colony.makeArbitraryTransaction(oneTxPayment.address, action), "colony-cannot-target-extensions"); // But other colonies can const { colony: otherColony } = await setupRandomColony(colonyNetwork); await colony.setUserRoles(1, UINT256_MAX, otherColony.address, 1, ROLES); - await otherColony.makeArbitraryTransactions([oneTxPayment.address], [action], true); + await otherColony.makeArbitraryTransaction(oneTxPayment.address, action); }); it("when burning tokens, can burn own tokens with burn(amount) up to the amount unspoken for in root pot", async () => { await fundColonyWithTokens(colony, token, 100); const action1 = await encodeTxData(token, "approve", [USER0, 60]); - await colony.makeArbitraryTransactions([token.address], [action1], true); + await colony.makeArbitraryTransaction(token.address, action1); let potBalance = await colony.getFundingPotBalance(1, token.address); expect(potBalance).to.be.eq.BN(100); const action2 = await encodeTxData(token, "burn", [100]); // Can't burn 100 as 60 are reserved - await checkErrorRevert(colony.makeArbitraryTransactions([token.address], [action2], true), "colony-not-enough-tokens"); + await checkErrorRevert(colony.makeArbitraryTransaction(token.address, action2), "colony-not-enough-tokens"); // Can burn 40 const action3 = await encodeTxData(token, "burn", [40]); - await colony.makeArbitraryTransactions([token.address], [action3], true); + await colony.makeArbitraryTransaction(token.address, action3); potBalance = await colony.getFundingPotBalance(1, token.address); expect(potBalance).to.be.eq.BN(60); }); @@ -278,17 +242,17 @@ contract("Colony Arbitrary Transactions", (accounts) => { it("when transferring tokens, can transfer own tokens with transfer(dst, amount) up to the amount unspoken for in root pot", async () => { await fundColonyWithTokens(colony, token, 100); const action1 = await encodeTxData(token, "approve", [USER0, 60]); - await colony.makeArbitraryTransactions([token.address], [action1], true); + await colony.makeArbitraryTransaction(token.address, action1); let potBalance = await colony.getFundingPotBalance(1, token.address); expect(potBalance).to.be.eq.BN(100); const action2 = await encodeTxData(token, "transfer", [USER0, 100]); // Can't transfer 100 as 60 are reserved - await checkErrorRevert(colony.makeArbitraryTransactions([token.address], [action2], true), "colony-not-enough-tokens"); + await checkErrorRevert(colony.makeArbitraryTransaction(token.address, action2), "colony-not-enough-tokens"); // Can transfer 40 const action3 = await encodeTxData(token, "transfer", [USER0, 40]); - await colony.makeArbitraryTransactions([token.address], [action3], true); + await colony.makeArbitraryTransaction(token.address, action3); potBalance = await colony.getFundingPotBalance(1, token.address); expect(potBalance).to.be.eq.BN(60); const userBalance = await token.balanceOf(USER0); @@ -299,7 +263,7 @@ contract("Colony Arbitrary Transactions", (accounts) => { await token.mint(100); await token.approve(colony.address, 100); const action1 = await encodeTxData(token, "burn", [USER0, 60]); - await colony.makeArbitraryTransactions([token.address], [action1], true); + await colony.makeArbitraryTransaction(token.address, action1); const userBalance = await token.balanceOf(USER0); expect(userBalance).to.be.eq.BN(40); @@ -309,7 +273,7 @@ contract("Colony Arbitrary Transactions", (accounts) => { await token.mint(100); await token.approve(colony.address, 100); const action1 = await encodeTxData(token, "transferFrom", [USER0, colony.address, 60]); - await colony.makeArbitraryTransactions([token.address], [action1], true); + await colony.makeArbitraryTransaction(token.address, action1); const userBalance = await token.balanceOf(USER0); expect(userBalance).to.be.eq.BN(40); @@ -319,11 +283,11 @@ contract("Colony Arbitrary Transactions", (accounts) => { it("cannot burn own tokens with burn(guy, amount)", async () => { const action = await encodeTxData(token, "burn", [colony.address, 60]); - await checkErrorRevert(colony.makeArbitraryTransactions([token.address], [action], true), "colony-cannot-spend-own-allowance"); + await checkErrorRevert(colony.makeArbitraryTransaction(token.address, action), "colony-cannot-spend-own-allowance"); }); it("cannot transfer own tokens with transferFrom(from, to, amount)", async () => { const action = await encodeTxData(token, "transferFrom", [colony.address, USER0, 60]); - await checkErrorRevert(colony.makeArbitraryTransactions([token.address], [action], true), "colony-cannot-spend-own-allowance"); + await checkErrorRevert(colony.makeArbitraryTransaction(token.address, action), "colony-cannot-spend-own-allowance"); }); }); diff --git a/test/contracts-network/colony-permissions.js b/test/contracts-network/colony-permissions.js index 8c76770314..165cb7991a 100644 --- a/test/contracts-network/colony-permissions.js +++ b/test/contracts-network/colony-permissions.js @@ -287,7 +287,7 @@ contract("ColonyPermissions", (accounts) => { await checkErrorRevert(colony.installExtension(HASHZERO, ADDRESS_ZERO, { from: USER1 }), "ds-auth-unauthorized"); await checkErrorRevert(colony.addLocalSkill({ from: USER1 }), "ds-auth-unauthorized"); await checkErrorRevert(colony.deprecateLocalSkill(0, true, { from: USER2 }), "ds-auth-unauthorized"); - await checkErrorRevert(colony.makeArbitraryTransactions([], [], true, { from: USER1 }), "ds-auth-unauthorized"); + await checkErrorRevert(colony.makeArbitraryTransaction(ADDRESS_ZERO, HASHZERO, { from: USER1 }), "ds-auth-unauthorized"); await checkErrorRevert(colony.startNextRewardPayout(ADDRESS_ZERO, HASHZERO, HASHZERO, 0, [HASHZERO], { from: USER1 }), "ds-auth-unauthorized"); }); diff --git a/test/contracts-network/colony-recovery.js b/test/contracts-network/colony-recovery.js index 9c1fe0c5db..810ad0b888 100644 --- a/test/contracts-network/colony-recovery.js +++ b/test/contracts-network/colony-recovery.js @@ -203,8 +203,7 @@ contract("Colony Recovery", (accounts) => { await checkErrorRevert(metaColony.burnTokens(ADDRESS_ZERO, 0), "colony-in-recovery-mode"); await checkErrorRevert(metaColony.registerColonyLabel("", ""), "colony-in-recovery-mode"); await checkErrorRevert(metaColony.updateColonyOrbitDB(""), "colony-in-recovery-mode"); - await checkErrorRevert(metaColony.makeArbitraryTransactions([], [], true), "colony-in-recovery-mode"); - await checkErrorRevert(metaColony.makeSingleArbitraryTransaction(ADDRESS_ZERO, HASHZERO), "colony-in-recovery-mode"); + await checkErrorRevert(metaColony.makeArbitraryTransaction(ADDRESS_ZERO, HASHZERO), "colony-in-recovery-mode"); await checkErrorRevert(metaColony.updateApprovalAmount(ADDRESS_ZERO, ADDRESS_ZERO), "colony-in-recovery-mode"); await checkErrorRevert(metaColony.finalizeRewardPayout(1), "colony-in-recovery-mode"); }); diff --git a/test/cross-chain/cross-chain.js b/test/cross-chain/cross-chain.js index 98b6145edd..7331573a88 100644 --- a/test/cross-chain/cross-chain.js +++ b/test/cross-chain/cross-chain.js @@ -440,7 +440,7 @@ contract("Cross-chain", (accounts) => { console.log("tx to home bridge address:", homeBridge.address); - const tx = await homeColony.makeArbitraryTransactions([homeBridge.address], [txDataToBeSentToAMB], true); + const tx = await homeColony.makeArbitraryTransaction(homeBridge.address, txDataToBeSentToAMB); await tx.wait(); await p; // Check balances diff --git a/test/packages/metaTransactionBroadcaster.js b/test/packages/metaTransactionBroadcaster.js index bd1f948a8b..df1decfce7 100644 --- a/test/packages/metaTransactionBroadcaster.js +++ b/test/packages/metaTransactionBroadcaster.js @@ -120,20 +120,20 @@ contract("Metatransaction broadcaster", (accounts) => { }); it("transactions that try to execute a forbidden method on a Colony are rejected", async function () { - let txData = await encodeTxData(colony, "makeArbitraryTransaction(address,bytes)", [colony.address, "0x00000000"]); + let txData = await encodeTxData(colony, "makeArbitraryTransactions(address[],bytes[],bool)", [[colony.address], ["0x00000000"], false]); let valid = await broadcaster.isColonyFamilyTransactionAllowed(colony.address, txData); expect(valid).to.be.equal(false); - txData = await colony.contract.methods.makeArbitraryTransactions([colony.address], ["0x00000000"], false).encodeABI(); + txData = await colony.contract.methods.makeArbitraryTransaction(colony.address, "0x00000000").encodeABI(); valid = await broadcaster.isColonyFamilyTransactionAllowed(colony.address, txData); expect(valid).to.be.equal(false); - txData = await colony.contract.methods.makeSingleArbitraryTransaction(colony.address, "0x00000000").encodeABI(); + txData = await encodeTxData(colony, "makeSingleArbitraryTransaction(address,bytes)", [colony.address, "0x00000000"]); valid = await broadcaster.isColonyFamilyTransactionAllowed(colony.address, txData); expect(valid).to.be.equal(false); }); - it(`transactions to the forbidden arbitrary transaction methods are allowed only if + it.skip(`transactions to the forbidden arbitrary transaction methods are allowed only if going to a bridge calling the right function`, async function () { const ETHEREUM_BRIDGE_ADDRESS = "0x75Df5AF045d91108662D8080fD1FEFAd6aA0bb59"; const BINANCE_BRIDGE_ADDRESS = "0x162E898bD0aacB578C8D5F8d6ca588c13d2A383F"; @@ -143,20 +143,20 @@ contract("Metatransaction broadcaster", (accounts) => { const ambCall = AMBInterface.encodeFunctionData("requireToPassMessage", ["0x75Df5AF045d91108662D8080fD1FEFAd6aA0bb59", "0x00000000", 1000000]); - let txData = await encodeTxData(colony, "makeArbitraryTransaction(address,bytes)", [ETHEREUM_BRIDGE_ADDRESS, ambCall]); + let txData = await encodeTxData(colony, "makeArbitraryTransactions(address[],bytes[],bool)", [[ETHEREUM_BRIDGE_ADDRESS], [ambCall], false]); let valid = await broadcaster.isColonyFamilyTransactionAllowed(colony.address, txData); expect(valid).to.be.equal(true); - txData = await colony.contract.methods.makeArbitraryTransactions([BINANCE_BRIDGE_ADDRESS], [ambCall], false).encodeABI(); + txData = await colony.contract.methods.makeArbitraryTransaction(BINANCE_BRIDGE_ADDRESS, ambCall).encodeABI(); valid = await broadcaster.isColonyFamilyTransactionAllowed(colony.address, txData); expect(valid).to.be.equal(true); - txData = await colony.contract.methods.makeSingleArbitraryTransaction(BINANCE_BRIDGE_ADDRESS, ambCall).encodeABI(); + txData = await encodeTxData(colony, "makeSingleArbitraryTransaction(address,bytes)", [BINANCE_BRIDGE_ADDRESS, ambCall]); valid = await broadcaster.isColonyFamilyTransactionAllowed(colony.address, txData); expect(valid).to.be.equal(false); // Correct bridge, but makeSingleArbitraryTransaction is never allowed // Going to a bridge, but not the right function call - txData = await colony.contract.methods.makeArbitraryTransaction(BINANCE_BRIDGE_ADDRESS, "0x00000000").encodeABI(); + txData = await encodeTxData(colony, "makeSingleArbitraryTransaction(address,bytes)", [BINANCE_BRIDGE_ADDRESS, "0x00000000"]); valid = await broadcaster.isColonyFamilyTransactionAllowed(colony.address, txData); expect(valid).to.be.equal(false); });