Skip to content
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

Closed
wants to merge 6 commits into from

Conversation

mshankarrao
Copy link
Contributor

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

Copy link
Member

@f-gate f-gate left a 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!

@@ -45,6 +46,7 @@ mod v0 {
pub approved_for_funding: bool,
pub funding_threshold_met: bool,
pub cancelled: bool,
pub payment_address: [u8;20],
Copy link
Member

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?

@@ -19,6 +19,7 @@ mod v0 {
pub name: Vec<u8>,
pub percentage_to_unlock: u32,
pub is_approved: bool,
pub withdrawn: bool,
Copy link
Member

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.

@@ -74,6 +76,7 @@ mod v1 {
pub approved_for_funding: bool,
pub funding_threshold_met: bool,
pub cancelled: bool,
pub payment_address: [u8;20],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same again

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -168,6 +172,7 @@ mod v2 {
pub funding_threshold_met: bool,
pub cancelled: bool,
pub funding_type: FundingType,
pub payment_address: [u8;20],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same again

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -176,6 +181,7 @@ mod v2 {
pub milestone_key: MilestoneKey,
pub percentage_to_unlock: u32,
pub is_approved: bool,
pub withdrawn: bool,
Copy link
Member

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 {
Copy link
Member

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 }) {

Copy link
Contributor

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],
Copy link
Member

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!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure

@@ -273,6 +273,7 @@ pub mod v3 {
milestone.percentage_to_unlock as u8,
),
is_approved: milestone.is_approved,
withdrawn: milestone.withdrawn
Copy link
Contributor

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

@@ -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,
Copy link
Contributor

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

@samelamin
Copy link
Contributor

samelamin commented Nov 13, 2023

@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 paymentAddress isnt passed we should have an ensure that throws an error

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,
Copy link
Member

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(),
Copy link
Member

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!!!

pub withdrawn: bool,
}
#[derive(Encode, Decode, Clone)]
pub struct ProjectV7<AccountId, Balance, BlockNumber> {
Copy link
Member

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.

{
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>| {
Copy link
Member

@f-gate f-gate Nov 21, 2023

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

@samelamin
Copy link
Contributor

@f-gate this pr is no longer needed correct ?

@f-gate
Copy link
Member

f-gate commented Dec 5, 2023

No longer needed fix merged with #233

@f-gate f-gate closed this Dec 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants