From 73ddf847588391258abf5aeeab8b85f846918e9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=9Fingen?= Date: Mon, 22 Jun 2020 19:41:27 +0200 Subject: [PATCH 1/6] Disputable apps: add missing pieces for transaction fees module --- contracts/apps/disputable/IDisputable.sol | 4 +++- contracts/lib/arbitration/IArbitrator.sol | 7 +++++++ .../lib/arbitration/ITransactionFeesOracle.sol | 12 ++++++++++++ .../mocks/apps/disputable/DisputableAppMock.sol | 14 +++++++++----- test/contracts/apps/disputable/disputable_app.js | 10 ++++++---- 5 files changed, 37 insertions(+), 10 deletions(-) create mode 100644 contracts/lib/arbitration/ITransactionFeesOracle.sol diff --git a/contracts/apps/disputable/IDisputable.sol b/contracts/apps/disputable/IDisputable.sol index 30e8ce783..f9a2f8450 100644 --- a/contracts/apps/disputable/IDisputable.sol +++ b/contracts/apps/disputable/IDisputable.sol @@ -11,7 +11,7 @@ import "../../lib/standards/ERC165.sol"; contract IDisputable is ERC165 { bytes4 internal constant ERC165_INTERFACE_ID = bytes4(0x01ffc9a7); - bytes4 internal constant DISPUTABLE_INTERFACE_ID = bytes4(0xef113021); + bytes4 internal constant DISPUTABLE_INTERFACE_ID = bytes4(0xce1f6de9); event AgreementSet(IAgreement indexed agreement); @@ -39,4 +39,6 @@ contract IDisputable is ERC165 { function supportsInterface(bytes4 _interfaceId) external pure returns (bool) { return _interfaceId == DISPUTABLE_INTERFACE_ID || _interfaceId == ERC165_INTERFACE_ID; } + + function appId() public view returns (bytes32); } diff --git a/contracts/lib/arbitration/IArbitrator.sol b/contracts/lib/arbitration/IArbitrator.sol index 5cfa63a4b..b6564f3d3 100644 --- a/contracts/lib/arbitration/IArbitrator.sol +++ b/contracts/lib/arbitration/IArbitrator.sol @@ -49,4 +49,11 @@ interface IArbitrator { * @return feeAmount Total amount of fees that must be allowed to the recipient */ function getSubscriptionFees(address _subscriber) external view returns (address recipient, ERC20 feeToken, uint256 feeAmount); + + /** + * @dev Tell address of a module based on a given ID + * @param _id ID of the module being queried + * @return Address of the requested module + */ + function getModule(bytes32 _id) external view returns (address); } diff --git a/contracts/lib/arbitration/ITransactionFeesOracle.sol b/contracts/lib/arbitration/ITransactionFeesOracle.sol new file mode 100644 index 000000000..df0cd3bbf --- /dev/null +++ b/contracts/lib/arbitration/ITransactionFeesOracle.sol @@ -0,0 +1,12 @@ +pragma solidity ^0.4.24; + +import "../token/ERC20.sol"; + + +interface ITransactionFeesOracle { + function setFee(bytes32 appId, ERC20 token, uint256 amount) external; + function setFees(bytes32[] _appIds, ERC20[] _tokens, uint256[] _amounts) external; + function unsetFee(bytes32 _appId) external; + function unsetFees(bytes32[] _appIds) external; + function getFee(bytes32 appId) external view returns (ERC20, uint256, address); +} diff --git a/contracts/test/mocks/apps/disputable/DisputableAppMock.sol b/contracts/test/mocks/apps/disputable/DisputableAppMock.sol index 42b893a64..acff258a8 100644 --- a/contracts/test/mocks/apps/disputable/DisputableAppMock.sol +++ b/contracts/test/mocks/apps/disputable/DisputableAppMock.sol @@ -36,11 +36,15 @@ contract DisputableAppMock is DisputableAragonApp { function interfaceID() external pure returns (bytes4) { IDisputable iDisputable; return iDisputable.setAgreement.selector ^ - iDisputable.onDisputableActionChallenged.selector ^ - iDisputable.onDisputableActionAllowed.selector ^ - iDisputable.onDisputableActionRejected.selector ^ - iDisputable.onDisputableActionVoided.selector ^ - iDisputable.getAgreement.selector; + iDisputable.onDisputableActionChallenged.selector ^ + iDisputable.onDisputableActionAllowed.selector ^ + iDisputable.onDisputableActionRejected.selector ^ + iDisputable.onDisputableActionVoided.selector ^ + iDisputable.getAgreement.selector ^ + iDisputable.getDisputableAction.selector ^ + iDisputable.canChallenge.selector ^ + iDisputable.canClose.selector ^ + iDisputable.appId.selector; } function erc165interfaceID() external pure returns (bytes4) { diff --git a/test/contracts/apps/disputable/disputable_app.js b/test/contracts/apps/disputable/disputable_app.js index 84f3f903e..c779eee5f 100644 --- a/test/contracts/apps/disputable/disputable_app.js +++ b/test/contracts/apps/disputable/disputable_app.js @@ -14,6 +14,8 @@ contract('DisputableApp', ([_, owner, agreement, anotherAgreement, someone]) => let disputable, disputableBase, dao, acl const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000' + const DISPUTABLE_INTERFACE = '0xce1f6de9' + const ERC165_INTERFACE = '0x01ffc9a7' before('deploy DAO', async () => { const kernelBase = await Kernel.new(true) @@ -41,16 +43,16 @@ contract('DisputableApp', ([_, owner, agreement, anotherAgreement, someone]) => describe('supportsInterface', () => { it('supports ERC165', async () => { - assert.isTrue(await disputable.supportsInterface('0x01ffc9a7'), 'does not support ERC165') + assert.isTrue(await disputable.supportsInterface(ERC165_INTERFACE), 'does not support ERC165') - assert.equal(await disputable.ERC165_INTERFACE(), '0x01ffc9a7', 'ERC165 interface ID does not match') + assert.equal(await disputable.ERC165_INTERFACE(), ERC165_INTERFACE, 'ERC165 interface ID does not match') assert.equal(await disputable.erc165interfaceID(), await disputable.ERC165_INTERFACE(), 'ERC165 interface ID does not match') }) it('supports IDisputable', async () => { - assert.isTrue(await disputable.supportsInterface('0xef113021'), 'does not support IDisputable') + assert.isTrue(await disputable.supportsInterface(DISPUTABLE_INTERFACE), 'does not support IDisputable') - assert.equal(await disputable.interfaceID(), '0xef113021') + assert.equal(await disputable.interfaceID(), DISPUTABLE_INTERFACE) assert.equal(await disputable.DISPUTABLE_INTERFACE(), await disputable.interfaceID(), 'IDisputable interface ID does not match') }) From f40902eebe3eb0d59caf2c925252a5362b583545 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=9Fingen?= Date: Fri, 26 Jun 2020 15:54:21 +0200 Subject: [PATCH 2/6] arbitration: Add IAragonCourtArbitrator --- contracts/apps/disputable/IAgreement.sol | 3 ++- .../lib/arbitration/IAragonCourtArbitrator.sol | 18 ++++++++++++++++++ contracts/lib/arbitration/IArbitrator.sol | 7 ------- 3 files changed, 20 insertions(+), 8 deletions(-) create mode 100644 contracts/lib/arbitration/IAragonCourtArbitrator.sol diff --git a/contracts/apps/disputable/IAgreement.sol b/contracts/apps/disputable/IAgreement.sol index 333cb7a58..f3fa2eb84 100644 --- a/contracts/apps/disputable/IAgreement.sol +++ b/contracts/apps/disputable/IAgreement.sol @@ -7,6 +7,7 @@ pragma solidity ^0.4.24; import "../../acl/IACLOracle.sol"; import "../../lib/token/ERC20.sol"; import "../../lib/arbitration/IArbitrable.sol"; +import "../../lib/arbitration/IAragonCourtArbitrator.sol"; contract IAgreement is IArbitrable, IACLOracle { @@ -61,7 +62,7 @@ contract IAgreement is IArbitrable, IACLOracle { function getCurrentSettingId() external view returns (uint256); - function getSetting(uint256 _settingId) external view returns (IArbitrator arbitrator, string title, bytes content); + function getSetting(uint256 _settingId) external view returns (IAragonCourtArbitrator arbitrator, string title, bytes content); function getDisputableInfo(address _disputable) external view returns (bool registered, uint256 currentCollateralRequirementId); diff --git a/contracts/lib/arbitration/IAragonCourtArbitrator.sol b/contracts/lib/arbitration/IAragonCourtArbitrator.sol new file mode 100644 index 000000000..2fd404f4f --- /dev/null +++ b/contracts/lib/arbitration/IAragonCourtArbitrator.sol @@ -0,0 +1,18 @@ +/* + * SPDX-License-Identifier: MIT + */ + +pragma solidity ^0.4.24; + +import "./IArbitrator.sol"; + + +contract IAragonCourtArbitrator is IArbitrator { + + /** + * @dev Tell address of a module based on a given ID + * @param _id ID of the module being queried + * @return Address of the requested module + */ + function getModule(bytes32 _id) external view returns (address); +} diff --git a/contracts/lib/arbitration/IArbitrator.sol b/contracts/lib/arbitration/IArbitrator.sol index b6564f3d3..5cfa63a4b 100644 --- a/contracts/lib/arbitration/IArbitrator.sol +++ b/contracts/lib/arbitration/IArbitrator.sol @@ -49,11 +49,4 @@ interface IArbitrator { * @return feeAmount Total amount of fees that must be allowed to the recipient */ function getSubscriptionFees(address _subscriber) external view returns (address recipient, ERC20 feeToken, uint256 feeAmount); - - /** - * @dev Tell address of a module based on a given ID - * @param _id ID of the module being queried - * @return Address of the requested module - */ - function getModule(bytes32 _id) external view returns (address); } From 1e97dddc5a404ace8bb1148ffaaaa064ceb2bee8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=9Fingen?= Date: Fri, 26 Jun 2020 19:23:33 +0200 Subject: [PATCH 3/6] arbitration: Remove IAragonCourtArbitrator --- contracts/apps/disputable/IAgreement.sol | 3 +-- .../lib/arbitration/IAragonCourtArbitrator.sol | 18 ------------------ 2 files changed, 1 insertion(+), 20 deletions(-) delete mode 100644 contracts/lib/arbitration/IAragonCourtArbitrator.sol diff --git a/contracts/apps/disputable/IAgreement.sol b/contracts/apps/disputable/IAgreement.sol index f3fa2eb84..333cb7a58 100644 --- a/contracts/apps/disputable/IAgreement.sol +++ b/contracts/apps/disputable/IAgreement.sol @@ -7,7 +7,6 @@ pragma solidity ^0.4.24; import "../../acl/IACLOracle.sol"; import "../../lib/token/ERC20.sol"; import "../../lib/arbitration/IArbitrable.sol"; -import "../../lib/arbitration/IAragonCourtArbitrator.sol"; contract IAgreement is IArbitrable, IACLOracle { @@ -62,7 +61,7 @@ contract IAgreement is IArbitrable, IACLOracle { function getCurrentSettingId() external view returns (uint256); - function getSetting(uint256 _settingId) external view returns (IAragonCourtArbitrator arbitrator, string title, bytes content); + function getSetting(uint256 _settingId) external view returns (IArbitrator arbitrator, string title, bytes content); function getDisputableInfo(address _disputable) external view returns (bool registered, uint256 currentCollateralRequirementId); diff --git a/contracts/lib/arbitration/IAragonCourtArbitrator.sol b/contracts/lib/arbitration/IAragonCourtArbitrator.sol deleted file mode 100644 index 2fd404f4f..000000000 --- a/contracts/lib/arbitration/IAragonCourtArbitrator.sol +++ /dev/null @@ -1,18 +0,0 @@ -/* - * SPDX-License-Identifier: MIT - */ - -pragma solidity ^0.4.24; - -import "./IArbitrator.sol"; - - -contract IAragonCourtArbitrator is IArbitrator { - - /** - * @dev Tell address of a module based on a given ID - * @param _id ID of the module being queried - * @return Address of the requested module - */ - function getModule(bytes32 _id) external view returns (address); -} From fe3148f822da689d694910a5b874eb7bc5f722d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=9Fingen?= Date: Mon, 29 Jun 2020 17:36:58 +0200 Subject: [PATCH 4/6] 5.0.0-beta.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 53449adaf..4d6c9c091 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@aragon/os", - "version": "5.0.0-beta.0", + "version": "5.0.0-beta.1", "description": "Core contracts for Aragon", "scripts": { "compile": "truffle compile", From 3c202d8704f40ce96e19063140236b8cfcce28f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=9Fingen?= Date: Mon, 29 Jun 2020 18:32:47 +0200 Subject: [PATCH 5/6] disputable apps: fixes after rebase on next --- contracts/apps/disputable/IDisputable.sol | 2 +- contracts/test/mocks/apps/disputable/DisputableAppMock.sol | 1 - test/contracts/apps/disputable/disputable_app.js | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/contracts/apps/disputable/IDisputable.sol b/contracts/apps/disputable/IDisputable.sol index f9a2f8450..f015feb67 100644 --- a/contracts/apps/disputable/IDisputable.sol +++ b/contracts/apps/disputable/IDisputable.sol @@ -11,7 +11,7 @@ import "../../lib/standards/ERC165.sol"; contract IDisputable is ERC165 { bytes4 internal constant ERC165_INTERFACE_ID = bytes4(0x01ffc9a7); - bytes4 internal constant DISPUTABLE_INTERFACE_ID = bytes4(0xce1f6de9); + bytes4 internal constant DISPUTABLE_INTERFACE_ID = bytes4(0x737c65f9); event AgreementSet(IAgreement indexed agreement); diff --git a/contracts/test/mocks/apps/disputable/DisputableAppMock.sol b/contracts/test/mocks/apps/disputable/DisputableAppMock.sol index acff258a8..4e8d10ba1 100644 --- a/contracts/test/mocks/apps/disputable/DisputableAppMock.sol +++ b/contracts/test/mocks/apps/disputable/DisputableAppMock.sol @@ -41,7 +41,6 @@ contract DisputableAppMock is DisputableAragonApp { iDisputable.onDisputableActionRejected.selector ^ iDisputable.onDisputableActionVoided.selector ^ iDisputable.getAgreement.selector ^ - iDisputable.getDisputableAction.selector ^ iDisputable.canChallenge.selector ^ iDisputable.canClose.selector ^ iDisputable.appId.selector; diff --git a/test/contracts/apps/disputable/disputable_app.js b/test/contracts/apps/disputable/disputable_app.js index c779eee5f..4f08896b9 100644 --- a/test/contracts/apps/disputable/disputable_app.js +++ b/test/contracts/apps/disputable/disputable_app.js @@ -14,7 +14,7 @@ contract('DisputableApp', ([_, owner, agreement, anotherAgreement, someone]) => let disputable, disputableBase, dao, acl const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000' - const DISPUTABLE_INTERFACE = '0xce1f6de9' + const DISPUTABLE_INTERFACE = '0x737c65f9' const ERC165_INTERFACE = '0x01ffc9a7' before('deploy DAO', async () => { From 91fd176868135a09527c3cb9fb3171e31624f27e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=9Fingen?= Date: Tue, 30 Jun 2020 14:09:05 +0200 Subject: [PATCH 6/6] disputable apps: Add ITransactionFeesOracle to Agreement settings --- contracts/apps/disputable/IAgreement.sol | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/contracts/apps/disputable/IAgreement.sol b/contracts/apps/disputable/IAgreement.sol index 333cb7a58..c91b56f63 100644 --- a/contracts/apps/disputable/IAgreement.sol +++ b/contracts/apps/disputable/IAgreement.sol @@ -7,6 +7,7 @@ pragma solidity ^0.4.24; import "../../acl/IACLOracle.sol"; import "../../lib/token/ERC20.sol"; import "../../lib/arbitration/IArbitrable.sol"; +import "../../lib/arbitration/ITransactionFeesOracle.sol"; contract IAgreement is IArbitrable, IACLOracle { @@ -61,7 +62,13 @@ contract IAgreement is IArbitrable, IACLOracle { function getCurrentSettingId() external view returns (uint256); - function getSetting(uint256 _settingId) external view returns (IArbitrator arbitrator, string title, bytes content); + function getSetting(uint256 _settingId) external view + returns ( + IArbitrator arbitrator, + ITransactionFeesOracle transactionFeesOracle, + string title, + bytes content + ); function getDisputableInfo(address _disputable) external view returns (bool registered, uint256 currentCollateralRequirementId);