Skip to content

Commit

Permalink
OS-459 : Subgraph update to v1.3.0 (#393)
Browse files Browse the repository at this point in the history
* rename 120 to 130

* fix dates

* update change log

* revert contracts test (renaming mistake)

* remove unnecessary  log
  • Loading branch information
Rekard0 authored Jun 2, 2023
1 parent d298ad9 commit 787d9df
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 16 deletions.
3 changes: 0 additions & 3 deletions packages/contracts/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,13 @@ 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.
- Added `allowFailureMap` to `IDAO.Executed` event.

### 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.
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;

// 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

0 comments on commit 787d9df

Please sign in to comment.