Skip to content

Commit

Permalink
added executionHash to Proposal entity, creationHash to TokenSaleTier
Browse files Browse the repository at this point in the history
  • Loading branch information
kevandee committed Oct 18, 2023
1 parent 59095c9 commit e04ad92
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 0 deletions.
5 changes: 5 additions & 0 deletions DaoPools/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ type Proposal @entity {
executor: Bytes!
"The timestamp of execution"
executionTimestamp: BigInt!
"The hash of proposal execution tx"
executionHash: Bytes!
"The timestamp of reaching quorum"
quorumReachedTimestamp: BigInt!

Expand Down Expand Up @@ -449,6 +451,9 @@ type TokenSaleTier @entity {
"id forms from token sale address + tier id"
id: Bytes!

"The hash of tier creation tx"
creationHash: Bytes!

"The sale token contract address"
saleToken: Bytes!

Expand Down
1 change: 1 addition & 0 deletions DaoPools/src/entities/Proposal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export function getProposal(
proposal.isFor = false;
proposal.executor = Bytes.empty();
proposal.executionTimestamp = BigInt.zero();
proposal.executionHash = Bytes.empty();
proposal.quorumReachedTimestamp = BigInt.zero();

proposal.rewardToken = rewardToken;
Expand Down
2 changes: 2 additions & 0 deletions DaoPools/src/entities/TokenSaleTier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export function getTokenSaleTier(

tier.saleToken = saleToken;

tier.creationHash = Bytes.empty();

tier.totalBuyersCount = BigInt.zero();
tier.buyers = new Array();

Expand Down
1 change: 1 addition & 0 deletions DaoPools/src/mappings/DaoPool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ export function onProposalExecuted(event: ProposalExecuted): void {
proposal.isFor = event.params.isFor;
proposal.executor = event.params.sender;
proposal.executionTimestamp = event.block.timestamp;
proposal.executionHash = event.transaction.hash;

proposal.save();
pool.save();
Expand Down
3 changes: 3 additions & 0 deletions DaoPools/src/mappings/TokenSale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import { push } from "../helpers/ArrayHelper";
export function onTierCreated(event: TierCreated): void {
let tokenSale = getTokenSale(event.address);
let tier = getTokenSaleTier(tokenSale, event.params.tierId, event.params.saleToken);

tier.creationHash = event.transaction.hash;

let participationDetails = event.params.participationDetails;
for (let i = 0; i < participationDetails.length; i++) {
tier.whitelistTypes = push(tier.whitelistTypes, BigInt.fromI32(participationDetails[i].participationType));
Expand Down
6 changes: 6 additions & 0 deletions DaoPools/tests/DaoPool.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1205,6 +1205,12 @@ describe("DaoPool", () => {
"executionTimestamp",
block.timestamp.toString()
);
assert.fieldEquals(
"Proposal",
contractSender.concatI32(proposalId.toI32()).toHexString(),
"executionHash",
tx.hash.toHexString()
);

proposalId = BigInt.fromI32(2);
isFor = false;
Expand Down
6 changes: 6 additions & 0 deletions DaoPools/tests/TokenSale.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ describe("TokenSale", () => {
"tokenSale",
contractSender.toHexString()
);
assert.fieldEquals(
"TokenSaleTier",
contractSender.concatI32(tierId.toI32()).toHexString(),
"creationHash",
tx.hash.toHexString()
);
assert.fieldEquals(
"TokenSaleTier",
contractSender.concatI32(tierId.toI32()).toHexString(),
Expand Down

0 comments on commit e04ad92

Please sign in to comment.