Skip to content

Commit

Permalink
ProposalSupport should not be immutable (#47)
Browse files Browse the repository at this point in the history
* ProposalSupport should not be immutable

* add Changelog entry
  • Loading branch information
Amxx authored Jan 30, 2023
1 parent 0d6b77a commit 11c9ffe
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 10 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

### Unreleased
* `Governor`: fix bug caused by duplicate write of immutable entity `ProposalSupport` ([#47](https://github.com/OpenZeppelin/openzeppelin-subgraphs/pull/47))

### 0.1.8-5 (2022-07-29)
* `AccessControl`: fix bug caused by duplicate write of immutable entity `AccessControl` ([#38](https://github.com/OpenZeppelin/openzeppelin-subgraphs/pull/38))

Expand Down
2 changes: 1 addition & 1 deletion generated/all.schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ type ProposalCall @entity(immutable: true) {
signature: String!
calldata: Bytes!
}
type ProposalSupport @entity(immutable: true) {
type ProposalSupport @entity {
id: ID!
proposal: Proposal!
support: Int!
Expand Down
2 changes: 1 addition & 1 deletion generated/governor.schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ type ProposalCall @entity(immutable: true) {
signature: String!
calldata: Bytes!
}
type ProposalSupport @entity(immutable: true) {
type ProposalSupport @entity {
id: ID!
proposal: Proposal!
support: Int!
Expand Down
1 change: 0 additions & 1 deletion src/datasources/governor.gql.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
]
},{
"name": "ProposalSupport",
"immutable": true,
"fields": [
{ "name": "proposal", "type": "Proposal!" },
{ "name": "support", "type": "Int!" },
Expand Down
1 change: 0 additions & 1 deletion src/datasources/governor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
} from '../../generated/schema'

import {
Governor as GovernorContract,
ProposalCreated as ProposalCreatedEvent,
ProposalQueued as ProposalQueuedEvent,
ProposalExecuted as ProposalExecutedEvent,
Expand Down
16 changes: 10 additions & 6 deletions src/fetch/governor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,16 @@ export function fetchProposal(contract: Governor, proposalId: BigInt): Proposal
let proposal = Proposal.load(id)

if (proposal == null) {
proposal = new Proposal(id)
proposal.governor = contract.id
proposal.proposalId = proposalId
proposal.canceled = false
proposal.queued = false
proposal.executed = false
proposal = new Proposal(id)
proposal.governor = contract.id
proposal.proposalId = proposalId
proposal.proposer = Address.zero()
proposal.startBlock = BigInt.zero()
proposal.endBlock = BigInt.zero()
proposal.description = ""
proposal.canceled = false
proposal.queued = false
proposal.executed = false
}

return proposal as Proposal
Expand Down

0 comments on commit 11c9ffe

Please sign in to comment.