Skip to content

Commit

Permalink
Merge pull request #1138 from gregdhill/chore/primitives-dep
Browse files Browse the repository at this point in the history
chore: feature gate sp-runtime in primitives
  • Loading branch information
sander2 authored Jul 24, 2023
2 parents 66ef87c + 313132a commit aec6c3e
Show file tree
Hide file tree
Showing 20 changed files with 139 additions and 151 deletions.
7 changes: 2 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion crates/annuity/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch =
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false }

reward = { path = "../reward", default-features = false }
primitives = { package = "interbtc-primitives", path = "../../primitives", default-features = false }

[features]
default = ["std"]
Expand Down
2 changes: 1 addition & 1 deletion crates/currency/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ parameter_type_with_key! {
impl orml_tokens::Config for Test {
type RuntimeEvent = RuntimeEvent;
type Balance = Balance;
type Amount = primitives::Amount;
type Amount = primitives::SignedBalance;
type CurrencyId = CurrencyId;
type WeightInfo = ();
type ExistentialDeposits = ExistentialDeposits;
Expand Down
2 changes: 0 additions & 2 deletions crates/escrow/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ rand = "0.8.3"
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false }
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false }

primitives = { package = "interbtc-primitives", path = "../../primitives", default-features = false }

[features]
default = ["std"]
std = [
Expand Down
2 changes: 0 additions & 2 deletions crates/farming/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ rand = "0.8.3"
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false }
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false }

primitives = { package = "interbtc-primitives", path = "../../primitives", default-features = false }

[features]
default = ["std"]
std = [
Expand Down
2 changes: 1 addition & 1 deletion crates/farming/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ parameter_type_with_key! {
impl orml_tokens::Config for Test {
type RuntimeEvent = RuntimeEvent;
type Balance = Balance;
type Amount = primitives::Amount;
type Amount = primitives::SignedBalance;
type CurrencyId = CurrencyId;
type WeightInfo = ();
type ExistentialDeposits = ExistentialDeposits;
Expand Down
3 changes: 0 additions & 3 deletions crates/fee/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ currency = { path = "../currency", features = ["testing-utils"] }
orml-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "dc39cfddefb10ef0de23655e2c3dcdab66a19404", default-features = false }
orml-traits = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "dc39cfddefb10ef0de23655e2c3dcdab66a19404", default-features = false }

# Parachain dependencies
primitives = { package = "interbtc-primitives", path = "../../primitives"}

[features]
default = ["std"]
std = [
Expand Down
1 change: 0 additions & 1 deletion crates/multi-transaction-payment/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-
sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false }
sp-arithmetic = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false }
primitives = { package = "interbtc-primitives", path = "../../primitives", default-features = false }

[features]
default = ["std"]
Expand Down
7 changes: 4 additions & 3 deletions crates/oracle/rpc/runtime-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,20 @@ authors = ["Interlay Ltd"]
edition = "2021"

[dependencies]
serde = { version = "1.0.130", default-features = false, optional = true, features = ["derive"] }
codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false, features = ["derive", "max-encoded-len"] }
frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false }
sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false }
sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false }
scale-info = { version = "2.2.0", default-features = false, features = ["derive"] }

primitives = { package = "interbtc-primitives", path = "../../../../primitives", default-features = false }

[features]
default = ["std"]
std = [
"serde",
"codec/std",
"frame-support/std",
"sp-api/std",
"sp-std/std",

"primitives/std",
]
30 changes: 2 additions & 28 deletions crates/oracle/rpc/runtime-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,10 @@

#![cfg_attr(not(feature = "std"), no_std)]

use codec::{Codec, Decode, Encode};
use codec::Codec;
use frame_support::dispatch::DispatchError;
use scale_info::TypeInfo;
#[cfg(feature = "std")]
use serde::{Deserialize, Deserializer, Serialize, Serializer};

#[derive(Eq, PartialEq, Encode, Decode, Default, TypeInfo)]
#[cfg_attr(feature = "std", derive(Debug, Serialize, Deserialize))]
#[cfg_attr(feature = "std", serde(rename_all = "camelCase"))]
/// a wrapper around a balance, used in RPC to workaround a bug where using u128
/// in runtime-apis fails. See <https://github.com/paritytech/substrate/issues/4641>
pub struct BalanceWrapper<T> {
#[cfg_attr(feature = "std", serde(bound(serialize = "T: std::fmt::Display")))]
#[cfg_attr(feature = "std", serde(serialize_with = "serialize_as_string"))]
#[cfg_attr(feature = "std", serde(bound(deserialize = "T: std::str::FromStr")))]
#[cfg_attr(feature = "std", serde(deserialize_with = "deserialize_from_string"))]
pub amount: T,
}

#[cfg(feature = "std")]
fn serialize_as_string<S: Serializer, T: std::fmt::Display>(t: &T, serializer: S) -> Result<S::Ok, S::Error> {
serializer.serialize_str(&t.to_string())
}

#[cfg(feature = "std")]
fn deserialize_from_string<'de, D: Deserializer<'de>, T: std::str::FromStr>(deserializer: D) -> Result<T, D::Error> {
let s = String::deserialize(deserializer)?;
s.parse::<T>()
.map_err(|_| serde::de::Error::custom("Parse from string failed"))
}
pub use primitives::BalanceWrapper;

sp_api::decl_runtime_apis! {
pub trait OracleApi<Balance, CurrencyId> where
Expand Down
2 changes: 1 addition & 1 deletion crates/oracle/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ parameter_type_with_key! {
impl orml_tokens::Config for Test {
type RuntimeEvent = RuntimeEvent;
type Balance = Balance;
type Amount = primitives::Amount;
type Amount = primitives::SignedBalance;
type CurrencyId = CurrencyId;
type WeightInfo = ();
type ExistentialDeposits = ExistentialDeposits;
Expand Down
4 changes: 1 addition & 3 deletions crates/reward/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ codec = { package = "parity-scale-codec", version = "3.1.5", default-features =
scale-info = { version = "2.2.0", default-features = false, features = ["derive"] }

# Parachain dependencies
primitives = { package = "interbtc-primitives", path = "../../primitives", default-features = false }
primitives = { package = "interbtc-primitives", path = "../../primitives", default-features = false, features = ["substrate-compat"] }

# Substrate dependencies
sp-arithmetic = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false }
Expand All @@ -31,8 +31,6 @@ rand = "0.8.3"
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false }
pallet-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false }

primitives = { package = "interbtc-primitives", path = "../../primitives", default-features = false }

[features]
default = ["std"]
std = [
Expand Down
2 changes: 0 additions & 2 deletions crates/staking/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ rand = "0.8.3"
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false }
pallet-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false }

primitives = { package = "interbtc-primitives", path = "../../primitives", default-features = false }

[features]
default = ["std"]
std = [
Expand Down
2 changes: 0 additions & 2 deletions crates/supply/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ rand = "0.8.3"
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false }
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false }

primitives = { package = "interbtc-primitives", path = "../../primitives", default-features = false }

[features]
default = ["std"]
std = [
Expand Down
2 changes: 1 addition & 1 deletion crates/traits/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ frame-support = { git = "https://github.com/paritytech/substrate.git", branch =
frame-system = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.31", default-features = false }

# Parachain dependencies
primitives = { package = "interbtc-primitives", path = "../../primitives", default-features = false }
primitives = { package = "interbtc-primitives", path = "../../primitives", default-features = false, features = ["substrate-compat"] }

[dev-dependencies]
sp-core = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.31" }
Expand Down
8 changes: 3 additions & 5 deletions parachain/runtime/interlay/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ impl frame_system::Config for Runtime {
/// The hashing algorithm used.
type Hashing = BlakeTwo256;
/// The header type.
type Header = generic::Header<BlockNumber, BlakeTwo256>;
type Header = Header;
/// The ubiquitous event type.
type RuntimeEvent = RuntimeEvent;
/// The ubiquitous origin type.
Expand Down Expand Up @@ -692,7 +692,7 @@ where
impl orml_tokens::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type Balance = Balance;
type Amount = primitives::Amount;
type Amount = primitives::SignedBalance;
type CurrencyId = CurrencyId;
type WeightInfo = weights::orml_tokens::WeightInfo<Runtime>;
type ExistentialDeposits = ExistentialDeposits;
Expand Down Expand Up @@ -1269,8 +1269,6 @@ construct_runtime! {
}
}

/// The address format for describing accounts.
pub type Address = AccountId;
/// Block header type as expected by this runtime.
pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
/// Block type as expected by this runtime.
Expand All @@ -1290,7 +1288,7 @@ pub type SignedExtra = (
pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
);
/// Unchecked extrinsic type as expected by this runtime.
pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, SignedExtra>;
pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<AccountId, RuntimeCall, Signature, SignedExtra>;
/// Extrinsic type that has already been checked.
pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, RuntimeCall, SignedExtra>;
/// Executive: handles dispatch to the various modules.
Expand Down
8 changes: 3 additions & 5 deletions parachain/runtime/kintsugi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ impl frame_system::Config for Runtime {
/// The hashing algorithm used.
type Hashing = BlakeTwo256;
/// The header type.
type Header = generic::Header<BlockNumber, BlakeTwo256>;
type Header = Header;
/// The ubiquitous event type.
type RuntimeEvent = RuntimeEvent;
/// The ubiquitous origin type.
Expand Down Expand Up @@ -691,7 +691,7 @@ where
impl orml_tokens::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type Balance = Balance;
type Amount = primitives::Amount;
type Amount = primitives::SignedBalance;
type CurrencyId = CurrencyId;
type WeightInfo = weights::orml_tokens::WeightInfo<Runtime>;
type ExistentialDeposits = ExistentialDeposits;
Expand Down Expand Up @@ -1269,8 +1269,6 @@ construct_runtime! {
}
}

/// The address format for describing accounts.
pub type Address = AccountId;
/// Block header type as expected by this runtime.
pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
/// Block type as expected by this runtime.
Expand All @@ -1290,7 +1288,7 @@ pub type SignedExtra = (
pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
);
/// Unchecked extrinsic type as expected by this runtime.
pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, SignedExtra>;
pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<AccountId, RuntimeCall, Signature, SignedExtra>;
/// Extrinsic type that has already been checked.
pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, RuntimeCall, SignedExtra>;
/// Executive: handles dispatch to the various modules.
Expand Down
1 change: 1 addition & 0 deletions parachain/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use sp_consensus_aura::{
sr25519::{AuthorityId as AuraId, AuthorityPair as AuraPair},
SlotDuration,
};
use sp_core::H256;
use sp_keystore::KeystorePtr;
use sp_runtime::traits::BlakeTwo256;
use std::{sync::Arc, time::Duration};
Expand Down
18 changes: 9 additions & 9 deletions primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,30 @@ version = "1.2.0"
bstringify = "0.1.2"
serde = { version = "1.0.130", optional = true }
codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false }
primitive-types = { version = "0.12.1", default-features = false, features = ["codec", "scale-info"] }
scale-info = { version = "2.2.0", default-features = false, features = ["derive"] }

sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false }
sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false }
xcm = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.31", default-features = false }
scale-decode = { version = "0.7.0", default-features = false, features = ["derive"], optional = true }
scale-encode = { version = "0.3.0", default-features = false, features = ["derive"], optional = true }

# Substrate dependencies
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false, optional = true }

# Parachain dependencies
bitcoin = { path = "../crates/bitcoin", default-features = false }

[features]
default = ["std"]
default = ["std", "substrate-compat"]
std = [
"serde",
"codec/std",
"primitive-types/std",
"primitive-types/serde",
"scale-decode",
"scale-encode",

"sp-core/std",
"sp-std/std",
"sp-runtime/std",
"sp-runtime?/std",

"bitcoin/std",
]
runtime-benchmarks = []
substrate-compat = ["sp-runtime"]
Loading

0 comments on commit aec6c3e

Please sign in to comment.