Skip to content

Commit

Permalink
fix todo
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike committed Jul 24, 2023
1 parent d843af3 commit c666cf4
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/grant-fund.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,8 @@ export function handleVoteCast(event: VoteCastEvent): void {
const proposalId = bigIntToBytes(event.params.proposalId)
const proposal = Proposal.load(proposalId) as Proposal
if (proposal != null) {
// TODO: need to be able to access the distributionId at that block height or call getDistributionIdAtBlock()?
// load distribution entity
const distributionId = bigIntToBytes(getCurrentDistributionId(event.address))
// load distribution entity using the distributionId from the proposal
const distributionId = proposal.distribution!
const distributionPeriod = DistributionPeriod.load(distributionId) as DistributionPeriod

// load voter's distributionPeriodVotes
Expand Down
1 change: 1 addition & 0 deletions src/utils/grants/distribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export function getCurrentDistributionId(grantFundAddress: Address): BigInt {
return distributionIdResult
}

// FIXME: update this for the latest version of the contract
export function getCurrentStage(currentBlockNumber: BigInt, distributionPeriod: DistributionPeriod): String {
if (currentBlockNumber.lt(distributionPeriod.endBlock - FUNDING_PERIOD_LENGTH)) {
return "SCREENING"
Expand Down
77 changes: 77 additions & 0 deletions tests/grant-fund.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ import {
handleProposalCreated,
handleProposalExecuted,
handleDistributionPeriodStarted,
handleVoteCast,
} from "../src/grant-fund";
import {
createDelegateRewardClaimedEvent,
createFundTreasuryEvent,
createProposalCreatedEvent,
createProposalExecutedEvent,
createDistributionPeriodStartedEvent,
createVoteCastEvent,
} from "./utils/grant-fund-utils";
import {
DISTRIBUTION_PERIOD_LENGTH,
Expand Down Expand Up @@ -294,5 +296,80 @@ describe("Grant Fund assertions", () => {
assert.entityCount("ProposalExecuted", 1);
});

test("ScreeningVote", () => {
/***********************/
/*** Submit Proposal ***/
/***********************/

// mock parameters
const ajnaTokenAddress = Address.fromString("0x0000000000000000000000000000000000000035");
const grantFundAddress = Address.fromString("0x00000000000000000000006772616E7466756E64")
const proposalId = BigInt.fromI32(234);
const proposer = Address.fromString(
"0x0000000000000000000000000000000000000025"
);
const targets = [ajnaTokenAddress, ajnaTokenAddress];
const values = [ZERO_BI, ZERO_BI];
const signatures = [
"transfer(address,uint256)",
"transfer(address,uint256)",
];
const calldatas = [
Bytes.fromHexString("0x000000"),
Bytes.fromHexString("0x000000"),
];
const distributionId = BigInt.fromI32(234);
const startBlock = ONE_BI;
const endBlock = startBlock.plus(DISTRIBUTION_PERIOD_LENGTH);
const description = "test proposal";

// mock GrantFund contract calls
const newDistributionPeriodStartedEvent = createDistributionPeriodStartedEvent(
distributionId,
startBlock,
endBlock
);
newDistributionPeriodStartedEvent.address = grantFundAddress
handleDistributionPeriodStarted(newDistributionPeriodStartedEvent);
mockGetDistributionId(grantFundAddress, distributionId);

// create mock event
const newProposalCreatedEvent = createProposalCreatedEvent(
proposalId,
proposer,
targets,
values,
signatures,
calldatas,
startBlock,
endBlock,
description
);
newProposalCreatedEvent.address = grantFundAddress
handleProposalCreated(newProposalCreatedEvent);

/*******************************/
/*** Screening Vote Proposal ***/
/*******************************/

// mock parameters
const voter = Address.fromString("0x0000000000000000000000000000000000000050");
const votesCast = BigInt.fromI32(234);
const reason = ""

const screeningVoteCastEvent = createVoteCastEvent(voter, proposalId, 1, votesCast, reason);
handleVoteCast(screeningVoteCastEvent);

});

test("getFundingVotingPowerUsed", () => {

});


test("FundingVote", () => {

});

test("FundedSlateUpdated", () => {});
});
Empty file added tests/utils/mock-function.ts
Empty file.

0 comments on commit c666cf4

Please sign in to comment.