Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

payment: allow changing deposit validation when amending an allocation #3246

Merged
merged 2 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }

Expand Down
13 changes: 13 additions & 0 deletions core/payment/src/api/allocations/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
}
Expand Down
Loading