Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Allow taking out raw bytes from a SubmittableExtrinsic #683

Merged
merged 1 commit into from
Oct 10, 2022

Conversation

MOZGIII
Copy link
Contributor

@MOZGIII MOZGIII commented Oct 6, 2022

This is useful for something like this:

    let balances_transfer_tx = ...;

    let signed_balances_transfer_tx = api
        .tx()
        .create_signed(&balances_transfer_tx, signer, Default::default())
        .await?;

    let extrinsic_hash = Hashing::hash(signed_balances_transfer_tx.encoded());

    // We need `extrinsic_hash` because we want to log it, before we try to submit and watch the extrinsic.
    // We can't use `signed_balances_transfer_tx.submit_and_watch()` as we want to avoid doing the work twice.
    debug!(
        message = "Balance transfer extrinsic signed",
        ?address,
        ?extrinsic_hash
    );

    // Manually do the `watch_extrinsic`.
    let sub = api
      .rpc()
      .watch_extrinsic(Encoded(signed_balances_transfer_tx.into_encoded())) // <---- this is where we need the new API
      .await?

     let mut progress =
        TxProgress::<chain::HumanodeConfig, _>::new(sub, api.clone(), extrinsic_hash);

    // Continue as if we called `signed_balances_transfer_tx.submit_and_watch()`...

@jsdw jsdw merged commit 10def3c into paritytech:master Oct 10, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants