diff --git a/core/model/src/driver.rs b/core/model/src/driver.rs index 1ccb7cb96e..27ccbb9ec9 100644 --- a/core/model/src/driver.rs +++ b/core/model/src/driver.rs @@ -403,7 +403,8 @@ impl ValidateAllocation { #[derive(Clone, Debug, Serialize, Deserialize)] pub enum ValidateAllocationResult { - InsufficientFunds, + InsufficientAccountFunds, + InsufficientDepositFunds, TimeoutExceedsDeposit, MalformedDepositContract, MalformedDepositId, diff --git a/core/payment-driver/erc20/src/driver.rs b/core/payment-driver/erc20/src/driver.rs index 166d170447..83a3e03a74 100644 --- a/core/payment-driver/erc20/src/driver.rs +++ b/core/payment-driver/erc20/src/driver.rs @@ -407,7 +407,7 @@ impl Erc20Driver { ); Ok(if msg.amount > account_balance - total_allocated_amount { - ValidateAllocationResult::InsufficientFunds + ValidateAllocationResult::InsufficientAccountFunds } else { ValidateAllocationResult::Valid }) @@ -504,7 +504,7 @@ impl Erc20Driver { deposit_balance ); - return Ok(ValidateAllocationResult::InsufficientFunds); + return Ok(ValidateAllocationResult::InsufficientDepositFunds); } if let Some(timeout) = msg.timeout { diff --git a/core/payment/src/api/allocations.rs b/core/payment/src/api/allocations.rs index 503bc07af6..c783fc4375 100644 --- a/core/payment/src/api/allocations.rs +++ b/core/payment/src/api/allocations.rs @@ -346,10 +346,15 @@ async fn create_allocation( match async move { Ok(bus::service(LOCAL_SERVICE).send(validate_msg).await??) }.await { Ok(ValidateAllocationResult::Valid) => {} - Ok(ValidateAllocationResult::InsufficientFunds) => { + Ok(ValidateAllocationResult::InsufficientAccountFunds) => { return bad_req_and_log(format!("Insufficient funds to make allocation for payment platform {payment_triple}. \ Top up your account or release all existing allocations to unlock the funds via `yagna payment release-allocations`")); } + Ok(ValidateAllocationResult::InsufficientDepositFunds) => { + return bad_req_and_log( + "Insufficient funds on the deposit for this allocation".to_string(), + ); + } Ok(ValidateAllocationResult::TimeoutExceedsDeposit) => { return bad_req_and_log( "Requested allocation timeout either not set or exceeds deposit timeout" @@ -522,10 +527,15 @@ async fn amend_allocation( }; match async move { Ok(bus::service(LOCAL_SERVICE).send(validate_msg).await??) }.await { Ok(ValidateAllocationResult::Valid) => {} - Ok(ValidateAllocationResult::InsufficientFunds) => { + Ok(ValidateAllocationResult::InsufficientAccountFunds) => { return bad_req_and_log(format!("Insufficient funds to make allocation for payment platform {payment_triple}. \ Top up your account or release all existing allocations to unlock the funds via `yagna payment release-allocations`")); } + Ok(ValidateAllocationResult::InsufficientDepositFunds) => { + return bad_req_and_log( + "Insufficient funds on the deposit for this allocation".to_string(), + ); + } Ok(ValidateAllocationResult::TimeoutExceedsDeposit) => { return bad_req_and_log( "Requested allocation timeout either not set or exceeds deposit timeout"