Skip to content

Commit

Permalink
Additional parameters for SingedExtra
Browse files Browse the repository at this point in the history
  • Loading branch information
kvinwang committed Nov 16, 2021
1 parent 57ab87b commit 8169327
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ where
where
<<<T as ExtrinsicExtraData<T>>::Extra as SignedExtra<T>>::Extra as SignedExtension>::AdditionalSigned: Send + Sync + 'static
{
let extrinsic = self.create_signed(signer).await?;
let extrinsic = self.create_signed(signer, Default::default()).await?;
self.client
.rpc()
.submit_and_watch_extrinsic(extrinsic, self.client.events_decoder())
Expand All @@ -235,14 +235,15 @@ where
where
<<<T as ExtrinsicExtraData<T>>::Extra as SignedExtra<T>>::Extra as SignedExtension>::AdditionalSigned: Send + Sync + 'static
{
let extrinsic = self.create_signed(signer).await?;
let extrinsic = self.create_signed(signer, Default::default()).await?;
self.client.rpc().submit_extrinsic(extrinsic).await
}

/// Creates a signed extrinsic.
pub async fn create_signed(
&self,
signer: &(dyn Signer<T> + Send + Sync),
additional_params: <T::Extra as SignedExtra<T>>::Parameters,
) -> Result<UncheckedExtrinsic<T>, Error>
where
<<<T as ExtrinsicExtraData<T>>::Extra as SignedExtra<T>>::Extra as SignedExtension>::AdditionalSigned: Send + Sync + 'static
Expand Down Expand Up @@ -273,6 +274,7 @@ where
account_nonce,
call,
signer,
additional_params,
)
.await?;
Ok(signed)
Expand Down
5 changes: 5 additions & 0 deletions src/extrinsic/extra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,13 +230,16 @@ impl SignedExtension for ChargeTransactionPayment {
pub trait SignedExtra<T: Config>: SignedExtension {
/// The type the extras.
type Extra: SignedExtension + Send + Sync;
/// The additional config parameters.
type Parameters: Default + Send + Sync;

/// Creates a new `SignedExtra`.
fn new(
spec_version: u32,
tx_version: u32,
nonce: T::Index,
genesis_hash: T::Hash,
additional_params: Self::Parameters,
) -> Self;

/// Returns the transaction extra.
Expand All @@ -263,12 +266,14 @@ impl<T: Config + Clone + Debug + Eq + Send + Sync> SignedExtra<T> for DefaultExt
CheckWeight<T>,
ChargeTransactionPayment,
);
type Parameters = ();

fn new(
spec_version: u32,
tx_version: u32,
nonce: T::Index,
genesis_hash: T::Hash,
_params: Self::Parameters,
) -> Self {
DefaultExtra {
spec_version,
Expand Down
2 changes: 2 additions & 0 deletions src/extrinsic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ pub async fn create_signed<T>(
nonce: T::Index,
call: Encoded,
signer: &(dyn Signer<T> + Send + Sync),
additional_params: <T::Extra as SignedExtra<T>>::Parameters,
) -> Result<UncheckedExtrinsic<T>, Error>
where
T: Config + ExtrinsicExtraData<T>,
Expand All @@ -81,6 +82,7 @@ where
tx_version,
nonce,
genesis_hash,
additional_params,
);
let payload = SignedPayload::<T>::new(call, extra.extra())?;
let signed = signer.sign(payload).await?;
Expand Down

0 comments on commit 8169327

Please sign in to comment.