Skip to content

Commit

Permalink
[FIL-367] Add info about increase allowance cid (#238)
Browse files Browse the repository at this point in the history
* Add info about increase allowance cid
---------

Co-authored-by: Filip Lelek <[email protected]>
  • Loading branch information
Filip-L and filip-neti authored Oct 30, 2024
1 parent 595cff5 commit 95796ad
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 9 deletions.
12 changes: 9 additions & 3 deletions fplus-http-server/src/router/application.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use actix_web::{get, post, web, HttpResponse, Responder};
use fplus_lib::core::{
application::file::{StorageProviderChangeVerifier, VerifierInput},
application::file::{StorageProviderChangeVerifier, VerifierGrantDataCapCids, VerifierInput},
ApplicationQueryParams, BranchDeleteInfo, CompleteGovernanceReviewInfo,
CompleteNewApplicationApprovalInfo, CompleteNewApplicationProposalInfo, CreateApplicationInfo,
DcReachedInfo, GithubQueryParams, LDNApplication, MoreInfoNeeded, NotifyRefillInfo,
Expand Down Expand Up @@ -116,7 +116,10 @@ pub async fn propose(
github_username: query.github_username.clone(), // Use the provided `github_username` parameter
signing_address: signer.signing_address,
created_at: signer.created_at,
message_cid: signer.message_cid,
message_cids: VerifierGrantDataCapCids {
message_cid: signer.message_cids.message_cid,
increase_allowance_cid: signer.message_cids.increase_allowance_cid,
},
};
match ldn_application
.complete_new_application_proposal(
Expand Down Expand Up @@ -227,7 +230,10 @@ pub async fn approve(
github_username: query.github_username.clone(), // Use the provided `github_username` parameter
signing_address: signer.signing_address,
created_at: signer.created_at,
message_cid: signer.message_cid,
message_cids: VerifierGrantDataCapCids {
message_cid: signer.message_cids.message_cid,
increase_allowance_cid: signer.message_cids.increase_allowance_cid,
},
};
match ldn_application
.complete_new_application_approval(
Expand Down
15 changes: 13 additions & 2 deletions fplus-lib/src/core/application/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ pub struct VerifierInput {
pub github_username: String,
pub signing_address: String,
pub created_at: String,
pub message_cid: String,
pub message_cids: VerifierGrantDataCapCids,
}

impl From<VerifierInput> for Verifier {
Expand All @@ -415,7 +415,7 @@ impl From<VerifierInput> for Verifier {
github_username: input.github_username,
signing_address: input.signing_address,
created_at: input.created_at,
message_cid: input.message_cid,
message_cids: input.message_cids,
}
}
}
Expand All @@ -428,8 +428,19 @@ pub struct Verifier {
pub signing_address: String,
#[serde(rename = "Created At")]
pub created_at: String,
#[serde(rename = "Message CIDs")]
pub message_cids: VerifierGrantDataCapCids,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct VerifierGrantDataCapCids {
#[serde(rename = "Message CID")]
pub message_cid: String,
#[serde(
rename = "Increase allowance CID",
skip_serializing_if = "Option::is_none"
)]
pub increase_allowance_cid: Option<String>,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
Expand Down
28 changes: 24 additions & 4 deletions fplus-lib/src/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,13 @@ pub struct VerifierList(pub Vec<String>);
pub struct ApplicationProposalApprovalSignerInfo {
pub signing_address: String,
pub created_at: String,
pub message_cids: GrantDataCapCids,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct GrantDataCapCids {
pub message_cid: String,
pub increase_allowance_cid: Option<String>,
}

#[derive(Deserialize, Serialize, Debug)]
Expand Down Expand Up @@ -3426,22 +3432,34 @@ _(OLD vs NEW)_
let mut id = String::new();
let mut signing_address = String::new();
let mut message_cid = String::new();
let mut increase_allowance_cid: Option<String> = None;

if let Some(allocation) = active_allocation {
datacap_allocation_requested.clone_from(&allocation.amount);
id.clone_from(&allocation.id);

if let Some(first_verifier) = allocation.signers.0.first() {
signing_address.clone_from(&first_verifier.signing_address);
message_cid.clone_from(&first_verifier.message_cid);
message_cid.clone_from(&first_verifier.message_cids.message_cid);
increase_allowance_cid = first_verifier.message_cids.increase_allowance_cid.clone();
}
}

let additional_status_message =
increase_allowance_cid
.clone()
.map_or("".to_string(), |increase_allowance_cid| {
format!(
", and here https://filfox.info/en/message/{}",
increase_allowance_cid
)
});

let comment = format!(
"## Request {}
Your Datacap Allocation Request has been {} by the Notary
#### Message sent to Filecoin Network
> {}
> {} {}
#### Address
> {}
#### Datacap Allocated
Expand All @@ -3450,15 +3468,17 @@ Your Datacap Allocation Request has been {} by the Notary
> {}
#### Id
> {}
#### You can check the status of the message here: https://filfox.info/en/message/{}",
#### You can check the status here https://filfox.info/en/message/{}{}",
signature_step_capitalized,
signature_step,
message_cid,
increase_allowance_cid.unwrap_or_default(),
application_file.lifecycle.client_on_chain_address.clone(),
datacap_allocation_requested,
signing_address,
id,
message_cid
message_cid,
additional_status_message
);

gh.add_comment_to_issue(issue_number.parse().unwrap(), &comment)
Expand Down

0 comments on commit 95796ad

Please sign in to comment.