From fb260970df003818ea01593981dbf568178f59d2 Mon Sep 17 00:00:00 2001 From: Branislav Kontur Date: Fri, 26 Aug 2022 16:24:36 +0200 Subject: [PATCH] Reexport paste from `sp-runtime` in `bp-runtime` to aviod including `paste` dependency everywhere (#1556) * Reexport paste from `sp-runtime` in `bp-runtime` to aviod including `paste` dependency everywhere * Add import `bp_runtime` to macro calls: decl_bridge_finality_runtime_apis/decl_bridge_messages_runtime_apis --- bridges/primitives/chain-kusama/Cargo.toml | 1 - bridges/primitives/chain-kusama/src/lib.rs | 4 +--- bridges/primitives/chain-millau/Cargo.toml | 1 - bridges/primitives/chain-millau/src/lib.rs | 5 +---- bridges/primitives/chain-polkadot/Cargo.toml | 1 - bridges/primitives/chain-polkadot/src/lib.rs | 4 +--- bridges/primitives/chain-rialto-parachain/Cargo.toml | 1 - bridges/primitives/chain-rialto-parachain/src/lib.rs | 5 +---- bridges/primitives/chain-rialto/Cargo.toml | 1 - bridges/primitives/chain-rialto/src/lib.rs | 5 +---- bridges/primitives/chain-rococo/Cargo.toml | 1 - bridges/primitives/chain-rococo/src/lib.rs | 4 +--- bridges/primitives/chain-westend/Cargo.toml | 1 - bridges/primitives/chain-wococo/Cargo.toml | 1 - bridges/primitives/chain-wococo/src/lib.rs | 4 +--- bridges/primitives/runtime/src/chain.rs | 8 ++++---- bridges/primitives/runtime/src/lib.rs | 3 +++ bridges/relays/bin-substrate/Cargo.toml | 1 - bridges/relays/bin-substrate/src/cli/chain_schema.rs | 8 ++++---- .../cli/relay_headers_and_messages/relay_to_parachain.rs | 2 +- .../src/cli/relay_headers_and_messages/relay_to_relay.rs | 2 +- 21 files changed, 20 insertions(+), 43 deletions(-) diff --git a/bridges/primitives/chain-kusama/Cargo.toml b/bridges/primitives/chain-kusama/Cargo.toml index 5e1b91d1cf182..a676b565c33dc 100644 --- a/bridges/primitives/chain-kusama/Cargo.toml +++ b/bridges/primitives/chain-kusama/Cargo.toml @@ -7,7 +7,6 @@ edition = "2021" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] -paste = "1.0" smallvec = "1.7" # Bridge Dependencies diff --git a/bridges/primitives/chain-kusama/src/lib.rs b/bridges/primitives/chain-kusama/src/lib.rs index 598e5730253d6..0b218b22250fd 100644 --- a/bridges/primitives/chain-kusama/src/lib.rs +++ b/bridges/primitives/chain-kusama/src/lib.rs @@ -29,9 +29,7 @@ use sp_std::prelude::*; use sp_version::RuntimeVersion; pub use bp_polkadot_core::*; -use bp_runtime::{ - decl_bridge_finality_runtime_apis, decl_bridge_messages_runtime_apis, decl_bridge_runtime_apis, -}; +use bp_runtime::decl_bridge_runtime_apis; /// Kusama Chain pub type Kusama = PolkadotLike; diff --git a/bridges/primitives/chain-millau/Cargo.toml b/bridges/primitives/chain-millau/Cargo.toml index 7c1e0dab7a571..4cd8b30f7ff90 100644 --- a/bridges/primitives/chain-millau/Cargo.toml +++ b/bridges/primitives/chain-millau/Cargo.toml @@ -7,7 +7,6 @@ edition = "2021" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] -paste = "1.0" # Bridge Dependencies diff --git a/bridges/primitives/chain-millau/src/lib.rs b/bridges/primitives/chain-millau/src/lib.rs index 536a9216c80e4..2f5b12eed0df0 100644 --- a/bridges/primitives/chain-millau/src/lib.rs +++ b/bridges/primitives/chain-millau/src/lib.rs @@ -23,10 +23,7 @@ mod millau_hash; use bp_messages::{ InboundMessageDetails, LaneId, MessageNonce, MessagePayload, OutboundMessageDetails, }; -use bp_runtime::{ - decl_bridge_finality_runtime_apis, decl_bridge_messages_runtime_apis, decl_bridge_runtime_apis, - Chain, -}; +use bp_runtime::{decl_bridge_runtime_apis, Chain}; use frame_support::{ weights::{constants::WEIGHT_PER_SECOND, DispatchClass, IdentityFee, Weight}, Parameter, RuntimeDebug, diff --git a/bridges/primitives/chain-polkadot/Cargo.toml b/bridges/primitives/chain-polkadot/Cargo.toml index 6525ea3b752ba..738899b658cdf 100644 --- a/bridges/primitives/chain-polkadot/Cargo.toml +++ b/bridges/primitives/chain-polkadot/Cargo.toml @@ -8,7 +8,6 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] smallvec = "1.7" -paste = "1.0" # Bridge Dependencies diff --git a/bridges/primitives/chain-polkadot/src/lib.rs b/bridges/primitives/chain-polkadot/src/lib.rs index 7519c38878dfe..6f584f5526a22 100644 --- a/bridges/primitives/chain-polkadot/src/lib.rs +++ b/bridges/primitives/chain-polkadot/src/lib.rs @@ -29,9 +29,7 @@ use sp_std::prelude::*; use sp_version::RuntimeVersion; pub use bp_polkadot_core::*; -use bp_runtime::{ - decl_bridge_finality_runtime_apis, decl_bridge_messages_runtime_apis, decl_bridge_runtime_apis, -}; +use bp_runtime::decl_bridge_runtime_apis; /// Polkadot Chain pub type Polkadot = PolkadotLike; diff --git a/bridges/primitives/chain-rialto-parachain/Cargo.toml b/bridges/primitives/chain-rialto-parachain/Cargo.toml index 5bfda1631e5ac..a15c40929579b 100644 --- a/bridges/primitives/chain-rialto-parachain/Cargo.toml +++ b/bridges/primitives/chain-rialto-parachain/Cargo.toml @@ -7,7 +7,6 @@ edition = "2021" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] -paste = "1.0" # Bridge Dependencies diff --git a/bridges/primitives/chain-rialto-parachain/src/lib.rs b/bridges/primitives/chain-rialto-parachain/src/lib.rs index 285f7f0f184bd..8afbf87725c2b 100644 --- a/bridges/primitives/chain-rialto-parachain/src/lib.rs +++ b/bridges/primitives/chain-rialto-parachain/src/lib.rs @@ -21,10 +21,7 @@ use bp_messages::{ InboundMessageDetails, LaneId, MessageNonce, MessagePayload, OutboundMessageDetails, }; -use bp_runtime::{ - decl_bridge_finality_runtime_apis, decl_bridge_messages_runtime_apis, decl_bridge_runtime_apis, - Chain, -}; +use bp_runtime::{decl_bridge_runtime_apis, Chain}; use frame_support::{ weights::{constants::WEIGHT_PER_SECOND, DispatchClass, IdentityFee, Weight}, Parameter, RuntimeDebug, diff --git a/bridges/primitives/chain-rialto/Cargo.toml b/bridges/primitives/chain-rialto/Cargo.toml index 5e02bb454b7d7..663f9076657dd 100644 --- a/bridges/primitives/chain-rialto/Cargo.toml +++ b/bridges/primitives/chain-rialto/Cargo.toml @@ -7,7 +7,6 @@ edition = "2021" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] -paste = "1.0" # Bridge Dependencies diff --git a/bridges/primitives/chain-rialto/src/lib.rs b/bridges/primitives/chain-rialto/src/lib.rs index cd4a81264d192..1b8d19249ea61 100644 --- a/bridges/primitives/chain-rialto/src/lib.rs +++ b/bridges/primitives/chain-rialto/src/lib.rs @@ -21,10 +21,7 @@ use bp_messages::{ InboundMessageDetails, LaneId, MessageNonce, MessagePayload, OutboundMessageDetails, }; -use bp_runtime::{ - decl_bridge_finality_runtime_apis, decl_bridge_messages_runtime_apis, decl_bridge_runtime_apis, - Chain, -}; +use bp_runtime::{decl_bridge_runtime_apis, Chain}; use frame_support::{ weights::{constants::WEIGHT_PER_SECOND, DispatchClass, IdentityFee, Weight}, Parameter, RuntimeDebug, diff --git a/bridges/primitives/chain-rococo/Cargo.toml b/bridges/primitives/chain-rococo/Cargo.toml index 8c02dcccf8489..fe6b07eeb766d 100644 --- a/bridges/primitives/chain-rococo/Cargo.toml +++ b/bridges/primitives/chain-rococo/Cargo.toml @@ -8,7 +8,6 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false, features = ["derive"] } -paste = "1.0" smallvec = "1.7" # Bridge Dependencies diff --git a/bridges/primitives/chain-rococo/src/lib.rs b/bridges/primitives/chain-rococo/src/lib.rs index dfc31c827376d..aa1d40ce92e25 100644 --- a/bridges/primitives/chain-rococo/src/lib.rs +++ b/bridges/primitives/chain-rococo/src/lib.rs @@ -29,9 +29,7 @@ use sp_std::prelude::*; use sp_version::RuntimeVersion; pub use bp_polkadot_core::*; -use bp_runtime::{ - decl_bridge_finality_runtime_apis, decl_bridge_messages_runtime_apis, decl_bridge_runtime_apis, -}; +use bp_runtime::decl_bridge_runtime_apis; /// Rococo Chain pub type Rococo = PolkadotLike; diff --git a/bridges/primitives/chain-westend/Cargo.toml b/bridges/primitives/chain-westend/Cargo.toml index fb2f846f7efd3..f37aa3b0e397e 100644 --- a/bridges/primitives/chain-westend/Cargo.toml +++ b/bridges/primitives/chain-westend/Cargo.toml @@ -8,7 +8,6 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false, features = ["derive"] } -paste = "1.0" scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } smallvec = "1.7" diff --git a/bridges/primitives/chain-wococo/Cargo.toml b/bridges/primitives/chain-wococo/Cargo.toml index 44af20b726f5e..92e7c9e80e279 100644 --- a/bridges/primitives/chain-wococo/Cargo.toml +++ b/bridges/primitives/chain-wococo/Cargo.toml @@ -8,7 +8,6 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false, features = ["derive"] } -paste = "1.0" # Bridge Dependencies bp-messages = { path = "../messages", default-features = false } diff --git a/bridges/primitives/chain-wococo/src/lib.rs b/bridges/primitives/chain-wococo/src/lib.rs index 6db6e2fe6fd95..c1626b0dc67d0 100644 --- a/bridges/primitives/chain-wococo/src/lib.rs +++ b/bridges/primitives/chain-wococo/src/lib.rs @@ -27,9 +27,7 @@ use sp_std::prelude::*; pub use bp_polkadot_core::*; // Rococo runtime = Wococo runtime pub use bp_rococo::{WeightToFee, EXISTENTIAL_DEPOSIT, PAY_INBOUND_DISPATCH_FEE_WEIGHT, VERSION}; -use bp_runtime::{ - decl_bridge_finality_runtime_apis, decl_bridge_messages_runtime_apis, decl_bridge_runtime_apis, -}; +use bp_runtime::decl_bridge_runtime_apis; /// Wococo Chain pub type Wococo = PolkadotLike; diff --git a/bridges/primitives/runtime/src/chain.rs b/bridges/primitives/runtime/src/chain.rs index 154603ccd3a10..7cb0ad976f06a 100644 --- a/bridges/primitives/runtime/src/chain.rs +++ b/bridges/primitives/runtime/src/chain.rs @@ -225,7 +225,7 @@ pub type TransactionEraOf = crate::TransactionEra, HashOf #[macro_export] macro_rules! decl_bridge_finality_runtime_apis { ($chain: ident) => { - paste::item! { + bp_runtime::paste::item! { mod [<$chain _finality_api>] { use super::*; @@ -263,7 +263,7 @@ macro_rules! decl_bridge_finality_runtime_apis { #[macro_export] macro_rules! decl_bridge_messages_runtime_apis { ($chain: ident) => { - paste::item! { + bp_runtime::paste::item! { mod [<$chain _messages_api>] { use super::*; @@ -339,7 +339,7 @@ macro_rules! decl_bridge_messages_runtime_apis { #[macro_export] macro_rules! decl_bridge_runtime_apis { ($chain: ident) => { - decl_bridge_finality_runtime_apis!($chain); - decl_bridge_messages_runtime_apis!($chain); + bp_runtime::decl_bridge_finality_runtime_apis!($chain); + bp_runtime::decl_bridge_messages_runtime_apis!($chain); }; } diff --git a/bridges/primitives/runtime/src/lib.rs b/bridges/primitives/runtime/src/lib.rs index a7e3e44626ad0..7589e70d703ae 100644 --- a/bridges/primitives/runtime/src/lib.rs +++ b/bridges/primitives/runtime/src/lib.rs @@ -48,6 +48,9 @@ pub mod messages; mod chain; mod storage_proof; +// Re-export macro to aviod include paste dependency everywhere +pub use sp_runtime::paste; + /// Use this when something must be shared among all instances. pub const NO_INSTANCE_ID: ChainId = [0, 0, 0, 0]; diff --git a/bridges/relays/bin-substrate/Cargo.toml b/bridges/relays/bin-substrate/Cargo.toml index ff7496f16ec72..8f984925cea76 100644 --- a/bridges/relays/bin-substrate/Cargo.toml +++ b/bridges/relays/bin-substrate/Cargo.toml @@ -15,7 +15,6 @@ hex = "0.4" log = "0.4.17" num-format = "0.4" num-traits = "0.2" -paste = "1.0" rand = "0.8" structopt = "0.3" strum = { version = "0.21.0", features = ["derive"] } diff --git a/bridges/relays/bin-substrate/src/cli/chain_schema.rs b/bridges/relays/bin-substrate/src/cli/chain_schema.rs index f6edd26db7a67..0f108aed6de52 100644 --- a/bridges/relays/bin-substrate/src/cli/chain_schema.rs +++ b/bridges/relays/bin-substrate/src/cli/chain_schema.rs @@ -38,7 +38,7 @@ pub enum RuntimeVersionType { #[macro_export] macro_rules! declare_chain_runtime_version_params_cli_schema { ($chain:ident, $chain_prefix:ident) => { - paste::item! { + bp_runtime::paste::item! { #[doc = $chain " runtime version params."] #[derive(StructOpt, Debug, PartialEq, Eq, Clone, Copy)] pub struct [<$chain RuntimeVersionParams>] { @@ -89,7 +89,7 @@ macro_rules! declare_chain_runtime_version_params_cli_schema { #[macro_export] macro_rules! declare_chain_connection_params_cli_schema { ($chain:ident, $chain_prefix:ident) => { - paste::item! { + bp_runtime::paste::item! { #[doc = $chain " connection params."] #[derive(StructOpt, Debug, PartialEq, Eq, Clone)] pub struct [<$chain ConnectionParams>] { @@ -157,7 +157,7 @@ pub trait TransactionParamsProvider { #[macro_export] macro_rules! declare_chain_signing_params_cli_schema { ($chain:ident, $chain_prefix:ident) => { - paste::item! { + bp_runtime::paste::item! { #[doc = $chain " signing params."] #[derive(StructOpt, Debug, PartialEq, Eq, Clone)] pub struct [<$chain SigningParams>] { @@ -263,7 +263,7 @@ macro_rules! declare_chain_signing_params_cli_schema { #[macro_export] macro_rules! declare_chain_messages_pallet_owner_signing_params_cli_schema { ($chain:ident, $chain_prefix:ident) => { - paste::item! { + bp_runtime::paste::item! { #[doc = "Parameters required to sign transaction on behalf of owner of the messages pallet at " $chain "."] #[derive(StructOpt, Debug, PartialEq, Eq)] pub struct [<$chain MessagesPalletOwnerSigningParams>] { diff --git a/bridges/relays/bin-substrate/src/cli/relay_headers_and_messages/relay_to_parachain.rs b/bridges/relays/bin-substrate/src/cli/relay_headers_and_messages/relay_to_parachain.rs index b8f1992a2ff86..4123dae5a70f0 100644 --- a/bridges/relays/bin-substrate/src/cli/relay_headers_and_messages/relay_to_parachain.rs +++ b/bridges/relays/bin-substrate/src/cli/relay_headers_and_messages/relay_to_parachain.rs @@ -60,7 +60,7 @@ pub struct RelayToParachainBridge< macro_rules! declare_relay_to_parachain_bridge_schema { // chain, parachain, relay-chain-of-parachain ($left_chain:ident, $right_parachain:ident, $right_chain:ident) => { - paste::item! { + bp_runtime::paste::item! { #[doc = $left_chain ", " $right_parachain " and " $right_chain " headers+parachains+messages relay params."] #[derive(Debug, PartialEq, StructOpt)] pub struct [<$left_chain $right_parachain HeadersAndMessages>] { diff --git a/bridges/relays/bin-substrate/src/cli/relay_headers_and_messages/relay_to_relay.rs b/bridges/relays/bin-substrate/src/cli/relay_headers_and_messages/relay_to_relay.rs index 7350f903f62c3..2e092ad406be7 100644 --- a/bridges/relays/bin-substrate/src/cli/relay_headers_and_messages/relay_to_relay.rs +++ b/bridges/relays/bin-substrate/src/cli/relay_headers_and_messages/relay_to_relay.rs @@ -47,7 +47,7 @@ pub struct RelayToRelayBridge< macro_rules! declare_relay_to_relay_bridge_schema { ($left_chain:ident, $right_chain:ident) => { - paste::item! { + bp_runtime::paste::item! { #[doc = $left_chain " and " $right_chain " headers+messages relay params."] #[derive(Debug, PartialEq, StructOpt)] pub struct [<$left_chain $right_chain HeadersAndMessages>] {