From 6a2981bba640b7f7b3175d4c1e0516b0e9ab85a9 Mon Sep 17 00:00:00 2001 From: ryuzo-nakata Date: Tue, 12 Nov 2024 11:57:36 +0900 Subject: [PATCH 1/3] fix sign --- src/contract/mod.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/contract/mod.rs b/src/contract/mod.rs index 443fc85..415e042 100644 --- a/src/contract/mod.rs +++ b/src/contract/mod.rs @@ -407,18 +407,23 @@ mod contract_signing { max_priority_fee_per_gas: options.max_priority_fee_per_gas, ..Default::default() }; - if let Some(gas) = options.gas { - tx.gas = gas; + tx.gas = if let Some(gas) = options.gas { + gas } else { - tx.gas = self + match self ._estimate_gas( Address::from_str(&from.to_string().as_str()).unwrap(), &tx, options.call_options.unwrap_or_default(), ) .await - .unwrap(); - } + { + Ok(gas) => gas, + Err(e) => { + return Err(e.to_string().into()); + } + } + }; if let Some(value) = options.value { tx.value = value; } From 045de2964c7bd123ad60e151df313f8182f363be Mon Sep 17 00:00:00 2001 From: ryuzo-nakata Date: Wed, 13 Nov 2024 10:31:32 +0900 Subject: [PATCH 2/3] update --- src/contract/error.rs | 11 +++++++++++ src/contract/mod.rs | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/contract/error.rs b/src/contract/error.rs index 5d693c9..7437bc2 100644 --- a/src/contract/error.rs +++ b/src/contract/error.rs @@ -35,6 +35,17 @@ impl std::error::Error for Error { } } +impl From for crate::error::Error { + fn from(e: Error) -> Self { + match e { + Error::InvalidOutputType(s) => crate::error::Error::InvalidResponse(s), + Error::Abi(eth_error) => crate::error::Error::Decoder(format!("{}", eth_error)), + Error::Api(api_error) => api_error, + Error::InterfaceUnsupported => crate::error::Error::Internal, + } + } +} + pub mod deploy { use crate::{error::Error as ApiError, types::H256}; use derive_more::{Display, From}; diff --git a/src/contract/mod.rs b/src/contract/mod.rs index 415e042..d423174 100644 --- a/src/contract/mod.rs +++ b/src/contract/mod.rs @@ -420,7 +420,7 @@ mod contract_signing { { Ok(gas) => gas, Err(e) => { - return Err(e.to_string().into()); + return Err(e.into()); } } }; From 8b20bfcde7767b491d73f100fd0ada8c65b50d14 Mon Sep 17 00:00:00 2001 From: ryuzo-nakata Date: Wed, 20 Nov 2024 15:36:24 +0900 Subject: [PATCH 3/3] bump to 0.1.10 --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ebd09cd..c19ae46 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1089,7 +1089,7 @@ dependencies = [ [[package]] name = "ic-web3-rs" -version = "0.1.9" +version = "0.1.10" dependencies = [ "arrayvec 0.7.6", "async-std", diff --git a/Cargo.toml b/Cargo.toml index 4f1f860..9f7f003 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ic-web3-rs" -version = "0.1.9" +version = "0.1.10" description = "Ethereum JSON-RPC client for IC canisters." homepage = "https://github.com/horizonx-tech/ic-web3" repository = "https://github.com/horizonx-tech/ic-web3"