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

Make ExtrinsicParams more flexible, and introduce signed extensions #1107

Merged
merged 11 commits into from
Aug 8, 2023

Conversation

jsdw
Copy link
Collaborator

@jsdw jsdw commented Aug 4, 2023

Introduce subxt::config::signed_extensions. This exposes a trait, SignedExtension, implementations for the usual signed extensions, and an AnyOf wrapper which composes signed extensions into a single thing which implements ExtrinsicParams and uses metadata to determine which extension to apply and in what order.

Make some changes to ExtrinsicParams to accomodate this, namely providing an OfflineClient (so that we can get hold of metadata and generally anything else that might be useful), and splitting the encode methods to an ExtrinsicParamsEncoder trait (necessary so that we can Box<dyn> what we need to be able to dynamically decide which signed extensions to use etc.

There's now a subxt::config::DefaultExtrinsicParams which is just an AllOf containing all of the known signed extensions (that emit data, at least; we can ignore the others). This is used in PolkadotConfig and SubstrateConfig (rendering the two almost identical), and should generally work across various chains.

I updated the docs and examples to show how to write a new signed extension or just fully custom ExtrinsicParams.

@jsdw jsdw force-pushed the jsdw-new-config branch from 11f2da0 to fc004d5 Compare August 4, 2023 16:27
Copy link
Collaborator Author

@jsdw jsdw Aug 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Era is useful behind the scenes for correct encoding etc, but it's not a great interface and so I've hidden it from public view.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually re-exposed it again from utils (but it's still not exposed in any Subxt APIs, just used internally. The reason I did this was just so that people would be able to properly encode mortal transactions in eg the wasm-example using the Era type (so I went back to using that there too)

@jsdw jsdw marked this pull request as ready for review August 7, 2023 11:51
@jsdw jsdw requested a review from a team as a code owner August 7, 2023 11:51
Copy link
Member

@niklasad1 niklasad1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and I like the new API where the Era is not exposed anymore.

Some minor questions

jsdw and others added 3 commits August 7, 2023 15:01
@jsdw jsdw merged commit 9b86b55 into master Aug 8, 2023
@jsdw jsdw deleted the jsdw-new-config branch August 8, 2023 08:37
Copy link
Contributor

@tadeohepperle tadeohepperle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the changes a lot, will make many things much easier.

@jsdw jsdw mentioned this pull request Sep 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants