-
Notifications
You must be signed in to change notification settings - Fork 9
⚡️ Remove AccountId and id from stored value
#487
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
⚡️ Remove AccountId and id from stored value
#487
Conversation
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
0ed680d to
9c7636a
Compare
AccountId and id from stored value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR removes the stored fields “id” and “project_id” from the EvaluationInfo struct and updates all related calls and tests accordingly. Key changes include:
- Updating the EvaluationInfo struct in pallets/funding/src/types.rs.
- Adjusting tests in pallets/funding/src/tests/5_settlement.rs and pallets/funding/src/tests/2_evaluation.rs to account for the changed struct.
- Modifying helper functions and instantiators to work with a tuple structure returned by get_evaluations.
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| pallets/funding/src/types.rs | Removed the id and project_id fields from EvaluationInfo. |
| pallets/funding/src/tests/5_settlement.rs | Updated tuple deconstruction and other references in tests. |
| pallets/funding/src/tests/2_evaluation.rs | Adjusted expected EvaluationInfo to match struct changes. |
| pallets/funding/src/lib.rs | Updated type alias and calls for EvaluationInfo. |
| pallets/funding/src/instantiator/chain_interactions.rs | Modified get_evaluations to return tuples instead of raw values. |
| pallets/funding/src/functions/misc.rs | Updated evaluation locking logic with tuple access. |
| pallets/funding/src/functions/5_settlement.rs | Changed do_settle_evaluation signature to include evaluation_id. |
| pallets/funding/src/functions/2_evaluation.rs | Updated EvaluationInfo instantiation to remove obsolete fields. |
| let first_evaluation = inst.get_evaluations(project_id).into_iter().next().unwrap(); | ||
| inst.execute(|| { | ||
| let evaluator = first_evaluation.evaluator; | ||
| let evaluator = first_evaluation.0; | ||
| assert_ok!(crate::Pallet::<TestRuntime>::settle_evaluation( | ||
| RuntimeOrigin::signed(evaluator), | ||
| project_id, | ||
| evaluator, | ||
| first_evaluation.id | ||
| first_evaluation.1 | ||
| )); | ||
| assert_noop!( | ||
| crate::Pallet::<TestRuntime>::settle_evaluation( | ||
| RuntimeOrigin::signed(evaluator), | ||
| project_id, | ||
| evaluator, | ||
| first_evaluation.id | ||
| first_evaluation.1 |
Copilot
AI
May 16, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Consider destructuring the tuple returned by get_evaluations instead of accessing its elements directly via indices (e.g. first_evaluation.0 and first_evaluation.1) to improve code readability.
|
|
||
| pub fn get_evaluations(&mut self, project_id: ProjectId) -> Vec<EvaluationInfoOf<T>> { | ||
| self.execute(|| Evaluations::<T>::iter_prefix_values((project_id,)).collect()) | ||
| pub fn get_evaluations(&mut self, project_id: ProjectId) -> Vec<(AccountIdOf<T>, u32, EvaluationInfoOf<T>)> { |
Copilot
AI
May 16, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The revised tuple structure returned by get_evaluations requires careful handling; ensure that all call sites properly destructure and use the tuple values.
fce9db1 to
f9cceec
Compare
67b6aa1 to
a998aff
Compare
f9cceec to
2ffd8f6
Compare
a998aff to
0d7c547
Compare
2ffd8f6 to
0c2cd35
Compare
0d7c547 to
992689e
Compare
0c2cd35 to
8c809b8
Compare
992689e to
aa8e672
Compare
7714174 to
909a092
Compare
aa8e672 to
7fcb836
Compare
909a092 to
ac45b29
Compare
7fcb836 to
33fe2fd
Compare
33fe2fd to
4783aa9
Compare
ac45b29 to
5559689
Compare
5559689 to
ac45b29
Compare
4783aa9 to
33fe2fd
Compare
7ba84ad to
8f206da
Compare
33fe2fd to
6daa42f
Compare

This pull request refactors the
EvaluationInfostructure and associated logic across thepallets/fundingmodule to simplify its design by removing theidandproject_idfields from the structure. The changes also update related functions, storage, and tests to accommodate this refactoring. Additionally, some minor cleanups were performed.Refactoring of
EvaluationInfoand Related Logic:EvaluationInfoStructure Simplification:idandproject_idfields from theEvaluationInfostruct definition inpallets/funding/src/types.rs. The struct now relies on external identifiers for these fields.EvaluationInfoOf<T>inpallets/funding/src/lib.rsto reflect the new structure.Function Updates:
do_settle_evaluationinpallets/funding/src/functions/5_settlement.rsto acceptevaluation_idas a separate parameter instead of using it from theEvaluationInfostruct. [1] [2]try_plmc_participation_lockto iterate over evaluation IDs and include them in updates to theEvaluationsstorage.settle_projectandget_evaluationsinpallets/funding/src/instantiator/chain_interactions.rsto handle the new structure. [1] [2]Storage Updates:
Evaluationsstorage to use externalevaluation_idwhere necessary, ensuring compatibility with the new structure. [1] [2]Test Adjustments:
EvaluationInfoChanges:pallets/funding/src/tests/5_settlement.rsto reflect the newEvaluationInfostructure by using tuples(AccountId, EvaluationId, EvaluationInfo)instead of the old structure. [1] [2] [3]evaluation_idfromEvaluationInfo. [1] [2]Minor Cleanups:
idandproject_idfields fromEvaluationInfoinpallets/funding/src/functions/2_evaluation.rsand associated logic. [1] [2]#[allow(unreachable_patterns)]directive inpallets/funding/src/lib.rs.BlockNumberForimport topallets/funding/src/lib.rsfor consistency.These changes streamline the
EvaluationInfostructure and improve the maintainability of the codebase by reducing redundancy and simplifying related logic.