Skip to content

Commit c8e2ded

Browse files
filip-netikacperzuk-neti
authored andcommitted
Remove allowance check after approval
1 parent f635843 commit c8e2ded

File tree

2 files changed

+6
-15
lines changed

2 files changed

+6
-15
lines changed

fplus-lib/src/core/application/file.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ use std::str::FromStr;
22

33
use serde::{Deserialize, Serialize};
44

5+
use crate::error::LDNError;
6+
57
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
68
pub enum DatacapGroup {
79
#[serde(rename = "da")]
@@ -329,18 +331,15 @@ impl ApplicationFile {
329331
self.allocation.0.iter().find(|alloc| alloc.is_active)
330332
}
331333

332-
pub fn adjust_active_allocation_amount(
333-
&mut self,
334-
new_amount: String,
335-
) -> Result<(), &'static str> {
334+
pub fn adjust_active_allocation_amount(&mut self, new_amount: String) -> Result<(), LDNError> {
336335
// Find the first active allocation
337336
if let Some(allocation) = self.allocation.0.iter_mut().find(|alloc| alloc.is_active) {
338337
// Update the amount
339338
allocation.amount = new_amount;
340339
Ok(())
341340
} else {
342341
// Return an error if no active allocation is found
343-
Err("No active allocation found")
342+
Err(LDNError::New("No active allocation found".to_string()))
344343
}
345344
}
346345

fplus-lib/src/core/mod.rs

+2-10
Original file line numberDiff line numberDiff line change
@@ -1038,8 +1038,7 @@ impl LDNApplication {
10381038
let new_allocation_amount_parsed =
10391039
process_amount(new_allocation_amount.clone().unwrap());
10401040

1041-
let _ =
1042-
app_file.adjust_active_allocation_amount(new_allocation_amount_parsed);
1041+
app_file.adjust_active_allocation_amount(new_allocation_amount_parsed)?;
10431042
}
10441043

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

11831182
if new_allocation_amount.is_some() && app_file.allocation.0.len() > 1 {
1184-
let db_multisig_address = db_allocator.multisig_address.unwrap();
1185-
1186-
Self::check_and_handle_allowance(
1187-
&db_multisig_address.clone(),
1188-
new_allocation_amount.clone(),
1189-
)
1190-
.await?;
11911183
let new_allocation_amount_parsed =
11921184
process_amount(new_allocation_amount.clone().unwrap());
11931185

1194-
let _ = app_file.adjust_active_allocation_amount(new_allocation_amount_parsed);
1186+
app_file.adjust_active_allocation_amount(new_allocation_amount_parsed)?;
11951187
}
11961188

11971189
// Add signer to signers array

0 commit comments

Comments
 (0)