From ad7583c7530c9ae0957f226d4f6845061eee2cc9 Mon Sep 17 00:00:00 2001 From: kevandee Date: Fri, 16 Feb 2024 02:33:40 +0200 Subject: [PATCH] removed claimed field from VoterInProposal, removed unused imports --- AllInteractions/tests/utils.ts | 2 -- DaoPools/schema.graphql | 2 -- .../src/entities/Voters/VoterInProposal.ts | 2 -- .../src/entities/global/RewardTypeEnum.ts | 12 --------- DaoPools/src/mappings/DaoPool.ts | 11 +++----- DaoPools/src/mappings/DistributionProposal.ts | 1 - DaoPools/src/mappings/ERC721Expert.ts | 3 +-- DaoPools/src/mappings/TokenSale.ts | 2 +- DaoPools/tests/DaoPool.test.ts | 25 ------------------- DaoPools/tests/ERC721Expert.test.ts | 2 +- 10 files changed, 6 insertions(+), 56 deletions(-) delete mode 100644 DaoPools/src/entities/global/RewardTypeEnum.ts diff --git a/AllInteractions/tests/utils.ts b/AllInteractions/tests/utils.ts index 7f9945ed..9868da4d 100644 --- a/AllInteractions/tests/utils.ts +++ b/AllInteractions/tests/utils.ts @@ -1,7 +1,5 @@ import { Address, BigInt, Bytes, ethereum } from "@graphprotocol/graph-ts"; import { assert } from "matchstick-as"; -import { TransactionType } from "../src/entities/global/TransactionTypeEnum"; -import { getTransaction as getTxEntity } from "../src/entities/transaction/Transaction"; export function getBlock(number: BigInt, timestamp: BigInt): ethereum.Block { return new ethereum.Block( diff --git a/DaoPools/schema.graphql b/DaoPools/schema.graphql index 78d196c9..f1f1c879 100644 --- a/DaoPools/schema.graphql +++ b/DaoPools/schema.graphql @@ -313,8 +313,6 @@ type VoterInProposal @entity { id: Bytes! # voter address + proposal entity id "Boolean flag, if true - voter voted for the proposal" isVoteFor: Boolean! - "Boolean flag, if true - rewards claimed" - claimed: Boolean! "The total amount of vote for the proposal" totalVote: BigInt! diff --git a/DaoPools/src/entities/Voters/VoterInProposal.ts b/DaoPools/src/entities/Voters/VoterInProposal.ts index 17f9aeff..5cc673c2 100644 --- a/DaoPools/src/entities/Voters/VoterInProposal.ts +++ b/DaoPools/src/entities/Voters/VoterInProposal.ts @@ -10,8 +10,6 @@ export function getVoterInProposal(proposal: Proposal, voterInPool: VoterInPool) voterInProposal.isVoteFor = false; - voterInProposal.claimed = false; - voterInProposal.totalVote = BigInt.zero(); voterInProposal.staticRewardUSD = BigInt.zero(); diff --git a/DaoPools/src/entities/global/RewardTypeEnum.ts b/DaoPools/src/entities/global/RewardTypeEnum.ts deleted file mode 100644 index b16e430a..00000000 --- a/DaoPools/src/entities/global/RewardTypeEnum.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { BigInt } from "@graphprotocol/graph-ts"; - -export enum RewardType { - CREATE = 0, - VOTE = 1, - EXECUTE = 2, - SAVE_OFFCHAIN_RESULTS = 3, -} - -export function getEnumBigInt(operation: RewardType): BigInt { - return BigInt.fromI32(operation as i32); -} diff --git a/DaoPools/src/mappings/DaoPool.ts b/DaoPools/src/mappings/DaoPool.ts index 2f50cebc..af991a63 100644 --- a/DaoPools/src/mappings/DaoPool.ts +++ b/DaoPools/src/mappings/DaoPool.ts @@ -30,7 +30,6 @@ import { getUSDValue } from "../helpers/PriceFeedInteractions"; import { DelegationType } from "../entities/global/DelegationTypeEnum"; import { TreasuryDelegationType } from "../entities/global/TreasuryDelegationTypeEnum"; import { getTreasuryDelegationHistory } from "../entities/TreasuryDelegationHistory"; -import { RewardType } from "../entities/global/RewardTypeEnum"; import { ProposalInteractionType, getEnumBigInt } from "../entities/global/ProposalInteractionTypeEnum"; import { getNftsVotePower } from "../helpers/UserKeeperInteractions"; @@ -352,8 +351,6 @@ export function onRewardClaimed(event: RewardClaimed): void { let proposal = getProposal(pool, event.params.proposalId); let voterInProposal = getVoterInProposal(proposal, voterInPool); - voterInProposal.claimed = true; - voterInProposal.claimedRewardUSD = voterInProposal.claimedRewardUSD.plus(usdAmount); voterInProposal.staticRewardUSD = voterInProposal.staticRewardUSD.plus(usdAmount); @@ -387,11 +384,9 @@ export function onVotingRewardClaimed(event: VotingRewardClaimed): void { let treasuryUsdAmount = getUSDValue(event.params.token, event.params.rewards.treasury); let totalUsdAmount = personalUsdAmount.plus(micropoolUsdAmount).plus(treasuryUsdAmount); - voterInProposal.claimed = true; - - voterInProposal.personalVotingRewardUSD = personalUsdAmount; - voterInProposal.micropoolVotingRewardUSD = micropoolUsdAmount; - voterInProposal.treasuryVotingRewardUSD = treasuryUsdAmount; + voterInProposal.personalVotingRewardUSD = voterInProposal.personalVotingRewardUSD.plus(personalUsdAmount); + voterInProposal.micropoolVotingRewardUSD = voterInProposal.micropoolVotingRewardUSD.plus(micropoolUsdAmount); + voterInProposal.treasuryVotingRewardUSD = voterInProposal.treasuryVotingRewardUSD.plus(treasuryUsdAmount); voterInProposal.claimedRewardUSD = voterInProposal.claimedRewardUSD.plus(totalUsdAmount); diff --git a/DaoPools/src/mappings/DistributionProposal.ts b/DaoPools/src/mappings/DistributionProposal.ts index ca919209..a14864fd 100644 --- a/DaoPools/src/mappings/DistributionProposal.ts +++ b/DaoPools/src/mappings/DistributionProposal.ts @@ -1,5 +1,4 @@ import { Address } from "@graphprotocol/graph-ts"; -import { pushUnique } from "@solarity/graph-lib"; import { DistributionProposalClaimed } from "../../generated/templates/DistributionProposal/DistributionProposal"; import { getDaoPool } from "../entities/DaoPool"; import { getDPContract } from "../entities/DPContract"; diff --git a/DaoPools/src/mappings/ERC721Expert.ts b/DaoPools/src/mappings/ERC721Expert.ts index 09109845..eb44847d 100644 --- a/DaoPools/src/mappings/ERC721Expert.ts +++ b/DaoPools/src/mappings/ERC721Expert.ts @@ -1,4 +1,4 @@ -import { pushUnique, remove } from "@solarity/graph-lib"; +import { pushUnique } from "@solarity/graph-lib"; import { Transfer, TagsAdded } from "../../generated/templates/ERC721Expert/ERC721Expert"; import { getExpertNft } from "../entities/ExpertNft"; import { Address, Bytes, store } from "@graphprotocol/graph-ts"; @@ -6,7 +6,6 @@ import { getExpertNftContract } from "../entities/ExpertNftContract"; import { getVoter } from "../entities/Voters/Voter"; import { getVoterInPool } from "../entities/Voters/VoterInPool"; import { getDaoPool } from "../entities/DaoPool"; -import { log } from "matchstick-as"; import { Voter, VoterInPool } from "../../generated/schema"; export function onTransfer(event: Transfer): void { diff --git a/DaoPools/src/mappings/TokenSale.ts b/DaoPools/src/mappings/TokenSale.ts index 5846eb08..24a0949d 100644 --- a/DaoPools/src/mappings/TokenSale.ts +++ b/DaoPools/src/mappings/TokenSale.ts @@ -1,4 +1,4 @@ -import { Address, BigDecimal, BigInt, Bytes } from "@graphprotocol/graph-ts"; +import { Address, BigInt, Bytes } from "@graphprotocol/graph-ts"; import { pushUnique } from "@solarity/graph-lib"; import { Bought, TierCreated, Whitelisted } from "../../generated/templates/TokenSale/TokenSaleProposal"; import { getDaoPool } from "../entities/DaoPool"; diff --git a/DaoPools/tests/DaoPool.test.ts b/DaoPools/tests/DaoPool.test.ts index 637665e4..83c5ad3f 100644 --- a/DaoPools/tests/DaoPool.test.ts +++ b/DaoPools/tests/DaoPool.test.ts @@ -48,7 +48,6 @@ import { onSetERC20 } from "../src/mappings/UserKeeper"; import { DelegationType } from "../src/entities/global/DelegationTypeEnum"; import { getDaoPool } from "../src/entities/DaoPool"; import { TreasuryDelegationType } from "../src/entities/global/TreasuryDelegationTypeEnum"; -import { RewardType } from "../src/entities/global/RewardTypeEnum"; function createProposalCreated( proposalId: BigInt, @@ -1280,12 +1279,6 @@ describe("DaoPool", () => { onRewardClaimed(event0); assert.fieldEquals("Voter", sender.toHexString(), "totalClaimedUSD", amounts[0].toString()); - assert.fieldEquals( - "VoterInProposal", - sender.concat(contractSender).concatI32(proposalIds[0].toI32()).toHexString(), - "claimed", - "true" - ); assert.fieldEquals( "VoterInProposal", sender.concat(contractSender).concatI32(proposalIds[0].toI32()).toHexString(), @@ -1308,12 +1301,6 @@ describe("DaoPool", () => { onRewardClaimed(event1); assert.fieldEquals("Voter", sender.toHexString(), "totalClaimedUSD", amounts[0].plus(amounts[1]).toString()); - assert.fieldEquals( - "VoterInProposal", - sender.concat(contractSender).concatI32(proposalIds[1].toI32()).toHexString(), - "claimed", - "true" - ); assert.fieldEquals( "VoterInProposal", sender.concat(contractSender).concatI32(proposalIds[1].toI32()).toHexString(), @@ -1378,12 +1365,6 @@ describe("DaoPool", () => { onVotingRewardClaimed(event0); assert.fieldEquals("Voter", sender.toHexString(), "totalClaimedUSD", totalAmount.toString()); - assert.fieldEquals( - "VoterInProposal", - sender.concat(contractSender).concatI32(proposalIds[0].toI32()).toHexString(), - "claimed", - "true" - ); assert.fieldEquals( "VoterInProposal", sender.concat(contractSender).concatI32(proposalIds[0].toI32()).toHexString(), @@ -1442,12 +1423,6 @@ describe("DaoPool", () => { onVotingRewardClaimed(event1); assert.fieldEquals("Voter", sender.toHexString(), "totalClaimedUSD", totalAmount.plus(totalAmount1).toString()); - assert.fieldEquals( - "VoterInProposal", - sender.concat(contractSender).concatI32(proposalIds[1].toI32()).toHexString(), - "claimed", - "true" - ); assert.fieldEquals( "VoterInProposal", sender.concat(contractSender).concatI32(proposalIds[1].toI32()).toHexString(), diff --git a/DaoPools/tests/ERC721Expert.test.ts b/DaoPools/tests/ERC721Expert.test.ts index 3039033d..d773d031 100644 --- a/DaoPools/tests/ERC721Expert.test.ts +++ b/DaoPools/tests/ERC721Expert.test.ts @@ -1,5 +1,5 @@ import { Address, ethereum, BigInt, Bytes } from "@graphprotocol/graph-ts"; -import { assert, beforeAll, describe, logStore, newMockEvent, test } from "matchstick-as"; +import { assert, beforeAll, describe, newMockEvent, test } from "matchstick-as"; import { TagsAdded, Transfer } from "../generated/templates/ERC721Expert/ERC721Expert"; import { getBlock, getTransaction } from "./utils"; import { onTagsAdded, onTransfer } from "../src/mappings/ERC721Expert";