mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-24 18:15:48 +00:00
Update substrate and codec crate aliases (#54)
* Replace substrate crate aliases with actual crate names * Alias parity-scale-codec to just codec, like in substrate * Format code
This commit is contained in:
+3
-3
@@ -18,7 +18,7 @@ jsonrpc-core-client = { version = "14.0", features = ["ws"] }
|
|||||||
num-traits = { version = "0.2", default-features = false }
|
num-traits = { version = "0.2", default-features = false }
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
url = "1.7"
|
url = "1.7"
|
||||||
parity-scale-codec = { version = "1.1", default-features = false, features = ["derive", "full"] }
|
codec = { package = "parity-scale-codec", version = "1.1", default-features = false, features = ["derive", "full"] }
|
||||||
|
|
||||||
frame-metadata = { git = "https://github.com/paritytech/substrate/", package = "frame-metadata" }
|
frame-metadata = { git = "https://github.com/paritytech/substrate/", package = "frame-metadata" }
|
||||||
frame-support = { git = "https://github.com/paritytech/substrate/", package = "frame-support" }
|
frame-support = { git = "https://github.com/paritytech/substrate/", package = "frame-support" }
|
||||||
@@ -28,10 +28,10 @@ frame-system = { git = "https://github.com/paritytech/substrate/", package = "fr
|
|||||||
pallet-balances = { git = "https://github.com/paritytech/substrate/", package = "pallet-balances" }
|
pallet-balances = { git = "https://github.com/paritytech/substrate/", package = "pallet-balances" }
|
||||||
pallet-contracts = { git = "https://github.com/paritytech/substrate/", package = "pallet-contracts" }
|
pallet-contracts = { git = "https://github.com/paritytech/substrate/", package = "pallet-contracts" }
|
||||||
pallet-indices = { git = "https://github.com/paritytech/substrate/", package = "pallet-indices" }
|
pallet-indices = { git = "https://github.com/paritytech/substrate/", package = "pallet-indices" }
|
||||||
substrate-rpc-api = { git = "https://github.com/paritytech/substrate/", package = "sc-rpc-api" }
|
sc-rpc-api = { git = "https://github.com/paritytech/substrate/", package = "sc-rpc-api" }
|
||||||
sp-rpc = { git = "https://github.com/paritytech/substrate/", package = "sp-rpc" }
|
sp-rpc = { git = "https://github.com/paritytech/substrate/", package = "sp-rpc" }
|
||||||
sp-core = { git = "https://github.com/paritytech/substrate/", package = "sp-core" }
|
sp-core = { git = "https://github.com/paritytech/substrate/", package = "sp-core" }
|
||||||
txpool-api = { git = "https://github.com/paritytech/substrate/", package = "sp-transaction-pool" }
|
sp-transaction-pool = { git = "https://github.com/paritytech/substrate/", package = "sp-transaction-pool" }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
env_logger = "0.7"
|
env_logger = "0.7"
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
// Copyright 2019 Parity Technologies (UK) Ltd.
|
|
||||||
// This file is part of substrate-subxt.
|
|
||||||
//
|
|
||||||
// subxt is free software: you can redistribute it and/or modify
|
|
||||||
// it under the terms of the GNU General Public License as published by
|
|
||||||
// the Free Software Foundation, either version 3 of the License, or
|
|
||||||
// (at your option) any later version.
|
|
||||||
//
|
|
||||||
// subxt is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU General Public License
|
|
||||||
// along with substrate-subxt. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
use parity_scale_codec::Encode;
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
|
||||||
pub struct Encoded(pub Vec<u8>);
|
|
||||||
|
|
||||||
impl Encode for Encoded {
|
|
||||||
fn encode(&self) -> Vec<u8> {
|
|
||||||
self.0.to_owned()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+2
-2
@@ -15,8 +15,8 @@
|
|||||||
// along with substrate-subxt. If not, see <http://www.gnu.org/licenses/>.
|
// along with substrate-subxt. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
use jsonrpc_core_client::RpcError;
|
use jsonrpc_core_client::RpcError;
|
||||||
use sp_runtime::transaction_validity::TransactionValidityError;
|
|
||||||
use sp_core::crypto::SecretStringError;
|
use sp_core::crypto::SecretStringError;
|
||||||
|
use sp_runtime::transaction_validity::TransactionValidityError;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
events::EventsError,
|
events::EventsError,
|
||||||
@@ -31,7 +31,7 @@ pub enum Error {
|
|||||||
Io(#[from] std::io::Error),
|
Io(#[from] std::io::Error),
|
||||||
/// Codec error.
|
/// Codec error.
|
||||||
#[error("Scale codec error: {0}")]
|
#[error("Scale codec error: {0}")]
|
||||||
Codec(#[from] parity_scale_codec::Error),
|
Codec(#[from] codec::Error),
|
||||||
/// Rpc error.
|
/// Rpc error.
|
||||||
#[error("Rpc error: {0}")]
|
#[error("Rpc error: {0}")]
|
||||||
Rpc(RpcError),
|
Rpc(RpcError),
|
||||||
|
|||||||
+6
-2
@@ -26,7 +26,7 @@ use std::{
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
use parity_scale_codec::{
|
use codec::{
|
||||||
Codec,
|
Codec,
|
||||||
Compact,
|
Compact,
|
||||||
Decode,
|
Decode,
|
||||||
@@ -231,7 +231,11 @@ impl<T: System + Balances + 'static> EventsDecoder<T> {
|
|||||||
} else {
|
} else {
|
||||||
let event_variant = input.read_byte()? as u8;
|
let event_variant = input.read_byte()? as u8;
|
||||||
let event_metadata = module.event(event_variant)?;
|
let event_metadata = module.event(event_variant)?;
|
||||||
log::debug!("decoding event '{}::{}'", module.name(), event_metadata.name);
|
log::debug!(
|
||||||
|
"decoding event '{}::{}'",
|
||||||
|
module.name(),
|
||||||
|
event_metadata.name
|
||||||
|
);
|
||||||
|
|
||||||
let mut event_data = Vec::<u8>::new();
|
let mut event_data = Vec::<u8>::new();
|
||||||
self.decode_raw_bytes(
|
self.decode_raw_bytes(
|
||||||
|
|||||||
+2
-2
@@ -16,12 +16,13 @@
|
|||||||
|
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
use parity_scale_codec::{
|
use codec::{
|
||||||
Codec,
|
Codec,
|
||||||
Decode,
|
Decode,
|
||||||
Encode,
|
Encode,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use sp_core::Pair;
|
||||||
use sp_runtime::{
|
use sp_runtime::{
|
||||||
generic::{
|
generic::{
|
||||||
Era,
|
Era,
|
||||||
@@ -35,7 +36,6 @@ use sp_runtime::{
|
|||||||
},
|
},
|
||||||
transaction_validity::TransactionValidityError,
|
transaction_validity::TransactionValidityError,
|
||||||
};
|
};
|
||||||
use sp_core::Pair;
|
|
||||||
|
|
||||||
use crate::frame::{
|
use crate::frame::{
|
||||||
balances::Balances,
|
balances::Balances,
|
||||||
|
|||||||
@@ -22,17 +22,13 @@ use futures::future::{
|
|||||||
self,
|
self,
|
||||||
Future,
|
Future,
|
||||||
};
|
};
|
||||||
use parity_scale_codec::{
|
|
||||||
Codec,
|
|
||||||
Encode,
|
|
||||||
};
|
|
||||||
|
|
||||||
|
use frame_support::Parameter;
|
||||||
use sp_runtime::traits::{
|
use sp_runtime::traits::{
|
||||||
MaybeSerialize,
|
MaybeSerialize,
|
||||||
Member,
|
Member,
|
||||||
SimpleArithmetic,
|
SimpleArithmetic,
|
||||||
};
|
};
|
||||||
use frame_support::Parameter;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
error::Error,
|
error::Error,
|
||||||
@@ -49,7 +45,7 @@ pub trait Balances: System {
|
|||||||
type Balance: Parameter
|
type Balance: Parameter
|
||||||
+ Member
|
+ Member
|
||||||
+ SimpleArithmetic
|
+ SimpleArithmetic
|
||||||
+ Codec
|
+ codec::Codec
|
||||||
+ Default
|
+ Default
|
||||||
+ Copy
|
+ Copy
|
||||||
+ MaybeSerialize
|
+ MaybeSerialize
|
||||||
@@ -118,7 +114,7 @@ const MODULE: &str = "Balances";
|
|||||||
const TRANSFER: &str = "transfer";
|
const TRANSFER: &str = "transfer";
|
||||||
|
|
||||||
/// Arguments for transferring a balance
|
/// Arguments for transferring a balance
|
||||||
#[derive(Encode)]
|
#[derive(codec::Encode)]
|
||||||
pub struct TransferArgs<T: Balances> {
|
pub struct TransferArgs<T: Balances> {
|
||||||
to: <T as System>::Address,
|
to: <T as System>::Address,
|
||||||
#[codec(compact)]
|
#[codec(compact)]
|
||||||
|
|||||||
@@ -16,13 +16,12 @@
|
|||||||
|
|
||||||
//! Implements support for the pallet_contracts module.
|
//! Implements support for the pallet_contracts module.
|
||||||
|
|
||||||
use parity_scale_codec::Encode;
|
|
||||||
|
|
||||||
use crate::frame::{
|
use crate::frame::{
|
||||||
balances::Balances,
|
balances::Balances,
|
||||||
system::System,
|
system::System,
|
||||||
Call,
|
Call,
|
||||||
};
|
};
|
||||||
|
use codec::Encode;
|
||||||
|
|
||||||
const MODULE: &str = "Contracts";
|
const MODULE: &str = "Contracts";
|
||||||
const PUT_CODE: &str = "put_code";
|
const PUT_CODE: &str = "put_code";
|
||||||
|
|||||||
+1
-1
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
//! Implements support for built-in runtime modules.
|
//! Implements support for built-in runtime modules.
|
||||||
|
|
||||||
use parity_scale_codec::Encode;
|
use codec::Encode;
|
||||||
|
|
||||||
pub mod balances;
|
pub mod balances;
|
||||||
pub mod contracts;
|
pub mod contracts;
|
||||||
|
|||||||
+3
-3
@@ -18,13 +18,14 @@
|
|||||||
|
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
|
|
||||||
|
use codec::Codec;
|
||||||
use futures::future::{
|
use futures::future::{
|
||||||
self,
|
self,
|
||||||
Future,
|
Future,
|
||||||
};
|
};
|
||||||
use parity_scale_codec::Codec;
|
|
||||||
use serde::de::DeserializeOwned;
|
use serde::de::DeserializeOwned;
|
||||||
|
|
||||||
|
use frame_support::Parameter;
|
||||||
use sp_runtime::traits::{
|
use sp_runtime::traits::{
|
||||||
Bounded,
|
Bounded,
|
||||||
CheckEqual,
|
CheckEqual,
|
||||||
@@ -38,7 +39,6 @@ use sp_runtime::traits::{
|
|||||||
SimpleBitOps,
|
SimpleBitOps,
|
||||||
StaticLookup,
|
StaticLookup,
|
||||||
};
|
};
|
||||||
use frame_support::Parameter;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
error::Error,
|
error::Error,
|
||||||
@@ -170,7 +170,7 @@ pub fn set_code(code: Vec<u8>) -> Call<SetCode> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Event for the System module.
|
/// Event for the System module.
|
||||||
#[derive(Clone, Debug, parity_scale_codec::Decode)]
|
#[derive(Clone, Debug, codec::Decode)]
|
||||||
pub enum SystemEvent {
|
pub enum SystemEvent {
|
||||||
/// An extrinsic completed successfully.
|
/// An extrinsic completed successfully.
|
||||||
ExtrinsicSuccess(frame_support::weights::DispatchInfo),
|
ExtrinsicSuccess(frame_support::weights::DispatchInfo),
|
||||||
|
|||||||
+33
-24
@@ -26,6 +26,11 @@ use std::{
|
|||||||
marker::PhantomData,
|
marker::PhantomData,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use codec::{
|
||||||
|
Codec,
|
||||||
|
Decode,
|
||||||
|
Encode,
|
||||||
|
};
|
||||||
use futures::future::{
|
use futures::future::{
|
||||||
self,
|
self,
|
||||||
Either,
|
Either,
|
||||||
@@ -33,10 +38,12 @@ use futures::future::{
|
|||||||
IntoFuture,
|
IntoFuture,
|
||||||
};
|
};
|
||||||
use jsonrpc_core_client::transports::ws;
|
use jsonrpc_core_client::transports::ws;
|
||||||
use parity_scale_codec::{
|
use sp_core::{
|
||||||
Codec,
|
storage::{
|
||||||
Decode,
|
StorageChangeSet,
|
||||||
Encode,
|
StorageKey,
|
||||||
|
},
|
||||||
|
Pair,
|
||||||
};
|
};
|
||||||
use sp_runtime::{
|
use sp_runtime::{
|
||||||
generic::UncheckedExtrinsic,
|
generic::UncheckedExtrinsic,
|
||||||
@@ -47,16 +54,8 @@ use sp_runtime::{
|
|||||||
MultiSignature,
|
MultiSignature,
|
||||||
};
|
};
|
||||||
use sp_version::RuntimeVersion;
|
use sp_version::RuntimeVersion;
|
||||||
use sp_core::{
|
|
||||||
storage::{
|
|
||||||
StorageChangeSet,
|
|
||||||
StorageKey,
|
|
||||||
},
|
|
||||||
Pair,
|
|
||||||
};
|
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
mod codec;
|
|
||||||
mod error;
|
mod error;
|
||||||
mod events;
|
mod events;
|
||||||
mod extrinsic;
|
mod extrinsic;
|
||||||
@@ -65,8 +64,14 @@ mod metadata;
|
|||||||
mod rpc;
|
mod rpc;
|
||||||
mod runtimes;
|
mod runtimes;
|
||||||
|
|
||||||
|
pub use self::{
|
||||||
|
error::Error,
|
||||||
|
events::RawEvent,
|
||||||
|
frame::*,
|
||||||
|
rpc::ExtrinsicSuccess,
|
||||||
|
runtimes::*,
|
||||||
|
};
|
||||||
use self::{
|
use self::{
|
||||||
codec::Encoded,
|
|
||||||
events::EventsDecoder,
|
events::EventsDecoder,
|
||||||
extrinsic::{
|
extrinsic::{
|
||||||
DefaultExtra,
|
DefaultExtra,
|
||||||
@@ -88,13 +93,6 @@ use self::{
|
|||||||
Rpc,
|
Rpc,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
pub use self::{
|
|
||||||
error::Error,
|
|
||||||
events::RawEvent,
|
|
||||||
frame::*,
|
|
||||||
rpc::ExtrinsicSuccess,
|
|
||||||
runtimes::*,
|
|
||||||
};
|
|
||||||
|
|
||||||
fn connect<T: System>(url: &Url) -> impl Future<Item = Rpc<T>, Error = Error> {
|
fn connect<T: System>(url: &Url) -> impl Future<Item = Rpc<T>, Error = Error> {
|
||||||
ws::connect(url).map_err(Into::into)
|
ws::connect(url).map_err(Into::into)
|
||||||
@@ -331,7 +329,7 @@ where
|
|||||||
Error,
|
Error,
|
||||||
>
|
>
|
||||||
where
|
where
|
||||||
C: parity_scale_codec::Encode,
|
C: codec::Encode,
|
||||||
{
|
{
|
||||||
let signer = self.signer.clone();
|
let signer = self.signer.clone();
|
||||||
let account_nonce = self.nonce;
|
let account_nonce = self.nonce;
|
||||||
@@ -390,13 +388,24 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Wraps an already encoded byte vector, prevents being encoded as a raw byte vector as part of
|
||||||
|
/// the transaction payload
|
||||||
|
#[derive(Clone)]
|
||||||
|
pub struct Encoded(pub Vec<u8>);
|
||||||
|
|
||||||
|
impl codec::Encode for Encoded {
|
||||||
|
fn encode(&self) -> Vec<u8> {
|
||||||
|
self.0.to_owned()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use futures::stream::Stream;
|
use codec::Encode;
|
||||||
use parity_scale_codec::Encode;
|
|
||||||
use frame_support::StorageMap;
|
use frame_support::StorageMap;
|
||||||
use sp_keyring::AccountKeyring;
|
use futures::stream::Stream;
|
||||||
use sp_core::storage::StorageKey;
|
use sp_core::storage::StorageKey;
|
||||||
|
use sp_keyring::AccountKeyring;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::{
|
use crate::{
|
||||||
|
|||||||
+9
-9
@@ -21,7 +21,7 @@ use std::{
|
|||||||
str::FromStr,
|
str::FromStr,
|
||||||
};
|
};
|
||||||
|
|
||||||
use parity_scale_codec::{
|
use codec::{
|
||||||
Decode,
|
Decode,
|
||||||
Encode,
|
Encode,
|
||||||
};
|
};
|
||||||
@@ -37,7 +37,7 @@ use frame_metadata::{
|
|||||||
};
|
};
|
||||||
use sp_core::storage::StorageKey;
|
use sp_core::storage::StorageKey;
|
||||||
|
|
||||||
use crate::codec::Encoded;
|
use crate::Encoded;
|
||||||
|
|
||||||
#[derive(Debug, thiserror::Error)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
pub enum MetadataError {
|
pub enum MetadataError {
|
||||||
@@ -236,12 +236,8 @@ impl<K: Encode, V: Decode + Clone> StorageMap<K, V> {
|
|||||||
bytes.extend(&sp_core::twox_128(&self.storage_prefix)[..]);
|
bytes.extend(&sp_core::twox_128(&self.storage_prefix)[..]);
|
||||||
let encoded_key = key.encode();
|
let encoded_key = key.encode();
|
||||||
let hash = match self.hasher {
|
let hash = match self.hasher {
|
||||||
StorageHasher::Blake2_128 => {
|
StorageHasher::Blake2_128 => sp_core::blake2_128(&encoded_key).to_vec(),
|
||||||
sp_core::blake2_128(&encoded_key).to_vec()
|
StorageHasher::Blake2_256 => sp_core::blake2_256(&encoded_key).to_vec(),
|
||||||
}
|
|
||||||
StorageHasher::Blake2_256 => {
|
|
||||||
sp_core::blake2_256(&encoded_key).to_vec()
|
|
||||||
}
|
|
||||||
StorageHasher::Twox128 => sp_core::twox_128(&encoded_key).to_vec(),
|
StorageHasher::Twox128 => sp_core::twox_128(&encoded_key).to_vec(),
|
||||||
StorageHasher::Twox256 => sp_core::twox_256(&encoded_key).to_vec(),
|
StorageHasher::Twox256 => sp_core::twox_256(&encoded_key).to_vec(),
|
||||||
StorageHasher::Twox64Concat => sp_core::twox_64(&encoded_key).to_vec(),
|
StorageHasher::Twox64Concat => sp_core::twox_64(&encoded_key).to_vec(),
|
||||||
@@ -360,7 +356,11 @@ impl TryFrom<RuntimeMetadataPrefixed> for Metadata {
|
|||||||
let module_prefix = convert(storage.prefix)?;
|
let module_prefix = convert(storage.prefix)?;
|
||||||
for entry in convert(storage.entries)?.into_iter() {
|
for entry in convert(storage.entries)?.into_iter() {
|
||||||
let storage_prefix = convert(entry.name.clone())?;
|
let storage_prefix = convert(entry.name.clone())?;
|
||||||
let entry = convert_entry(module_prefix.clone(), storage_prefix.clone(), entry)?;
|
let entry = convert_entry(
|
||||||
|
module_prefix.clone(),
|
||||||
|
storage_prefix.clone(),
|
||||||
|
entry,
|
||||||
|
)?;
|
||||||
storage_map.insert(storage_prefix, entry);
|
storage_map.insert(storage_prefix, entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+39
-33
@@ -16,6 +16,11 @@
|
|||||||
|
|
||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
|
|
||||||
|
use codec::{
|
||||||
|
Decode,
|
||||||
|
Encode,
|
||||||
|
Error as CodecError,
|
||||||
|
};
|
||||||
use futures::{
|
use futures::{
|
||||||
future::{
|
future::{
|
||||||
self,
|
self,
|
||||||
@@ -32,14 +37,25 @@ use jsonrpc_core_client::{
|
|||||||
TypedSubscriptionStream,
|
TypedSubscriptionStream,
|
||||||
};
|
};
|
||||||
use num_traits::bounds::Bounded;
|
use num_traits::bounds::Bounded;
|
||||||
use parity_scale_codec::{
|
|
||||||
Decode,
|
|
||||||
Encode,
|
|
||||||
Error as CodecError,
|
|
||||||
};
|
|
||||||
|
|
||||||
use frame_system::Phase;
|
|
||||||
use frame_metadata::RuntimeMetadataPrefixed;
|
use frame_metadata::RuntimeMetadataPrefixed;
|
||||||
|
use frame_system::Phase;
|
||||||
|
use sc_rpc_api::{
|
||||||
|
author::AuthorClient,
|
||||||
|
chain::ChainClient,
|
||||||
|
state::StateClient,
|
||||||
|
};
|
||||||
|
use sp_core::{
|
||||||
|
storage::{
|
||||||
|
StorageChangeSet,
|
||||||
|
StorageKey,
|
||||||
|
},
|
||||||
|
twox_128,
|
||||||
|
};
|
||||||
|
use sp_rpc::{
|
||||||
|
list::ListOrValue,
|
||||||
|
number::NumberOrHex,
|
||||||
|
};
|
||||||
use sp_runtime::{
|
use sp_runtime::{
|
||||||
generic::{
|
generic::{
|
||||||
Block,
|
Block,
|
||||||
@@ -48,24 +64,8 @@ use sp_runtime::{
|
|||||||
traits::Hash,
|
traits::Hash,
|
||||||
OpaqueExtrinsic,
|
OpaqueExtrinsic,
|
||||||
};
|
};
|
||||||
|
use sp_transaction_pool::TransactionStatus;
|
||||||
use sp_version::RuntimeVersion;
|
use sp_version::RuntimeVersion;
|
||||||
use sp_core::{
|
|
||||||
storage::{
|
|
||||||
StorageChangeSet,
|
|
||||||
StorageKey,
|
|
||||||
},
|
|
||||||
twox_128,
|
|
||||||
};
|
|
||||||
use substrate_rpc_api::{
|
|
||||||
author::AuthorClient,
|
|
||||||
chain::ChainClient,
|
|
||||||
state::StateClient,
|
|
||||||
};
|
|
||||||
use sp_rpc::{
|
|
||||||
list::ListOrValue,
|
|
||||||
number::NumberOrHex,
|
|
||||||
};
|
|
||||||
use txpool_api::TransactionStatus;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
error::Error,
|
error::Error,
|
||||||
@@ -132,12 +132,12 @@ impl<T: System> Rpc<T> {
|
|||||||
.block_hash(Some(ListOrValue::Value(NumberOrHex::Number(block_zero))))
|
.block_hash(Some(ListOrValue::Value(NumberOrHex::Number(block_zero))))
|
||||||
.map_err(Into::into)
|
.map_err(Into::into)
|
||||||
.and_then(|list_or_value| {
|
.and_then(|list_or_value| {
|
||||||
future::result(
|
future::result(match list_or_value {
|
||||||
match list_or_value {
|
ListOrValue::Value(genesis_hash) => {
|
||||||
ListOrValue::Value(genesis_hash) => genesis_hash.ok_or_else(|| "Genesis hash not found".into()),
|
genesis_hash.ok_or_else(|| "Genesis hash not found".into())
|
||||||
ListOrValue::List(_) => Err("Expected a Value, got a List".into()),
|
|
||||||
}
|
}
|
||||||
)
|
ListOrValue::List(_) => Err("Expected a Value, got a List".into()),
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -274,15 +274,21 @@ impl<T: System + Balances + 'static> Rpc<T> {
|
|||||||
log::info!("received status {:?}", status);
|
log::info!("received status {:?}", status);
|
||||||
match status {
|
match status {
|
||||||
// ignore in progress extrinsic for now
|
// ignore in progress extrinsic for now
|
||||||
TransactionStatus::Future | TransactionStatus::Ready | TransactionStatus::Broadcast(_) => {
|
TransactionStatus::Future
|
||||||
None
|
| TransactionStatus::Ready
|
||||||
|
| TransactionStatus::Broadcast(_) => None,
|
||||||
|
TransactionStatus::Finalized(block_hash) => {
|
||||||
|
Some(Ok(block_hash))
|
||||||
}
|
}
|
||||||
TransactionStatus::Finalized(block_hash) => Some(Ok(block_hash)),
|
|
||||||
TransactionStatus::Usurped(_) => {
|
TransactionStatus::Usurped(_) => {
|
||||||
Some(Err("Extrinsic Usurped".into()))
|
Some(Err("Extrinsic Usurped".into()))
|
||||||
}
|
}
|
||||||
TransactionStatus::Dropped => Some(Err("Extrinsic Dropped".into())),
|
TransactionStatus::Dropped => {
|
||||||
TransactionStatus::Invalid => Some(Err("Extrinsic Invalid".into())),
|
Some(Err("Extrinsic Dropped".into()))
|
||||||
|
}
|
||||||
|
TransactionStatus::Invalid => {
|
||||||
|
Some(Err("Extrinsic Invalid".into()))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.into_future()
|
.into_future()
|
||||||
|
|||||||
Reference in New Issue
Block a user