Skip to content

Commit

Permalink
remove succeeded attribute of Proposals; expand proposalExecuted testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike committed Jul 27, 2023
1 parent 9b3faf0 commit c9061e5
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 17 deletions.
1 change: 0 additions & 1 deletion schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,6 @@ type Proposal @entity {
description: String! # proposal description hashed as part of proposalId
distribution: DistributionPeriod # distributionPeriod in which the proposal was submitted if Standard, null otherwise
executed: Boolean! # bool
successful: Boolean! # bool
screeningVotesReceived: BigDecimal! # uint256
fundingVotesReceived: BigDecimal! # uint256
totalTokensRequested: BigDecimal! # uint256
Expand Down
19 changes: 5 additions & 14 deletions src/grant-fund.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,8 @@ export function handleProposalCreated(event: ProposalCreatedEvent): void {

// create Proposal entity
const proposalId = bigIntToBytes(event.params.proposalId)
const proposal = new Proposal(proposalId) as Proposal
const proposal = loadOrCreateProposal(proposalId)
proposal.description = event.params.description
proposal.distribution = Bytes.empty()
proposal.executed = false
proposal.successful = false
proposal.screeningVotesReceived = ZERO_BD
proposal.fundingVotesReceived = ZERO_BD
proposal.params = []

let totalTokensRequested = ZERO_BD

Expand Down Expand Up @@ -224,14 +218,11 @@ export function handleProposalExecuted(event: ProposalExecutedEvent): void {
proposalExecuted.transactionHash = event.transaction.hash

// update proposal entity
const proposal = Proposal.load(bigIntToBytes(event.params.proposalId)) as Proposal
if (proposal != null) {
proposal.executed = true
proposal.successful = true
const proposal = loadOrCreateProposal(bigIntToBytes(event.params.proposalId))
proposal.executed = true

// save entities to the store
proposal.save()
}
// save entities to the store
proposal.save()
proposalExecuted.save()
}

Expand Down
1 change: 0 additions & 1 deletion src/utils/grants/proposal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export function loadOrCreateProposal(proposalId: Bytes): Proposal {
proposal.description = ""
proposal.distribution = Bytes.empty()
proposal.executed = false
proposal.successful = false
proposal.screeningVotesReceived = ZERO_BD
proposal.fundingVotesReceived = ZERO_BD
proposal.totalTokensRequested = ZERO_BD
Expand Down
24 changes: 23 additions & 1 deletion tests/grant-fund.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,28 @@ describe("Grant Fund assertions", () => {

// check ProposalExecuted attributes
assert.entityCount("ProposalExecuted", 1);

assert.fieldEquals(
"Proposal",
`${bigIntToBytes(proposalId).toHexString()}`,
"totalTokensRequested",
`${BigInt.fromI32(2)}`
);

assert.fieldEquals(
"Proposal",
`${bigIntToBytes(proposalId).toHexString()}`,
"executed",
`${true}`
);

assert.fieldEquals(
"ProposalExecuted",
`0xa16081f360e3847006db660bae1c6d1b2e17ec2a01000000`,
"proposalId",
`${proposalId}`
);

});

test("ScreeningVote", () => {
Expand Down Expand Up @@ -762,7 +784,7 @@ describe("Grant Fund assertions", () => {
assert.entityCount("DistributionPeriod", 1);
assert.entityCount("FundedSlate", 1);

logStore();
// logStore();

// check FundedSlate attributes
// assert.fieldEquals(
Expand Down

0 comments on commit c9061e5

Please sign in to comment.