Skip to content

Commit

Permalink
✨ Add ProposedIdeas event using new ProposalInfo struct to granularly…
Browse files Browse the repository at this point in the history
… provide indexable proposal information
  • Loading branch information
robriks committed May 5, 2024
1 parent bcf06e4 commit 277f2df
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/IdeaTokenHub.sol
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ contract IdeaTokenHub is OwnableUpgradeable, UUPSUpgradeable, ERC1155Upgradeable
// populate array with winning txs & description and aggregate total payout amount
uint256 winningProposalsTotalFunding;
IPropLot.Proposal[] memory winningProposals = new IPropLot.Proposal[](winningIds.length);
ProposalInfo[] memory proposedIdeas = new ProposalInfo[](winningIds.length);
for (uint256 i; i < winningIds.length; ++i) {
uint96 currentWinnerId = winningIds[i];
// re-validate canonical winnerId values against provided ones
Expand All @@ -160,10 +161,20 @@ contract IdeaTokenHub is OwnableUpgradeable, UUPSUpgradeable, ERC1155Upgradeable
winner.isProposed = true;
winningProposalsTotalFunding += winner.totalFunding;
winningProposals[i] = IPropLot.Proposal(winner.proposalTxs, offchainDescriptions[i]);

// use placeholder value since `nounsProposalId` is not known and will be assigned by Nouns Governor
proposedIdeas[i] = ProposalInfo(0, uint256(currentWinnerId), winner.totalFunding, winner.blockCreated);
}

(delegations, nounsProposalIds) = __propLotCore.pushProposals(winningProposals);

// populate array's `nounsProposalId` struct field for event emission now that they are known
for (uint256 i; i < proposedIdeas.length; ++i) {
proposedIdeas[i].nounsProposalId = nounsProposalIds[i];
}

emit ProposedIdeas(proposedIdeas);

// calculate yield for returned valid delegations
for (uint256 j; j < delegations.length; ++j) {
uint256 denominator = 10_000 * minRequiredVotes / delegations[j].votingPower;
Expand Down
9 changes: 8 additions & 1 deletion src/interfaces/IIdeaTokenHub.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ interface IIdeaTokenHub {
bool isCreator;
}

struct ProposalInfo {
uint256 nounsProposalId;
uint256 waveIdeaId;
uint216 totalFunding;
uint32 blockCreated;
}

error BelowMinimumSponsorshipAmount(uint256 value);
error InvalidActionsCount(uint256 count);
error ProposalInfoArityMismatch();
Expand All @@ -40,7 +47,7 @@ interface IIdeaTokenHub {

event IdeaCreated(IPropLot.Proposal idea, address creator, uint96 ideaId, SponsorshipParams params);
event Sponsorship(address sponsor, uint96 ideaId, SponsorshipParams params);
event IdeaProposed(IdeaInfo ideaInfo);
event ProposedIdeas(ProposalInfo[] proposedIdeas);

function minSponsorshipAmount() external view returns (uint256);
function decimals() external view returns (uint256);
Expand Down

0 comments on commit 277f2df

Please sign in to comment.