mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 07:41:08 +00:00
adjust examples
This commit is contained in:
@@ -40,7 +40,10 @@ 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).nonce(current_nonce).build();
|
||||
let ext_params = Params::new()
|
||||
.mortal(¤t_header, 8)
|
||||
.nonce(current_nonce)
|
||||
.build();
|
||||
|
||||
let balance_transfer = polkadot::tx()
|
||||
.balances()
|
||||
@@ -48,7 +51,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
let ext_hash = api
|
||||
.tx()
|
||||
.create_signed(&balance_transfer, &alice, ext_params).await?
|
||||
.create_signed(&balance_transfer, &alice, ext_params)
|
||||
.await?
|
||||
.submit()
|
||||
.await?;
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#![allow(missing_docs)]
|
||||
use codec::Encode;
|
||||
use subxt::client::OfflineClientT;
|
||||
use subxt::config::{Config, ExtrinsicParams, ExtrinsicParamsEncoder, ExtrinsicParamsError, BaseParams, FromBaseParams};
|
||||
use subxt::config::{
|
||||
BaseParams, Config, ExtrinsicParams, ExtrinsicParamsEncoder, ExtrinsicParamsError,
|
||||
FromBaseParams,
|
||||
};
|
||||
use subxt_signer::sr25519::dev;
|
||||
|
||||
#[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata_full.scale")]
|
||||
@@ -51,8 +53,8 @@ impl CustomExtrinsicParamsBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Config> FromBaseParams<T> for CustomExtrinsicParamsBuilder{
|
||||
fn from_base_params(params: &BaseParams<T>) -> Self {
|
||||
impl<T: Config> FromBaseParams<T> for CustomExtrinsicParamsBuilder {
|
||||
fn from_base_params(_params: &BaseParams<T>) -> Self {
|
||||
Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,10 @@
|
||||
use codec::Encode;
|
||||
use scale_encode::EncodeAsType;
|
||||
use scale_info::PortableRegistry;
|
||||
use subxt::client::OfflineClientT;
|
||||
use subxt::config::signed_extensions;
|
||||
use subxt::config::{
|
||||
Config, DefaultExtrinsicParamsBuilder, ExtrinsicParams, ExtrinsicParamsEncoder,
|
||||
ExtrinsicParamsError, BaseParams
|
||||
BaseParams, Config, DefaultExtrinsicParamsBuilder, ExtrinsicParams, ExtrinsicParamsEncoder,
|
||||
ExtrinsicParamsError,
|
||||
};
|
||||
use subxt_signer::sr25519::dev;
|
||||
|
||||
@@ -60,7 +59,10 @@ impl<T: Config> signed_extensions::SignedExtension<T> for CustomSignedExtension
|
||||
impl<T: Config> ExtrinsicParams<T> for CustomSignedExtension {
|
||||
type Params = ();
|
||||
|
||||
fn new( base_params: &BaseParams<T>, _params: Self::Params) -> Result<Self, ExtrinsicParamsError> {
|
||||
fn new(
|
||||
_base_params: &BaseParams<T>,
|
||||
_params: Self::Params,
|
||||
) -> Result<Self, ExtrinsicParamsError> {
|
||||
Ok(CustomSignedExtension)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,8 +103,8 @@ impl<T: Config> DefaultExtrinsicParamsBuilder<T> {
|
||||
self
|
||||
}
|
||||
|
||||
/// Provide a specific nonce for the submitter of the extrinsic
|
||||
pub fn nonce(mut self, nonce: u64) -> Self {
|
||||
/// Provide a specific nonce for the submitter of the extrinsic
|
||||
pub fn nonce(mut self, nonce: u64) -> Self {
|
||||
self.nonce = Some(nonce);
|
||||
self
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ use super::extrinsic_params::{ExtrinsicParams, ExtrinsicParamsEncoder, Extrinsic
|
||||
use super::{BaseParams, FromBaseParams};
|
||||
use crate::config::Header;
|
||||
use crate::utils::Era;
|
||||
use crate::{client::OfflineClientT, Config};
|
||||
use crate::Config;
|
||||
use codec::{Compact, Encode};
|
||||
use core::fmt::Debug;
|
||||
use derivative::Derivative;
|
||||
@@ -43,7 +43,7 @@ impl<T: Config> ExtrinsicParams<T> for CheckSpecVersion {
|
||||
|
||||
fn new(
|
||||
base_params: &BaseParams<T>,
|
||||
params: Self::Params,
|
||||
_params: Self::Params,
|
||||
) -> Result<Self, ExtrinsicParamsError> {
|
||||
Ok(CheckSpecVersion(
|
||||
base_params.client.runtime_version().spec_version,
|
||||
@@ -74,7 +74,7 @@ impl<T: Config> ExtrinsicParams<T> for CheckNonce {
|
||||
base_params: &BaseParams<T>,
|
||||
params: Self::Params,
|
||||
) -> Result<Self, ExtrinsicParamsError> {
|
||||
let nonce = params.0.unwrap_or_else(|| base_params.nonce);
|
||||
let nonce = params.0.unwrap_or(base_params.nonce);
|
||||
Ok(CheckNonce(Compact(nonce)))
|
||||
}
|
||||
}
|
||||
@@ -110,7 +110,7 @@ impl<T: Config> ExtrinsicParams<T> for CheckTxVersion {
|
||||
|
||||
fn new(
|
||||
base_params: &BaseParams<T>,
|
||||
params: Self::Params,
|
||||
_params: Self::Params,
|
||||
) -> Result<Self, ExtrinsicParamsError> {
|
||||
Ok(CheckTxVersion(
|
||||
base_params.client.runtime_version().transaction_version,
|
||||
@@ -139,7 +139,7 @@ impl<T: Config> ExtrinsicParams<T> for CheckGenesis<T> {
|
||||
|
||||
fn new(
|
||||
base_params: &BaseParams<T>,
|
||||
params: Self::Params,
|
||||
_params: Self::Params,
|
||||
) -> Result<Self, ExtrinsicParamsError> {
|
||||
Ok(CheckGenesis(base_params.client.genesis_hash()))
|
||||
}
|
||||
@@ -279,7 +279,7 @@ impl<T: Config> Default for ChargeAssetTxPaymentParams<T> {
|
||||
}
|
||||
|
||||
impl<T: Config> FromBaseParams<T> for ChargeAssetTxPaymentParams<T> {
|
||||
fn from_base_params(params: &BaseParams<T>) -> Self {
|
||||
fn from_base_params(_params: &BaseParams<T>) -> Self {
|
||||
Default::default()
|
||||
}
|
||||
}
|
||||
@@ -312,7 +312,7 @@ impl<T: Config> ExtrinsicParams<T> for ChargeAssetTxPayment<T> {
|
||||
type Params = ChargeAssetTxPaymentParams<T>;
|
||||
|
||||
fn new(
|
||||
base_params: &BaseParams<T>,
|
||||
_base_params: &BaseParams<T>,
|
||||
params: Self::Params,
|
||||
) -> Result<Self, ExtrinsicParamsError> {
|
||||
Ok(ChargeAssetTxPayment {
|
||||
@@ -355,7 +355,7 @@ pub struct ChargeTransactionPaymentParams {
|
||||
}
|
||||
|
||||
impl<T: Config> FromBaseParams<T> for ChargeTransactionPaymentParams {
|
||||
fn from_base_params(params: &BaseParams<T>) -> Self {
|
||||
fn from_base_params(_params: &BaseParams<T>) -> Self {
|
||||
Default::default()
|
||||
}
|
||||
}
|
||||
@@ -375,7 +375,7 @@ impl<T: Config> ExtrinsicParams<T> for ChargeTransactionPayment {
|
||||
type Params = ChargeTransactionPaymentParams;
|
||||
|
||||
fn new(
|
||||
base_params: &BaseParams<T>,
|
||||
_base_params: &BaseParams<T>,
|
||||
params: Self::Params,
|
||||
) -> Result<Self, ExtrinsicParamsError> {
|
||||
Ok(ChargeTransactionPayment {
|
||||
|
||||
@@ -348,6 +348,10 @@ mod test {
|
||||
fn runtime_version(&self) -> crate::backend::RuntimeVersion {
|
||||
unimplemented!("just a mock impl to satisfy trait bounds")
|
||||
}
|
||||
|
||||
fn base_client(&self) -> crate::client::BaseClient<SubstrateConfig> {
|
||||
unimplemented!("just a mock impl to satisfy trait bounds")
|
||||
}
|
||||
}
|
||||
|
||||
impl OnlineClientT<SubstrateConfig> for MockClient {
|
||||
|
||||
Reference in New Issue
Block a user