Make sp_core and sp_runtime dependencies optional, and bump to latest (#760)

* begin porting over traits; remove Config use of Hash

* port over the Header bits that we need

* sp_core_hashing where possible, move Verify to PairSigner, remove unused errors

* tidy up Config things and move related bits into one place

* fix codegen

* copy Era over

* move AccountId, Address, Signer to Signer trait and a pass over fixing examples

* impl MultiAddress, MultiSignature, AccountId32 and add back to Config (for decoding later)

* Copy over StorageKey, StorageData, StorageChangeSet

* subxt core compiling with no sp_core or sp_runtime

* Get examples compiling

* pass over fixing tests

* cargo fmt

* clippy tweaks and update polkadot.rs

* fix codegen docs

* port over special DigestItem encoding/decoding

* clippy and doc fixes

* cargo fmt and example fix

* more cargo fmt-ing...

* substrate-extra to substrate-compat

* cargo.toml comments

* simplify PairSigner trait bounds

* move RPC types to a separate file

* fix docs

* Add some tests for things and other PR feedback

* bump to latest sp deps

* avoid needing substrate-compat feature in a test
This commit is contained in:
James Wilson
2023-01-10 12:02:41 +00:00
committed by GitHub
parent ea5daa444f
commit b316301d61
47 changed files with 2658 additions and 1736 deletions
+2 -2
View File
@@ -15,8 +15,8 @@ pub use storage_client::{
StorageClient,
};
// Re-export as this is used in the public API:
pub use sp_core::storage::StorageKey;
// Re-export as this is used in the public API in this module:
pub use crate::rpc::types::StorageKey;
/// Types representing an address which describes where a storage
/// entry lives and how to properly decode it.
+4 -4
View File
@@ -16,15 +16,15 @@ use crate::{
DecodeWithMetadata,
Metadata,
},
rpc::types::{
StorageData,
StorageKey,
},
Config,
};
use derivative::Derivative;
use frame_metadata::StorageEntryType;
use scale_info::form::PortableForm;
use sp_core::storage::{
StorageData,
StorageKey,
};
use std::{
future::Future,
marker::PhantomData,
+6 -7
View File
@@ -3,7 +3,6 @@
// see LICENSE for license details.
use codec::Encode;
pub use sp_runtime::traits::SignedExtension;
// We use this type a bunch, so export it from here.
pub use frame_metadata::StorageHasher;
@@ -37,16 +36,16 @@ impl StorageMapKey {
pub(super) fn hash_bytes(input: &[u8], hasher: &StorageHasher, bytes: &mut Vec<u8>) {
match hasher {
StorageHasher::Identity => bytes.extend(input),
StorageHasher::Blake2_128 => bytes.extend(sp_core::blake2_128(input)),
StorageHasher::Blake2_128 => bytes.extend(sp_core_hashing::blake2_128(input)),
StorageHasher::Blake2_128Concat => {
bytes.extend(sp_core::blake2_128(input));
bytes.extend(sp_core_hashing::blake2_128(input));
bytes.extend(input);
}
StorageHasher::Blake2_256 => bytes.extend(sp_core::blake2_256(input)),
StorageHasher::Twox128 => bytes.extend(sp_core::twox_128(input)),
StorageHasher::Twox256 => bytes.extend(sp_core::twox_256(input)),
StorageHasher::Blake2_256 => bytes.extend(sp_core_hashing::blake2_256(input)),
StorageHasher::Twox128 => bytes.extend(sp_core_hashing::twox_128(input)),
StorageHasher::Twox256 => bytes.extend(sp_core_hashing::twox_256(input)),
StorageHasher::Twox64Concat => {
bytes.extend(sp_core::twox_64(input));
bytes.extend(sp_core_hashing::twox_64(input));
bytes.extend(input);
}
}
+2 -2
View File
@@ -18,8 +18,8 @@ pub fn write_storage_address_root_bytes<Address: StorageAddress>(
addr: &Address,
out: &mut Vec<u8>,
) {
out.extend(sp_core::twox_128(addr.pallet_name().as_bytes()));
out.extend(sp_core::twox_128(addr.entry_name().as_bytes()));
out.extend(sp_core_hashing::twox_128(addr.pallet_name().as_bytes()));
out.extend(sp_core_hashing::twox_128(addr.entry_name().as_bytes()));
}
/// Outputs the [`storage_address_root_bytes`] as well as any additional bytes that represent