Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OS-459 : Subgraph update to v1.3.0 #393

Merged
merged 5 commits into from
Jun 2, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions packages/contracts/test/upgrade/dao.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Rekard0 marked this conversation as resolved.
Show resolved Hide resolved
import {DAO, DAO__factory, ProtocolVersion__factory} from '../../typechain';

Expand All @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions packages/subgraph/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions packages/subgraph/manifest/subgraph.placeholder.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;

heueristik marked this conversation as resolved.
Show resolved Hide resolved
// Tally
let tally = proposal.value.value3;
proposalEntity.abstain = tally.abstain;
Expand Down
12 changes: 8 additions & 4 deletions packages/subgraph/src/packages/token/token-voting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions packages/subgraph/src/registries/daoRegistry.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down