-
Notifications
You must be signed in to change notification settings - Fork 455
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
Added contract::call_with_confirmations(). #102
Added contract::call_with_confirmations(). #102
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good apart from an unhandled error.
src/contract/mod.rs
Outdated
|
||
let fn_data = self.abi.function(func.into()) | ||
.and_then(|function| function.encode_input(¶ms.into_tokens())) | ||
.unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be good to handle the error here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what is the right way to handle this (still getting used to Rust). Should the function return a Result
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have a look at:
rust-web3/src/contract/result.rs
Lines 55 to 63 in a9611d3
impl<T, F, E> From<E> for QueryResult<T, F> where | |
E: Into<contract::Error>, | |
{ | |
fn from(e: E) -> Self { | |
QueryResult { | |
inner: ResultType::Constant(Err(e.into())) | |
} | |
} | |
} |
CallResult
in that case encapsulate an asynchronous result (positive Ok()
and negative Err()
).
We should probably have something similar for SendTransactionWithConfirmation
type.
It will require introducing new state here:
Line 197 in a9611d3
enum SendTransactionWithConfirmationState<T: Transport> { |
that immediately resolves to an error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me know if you need more help with that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think I do need more help with this. Are you saying that call_with_confirmations()
should still return SendTransactionWithConfirmation
, but that SendTransactionWithConfirmation
should have an error state so that any errors that happen in the function can be converted into it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix unwrapped error
Allows you to call a contract function and wait for a specified number of confirmations.