-
Notifications
You must be signed in to change notification settings - Fork 245
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add IAragonApp * Add Aragon App interface id Refactor ERC-165 related inheritance. * IAragonApp interface: move it up to AragonApp (out of AppStorage) * disputable: move interface id helpers to proper mocks * disputable: Move supportsInterface from interface to implementation * Update contracts/apps/disputable/IDisputable.sol Co-authored-by: Brett Sun <[email protected]> * IAragonApp interface: move constant from implementation to interface * IAragonApp interface: add tests for AragonApp * disputable: move supportsInterface from interface to implementation * disputable: Fix supportsInterface after merge in mock contract Co-authored-by: Brett Sun <[email protected]>
- Loading branch information
Showing
13 changed files
with
155 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
pragma solidity ^0.4.24; | ||
|
||
import "../kernel/IKernel.sol"; | ||
|
||
|
||
contract IAragonApp { | ||
// Includes appId and kernel methods: | ||
bytes4 internal constant ARAGON_APP_INTERFACE_ID = bytes4(0x54053e6c); | ||
|
||
function kernel() public view returns (IKernel); | ||
function appId() public view returns (bytes32); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
pragma solidity 0.4.24; | ||
|
||
import "../../../apps/AragonApp.sol"; | ||
|
||
|
||
contract AragonAppMock is AragonApp { | ||
bytes4 public constant ARAGON_APP_INTERFACE = ARAGON_APP_INTERFACE_ID; | ||
|
||
function initialize() external { | ||
initialized(); | ||
} | ||
|
||
function interfaceID() external pure returns (bytes4) { | ||
IAragonApp iAragonApp; | ||
return iAragonApp.kernel.selector ^ | ||
iAragonApp.appId.selector; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
pragma solidity 0.4.24; | ||
|
||
import "../../../../lib/standards/ERC165.sol"; | ||
|
||
|
||
contract ERC165Mock is ERC165 { | ||
bytes4 public constant ERC165_INTERFACE = ERC165_INTERFACE_ID; | ||
|
||
function interfaceID() external pure returns (bytes4) { | ||
ERC165 erc165; | ||
return erc165.supportsInterface.selector; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
const { getEventArgument } = require('../../helpers/events') | ||
const { getNewProxyAddress } = require('../../helpers/events') | ||
|
||
const ACL = artifacts.require('ACL') | ||
const Kernel = artifacts.require('Kernel') | ||
const DAOFactory = artifacts.require('DAOFactory') | ||
const AragonApp = artifacts.require('AragonAppMock') | ||
const ERC165 = artifacts.require('ERC165Mock') | ||
const EVMScriptRegistryFactory = artifacts.require('EVMScriptRegistryFactory') | ||
|
||
contract('AragonApp', ([_, owner, agreement, anotherAgreement, someone]) => { | ||
let aragonApp | ||
|
||
const ARAGON_APP_INTERFACE = '0x54053e6c' | ||
const ERC165_INTERFACE = '0x01ffc9a7' | ||
|
||
before('deploy DAO and install aragon app', async () => { | ||
const kernelBase = await Kernel.new(true) | ||
const aclBase = await ACL.new() | ||
const registryFactory = await EVMScriptRegistryFactory.new() | ||
const daoFact = await DAOFactory.new(kernelBase.address, aclBase.address, registryFactory.address) | ||
|
||
const receiptDao = await daoFact.newDAO(owner) | ||
dao = await Kernel.at(getEventArgument(receiptDao, 'DeployDAO', 'dao')) | ||
acl = await ACL.at(await dao.acl()) | ||
const aragonAppBase = await AragonApp.new() | ||
|
||
const APP_MANAGER_ROLE = await kernelBase.APP_MANAGER_ROLE() | ||
await acl.createPermission(owner, dao.address, APP_MANAGER_ROLE, owner, { from: owner }) | ||
const initializeData = aragonAppBase.contract.initialize.getData() | ||
const receiptInstance = await dao.newAppInstance('0x1234', aragonAppBase.address, initializeData, false, { from: owner }) | ||
aragonApp = await AragonApp.at(getNewProxyAddress(receiptInstance)) | ||
}) | ||
|
||
describe('supportsInterface', () => { | ||
it('supports ERC165', async () => { | ||
const erc165 = await ERC165.new() | ||
assert.isTrue(await aragonApp.supportsInterface(ERC165_INTERFACE), 'does not support ERC165') | ||
|
||
assert.equal(await erc165.interfaceID(), ERC165_INTERFACE, 'ERC165 interface ID does not match') | ||
assert.equal(await erc165.ERC165_INTERFACE(), ERC165_INTERFACE, 'ERC165 interface ID does not match') | ||
}) | ||
|
||
it('supports Aragon App interface', async () => { | ||
const aragonApp = await AragonApp.new() | ||
assert.isTrue(await aragonApp.supportsInterface(ARAGON_APP_INTERFACE), 'does not support Aragon App interface') | ||
|
||
assert.equal(await aragonApp.interfaceID(), ARAGON_APP_INTERFACE, 'Aragon App interface ID does not match') | ||
assert.equal(await aragonApp.ARAGON_APP_INTERFACE(), ARAGON_APP_INTERFACE, 'Aragon App interface ID does not match') | ||
}) | ||
|
||
it('does not support 0xffffffff', async () => { | ||
assert.isFalse(await aragonApp.supportsInterface('0xffffffff'), 'should not support 0xffffffff') | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters