-
Notifications
You must be signed in to change notification settings - Fork 17
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
Improve API consistency #85
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.
LGTM
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.
Maybe we could rename the XyzRequest
structs to XyzBuilders
to be more obvious to new SDK users.
Overall, it looks good to me. I think that all my comments can be discussed and addressed in the future.
@@ -229,3 +235,98 @@ impl Default for Eip712TransactionRequest { | |||
} | |||
} | |||
} | |||
|
|||
impl TryFrom<WithdrawRequest> for Eip712TransactionRequest { |
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.
Since a WithdrawRequest
is a subset of Eip712TransactionRequest
s, shouldn't we implement a TryInto
in that module? (following the principle that Eip712TransactionRequest
shouldn't know about its children structures.
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.
The TryFrom
function already implements the functionality of TryInto
, but the reverse isn't necessarily true. By implementing TryFrom
or From
, you automatically gain the corresponding TryInto
or Into
trait respectively. This behavior is outlined in the Rust documentation on this trait.
} | ||
} | ||
|
||
impl From<TransferRequest> for Eip712TransactionRequest { |
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.
Same as my comment for WithdrawRequest
s
} | ||
} | ||
|
||
impl TryFrom<DeployRequest> for Eip712TransactionRequest { |
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.
Same as my comment for WithdrawRequest
s
polling_time_in_seconds: Option<Duration>, | ||
timeout_in_seconds: Option<Duration>, | ||
) -> Result<TransactionReceipt, ProviderError> { | ||
let polling_time_in_seconds = polling_time_in_seconds.unwrap_or(Duration::from_secs(2)); | ||
let mut timer = tokio::time::interval(polling_time_in_seconds); | ||
let start = Instant::now(); | ||
|
||
let transaction_receipt = | ||
self.get_transaction_receipt(tx_hash) |
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.
Maybe we could use TryInto and replace the tx_hash
with a generic parameter in order to avoid double calls to get_transaction_receipt
in the scenario where we already have a TransactionReceipt
at hand.
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 that I understand the suggestion, you mean that the hash should implements the Try_into
to a TransactionReceipt
?
examples/simple_payment/main.rs
Outdated
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.
Are we testing examples in the CI?
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.
No, we are not at the moment
Codecov Report
@@ Coverage Diff @@
## main #85 +/- ##
==========================================
- Coverage 83.02% 73.13% -9.90%
==========================================
Files 13 16 +3
Lines 3170 2021 -1149
==========================================
- Hits 2632 1478 -1154
- Misses 538 543 +5
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
closes #83