Skip to content

Commit

Permalink
decrease deposit amounts, add license notes
Browse files Browse the repository at this point in the history
  • Loading branch information
ilionic committed Jun 1, 2022
1 parent cbe3831 commit 11662cb
Show file tree
Hide file tree
Showing 23 changed files with 162 additions and 45 deletions.
4 changes: 4 additions & 0 deletions pallets/rmrk-core/src/functions.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (C) 2021-2022 RMRK
// This file is part of rmrk-core.
// License: Apache 2.0 modified by RMRK, see LICENSE.md

#![allow(clippy::too_many_arguments)]

use super::*;
Expand Down
4 changes: 4 additions & 0 deletions pallets/rmrk-core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (C) 2021-2022 RMRK
// This file is part of rmrk-core.
// License: Apache 2.0 modified by RMRK, see LICENSE.md

#![cfg_attr(not(feature = "std"), no_std)]
#![allow(clippy::unused_unit)]
#![allow(clippy::too_many_arguments)]
Expand Down
4 changes: 4 additions & 0 deletions pallets/rmrk-core/src/mock.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (C) 2021-2022 RMRK
// This file is part of rmrk-core.
// License: Apache 2.0 modified by RMRK, see LICENSE.md

use super::*;
use crate as pallet_rmrk_core;

Expand Down
4 changes: 4 additions & 0 deletions pallets/rmrk-core/src/tests.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (C) 2021-2022 RMRK
// This file is part of rmrk-core.
// License: Apache 2.0 modified by RMRK, see LICENSE.md

use frame_support::{assert_noop, assert_ok};
// use sp_runtime::AccountId32;
use sp_runtime::Permill;
Expand Down
4 changes: 4 additions & 0 deletions pallets/rmrk-core/src/types.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (C) 2021-2022 RMRK
// This file is part of rmrk-core.
// License: Apache 2.0 modified by RMRK, see LICENSE.md

use frame_support::pallet_prelude::*;
use sp_runtime::Permill;

Expand Down
38 changes: 27 additions & 11 deletions pallets/rmrk-equip/src/functions.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (C) 2021-2022 RMRK
// This file is part of rmrk-equip.
// License: Apache 2.0 modified by RMRK, see LICENSE.md

use super::*;
use frame_support::traits::tokens::Locker;

Expand Down Expand Up @@ -27,14 +31,20 @@ impl<T: Config> Pallet<T> {
}
}

impl<T: Config> Base<
T::AccountId,
CollectionId,
NftId,
StringLimitOf<T>,
BoundedVec<PartType<StringLimitOf<T>, BoundedVec<CollectionId, T::MaxCollectionsEquippablePerPart>>,
T::PartsLimit>,
BoundedVec<CollectionId, T::MaxCollectionsEquippablePerPart>
impl<T: Config>
Base<
T::AccountId,
CollectionId,
NftId,
StringLimitOf<T>,
BoundedVec<
PartType<
StringLimitOf<T>,
BoundedVec<CollectionId, T::MaxCollectionsEquippablePerPart>,
>,
T::PartsLimit,
>,
BoundedVec<CollectionId, T::MaxCollectionsEquippablePerPart>,
> for Pallet<T>
where
T: pallet_uniques::Config<ClassId = CollectionId, InstanceId = NftId>,
Expand All @@ -52,7 +62,13 @@ where
issuer: T::AccountId,
base_type: StringLimitOf<T>,
symbol: StringLimitOf<T>,
parts: BoundedVec<PartType<StringLimitOf<T>, BoundedVec<CollectionId, T::MaxCollectionsEquippablePerPart>>, T::PartsLimit>,
parts: BoundedVec<
PartType<
StringLimitOf<T>,
BoundedVec<CollectionId, T::MaxCollectionsEquippablePerPart>,
>,
T::PartsLimit,
>,
) -> Result<BaseId, DispatchError> {
let base_id = Self::get_next_base_id()?;
for part in parts.clone() {
Expand Down Expand Up @@ -226,8 +242,8 @@ where
// First we iterate through the resources added to this NFT in search of the base ID
ensure!(
pallet_rmrk_core::Pallet::<T>::composable_resources((
equipper_collection_id,
equipper_nft_id,
equipper_collection_id,
equipper_nft_id,
// resource_id,
base_id
))
Expand Down
67 changes: 44 additions & 23 deletions pallets/rmrk-equip/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (C) 2021-2022 RMRK
// This file is part of rmrk-equip.
// License: Apache 2.0 modified by RMRK, see LICENSE.md

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

Expand All @@ -6,13 +10,13 @@ use frame_support::{
ensure, BoundedVec,
};

use sp_runtime::{traits::StaticLookup};
use sp_runtime::traits::StaticLookup;

pub use pallet::*;

use rmrk_traits::{
primitives::*, AccountIdOrCollectionNftTuple, Base, BaseInfo, EquippableList, PartType, Theme,
BasicResource, ComposableResource, SlotResource, ResourceTypes,
primitives::*, AccountIdOrCollectionNftTuple, Base, BaseInfo, BasicResource,
ComposableResource, EquippableList, PartType, ResourceTypes, SlotResource, Theme,
};

mod functions;
Expand Down Expand Up @@ -49,30 +53,44 @@ pub mod pallet {

/// Maximum number of Properties allowed for any Theme
#[pallet::constant]
type MaxCollectionsEquippablePerPart: Get<u32>;
type MaxCollectionsEquippablePerPart: Get<u32>;
}

#[pallet::storage]
#[pallet::getter(fn bases)]
/// Stores Bases info (issuer, base_type, symbol, parts)
/// TODO https://github.com/rmrk-team/rmrk-substrate/issues/98
/// Delete Parts from Bases info, as it's kept in Parts storage
pub type Bases<T: Config> =
StorageMap<
_,
Twox64Concat, BaseId,
pub type Bases<T: Config> = StorageMap<
_,
Twox64Concat,
BaseId,
BaseInfo<
T::AccountId, StringLimitOf<T>, BoundedVec<PartType<StringLimitOf<T>, BoundedVec<CollectionId, T::MaxCollectionsEquippablePerPart>>,
T::PartsLimit>>
>;
T::AccountId,
StringLimitOf<T>,
BoundedVec<
PartType<
StringLimitOf<T>,
BoundedVec<CollectionId, T::MaxCollectionsEquippablePerPart>,
>,
T::PartsLimit,
>,
>,
>;

#[pallet::storage]
#[pallet::getter(fn parts)]
/// Stores Parts (either FixedPart or SlotPart)
/// - SlotPart: id, equippable (list), src, z
/// - FixedPart: id, src, z
pub type Parts<T: Config> =
StorageDoubleMap<_, Twox64Concat, BaseId, Twox64Concat, PartId, PartType<StringLimitOf<T>, BoundedVec<CollectionId, T::MaxCollectionsEquippablePerPart>>>;
pub type Parts<T: Config> = StorageDoubleMap<
_,
Twox64Concat,
BaseId,
Twox64Concat,
PartId,
PartType<StringLimitOf<T>, BoundedVec<CollectionId, T::MaxCollectionsEquippablePerPart>>,
>;

#[pallet::storage]
#[pallet::getter(fn next_base_id)]
Expand Down Expand Up @@ -214,18 +232,13 @@ pub mod pallet {
new_issuer: <T::Lookup as StaticLookup>::Source,
) -> DispatchResult {
let sender = ensure_signed(origin.clone())?;
let base =
Self::bases(base_id).ok_or(Error::<T>::BaseDoesntExist)?;
let base = Self::bases(base_id).ok_or(Error::<T>::BaseDoesntExist)?;
ensure!(base.issuer == sender, Error::<T>::PermissionError);
let new_owner = T::Lookup::lookup(new_issuer.clone())?;

ensure!(
Bases::<T>::contains_key(base_id),
Error::<T>::NoAvailableBaseId
);
ensure!(Bases::<T>::contains_key(base_id), Error::<T>::NoAvailableBaseId);

let (new_owner, base_id) =
Self::base_change_issuer(base_id, new_owner)?;
let (new_owner, base_id) = Self::base_change_issuer(base_id, new_owner)?;

Self::deposit_event(Event::BaseIssuerChanged {
old_issuer: sender,
Expand Down Expand Up @@ -295,7 +308,9 @@ pub mod pallet {
origin: OriginFor<T>,
base_id: BaseId,
slot_id: SlotId,
equippables: EquippableList<BoundedVec<CollectionId, T::MaxCollectionsEquippablePerPart>>,
equippables: EquippableList<
BoundedVec<CollectionId, T::MaxCollectionsEquippablePerPart>,
>,
) -> DispatchResult {
let sender = ensure_signed(origin)?;

Expand Down Expand Up @@ -352,7 +367,13 @@ pub mod pallet {
origin: OriginFor<T>,
base_type: BoundedVec<u8, T::StringLimit>,
symbol: BoundedVec<u8, T::StringLimit>,
parts: BoundedVec<PartType<StringLimitOf<T>, BoundedVec<CollectionId, T::MaxCollectionsEquippablePerPart>>, T::PartsLimit>,
parts: BoundedVec<
PartType<
StringLimitOf<T>,
BoundedVec<CollectionId, T::MaxCollectionsEquippablePerPart>,
>,
T::PartsLimit,
>,
) -> DispatchResult {
let sender = ensure_signed(origin)?;

Expand Down
4 changes: 4 additions & 0 deletions pallets/rmrk-equip/src/mock.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (C) 2021-2022 RMRK
// This file is part of rmrk-equip.
// License: Apache 2.0 modified by RMRK, see LICENSE.md

use super::*;
use crate as pallet_rmrk_equip;

Expand Down
4 changes: 4 additions & 0 deletions pallets/rmrk-equip/src/tests.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (C) 2021-2022 RMRK
// This file is part of rmrk-equip.
// License: Apache 2.0 modified by RMRK, see LICENSE.md

use super::*;

use rmrk_traits::{FixedPart, SlotPart, ThemeProperty};
Expand Down
4 changes: 4 additions & 0 deletions pallets/rmrk-market/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (C) 2021-2022 RMRK
// This file is part of rmrk-market.
// License: Apache 2.0 modified by RMRK, see LICENSE.md

#![cfg_attr(not(feature = "std"), no_std)]
#![allow(clippy::unused_unit)]
#![allow(clippy::upper_case_acronyms)]
Expand Down
4 changes: 4 additions & 0 deletions pallets/rmrk-market/src/mock.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (C) 2021-2022 RMRK
// This file is part of rmrk-market.
// License: Apache 2.0 modified by RMRK, see LICENSE.md

use super::*;
use crate as pallet_rmrk_market;

Expand Down
4 changes: 4 additions & 0 deletions pallets/rmrk-market/src/tests.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (C) 2021-2022 RMRK
// This file is part of rmrk-market.
// License: Apache 2.0 modified by RMRK, see LICENSE.md

use super::*;
use crate::mock::*;
use frame_support::{assert_noop, assert_ok};
Expand Down
4 changes: 4 additions & 0 deletions pallets/rmrk-market/src/types.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (C) 2021-2022 RMRK
// This file is part of rmrk-market.
// License: Apache 2.0 modified by RMRK, see LICENSE.md

use frame_support::pallet_prelude::*;

#[cfg(feature = "std")]
Expand Down
8 changes: 4 additions & 4 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,13 +362,13 @@ impl pallet_rmrk_market::Config for Runtime {
}

parameter_types! {
pub const ClassDeposit: Balance = 100 * DOLLARS;
pub const ClassDeposit: Balance = 10 * CENTS;
pub const InstanceDeposit: Balance = DOLLARS;
pub const KeyLimit: u32 = 32;
pub const ValueLimit: u32 = 256;
pub const UniquesMetadataDepositBase: Balance = 100 * DOLLARS;
pub const AttributeDepositBase: Balance = 10 * DOLLARS;
pub const DepositPerByte: Balance = DOLLARS;
pub const UniquesMetadataDepositBase: Balance = 10 * CENTS;
pub const AttributeDepositBase: Balance = 10 * CENTS;
pub const DepositPerByte: Balance = CENTS;
pub const UniquesStringLimit: u32 = 128;
pub const MaxPropertiesPerTheme: u32 = 100;
pub const MaxCollectionsEquippablePerPart: u32 = 100;
Expand Down
9 changes: 6 additions & 3 deletions traits/src/base.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
// Copyright (C) 2021-2022 RMRK
// This file is part of rmrk-substrate.
// License: Apache 2.0 modified by RMRK, see LICENSE.md

use super::{
part::{EquippableList, PartType},
theme::Theme,
};
use crate::primitives::{BaseId, SlotId, ResourceId};
use crate::primitives::{BaseId, ResourceId, SlotId};
use codec::{Decode, Encode};
use frame_support::pallet_prelude::MaxEncodedLen;
use scale_info::TypeInfo;
use sp_runtime::{DispatchError, RuntimeDebug};
use sp_std::vec::Vec;
use frame_support::pallet_prelude::MaxEncodedLen;


#[cfg_attr(feature = "std", derive(PartialEq, Eq))]
#[derive(Encode, Decode, RuntimeDebug, TypeInfo, MaxEncodedLen)]
Expand Down
6 changes: 5 additions & 1 deletion traits/src/collection.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
// Copyright (C) 2021-2022 RMRK
// This file is part of rmrk-substrate.
// License: Apache 2.0 modified by RMRK, see LICENSE.md

use codec::{Decode, Encode};
use frame_support::pallet_prelude::MaxEncodedLen;
use scale_info::TypeInfo;
use sp_runtime::{DispatchError, DispatchResult, RuntimeDebug};
use frame_support::pallet_prelude::MaxEncodedLen;

use crate::primitives::*;
use sp_std::result::Result;
Expand Down
8 changes: 7 additions & 1 deletion traits/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (C) 2021-2022 RMRK
// This file is part of rmrk-substrate.
// License: Apache 2.0 modified by RMRK, see LICENSE.md

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

pub mod base;
Expand All @@ -17,7 +21,9 @@ pub use collection::{Collection, CollectionInfo};
pub use nft::{AccountIdOrCollectionNftTuple, Nft, NftInfo, RoyaltyInfo};
pub use priority::Priority;
pub use property::Property;
pub use resource::{Resource, ResourceInfo, ResourceTypes, BasicResource, SlotResource, ComposableResource};
pub use resource::{
BasicResource, ComposableResource, Resource, ResourceInfo, ResourceTypes, SlotResource,
};
pub mod primitives {
pub type CollectionId = u32;
pub type ResourceId = u32;
Expand Down
5 changes: 4 additions & 1 deletion traits/src/nft.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (C) 2021-2022 RMRK
// This file is part of rmrk-substrate.
// License: Apache 2.0 modified by RMRK, see LICENSE.md

use codec::{Decode, Encode};
use scale_info::TypeInfo;
use sp_runtime::{DispatchError, RuntimeDebug};
Expand Down Expand Up @@ -46,7 +50,6 @@ pub struct NftInfo<AccountId, BoundedString> {
/// transferability ( non-transferable is "souldbound" )
pub transferable: bool,
}

/// Abstraction over a Nft system.
#[allow(clippy::upper_case_acronyms)]
pub trait Nft<AccountId, BoundedString> {
Expand Down
6 changes: 5 additions & 1 deletion traits/src/part.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
// Copyright (C) 2021-2022 RMRK
// This file is part of rmrk-substrate.
// License: Apache 2.0 modified by RMRK, see LICENSE.md

use crate::primitives::*;
use codec::{Decode, Encode};
use frame_support::pallet_prelude::MaxEncodedLen;
use scale_info::TypeInfo;
use sp_runtime::RuntimeDebug;
use sp_std::vec::Vec;
use frame_support::pallet_prelude::MaxEncodedLen;

// #[cfg_attr(feature = "std", derive(PartialEq, Eq))]
#[derive(Encode, Decode, RuntimeDebug, TypeInfo, Clone, PartialEq, Eq, MaxEncodedLen)]
Expand Down
4 changes: 4 additions & 0 deletions traits/src/priority.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (C) 2021-2022 RMRK
// This file is part of rmrk-substrate.
// License: Apache 2.0 modified by RMRK, see LICENSE.md

use sp_runtime::DispatchResult;

use crate::primitives::*;
Expand Down
4 changes: 4 additions & 0 deletions traits/src/property.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (C) 2021-2022 RMRK
// This file is part of rmrk-substrate.
// License: Apache 2.0 modified by RMRK, see LICENSE.md

use sp_runtime::DispatchResult;

use crate::primitives::*;
Expand Down
Loading

0 comments on commit 11662cb

Please sign in to comment.