Skip to content

Commit

Permalink
fix: update crates to v1
Browse files Browse the repository at this point in the history
  • Loading branch information
nakul1010 committed Aug 1, 2023
1 parent 1064f97 commit 8f82a9a
Show file tree
Hide file tree
Showing 90 changed files with 4,238 additions and 2,946 deletions.
5,547 changes: 3,354 additions & 2,193 deletions Cargo.lock

Large diffs are not rendered by default.

523 changes: 275 additions & 248 deletions Cargo.toml

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions crates/annuity/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ name = "annuity"
version = "1.0.0"

[dependencies]
serde = { version = "1.0.130", default-features = false, features = ["derive"], optional = true }
serde = { version = "1.0.130", default-features = false, features = ["derive"] }
codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false, features = ["derive", "max-encoded-len"] }
scale-info = { version = "2.2.0", default-features = false, features = ["derive"] }

Expand Down Expand Up @@ -35,7 +35,7 @@ reward = { path = "../reward", default-features = false }
[features]
default = ["std"]
std = [
"serde",
"serde/std",
"codec/std",
"scale-info/std",

Expand Down
2 changes: 1 addition & 1 deletion crates/annuity/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ impl pallet_balances::Config for Test {
type MaxLocks = ();
type MaxReserves = ();
type ReserveIdentifier = [u8; 8];
type HoldIdentifier = ();
type RuntimeHoldReason = ();
type FreezeIdentifier = ();
type MaxFreezes = ();
type MaxHolds = ();
Expand Down
9 changes: 4 additions & 5 deletions crates/bitcoin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ edition = "2021"
[dependencies]
codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false, features = ["derive", "max-encoded-len"] }
scale-info = { version = "2.2.0", default-features = false, features = ["derive"] }
serde = { version = "1.0.130", default-features = false, features = ["derive"], optional = true }
impl-serde = { version = "0.3.1", default-features = false, optional = true }
serde = { version = "1.0.130", default-features = false, features = ["derive"] }
impl-serde = { version = "0.3.1", default-features = false }
sha2 = { version = "0.8.2", default-features = false }
hex = { version = "0.4.2", default-features = false }
spin = { version = "0.7.1", default-features = false }
Expand All @@ -25,13 +25,12 @@ frame-support = { git = "https://github.com/paritytech/substrate", branch = "pol
default = ["std"]
std = [
"codec/std",
"impl-serde/std",
"scale-info/std",
"serde",
"impl-serde",
"serde/std",
"sha2/std",
"hex/alloc",
"primitive-types/std",
"primitive-types/serde",
"secp256k1/std",
]
parser = []
Expand Down
9 changes: 5 additions & 4 deletions crates/bitcoin/src/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use bitcoin_hashes::{hash160::Hash as Hash160, Hash};
use codec::{Decode, Encode, MaxEncodedLen};
use primitive_types::{H160, H256};
use scale_info::TypeInfo;
use serde::{Deserialize, Serialize};
use sha2::{Digest, Sha256};

#[cfg(not(feature = "std"))]
Expand All @@ -13,8 +14,10 @@ use secp256k1::{constants::PUBLIC_KEY_SIZE, Error as Secp256k1Error, PublicKey a
/// A Bitcoin address is a serialized identifier that represents the destination for a payment.
/// Address prefixes are used to indicate the network as well as the format. Since the Parachain
/// follows SPV assumptions we do not need to know which network a payment is included in.
#[derive(Encode, Decode, Clone, Ord, PartialOrd, PartialEq, Eq, Debug, Copy, TypeInfo, MaxEncodedLen)]
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize, std::hash::Hash))]
#[derive(
Serialize, Deserialize, Encode, Decode, Clone, Ord, PartialOrd, PartialEq, Eq, Debug, Copy, TypeInfo, MaxEncodedLen,
)]
#[cfg_attr(feature = "std", derive(std::hash::Hash))]
pub enum Address {
// input: {signature} {pubkey}
// output: OP_DUP OP_HASH160 {hash160(pubkey)} OP_EQUALVERIFY OP_CHECKSIG
Expand Down Expand Up @@ -150,7 +153,6 @@ impl From<[u8; PUBLIC_KEY_SIZE]> for PublicKey {
}
}

#[cfg(feature = "std")]
impl serde::Serialize for PublicKey {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
Expand All @@ -161,7 +163,6 @@ impl serde::Serialize for PublicKey {
}
}

#[cfg(feature = "std")]
impl<'de> serde::Deserialize<'de> for PublicKey {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
Expand Down
1 change: 0 additions & 1 deletion crates/bitcoin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
//! - Script (address) construction and parsing.
//! - Merkle proof construction and verification.
//! - Elliptic curve multiplication over Secp256k1.
#![deny(warnings)]
#![cfg_attr(test, feature(proc_macro_hygiene))]
#![cfg_attr(not(feature = "std"), no_std)]
Expand Down
6 changes: 3 additions & 3 deletions crates/bitcoin/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ use alloc::{vec, vec::Vec};
#[cfg(feature = "std")]
use codec::alloc::string::String;

#[cfg(feature = "std")]
use serde::{Deserialize, Serialize};

/// We also check the coinbase proof in order to defend against the 'leaf-node weakness'.
Expand Down Expand Up @@ -591,8 +590,9 @@ pub struct BlockChain {
}

/// Represents a bitcoin 32 bytes hash digest encoded in little-endian
#[derive(Encode, Decode, Default, PartialEq, Eq, Clone, Copy, Debug, TypeInfo, MaxEncodedLen)]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
#[derive(
Serialize, Deserialize, Encode, Decode, Default, PartialEq, Eq, Clone, Copy, Debug, TypeInfo, MaxEncodedLen,
)]
pub struct H256Le {
content: [u8; 32],
}
Expand Down
13 changes: 1 addition & 12 deletions crates/btc-relay/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ pub mod pallet {
pub(super) type DisableInclusionCheck<T: Config> = StorageValue<_, bool, ValueQuery>;

#[pallet::genesis_config]
#[derive(frame_support::DefaultNoBound)]
pub struct GenesisConfig<T: Config> {
/// Global security parameter k for stable Bitcoin transactions
pub bitcoin_confirmations: u32,
Expand All @@ -390,18 +391,6 @@ pub mod pallet {
pub disable_inclusion_check: bool,
}

#[cfg(feature = "std")]
impl<T: Config> Default for GenesisConfig<T> {
fn default() -> Self {
Self {
bitcoin_confirmations: Default::default(),
parachain_confirmations: Default::default(),
disable_difficulty_check: Default::default(),
disable_inclusion_check: Default::default(),
}
}
}

#[pallet::genesis_build]
impl<T: Config> GenesisBuild<T> for GenesisConfig<T> {
fn build(&self) {
Expand Down
4 changes: 2 additions & 2 deletions crates/clients-info/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ authors = ["Interlay Ltd"]
edition = "2021"

[dependencies]
serde = { version = "1.0.130", default-features = false, features = ["derive"], optional = true }
serde = { version = "1.0.130", default-features = false, features = ["derive"] }
codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false, features = ["derive", "max-encoded-len"] }
scale-info = { version = "2.2.0", default-features = false, features = ["derive"] }

Expand All @@ -28,7 +28,7 @@ frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch =
[features]
default = ["std"]
std = [
"serde",
"serde/std",
"codec/std",
"scale-info/std",

Expand Down
20 changes: 6 additions & 14 deletions crates/collator-selection/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ pub mod pallet {
use core::ops::Div;
use frame_support::{
dispatch::{DispatchClass, DispatchResultWithPostInfo},
inherent::Vec,
pallet_prelude::*,
sp_runtime::{
traits::{AccountIdConversion, CheckedSub, Saturating, Zero},
Expand All @@ -74,7 +73,7 @@ pub mod pallet {
use pallet_session::SessionManager;
use sp_runtime::traits::Convert;
use sp_staking::SessionIndex;

use sp_std::prelude::*;
type BalanceOf<T> = <<T as Config>::StakingCurrency as Currency<<T as SystemConfig>::AccountId>>::Balance;

/// A convertor from collators id. Since this pallet does not have stash/controller, this is
Expand Down Expand Up @@ -178,27 +177,20 @@ pub mod pallet {
pub type CandidacyBond<T> = StorageValue<_, BalanceOf<T>, ValueQuery>;

#[pallet::genesis_config]
#[derive(frame_support::DefaultNoBound)]
pub struct GenesisConfig<T: Config> {
pub invulnerables: Vec<T::AccountId>,
pub candidacy_bond: BalanceOf<T>,
pub desired_candidates: u32,
}

#[cfg(feature = "std")]
impl<T: Config> Default for GenesisConfig<T> {
fn default() -> Self {
Self {
invulnerables: Default::default(),
candidacy_bond: Default::default(),
desired_candidates: Default::default(),
}
}
}

#[pallet::genesis_build]
impl<T: Config> GenesisBuild<T> for GenesisConfig<T> {
fn build(&self) {
let duplicate_invulnerables = self.invulnerables.iter().collect::<std::collections::BTreeSet<_>>();
let duplicate_invulnerables = self
.invulnerables
.iter()
.collect::<sp_std::collections::btree_set::BTreeSet<_>>();
assert!(
duplicate_invulnerables.len() == self.invulnerables.len(),
"duplicate invulnerables in genesis."
Expand Down
5 changes: 3 additions & 2 deletions crates/collator-selection/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use frame_system::EnsureSignedBy;
use sp_core::H256;
use sp_runtime::{
testing::{Header, UintAuthorityId},
traits::{BlakeTwo256, IdentityLookup, OpaqueKeys},
traits::{BlakeTwo256, ConstBool, IdentityLookup, OpaqueKeys},
RuntimeAppPublic,
};

Expand Down Expand Up @@ -96,7 +96,7 @@ impl pallet_balances::Config for Test {
type MaxLocks = ();
type MaxReserves = MaxReserves;
type ReserveIdentifier = [u8; 8];
type HoldIdentifier = ();
type RuntimeHoldReason = ();
type FreezeIdentifier = ();
type MaxFreezes = ();
type MaxHolds = ();
Expand Down Expand Up @@ -132,6 +132,7 @@ impl pallet_aura::Config for Test {
type AuthorityId = sp_consensus_aura::sr25519::AuthorityId;
type MaxAuthorities = MaxAuthorities;
type DisabledValidators = ();
type AllowMultipleBlocksPerSlot = ConstBool<false>;
}

sp_runtime::impl_opaque_keys! {
Expand Down
4 changes: 2 additions & 2 deletions crates/currency/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "currency"
version = "1.2.0"

[dependencies]
serde = { version = "1.0.130", default-features = false, features = ["derive"], optional = true }
serde = { version = "1.0.130", default-features = false, features = ["derive"] }
codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false, features = ["derive", "max-encoded-len"] }
scale-info = { version = "2.2.0", default-features = false, features = ["derive"] }

Expand Down Expand Up @@ -38,7 +38,7 @@ sp-arithmetic = { git = "https://github.com/paritytech/substrate", branch = "pol
[features]
default = ["std"]
std = [
"serde",
"serde/std",
"codec/std",
"scale-info/std",

Expand Down
4 changes: 2 additions & 2 deletions crates/democracy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
log = { version = "0.4.17", default-features = false }
serde = { version = "1.0.130", default-features = false, features = ["derive"], optional = true }
serde = { version = "1.0.130", default-features = false, features = ["derive"] }
codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false, features = ["derive", "max-encoded-len"] }
scale-info = { version = "2.2.0", default-features = false, features = ["derive"] }

Expand All @@ -36,7 +36,7 @@ pallet-preimage = { git = "https://github.com/paritytech/substrate", branch = "p
[features]
default = ["std"]
std = [
"serde",
"serde/std",
"codec/std",
"scale-info/std",
"sp-core/std",
Expand Down
11 changes: 1 addition & 10 deletions crates/democracy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,21 +255,12 @@ pub mod pallet {
pub type NextLaunchTimestamp<T: Config> = StorageValue<_, u64, ValueQuery>;

#[pallet::genesis_config]
#[derive(frame_support::DefaultNoBound)]
pub struct GenesisConfig<T: Config> {
_phantom: sp_std::marker::PhantomData<T>,
next_launch_timestamp: u64,
}

#[cfg(feature = "std")]
impl<T: Config> Default for GenesisConfig<T> {
fn default() -> Self {
GenesisConfig {
_phantom: Default::default(),
next_launch_timestamp: 0,
}
}
}

#[pallet::genesis_build]
impl<T: Config> GenesisBuild<T> for GenesisConfig<T> {
fn build(&self) {
Expand Down
6 changes: 4 additions & 2 deletions crates/democracy/src/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,15 @@ mod v0 {

pub mod v1 {
use super::*;
#[cfg(feature = "try-runtime")]
use sp_runtime::TryRuntimeError;

/// Migration for translating bare `Hash`es into `Bounded<Call>`s.
pub struct Migration<T>(sp_std::marker::PhantomData<T>);

impl<T: Config + frame_system::Config<Hash = H256>> OnRuntimeUpgrade for Migration<T> {
#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<Vec<u8>, &'static str> {
fn pre_upgrade() -> Result<Vec<u8>, TryRuntimeError> {
assert_eq!(StorageVersion::get::<Pallet<T>>(), 0, "can only upgrade from version 0");

let props_count = v0::PublicProps::<T>::get().len();
Expand Down Expand Up @@ -154,7 +156,7 @@ pub mod v1 {
}

#[cfg(feature = "try-runtime")]
fn post_upgrade(state: Vec<u8>) -> Result<(), &'static str> {
fn post_upgrade(state: Vec<u8>) -> Result<(), TryRuntimeError> {
assert_eq!(StorageVersion::get::<Pallet<T>>(), 1, "must upgrade");

let (old_props_count, old_ref_count): (u32, u32) =
Expand Down
2 changes: 1 addition & 1 deletion crates/democracy/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ impl pallet_balances::Config for Test {
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = System;
type WeightInfo = ();
type HoldIdentifier = ();
type RuntimeHoldReason = ();
type FreezeIdentifier = ();
type MaxFreezes = ();
type MaxHolds = ();
Expand Down
16 changes: 13 additions & 3 deletions crates/democracy/src/vote_threshold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,24 @@
use crate::Tally;
use codec::{Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo;
#[cfg(feature = "std")]
use serde::{Deserialize, Serialize};
use sp_runtime::traits::{IntegerSquareRoot, Zero};
use sp_std::ops::{Add, Div, Mul, Rem};

/// A means of determining if a vote is past pass threshold.
#[derive(Clone, Copy, PartialEq, Eq, Encode, Decode, sp_runtime::RuntimeDebug, TypeInfo, MaxEncodedLen)]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
#[derive(
Serialize,
Deserialize,
Clone,
Copy,
PartialEq,
Eq,
Encode,
Decode,
sp_runtime::RuntimeDebug,
TypeInfo,
MaxEncodedLen,
)]
pub enum VoteThreshold {
/// A supermajority of approvals is needed to pass this vote.
SuperMajorityApprove,
Expand Down
4 changes: 2 additions & 2 deletions crates/dex-general/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ license = "Apache 2.0"

[dependencies]
log = { version = "0.4.14", default-features = false }
serde = { version = "1.0.119", optional = true }
serde = { version = "1.0.119", default-features = false }
# alias "parity-scale-code" to "codec"
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false }
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
Expand Down Expand Up @@ -35,7 +35,7 @@ proptest = "1.1.0"
default = ["std"]
std = [
"log/std",
"serde",
"serde/std",
"codec/std",
"scale-info/std",
"sp-core/std",
Expand Down
2 changes: 1 addition & 1 deletion crates/dex-general/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2021"
license = "Apache 2.0"

[dependencies]
serde = { version = "1.0.119", features = ["derive"], optional = true }
serde = { version = "1.0.119", features = ["derive"] , default-features = false}
# alias "parity-scale-code" to "codec"
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false }

Expand Down
Loading

0 comments on commit 8f82a9a

Please sign in to comment.