Extrinsic Params Refinement (#1439)

* refinement based approach to params

* doc and test fixes

* bundle refine data into struct
This commit is contained in:
Tadeo Hepperle
2024-03-01 10:04:34 +01:00
committed by GitHub
parent ddd0865fa9
commit 2727f77910
14 changed files with 327 additions and 150 deletions
@@ -58,12 +58,11 @@ impl<T: Config> signed_extensions::SignedExtension<T> for CustomSignedExtension
// Gather together any params we need for our signed extension, here none.
impl<T: Config> ExtrinsicParams<T> for CustomSignedExtension {
type OtherParams = ();
type Params = ();
fn new<Client: OfflineClientT<T>>(
_nonce: u64,
_client: Client,
_other_params: Self::OtherParams,
_params: Self::Params,
) -> Result<Self, ExtrinsicParamsError> {
Ok(CustomSignedExtension)
}
@@ -80,13 +79,13 @@ impl ExtrinsicParamsEncoder for CustomSignedExtension {
}
// When composing a tuple of signed extensions, the user parameters we need must
// be able to convert `Into` a tuple of corresponding `OtherParams`. Here, we just
// "hijack" the default param builder, but add the `OtherParams` (`()`) for our
// be able to convert `Into` a tuple of corresponding `Params`. Here, we just
// "hijack" the default param builder, but add the `Params` (`()`) for our
// new signed extension at the end, to make the types line up. IN reality you may wish
// to construct an entirely new interface to provide the relevant `OtherParams`.
// to construct an entirely new interface to provide the relevant `Params`.
pub fn custom(
params: DefaultExtrinsicParamsBuilder<CustomConfig>,
) -> <<CustomConfig as Config>::ExtrinsicParams as ExtrinsicParams<CustomConfig>>::OtherParams {
) -> <<CustomConfig as Config>::ExtrinsicParams as ExtrinsicParams<CustomConfig>>::Params {
let (a, b, c, d, e, f, g) = params.build();
(a, b, c, d, e, f, g, ())
}