From 53598b8ef5c17d4328dab47f1540bfa80649b1a0 Mon Sep 17 00:00:00 2001 From: Jun Jiang Date: Fri, 12 Jul 2024 07:35:46 +0800 Subject: [PATCH] Remove usage of `sp-std` on templates (#5001) Following PR for https://github.com/paritytech/polkadot-sdk/pull/4941 that removes usage of `sp-std` on templates `sp-std` crate was proposed to deprecate on https://github.com/paritytech/polkadot-sdk/issues/2101 @kianenigma --------- Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> --- Cargo.lock | 3 --- templates/parachain/pallets/template/Cargo.toml | 2 -- templates/parachain/runtime/Cargo.toml | 2 -- templates/parachain/runtime/src/apis.rs | 6 +++--- templates/parachain/runtime/src/lib.rs | 3 ++- templates/solochain/runtime/Cargo.toml | 2 -- templates/solochain/runtime/src/lib.rs | 5 +++-- 7 files changed, 8 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3b46a2680e8d..33475d9b6196 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11270,7 +11270,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -12152,7 +12151,6 @@ dependencies = [ "sp-offchain", "sp-runtime", "sp-session", - "sp-std 14.0.0", "sp-transaction-pool", "sp-version", "staging-parachain-info", @@ -19840,7 +19838,6 @@ dependencies = [ "sp-offchain", "sp-runtime", "sp-session", - "sp-std 14.0.0", "sp-storage 19.0.0", "sp-transaction-pool", "sp-version", diff --git a/templates/parachain/pallets/template/Cargo.toml b/templates/parachain/pallets/template/Cargo.toml index 3b651ce427f9..dde863101372 100644 --- a/templates/parachain/pallets/template/Cargo.toml +++ b/templates/parachain/pallets/template/Cargo.toml @@ -27,7 +27,6 @@ frame-system = { workspace = true } # primitive deps sp-runtime = { workspace = true } -sp-std = { workspace = true } [dev-dependencies] sp-core = { workspace = true, default-features = true } @@ -50,7 +49,6 @@ std = [ "frame-system/std", "sp-runtime/std", - "sp-std/std", ] try-runtime = [ "frame-support/try-runtime", diff --git a/templates/parachain/runtime/Cargo.toml b/templates/parachain/runtime/Cargo.toml index de0ecad9b06e..939fa245d2a0 100644 --- a/templates/parachain/runtime/Cargo.toml +++ b/templates/parachain/runtime/Cargo.toml @@ -62,7 +62,6 @@ sp-inherents = { workspace = true } sp-offchain = { workspace = true } sp-runtime = { workspace = true } sp-session = { workspace = true } -sp-std = { workspace = true } sp-transaction-pool = { workspace = true } sp-version = { workspace = true } @@ -136,7 +135,6 @@ std = [ "sp-offchain/std", "sp-runtime/std", "sp-session/std", - "sp-std/std", "sp-transaction-pool/std", "sp-version/std", "substrate-wasm-builder", diff --git a/templates/parachain/runtime/src/apis.rs b/templates/parachain/runtime/src/apis.rs index bc3c3808fb78..f5d5d3e63027 100644 --- a/templates/parachain/runtime/src/apis.rs +++ b/templates/parachain/runtime/src/apis.rs @@ -24,6 +24,7 @@ // For more information, please refer to // External crates imports +use alloc::vec::Vec; use frame_support::{ genesis_builder_helper::{build_state, get_preset}, weights::Weight, @@ -37,7 +38,6 @@ use sp_runtime::{ transaction_validity::{TransactionSource, TransactionValidity}, ApplyExtrinsicResult, }; -use sp_std::prelude::Vec; use sp_version::RuntimeVersion; // Local module imports @@ -106,7 +106,7 @@ impl_runtime_apis! { Runtime::metadata_at_version(version) } - fn metadata_versions() -> sp_std::vec::Vec { + fn metadata_versions() -> Vec { Runtime::metadata_versions() } } @@ -264,7 +264,7 @@ impl_runtime_apis! { use frame_system_benchmarking::Pallet as SystemBench; impl frame_system_benchmarking::Config for Runtime { - fn setup_set_code_requirements(code: &sp_std::vec::Vec) -> Result<(), BenchmarkError> { + fn setup_set_code_requirements(code: &Vec) -> Result<(), BenchmarkError> { ParachainSystem::initialize_for_set_code_benchmark(code.len() as u32); Ok(()) } diff --git a/templates/parachain/runtime/src/lib.rs b/templates/parachain/runtime/src/lib.rs index 3a9fee38f245..012ad1d097bf 100644 --- a/templates/parachain/runtime/src/lib.rs +++ b/templates/parachain/runtime/src/lib.rs @@ -12,6 +12,8 @@ mod benchmarks; mod configs; mod weights; +extern crate alloc; +use alloc::{boxed::Box, vec::Vec}; use smallvec::smallvec; use sp_runtime::{ create_runtime_str, generic, impl_opaque_keys, @@ -19,7 +21,6 @@ use sp_runtime::{ MultiSignature, }; -use sp_std::prelude::*; #[cfg(feature = "std")] use sp_version::NativeVersion; use sp_version::RuntimeVersion; diff --git a/templates/solochain/runtime/Cargo.toml b/templates/solochain/runtime/Cargo.toml index af1cd466ea00..f06c80b9a032 100644 --- a/templates/solochain/runtime/Cargo.toml +++ b/templates/solochain/runtime/Cargo.toml @@ -53,7 +53,6 @@ sp-runtime = { features = [ "serde", ], workspace = true } sp-session = { workspace = true } -sp-std = { workspace = true } sp-storage = { workspace = true } sp-transaction-pool = { workspace = true } sp-version = { features = [ @@ -109,7 +108,6 @@ std = [ "sp-offchain/std", "sp-runtime/std", "sp-session/std", - "sp-std/std", "sp-storage/std", "sp-transaction-pool/std", "sp-version/std", diff --git a/templates/solochain/runtime/src/lib.rs b/templates/solochain/runtime/src/lib.rs index c147845fe2fe..936ecd1bd388 100644 --- a/templates/solochain/runtime/src/lib.rs +++ b/templates/solochain/runtime/src/lib.rs @@ -3,6 +3,8 @@ #[cfg(feature = "std")] include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); +extern crate alloc; +use alloc::{boxed::Box, vec, vec::Vec}; use pallet_grandpa::AuthorityId as GrandpaId; use sp_api::impl_runtime_apis; use sp_consensus_aura::sr25519::AuthorityId as AuraId; @@ -13,7 +15,6 @@ use sp_runtime::{ transaction_validity::{TransactionSource, TransactionValidity}, ApplyExtrinsicResult, MultiSignature, }; -use sp_std::prelude::*; #[cfg(feature = "std")] use sp_version::NativeVersion; use sp_version::RuntimeVersion; @@ -370,7 +371,7 @@ impl_runtime_apis! { Runtime::metadata_at_version(version) } - fn metadata_versions() -> sp_std::vec::Vec { + fn metadata_versions() -> Vec { Runtime::metadata_versions() } }