diff --git a/contracts/extensions/CoinMachine.sol b/contracts/extensions/CoinMachine.sol index c1b3c6cfb5..b6884495ab 100644 --- a/contracts/extensions/CoinMachine.sol +++ b/contracts/extensions/CoinMachine.sol @@ -19,13 +19,14 @@ pragma solidity 0.7.3; pragma experimental ABIEncoderV2; import "./../../lib/dappsys/erc20.sol"; +import "./../common/BasicMetaTransaction.sol"; import "./ColonyExtension.sol"; import "./Whitelist.sol"; // ignore-file-swc-108 -contract CoinMachine is ColonyExtension { +contract CoinMachine is ColonyExtension, BasicMetaTransaction { // Events diff --git a/contracts/extensions/ColonyExtension.sol b/contracts/extensions/ColonyExtension.sol index 3570228c51..c9ec705d99 100644 --- a/contracts/extensions/ColonyExtension.sol +++ b/contracts/extensions/ColonyExtension.sol @@ -22,9 +22,9 @@ import "./../../lib/dappsys/math.sol"; import "./../common/EtherRouter.sol"; import "./../colony/IColony.sol"; import "./../colony/ColonyDataTypes.sol"; -import "./../common/BasicMetaTransaction.sol"; -abstract contract ColonyExtension is DSAuth, DSMath, BasicMetaTransaction { + +abstract contract ColonyExtension is DSAuth, DSMath { uint256 constant UINT256_MAX = 2**256 - 1; diff --git a/contracts/extensions/ColonyExtensionMeta.sol b/contracts/extensions/ColonyExtensionMeta.sol new file mode 100644 index 0000000000..bd6ec60f1b --- /dev/null +++ b/contracts/extensions/ColonyExtensionMeta.sol @@ -0,0 +1,36 @@ +/* + This file is part of The Colony Network. + + The Colony Network is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + The Colony Network is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with The Colony Network. If not, see . +*/ + +pragma solidity 0.7.3; +pragma experimental ABIEncoderV2; + +import "./../common/BasicMetaTransaction.sol"; +import "./ColonyExtension.sol"; + +abstract contract ColonyExtensionMeta is ColonyExtension, BasicMetaTransaction { + + mapping (address => uint256) metatransactionNonces; + + function getMetatransactionNonce(address _user) override public view returns (uint256 nonce) { + return metatransactionNonces[_user]; + } + + function incrementMetatransactionNonce(address _user) override internal { + metatransactionNonces[_user] += 1; + } + +} diff --git a/contracts/extensions/EvaluatedExpenditure.sol b/contracts/extensions/EvaluatedExpenditure.sol index b4cbaea803..cf3cf6c44b 100644 --- a/contracts/extensions/EvaluatedExpenditure.sol +++ b/contracts/extensions/EvaluatedExpenditure.sol @@ -19,11 +19,12 @@ pragma solidity 0.7.3; pragma experimental ABIEncoderV2; import "./ColonyExtension.sol"; +import "./../common/BasicMetaTransaction.sol"; // ignore-file-swc-108 -contract EvaluatedExpenditure is ColonyExtension { +contract EvaluatedExpenditure is ColonyExtension, BasicMetaTransaction { uint256 constant EXPENDITURESLOTS_SLOT = 26; uint256 constant PAYOUT_MODIFIER_OFFSET = 2; diff --git a/contracts/extensions/FundingQueue.sol b/contracts/extensions/FundingQueue.sol index 674cd38a09..e79c8491e2 100644 --- a/contracts/extensions/FundingQueue.sol +++ b/contracts/extensions/FundingQueue.sol @@ -18,14 +18,15 @@ pragma solidity 0.7.3; pragma experimental ABIEncoderV2; +import "./../colony/ColonyDataTypes.sol"; import "./../colonyNetwork/IColonyNetwork.sol"; +import "./../common/BasicMetaTransaction.sol"; import "./../common/ERC20Extended.sol"; import "./../patriciaTree/PatriciaTreeProofs.sol"; import "./../tokenLocking/ITokenLocking.sol"; import "./ColonyExtension.sol"; -import "./../colony/ColonyDataTypes.sol"; -contract FundingQueue is ColonyExtension, PatriciaTreeProofs { +contract FundingQueue is ColonyExtension, PatriciaTreeProofs, BasicMetaTransaction { // Events event ProposalCreated(uint256 id, uint256 indexed fromPot, uint256 indexed toPot, address indexed token, uint256 amount); diff --git a/contracts/extensions/OneTxPayment.sol b/contracts/extensions/OneTxPayment.sol index ecbfcb4aa8..f325c35d40 100644 --- a/contracts/extensions/OneTxPayment.sol +++ b/contracts/extensions/OneTxPayment.sol @@ -19,11 +19,12 @@ pragma solidity 0.7.3; pragma experimental ABIEncoderV2; import "./ColonyExtension.sol"; +import "./../common/BasicMetaTransaction.sol"; // ignore-file-swc-108 -contract OneTxPayment is ColonyExtension { +contract OneTxPayment is ColonyExtension, BasicMetaTransaction { event OneTxPaymentMade(address agent, uint256 fundamentalId, uint256 nPayouts); ColonyDataTypes.ColonyRole constant ADMINISTRATION = ColonyDataTypes.ColonyRole.Administration; diff --git a/contracts/extensions/TokenSupplier.sol b/contracts/extensions/TokenSupplier.sol index 340712c267..e169f13134 100644 --- a/contracts/extensions/TokenSupplier.sol +++ b/contracts/extensions/TokenSupplier.sol @@ -18,11 +18,12 @@ pragma solidity 0.7.3; pragma experimental ABIEncoderV2; +import "./../common/BasicMetaTransaction.sol"; import "./../common/ERC20Extended.sol"; import "./ColonyExtension.sol"; -contract TokenSupplier is ColonyExtension { +contract TokenSupplier is ColonyExtension, BasicMetaTransaction { uint256 constant ISSUANCE_PERIOD = 1 days; diff --git a/contracts/extensions/VotingReputation.sol b/contracts/extensions/VotingReputation.sol index f4294d134e..cd96adc7d1 100644 --- a/contracts/extensions/VotingReputation.sol +++ b/contracts/extensions/VotingReputation.sol @@ -18,15 +18,16 @@ pragma solidity 0.7.3; pragma experimental ABIEncoderV2; -import "./../colony/ColonyRoles.sol"; import "./../colonyNetwork/IColonyNetwork.sol"; +import "./../colony/ColonyRoles.sol"; +import "./../common/BasicMetaTransaction.sol"; import "./../common/ERC20Extended.sol"; import "./../patriciaTree/PatriciaTreeProofs.sol"; import "./../tokenLocking/ITokenLocking.sol"; import "./ColonyExtension.sol"; -contract VotingReputation is ColonyExtension, PatriciaTreeProofs { +contract VotingReputation is ColonyExtension, PatriciaTreeProofs, BasicMetaTransaction { // Events event MotionCreated(uint256 indexed motionId, address creator, uint256 indexed domainId); diff --git a/contracts/extensions/Whitelist.sol b/contracts/extensions/Whitelist.sol index 76a9a3f166..0d14f77bf7 100644 --- a/contracts/extensions/Whitelist.sol +++ b/contracts/extensions/Whitelist.sol @@ -18,12 +18,13 @@ pragma solidity 0.7.3; pragma experimental ABIEncoderV2; +import "./../common/BasicMetaTransaction.sol"; import "./ColonyExtension.sol"; // ignore-file-swc-108 -contract Whitelist is ColonyExtension { +contract Whitelist is ColonyExtension, BasicMetaTransaction { // Events diff --git a/contracts/testHelpers/TestExtensions.sol b/contracts/testHelpers/TestExtensions.sol index 0503cc7dc6..c2992874df 100644 --- a/contracts/testHelpers/TestExtensions.sol +++ b/contracts/testHelpers/TestExtensions.sol @@ -18,10 +18,10 @@ pragma solidity 0.7.3; pragma experimental ABIEncoderV2; -import "../extensions/ColonyExtension.sol"; +import "../extensions/ColonyExtensionMeta.sol"; -abstract contract TestExtension is ColonyExtension { +abstract contract TestExtension is ColonyExtensionMeta { function install(address _colony) public override auth { require(address(colony) == address(0x0), "extension-already-installed"); @@ -37,16 +37,6 @@ abstract contract TestExtension is ColonyExtension { function uninstall() public override auth { selfdestruct(address(uint160(address(colony)))); } - - mapping(address => uint256) metatransactionNonces; - function getMetatransactionNonce(address userAddress) override public view returns (uint256 nonce){ - return metatransactionNonces[userAddress]; - } - - function incrementMetatransactionNonce(address user) override internal { - metatransactionNonces[user] = add(metatransactionNonces[user], 1); - } - }