diff --git a/Cargo.lock b/Cargo.lock index 30886e5260..4d578b5942 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1989,7 +1989,7 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "erc20_payment_lib" version = "0.4.1" -source = "git+https://github.com/golemfactory/erc20_payment_lib?rev=0e693a31ed62a293b7cf11f926a9b159f785107b#0e693a31ed62a293b7cf11f926a9b159f785107b" +source = "git+https://github.com/golemfactory/erc20_payment_lib?rev=9c9224dfdb0818d905876c241bb7b6312975f1cb#9c9224dfdb0818d905876c241bb7b6312975f1cb" dependencies = [ "actix", "actix-files", @@ -2031,7 +2031,7 @@ dependencies = [ [[package]] name = "erc20_payment_lib_common" version = "0.4.1" -source = "git+https://github.com/golemfactory/erc20_payment_lib?rev=0e693a31ed62a293b7cf11f926a9b159f785107b#0e693a31ed62a293b7cf11f926a9b159f785107b" +source = "git+https://github.com/golemfactory/erc20_payment_lib?rev=9c9224dfdb0818d905876c241bb7b6312975f1cb#9c9224dfdb0818d905876c241bb7b6312975f1cb" dependencies = [ "actix-files", "actix-web", @@ -2072,7 +2072,7 @@ dependencies = [ [[package]] name = "erc20_payment_lib_extra" version = "0.4.1" -source = "git+https://github.com/golemfactory/erc20_payment_lib?rev=0e693a31ed62a293b7cf11f926a9b159f785107b#0e693a31ed62a293b7cf11f926a9b159f785107b" +source = "git+https://github.com/golemfactory/erc20_payment_lib?rev=9c9224dfdb0818d905876c241bb7b6312975f1cb#9c9224dfdb0818d905876c241bb7b6312975f1cb" dependencies = [ "actix-files", "actix-web", @@ -2108,7 +2108,7 @@ dependencies = [ [[package]] name = "erc20_processor" version = "0.4.1" -source = "git+https://github.com/golemfactory/erc20_payment_lib?rev=0e693a31ed62a293b7cf11f926a9b159f785107b#0e693a31ed62a293b7cf11f926a9b159f785107b" +source = "git+https://github.com/golemfactory/erc20_payment_lib?rev=9c9224dfdb0818d905876c241bb7b6312975f1cb#9c9224dfdb0818d905876c241bb7b6312975f1cb" dependencies = [ "actix-cors", "actix-files", @@ -2156,7 +2156,7 @@ dependencies = [ [[package]] name = "erc20_rpc_pool" version = "0.4.1" -source = "git+https://github.com/golemfactory/erc20_payment_lib?rev=0e693a31ed62a293b7cf11f926a9b159f785107b#0e693a31ed62a293b7cf11f926a9b159f785107b" +source = "git+https://github.com/golemfactory/erc20_payment_lib?rev=9c9224dfdb0818d905876c241bb7b6312975f1cb#9c9224dfdb0818d905876c241bb7b6312975f1cb" dependencies = [ "actix-files", "actix-web", diff --git a/Cargo.toml b/Cargo.toml index d480c01896..91c10ea9fa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -232,8 +232,8 @@ members = [ # diesel 1.4.* supports up to 0.23.0, but sqlx 0.5.9 requires 0.22.0 # sqlx 0.5.10 need 0.23.2, so 0.5.9 is last version possible derive_more = "0.99.11" -erc20_payment_lib = { git = "https://github.com/golemfactory/erc20_payment_lib", rev = "0e693a31ed62a293b7cf11f926a9b159f785107b" } -erc20_processor = { git = "https://github.com/golemfactory/erc20_payment_lib", rev = "0e693a31ed62a293b7cf11f926a9b159f785107b" } +erc20_payment_lib = { git = "https://github.com/golemfactory/erc20_payment_lib", rev = "9c9224dfdb0818d905876c241bb7b6312975f1cb" } +erc20_processor = { git = "https://github.com/golemfactory/erc20_payment_lib", rev = "9c9224dfdb0818d905876c241bb7b6312975f1cb" } #erc20_payment_lib = { path = "../../payments/erc20_payment_lib/crates/erc20_payment_lib" } #erc20_processor = { path = "../../payments/erc20_payment_lib" } #erc20_payment_lib = { version = "=0.4.1" } diff --git a/core/model/src/driver.rs b/core/model/src/driver.rs index 3fdbb8c5af..1ccb7cb96e 100644 --- a/core/model/src/driver.rs +++ b/core/model/src/driver.rs @@ -316,7 +316,7 @@ pub struct SchedulePayment { sender: String, recipient: String, platform: String, - deposit_id: Option, + deposit_id: Option, due_date: DateTime, } @@ -326,7 +326,7 @@ impl SchedulePayment { sender: String, recipient: String, platform: String, - deposit_id: Option, + deposit_id: Option, due_date: DateTime, ) -> SchedulePayment { SchedulePayment { @@ -355,7 +355,7 @@ impl SchedulePayment { self.platform.clone() } - pub fn deposit_id(&self) -> Option { + pub fn deposit_id(&self) -> Option { self.deposit_id.clone() } diff --git a/core/payment-driver/erc20/src/driver.rs b/core/payment-driver/erc20/src/driver.rs index 21bc7b113f..1526bab709 100644 --- a/core/payment-driver/erc20/src/driver.rs +++ b/core/payment-driver/erc20/src/driver.rs @@ -7,7 +7,7 @@ use chrono::{DateTime, Duration, Utc}; // Extrnal crates use erc20_payment_lib::config::AdditionalOptions; use erc20_payment_lib::faucet_client::faucet_donate; -use erc20_payment_lib::model::{TokenTransferDbObj, TxDbObj}; +use erc20_payment_lib::model::{DepositId, TokenTransferDbObj, TxDbObj}; use erc20_payment_lib::runtime::{ PaymentRuntime, TransferArgs, TransferType, VerifyTransactionResult, }; @@ -119,7 +119,7 @@ impl Erc20Driver { amount: &BigDecimal, network: &str, deadline: Option>, - deposit_id: Option, + deposit_id: Option, ) -> Result { self.is_account_active(sender).await?; let sender = H160::from_str(sender) @@ -130,6 +130,21 @@ impl Erc20Driver { let payment_id = Uuid::new_v4().to_simple().to_string(); + let deposit_id = if let Some(deposit) = deposit_id { + Some(DepositId { + deposit_id: U256::from_str(&deposit.id).map_err(|err| { + GenericError::new(format!("Error when parsing deposit id {err:?}")) + })?, + lock_address: Address::from_str(&deposit.contract).map_err(|err| { + GenericError::new(format!( + "Error when parsing deposit contract address {err:?}" + )) + })?, + }) + } else { + None + }; + self.payment_runtime .transfer_guess_account(TransferArgs { network: network.to_string(), @@ -438,7 +453,13 @@ impl Erc20Driver { let deposit_details = self .payment_runtime - .deposit_details(network.to_string(), deposit_id, deposit_contract) + .deposit_details( + network.to_string(), + DepositId { + deposit_id, + lock_address: deposit_contract, + }, + ) .await .map_err(GenericError::new)?; let deposit_balance = BigDecimal::new( @@ -1079,18 +1100,20 @@ impl PaymentDriver for Erc20Driver { H160::from_str(&msg.from).map_err(|e| { GenericError::new(format!("`{}` address parsing error: {}", msg.from, e)) })?, - H160::from_str(&msg.deposit_contract).map_err(|e| { - GenericError::new(format!( - "`{}` address parsing error: {}", - msg.deposit_contract, e - )) - })?, - U256::from_str(&msg.deposit_id).map_err(|e| { - GenericError::new(format!( - "`{}` deposit id parsing error: {}", - msg.deposit_id, e - )) - })?, + DepositId { + lock_address: H160::from_str(&msg.deposit_contract).map_err(|e| { + GenericError::new(format!( + "`{}` address parsing error: {}", + msg.deposit_contract, e + )) + })?, + deposit_id: U256::from_str(&msg.deposit_id).map_err(|e| { + GenericError::new(format!( + "`{}` deposit id parsing error: {}", + msg.deposit_id, e + )) + })?, + }, ) .await .map_err(|err| GenericError::new(format!("Error releasing deposit: {}", err)))?; diff --git a/core/payment/src/processor.rs b/core/payment/src/processor.rs index 39c40d6669..76b72c64e3 100644 --- a/core/payment/src/processor.rs +++ b/core/payment/src/processor.rs @@ -561,7 +561,7 @@ impl PaymentProcessor { .get(msg.allocation_id.clone(), msg.payer_id) .await?; let deposit_id = if let AllocationStatus::Active(allocation) = allocation_status { - allocation.deposit.clone().map(|deposit| deposit.id) + allocation.deposit } else { None };