Skip to content

Commit

Permalink
wip: deposit validation error handling
Browse files Browse the repository at this point in the history
* also fix ya-client
  • Loading branch information
kamirr committed Jul 9, 2024
1 parent f1d1b3c commit 8f291e4
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 15 deletions.
15 changes: 2 additions & 13 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 @@ -280,9 +280,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 = "4fb874b81f9dbad2281601d2351383a356c89dd6" }
ya-client = { git = "https://github.com/golemfactory/ya-client.git", rev = "699c62a628070708edb39e3692f7b2052fcd9afa" }
#ya-client = { path = "../ya-client" }
ya-client-model = { git = "https://github.com/golemfactory/ya-client.git", rev = "4fb874b81f9dbad2281601d2351383a356c89dd6" }
ya-client-model = { git = "https://github.com/golemfactory/ya-client.git", rev = "699c62a628070708edb39e3692f7b2052fcd9afa" }
#ya-client-model = "0.7"
golem-certificate = { git = "https://github.com/golemfactory/golem-certificate.git", rev = "f2d7514c18fc066e9cfb796090b90f5b27cfe1c6" }

Expand Down
2 changes: 2 additions & 0 deletions core/payment-driver/erc20/src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -527,11 +527,13 @@ impl Erc20Driver {
};

if let Some(_extra_validation) = deposit.validate {
#[allow(unused)]
let validation_result: Result<(), String> = {
//self.payment_runtime.blah();
unimplemented!("awaiting implementation in erc20_payment_lib")
};

#[allow(unreachable_code)]
if let Err(e) = validation_result {
return Ok(ValidateAllocationResult::DepositValidationError(e));
}
Expand Down
6 changes: 6 additions & 0 deletions core/payment/src/api/allocations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,9 @@ async fn create_allocation(
Ok(ValidateAllocationResult::DepositSpenderMismatch) => {
return bad_req_and_log("Deposit spender doesn't match allocation address".to_string());
}
Ok(ValidateAllocationResult::DepositValidationError(message)) => {
return bad_req_and_log(format!("Deposit contract rejected the deposit: {message}"));
}
Err(Error::Rpc(RpcMessageError::ValidateAllocation(
ValidateAllocationError::AccountNotRegistered,
))) => {
Expand Down Expand Up @@ -557,6 +560,9 @@ async fn amend_allocation(
Ok(ValidateAllocationResult::DepositSpenderMismatch) => {
return bad_req_and_log("Deposit spender doesn't match allocation address".to_string());
}
Ok(ValidateAllocationResult::DepositValidationError(message)) => {
return bad_req_and_log(format!("Deposit contract rejected the deposit: {message}"));
}
Err(Error::Rpc(RpcMessageError::ValidateAllocation(
ValidateAllocationError::AccountNotRegistered,
))) => return response::bad_request(&"Account not registered"),
Expand Down

0 comments on commit 8f291e4

Please sign in to comment.