From f5496e6abc832b81ac9a0ba937905e10b6dfd93f Mon Sep 17 00:00:00 2001 From: Kamil Koczurek Date: Wed, 12 Jun 2024 12:29:38 +0200 Subject: [PATCH] payment: allow changing deposit validation when amending an allocation --- Cargo.lock | 4 ++-- Cargo.toml | 4 ++-- core/payment/src/api/allocations/mod.rs | 13 +++++++++++++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4de5936338..00a86d35b4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8615,7 +8615,7 @@ dependencies = [ [[package]] name = "ya-client" version = "0.8.0" -source = "git+https://github.com/golemfactory/ya-client.git?rev=ec1643bd27307310e8e5c8715a73967b6341ac60#ec1643bd27307310e8e5c8715a73967b6341ac60" +source = "git+https://github.com/golemfactory/ya-client.git?rev=b60640065835a1fc8eb33d2fb174ec6c0e4b30c4#b60640065835a1fc8eb33d2fb174ec6c0e4b30c4" dependencies = [ "actix-codec", "awc", @@ -8639,7 +8639,7 @@ dependencies = [ [[package]] name = "ya-client-model" version = "0.6.0" -source = "git+https://github.com/golemfactory/ya-client.git?rev=ec1643bd27307310e8e5c8715a73967b6341ac60#ec1643bd27307310e8e5c8715a73967b6341ac60" +source = "git+https://github.com/golemfactory/ya-client.git?rev=b60640065835a1fc8eb33d2fb174ec6c0e4b30c4#b60640065835a1fc8eb33d2fb174ec6c0e4b30c4" dependencies = [ "bigdecimal 0.2.2", "chrono", diff --git a/Cargo.toml b/Cargo.toml index 147ff1b6c3..5a463205c2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -287,9 +287,9 @@ ya-service-api-interfaces = { path = "core/serv-api/interfaces" } ya-service-api-web = { path = "core/serv-api/web" } ## CLIENT -ya-client = { git = "https://github.com/golemfactory/ya-client.git", rev = "ec1643bd27307310e8e5c8715a73967b6341ac60" } +ya-client = { git = "https://github.com/golemfactory/ya-client.git", rev = "b60640065835a1fc8eb33d2fb174ec6c0e4b30c4" } #ya-client = { path = "../ya-client" } -ya-client-model = { git = "https://github.com/golemfactory/ya-client.git", rev = "ec1643bd27307310e8e5c8715a73967b6341ac60" } +ya-client-model = { git = "https://github.com/golemfactory/ya-client.git", rev = "b60640065835a1fc8eb33d2fb174ec6c0e4b30c4" } #ya-client-model = { path = "../ya-client/model" } golem-certificate = { git = "https://github.com/golemfactory/golem-certificate.git", rev = "f2d7514c18fc066e9cfb796090b90f5b27cfe1c6" } diff --git a/core/payment/src/api/allocations/mod.rs b/core/payment/src/api/allocations/mod.rs index 5989b5eeaf..a6bddbba05 100644 --- a/core/payment/src/api/allocations/mod.rs +++ b/core/payment/src/api/allocations/mod.rs @@ -244,10 +244,23 @@ fn amend_allocation_fields( } } + let deposit = match (old_allocation.deposit.clone(), update.deposit) { + (Some(deposit), None) => Some(deposit), + (Some(mut deposit), Some(deposit_update)) => { + deposit.validate = deposit_update.validate; + Some(deposit) + } + (None, None) => None, + (None, Some(_deposit_update)) => { + return Err("Cannot update deposit of an allocation created without one"); + } + }; + Ok(Allocation { total_amount, remaining_amount, timeout: update.timeout.or(old_allocation.timeout), + deposit, ..old_allocation }) }