Skip to content

Commit

Permalink
✨ Add when to ContributionInfo (#330)
Browse files Browse the repository at this point in the history
## What?
- Add `when` to `ContributionInfo`

## Why?
So the UI can easily know when the contribution was made and display it

## How?
add the field to the type, and assign it to `now` inside `do_contribute`

## Testing?
Run normal tests, since this new field shouldn't affect the logic
  • Loading branch information
JuaniRios authored Jun 20, 2024
1 parent 8e88a7e commit 2aa7db7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions pallets/funding/src/functions/4_contribution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ impl<T: Config> Pallet<T> {
funding_asset,
funding_asset_amount,
plmc_bond,
when: now,
};

// Try adding the new contribution to the system
Expand Down
3 changes: 2 additions & 1 deletion pallets/funding/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ pub type EvaluationInfoOf<T> = EvaluationInfo<u32, Did, ProjectId, AccountIdOf<T
pub type BidInfoOf<T> =
BidInfo<ProjectId, Did, BalanceOf<T>, PriceOf<T>, AccountIdOf<T>, BlockNumberFor<T>, MultiplierOf<T>>;

pub type ContributionInfoOf<T> = ContributionInfo<u32, Did, ProjectId, AccountIdOf<T>, BalanceOf<T>, MultiplierOf<T>>;
pub type ContributionInfoOf<T> =
ContributionInfo<u32, Did, ProjectId, AccountIdOf<T>, BalanceOf<T>, BlockNumberFor<T>, MultiplierOf<T>>;

pub type BucketOf<T> = Bucket<BalanceOf<T>, PriceOf<T>>;
pub type WeightInfoOf<T> = <T as Config>::WeightInfo;
Expand Down
3 changes: 2 additions & 1 deletion pallets/funding/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ pub mod storage_types {
}

#[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, MaxEncodedLen, TypeInfo)]
pub struct ContributionInfo<Id, Did, ProjectId, AccountId, Balance, Multiplier> {
pub struct ContributionInfo<Id, Did, ProjectId, AccountId, Balance, BlockNumber, Multiplier> {
pub id: Id,
pub did: Did,
pub project_id: ProjectId,
Expand All @@ -424,6 +424,7 @@ pub mod storage_types {
pub funding_asset: AcceptedFundingAsset,
pub funding_asset_amount: Balance,
pub plmc_bond: Balance,
pub when: BlockNumber,
}

/// Represents a bucket that holds a specific amount of tokens at a given price.
Expand Down

0 comments on commit 2aa7db7

Please sign in to comment.