mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 14:01:06 +00:00
start fixing examples and cleaning up interface
This commit is contained in:
@@ -11,11 +11,8 @@ use crate::client::ClientBase;
|
||||
|
||||
use super::Config;
|
||||
use crate::ExtrinsicParamsError;
|
||||
use alloc::string::String;
|
||||
use alloc::vec::Vec;
|
||||
use core::fmt::Debug;
|
||||
|
||||
use derive_more::Display;
|
||||
use alloc::vec::Vec;
|
||||
|
||||
/// This trait allows you to configure the "signed extra" and
|
||||
/// "additional" parameters that are a part of the transaction payload
|
||||
@@ -29,7 +26,7 @@ pub trait ExtrinsicParams<T: Config>: ExtrinsicParamsEncoder + Sized + 'static {
|
||||
/// Construct a new instance of our [`ExtrinsicParams`].
|
||||
fn new(
|
||||
nonce: u64,
|
||||
client: &ClientBase<T>,
|
||||
client: ClientBase<T>,
|
||||
other_params: Self::OtherParams,
|
||||
) -> Result<Self, ExtrinsicParamsError>;
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ impl<T: Config> ExtrinsicParams<T> for CheckSpecVersion {
|
||||
|
||||
fn new(
|
||||
_nonce: u64,
|
||||
client: &ClientBase<T>,
|
||||
client: ClientBase<T>,
|
||||
_other_params: Self::OtherParams,
|
||||
) -> Result<Self, ExtrinsicParamsError> {
|
||||
Ok(CheckSpecVersion(client.runtime_version().spec_version))
|
||||
@@ -73,7 +73,7 @@ impl<T: Config> ExtrinsicParams<T> for CheckNonce {
|
||||
|
||||
fn new(
|
||||
nonce: u64,
|
||||
_client: &ClientBase<T>,
|
||||
_client: ClientBase<T>,
|
||||
_other_params: Self::OtherParams,
|
||||
) -> Result<Self, ExtrinsicParamsError> {
|
||||
Ok(CheckNonce(Compact(nonce)))
|
||||
@@ -101,7 +101,7 @@ impl<T: Config> ExtrinsicParams<T> for CheckTxVersion {
|
||||
|
||||
fn new(
|
||||
_nonce: u64,
|
||||
client: &ClientBase<T>,
|
||||
client: ClientBase<T>,
|
||||
_other_params: Self::OtherParams,
|
||||
) -> Result<Self, ExtrinsicParamsError> {
|
||||
Ok(CheckTxVersion(client.runtime_version().transaction_version))
|
||||
@@ -129,7 +129,7 @@ impl<T: Config> ExtrinsicParams<T> for CheckGenesis<T> {
|
||||
|
||||
fn new(
|
||||
_nonce: u64,
|
||||
client: &ClientBase<T>,
|
||||
client: ClientBase<T>,
|
||||
_other_params: Self::OtherParams,
|
||||
) -> Result<Self, ExtrinsicParamsError> {
|
||||
Ok(CheckGenesis(client.genesis_hash()))
|
||||
@@ -195,7 +195,7 @@ impl<T: Config> ExtrinsicParams<T> for CheckMortality<T> {
|
||||
|
||||
fn new(
|
||||
_nonce: u64,
|
||||
client: &ClientBase<T>,
|
||||
client: ClientBase<T>,
|
||||
other_params: Self::OtherParams,
|
||||
) -> Result<Self, ExtrinsicParamsError> {
|
||||
Ok(CheckMortality {
|
||||
@@ -286,7 +286,7 @@ impl<T: Config> ExtrinsicParams<T> for ChargeAssetTxPayment<T> {
|
||||
|
||||
fn new(
|
||||
_nonce: u64,
|
||||
_client: &ClientBase<T>,
|
||||
_client: ClientBase<T>,
|
||||
other_params: Self::OtherParams,
|
||||
) -> Result<Self, ExtrinsicParamsError> {
|
||||
Ok(ChargeAssetTxPayment {
|
||||
@@ -344,7 +344,7 @@ impl<T: Config> ExtrinsicParams<T> for ChargeTransactionPayment {
|
||||
|
||||
fn new(
|
||||
_nonce: u64,
|
||||
_client: &ClientBase<T>,
|
||||
_client: ClientBase<T>,
|
||||
other_params: Self::OtherParams,
|
||||
) -> Result<Self, ExtrinsicParamsError> {
|
||||
Ok(ChargeTransactionPayment {
|
||||
@@ -388,7 +388,7 @@ macro_rules! impl_tuples {
|
||||
|
||||
fn new(
|
||||
nonce: u64,
|
||||
client: &ClientBase<T>,
|
||||
client: ClientBase<T>,
|
||||
other_params: Self::OtherParams,
|
||||
) -> Result<Self, ExtrinsicParamsError> {
|
||||
let metadata = client.metadata();
|
||||
@@ -405,7 +405,7 @@ macro_rules! impl_tuples {
|
||||
}
|
||||
// Break and record as soon as we find a match:
|
||||
if $ident::matches(e.identifier(), e.extra_ty(), types) {
|
||||
let ext = $ident::new(nonce, client, other_params.$index)?;
|
||||
let ext = $ident::new(nonce, client.clone(), other_params.$index)?;
|
||||
let boxed_ext: Box<dyn ExtrinsicParamsEncoder> = Box::new(ext);
|
||||
exts_by_index.insert(idx, boxed_ext);
|
||||
break
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
|
||||
use super::{Config, DefaultExtrinsicParams, DefaultExtrinsicParamsBuilder, Hasher, Header};
|
||||
pub use crate::utils::{AccountId32, MultiAddress, MultiSignature};
|
||||
use alloc::string::String;
|
||||
use alloc::vec::Vec;
|
||||
use codec::{Decode, Encode};
|
||||
pub use primitive_types::{H256, U256};
|
||||
@@ -289,10 +288,7 @@ impl From<U256> for NumberOrHex {
|
||||
}
|
||||
}
|
||||
|
||||
/// A quick helper to encode some bytes to hex.
|
||||
fn to_hex(bytes: impl AsRef<[u8]>) -> String {
|
||||
alloc::format!("0x{}", hex::encode(bytes.as_ref()))
|
||||
}
|
||||
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
|
||||
@@ -52,7 +52,7 @@ pub fn get_constant<Address: ConstantAddress>(
|
||||
let value = <Address::Target as DecodeWithMetadata>::decode_with_metadata(
|
||||
&mut constant.value(),
|
||||
constant.ty(),
|
||||
&metadata,
|
||||
metadata,
|
||||
)?;
|
||||
Ok(value)
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ pub fn get_custom_value<Address: CustomValueAddress<IsDecodable = Yes> + ?Sized>
|
||||
let value = <Address::Target as DecodeWithMetadata>::decode_with_metadata(
|
||||
&mut custom_value.bytes(),
|
||||
custom_value.type_id(),
|
||||
&metadata,
|
||||
metadata,
|
||||
)?;
|
||||
Ok(value)
|
||||
}
|
||||
|
||||
+1
-7
@@ -33,14 +33,8 @@ pub use config::{
|
||||
pub use metadata::Metadata;
|
||||
pub use signer::Signer;
|
||||
pub use storage::StorageAddress;
|
||||
pub use utils::{AccountId32, MultiAddress, MultiSignature, H160, H256, H512};
|
||||
pub use utils::{AccountId32, MultiAddress, MultiSignature, H160, H256, H512, Yes, to_hex};
|
||||
|
||||
#[macro_use]
|
||||
mod macros;
|
||||
|
||||
mod marker {
|
||||
/// A unit marker struct signalling that some property is true
|
||||
pub struct Yes;
|
||||
}
|
||||
|
||||
pub use marker::Yes;
|
||||
|
||||
@@ -78,3 +78,11 @@ unsafe impl<T> Sync for PhantomDataSendSync<T> {}
|
||||
/// with collections like BTreeMap. This has the same type params
|
||||
/// as `BTreeMap` which allows us to easily swap the two during codegen.
|
||||
pub type KeyedVec<K, V> = Vec<(K, V)>;
|
||||
|
||||
/// A unit marker struct signalling that some property is true
|
||||
pub struct Yes;
|
||||
|
||||
/// A quick helper to encode some bytes to hex.
|
||||
pub fn to_hex(bytes: impl AsRef<[u8]>) -> String {
|
||||
alloc::format!("0x{}", hex::encode(bytes.as_ref()))
|
||||
}
|
||||
Reference in New Issue
Block a user