From f5cd76fd5605e7873e4659d2dc1a3e4fcfd2a633 Mon Sep 17 00:00:00 2001 From: Filip Lelek Date: Fri, 20 Sep 2024 12:01:44 +0200 Subject: [PATCH] Fix transaction error handling --- fplus-lib/src/config.rs | 2 +- .../src/core/autoallocator/metaallocator_interaction.rs | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/fplus-lib/src/config.rs b/fplus-lib/src/config.rs index 084e40b..2498cca 100644 --- a/fplus-lib/src/config.rs +++ b/fplus-lib/src/config.rs @@ -40,7 +40,7 @@ pub fn default_env_vars() -> &'static HashMap<&'static str, &'static str> { "ALLOCATOR_CONTRACT_ADDRESS", "0x640bD4be149f40714D95aBcD414338bc7CfF39a3", ); - m.insert("AUTOALLOCATION_AMOUNT", "68719476736"); // 68719476736 B == 64 GB + m.insert("AUTOALLOCATION_AMOUNT", "68719476736"); // 68719476736 B == 64 GiB m }) } diff --git a/fplus-lib/src/core/autoallocator/metaallocator_interaction.rs b/fplus-lib/src/core/autoallocator/metaallocator_interaction.rs index f8e1fd4..2a71c14 100644 --- a/fplus-lib/src/core/autoallocator/metaallocator_interaction.rs +++ b/fplus-lib/src/core/autoallocator/metaallocator_interaction.rs @@ -58,13 +58,16 @@ pub async fn add_verified_client(address: &str, amount: &u64) -> Result<(), LDNE .with_input(input) .with_gas_limit(45_000_000); - provider + let tx = provider .send_transaction(tx) .await .map_err(|e| LDNError::New(format!("RPC error: {}", e)))? - .watch() + .get_receipt() .await .map_err(|e| LDNError::New(format!("Transaction failed: {}", e)))?; + if !tx.status() { + return Err(LDNError::New("Transaction failed.".to_string())); + } Ok(()) }