-
Notifications
You must be signed in to change notification settings - Fork 254
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
Conversation
subxt/src/config/era.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.
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.
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 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)
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.
Looks good and I like the new API where the Era is not exposed anymore.
Some minor questions
Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com>
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 like the changes a lot, will make many things much easier.
Introduce
subxt::config::signed_extensions
. This exposes a trait,SignedExtension
, implementations for the usual signed extensions, and anAnyOf
wrapper which composes signed extensions into a single thing which implementsExtrinsicParams
and uses metadata to determine which extension to apply and in what order.Make some changes to
ExtrinsicParams
to accomodate this, namely providing anOfflineClient
(so that we can get hold of metadata and generally anything else that might be useful), and splitting theencode
methods to anExtrinsicParamsEncoder
trait (necessary so that we canBox<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 anAllOf
containing all of the known signed extensions (that emit data, at least; we can ignore the others). This is used inPolkadotConfig
andSubstrateConfig
(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
.