From f56eab63398e1ef413ac6c97b33c5504715fb89d Mon Sep 17 00:00:00 2001 From: Rekard0 <5880388+Rekard0@users.noreply.github.com> Date: Wed, 31 May 2023 14:25:53 +0200 Subject: [PATCH 1/5] rename 120 to 130 --- packages/contracts/test/upgrade/dao.ts | 16 ++++++++-------- .../subgraph/manifest/subgraph.placeholder.yaml | 4 ++-- .../src/dao/{dao_v1_2_0.ts => dao_v1_3_0.ts} | 2 +- packages/subgraph/src/registries/daoRegistry.ts | 4 ++-- .../{dao_v1_2_0.test.ts => dao_v1_3_0.test.ts} | 4 ++-- 5 files changed, 15 insertions(+), 15 deletions(-) rename packages/subgraph/src/dao/{dao_v1_2_0.ts => dao_v1_3_0.ts} (95%) rename packages/subgraph/tests/dao/{dao_v1_2_0.test.ts => dao_v1_3_0.test.ts} (99%) diff --git a/packages/contracts/test/upgrade/dao.ts b/packages/contracts/test/upgrade/dao.ts index 3104b09bb..c031cf50e 100644 --- a/packages/contracts/test/upgrade/dao.ts +++ b/packages/contracts/test/upgrade/dao.ts @@ -7,8 +7,8 @@ import { DAO__factory as DAO_V1_0_0__factory, } from '../../typechain/osx-versions/v1_0_0/contracts/core/dao/DAO.sol'; import { - DAO as DAO_V1_2_0, - DAO__factory as DAO_V1_2_0__factory, + DAO as DAO_V1_3_0, + DAO__factory as DAO_V1_3_0__factory, } from '../../typechain/osx-versions/v1_2_0/contracts/core/dao/DAO.sol'; import {DAO, DAO__factory, ProtocolVersion__factory} from '../../typechain'; @@ -21,11 +21,11 @@ import {getInterfaceID} from '../test-utils/interfaces'; let signers: SignerWithAddress[]; let DAO_V1_0_0: DAO_V1_0_0__factory; -let DAO_V1_2_0: DAO_V1_2_0__factory; +let DAO_V1_3_0: DAO_V1_3_0__factory; let DAO_Current: DAO__factory; let daoV100Proxy: DAO_V1_0_0; -let daoV120Proxy: DAO_V1_2_0; +let daoV120Proxy: DAO_V1_3_0; let daoV100Implementation: string; let daoV120Implementation: string; @@ -46,7 +46,7 @@ describe('DAO Upgrade', function () { // We don't use the typchain here but directly grab the artifacts. This will be changed in an upcoming PR again. DAO_V1_0_0 = new DAO_V1_0_0__factory(signers[0]); - DAO_V1_2_0 = new DAO_V1_2_0__factory(signers[0]); + DAO_V1_3_0 = new DAO_V1_3_0__factory(signers[0]); DAO_Current = new DAO__factory(signers[0]); // Deploy the v1.3.0 implementation @@ -262,7 +262,7 @@ describe('DAO Upgrade', function () { context(`v1.2.0 to v1.3.0`, function () { beforeEach(async function () { - daoV120Proxy = await deployWithProxy(DAO_V1_2_0); + daoV120Proxy = await deployWithProxy(DAO_V1_3_0); await daoV120Proxy.initialize( DUMMY_METADATA, signers[0].address, @@ -303,7 +303,7 @@ describe('DAO Upgrade', function () { // Check the emitted implementation. const emittedImplementation = ( - await findEventTopicLog(upgradeTx, DAO_V1_2_0.interface, 'Upgraded') + await findEventTopicLog(upgradeTx, DAO_V1_3_0.interface, 'Upgraded') ).args.implementation; expect(emittedImplementation).to.equal(daoCurrentImplementaion.address); @@ -486,7 +486,7 @@ describe('DAO Upgrade', function () { ); // prepare v1.2.0 - daoV120Proxy = await deployWithProxy(DAO_V1_2_0); + daoV120Proxy = await deployWithProxy(DAO_V1_3_0); await daoV120Proxy.initialize( DUMMY_METADATA, signers[0].address, diff --git a/packages/subgraph/manifest/subgraph.placeholder.yaml b/packages/subgraph/manifest/subgraph.placeholder.yaml index 951a3074e..75793e3a1 100644 --- a/packages/subgraph/manifest/subgraph.placeholder.yaml +++ b/packages/subgraph/manifest/subgraph.placeholder.yaml @@ -142,7 +142,7 @@ templates: handler: handleSignatureValidatorSet - event: NewURI(string) handler: handleNewURI - - name: DaoTemplateV1_2_0 + - name: DaoTemplateV1_3_0 kind: ethereum/contract network: {{network}} source: @@ -151,7 +151,7 @@ templates: kind: ethereum/events apiVersion: 0.0.5 language: wasm/assemblyscript - file: ./src/dao/dao_v1_2_0.ts + file: ./src/dao/dao_v1_3_0.ts entities: - Dao abis: diff --git a/packages/subgraph/src/dao/dao_v1_2_0.ts b/packages/subgraph/src/dao/dao_v1_3_0.ts similarity index 95% rename from packages/subgraph/src/dao/dao_v1_2_0.ts rename to packages/subgraph/src/dao/dao_v1_3_0.ts index 0cc6a90a4..e362a40dc 100644 --- a/packages/subgraph/src/dao/dao_v1_2_0.ts +++ b/packages/subgraph/src/dao/dao_v1_3_0.ts @@ -2,7 +2,7 @@ import {TransactionActionsProposal} from '../../generated/schema'; import { Executed, ExecutedActionsStruct -} from '../../generated/templates/DaoTemplateV1_2_0/DAO'; +} from '../../generated/templates/DaoTemplateV1_3_0/DAO'; import {handleAction} from './utils'; export function handleExecuted(event: Executed): void { diff --git a/packages/subgraph/src/registries/daoRegistry.ts b/packages/subgraph/src/registries/daoRegistry.ts index 219a08965..d5c993c80 100644 --- a/packages/subgraph/src/registries/daoRegistry.ts +++ b/packages/subgraph/src/registries/daoRegistry.ts @@ -1,5 +1,5 @@ import {DAORegistered} from '../../generated/DAORegistry/DAORegistry'; -import {DaoTemplateV1_0_0, DaoTemplateV1_2_0} from '../../generated/templates'; +import {DaoTemplateV1_0_0, DaoTemplateV1_3_0} from '../../generated/templates'; import {Dao} from '../../generated/schema'; import {dataSource} from '@graphprotocol/graph-ts'; @@ -22,7 +22,7 @@ export function handleDAORegistered(event: DAORegistered): void { // subscribe to templates DaoTemplateV1_0_0.create(event.params.dao); - DaoTemplateV1_2_0.create(event.params.dao); + DaoTemplateV1_3_0.create(event.params.dao); entity.save(); } diff --git a/packages/subgraph/tests/dao/dao_v1_2_0.test.ts b/packages/subgraph/tests/dao/dao_v1_3_0.test.ts similarity index 99% rename from packages/subgraph/tests/dao/dao_v1_2_0.test.ts rename to packages/subgraph/tests/dao/dao_v1_3_0.test.ts index 5708451d8..221da6f51 100644 --- a/packages/subgraph/tests/dao/dao_v1_2_0.test.ts +++ b/packages/subgraph/tests/dao/dao_v1_3_0.test.ts @@ -13,8 +13,8 @@ import { Action, ERC721Balance } from '../../generated/schema'; -import {Executed} from '../../generated/templates/DaoTemplateV1_2_0/DAO'; -import {handleExecuted} from '../../src/dao/dao_v1_2_0'; +import {Executed} from '../../generated/templates/DaoTemplateV1_3_0/DAO'; +import {handleExecuted} from '../../src/dao/dao_v1_3_0'; import { ERC20_transfer, getTransferId, From 0a0e98594de40c13ae2341083c5324eaef900796 Mon Sep 17 00:00:00 2001 From: Rekard0 <5880388+Rekard0@users.noreply.github.com> Date: Wed, 31 May 2023 15:08:23 +0200 Subject: [PATCH 2/5] fix dates --- .../src/packages/addresslist/addresslist-voting.ts | 7 +++++-- packages/subgraph/src/packages/token/token-voting.ts | 12 ++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/packages/subgraph/src/packages/addresslist/addresslist-voting.ts b/packages/subgraph/src/packages/addresslist/addresslist-voting.ts index 99dae5fd9..0fd543684 100644 --- a/packages/subgraph/src/packages/addresslist/addresslist-voting.ts +++ b/packages/subgraph/src/packages/addresslist/addresslist-voting.ts @@ -44,8 +44,6 @@ export function _handleProposalCreated( proposalEntity.metadata = metadata; proposalEntity.createdAt = event.block.timestamp; proposalEntity.creationBlockNumber = event.block.number; - proposalEntity.startDate = event.params.startDate; - proposalEntity.endDate = event.params.endDate; proposalEntity.allowFailureMap = event.params.allowFailureMap; proposalEntity.potentiallyExecutable = false; @@ -63,6 +61,11 @@ export function _handleProposalCreated( proposalEntity.snapshotBlock = parameters.snapshotBlock; proposalEntity.minVotingPower = parameters.minVotingPower; + // Get the dates from `parameters` returned from `getProposal()`, + // so all the dates are correct in both build 1 & 2 + proposalEntity.startDate = parameters.startDate; + proposalEntity.endDate = parameters.endDate; + // Tally let tally = proposal.value.value3; proposalEntity.abstain = tally.abstain; diff --git a/packages/subgraph/src/packages/token/token-voting.ts b/packages/subgraph/src/packages/token/token-voting.ts index e3f8abc02..a8456979f 100644 --- a/packages/subgraph/src/packages/token/token-voting.ts +++ b/packages/subgraph/src/packages/token/token-voting.ts @@ -40,19 +40,18 @@ export function _handleProposalCreated( daoId: string, metadata: string ): void { + let pluginAddress = event.address; let pluginProposalId = event.params.proposalId; - let proposalId = getProposalId(event.address, pluginProposalId); + let proposalId = getProposalId(pluginAddress, pluginProposalId); let proposalEntity = new TokenVotingProposal(proposalId); proposalEntity.dao = daoId; - proposalEntity.plugin = event.address.toHexString(); + proposalEntity.plugin = pluginAddress.toHexString(); proposalEntity.pluginProposalId = pluginProposalId; proposalEntity.creator = event.params.creator; proposalEntity.metadata = metadata; proposalEntity.createdAt = event.block.timestamp; proposalEntity.creationBlockNumber = event.block.number; - proposalEntity.startDate = event.params.startDate; - proposalEntity.endDate = event.params.endDate; proposalEntity.allowFailureMap = event.params.allowFailureMap; proposalEntity.potentiallyExecutable = false; @@ -70,6 +69,11 @@ export function _handleProposalCreated( proposalEntity.snapshotBlock = parameters.snapshotBlock; proposalEntity.minVotingPower = parameters.minVotingPower; + // Get the dates from `parameters` returned from `getProposal()`, + // so all the dates are correct in both build 1 & 2 + proposalEntity.startDate = parameters.startDate; + proposalEntity.endDate = parameters.endDate; + // Tally let tally = proposal.value.value3; proposalEntity.abstain = tally.abstain; From 6d66a39a15b336ba7662f13963b2be106bc2a023 Mon Sep 17 00:00:00 2001 From: Rekard0 <5880388+Rekard0@users.noreply.github.com> Date: Wed, 31 May 2023 15:16:05 +0200 Subject: [PATCH 3/5] update change log --- packages/subgraph/CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/subgraph/CHANGELOG.md b/packages/subgraph/CHANGELOG.md index 8d3c910dc..c937f2db9 100644 --- a/packages/subgraph/CHANGELOG.md +++ b/packages/subgraph/CHANGELOG.md @@ -15,6 +15,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- Renamed handling updates from v1.2.0 to v1.3.0 +- Fixed start & end date issue by indexing from `getProposal()` instead of the event. - BREAKING: DAO's plugins attribute derive from `PluginInstallation` instead of `IPlugin`. - BREAKING: Changed attribute of `proposalId` in all proposal entities to `pluginProposalId` - Supports now multiple `DAORegistries`, `PluginRepoRegistries` and `PluginSetupProcessors` as datasources. From fdf5291d762c856d3928dfe601d3ab365d78124e Mon Sep 17 00:00:00 2001 From: Rekard0 <5880388+Rekard0@users.noreply.github.com> Date: Wed, 31 May 2023 16:05:25 +0200 Subject: [PATCH 4/5] revert contracts test (renaming mistake) --- packages/contracts/test/upgrade/dao.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/contracts/test/upgrade/dao.ts b/packages/contracts/test/upgrade/dao.ts index c031cf50e..3104b09bb 100644 --- a/packages/contracts/test/upgrade/dao.ts +++ b/packages/contracts/test/upgrade/dao.ts @@ -7,8 +7,8 @@ import { DAO__factory as DAO_V1_0_0__factory, } from '../../typechain/osx-versions/v1_0_0/contracts/core/dao/DAO.sol'; import { - DAO as DAO_V1_3_0, - DAO__factory as DAO_V1_3_0__factory, + DAO as DAO_V1_2_0, + DAO__factory as DAO_V1_2_0__factory, } from '../../typechain/osx-versions/v1_2_0/contracts/core/dao/DAO.sol'; import {DAO, DAO__factory, ProtocolVersion__factory} from '../../typechain'; @@ -21,11 +21,11 @@ import {getInterfaceID} from '../test-utils/interfaces'; let signers: SignerWithAddress[]; let DAO_V1_0_0: DAO_V1_0_0__factory; -let DAO_V1_3_0: DAO_V1_3_0__factory; +let DAO_V1_2_0: DAO_V1_2_0__factory; let DAO_Current: DAO__factory; let daoV100Proxy: DAO_V1_0_0; -let daoV120Proxy: DAO_V1_3_0; +let daoV120Proxy: DAO_V1_2_0; let daoV100Implementation: string; let daoV120Implementation: string; @@ -46,7 +46,7 @@ describe('DAO Upgrade', function () { // We don't use the typchain here but directly grab the artifacts. This will be changed in an upcoming PR again. DAO_V1_0_0 = new DAO_V1_0_0__factory(signers[0]); - DAO_V1_3_0 = new DAO_V1_3_0__factory(signers[0]); + DAO_V1_2_0 = new DAO_V1_2_0__factory(signers[0]); DAO_Current = new DAO__factory(signers[0]); // Deploy the v1.3.0 implementation @@ -262,7 +262,7 @@ describe('DAO Upgrade', function () { context(`v1.2.0 to v1.3.0`, function () { beforeEach(async function () { - daoV120Proxy = await deployWithProxy(DAO_V1_3_0); + daoV120Proxy = await deployWithProxy(DAO_V1_2_0); await daoV120Proxy.initialize( DUMMY_METADATA, signers[0].address, @@ -303,7 +303,7 @@ describe('DAO Upgrade', function () { // Check the emitted implementation. const emittedImplementation = ( - await findEventTopicLog(upgradeTx, DAO_V1_3_0.interface, 'Upgraded') + await findEventTopicLog(upgradeTx, DAO_V1_2_0.interface, 'Upgraded') ).args.implementation; expect(emittedImplementation).to.equal(daoCurrentImplementaion.address); @@ -486,7 +486,7 @@ describe('DAO Upgrade', function () { ); // prepare v1.2.0 - daoV120Proxy = await deployWithProxy(DAO_V1_3_0); + daoV120Proxy = await deployWithProxy(DAO_V1_2_0); await daoV120Proxy.initialize( DUMMY_METADATA, signers[0].address, From 8c171e054f98f30dbc1f3d0022127eed9a9605a2 Mon Sep 17 00:00:00 2001 From: Rekard0 <5880388+Rekard0@users.noreply.github.com> Date: Fri, 2 Jun 2023 11:09:15 +0200 Subject: [PATCH 5/5] remove unnecessary log --- packages/contracts/CHANGELOG.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/contracts/CHANGELOG.md b/packages/contracts/CHANGELOG.md index e8a994884..34793becc 100644 --- a/packages/contracts/CHANGELOG.md +++ b/packages/contracts/CHANGELOG.md @@ -9,8 +9,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- Added `initializeFork`, `initializeDeploymentFixture` and `initForkAndFixture` utility functions to `test-utils`. -- Added `UpdateInfo`, and `TestingFork` types, and extended `HardhatRuntimeEnvironment`. - Inherit `ProtocolVersion` and `ERC165` in `DAOFactory`. - Inherit `ProtocolVersion` in `DAO`. - Added a `nonReentrant` modifier to the `execute` function in the `DAO` contract. @@ -18,7 +16,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed -- Extended `getContractAddress` functionality to import addresses from osx-versions if a fork has initiated. - Fixed logic bug in the `TokenVoting` and `AddresslistVoting` implementations that caused the `createProposal` function to emit the unvalidated `_startDate` and `_endDate` input arguments (that both can be zero) in the `ProposalCreated` event instead of the validated ones. - Changed the `createProposal` functions in `Multisig` to allow creating proposals when the `_msgSender()` is listed in the current block. - Changed the `createProposal` functions in `AddresslistVoting` to allow creating proposals when the `_msgSender()` is listed in the current block.