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 77ba8e4
Show file tree
Hide file tree
Showing 73 changed files with 3,586 additions and 2,811 deletions.
5,121 changes: 2,900 additions & 2,221 deletions Cargo.lock

Large diffs are not rendered by default.

522 changes: 274 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
8 changes: 3 additions & 5 deletions crates/bitcoin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ 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"] }
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 @@ -26,12 +25,11 @@ default = ["std"]
std = [
"codec/std",
"scale-info/std",
"serde",
"impl-serde",
"serde/std",
"sha2/std",
"hex/alloc",
"primitive-types/std",
"primitive-types/serde",
# "primitive-types/serde",
"secp256k1/std",
]
parser = []
Expand Down
22 changes: 13 additions & 9 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,28 +153,29 @@ impl From<[u8; PUBLIC_KEY_SIZE]> for PublicKey {
}
}

#[cfg(feature = "std")]
// #[cfg(feature = "std")]
impl serde::Serialize for PublicKey {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
let mut slice = [0u8; 2 + 2 * PUBLIC_KEY_SIZE];
impl_serde::serialize::serialize_raw(&mut slice, &self.0, serializer)
// impl_serde::serialize::serialize_raw(&mut slice, &self.0, serializer)
todo!()
}
}

#[cfg(feature = "std")]
// #[cfg(feature = "std")]
impl<'de> serde::Deserialize<'de> for PublicKey {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let mut bytes = [0u8; PUBLIC_KEY_SIZE];
impl_serde::serialize::deserialize_check_len(
deserializer,
impl_serde::serialize::ExpectedLen::Exact(&mut bytes),
)?;
// impl_serde::serialize::deserialize_check_len(
// deserializer,
// impl_serde::serialize::ExpectedLen::Exact(&mut bytes),
// )?;todo()
Ok(PublicKey(bytes))
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/bitcoin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
//! - Script (address) construction and parsing.
//! - Merkle proof construction and verification.
//! - Elliptic curve multiplication over Secp256k1.
#![deny(warnings)]
// #![allow(clippy::all)]
// #![deny(warnings)]
#![cfg_attr(test, feature(proc_macro_hygiene))]
#![cfg_attr(not(feature = "std"), no_std)]

Expand Down
17 changes: 14 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,20 @@ 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(
serde::Serialize,
serde::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
2 changes: 1 addition & 1 deletion crates/collator-selection/src/mock.rs
Original file line number Diff line number Diff line change
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
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
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 77ba8e4

Please sign in to comment.