mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-09 20:11:09 +00:00
adjust signed extension examples
This commit is contained in:
@@ -40,7 +40,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
.await?;
|
||||
let current_header = rpc.chain_get_header(None).await?.unwrap();
|
||||
|
||||
let ext_params = Params::new().mortal(¤t_header, 8).build();
|
||||
let ext_params = Params::new().mortal(¤t_header, 8).nonce(current_nonce).build();
|
||||
|
||||
let balance_transfer = polkadot::tx()
|
||||
.balances()
|
||||
@@ -48,7 +48,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
let ext_hash = api
|
||||
.tx()
|
||||
.create_signed_with_nonce(&balance_transfer, &alice, current_nonce, ext_params)?
|
||||
.create_signed(&balance_transfer, &alice, ext_params).await?
|
||||
.submit()
|
||||
.await?;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#![allow(missing_docs)]
|
||||
use codec::Encode;
|
||||
use subxt::client::OfflineClientT;
|
||||
use subxt::config::{Config, ExtrinsicParams, ExtrinsicParamsEncoder, ExtrinsicParamsError};
|
||||
use subxt::config::{Config, ExtrinsicParams, ExtrinsicParamsEncoder, ExtrinsicParamsError, BaseParams, FromBaseParams};
|
||||
use subxt_signer::sr25519::dev;
|
||||
|
||||
#[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata_full.scale")]
|
||||
@@ -51,18 +51,23 @@ impl CustomExtrinsicParamsBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Config> FromBaseParams<T> for CustomExtrinsicParamsBuilder{
|
||||
fn from_base_params(params: &BaseParams<T>) -> Self {
|
||||
Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
// Describe how to fetch and then encode the params:
|
||||
impl<T: Config> ExtrinsicParams<T> for CustomExtrinsicParams<T> {
|
||||
type Params = CustomExtrinsicParamsBuilder;
|
||||
|
||||
// Gather together all of the params we will need to encode:
|
||||
fn new<Client: OfflineClientT<T>>(
|
||||
_nonce: u64,
|
||||
client: Client,
|
||||
fn new(
|
||||
base_params: &BaseParams<T>,
|
||||
other_params: Self::Params,
|
||||
) -> Result<Self, ExtrinsicParamsError> {
|
||||
Ok(Self {
|
||||
genesis_hash: client.genesis_hash(),
|
||||
genesis_hash: base_params.client.genesis_hash(),
|
||||
tip: other_params.tip,
|
||||
foo: other_params.foo,
|
||||
})
|
||||
|
||||
@@ -6,7 +6,7 @@ use subxt::client::OfflineClientT;
|
||||
use subxt::config::signed_extensions;
|
||||
use subxt::config::{
|
||||
Config, DefaultExtrinsicParamsBuilder, ExtrinsicParams, ExtrinsicParamsEncoder,
|
||||
ExtrinsicParamsError,
|
||||
ExtrinsicParamsError, BaseParams
|
||||
};
|
||||
use subxt_signer::sr25519::dev;
|
||||
|
||||
@@ -60,11 +60,7 @@ impl<T: Config> signed_extensions::SignedExtension<T> for CustomSignedExtension
|
||||
impl<T: Config> ExtrinsicParams<T> for CustomSignedExtension {
|
||||
type Params = ();
|
||||
|
||||
fn new<Client: OfflineClientT<T>>(
|
||||
_nonce: u64,
|
||||
_client: Client,
|
||||
_other_params: Self::Params,
|
||||
) -> Result<Self, ExtrinsicParamsError> {
|
||||
fn new( base_params: &BaseParams<T>, _params: Self::Params) -> Result<Self, ExtrinsicParamsError> {
|
||||
Ok(CustomSignedExtension)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user