diff --git a/packages/contracts/src/test/Migration.sol b/packages/contracts/src/test/Migration.sol index 15bf7188f..fdb3b14bf 100644 --- a/packages/contracts/src/test/Migration.sol +++ b/packages/contracts/src/test/Migration.sol @@ -47,3 +47,9 @@ import {MerkleMinter as MerkleMinter_v1_3_0} from "@aragon/osx-v1.3.0-rc0.2/plug import {MerkleDistributor as MerkleDistributor_v1_0_0} from "@aragon/osx-v1.0.1/plugins/token/MerkleDistributor.sol"; import {MerkleDistributor as MerkleDistributor_v1_3_0} from "@aragon/osx-v1.3.0-rc0.2/plugins/token/MerkleDistributor.sol"; + +import {GovernanceERC20 as GovernanceERC20_v1_0_0} from "@aragon/osx-v1.0.1/token/ERC20/governance/GovernanceERC20.sol"; +import {GovernanceERC20 as GovernanceERC20_v1_3_0} from "@aragon/osx-v1.3.0-rc0.2/token/ERC20/governance/GovernanceERC20.sol"; + +import {GovernanceWrappedERC20 as GovernanceWrappedERC20_v1_0_0} from "@aragon/osx-v1.0.1/token/ERC20/governance/GovernanceWrappedERC20.sol"; +import {GovernanceWrappedERC20 as GovernanceWrappedERC20_v1_3_0} from "@aragon/osx-v1.3.0-rc0.2/token/ERC20/governance/GovernanceWrappedERC20.sol"; diff --git a/packages/contracts/test/core/dao/dao.ts b/packages/contracts/test/core/dao/dao.ts index dbced7545..0bd8907ec 100644 --- a/packages/contracts/test/core/dao/dao.ts +++ b/packages/contracts/test/core/dao/dao.ts @@ -155,10 +155,6 @@ describe('DAO', function () { ]); }); - it('does not support the empty interface', async () => { - expect(await dao.supportsInterface('0xffffffff')).to.be.false; - }); - describe('initialize', async () => { it('reverts if trying to re-initialize', async () => { await expect( diff --git a/packages/contracts/test/interfaces.ts b/packages/contracts/test/interfaces.ts new file mode 100644 index 000000000..5c327d6f7 --- /dev/null +++ b/packages/contracts/test/interfaces.ts @@ -0,0 +1,216 @@ +import {expect} from 'chai'; + +import {getInterfaceID} from './test-utils/interfaces'; + +import { + // core + IDAO__factory, + IEIP4824__factory, + IPermissionCondition__factory, + IPlugin__factory, + IMembership__factory, + IProposal__factory, + // framework + IPluginRepo__factory, + IPluginSetup__factory, + // plugins + IMajorityVoting__factory, + IMultisig__factory, + IMerkleMinter__factory, + IMerkleDistributor__factory, + // token + IERC20MintableUpgradeable__factory, + IGovernanceWrappedERC20__factory, + // utils + IProtocolVersion__factory, +} from '../typechain'; + +import {IDAO__factory as IDAO_V1_0_0__factory} from '../typechain/@aragon/osx-v1.0.1/core/dao/IDAO.sol'; +import {IEIP4824__factory as IEIP4824_V1_0_0__factory} from '../typechain/@aragon/osx-v1.0.1/core/dao/IEIP4824.sol'; +import {IPermissionCondition__factory as IPermissionCondition_V1_0_0__factory} from '../typechain/@aragon/osx-v1.0.1/core/permission/IPermissionCondition.sol'; +import {IPlugin__factory as IPlugin_V1_0_0__factory} from '../typechain/@aragon/osx-v1.0.1/core/plugin/IPlugin.sol'; +import {IMembership__factory as IMembership_V1_0_0__factory} from '../typechain/@aragon/osx-v1.0.1/core/plugin/membership/IMembership.sol'; +import {IProposal__factory as IProposal_V1_0_0__factory} from '../typechain/@aragon/osx-v1.0.1/core/plugin/proposal/IProposal.sol'; + +import {IPluginRepo__factory as IPluginRepo_V1_0_0__factory} from '../typechain/@aragon/osx-v1.0.1/framework/plugin/repo/IPluginRepo.sol'; +import {IPluginSetup__factory as IPluginSetup_V1_0_0__factory} from '../typechain/@aragon/osx-v1.0.1/framework/plugin/setup/IPluginSetup.sol'; + +import {IMajorityVoting__factory as IMajorityVoting_V1_0_0__factory} from '../typechain/@aragon/osx-v1.0.1/plugins/governance/majority-voting/IMajorityVoting.sol'; +import {IMultisig__factory as IMultisig_V1_0_0__factory} from '../typechain/@aragon/osx-v1.0.1/plugins/governance/multisig/IMultisig.sol'; +import {IMerkleMinter__factory as IMerkleMinter_V1_0_0__factory} from '../typechain/@aragon/osx-v1.0.1/plugins/token/IMerkleMinter.sol'; +import {IMerkleDistributor__factory as IMerkleDistributor_V1_0_0__factory} from '../typechain/@aragon/osx-v1.0.1/plugins/token/IMerkleDistributor.sol'; + +import {IERC20MintableUpgradeable__factory as IERC20MintableUpgradeable_V1_0_0__factory} from '../typechain/@aragon/osx-v1.0.1/token/ERC20/IERC20MintableUpgradeable.sol'; +import {IGovernanceWrappedERC20__factory as IGovernanceWrappedERC20_V1_0_0__factory} from '../typechain/@aragon/osx-v1.0.1/token/ERC20/governance/IGovernanceWrappedERC20.sol'; // TODO: For some reason this file is missing. + +import {IProtocolVersion__factory as IProtocolVersion_V1_3_0__factory} from '../typechain/@aragon/osx-v1.3.0-rc0.2/utils/protocol/IProtocolVersion.sol'; + +describe('Interfaces', function () { + context('introduced in v1.0.0', function () { + describe('IDAO', function () { + it('has still the same interface ID', async () => { + const current = getInterfaceID(IDAO__factory.createInterface()); + const initial = getInterfaceID(IDAO_V1_0_0__factory.createInterface()); + expect(current).to.equal(initial); + }); + }); + + describe('IEIP4824', function () { + it('has still the same interface ID', async () => { + const current = getInterfaceID(IEIP4824__factory.createInterface()); + const initial = getInterfaceID( + IEIP4824_V1_0_0__factory.createInterface() + ); + expect(current).to.equal(initial); + }); + }); + + describe('IPermissionCondition', function () { + it('has still the same interface ID', async () => { + const current = getInterfaceID( + IPermissionCondition__factory.createInterface() + ); + const initial = getInterfaceID( + IPermissionCondition_V1_0_0__factory.createInterface() + ); + expect(current).to.equal(initial); + }); + }); + describe('IPlugin', function () { + it('has still the same interface ID', async () => { + const current = getInterfaceID(IPlugin__factory.createInterface()); + const initial = getInterfaceID( + IPlugin_V1_0_0__factory.createInterface() + ); + expect(current).to.equal(initial); + }); + }); + + describe('IMembership', function () { + it('has still the same interface ID', async () => { + const current = getInterfaceID(IMembership__factory.createInterface()); + const initial = getInterfaceID( + IMembership_V1_0_0__factory.createInterface() + ); + expect(current).to.equal(initial); + }); + }); + + describe('IProposal', function () { + it('has still the same interface ID', async () => { + const current = getInterfaceID(IProposal__factory.createInterface()); + const initial = getInterfaceID( + IProposal_V1_0_0__factory.createInterface() + ); + expect(current).to.equal(initial); + }); + }); + + describe('IPluginRepo', function () { + it('has still the same interface ID', async () => { + const current = getInterfaceID(IPluginRepo__factory.createInterface()); + const initial = getInterfaceID( + IPluginRepo_V1_0_0__factory.createInterface() + ); + expect(current).to.equal(initial); + }); + }); + + describe('IPluginSetup', function () { + it('has still the same interface ID', async () => { + const current = getInterfaceID(IPluginSetup__factory.createInterface()); + const initial = getInterfaceID( + IPluginSetup_V1_0_0__factory.createInterface() + ); + expect(current).to.equal(initial); + }); + }); + + // plugins + describe('IMajorityVoting', function () { + it('has still the same interface ID', async () => { + const current = getInterfaceID( + IMajorityVoting__factory.createInterface() + ); + const initial = getInterfaceID( + IMajorityVoting_V1_0_0__factory.createInterface() + ); + expect(current).to.equal(initial); + }); + }); + + describe('IMultisig', function () { + it('has still the same interface ID', async () => { + const current = getInterfaceID(IMultisig__factory.createInterface()); + const initial = getInterfaceID( + IMultisig_V1_0_0__factory.createInterface() + ); + expect(current).to.equal(initial); + }); + }); + + describe('IMerkleMinter', function () { + it('has still the same interface ID', async () => { + const current = getInterfaceID( + IMerkleMinter__factory.createInterface() + ); + const initial = getInterfaceID( + IMerkleMinter_V1_0_0__factory.createInterface() + ); + expect(current).to.equal(initial); + }); + }); + + describe('IMerkleDistributor', function () { + it('has still the same interface ID', async () => { + const current = getInterfaceID( + IMerkleDistributor__factory.createInterface() + ); + const initial = getInterfaceID( + IMerkleDistributor_V1_0_0__factory.createInterface() + ); + expect(current).to.equal(initial); + }); + }); + + // tokens + describe('IERC20MintableUpgradeable', function () { + it('has still the same interface ID', async () => { + const current = getInterfaceID( + IERC20MintableUpgradeable__factory.createInterface() + ); + const initial = getInterfaceID( + IERC20MintableUpgradeable_V1_0_0__factory.createInterface() + ); + expect(current).to.equal(initial); + }); + }); + + describe('IGovernanceWrappedERC20', function () { + it('has still the same interface ID', async () => { + const current = getInterfaceID( + IGovernanceWrappedERC20__factory.createInterface() + ); + const initial = getInterfaceID( + IGovernanceWrappedERC20_V1_0_0__factory.createInterface() + ); + expect(current).to.equal(initial); + }); + }); + }); + + // utils + context('introduced in v1.3.0', function () { + describe('IProtocolVersion', function () { + it('has still the same interface ID', async () => { + const current = getInterfaceID( + IProtocolVersion__factory.createInterface() + ); + const initial = getInterfaceID( + IProtocolVersion_V1_3_0__factory.createInterface() + ); + expect(current).to.equal(initial); + }); + }); + }); +}); diff --git a/packages/contracts/test/plugins/governance/admin/admin.ts b/packages/contracts/test/plugins/governance/admin/admin.ts index 2d3d0534e..df3f0a6fc 100644 --- a/packages/contracts/test/plugins/governance/admin/admin.ts +++ b/packages/contracts/test/plugins/governance/admin/admin.ts @@ -10,7 +10,9 @@ import { findEventTopicLog, } from '../../../../utils/event'; import {deployNewDAO} from '../../../test-utils/dao'; -import {getInterfaceID} from '../../../test-utils/interfaces'; +import {ADMIN_INTERFACE, getInterfaceID} from '../../../test-utils/interfaces'; +import {ADMIN_INTERFACE_ID} from '../../../../../subgraph/src/utils/constants'; + import {OZ_ERRORS} from '../../../test-utils/error'; import {toBytes32} from '../../../test-utils/voting'; import { @@ -33,11 +35,6 @@ const EXECUTE_PROPOSAL_PERMISSION_ID = ethers.utils.id( ); const EXECUTE_PERMISSION_ID = ethers.utils.id('EXECUTE_PERMISSION'); -export const adminInterface = new ethers.utils.Interface([ - 'function initialize(address)', - 'function executeProposal(bytes,tuple(address,uint256,bytes)[],uint256)', -]); - describe('Admin', function () { let signers: SignerWithAddress[]; let plugin: any; @@ -144,8 +141,9 @@ describe('Admin', function () { }); it('supports the `Admin` interface', async () => { - expect(await plugin.supportsInterface(getInterfaceID(adminInterface))).to - .be.true; + const iface = getInterfaceID(ADMIN_INTERFACE); + expect(iface).to.equal(ADMIN_INTERFACE_ID); // checks that it didn't change + expect(await plugin.supportsInterface(iface)).to.be.true; }); }); diff --git a/packages/contracts/test/plugins/governance/majority-voting/addresslist/addresslist-voting.ts b/packages/contracts/test/plugins/governance/majority-voting/addresslist/addresslist-voting.ts index a37499eb0..ce0055b69 100644 --- a/packages/contracts/test/plugins/governance/majority-voting/addresslist/addresslist-voting.ts +++ b/packages/contracts/test/plugins/governance/majority-voting/addresslist/addresslist-voting.ts @@ -50,7 +50,11 @@ import {deployNewDAO} from '../../../../test-utils/dao'; import {OZ_ERRORS} from '../../../../test-utils/error'; import {UPGRADE_PERMISSIONS} from '../../../../test-utils/permissions'; import {deployWithProxy} from '../../../../test-utils/proxy'; -import {getInterfaceID} from '../../../../test-utils/interfaces'; +import { + ADDRESSLIST_VOTING_INTERFACE, + getInterfaceID, +} from '../../../../test-utils/interfaces'; +import {ADDRESSLIST_VOTING_INTERFACE_ID} from '../../../../../../subgraph/src/utils/constants'; import { getProtocolVersion, @@ -63,12 +67,6 @@ import { } from '../../../../test-utils/protocol-version'; import {ExecutedEvent} from '../../../../../typechain/DAO'; -export const addresslistVotingInterface = new ethers.utils.Interface([ - 'function initialize(address,tuple(uint8,uint32,uint32,uint64,uint256),address[])', - 'function addAddresses(address[])', - 'function removeAddresses(address[])', -]); - describe('AddresslistVoting', function () { let signers: SignerWithAddress[]; let voting: AddresslistVoting; @@ -276,11 +274,9 @@ describe('AddresslistVoting', function () { }); it('supports the `AddresslistVoting` interface', async () => { - expect( - await voting.supportsInterface( - getInterfaceID(addresslistVotingInterface) - ) - ).to.be.true; + const iface = getInterfaceID(ADDRESSLIST_VOTING_INTERFACE); + expect(iface).to.equal(ADDRESSLIST_VOTING_INTERFACE_ID); // checks that it didn't change + expect(await voting.supportsInterface(iface)).to.be.true; }); }); diff --git a/packages/contracts/test/plugins/governance/majority-voting/token/token-voting.ts b/packages/contracts/test/plugins/governance/majority-voting/token/token-voting.ts index e16edf9a1..91aa105d1 100644 --- a/packages/contracts/test/plugins/governance/majority-voting/token/token-voting.ts +++ b/packages/contracts/test/plugins/governance/majority-voting/token/token-voting.ts @@ -50,7 +50,12 @@ import { import {deployNewDAO} from '../../../../test-utils/dao'; import {OZ_ERRORS} from '../../../../test-utils/error'; import {deployWithProxy} from '../../../../test-utils/proxy'; -import {getInterfaceID} from '../../../../test-utils/interfaces'; +import { + TOKEN_VOTING_INTERFACE, + getInterfaceID, +} from '../../../../test-utils/interfaces'; +import {TOKEN_VOTING_INTERFACE_ID} from '../../../../../../subgraph/src/utils/constants'; + import {UPGRADE_PERMISSIONS} from '../../../../test-utils/permissions'; import { getProtocolVersion, @@ -64,11 +69,6 @@ import { } from '../../../../test-utils/protocol-version'; import {ExecutedEvent} from '../../../../../typechain/DAO'; -export const tokenVotingInterface = new ethers.utils.Interface([ - 'function initialize(address,tuple(uint8,uint32,uint32,uint64,uint256),address)', - 'function getVotingToken()', -]); - describe('TokenVoting', function () { let signers: SignerWithAddress[]; let voting: TokenVoting; @@ -338,9 +338,9 @@ describe('TokenVoting', function () { }); it('supports the `TokenVoting` interface', async () => { - expect( - await voting.supportsInterface(getInterfaceID(tokenVotingInterface)) - ).to.be.true; + const iface = getInterfaceID(TOKEN_VOTING_INTERFACE); + expect(iface).to.equal(TOKEN_VOTING_INTERFACE_ID); // checks that it didn't change + expect(await voting.supportsInterface(iface)).to.be.true; }); }); diff --git a/packages/contracts/test/plugins/governance/multisig/multisig.ts b/packages/contracts/test/plugins/governance/multisig/multisig.ts index f6754621f..06303f533 100644 --- a/packages/contracts/test/plugins/governance/multisig/multisig.ts +++ b/packages/contracts/test/plugins/governance/multisig/multisig.ts @@ -44,7 +44,11 @@ import { } from '../../../test-utils/voting'; import {UPGRADE_PERMISSIONS} from '../../../test-utils/permissions'; import {deployWithProxy} from '../../../test-utils/proxy'; -import {getInterfaceID} from '../../../test-utils/interfaces'; +import { + MULTISIG_INTERFACE, + getInterfaceID, +} from '../../../test-utils/interfaces'; +import {MULTISIG_INTERFACE_ID} from '../../../../../subgraph/src/utils/constants'; import { getProtocolVersion, deployAndUpgradeFromToCheck, @@ -56,13 +60,6 @@ import { } from '../../../test-utils/protocol-version'; import {ExecutedEvent} from '../../../../typechain/DAO'; -export const multisigInterface = new ethers.utils.Interface([ - 'function initialize(address,address[],tuple(bool,uint16))', - 'function updateMultisigSettings(tuple(bool,uint16))', - 'function createProposal(bytes,tuple(address,uint256,bytes)[],uint256,bool,bool,uint64,uint64) ', - 'function getProposal(uint256)', -]); - export type MultisigSettings = { minApprovals: number; onlyListed: boolean; @@ -341,9 +338,9 @@ describe('Multisig', function () { }); it('supports the `Multisig` interface', async () => { - expect( - await multisig.supportsInterface(getInterfaceID(multisigInterface)) - ).to.be.true; + const iface = getInterfaceID(MULTISIG_INTERFACE); + expect(iface).to.equal(MULTISIG_INTERFACE_ID); // checks that it didn't change + expect(await multisig.supportsInterface(iface)).to.be.true; }); }); diff --git a/packages/contracts/test/test-utils/interfaces.ts b/packages/contracts/test/test-utils/interfaces.ts index 271280026..dbfb537dd 100644 --- a/packages/contracts/test/test-utils/interfaces.ts +++ b/packages/contracts/test/test-utils/interfaces.ts @@ -11,3 +11,26 @@ export function getInterfaceID( } return interfaceID.toHexString(); } + +export const ADMIN_INTERFACE = new ethers.utils.Interface([ + 'function initialize(address)', + 'function executeProposal(bytes,tuple(address,uint256,bytes)[],uint256)', +]); + +export const TOKEN_VOTING_INTERFACE = new ethers.utils.Interface([ + 'function initialize(address,tuple(uint8,uint32,uint32,uint64,uint256),address)', + 'function getVotingToken()', +]); + +export const ADDRESSLIST_VOTING_INTERFACE = new ethers.utils.Interface([ + 'function initialize(address,tuple(uint8,uint32,uint32,uint64,uint256),address[])', + 'function addAddresses(address[])', + 'function removeAddresses(address[])', +]); + +export const MULTISIG_INTERFACE = new ethers.utils.Interface([ + 'function initialize(address,address[],tuple(bool,uint16))', + 'function updateMultisigSettings(tuple(bool,uint16))', + 'function createProposal(bytes,tuple(address,uint256,bytes)[],uint256,bool,bool,uint64,uint64) ', + 'function getProposal(uint256)', +]); diff --git a/packages/contracts/test/token/erc20/governance-wrapped-erc20.ts b/packages/contracts/test/token/erc20/governance-wrapped-erc20.ts index a92693091..ebd3af014 100644 --- a/packages/contracts/test/token/erc20/governance-wrapped-erc20.ts +++ b/packages/contracts/test/token/erc20/governance-wrapped-erc20.ts @@ -8,6 +8,11 @@ import { GovernanceWrappedERC20, GovernanceWrappedERC20__factory, IERC165Upgradeable__factory, + IGovernanceWrappedERC20__factory, + IERC20Upgradeable__factory, + IERC20PermitUpgradeable__factory, + IVotesUpgradeable__factory, + IERC20MetadataUpgradeable__factory, } from '../../../typechain'; import {OZ_ERRORS} from '../../test-utils/error'; import {getInterfaceID} from '../../test-utils/interfaces'; @@ -120,33 +125,39 @@ describe('GovernanceWrappedERC20', function () { .be.true; }); - it('it supports all inherited interfaces', async () => { - await Promise.all( - [ - 'IGovernanceWrappedERC20', - 'IERC20Upgradeable', - 'IERC20PermitUpgradeable', - 'IVotesUpgradeable', - ].map(async interfaceName => { - const iface = new ethers.utils.Interface( - // @ts-ignore - (await hre.artifacts.readArtifact(interfaceName)).abi - ); - expect(await governanceToken.supportsInterface(getInterfaceID(iface))) - .to.be.true; - }) - ); + it('supports the `IGovernanceWrappedERC20` interface', async () => { + const iface = IGovernanceWrappedERC20__factory.createInterface(); + expect(await governanceToken.supportsInterface(getInterfaceID(iface))).to + .be.true; + }); + + it('supports the `IERC20Upgradeable` interface', async () => { + const iface = IERC20Upgradeable__factory.createInterface(); + expect(await governanceToken.supportsInterface(getInterfaceID(iface))).to + .be.true; + }); + + it('supports the `IERC20PermitUpgradeable` interface', async () => { + const iface = IERC20PermitUpgradeable__factory.createInterface(); + expect(await governanceToken.supportsInterface(getInterfaceID(iface))).to + .be.true; + }); + + it('supports the `IVotesUpgradeable` interface', async () => { + const iface = IVotesUpgradeable__factory.createInterface(); + expect(await governanceToken.supportsInterface(getInterfaceID(iface))).to + .be.true; + }); + + it('supports the `IERC20MetadataUpgradeable` interface', async () => { // We must check `IERC20MetadataUpgradeable` separately as it inherits from `IERC20Upgradeable` and we cannot get the isolated ABI. - const ierc20MetadataInterface = new ethers.utils.Interface([ + const iface = new ethers.utils.Interface([ 'function name()', 'function symbol()', 'function decimals()', ]); - expect( - await governanceToken.supportsInterface( - getInterfaceID(ierc20MetadataInterface) - ) - ).to.be.true; + expect(await governanceToken.supportsInterface(getInterfaceID(iface))).to + .be.true; }); }); diff --git a/packages/subgraph/src/plugin/utils.ts b/packages/subgraph/src/plugin/utils.ts index a2447dae3..2f416bb28 100644 --- a/packages/subgraph/src/plugin/utils.ts +++ b/packages/subgraph/src/plugin/utils.ts @@ -24,12 +24,13 @@ import { MultisigPlugin } from '../../generated/schema'; import { - TOKEN_VOTING_INTERFACE, - ADDRESSLIST_VOTING_INTERFACE, - ADMIN_INTERFACE, VOTING_MODES, - MULTISIG_INTERFACE + ADMIN_INTERFACE_ID, + TOKEN_VOTING_INTERFACE_ID, + ADDRESSLIST_VOTING_INTERFACE_ID, + MULTISIG_INTERFACE_ID } from '../utils/constants'; + import {supportsInterface} from '../utils/erc165'; import { fetchERC20, @@ -173,16 +174,16 @@ export function addPlugin(daoId: string, plugin: Address): void { let tokenVotingInterfaceSupported = supportsInterface( contract, - TOKEN_VOTING_INTERFACE + TOKEN_VOTING_INTERFACE_ID ); let addresslistInterfaceSupported = supportsInterface( contract, - ADDRESSLIST_VOTING_INTERFACE + ADDRESSLIST_VOTING_INTERFACE_ID ); - let adminInterfaceSupported = supportsInterface(contract, ADMIN_INTERFACE); + let adminInterfaceSupported = supportsInterface(contract, ADMIN_INTERFACE_ID); let multisigInterfaceSupported = supportsInterface( contract, - MULTISIG_INTERFACE + MULTISIG_INTERFACE_ID ); if (tokenVotingInterfaceSupported) { diff --git a/packages/subgraph/src/utils/constants.ts b/packages/subgraph/src/utils/constants.ts index 2b0ded6d9..c12ba6ac7 100644 --- a/packages/subgraph/src/utils/constants.ts +++ b/packages/subgraph/src/utils/constants.ts @@ -23,10 +23,10 @@ export const VOTING_MODE_INDEXES = new Map() .set('EarlyExecution', '1') .set('VoteReplacement', '2'); -export const TOKEN_VOTING_INTERFACE = '0x50eb001e'; -export const ADDRESSLIST_VOTING_INTERFACE = '0x5f21eb8b'; -export const ADMIN_INTERFACE = '0xa5793356'; -export const MULTISIG_INTERFACE = '0x8f852786'; -export const WRAPPED_ERC20_INTERFACE = '0x0f13099a'; +export const TOKEN_VOTING_INTERFACE_ID = '0x50eb001e'; +export const ADDRESSLIST_VOTING_INTERFACE_ID = '0x5f21eb8b'; +export const ADMIN_INTERFACE_ID = '0xa5793356'; +export const MULTISIG_INTERFACE_ID = '0x8f852786'; +export const GOVERNANCE_WRAPPED_ERC20_INTERFACE_ID = '0x0f13099a'; export const RATIO_BASE = '1000000'; // 10**6 diff --git a/packages/subgraph/src/utils/tokens/erc20.ts b/packages/subgraph/src/utils/tokens/erc20.ts index 5858a5f2f..835b9245a 100644 --- a/packages/subgraph/src/utils/tokens/erc20.ts +++ b/packages/subgraph/src/utils/tokens/erc20.ts @@ -9,14 +9,14 @@ import {ERC20} from '../../../generated/templates/DaoTemplateV1_0_0/ERC20'; import {GovernanceWrappedERC20} from '../../../generated/templates/TokenVoting/GovernanceWrappedERC20'; import {ERC20_transfer, ERC20_transferFrom, getTransferId} from './common'; import {supportsInterface} from '../erc165'; -import {WRAPPED_ERC20_INTERFACE} from '../constants'; +import {GOVERNANCE_WRAPPED_ERC20_INTERFACE_ID} from '../../utils/constants'; export function supportsERC20Wrapped(token: Address): bool { // Double check that it's ERC20Wrapped by calling supportsInterface checks. let erc20Wrapped = GovernanceWrappedERC20.bind(token); let introspection_wrapped_erc20 = supportsInterface( erc20Wrapped, - WRAPPED_ERC20_INTERFACE + GOVERNANCE_WRAPPED_ERC20_INTERFACE_ID ); // GovernanceWrappedERC20 if (!introspection_wrapped_erc20) { return false; diff --git a/packages/subgraph/tests/plugin/pluginSetupProcessor.test.ts b/packages/subgraph/tests/plugin/pluginSetupProcessor.test.ts index a02043e33..27c58f3f5 100644 --- a/packages/subgraph/tests/plugin/pluginSetupProcessor.test.ts +++ b/packages/subgraph/tests/plugin/pluginSetupProcessor.test.ts @@ -32,11 +32,12 @@ import {PluginPreparation} from '../../generated/schema'; import {Address, BigInt, Bytes, ethereum} from '@graphprotocol/graph-ts'; import {getSupportsInterface} from '../../tests/dao/utils'; import { - ADDRESSLIST_VOTING_INTERFACE, - ADMIN_INTERFACE, - MULTISIG_INTERFACE, - TOKEN_VOTING_INTERFACE + ADMIN_INTERFACE_ID, + TOKEN_VOTING_INTERFACE_ID, + ADDRESSLIST_VOTING_INTERFACE_ID, + MULTISIG_INTERFACE_ID } from '../../src/utils/constants'; + import { getPluginInstallationId, PERMISSION_OPERATIONS @@ -78,10 +79,10 @@ test('InstallationPrepared event', function() { ] ]; - getSupportsInterface(plugin, TOKEN_VOTING_INTERFACE, false); - getSupportsInterface(plugin, ADDRESSLIST_VOTING_INTERFACE, false); - getSupportsInterface(plugin, ADMIN_INTERFACE, false); - getSupportsInterface(plugin, MULTISIG_INTERFACE, false); + getSupportsInterface(plugin, TOKEN_VOTING_INTERFACE_ID, false); + getSupportsInterface(plugin, ADDRESSLIST_VOTING_INTERFACE_ID, false); + getSupportsInterface(plugin, ADMIN_INTERFACE_ID, false); + getSupportsInterface(plugin, MULTISIG_INTERFACE_ID, false); let event = createInstallationPreparedEvent( ADDRESS_THREE, @@ -473,10 +474,10 @@ test('UpdateApplied event', function() { let installationIdString = installationId.toHexString(); let preparationId = `${installationIdString}_${setupId}`; - getSupportsInterface(plugin, TOKEN_VOTING_INTERFACE, false); - getSupportsInterface(plugin, ADDRESSLIST_VOTING_INTERFACE, false); - getSupportsInterface(plugin, ADMIN_INTERFACE, false); - getSupportsInterface(plugin, MULTISIG_INTERFACE, false); + getSupportsInterface(plugin, TOKEN_VOTING_INTERFACE_ID, false); + getSupportsInterface(plugin, ADDRESSLIST_VOTING_INTERFACE_ID, false); + getSupportsInterface(plugin, ADMIN_INTERFACE_ID, false); + getSupportsInterface(plugin, MULTISIG_INTERFACE_ID, false); let event = createUpdateAppliedEvent( dao, diff --git a/packages/subgraph/tests/token/token-voting.test.ts b/packages/subgraph/tests/token/token-voting.test.ts index b9827fddb..d729d3df4 100644 --- a/packages/subgraph/tests/token/token-voting.test.ts +++ b/packages/subgraph/tests/token/token-voting.test.ts @@ -8,7 +8,8 @@ import { _handleProposalCreated, handleMembershipContractAnnounced } from '../../src/packages/token/token-voting'; -import {VOTING_MODES, WRAPPED_ERC20_INTERFACE} from '../../src/utils/constants'; +import {VOTING_MODES} from '../../src/utils/constants'; +import {GOVERNANCE_WRAPPED_ERC20_INTERFACE_ID} from '../../src/utils/constants'; import { DAO_TOKEN_ADDRESS, STRING_DATA, @@ -228,7 +229,10 @@ describe('handleMembershipContractAnnounced', () => { let erc20Contract = new ExtendedERC20Contract().withDefaultValues(); erc20Contract.mockCall_createTokenCalls(ERC20_AMOUNT_FULL); erc20Contract.mockCall_balanceOf(erc20Contract.id, ERC20_AMOUNT_FULL); - erc20Contract.mockCall_supportsInterface(WRAPPED_ERC20_INTERFACE, false); + erc20Contract.mockCall_supportsInterface( + GOVERNANCE_WRAPPED_ERC20_INTERFACE_ID, + false + ); erc20Contract.mockCall_supportsInterface('ffffffff', false); tokenVotingPlugin.token = erc20Contract.id; @@ -252,7 +256,10 @@ describe('handleMembershipContractAnnounced', () => { let erc20WrappedContract = new ExtendedERC20WrapperContract().withDefaultValues(); erc20Contract.mockCall_createTokenCalls(ERC20_AMOUNT_FULL); erc20Contract.mockCall_balanceOf(erc20Contract.id, ERC20_AMOUNT_FULL); - erc20Contract.mockCall_supportsInterface(WRAPPED_ERC20_INTERFACE, false); + erc20Contract.mockCall_supportsInterface( + GOVERNANCE_WRAPPED_ERC20_INTERFACE_ID, + false + ); erc20Contract.mockCall_supportsInterface('ffffffff', false); erc20WrappedContract.mockCall_createTokenCalls(ERC20_AMOUNT_FULL); @@ -261,7 +268,7 @@ describe('handleMembershipContractAnnounced', () => { ERC20_AMOUNT_FULL ); erc20WrappedContract.mockCall_supportsInterface( - WRAPPED_ERC20_INTERFACE, + GOVERNANCE_WRAPPED_ERC20_INTERFACE_ID, true ); erc20WrappedContract.mockCall_supportsInterface('ffffffff', false);