diff --git a/fplus-lib/src/core/application/file.rs b/fplus-lib/src/core/application/file.rs index 2475739..b758326 100644 --- a/fplus-lib/src/core/application/file.rs +++ b/fplus-lib/src/core/application/file.rs @@ -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")] @@ -329,10 +331,7 @@ 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 @@ -340,7 +339,7 @@ impl ApplicationFile { 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())) } } diff --git a/fplus-lib/src/core/mod.rs b/fplus-lib/src/core/mod.rs index a633eee..7d38586 100644 --- a/fplus-lib/src/core/mod.rs +++ b/fplus-lib/src/core/mod.rs @@ -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(); @@ -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