Skip to content

Commit

Permalink
Remove allowance check after approval
Browse files Browse the repository at this point in the history
  • Loading branch information
Filip Lelek authored and kacperzuk-neti committed Oct 7, 2024
1 parent f635843 commit c8e2ded
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
9 changes: 4 additions & 5 deletions fplus-lib/src/core/application/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ use std::str::FromStr;

use serde::{Deserialize, Serialize};

use crate::error::LDNError;

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
pub enum DatacapGroup {
#[serde(rename = "da")]
Expand Down Expand Up @@ -329,18 +331,15 @@ impl ApplicationFile {
self.allocation.0.iter().find(|alloc| alloc.is_active)
}

pub fn adjust_active_allocation_amount(
&mut self,
new_amount: String,
) -> Result<(), &'static str> {
pub fn adjust_active_allocation_amount(&mut self, new_amount: String) -> Result<(), LDNError> {
// Find the first active allocation
if let Some(allocation) = self.allocation.0.iter_mut().find(|alloc| alloc.is_active) {
// Update the amount
allocation.amount = new_amount;
Ok(())
} else {
// Return an error if no active allocation is found
Err("No active allocation found")
Err(LDNError::New("No active allocation found".to_string()))
}
}

Expand Down
12 changes: 2 additions & 10 deletions fplus-lib/src/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1038,8 +1038,7 @@ impl LDNApplication {
let new_allocation_amount_parsed =
process_amount(new_allocation_amount.clone().unwrap());

let _ =
app_file.adjust_active_allocation_amount(new_allocation_amount_parsed);
app_file.adjust_active_allocation_amount(new_allocation_amount_parsed)?;
}

let file_content = serde_json::to_string_pretty(&app_file).unwrap();
Expand Down Expand Up @@ -1181,17 +1180,10 @@ impl LDNApplication {
// Check the allowance for the address

if new_allocation_amount.is_some() && app_file.allocation.0.len() > 1 {
let db_multisig_address = db_allocator.multisig_address.unwrap();

Self::check_and_handle_allowance(
&db_multisig_address.clone(),
new_allocation_amount.clone(),
)
.await?;
let new_allocation_amount_parsed =
process_amount(new_allocation_amount.clone().unwrap());

let _ = app_file.adjust_active_allocation_amount(new_allocation_amount_parsed);
app_file.adjust_active_allocation_amount(new_allocation_amount_parsed)?;
}

// Add signer to signers array
Expand Down

0 comments on commit c8e2ded

Please sign in to comment.