Skip to content
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

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

Niederb
Copy link
Contributor

@Niederb Niederb commented Oct 8, 2024

  • Move Retracted enum value from UnexpectedTxStatus to XtStatus
  • Provide is_final method for TransactionStatus
    • Currently not used, but I think it makes sense to provide it
  • Return from watch method as soon as a final state is reached
  • Provide separate method to populate events for an ExtrinsicReport

@Niederb Niederb self-assigned this Oct 8, 2024
- 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
@Niederb Niederb marked this pull request as ready for review October 9, 2024 06:43
@Niederb Niederb added E2-breaksapi F7-enhancement Enhances an already existing functionality labels Oct 9, 2024
@Niederb Niederb requested a review from haerdib October 9, 2024 07:24
@Niederb Niederb linked an issue Oct 9, 2024 that may be closed by this pull request
return Ok(report);
}

async fn populate_events(&self, report: &mut ExtrinsicReport<Self::Hash>) -> Result<()> {
Copy link
Contributor

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E2-breaksapi F7-enhancement Enhances an already existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

accept retracted XtStatus
2 participants