Skip to content

Commit

Permalink
fixed id for ValidatorInProposal entity (#143)
Browse files Browse the repository at this point in the history
* fixed id for ValidatorInProposal entity

* fixed comments in schema
  • Loading branch information
kevandee authored Nov 29, 2023
1 parent 7b32187 commit bb74071
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
14 changes: 7 additions & 7 deletions DaoValidators/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ The entity that holds informations about pool
"""
type DaoPool @entity {
"The pool address"
id: Bytes! # pool address
id: Bytes!
"Array of ValidatorInPool entity ids"
validators: [ValidatorInPool!]! @derivedFrom(field: "pool")
}
Expand All @@ -13,7 +13,7 @@ The entity that holds informations about validators contract
"""
type ValidatorsContract @entity(immutable: true) {
"The validators contract address"
id: Bytes! # validators contract address
id: Bytes!
"The pool address"
pool: Bytes!
}
Expand All @@ -23,7 +23,7 @@ The entity that holds informations about validators proposal
"""
type Proposal @entity {
"id forms from pool address + proposalId + isInternal"
id: ID! # pool address + proposalId + isInternal
id: ID!
"The id of proposal"
proposalId: BigInt!
"Boolean flag, if true - internal for validators"
Expand Down Expand Up @@ -52,7 +52,7 @@ The entity that holds informations about validator's actions in pool
"""
type ValidatorInPool @entity {
"id forms from the validator address + pool address"
id: Bytes! # validator address + pool address
id: Bytes!
"The address of validator"
validatorAddress: Bytes!
"The amount of validators token"
Expand All @@ -67,7 +67,7 @@ The entity that holds informations about vote
"""
type ProposalInteraction @entity(immutable: true) {
"id forms from the tx hash + interactionCount"
id: Bytes! # tx hash + counter
id: Bytes!
"The tx hash"
hash: Bytes!
"The timestamp of transaction"
Expand All @@ -88,8 +88,8 @@ type ProposalInteraction @entity(immutable: true) {
The entity that holds informations about vote
"""
type ValidatorInProposal @entity {
"id forms from the validator address + pool address + proposal id"
id: Bytes! # user address + pool address + proposal id
"id forms from the validator address + pool address + proposal id + isInternal"
id: Bytes!
"The pool entity id"
pool: DaoPool!
"The proposal entity id"
Expand Down
2 changes: 1 addition & 1 deletion DaoValidators/src/entities/ValidatorInProposal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { BigInt } from "@graphprotocol/graph-ts";
import { Proposal, ValidatorInPool, ValidatorInProposal } from "../../generated/schema";

export function getValidatorInProposal(validator: ValidatorInPool, proposal: Proposal): ValidatorInProposal {
let id = validator.id.concatI32(proposal.proposalId.toI32());
let id = validator.id.concatI32(proposal.proposalId.toI32()).concatI32(proposal.isInternal);
let validatorInProposal = ValidatorInProposal.load(id);

if (validatorInProposal == null) {
Expand Down
24 changes: 12 additions & 12 deletions DaoValidators/tests/DaoValidators.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,13 +400,13 @@ describe("DaoValidators", () => {

assert.fieldEquals(
"ValidatorInProposal",
sender.concat(poolAddress).concatI32(proposalId.toI32()).toHexString(),
sender.concat(poolAddress).concatI32(proposalId.toI32()).concatI32(isInternal).toHexString(),
"totalVoteAgainst",
"0"
);
assert.fieldEquals(
"ValidatorInProposal",
sender.concat(poolAddress).concatI32(proposalId.toI32()).toHexString(),
sender.concat(poolAddress).concatI32(proposalId.toI32()).concatI32(isInternal).toHexString(),
"totalVoteFor",
vote.toString()
);
Expand Down Expand Up @@ -434,7 +434,7 @@ describe("DaoValidators", () => {
"ProposalInteraction",
tx.hash.concatI32(0).toHexString(),
"voter",
sender.concat(poolAddress).concatI32(proposalId.toI32()).toHexString()
sender.concat(poolAddress).concatI32(proposalId.toI32()).concatI32(isInternal).toHexString()
);

isVoteFor = false;
Expand All @@ -446,13 +446,13 @@ describe("DaoValidators", () => {

assert.fieldEquals(
"ValidatorInProposal",
sender.concat(poolAddress).concatI32(proposalId.toI32()).toHexString(),
sender.concat(poolAddress).concatI32(proposalId.toI32()).concatI32(isInternal).toHexString(),
"totalVoteAgainst",
vote.toString()
);
assert.fieldEquals(
"ValidatorInProposal",
sender.concat(poolAddress).concatI32(proposalId.toI32()).toHexString(),
sender.concat(poolAddress).concatI32(proposalId.toI32()).concatI32(isInternal).toHexString(),
"totalVoteFor",
vote.toString()
);
Expand Down Expand Up @@ -485,7 +485,7 @@ describe("DaoValidators", () => {
"ProposalInteraction",
nextTx.hash.concatI32(0).toHexString(),
"voter",
sender.concat(poolAddress).concatI32(proposalId.toI32()).toHexString()
sender.concat(poolAddress).concatI32(proposalId.toI32()).concatI32(isInternal).toHexString()
);
});

Expand All @@ -502,13 +502,13 @@ describe("DaoValidators", () => {

assert.fieldEquals(
"ValidatorInProposal",
sender.concat(poolAddress).concatI32(proposalId.toI32()).toHexString(),
sender.concat(poolAddress).concatI32(proposalId.toI32()).concatI32(isInternal).toHexString(),
"totalVoteAgainst",
"0"
);
assert.fieldEquals(
"ValidatorInProposal",
sender.concat(poolAddress).concatI32(proposalId.toI32()).toHexString(),
sender.concat(poolAddress).concatI32(proposalId.toI32()).concatI32(isInternal).toHexString(),
"totalVoteFor",
vote.toString()
);
Expand Down Expand Up @@ -536,7 +536,7 @@ describe("DaoValidators", () => {
"ProposalInteraction",
tx.hash.concatI32(0).toHexString(),
"voter",
sender.concat(poolAddress).concatI32(proposalId.toI32()).toHexString()
sender.concat(poolAddress).concatI32(proposalId.toI32()).concatI32(isInternal).toHexString()
);

const nextTx = getNextTx(tx);
Expand All @@ -546,13 +546,13 @@ describe("DaoValidators", () => {

assert.fieldEquals(
"ValidatorInProposal",
sender.concat(poolAddress).concatI32(proposalId.toI32()).toHexString(),
sender.concat(poolAddress).concatI32(proposalId.toI32()).concatI32(isInternal).toHexString(),
"totalVoteAgainst",
"0"
);
assert.fieldEquals(
"ValidatorInProposal",
sender.concat(poolAddress).concatI32(proposalId.toI32()).toHexString(),
sender.concat(poolAddress).concatI32(proposalId.toI32()).concatI32(isInternal).toHexString(),
"totalVoteFor",
"0"
);
Expand Down Expand Up @@ -585,7 +585,7 @@ describe("DaoValidators", () => {
"ProposalInteraction",
nextTx.hash.concatI32(0).toHexString(),
"voter",
sender.concat(poolAddress).concatI32(proposalId.toI32()).toHexString()
sender.concat(poolAddress).concatI32(proposalId.toI32()).concatI32(isInternal).toHexString()
);
});

Expand Down

0 comments on commit bb74071

Please sign in to comment.