cargo +nightly fmt

This commit is contained in:
Tadeo hepperle
2023-05-10 14:26:10 +02:00
parent 213bc4c47a
commit a3419a6f44
94 changed files with 326 additions and 259 deletions
+4 -3
View File
@@ -2,6 +2,10 @@
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
// see LICENSE for license details.
use std::sync::Arc;
use futures::lock::Mutex as AsyncMutex;
use crate::{
blocks::{extrinsic_types::ExtrinsicPartTypeIds, Extrinsics},
client::{OfflineClientT, OnlineClientT},
@@ -13,9 +17,6 @@ use crate::{
storage::Storage,
};
use futures::lock::Mutex as AsyncMutex;
use std::sync::Arc;
/// A representation of a block.
pub struct Block<T: Config, C> {
header: T::Header,
+5 -3
View File
@@ -2,6 +2,11 @@
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
// see LICENSE for license details.
use std::{future::Future, pin::Pin};
use derivative::Derivative;
use futures::{future::Either, stream, Stream, StreamExt};
use super::Block;
use crate::{
client::OnlineClientT,
@@ -9,9 +14,6 @@ use crate::{
error::{BlockError, Error},
utils::PhantomDataSendSync,
};
use derivative::Derivative;
use futures::{future::Either, stream, Stream, StreamExt};
use std::{future::Future, pin::Pin};
type BlockStream<T> = Pin<Box<dyn Stream<Item = Result<T, Error>> + Send>>;
type BlockStreamRes<T> = Result<BlockStream<T>, Error>;
+10 -8
View File
@@ -2,6 +2,13 @@
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
// see LICENSE for license details.
use std::{collections::HashMap, sync::Arc};
use codec::Decode;
use derivative::Derivative;
use frame_metadata::v15::RuntimeMetadataV15;
use scale_decode::DecodeAsFields;
use crate::{
blocks::block_types::{get_events, CachedEvents},
client::{OfflineClientT, OnlineClientT},
@@ -13,12 +20,6 @@ use crate::{
Metadata,
};
use codec::Decode;
use derivative::Derivative;
use frame_metadata::v15::RuntimeMetadataV15;
use scale_decode::DecodeAsFields;
use std::{collections::HashMap, sync::Arc};
/// Trait to uniquely identify the extrinsic's identity from the runtime metadata.
///
/// Generated API structures that represent an extrinsic implement this trait.
@@ -622,8 +623,6 @@ impl<T: Config> ExtrinsicEvents<T> {
#[cfg(test)]
mod tests {
use super::*;
use crate::{rpc::types::RuntimeVersion, OfflineClient, PolkadotConfig};
use assert_matches::assert_matches;
use codec::{Decode, Encode};
use frame_metadata::{
@@ -634,6 +633,9 @@ mod tests {
use scale_info::{meta_type, TypeInfo};
use scale_value::Value;
use super::*;
use crate::{rpc::types::RuntimeVersion, OfflineClient, PolkadotConfig};
// Extrinsic needs to contain at least the generic type parameter "Call"
// for the metadata to be valid.
// The "Call" type from the metadata is used to decode extrinsics.
+3 -4
View File
@@ -12,12 +12,11 @@ mod offline_client;
mod online_client;
pub use offline_client::{OfflineClient, OfflineClientT};
pub use online_client::{
ClientRuntimeUpdater, OnlineClient, OnlineClientT, RuntimeUpdaterStream, Update, UpgradeError,
};
#[cfg(any(
feature = "jsonrpsee-ws",
all(feature = "jsonrpsee-web", target_arch = "wasm32")
))]
pub use online_client::default_rpc_client;
pub use online_client::{
ClientRuntimeUpdater, OnlineClient, OnlineClientT, RuntimeUpdaterStream, Update, UpgradeError,
};
+4 -2
View File
@@ -2,13 +2,15 @@
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
// see LICENSE for license details.
use std::sync::Arc;
use derivative::Derivative;
use crate::{
blocks::BlocksClient, constants::ConstantsClient, events::EventsClient,
rpc::types::RuntimeVersion, runtime_api::RuntimeApiClient, storage::StorageClient,
tx::TxClient, Config, Metadata,
};
use derivative::Derivative;
use std::sync::Arc;
/// A trait representing a client that can perform
/// offline-only actions.
+6 -4
View File
@@ -2,6 +2,12 @@
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
// see LICENSE for license details.
use std::sync::Arc;
use derivative::Derivative;
use futures::future;
use parking_lot::RwLock;
use super::{OfflineClient, OfflineClientT};
use crate::{
blocks::BlocksClient,
@@ -17,10 +23,6 @@ use crate::{
tx::TxClient,
Config, Metadata,
};
use derivative::Derivative;
use futures::future;
use parking_lot::RwLock;
use std::sync::Arc;
/// A trait representing a client that can perform
/// online actions.
+4 -2
View File
@@ -7,12 +7,14 @@
//! implementation of the trait is provided ([`BaseExtrinsicParams`]) which is
//! used by the provided Substrate and Polkadot configuration.
use crate::{utils::Encoded, Config};
use codec::{Compact, Decode, Encode};
use core::fmt::Debug;
use codec::{Compact, Decode, Encode};
use derivative::Derivative;
use serde::{Deserialize, Serialize};
use crate::{utils::Encoded, Config};
/// This trait allows you to configure the "signed extra" and
/// "additional" parameters that are signed and used in transactions.
/// see [`BaseExtrinsicParams`] for an implementation that is compatible with
+4 -3
View File
@@ -12,12 +12,12 @@ pub mod extrinsic_params;
pub mod polkadot;
pub mod substrate;
use codec::{Decode, Encode};
use core::fmt::Debug;
use serde::{de::DeserializeOwned, Serialize};
use codec::{Decode, Encode};
pub use extrinsic_params::ExtrinsicParams;
pub use polkadot::PolkadotConfig;
use serde::{de::DeserializeOwned, Serialize};
pub use substrate::SubstrateConfig;
/// Runtime types.
@@ -115,9 +115,10 @@ impl<T: Config, E: extrinsic_params::ExtrinsicParams<T::Index, T::Hash>> Config
/// implement subxt's Hasher and Header traits for some substrate structs
#[cfg(feature = "substrate-compat")]
mod substrate_impls {
use super::*;
use primitive_types::{H256, U256};
use super::*;
impl<N, H> Header for sp_runtime::generic::Header<N, H>
where
Self: Encode,
+3 -3
View File
@@ -4,15 +4,15 @@
//! Polkadot specific configuration
use codec::Encode;
pub use primitive_types::{H256, U256};
use super::{
extrinsic_params::{BaseExtrinsicParams, BaseExtrinsicParamsBuilder},
Config,
};
use codec::Encode;
pub use crate::utils::{AccountId32, MultiAddress, MultiSignature};
use crate::SubstrateConfig;
pub use primitive_types::{H256, U256};
/// Default set of commonly used types by Polkadot nodes.
pub enum PolkadotConfig {}
+4 -4
View File
@@ -4,15 +4,15 @@
//! Substrate specific configuration
use codec::{Decode, Encode};
pub use primitive_types::{H256, U256};
use serde::{Deserialize, Serialize};
use super::{
extrinsic_params::{BaseExtrinsicParams, BaseExtrinsicParamsBuilder},
Config, Hasher, Header,
};
use codec::{Decode, Encode};
use serde::{Deserialize, Serialize};
pub use crate::utils::{AccountId32, MultiAddress, MultiSignature};
pub use primitive_types::{H256, U256};
/// Default set of commonly used types by Substrate runtimes.
// Note: We only use this at the type level, so it should be impossible to
+2 -1
View File
@@ -2,9 +2,10 @@
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
// see LICENSE for license details.
use crate::{dynamic::DecodedValueThunk, metadata::DecodeWithMetadata};
use std::borrow::Cow;
use crate::{dynamic::DecodedValueThunk, metadata::DecodeWithMetadata};
/// This represents a constant address. Anything implementing this trait
/// can be used to fetch constants.
pub trait ConstantAddress {
+2 -1
View File
@@ -2,6 +2,8 @@
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
// see LICENSE for license details.
use derivative::Derivative;
use super::ConstantAddress;
use crate::{
client::OfflineClientT,
@@ -9,7 +11,6 @@ use crate::{
metadata::{DecodeWithMetadata, MetadataError},
Config,
};
use derivative::Derivative;
/// A client for accessing constants.
#[derive(Derivative)]
+6 -9
View File
@@ -5,13 +5,13 @@
//! This module provides the entry points to create dynamic
//! transactions, storage and constant lookups.
use scale_decode::DecodeAsType;
pub use scale_value::{At, Value};
use crate::{
error::Error,
metadata::{DecodeWithMetadata, Metadata},
};
use scale_decode::DecodeAsType;
pub use scale_value::{At, Value};
/// A [`scale_value::Value`] type endowed with contextual information
/// regarding what type was used to decode each part of it. This implements
@@ -20,16 +20,13 @@ pub use scale_value::{At, Value};
pub type DecodedValue = scale_value::Value<scale_value::scale::TypeId>;
// Submit dynamic transactions.
pub use crate::tx::dynamic as tx;
// Lookup constants dynamically.
pub use crate::constants::dynamic as constant;
// Lookup storage values dynamically.
pub use crate::storage::{dynamic as storage, dynamic_root as storage_root};
// Execute runtime API function call dynamically.
pub use crate::runtime_api::dynamic as runtime_api_call;
// Lookup storage values dynamically.
pub use crate::storage::{dynamic as storage, dynamic_root as storage_root};
pub use crate::tx::dynamic as tx;
/// This is the result of making a dynamic request to a node. From this,
/// we can return the raw SCALE bytes that we were handed back, or we can
+6 -3
View File
@@ -5,13 +5,16 @@
//! A representation of the dispatch error; an error returned when
//! something fails in trying to submit/execute a transaction.
use crate::metadata::{DecodeWithMetadata, Metadata};
use core::fmt::Debug;
use scale_decode::visitor::DecodeAsTypeResult;
use std::borrow::Cow;
use scale_decode::visitor::DecodeAsTypeResult;
use super::Error;
use crate::error::RootError;
use crate::{
error::RootError,
metadata::{DecodeWithMetadata, Metadata},
};
/// An error dispatching a transaction.
#[derive(Debug, thiserror::Error, PartialEq, Eq)]
+2 -2
View File
@@ -12,11 +12,11 @@ use core::fmt::Debug;
pub use dispatch_error::{
ArithmeticError, DispatchError, ModuleError, RawModuleError, TokenError, TransactionalError,
};
pub use scale_decode::Error as DecodeError;
pub use scale_encode::Error as EncodeError;
// Re-expose the errors we use from other crates here:
pub use crate::metadata::{InvalidMetadataError, Metadata, MetadataError};
pub use scale_decode::Error as DecodeError;
pub use scale_encode::Error as EncodeError;
/// The underlying error enum, generic over the type held by the `Runtime`
/// variant. Prefer to use the [`Error<E>`] and [`Error`] aliases over
+4 -2
View File
@@ -2,10 +2,12 @@
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
// see LICENSE for license details.
use crate::{client::OnlineClientT, error::Error, events::Events, rpc::types::StorageKey, Config};
use derivative::Derivative;
use std::future::Future;
use derivative::Derivative;
use crate::{client::OnlineClientT, error::Error, events::Events, rpc::types::StorageKey, Config};
/// A client for working with events.
#[derive(Derivative)]
#[derivative(Clone(bound = "Client: Clone"))]
+14 -9
View File
@@ -4,6 +4,11 @@
//! A representation of a block of events.
use std::sync::Arc;
use codec::{Compact, Decode};
use derivative::Derivative;
use super::{Phase, StaticEvent};
use crate::{
client::OnlineClientT,
@@ -12,9 +17,6 @@ use crate::{
metadata::{DecodeWithMetadata, EventMetadata},
Config, Metadata,
};
use codec::{Compact, Decode};
use derivative::Derivative;
use std::sync::Arc;
/// A collection of events obtained from a block, bundled with the necessary
/// information needed to decode and iterate over them.
@@ -426,15 +428,17 @@ pub trait RootEvent: Sized {
/// Event related test utilities used outside this module.
#[cfg(test)]
pub(crate) mod test_utils {
use super::*;
use crate::{Config, SubstrateConfig};
use std::convert::TryFrom;
use codec::Encode;
use frame_metadata::{
v15::{ExtrinsicMetadata, PalletEventMetadata, PalletMetadata, RuntimeMetadataV15},
RuntimeMetadataPrefixed,
};
use scale_info::{meta_type, TypeInfo};
use std::convert::TryFrom;
use super::*;
use crate::{Config, SubstrateConfig};
/// An "outer" events enum containing exactly one event.
#[derive(
@@ -576,13 +580,14 @@ pub(crate) mod test_utils {
#[cfg(test)]
mod tests {
use codec::Encode;
use scale_info::TypeInfo;
use scale_value::Value;
use super::{
test_utils::{event_record, events, events_raw, AllEvents},
*,
};
use codec::Encode;
use scale_info::TypeInfo;
use scale_value::Value;
/// Build a fake wrapped metadata.
fn metadata<E: TypeInfo + 'static>() -> Metadata {
+2 -3
View File
@@ -38,12 +38,11 @@ pub mod book;
// Suppress an unused dependency warning because tokio is
// only used in example code snippets at the time of writing.
#[cfg(test)]
use tokio as _;
// Used to enable the js feature for wasm.
#[cfg(target_arch = "wasm32")]
pub use getrandom as _;
#[cfg(test)]
use tokio as _;
#[cfg(all(feature = "jsonrpsee-ws", feature = "jsonrpsee-web"))]
std::compile_error!(
+2 -1
View File
@@ -2,9 +2,10 @@
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
// see LICENSE for license details.
use parking_lot::RwLock;
use std::{borrow::Cow, collections::HashMap};
use parking_lot::RwLock;
/// A cache with the simple goal of storing 32 byte hashes against root+item keys
#[derive(Default, Debug)]
pub struct HashCache {
+7 -4
View File
@@ -2,15 +2,17 @@
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
// see LICENSE for license details.
use super::hash_cache::HashCache;
use std::{collections::HashMap, convert::TryFrom, sync::Arc};
use codec::Error as CodecError;
use frame_metadata::{
v15::PalletConstantMetadata, v15::RuntimeMetadataV15, v15::StorageEntryMetadata,
v15::{PalletConstantMetadata, RuntimeMetadataV15, StorageEntryMetadata},
RuntimeMetadata, RuntimeMetadataPrefixed, META_RESERVED,
};
use parking_lot::RwLock;
use scale_info::{form::PortableForm, PortableRegistry, Type};
use std::{collections::HashMap, convert::TryFrom, sync::Arc};
use super::hash_cache::HashCache;
/// Metadata error originated from inspecting the internal representation of the runtime metadata.
#[derive(Debug, thiserror::Error, PartialEq, Eq)]
@@ -723,13 +725,14 @@ impl TryFrom<RuntimeMetadataPrefixed> for Metadata {
#[cfg(test)]
mod tests {
use super::*;
use frame_metadata::v15::{
ExtrinsicMetadata, PalletCallMetadata, PalletMetadata, PalletStorageMetadata,
StorageEntryModifier, StorageEntryType,
};
use scale_info::{meta_type, TypeInfo};
use super::*;
fn load_metadata() -> Metadata {
// Extrinsic needs to contain at least the generic type parameter "Call"
// for the metadata to be valid.
+1 -3
View File
@@ -9,11 +9,9 @@ mod hash_cache;
mod metadata_location;
mod metadata_type;
pub use decode_encode_traits::{DecodeWithMetadata, EncodeWithMetadata};
pub use metadata_location::MetadataLocation;
pub use metadata_type::{
ErrorMetadata, EventMetadata, ExtrinsicMetadata, InvalidMetadataError, Metadata, MetadataError,
PalletMetadata, RuntimeFnMetadata,
};
pub use decode_encode_traits::{DecodeWithMetadata, EncodeWithMetadata};
+3 -2
View File
@@ -2,8 +2,6 @@
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
// see LICENSE for license details.
use super::{RpcClientT, RpcFuture, RpcSubscription};
use crate::error::RpcError;
use futures::stream::{StreamExt, TryStreamExt};
use jsonrpsee::{
core::{
@@ -15,6 +13,9 @@ use jsonrpsee::{
};
use serde_json::value::RawValue;
use super::{RpcClientT, RpcFuture, RpcSubscription};
use crate::error::RpcError;
struct Params(Option<Box<RawValue>>);
impl ToRpcParams for Params {
+1 -3
View File
@@ -56,9 +56,7 @@ pub mod types;
// Expose the `Rpc` struct.
pub use rpc::*;
pub use rpc_client::{rpc_params, RpcClient, RpcParams, Subscription};
pub use rpc_client_t::{
RawValue, RpcClientT, RpcFuture, RpcSubscription, RpcSubscriptionId, RpcSubscriptionStream,
};
pub use rpc_client::{rpc_params, RpcClient, RpcParams, Subscription};
+1 -2
View File
@@ -37,13 +37,12 @@ use codec::{Decode, Encode};
use frame_metadata::RuntimeMetadataPrefixed;
use serde::Serialize;
use crate::{error::Error, utils::PhantomDataSendSync, Config, Metadata};
use super::{
rpc_params,
types::{self, ChainHeadEvent, FollowEvent},
RpcClient, RpcClientT, Subscription,
};
use crate::{error::Error, utils::PhantomDataSendSync, Config, Metadata};
/// Client for substrate rpc interfaces
pub struct Rpc<T: Config> {
+5 -3
View File
@@ -2,12 +2,14 @@
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
// see LICENSE for license details.
use super::{RpcClientT, RpcSubscription, RpcSubscriptionId};
use crate::error::Error;
use std::{pin::Pin, sync::Arc, task::Poll};
use futures::{Stream, StreamExt};
use serde::{de::DeserializeOwned, Serialize};
use serde_json::value::RawValue;
use std::{pin::Pin, sync::Arc, task::Poll};
use super::{RpcClientT, RpcSubscription, RpcSubscriptionId};
use crate::error::Error;
/// A concrete wrapper around an [`RpcClientT`] which exposes the udnerlying interface via some
/// higher level methods that make it a little easier to work with.
+3 -2
View File
@@ -2,13 +2,14 @@
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
// see LICENSE for license details.
use crate::error::RpcError;
use futures::Stream;
use std::{future::Future, pin::Pin};
use futures::Stream;
// Re-exporting for simplicity since it's used a bunch in the trait definition.
pub use serde_json::value::RawValue;
use crate::error::RpcError;
/// Any RPC client which implements this can be used in our [`super::Rpc`] type
/// to talk to a node.
///
+5 -3
View File
@@ -4,14 +4,15 @@
//! Types sent to/from the Substrate RPC interface.
use crate::{metadata::Metadata, Config};
use std::collections::HashMap;
use codec::{Decode, Encode};
use primitive_types::U256;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
// Subscription types are returned from some calls, so expose it with the rest of the returned types.
pub use super::rpc_client::Subscription;
use crate::{metadata::Metadata, Config};
/// An error dry running an extrinsic.
#[derive(Debug, PartialEq, Eq)]
@@ -730,9 +731,10 @@ impl<Hash> From<TransactionEventIR<Hash>> for TransactionEvent<Hash> {
/// Serialize and deserialize helper as string.
mod as_string {
use super::*;
use serde::Deserializer;
use super::*;
pub fn deserialize<'de, D: Deserializer<'de>>(deserializer: D) -> Result<usize, D::Error> {
String::deserialize(deserializer)?
.parse()
+5 -4
View File
@@ -2,12 +2,13 @@
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
// see LICENSE for license details.
use super::runtime_types::RuntimeApi;
use crate::{client::OnlineClientT, error::Error, Config};
use derivative::Derivative;
use std::{future::Future, marker::PhantomData};
use derivative::Derivative;
use super::runtime_types::RuntimeApi;
use crate::{client::OnlineClientT, error::Error, Config};
/// Execute runtime API calls.
#[derive(Derivative)]
#[derivative(Clone(bound = "Client: Clone"))]
+4 -4
View File
@@ -3,12 +3,12 @@
// see LICENSE for license details.
use core::marker::PhantomData;
use scale_encode::EncodeAsFields;
use scale_value::Composite;
use std::borrow::Cow;
use crate::dynamic::DecodedValueThunk;
use crate::{metadata::DecodeWithMetadata, Error, Metadata};
use scale_encode::EncodeAsFields;
use scale_value::Composite;
use crate::{dynamic::DecodedValueThunk, metadata::DecodeWithMetadata, Error, Metadata};
/// This represents a runtime API payload that can call into the runtime of node.
///
+4 -3
View File
@@ -2,12 +2,13 @@
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
// see LICENSE for license details.
use crate::{client::OnlineClientT, error::Error, metadata::DecodeWithMetadata, Config};
use codec::Decode;
use derivative::Derivative;
use std::{future::Future, marker::PhantomData};
use codec::Decode;
use derivative::Derivative;
use super::RuntimeApiPayload;
use crate::{client::OnlineClientT, error::Error, metadata::DecodeWithMetadata, Config};
/// Execute runtime API calls.
#[derive(Derivative)]
-1
View File
@@ -11,7 +11,6 @@ mod storage_type;
pub mod utils;
pub use storage_client::StorageClient;
pub use storage_type::{KeyIter, Storage};
// Re-export as this is used in the public API in this module:
+5 -3
View File
@@ -2,15 +2,17 @@
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
// see LICENSE for license details.
use std::borrow::Cow;
use frame_metadata::v15::{StorageEntryType, StorageHasher};
use scale_info::TypeDef;
use crate::{
dynamic::{DecodedValueThunk, Value},
error::{Error, StorageAddressError},
metadata::{DecodeWithMetadata, EncodeWithMetadata, Metadata},
utils::{Encoded, Static},
};
use frame_metadata::v15::{StorageEntryType, StorageHasher};
use scale_info::TypeDef;
use std::borrow::Cow;
/// This represents a storage address. Anything implementing this trait
/// can be used to fetch and iterate over storage entries.
+4 -3
View File
@@ -2,18 +2,19 @@
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
// see LICENSE for license details.
use std::{future::Future, marker::PhantomData};
use derivative::Derivative;
use super::{
storage_type::{validate_storage_address, Storage},
utils, StorageAddress,
};
use crate::{
client::{OfflineClientT, OnlineClientT},
error::Error,
Config,
};
use derivative::Derivative;
use std::{future::Future, marker::PhantomData};
/// Query the runtime storage.
#[derive(Derivative)]
+6 -4
View File
@@ -2,6 +2,12 @@
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
// see LICENSE for license details.
use std::{future::Future, marker::PhantomData};
use derivative::Derivative;
use frame_metadata::v15::StorageEntryType;
use scale_info::form::PortableForm;
use super::storage_address::{StorageAddress, Yes};
use crate::{
client::OnlineClientT,
@@ -10,10 +16,6 @@ use crate::{
rpc::types::{StorageData, StorageKey},
Config,
};
use derivative::Derivative;
use frame_metadata::v15::StorageEntryType;
use scale_info::form::PortableForm;
use std::{future::Future, marker::PhantomData};
/// Query the runtime storage.
#[derive(Derivative)]
-1
View File
@@ -18,7 +18,6 @@ mod tx_progress;
// feature if we want to avoid needing sp_core and sp_runtime.
#[cfg(feature = "substrate-compat")]
pub use self::signer::PairSigner;
pub use self::{
signer::Signer,
tx_client::{SubmittableExtrinsic, TxClient},
+3 -2
View File
@@ -31,14 +31,15 @@ pub use pair_signer::PairSigner;
// packages like sp_keyring and such, and so relies on sp_core and sp_runtime to be included.
#[cfg(feature = "substrate-compat")]
mod pair_signer {
use super::Signer;
use crate::Config;
use sp_core::Pair as PairT;
use sp_runtime::{
traits::{IdentifyAccount, Verify},
AccountId32 as SpAccountId32, MultiSignature as SpMultiSignature,
};
use super::Signer;
use crate::Config;
/// A [`Signer`] implementation that can be constructed from an [`sp_core::Pair`].
#[derive(Clone, Debug)]
pub struct PairSigner<T: Config, Pair> {
+2 -3
View File
@@ -8,6 +8,8 @@ use codec::{Compact, Encode};
use derivative::Derivative;
use sp_core_hashing::blake2_256;
// This is returned from an API below, so expose it here.
pub use crate::rpc::types::DryRunResult;
use crate::{
client::{OfflineClientT, OnlineClientT},
config::{Config, ExtrinsicParams, Hasher},
@@ -16,9 +18,6 @@ use crate::{
utils::{Encoded, PhantomDataSendSync},
};
// This is returned from an API below, so expose it here.
pub use crate::rpc::types::DryRunResult;
/// A client for working with transactions.
#[derive(Derivative)]
#[derivative(Clone(bound = "Client: Clone"))]
+4 -2
View File
@@ -5,11 +5,13 @@
//! This module contains the trait and types used to represent
//! transactions that can be submitted.
use crate::{dynamic::Value, error::Error, metadata::Metadata};
use std::{borrow::Cow, sync::Arc};
use codec::Encode;
use scale_encode::EncodeAsFields;
use scale_value::{Composite, ValueDef, Variant};
use std::{borrow::Cow, sync::Arc};
use crate::{dynamic::Value, error::Error, metadata::Metadata};
/// This represents a transaction payload that can be submitted
/// to a node.
+4 -4
View File
@@ -6,6 +6,9 @@
use std::task::Poll;
use derivative::Derivative;
use futures::{Stream, StreamExt};
use crate::{
client::OnlineClientT,
error::{DispatchError, Error, RpcError, TransactionError},
@@ -13,8 +16,6 @@ use crate::{
rpc::types::{Subscription, SubstrateTxStatus},
Config,
};
use derivative::Derivative;
use futures::{Stream, StreamExt};
/// This struct represents a subscription to the progress of some transaction.
#[derive(Derivative)]
@@ -413,6 +414,7 @@ mod test {
use std::pin::Pin;
use futures::Stream;
use serde_json::value::RawValue;
use crate::{
client::{OfflineClientT, OnlineClientT},
@@ -423,8 +425,6 @@ mod test {
Config, Error, SubstrateConfig,
};
use serde_json::value::RawValue;
type MockTxProgress = TxProgress<SubstrateConfig, MockClient>;
type MockHash = <WithExtrinsicParams<
SubstrateConfig,
+2 -2
View File
@@ -180,11 +180,11 @@ mod substrate_impls {
#[cfg(test)]
mod test {
use super::*;
use sp_core::crypto::Ss58Codec;
use sp_keyring::AccountKeyring;
use super::*;
#[test]
fn ss58_is_compatible_with_substrate_impl() {
let keyrings = vec![
+4 -3
View File
@@ -4,13 +4,14 @@
//! Generic `scale_bits` over `bitvec`-like `BitOrder` and `BitFormat` types.
use std::marker::PhantomData;
use codec::{Compact, Input};
use scale_bits::{
scale::format::{Format, OrderFormat, StoreFormat},
Bits,
};
use scale_decode::IntoVisitor;
use std::marker::PhantomData;
/// Associates `bitvec::store::BitStore` trait with corresponding, type-erased `scale_bits::StoreFormat` enum.
///
@@ -191,13 +192,13 @@ impl<Store, Order> scale_encode::EncodeAsType for DecodedBits<Store, Order> {
#[cfg(test)]
mod tests {
use super::*;
use core::fmt::Debug;
use bitvec::vec::BitVec;
use codec::Decode as _;
use super::*;
// NOTE: We don't use `bitvec::order` types in our implementation, since we
// don't want to depend on `bitvec`. Rather than reimplementing the unsafe
// trait on our types here for testing purposes, we simply convert and
+3 -5
View File
@@ -11,18 +11,16 @@ mod multi_signature;
mod static_type;
mod wrapper_opaque;
pub use account_id::AccountId32;
use codec::{Decode, Encode};
use derivative::Derivative;
pub use account_id::AccountId32;
pub use multi_address::MultiAddress;
pub use multi_signature::MultiSignature;
pub use static_type::Static;
pub use wrapper_opaque::WrapperKeepOpaque;
// Used in codegen
#[doc(hidden)]
pub use primitive_types::{H160, H256, H512};
pub use static_type::Static;
pub use wrapper_opaque::WrapperKeepOpaque;
/// Wraps an already encoded byte vector, prevents being encoded as a raw byte vector as part of
/// the transaction payload
+2 -1
View File
@@ -2,12 +2,13 @@
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
// see LICENSE for license details.
use super::PhantomDataSendSync;
use codec::{Compact, Decode, DecodeAll, Encode};
use derivative::Derivative;
use scale_decode::{IntoVisitor, Visitor};
use scale_encode::EncodeAsType;
use super::PhantomDataSendSync;
/// A wrapper for any type `T` which implement encode/decode in a way compatible with `Vec<u8>`.
/// [`WrapperKeepOpaque`] stores the type only in its opaque format, aka as a `Vec<u8>`. To
/// access the real type `T` [`Self::try_decode`] needs to be used.