Conversation
| } | ||
|
|
||
| pub struct RuntimeApi<T: ::subxt::Config + ::subxt::ExtrinsicExtraData<T>> { | ||
| pub struct RuntimeApi<T: ::subxt::Config, E> { |
There was a problem hiding this comment.
Is it worth defaulting these generic params eg
pub struct RuntimeApi<T: ::subxt::Config = ::subxt::DefaultConfig, E = ::subxt::DefaultExtra<::subxt::DefaultConfig>> {
so that we don't have to specify them when instantiating the RuntimeApi unless they differ? Or is the common case that you'll need to specify different ones, so it may as well be explicit?
There was a problem hiding this comment.
I'm not sure TBH, on the one hand it is very convenient if you are using the defaults, on the other if they are hidden then there is not the clue that it is configurable.
I'd lean towards leaving it explicit for now, until the api has solidified and we have an idea of the common usage.
jsdw
left a comment
There was a problem hiding this comment.
Looks great to me; basically a ton of threading a new generic param or two through things for that extra flexibility as far as I understand it. Nice one!
* WIP config * WIP separate default config * Separate trait impls on client * WIP introduce new ApiConfig (to be renamed) trait * Update generated polkadot codegen * Allow configuring Config and Extra types independently * Add extra default configuration * Revert ir parsing of config attr * Add default-features = false to substrate deps * Revert "Add default-features = false to substrate deps" This reverts commit 099d20c.
Closes #331
Currently the
ConfigandExtratrait implementations are hardcoded by the macro, which means that if the target runtime has different types or extrinsic signed extensions, then it will not work.This PR enables the user to supply their own implementations of
ConfigandExtraas parameters to theRuntimeApitype generated by the macro. E.g.Here we are using the built in default implementations as type parameters, but the user is now able to supply their own implementations in their place.
This may not be the final API, since we also need to consider how we can integrate the initialisation of some of the additional signed data (e.g. transaction payment), which currently have default values set. Also we will probably want to use metadata to have the macro generate the correct set of signed extensions, rather than requiring them to be hardcoded upfront.
However these things can be built upon this foundation, which at least allows the user the ability to customise these previously hardcoded types.