-
Notifications
You must be signed in to change notification settings - Fork 122
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
Implement state handling for Retracted status #807
base: master
Are you sure you want to change the base?
Conversation
- Provide is_final method for TransactionStatus - Return from watch method as soon as a final state is reached - Provide separate method to populate events for an ExtrinsicReport
return Ok(report); | ||
} | ||
|
||
async fn populate_events(&self, report: &mut ExtrinsicReport<Self::Hash>) -> 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.
I'm not sure about the distribution and function name. We do a lot here:
- Events from the node are fetched
- Events are checked if they contain errors and if so, return an Error
- Copy the events into the report.
So the function name does only describe one of three important points.
How about the following: Let the ExtrinsicReport
implement the function is_success
or similar, as well as the function add_events
for easy event adding. This would not bloat the trait event more and still offer most of the convenience. Caveat: The events still need to be fetched separately. Not sure if it should part of the ExtrinsicReport
struct, as this involves chain interaction.
E.g. it could look like something like this:
let mut report = self
.submit_and_watch_opaque_extrinsic_until_without_events(encoded_extrinsic, watch_until)
.await?;
if watch_until < XtStatus::InBlock {
return Ok(report)
}
let block_hash = report.block_hash.ok_or(Error::BlockHashNotFound)?;
let extrinsic_events =
self.fetch_events_for_extrinsic(block_hash, report.extrinsic_hash).await?;
report.add_events(extrinsic_events);
report.is_success()?;
return Ok(report);
What do you think?
UnexpectedTxStatus
toXtStatus
TransactionStatus
ExtrinsicReport