-
Notifications
You must be signed in to change notification settings - Fork 13
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
added flag to track the withdrawl of fund for milestones #257
Conversation
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.
Drop me a message so we can talk about how to next proceed!
pallets/proposals/src/migration.rs
Outdated
@@ -45,6 +46,7 @@ mod v0 { | |||
pub approved_for_funding: bool, | |||
pub funding_threshold_met: bool, | |||
pub cancelled: bool, | |||
pub payment_address: [u8;20], |
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.
Why are you adding payment_address to old migration types?
pallets/proposals/src/migration.rs
Outdated
@@ -19,6 +19,7 @@ mod v0 { | |||
pub name: Vec<u8>, | |||
pub percentage_to_unlock: u32, | |||
pub is_approved: bool, | |||
pub withdrawn: bool, |
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.
pls remove this line its an old migration type, it should be preserved and there is no reason to change it as we are on v7 or something now.
pallets/proposals/src/migration.rs
Outdated
@@ -74,6 +76,7 @@ mod v1 { | |||
pub approved_for_funding: bool, | |||
pub funding_threshold_met: bool, | |||
pub cancelled: bool, | |||
pub payment_address: [u8;20], |
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.
same again
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.
Done
pallets/proposals/src/migration.rs
Outdated
@@ -168,6 +172,7 @@ mod v2 { | |||
pub funding_threshold_met: bool, | |||
pub cancelled: bool, | |||
pub funding_type: FundingType, | |||
pub payment_address: [u8;20], |
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.
same again
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.
Done
pallets/proposals/src/migration.rs
Outdated
@@ -176,6 +181,7 @@ mod v2 { | |||
pub milestone_key: MilestoneKey, | |||
pub percentage_to_unlock: u32, | |||
pub is_approved: bool, | |||
pub withdrawn: bool, |
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.
Nothing in mod v2 should be changed, in fact nothing in any migration should be changed except possibly the latest.
Feel free to drop me a message if you wanna chat about migrations and steps for introducing your new field.
if ms.is_approved { | ||
ms.withdrawn = true; | ||
} | ||
} | ||
if p.withdrawn_funds == p.raised_funds { |
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.
This is nice, We can now remove this possibly troublesome line if p.withdrawn_funds == p.raised_funds {
which doesnt handle with dust at all and replace it with something like.
if milestones.iter().all(|&ms|{ ms.withdrawn }) {
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.
agreed
@@ -562,6 +565,7 @@ pub struct Project<T: Config> { | |||
pub cancelled: bool, | |||
pub funding_type: FundingType, | |||
pub deposit_id: DepositIdOf<T>, | |||
pub payment_address: [u8; 20], |
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.
This is meant to signal where the tokens will end up. check telegram when you get a minute!
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.
Sure
pallets/proposals/src/migration.rs
Outdated
@@ -273,6 +273,7 @@ pub mod v3 { | |||
milestone.percentage_to_unlock as u8, | |||
), | |||
is_approved: milestone.is_approved, | |||
withdrawn: milestone.withdrawn |
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.
how will these migrations work, the old data doesnt have these flags. You can default them is_approved
for now
pallets/proposals/src/migration.rs
Outdated
@@ -296,6 +297,7 @@ pub mod v3 { | |||
funding_type: FundingType::Proposal, | |||
// A deposit_id of u32::MAX is ignored. | |||
deposit_id: u32::MAX.into(), | |||
payment_address: project.payment_address, |
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.
this should default to the initiator address
@mshankarrao we need to pass in the payment address when we create the project, I dont see it in the current pr? we need to pass the payment address when we create the project, either through a brief or a grant. We can have it as an optional parameter and if it's a foreign currency and Also if it isn't a foreign currency then we should default it to the project owners address |
agreement_hash: Default::default(), | ||
cancelled: project.cancelled, | ||
raised_funds: project.raised_funds, | ||
funding_type: FundingType::Proposal, |
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.
use the funding type of the old project instead of overwiting with FundingType::Proposal
.
withdrawn_funds: project.withdrawn_funds, | ||
initiator: project.initiator, | ||
created_on: project.created_on, | ||
agreement_hash: Default::default(), |
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.
use the agreement_hash
of the old project instead of overwriting!!!
pallets/proposals/src/migration.rs
Outdated
pub withdrawn: bool, | ||
} | ||
#[derive(Encode, Decode, Clone)] | ||
pub struct ProjectV7<AccountId, Balance, BlockNumber> { |
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.
This is meant to be the old Project type, the new project type is not defined here but defined in crate::Project
This should be the Project before you made the changes.
pallets/proposals/src/migration.rs
Outdated
{ | ||
let mut weight = T::DbWeight::get().reads_writes(1, 1); | ||
let mut migrated_milestones: BTreeMap<MilestoneKey, MilestoneV7> = BTreeMap::new(); | ||
v7::Projects::<T>::translate(|_project_key, project: ProjectV7Of<T>| { |
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.
If you use v7::Projects::drain
its much easier to understand
@f-gate this pr is no longer needed correct ? |
No longer needed fix merged with #233 |
Added the flag in the milestone for tracking the withdrawl which is set to true once the withrawl has been done for the given milestone
Added the payment address for the project to allow user to request payment in a given address type