From 38958214930d3156bbaa973c5ace67e823cbdaeb Mon Sep 17 00:00:00 2001 From: Alexander Popiak Date: Wed, 12 Jul 2023 18:59:00 +0200 Subject: [PATCH 1/2] bump crate versions --- Cargo.lock | 10 +++++----- math/Cargo.toml | 2 +- pallets/dca/Cargo.toml | 2 +- primitives/Cargo.toml | 2 +- runtime/adapters/Cargo.toml | 2 +- runtime/hydradx/Cargo.toml | 2 +- runtime/hydradx/src/lib.rs | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 04db82c11..46cbcaac6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3686,7 +3686,7 @@ dependencies = [ [[package]] name = "hydra-dx-math" -version = "7.4.2" +version = "7.4.3" dependencies = [ "approx", "criterion", @@ -3783,7 +3783,7 @@ dependencies = [ [[package]] name = "hydradx-adapters" -version = "0.4.0" +version = "0.4.1" dependencies = [ "cumulus-pallet-parachain-system", "cumulus-primitives-core", @@ -3815,7 +3815,7 @@ dependencies = [ [[package]] name = "hydradx-runtime" -version = "166.0.0" +version = "167.0.0" dependencies = [ "cumulus-pallet-aura-ext", "cumulus-pallet-dmp-queue", @@ -6561,7 +6561,7 @@ dependencies = [ [[package]] name = "pallet-dca" -version = "1.1.6" +version = "1.1.7" dependencies = [ "cumulus-pallet-parachain-system", "cumulus-primitives-core", @@ -9350,7 +9350,7 @@ dependencies = [ [[package]] name = "primitives" -version = "5.8.1" +version = "5.8.2" dependencies = [ "frame-support", "hex-literal 0.3.4", diff --git a/math/Cargo.toml b/math/Cargo.toml index 47191d1c9..c6005ee41 100644 --- a/math/Cargo.toml +++ b/math/Cargo.toml @@ -6,7 +6,7 @@ license = 'Apache-2.0' name = "hydra-dx-math" description = "A collection of utilities to make performing liquidity pool calculations more convenient." repository = 'https://github.com/galacticcouncil/hydradx-math' -version = "7.4.2" +version = "7.4.3" [dependencies] primitive-types = {default-features = false, version = '0.12.0'} diff --git a/pallets/dca/Cargo.toml b/pallets/dca/Cargo.toml index 4db1fa6c3..f22fd3df7 100644 --- a/pallets/dca/Cargo.toml +++ b/pallets/dca/Cargo.toml @@ -1,6 +1,6 @@ [package] name = 'pallet-dca' -version = '1.1.6' +version = "1.1.7" description = 'A pallet to manage DCA scheduling' authors = ['GalacticCouncil'] edition = '2021' diff --git a/primitives/Cargo.toml b/primitives/Cargo.toml index f8a3c1622..a42eb1efc 100644 --- a/primitives/Cargo.toml +++ b/primitives/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "primitives" -version = "5.8.1" +version = "5.8.2" authors = ["GalacticCouncil"] edition = "2021" repository = "https://github.com/galacticcouncil/HydraDX-node" diff --git a/runtime/adapters/Cargo.toml b/runtime/adapters/Cargo.toml index c5e1cbe5b..6c0e162d0 100644 --- a/runtime/adapters/Cargo.toml +++ b/runtime/adapters/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hydradx-adapters" -version = "0.4.0" +version = "0.4.1" description = "Structs and other generic types for building runtimes." authors = ["GalacticCouncil"] edition = "2021" diff --git a/runtime/hydradx/Cargo.toml b/runtime/hydradx/Cargo.toml index ba21c3895..8aff00d07 100644 --- a/runtime/hydradx/Cargo.toml +++ b/runtime/hydradx/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hydradx-runtime" -version = "166.0.0" +version = "167.0.0" authors = ["GalacticCouncil"] edition = "2021" license = "Apache 2.0" diff --git a/runtime/hydradx/src/lib.rs b/runtime/hydradx/src/lib.rs index b1e1fce05..8bcf9a6e3 100644 --- a/runtime/hydradx/src/lib.rs +++ b/runtime/hydradx/src/lib.rs @@ -95,7 +95,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("hydradx"), impl_name: create_runtime_str!("hydradx"), authoring_version: 1, - spec_version: 166, + spec_version: 167, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 1, From d7917df8683ad8fb931f45eaac83ef7f342851a5 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Sat, 15 Jul 2023 19:39:51 +0200 Subject: [PATCH 2/2] remove faucet pallet --- Cargo.lock | 18 ---- Cargo.toml | 2 - pallets/faucet/Cargo.toml | 39 -------- pallets/faucet/README.md | 6 -- pallets/faucet/src/lib.rs | 162 --------------------------------- pallets/faucet/src/mock.rs | 174 ------------------------------------ pallets/faucet/src/tests.rs | 93 ------------------- 7 files changed, 494 deletions(-) delete mode 100644 pallets/faucet/Cargo.toml delete mode 100644 pallets/faucet/README.md delete mode 100644 pallets/faucet/src/lib.rs delete mode 100644 pallets/faucet/src/mock.rs delete mode 100644 pallets/faucet/src/tests.rs diff --git a/Cargo.lock b/Cargo.lock index 46cbcaac6..7141a8436 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6759,24 +6759,6 @@ dependencies = [ "sp-std", ] -[[package]] -name = "pallet-faucet" -version = "0.2.3" -dependencies = [ - "frame-support", - "frame-system", - "orml-tokens", - "orml-traits", - "parity-scale-codec", - "scale-info", - "serde", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", - "test-utils", -] - [[package]] name = "pallet-genesis-history" version = "2.0.1" diff --git a/Cargo.toml b/Cargo.toml index e5d9aba79..4d0c4126a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,6 @@ members = [ 'pallets/xcm-rate-limiter', 'pallets/omnipool-liquidity-mining', 'scraper', - 'pallets/faucet', 'traits', 'pallets/relaychain-info', 'pallets/route-executor', @@ -52,7 +51,6 @@ pallet-dca = { path = "pallets/dca", default-features = false } pallet-duster = { path = "pallets/duster", default-features = false } pallet-dynamic-fees = { path = "pallets/dynamic-fees", default-features = false } pallet-ema-oracle = { path = "pallets/ema-oracle", default-features = false } -pallet-faucet = { path = "pallets/faucet", default-features = false } pallet-genesis-history = { path = "pallets/genesis-history", default-features = false } pallet-liquidity-mining = { path = "pallets/liquidity-mining", default-features = false } pallet-nft = { path = "pallets/nft", default-features = false } diff --git a/pallets/faucet/Cargo.toml b/pallets/faucet/Cargo.toml deleted file mode 100644 index 7392822c9..000000000 --- a/pallets/faucet/Cargo.toml +++ /dev/null @@ -1,39 +0,0 @@ -[package] -name = 'pallet-faucet' -version = '0.2.3' -description = 'Simple token faucet to dispence resource on dev chain' -authors = ['GalacticCouncil'] -edition = '2021' -license = 'Apache 2.0' -repository = "https://github.com/galacticcouncil/warehouse/tree/master/faucet" - -[dependencies] -codec = { default-features = false, features = ["derive"], package = "parity-scale-codec", version = "3.4.0" } -scale-info = { version = "2.1.2", default-features = false, features = ["derive"] } -serde = { features = ["derive"], optional = true, version = "1.0.137" } - -# ORML dependencies -orml-tokens = { workspace = true } -orml-traits = { workspace = true } - -# Substrate dependencies -frame-support = { workspace = true } -frame-system= { workspace = true } -sp-std = { workspace = true } -sp-core = { workspace = true } -sp-runtime = { workspace = true } - -[dev-dependencies] -sp-io = { workspace = true } -test-utils = { workspace = true } - -[features] -default = ['std'] -std = [ - 'serde/std', - 'codec/std', - 'sp-std/std', - 'frame-support/std', - 'frame-system/std', - 'orml-tokens/std', -] diff --git a/pallets/faucet/README.md b/pallets/faucet/README.md deleted file mode 100644 index f8650f31b..000000000 --- a/pallets/faucet/README.md +++ /dev/null @@ -1,6 +0,0 @@ -### Faucet pallet - -## Overview -Simple token faucet to dispense resource on development chain. - -Only works with AssetId = u32 and Balance = u128. diff --git a/pallets/faucet/src/lib.rs b/pallets/faucet/src/lib.rs deleted file mode 100644 index e6a0dd941..000000000 --- a/pallets/faucet/src/lib.rs +++ /dev/null @@ -1,162 +0,0 @@ -// This file is part of pallet-faucet. - -// Copyright (C) 2020-2022 Intergalactic, Limited (GIB). -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#![cfg_attr(not(feature = "std"), no_std)] -#![allow(clippy::unused_unit)] - -use frame_support::ensure; -use frame_system::ensure_signed; -use orml_traits::{MultiCurrency, MultiCurrencyExtended}; -use sp_std::vec::Vec; - -#[cfg(test)] -mod mock; - -#[cfg(test)] -mod tests; - -type AssetId = u32; -type Balance = u128; - -// Re-export pallet items so that they can be accessed from the crate namespace. -pub use pallet::*; - -#[frame_support::pallet] -pub mod pallet { - use super::*; - use frame_support::pallet_prelude::*; - use frame_system::pallet_prelude::OriginFor; - - #[pallet::pallet] - #[pallet::without_storage_info] - pub struct Pallet(_); - - #[pallet::hooks] - impl Hooks for Pallet { - fn on_finalize(_p: T::BlockNumber) { - Minted::::set(0u8); - } - } - - #[pallet::config] - pub trait Config: frame_system::Config { - type RuntimeEvent: From> + IsType<::RuntimeEvent>; - - type Currency: MultiCurrencyExtended; - } - - #[pallet::event] - #[pallet::generate_deposit(pub(crate) fn deposit_event)] - pub enum Event { - RampageMint { - account_id: T::AccountId, - asset_id: AssetId, - amount: Balance, - }, - Mint { - account_id: T::AccountId, - }, - } - - #[pallet::error] - pub enum Error { - RampageMintNotAllowed, - MaximumMintLimitReached, - } - #[pallet::storage] - #[pallet::getter(fn minted)] - pub type Minted = StorageValue<_, u8, ValueQuery>; - - #[pallet::storage] - #[pallet::getter(fn mint_limit)] - pub type MintLimit = StorageValue<_, u8, ValueQuery>; - - #[pallet::storage] - #[pallet::getter(fn rampage)] - pub type Rampage = StorageValue<_, bool, ValueQuery>; - - #[pallet::storage] - #[pallet::getter(fn mintable_currencies)] - pub type MintableCurrencies = StorageValue<_, Vec, ValueQuery>; - - #[pallet::genesis_config] - #[derive(Default)] - pub struct GenesisConfig { - pub mint_limit: u8, - pub rampage: bool, - pub mintable_currencies: Vec, - } - - #[cfg(feature = "std")] - impl GenesisConfig { - /// Direct implementation to not break dependency - pub fn build_storage(&self) -> Result { - >::build_storage(self) - } - - /// Direct implementation to not break dependency - pub fn assimilate_storage(&self, storage: &mut sp_runtime::Storage) -> Result<(), String> { - >::assimilate_storage(self, storage) - } - } - - #[pallet::genesis_build] - impl GenesisBuild for GenesisConfig { - fn build(&self) { - MintLimit::::put(self.mint_limit); - Rampage::::put(self.rampage); - MintableCurrencies::::put(self.mintable_currencies.clone()); - } - } - - #[pallet::call] - impl Pallet { - #[pallet::call_index(0)] - #[pallet::weight((0, DispatchClass::Normal, Pays::No))] - pub fn rampage_mint(origin: OriginFor, asset: AssetId, amount: Balance) -> DispatchResultWithPostInfo { - let who = ensure_signed(origin)?; - ensure!(Self::rampage(), Error::::RampageMintNotAllowed); - - T::Currency::deposit(asset, &who, amount)?; - Self::deposit_event(Event::RampageMint { - account_id: who, - asset_id: asset, - amount, - }); - - Ok(().into()) - } - - #[pallet::call_index(1)] - #[pallet::weight((0, DispatchClass::Normal, Pays::No))] - pub fn mint(origin: OriginFor) -> DispatchResultWithPostInfo { - let who = ensure_signed(origin)?; - - ensure!(Self::minted() < Self::mint_limit(), Error::::MaximumMintLimitReached); - - for i in Self::mintable_currencies() { - T::Currency::deposit(i, &who, 1_000_000_000_000_000)?; - } - - Minted::::set(Self::minted() + 1); - - Self::deposit_event(Event::Mint { account_id: who }); - - Ok(().into()) - } - } -} diff --git a/pallets/faucet/src/mock.rs b/pallets/faucet/src/mock.rs deleted file mode 100644 index 10f0da292..000000000 --- a/pallets/faucet/src/mock.rs +++ /dev/null @@ -1,174 +0,0 @@ -// This file is part of HydraDX. - -// Copyright (C) 2020-2022 Intergalactic, Limited (GIB). -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -use crate as faucet; -use crate::Config; -use frame_support::parameter_types; -use frame_support::traits::{Everything, GenesisBuild, Nothing}; -use frame_system as system; -use orml_traits::parameter_type_with_key; -use sp_core::H256; -use sp_runtime::{ - testing::Header, - traits::{BlakeTwo256, IdentityLookup, One}, -}; - -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; -type Block = frame_system::mocking::MockBlock; - -type AssetId = u32; -type Balance = u128; - -frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, - { - System: frame_system::{Pallet, Call, Config, Storage, Event}, - Faucet: faucet::{Pallet, Call,Config, Storage, Event}, - Currency: orml_tokens::{Pallet, Event}, - } -); - -parameter_types! { - pub const BlockHashCount: u64 = 250; - pub const SS58Prefix: u8 = 63; -} - -impl system::Config for Test { - type BaseCallFilter = Everything; - type BlockWeights = (); - type BlockLength = (); - type RuntimeOrigin = RuntimeOrigin; - type RuntimeCall = RuntimeCall; - type Index = u64; - type BlockNumber = u64; - type Hash = H256; - type Hashing = BlakeTwo256; - type AccountId = u64; - type Lookup = IdentityLookup; - type Header = Header; - type RuntimeEvent = RuntimeEvent; - type BlockHashCount = BlockHashCount; - type DbWeight = (); - type Version = (); - type PalletInfo = PalletInfo; - type AccountData = (); - type OnNewAccount = (); - type OnKilledAccount = (); - type SystemWeightInfo = (); - type SS58Prefix = SS58Prefix; - type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; -} - -pub type Amount = i128; - -parameter_type_with_key! { - pub ExistentialDeposits: |_currency_id: AssetId| -> Balance { - One::one() - }; -} - -parameter_types! { - pub const MaxReserves: u32 = 50; -} - -impl orml_tokens::Config for Test { - type RuntimeEvent = RuntimeEvent; - type Balance = Balance; - type Amount = Amount; - type CurrencyId = AssetId; - type WeightInfo = (); - type ExistentialDeposits = ExistentialDeposits; - type MaxLocks = (); - type DustRemovalWhitelist = Nothing; - type ReserveIdentifier = (); - type MaxReserves = MaxReserves; - type CurrencyHooks = (); -} - -impl Config for Test { - type RuntimeEvent = RuntimeEvent; - type Currency = Currency; -} - -pub type AccountId = u64; - -pub const ALICE: AccountId = 1; - -pub const HDX: AssetId = 1000; - -pub struct ExtBuilder { - endowed_accounts: Vec<(AccountId, AssetId, Balance)>, -} - -// Returns default values for genesis config -impl Default for ExtBuilder { - fn default() -> Self { - Self { - endowed_accounts: vec![(ALICE, HDX, 1000u128)], - } - } -} - -impl ExtBuilder { - pub fn build_rampage(self) -> sp_io::TestExternalities { - let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); - - orml_tokens::GenesisConfig:: { - balances: self.endowed_accounts, - } - .assimilate_storage(&mut t) - .unwrap(); - - faucet::GenesisConfig { - rampage: true, - mintable_currencies: vec![2000, 3000], - mint_limit: 5, - } - .assimilate_storage::(&mut t) - .unwrap(); - - t.into() - } - - pub fn build_live(self) -> sp_io::TestExternalities { - let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); - - crate::GenesisConfig { - rampage: false, - mintable_currencies: vec![2000, 3000], - mint_limit: 5, - } - .assimilate_storage::(&mut t) - .unwrap(); - - orml_tokens::GenesisConfig:: { - balances: self.endowed_accounts, - } - .assimilate_storage(&mut t) - .unwrap(); - - t.into() - } -} - -pub fn expect_events(e: Vec) { - test_utils::expect_events::(e) -} diff --git a/pallets/faucet/src/tests.rs b/pallets/faucet/src/tests.rs deleted file mode 100644 index ac0601ca9..000000000 --- a/pallets/faucet/src/tests.rs +++ /dev/null @@ -1,93 +0,0 @@ -// This file is part of HydraDX. - -// Copyright (C) 2020-2022 Intergalactic, Limited (GIB). -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -use super::*; -use crate::mock::{expect_events, Currency, ExtBuilder, Faucet, RuntimeOrigin, System, Test, ALICE, HDX}; -use frame_support::traits::OnFinalize; -use frame_support::{assert_noop, assert_ok}; - -#[test] -fn rampage_mints() { - ExtBuilder::default().build_rampage().execute_with(|| { - //Arrange - System::set_block_number(1); //For event emitting - - //Act - assert_ok!(Faucet::rampage_mint(RuntimeOrigin::signed(ALICE), HDX, 1000)); - - //Assert - assert_eq!(Currency::free_balance(HDX, &ALICE), 2000); - expect_events(vec![Event::RampageMint { - account_id: ALICE, - asset_id: HDX, - amount: 1000, - } - .into()]); - }); -} - -#[test] -fn mints() { - ExtBuilder::default().build_live().execute_with(|| { - //Arrange - System::set_block_number(1); //For event emitting - - assert_eq!(Currency::free_balance(2000, &ALICE), 0); - - //Act - assert_ok!(Faucet::mint(RuntimeOrigin::signed(ALICE))); - - //Assert - assert_eq!(Currency::free_balance(2000, &ALICE), 1_000_000_000_000_000); - assert_eq!(Currency::free_balance(3000, &ALICE), 1_000_000_000_000_000); - assert_eq!(Currency::free_balance(4000, &ALICE), 0); - - expect_events(vec![Event::Mint { account_id: ALICE }.into()]); - }); -} - -#[test] -fn rampage_disabled() { - ExtBuilder::default().build_live().execute_with(|| { - assert_noop!( - Faucet::rampage_mint(RuntimeOrigin::signed(ALICE), HDX, 1000), - Error::::RampageMintNotAllowed - ); - }); -} - -#[test] -fn mint_limit() { - ExtBuilder::default().build_live().execute_with(|| { - assert_ok!(Faucet::mint(RuntimeOrigin::signed(ALICE))); - assert_ok!(Faucet::mint(RuntimeOrigin::signed(ALICE))); - assert_ok!(Faucet::mint(RuntimeOrigin::signed(ALICE))); - assert_ok!(Faucet::mint(RuntimeOrigin::signed(ALICE))); - assert_ok!(Faucet::mint(RuntimeOrigin::signed(ALICE))); - - assert_noop!( - Faucet::mint(RuntimeOrigin::signed(ALICE)), - Error::::MaximumMintLimitReached - ); - - >::on_finalize(1); - - assert_ok!(Faucet::mint(RuntimeOrigin::signed(ALICE))); - - assert_eq!(Currency::free_balance(2000, &ALICE), 6_000_000_000_000_000); - }); -}