difftreelog
fix unit tests
in: master
2 files changed
runtime/tests/src/lib.rsdiffbeforeafterboth1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617#![allow(clippy::from_over_into)]1819use sp_core::{H256, U256};20use frame_support::{21 parameter_types,22 traits::{Everything, ConstU32, ConstU64},23 weights::IdentityFee,24};25use sp_runtime::{26 traits::{BlakeTwo256, IdentityLookup},27 testing::Header,28};29use pallet_transaction_payment::{CurrencyAdapter};30use frame_system as system;31use pallet_evm::{32 AddressMapping, account::CrossAccountId, EnsureAddressNever, SubstrateBlockHashMapping,33};34use fp_evm_mapping::EvmBackwardsAddressMapping;35use parity_scale_codec::{Encode, Decode, MaxEncodedLen};36use scale_info::TypeInfo;3738use unique_runtime_common::{dispatch::CollectionDispatchT, weights::CommonWeights};39use up_data_structs::mapping::{CrossTokenAddressMapping, EvmTokenAddressMapping};4041type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;42type Block = frame_system::mocking::MockBlock<Test>;4344#[cfg(test)]45mod tests;4647// Configure a mock runtime to test the pallet.48frame_support::construct_runtime!(49 pub enum Test where50 Block = Block,51 NodeBlock = Block,52 UncheckedExtrinsic = UncheckedExtrinsic,53 {54 System: frame_system::{Pallet, Call, Config, Storage, Event<T>},55 Unique: pallet_unique::{Pallet, Call, Storage},56 Balances: pallet_balances::{Pallet, Call, Storage},57 Common: pallet_common::{Pallet, Storage, Event<T>},58 Fungible: pallet_fungible::{Pallet, Storage},59 Refungible: pallet_refungible::{Pallet, Storage},60 Nonfungible: pallet_nonfungible::{Pallet, Storage},61 }62);6364parameter_types! {65 pub const BlockHashCount: u64 = 250;66 pub const SS58Prefix: u8 = 42;67}6869impl system::Config for Test {70 type BaseCallFilter = Everything;71 type BlockWeights = ();72 type BlockLength = ();73 type DbWeight = ();74 type Origin = Origin;75 type Call = Call;76 type Index = u64;77 type BlockNumber = u64;78 type Hash = H256;79 type Hashing = BlakeTwo256;80 type AccountId = u64;81 type Lookup = IdentityLookup<Self::AccountId>;82 type Header = Header;83 type Event = ();84 type BlockHashCount = BlockHashCount;85 type Version = ();86 type PalletInfo = PalletInfo;87 type AccountData = pallet_balances::AccountData<u64>;88 type OnNewAccount = ();89 type OnKilledAccount = ();90 type SystemWeightInfo = ();91 type SS58Prefix = SS58Prefix;92 type OnSetCode = ();93 type MaxConsumers = ConstU32<16>;94}9596parameter_types! {97 pub const ExistentialDeposit: u64 = 1;98 pub const MaxLocks: u32 = 50;99}100//frame_system::Module<Test>;101impl pallet_balances::Config for Test {102 type AccountStore = System;103 type Balance = u64;104 type DustRemoval = ();105 type Event = ();106 type ExistentialDeposit = ExistentialDeposit;107 type WeightInfo = ();108 type MaxLocks = MaxLocks;109 type MaxReserves = ();110 type ReserveIdentifier = [u8; 8];111}112113parameter_types! {114 pub const OperationalFeeMultiplier: u8 = 5;115}116117impl pallet_transaction_payment::Config for Test {118 type OnChargeTransaction = CurrencyAdapter<pallet_balances::Pallet<Test>, ()>;119 type LengthToFee = IdentityFee<u64>;120 type WeightToFee = IdentityFee<u64>;121 type FeeMultiplierUpdate = ();122 type OperationalFeeMultiplier = OperationalFeeMultiplier;123}124125parameter_types! {126 pub const MinimumPeriod: u64 = 1;127}128impl pallet_timestamp::Config for Test {129 type Moment = u64;130 type OnTimestampSet = ();131 type MinimumPeriod = MinimumPeriod;132 type WeightInfo = ();133}134135parameter_types! {136 pub const CollectionCreationPrice: u32 = 100;137 pub TreasuryAccountId: u64 = 1234;138 pub EthereumChainId: u32 = 1111;139}140141pub struct TestEvmAddressMapping;142impl AddressMapping<u64> for TestEvmAddressMapping {143 fn into_account_id(_addr: sp_core::H160) -> u64 {144 unimplemented!()145 }146}147148pub struct TestEvmBackwardsAddressMapping;149impl EvmBackwardsAddressMapping<u64> for TestEvmBackwardsAddressMapping {150 fn from_account_id(_account_id: u64) -> sp_core::H160 {151 unimplemented!()152 }153}154155#[derive(Encode, Decode, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, TypeInfo, MaxEncodedLen)]156pub struct TestCrossAccountId(u64, sp_core::H160);157impl CrossAccountId<u64> for TestCrossAccountId {158 fn as_sub(&self) -> &u64 {159 &self.0160 }161 fn as_eth(&self) -> &sp_core::H160 {162 &self.1163 }164 fn from_sub(sub: u64) -> Self {165 let mut eth = [0; 20];166 eth[12..20].copy_from_slice(&sub.to_be_bytes());167 Self(sub, sp_core::H160(eth))168 }169 fn from_eth(eth: sp_core::H160) -> Self {170 let mut sub_raw = [0; 8];171 sub_raw.copy_from_slice(ð.0[0..8]);172 let sub = u64::from_be_bytes(sub_raw);173 Self(sub, eth)174 }175 fn conv_eq(&self, other: &Self) -> bool {176 self.as_sub() == other.as_sub()177 }178}179180impl Default for TestCrossAccountId {181 fn default() -> Self {182 Self::from_sub(0)183 }184}185186parameter_types! {187 pub BlockGasLimit: U256 = 0u32.into();188}189190impl pallet_evm::Config for Test {191 type Event = ();192 type FeeCalculator = ();193 type GasWeightMapping = ();194 type CallOrigin = EnsureAddressNever<Self::CrossAccountId>;195 type WithdrawOrigin = EnsureAddressNever<Self::CrossAccountId>;196 type AddressMapping = TestEvmAddressMapping;197 type Currency = Balances;198 type PrecompilesType = ();199 type PrecompilesValue = ();200 type Runner = pallet_evm::runner::stack::Runner<Self>;201 type ChainId = ConstU64<0>;202 type BlockGasLimit = BlockGasLimit;203 type OnMethodCall = ();204 type OnCreate = ();205 type OnChargeTransaction = ();206 type FindAuthor = ();207 type BlockHashMapping = SubstrateBlockHashMapping<Self>;208 type TransactionValidityHack = ();209}210impl pallet_evm_coder_substrate::Config for Test {211 type GasWeightMapping = ();212}213214impl pallet_common::Config for Test {215 type WeightInfo = ();216 type Event = ();217 type Currency = Balances;218 type CollectionCreationPrice = CollectionCreationPrice;219 type TreasuryAccountId = TreasuryAccountId;220221 type CollectionDispatch = CollectionDispatchT<Self>;222 type EvmTokenAddressMapping = EvmTokenAddressMapping;223 type CrossTokenAddressMapping = CrossTokenAddressMapping<Self::AccountId>;224}225226impl pallet_evm::account::Config for Test {227 type CrossAccountId = TestCrossAccountId;228 type EvmAddressMapping = TestEvmAddressMapping;229 type EvmBackwardsAddressMapping = TestEvmBackwardsAddressMapping;230}231232impl pallet_structure::Config for Test {233 type WeightInfo = ();234 type Event = ();235 type Call = Call;236}237impl pallet_fungible::Config for Test {238 type WeightInfo = ();239}240impl pallet_refungible::Config for Test {241 type WeightInfo = ();242}243impl pallet_nonfungible::Config for Test {244 type WeightInfo = ();245}246247impl pallet_unique::Config for Test {248 type Event = ();249 type WeightInfo = ();250 type CommonWeightInfo = CommonWeights<Self>;251}252253// Build genesis storage according to the mock runtime.254pub fn new_test_ext() -> sp_io::TestExternalities {255 system::GenesisConfig::default()256 .build_storage::<Test>()257 .unwrap()258 .into()259}1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617#![allow(clippy::from_over_into)]1819use sp_core::{H256, U256};20use frame_support::{21 parameter_types,22 traits::{Everything, ConstU32, ConstU64},23 weights::IdentityFee,24};25use sp_runtime::{26 traits::{BlakeTwo256, IdentityLookup},27 testing::Header,28};29use pallet_transaction_payment::{CurrencyAdapter};30use frame_system as system;31use pallet_evm::{32 AddressMapping, account::CrossAccountId, EnsureAddressNever, SubstrateBlockHashMapping,33};34use fp_evm_mapping::EvmBackwardsAddressMapping;35use parity_scale_codec::{Encode, Decode, MaxEncodedLen};36use scale_info::TypeInfo;3738use unique_runtime_common::{dispatch::CollectionDispatchT, weights::CommonWeights};39use up_data_structs::mapping::{CrossTokenAddressMapping, EvmTokenAddressMapping};4041type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;42type Block = frame_system::mocking::MockBlock<Test>;4344#[cfg(test)]45mod tests;4647// Configure a mock runtime to test the pallet.48frame_support::construct_runtime!(49 pub enum Test where50 Block = Block,51 NodeBlock = Block,52 UncheckedExtrinsic = UncheckedExtrinsic,53 {54 System: frame_system::{Pallet, Call, Config, Storage, Event<T>},55 Unique: pallet_unique::{Pallet, Call, Storage},56 Balances: pallet_balances::{Pallet, Call, Storage},57 Common: pallet_common::{Pallet, Storage, Event<T>},58 Fungible: pallet_fungible::{Pallet, Storage},59 Refungible: pallet_refungible::{Pallet, Storage},60 Nonfungible: pallet_nonfungible::{Pallet, Storage},61 EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>},62 }63);6465parameter_types! {66 pub const BlockHashCount: u64 = 250;67 pub const SS58Prefix: u8 = 42;68}6970impl system::Config for Test {71 type BaseCallFilter = Everything;72 type BlockWeights = ();73 type BlockLength = ();74 type DbWeight = ();75 type Origin = Origin;76 type Call = Call;77 type Index = u64;78 type BlockNumber = u64;79 type Hash = H256;80 type Hashing = BlakeTwo256;81 type AccountId = u64;82 type Lookup = IdentityLookup<Self::AccountId>;83 type Header = Header;84 type Event = ();85 type BlockHashCount = BlockHashCount;86 type Version = ();87 type PalletInfo = PalletInfo;88 type AccountData = pallet_balances::AccountData<u64>;89 type OnNewAccount = ();90 type OnKilledAccount = ();91 type SystemWeightInfo = ();92 type SS58Prefix = SS58Prefix;93 type OnSetCode = ();94 type MaxConsumers = ConstU32<16>;95}9697parameter_types! {98 pub const ExistentialDeposit: u64 = 1;99 pub const MaxLocks: u32 = 50;100}101//frame_system::Module<Test>;102impl pallet_balances::Config for Test {103 type AccountStore = System;104 type Balance = u64;105 type DustRemoval = ();106 type Event = ();107 type ExistentialDeposit = ExistentialDeposit;108 type WeightInfo = ();109 type MaxLocks = MaxLocks;110 type MaxReserves = ();111 type ReserveIdentifier = [u8; 8];112}113114parameter_types! {115 pub const OperationalFeeMultiplier: u8 = 5;116}117118impl pallet_transaction_payment::Config for Test {119 type OnChargeTransaction = CurrencyAdapter<pallet_balances::Pallet<Test>, ()>;120 type LengthToFee = IdentityFee<u64>;121 type WeightToFee = IdentityFee<u64>;122 type FeeMultiplierUpdate = ();123 type OperationalFeeMultiplier = OperationalFeeMultiplier;124}125126parameter_types! {127 pub const MinimumPeriod: u64 = 1;128}129impl pallet_timestamp::Config for Test {130 type Moment = u64;131 type OnTimestampSet = ();132 type MinimumPeriod = MinimumPeriod;133 type WeightInfo = ();134}135136parameter_types! {137 pub const CollectionCreationPrice: u32 = 100;138 pub TreasuryAccountId: u64 = 1234;139 pub EthereumChainId: u32 = 1111;140}141142pub struct TestEvmAddressMapping;143impl AddressMapping<u64> for TestEvmAddressMapping {144 fn into_account_id(_addr: sp_core::H160) -> u64 {145 unimplemented!()146 }147}148149pub struct TestEvmBackwardsAddressMapping;150impl EvmBackwardsAddressMapping<u64> for TestEvmBackwardsAddressMapping {151 fn from_account_id(_account_id: u64) -> sp_core::H160 {152 unimplemented!()153 }154}155156#[derive(Encode, Decode, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, TypeInfo, MaxEncodedLen)]157pub struct TestCrossAccountId(u64, sp_core::H160);158impl CrossAccountId<u64> for TestCrossAccountId {159 fn as_sub(&self) -> &u64 {160 &self.0161 }162 fn as_eth(&self) -> &sp_core::H160 {163 &self.1164 }165 fn from_sub(sub: u64) -> Self {166 let mut eth = [0; 20];167 eth[12..20].copy_from_slice(&sub.to_be_bytes());168 Self(sub, sp_core::H160(eth))169 }170 fn from_eth(eth: sp_core::H160) -> Self {171 let mut sub_raw = [0; 8];172 sub_raw.copy_from_slice(ð.0[0..8]);173 let sub = u64::from_be_bytes(sub_raw);174 Self(sub, eth)175 }176 fn conv_eq(&self, other: &Self) -> bool {177 self.as_sub() == other.as_sub()178 }179}180181impl Default for TestCrossAccountId {182 fn default() -> Self {183 Self::from_sub(0)184 }185}186187parameter_types! {188 pub BlockGasLimit: U256 = 0u32.into();189}190191impl pallet_evm::Config for Test {192 type Event = ();193 type FeeCalculator = ();194 type GasWeightMapping = ();195 type CallOrigin = EnsureAddressNever<Self::CrossAccountId>;196 type WithdrawOrigin = EnsureAddressNever<Self::CrossAccountId>;197 type AddressMapping = TestEvmAddressMapping;198 type Currency = Balances;199 type PrecompilesType = ();200 type PrecompilesValue = ();201 type Runner = pallet_evm::runner::stack::Runner<Self>;202 type ChainId = ConstU64<0>;203 type BlockGasLimit = BlockGasLimit;204 type OnMethodCall = ();205 type OnCreate = ();206 type OnChargeTransaction = ();207 type FindAuthor = ();208 type BlockHashMapping = SubstrateBlockHashMapping<Self>;209 type TransactionValidityHack = ();210}211impl pallet_evm_coder_substrate::Config for Test {212 type GasWeightMapping = ();213}214215impl pallet_common::Config for Test {216 type WeightInfo = ();217 type Event = ();218 type Currency = Balances;219 type CollectionCreationPrice = CollectionCreationPrice;220 type TreasuryAccountId = TreasuryAccountId;221222 type CollectionDispatch = CollectionDispatchT<Self>;223 type EvmTokenAddressMapping = EvmTokenAddressMapping;224 type CrossTokenAddressMapping = CrossTokenAddressMapping<Self::AccountId>;225}226227impl pallet_evm::account::Config for Test {228 type CrossAccountId = TestCrossAccountId;229 type EvmAddressMapping = TestEvmAddressMapping;230 type EvmBackwardsAddressMapping = TestEvmBackwardsAddressMapping;231}232233impl pallet_structure::Config for Test {234 type WeightInfo = ();235 type Event = ();236 type Call = Call;237}238impl pallet_fungible::Config for Test {239 type WeightInfo = ();240}241impl pallet_refungible::Config for Test {242 type WeightInfo = ();243}244impl pallet_nonfungible::Config for Test {245 type WeightInfo = ();246}247248impl pallet_unique::Config for Test {249 type Event = ();250 type WeightInfo = ();251 type CommonWeightInfo = CommonWeights<Self>;252}253254// Build genesis storage according to the mock runtime.255pub fn new_test_ext() -> sp_io::TestExternalities {256 system::GenesisConfig::default()257 .build_storage::<Test>()258 .unwrap()259 .into()260}runtime/tests/src/tests.rsdiffbeforeafterboth--- a/runtime/tests/src/tests.rs
+++ b/runtime/tests/src/tests.rs
@@ -19,8 +19,9 @@
use up_data_structs::{
COLLECTION_NUMBER_LIMIT, CollectionId, CreateItemData, CreateFungibleData, CreateNftData,
CreateReFungibleData, MAX_DECIMAL_POINTS, COLLECTION_ADMINS_LIMIT, TokenId,
- MAX_TOKEN_OWNERSHIP, CreateCollectionData, CollectionField, SchemaVersion, CollectionMode,
- AccessMode,
+ MAX_TOKEN_OWNERSHIP, CreateCollectionData, CollectionMode,
+ AccessMode, CollectionPermissions, PropertyKeyPermission, PropertyPermission,
+ Property, CollectionPropertiesVec, CollectionPropertiesPermissionsVec,
};
use frame_support::{assert_noop, assert_ok, assert_err};
use sp_std::convert::TryInto;
@@ -46,8 +47,12 @@
fn default_nft_data() -> CreateNftData {
CreateNftData {
- const_data: vec![1, 2, 3].try_into().unwrap(),
- properties: vec![].try_into().unwrap(),
+ properties: vec![
+ Property {
+ key: b"test-prop".to_vec().try_into().unwrap(),
+ value: b"test-nft-prop".to_vec().try_into().unwrap(),
+ },
+ ].try_into().unwrap(),
}
}
@@ -72,12 +77,30 @@
let col_name1: Vec<u16> = "Test1\0".encode_utf16().collect::<Vec<u16>>();
let col_desc1: Vec<u16> = "TestDescription1\0".encode_utf16().collect::<Vec<u16>>();
let token_prefix1: Vec<u8> = b"token_prefix1\0".to_vec();
+ let token_property_permissions: CollectionPropertiesPermissionsVec = vec![
+ PropertyKeyPermission {
+ key: b"test-prop".to_vec().try_into().unwrap(),
+ permission: PropertyPermission {
+ mutable: true,
+ collection_admin: false,
+ token_owner: true,
+ },
+ },
+ ].try_into().unwrap();
+ let properties: CollectionPropertiesVec = vec![
+ Property {
+ key: b"test-collection-prop".to_vec().try_into().unwrap(),
+ value: b"test-collection-value".to_vec().try_into().unwrap(),
+ }
+ ].try_into().unwrap();
let data: CreateCollectionData<u64> = CreateCollectionData {
name: col_name1.try_into().unwrap(),
description: col_desc1.try_into().unwrap(),
token_prefix: token_prefix1.try_into().unwrap(),
mode: mode.clone(),
+ token_property_permissions: token_property_permissions.clone(),
+ properties: properties.clone(),
..Default::default()
};
@@ -113,9 +136,47 @@
.token_prefix,
saved_prefix
);
+ assert_eq!(
+ get_collection_property_permissions(id).as_slice(),
+ token_property_permissions.as_slice()
+ );
+ assert_eq!(
+ get_collection_properties(id).as_slice(),
+ properties.as_slice()
+ );
id
}
+fn get_collection_property_permissions(collection_id: CollectionId) -> Vec<PropertyKeyPermission> {
+ <pallet_common::Pallet<Test>>::property_permissions(collection_id)
+ .into_iter()
+ .map(|(key, permission)| PropertyKeyPermission {
+ key,
+ permission,
+ })
+ .collect()
+}
+
+fn get_collection_properties(collection_id: CollectionId) -> Vec<Property> {
+ <pallet_common::Pallet<Test>>::collection_properties(collection_id)
+ .into_iter()
+ .map(|(key, value)| Property {
+ key,
+ value,
+ })
+ .collect()
+}
+
+fn get_token_properties(collection_id: CollectionId, token_id: TokenId) -> Vec<Property> {
+ <pallet_nonfungible::Pallet<Test>>::token_properties((collection_id, token_id))
+ .into_iter()
+ .map(|(key, value)| Property {
+ key,
+ value,
+ })
+ .collect()
+}
+
fn create_test_collection(mode: &CollectionMode, id: CollectionId) -> CollectionId {
create_test_collection_for_owner(&mode, 1, id)
}
@@ -138,26 +199,6 @@
// #region
#[test]
-fn set_version_schema() {
- new_test_ext().execute_with(|| {
- let origin1 = Origin::signed(1);
- let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));
-
- assert_ok!(Unique::set_schema_version(
- origin1,
- collection_id,
- SchemaVersion::Unique
- ));
- assert_eq!(
- <pallet_common::CollectionById<Test>>::get(collection_id)
- .unwrap()
- .schema_version,
- SchemaVersion::Unique
- );
- });
-}
-
-#[test]
fn check_not_sufficient_founds() {
new_test_ext().execute_with(|| {
let acc: u64 = 1;
@@ -212,8 +253,10 @@
let data = default_nft_data();
create_test_item(collection_id, &data.clone().into());
- let item = <pallet_nonfungible::TokenData<Test>>::get((collection_id, 1)).unwrap();
- assert_eq!(item.const_data, data.const_data.into_inner());
+ assert_eq!(
+ get_token_properties(collection_id, TokenId(1)).as_slice(),
+ data.properties.as_slice(),
+ );
});
}
@@ -239,12 +282,10 @@
.collect()
));
for (index, data) in items_data.into_iter().enumerate() {
- let item = <pallet_nonfungible::TokenData<Test>>::get((
- CollectionId(1),
- TokenId((index + 1) as u32),
- ))
- .unwrap();
- assert_eq!(item.const_data.to_vec(), data.const_data.into_inner());
+ assert_eq!(
+ get_token_properties(CollectionId(1), TokenId(index as u32 + 1)).as_slice(),
+ data.properties.as_slice()
+ );
}
});
}
@@ -701,12 +742,6 @@
let data = default_nft_data();
create_test_item(collection_id, &data.clone().into());
assert_eq!(
- &<pallet_nonfungible::TokenData<Test>>::get((collection_id, TokenId(1)))
- .unwrap()
- .const_data,
- &data.const_data.into_inner()
- );
- assert_eq!(
<pallet_nonfungible::AccountBalance<Test>>::get((collection_id, account(1))),
1
);
@@ -716,15 +751,14 @@
);
// Allow allow-list users to mint and add accounts 1, 2, and 3 to allow-list
- assert_ok!(Unique::set_mint_permission(
- origin1.clone(),
- CollectionId(1),
- true
- ));
- assert_ok!(Unique::set_public_access_mode(
+ assert_ok!(Unique::set_collection_permissions(
origin1.clone(),
CollectionId(1),
- AccessMode::AllowList
+ CollectionPermissions {
+ mint_mode: Some(true),
+ access: Some(AccessMode::AllowList),
+ nesting: None,
+ }
));
assert_ok!(Unique::add_to_allow_list(
origin1.clone(),
@@ -796,15 +830,14 @@
);
// Allow public minting, enable allow-list and add accounts 1, 2, 3 to allow-list
- assert_ok!(Unique::set_mint_permission(
- origin1.clone(),
- CollectionId(1),
- true
- ));
- assert_ok!(Unique::set_public_access_mode(
+ assert_ok!(Unique::set_collection_permissions(
origin1.clone(),
CollectionId(1),
- AccessMode::AllowList
+ CollectionPermissions {
+ mint_mode: Some(true),
+ access: Some(AccessMode::AllowList),
+ nesting: None,
+ }
));
assert_ok!(Unique::add_to_allow_list(
origin1.clone(),
@@ -896,15 +929,14 @@
let origin1 = Origin::signed(1);
let origin2 = Origin::signed(2);
- assert_ok!(Unique::set_mint_permission(
- origin1.clone(),
- CollectionId(1),
- true
- ));
- assert_ok!(Unique::set_public_access_mode(
+ assert_ok!(Unique::set_collection_permissions(
origin1.clone(),
CollectionId(1),
- AccessMode::AllowList
+ CollectionPermissions {
+ mint_mode: Some(true),
+ access: Some(AccessMode::AllowList),
+ nesting: None,
+ }
));
assert_ok!(Unique::add_to_allow_list(
origin1.clone(),
@@ -1146,15 +1178,14 @@
let collection_id = create_test_collection(&CollectionMode::ReFungible, CollectionId(1));
let origin1 = Origin::signed(1);
- assert_ok!(Unique::set_mint_permission(
- origin1.clone(),
- collection_id,
- true
- ));
- assert_ok!(Unique::set_public_access_mode(
+ assert_ok!(Unique::set_collection_permissions(
origin1.clone(),
collection_id,
- AccessMode::AllowList
+ CollectionPermissions {
+ mint_mode: Some(true),
+ access: Some(AccessMode::AllowList),
+ nesting: None,
+ }
));
assert_ok!(Unique::add_to_allow_list(
origin1.clone(),
@@ -1392,15 +1423,14 @@
account(2)
);
- assert_ok!(Unique::set_mint_permission(
- origin1.clone(),
- CollectionId(1),
- true
- ));
- assert_ok!(Unique::set_public_access_mode(
+ assert_ok!(Unique::set_collection_permissions(
origin1.clone(),
CollectionId(1),
- AccessMode::AllowList
+ CollectionPermissions {
+ mint_mode: Some(true),
+ access: Some(AccessMode::AllowList),
+ nesting: None,
+ }
));
assert_ok!(Unique::add_to_allow_list(
origin1.clone(),
@@ -1722,10 +1752,14 @@
let data = default_nft_data();
create_test_item(collection_id, &data.into());
- assert_ok!(Unique::set_public_access_mode(
+ assert_ok!(Unique::set_collection_permissions(
origin1.clone(),
collection_id,
- AccessMode::AllowList
+ CollectionPermissions {
+ mint_mode: None,
+ access: Some(AccessMode::AllowList),
+ nesting: None,
+ }
));
assert_ok!(Unique::add_to_allow_list(
origin1.clone(),
@@ -1750,10 +1784,14 @@
let data = default_nft_data();
create_test_item(collection_id, &data.into());
- assert_ok!(Unique::set_public_access_mode(
+ assert_ok!(Unique::set_collection_permissions(
origin1.clone(),
collection_id,
- AccessMode::AllowList
+ CollectionPermissions {
+ mint_mode: None,
+ access: Some(AccessMode::AllowList),
+ nesting: None,
+ }
));
assert_ok!(Unique::add_to_allow_list(
origin1.clone(),
@@ -1811,10 +1849,14 @@
let data = default_nft_data();
create_test_item(collection_id, &data.into());
- assert_ok!(Unique::set_public_access_mode(
+ assert_ok!(Unique::set_collection_permissions(
origin1.clone(),
collection_id,
- AccessMode::AllowList
+ CollectionPermissions {
+ mint_mode: None,
+ access: Some(AccessMode::AllowList),
+ nesting: None,
+ }
));
assert_ok!(Unique::add_to_allow_list(
origin1.clone(),
@@ -1840,10 +1882,14 @@
let data = default_nft_data();
create_test_item(collection_id, &data.into());
- assert_ok!(Unique::set_public_access_mode(
+ assert_ok!(Unique::set_collection_permissions(
origin1.clone(),
collection_id,
- AccessMode::AllowList
+ CollectionPermissions {
+ mint_mode: None,
+ access: Some(AccessMode::AllowList),
+ nesting: None,
+ }
));
assert_ok!(Unique::add_to_allow_list(
origin1.clone(),
@@ -1901,10 +1947,14 @@
let data = default_nft_data();
create_test_item(collection_id, &data.into());
- assert_ok!(Unique::set_public_access_mode(
+ assert_ok!(Unique::set_collection_permissions(
origin1.clone(),
collection_id,
- AccessMode::AllowList
+ CollectionPermissions {
+ mint_mode: None,
+ access: Some(AccessMode::AllowList),
+ nesting: None,
+ }
));
assert_noop!(
Unique::burn_item(origin1.clone(), CollectionId(1), TokenId(1), 1).map_err(|e| e.error),
@@ -1924,10 +1974,14 @@
let data = default_nft_data();
create_test_item(collection_id, &data.into());
- assert_ok!(Unique::set_public_access_mode(
+ assert_ok!(Unique::set_collection_permissions(
origin1.clone(),
collection_id,
- AccessMode::AllowList
+ CollectionPermissions {
+ mint_mode: None,
+ access: Some(AccessMode::AllowList),
+ nesting: None,
+ }
));
// do approve
@@ -1951,10 +2005,14 @@
let origin1 = Origin::signed(1);
- assert_ok!(Unique::set_public_access_mode(
+ assert_ok!(Unique::set_collection_permissions(
origin1.clone(),
collection_id,
- AccessMode::AllowList
+ CollectionPermissions {
+ mint_mode: None,
+ access: Some(AccessMode::AllowList),
+ nesting: None,
+ }
));
assert_ok!(Unique::add_to_allow_list(
origin1.clone(),
@@ -1989,10 +2047,14 @@
let origin1 = Origin::signed(1);
// Toggle Allow List mode and add accounts 1 and 2
- assert_ok!(Unique::set_public_access_mode(
+ assert_ok!(Unique::set_collection_permissions(
origin1.clone(),
collection_id,
- AccessMode::AllowList
+ CollectionPermissions {
+ mint_mode: None,
+ access: Some(AccessMode::AllowList),
+ nesting: None,
+ }
));
assert_ok!(Unique::add_to_allow_list(
origin1.clone(),
@@ -2037,12 +2099,15 @@
let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));
let origin1 = Origin::signed(1);
- assert_ok!(Unique::set_public_access_mode(
+ assert_ok!(Unique::set_collection_permissions(
origin1.clone(),
collection_id,
- AccessMode::AllowList
+ CollectionPermissions {
+ mint_mode: Some(false),
+ access: Some(AccessMode::AllowList),
+ nesting: None,
+ }
));
- assert_ok!(Unique::set_mint_permission(origin1, collection_id, false));
let data = default_nft_data();
create_test_item(collection_id, &data.into());
@@ -2058,15 +2123,14 @@
let origin1 = Origin::signed(1);
let origin2 = Origin::signed(2);
- assert_ok!(Unique::set_public_access_mode(
+ assert_ok!(Unique::set_collection_permissions(
origin1.clone(),
collection_id,
- AccessMode::AllowList
- ));
- assert_ok!(Unique::set_mint_permission(
- origin1.clone(),
- collection_id,
- false
+ CollectionPermissions {
+ mint_mode: Some(false),
+ access: Some(AccessMode::AllowList),
+ nesting: None,
+ }
));
assert_ok!(Unique::add_collection_admin(
@@ -2093,15 +2157,14 @@
let origin1 = Origin::signed(1);
let origin2 = Origin::signed(2);
- assert_ok!(Unique::set_public_access_mode(
+ assert_ok!(Unique::set_collection_permissions(
origin1.clone(),
collection_id,
- AccessMode::AllowList
- ));
- assert_ok!(Unique::set_mint_permission(
- origin1.clone(),
- collection_id,
- false
+ CollectionPermissions {
+ mint_mode: Some(false),
+ access: Some(AccessMode::AllowList),
+ nesting: None,
+ }
));
assert_ok!(Unique::add_to_allow_list(
origin1,
@@ -2131,12 +2194,15 @@
let origin1 = Origin::signed(1);
let origin2 = Origin::signed(2);
- assert_ok!(Unique::set_public_access_mode(
+ assert_ok!(Unique::set_collection_permissions(
origin1.clone(),
collection_id,
- AccessMode::AllowList
+ CollectionPermissions {
+ mint_mode: Some(false),
+ access: Some(AccessMode::AllowList),
+ nesting: None,
+ }
));
- assert_ok!(Unique::set_mint_permission(origin1, collection_id, false));
assert_noop!(
Unique::create_item(
@@ -2159,12 +2225,15 @@
let origin1 = Origin::signed(1);
- assert_ok!(Unique::set_public_access_mode(
+ assert_ok!(Unique::set_collection_permissions(
origin1.clone(),
collection_id,
- AccessMode::AllowList
+ CollectionPermissions {
+ mint_mode: Some(true),
+ access: Some(AccessMode::AllowList),
+ nesting: None,
+ }
));
- assert_ok!(Unique::set_mint_permission(origin1, collection_id, true));
let data = default_nft_data();
create_test_item(collection_id, &data.into());
@@ -2180,15 +2249,14 @@
let origin1 = Origin::signed(1);
let origin2 = Origin::signed(2);
- assert_ok!(Unique::set_public_access_mode(
- origin1.clone(),
- collection_id,
- AccessMode::AllowList
- ));
- assert_ok!(Unique::set_mint_permission(
+ assert_ok!(Unique::set_collection_permissions(
origin1.clone(),
collection_id,
- true
+ CollectionPermissions {
+ mint_mode: Some(true),
+ access: Some(AccessMode::AllowList),
+ nesting: None,
+ }
));
assert_ok!(Unique::add_collection_admin(
@@ -2215,12 +2283,15 @@
let origin1 = Origin::signed(1);
let origin2 = Origin::signed(2);
- assert_ok!(Unique::set_public_access_mode(
+ assert_ok!(Unique::set_collection_permissions(
origin1.clone(),
collection_id,
- AccessMode::AllowList
+ CollectionPermissions {
+ mint_mode: Some(true),
+ access: Some(AccessMode::AllowList),
+ nesting: None,
+ }
));
- assert_ok!(Unique::set_mint_permission(origin1, collection_id, true));
assert_noop!(
Unique::create_item(
@@ -2244,15 +2315,14 @@
let origin1 = Origin::signed(1);
let origin2 = Origin::signed(2);
- assert_ok!(Unique::set_public_access_mode(
+ assert_ok!(Unique::set_collection_permissions(
origin1.clone(),
collection_id,
- AccessMode::AllowList
- ));
- assert_ok!(Unique::set_mint_permission(
- origin1.clone(),
- collection_id,
- true
+ CollectionPermissions {
+ mint_mode: Some(true),
+ access: Some(AccessMode::AllowList),
+ nesting: None,
+ }
));
assert_ok!(Unique::add_to_allow_list(
origin1,
@@ -2528,20 +2598,19 @@
)
.is_err());
- assert_ok!(Unique::set_public_access_mode(
+ assert_ok!(Unique::set_collection_permissions(
origin1.clone(),
collection_id,
- AccessMode::AllowList
+ CollectionPermissions {
+ mint_mode: Some(true),
+ access: Some(AccessMode::AllowList),
+ nesting: None,
+ }
));
assert_ok!(Unique::add_to_allow_list(
origin1.clone(),
collection_id,
account2.clone()
- ));
- assert_ok!(Unique::set_mint_permission(
- origin1.clone(),
- collection_id,
- true
));
assert_ok!(Unique::create_item(