pub trait ExtrinsicParamsEncoder: 'static {
// Provided methods
fn encode_value_to(&self, _v: &mut Vec<u8>) { ... }
fn encode_signer_payload_value_to(&self, v: &mut Vec<u8>) { ... }
fn encode_implicit_to(&self, _v: &mut Vec<u8>) { ... }
fn inject_signature(&mut self, _account_id: &dyn Any, _signature: &dyn Any) { ... }
}
Expand description
This trait is expected to be implemented for any ExtrinsicParams
, and
defines how to encode the “additional” and “extra” params. Both functions
are optional and will encode nothing by default.
Provided Methods§
Sourcefn encode_value_to(&self, _v: &mut Vec<u8>)
fn encode_value_to(&self, _v: &mut Vec<u8>)
This is expected to SCALE encode the transaction extension data to some buffer that has been provided. This data is attached to the transaction and also (by default) attached to the signer payload which is signed to provide a signature for the transaction.
If ExtrinsicParamsEncoder::encode_signer_payload_value_to
is implemented,
then that will be used instead when generating a signer payload. Useful for
eg the VerifySignature
extension, which is send with the transaction but
is not a part of the signer payload.
Sourcefn encode_signer_payload_value_to(&self, v: &mut Vec<u8>)
fn encode_signer_payload_value_to(&self, v: &mut Vec<u8>)
See ExtrinsicParamsEncoder::encode_value_to
. This defaults to calling that
method, but if implemented will dictate what is encoded to the signer payload.
Sourcefn encode_implicit_to(&self, _v: &mut Vec<u8>)
fn encode_implicit_to(&self, _v: &mut Vec<u8>)
This is expected to SCALE encode the “implicit” (formally “additional”) parameters to some buffer that has been provided. These parameters are not sent along with the transaction, but are taken into account when signing it, meaning the client and node must agree on their values.
Sourcefn inject_signature(&mut self, _account_id: &dyn Any, _signature: &dyn Any)
fn inject_signature(&mut self, _account_id: &dyn Any, _signature: &dyn Any)
Set the signature. This happens after we have constructed the extrinsic params,
and so is defined here rather than on the params, below. We need to use &dyn Any
to keep this trait object safe, but can downcast in the impls.
§Panics
Implementations of this will likely try to downcast the provided account_id
and signature
into T::AccountId
and T::Signature
(where T: Config
), and are
free to panic if this downcasting does not succeed.
In typical usage, this is not a problem, since this method is only called internally
and provided values which line up with the relevant Config
. In theory though, this
method can be called manually with any types, hence this warning.