difftreelog
Whitelist to allowlist renamed
in: master
9 files changed
pallets/fungible/src/lib.rsdiffbeforeafterboth--- a/pallets/fungible/src/lib.rs
+++ b/pallets/fungible/src/lib.rs
@@ -123,7 +123,7 @@
.checked_sub(amount)
.ok_or(<CommonError<T>>::TokenValueTooLow)?;
- if collection.access == AccessMode::WhiteList {
+ if collection.access == AccessMode::AllowList {
collection.check_allowlist(owner)?;
}
@@ -161,7 +161,7 @@
<CommonError<T>>::TransferNotAllowed
);
- if collection.access == AccessMode::WhiteList {
+ if collection.access == AccessMode::AllowList {
collection.check_allowlist(from)?;
collection.check_allowlist(to)?;
}
@@ -305,7 +305,7 @@
spender: &T::CrossAccountId,
amount: u128,
) -> DispatchResult {
- if collection.access == AccessMode::WhiteList {
+ if collection.access == AccessMode::AllowList {
collection.check_allowlist(&owner)?;
collection.check_allowlist(&spender)?;
}
@@ -333,7 +333,7 @@
if spender == from {
return Self::transfer(collection, from, to, amount);
}
- if collection.access == AccessMode::WhiteList {
+ if collection.access == AccessMode::AllowList {
// `from`, `to` checked in [`transfer`]
collection.check_allowlist(spender)?;
}
@@ -365,7 +365,7 @@
if spender == from {
return Self::burn(collection, from, amount);
}
- if collection.access == AccessMode::WhiteList {
+ if collection.access == AccessMode::AllowList {
// `from` checked in [`burn`]
collection.check_allowlist(spender)?;
}
pallets/nft/src/benchmarking.rsdiffbeforeafterboth--- a/pallets/nft/src/benchmarking.rs
+++ b/pallets/nft/src/benchmarking.rs
@@ -55,23 +55,23 @@
let collection = create_nft_collection::<T>(caller.clone())?;
}: _(RawOrigin::Signed(caller.clone()), collection)
- add_to_white_list {
+ add_to_allow_list {
let caller: T::AccountId = account("caller", 0, SEED);
let whitelist_account: T::AccountId = account("admin", 0, SEED);
let collection = create_nft_collection::<T>(caller.clone())?;
}: _(RawOrigin::Signed(caller.clone()), collection, T::CrossAccountId::from_sub(whitelist_account))
- remove_from_white_list {
+ remove_from_allow_list {
let caller: T::AccountId = account("caller", 0, SEED);
let whitelist_account: T::AccountId = account("admin", 0, SEED);
let collection = create_nft_collection::<T>(caller.clone())?;
- <Pallet<T>>::add_to_white_list(RawOrigin::Signed(caller.clone()).into(), collection, T::CrossAccountId::from_sub(whitelist_account.clone()))?;
+ <Pallet<T>>::add_to_allow_list(RawOrigin::Signed(caller.clone()).into(), collection, T::CrossAccountId::from_sub(whitelist_account.clone()))?;
}: _(RawOrigin::Signed(caller.clone()), collection, T::CrossAccountId::from_sub(whitelist_account))
set_public_access_mode {
let caller: T::AccountId = account("caller", 0, SEED);
let collection = create_nft_collection::<T>(caller.clone())?;
- }: _(RawOrigin::Signed(caller.clone()), collection, AccessMode::WhiteList)
+ }: _(RawOrigin::Signed(caller.clone()), collection, AccessMode::AllowList)
set_mint_permission {
let caller: T::AccountId = account("caller", 0, SEED);
pallets/nft/src/lib.rsdiffbeforeafterboth--- a/pallets/nft/src/lib.rs
+++ b/pallets/nft/src/lib.rs
@@ -274,9 +274,9 @@
/// * collection_id.
///
/// * address.
- #[weight = <SelfWeightOf<T>>::add_to_white_list()]
+ #[weight = <SelfWeightOf<T>>::add_to_allow_list()]
#[transactional]
- pub fn add_to_white_list(origin, collection_id: CollectionId, address: T::CrossAccountId) -> DispatchResult{
+ pub fn add_to_allow_list(origin, collection_id: CollectionId, address: T::CrossAccountId) -> DispatchResult{
let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
let collection = <CollectionHandle<T>>::try_get(collection_id)?;
@@ -303,9 +303,9 @@
/// * collection_id.
///
/// * address.
- #[weight = <SelfWeightOf<T>>::remove_from_white_list()]
+ #[weight = <SelfWeightOf<T>>::remove_from_allow_list()]
#[transactional]
- pub fn remove_from_white_list(origin, collection_id: CollectionId, address: T::CrossAccountId) -> DispatchResult{
+ pub fn remove_from_allow_list(origin, collection_id: CollectionId, address: T::CrossAccountId) -> DispatchResult{
let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
let collection = <CollectionHandle<T>>::try_get(collection_id)?;
pallets/nft/src/tests.rsdiffbeforeafterboth--- a/pallets/nft/src/tests.rs
+++ b/pallets/nft/src/tests.rs
@@ -485,19 +485,19 @@
assert_ok!(TemplateModule::set_public_access_mode(
origin1.clone(),
1,
- AccessMode::WhiteList
+ AccessMode::AllowList
));
- assert_ok!(TemplateModule::add_to_white_list(
+ assert_ok!(TemplateModule::add_to_allow_list(
origin1.clone(),
1,
account(1)
));
- assert_ok!(TemplateModule::add_to_white_list(
+ assert_ok!(TemplateModule::add_to_allow_list(
origin1.clone(),
1,
account(2)
));
- assert_ok!(TemplateModule::add_to_white_list(
+ assert_ok!(TemplateModule::add_to_allow_list(
origin1.clone(),
1,
account(3)
@@ -549,19 +549,19 @@
assert_ok!(TemplateModule::set_public_access_mode(
origin1.clone(),
1,
- AccessMode::WhiteList
+ AccessMode::AllowList
));
- assert_ok!(TemplateModule::add_to_white_list(
+ assert_ok!(TemplateModule::add_to_allow_list(
origin1.clone(),
1,
account(1)
));
- assert_ok!(TemplateModule::add_to_white_list(
+ assert_ok!(TemplateModule::add_to_allow_list(
origin1.clone(),
1,
account(2)
));
- assert_ok!(TemplateModule::add_to_white_list(
+ assert_ok!(TemplateModule::add_to_allow_list(
origin1.clone(),
1,
account(3)
@@ -609,19 +609,19 @@
assert_ok!(TemplateModule::set_public_access_mode(
origin1.clone(),
1,
- AccessMode::WhiteList
+ AccessMode::AllowList
));
- assert_ok!(TemplateModule::add_to_white_list(
+ assert_ok!(TemplateModule::add_to_allow_list(
origin1.clone(),
1,
account(1)
));
- assert_ok!(TemplateModule::add_to_white_list(
+ assert_ok!(TemplateModule::add_to_allow_list(
origin1.clone(),
1,
account(2)
));
- assert_ok!(TemplateModule::add_to_white_list(
+ assert_ok!(TemplateModule::add_to_allow_list(
origin1.clone(),
1,
account(3)
@@ -765,9 +765,9 @@
assert_ok!(TemplateModule::set_public_access_mode(
origin1.clone(),
collection_id,
- AccessMode::WhiteList
+ AccessMode::AllowList
));
- assert_ok!(TemplateModule::add_to_white_list(
+ assert_ok!(TemplateModule::add_to_allow_list(
origin1.clone(),
1,
account(1)
@@ -952,19 +952,19 @@
assert_ok!(TemplateModule::set_public_access_mode(
origin1.clone(),
1,
- AccessMode::WhiteList
+ AccessMode::AllowList
));
- assert_ok!(TemplateModule::add_to_white_list(
+ assert_ok!(TemplateModule::add_to_allow_list(
origin1.clone(),
1,
account(1)
));
- assert_ok!(TemplateModule::add_to_white_list(
+ assert_ok!(TemplateModule::add_to_allow_list(
origin1.clone(),
1,
account(2)
));
- assert_ok!(TemplateModule::add_to_white_list(origin1, 1, account(3)));
+ assert_ok!(TemplateModule::add_to_allow_list(origin1, 1, account(3)));
assert_ok!(TemplateModule::transfer_from(
origin2,
@@ -992,7 +992,7 @@
let collection_id = create_test_collection(&CollectionMode::NFT, 1);
let origin1 = Origin::signed(1);
- assert_ok!(TemplateModule::add_to_white_list(
+ assert_ok!(TemplateModule::add_to_allow_list(
origin1,
collection_id,
account(2)
@@ -1013,7 +1013,7 @@
collection_id,
account(2)
));
- assert_ok!(TemplateModule::add_to_white_list(
+ assert_ok!(TemplateModule::add_to_allow_list(
origin2,
collection_id,
account(3)
@@ -1029,7 +1029,7 @@
let origin2 = Origin::signed(2);
assert_noop!(
- TemplateModule::add_to_white_list(origin2, collection_id, account(3)),
+ TemplateModule::add_to_allow_list(origin2, collection_id, account(3)),
Error::<Test>::NoPermission
);
});
@@ -1041,7 +1041,7 @@
let origin1 = Origin::signed(1);
assert_noop!(
- TemplateModule::add_to_white_list(origin1, 1, account(2)),
+ TemplateModule::add_to_allow_list(origin1, 1, account(2)),
Error::<Test>::CollectionNotFound
);
});
@@ -1058,7 +1058,7 @@
collection_id
));
assert_noop!(
- TemplateModule::add_to_white_list(origin1, collection_id, account(2)),
+ TemplateModule::add_to_allow_list(origin1, collection_id, account(2)),
Error::<Test>::CollectionNotFound
);
});
@@ -1071,12 +1071,12 @@
let collection_id = create_test_collection(&CollectionMode::NFT, 1);
let origin1 = Origin::signed(1);
- assert_ok!(TemplateModule::add_to_white_list(
+ assert_ok!(TemplateModule::add_to_allow_list(
origin1.clone(),
collection_id,
account(2)
));
- assert_ok!(TemplateModule::add_to_white_list(
+ assert_ok!(TemplateModule::add_to_allow_list(
origin1,
collection_id,
account(2)
@@ -1091,12 +1091,12 @@
let collection_id = create_test_collection(&CollectionMode::NFT, 1);
let origin1 = Origin::signed(1);
- assert_ok!(TemplateModule::add_to_white_list(
+ assert_ok!(TemplateModule::add_to_allow_list(
origin1.clone(),
collection_id,
account(2)
));
- assert_ok!(TemplateModule::remove_from_white_list(
+ assert_ok!(TemplateModule::remove_from_allow_list(
origin1,
collection_id,
account(2)
@@ -1118,12 +1118,12 @@
account(2)
));
- assert_ok!(TemplateModule::add_to_white_list(
+ assert_ok!(TemplateModule::add_to_allow_list(
origin1,
collection_id,
account(3)
));
- assert_ok!(TemplateModule::remove_from_white_list(
+ assert_ok!(TemplateModule::remove_from_allow_list(
origin2,
collection_id,
account(3)
@@ -1139,13 +1139,13 @@
let origin1 = Origin::signed(1);
let origin2 = Origin::signed(2);
- assert_ok!(TemplateModule::add_to_white_list(
+ assert_ok!(TemplateModule::add_to_allow_list(
origin1,
collection_id,
account(2)
));
assert_noop!(
- TemplateModule::remove_from_white_list(origin2, collection_id, account(2)),
+ TemplateModule::remove_from_allow_list(origin2, collection_id, account(2)),
Error::<Test>::NoPermission
);
assert!(TemplateModule::white_list(collection_id, 2));
@@ -1158,7 +1158,7 @@
let origin1 = Origin::signed(1);
assert_noop!(
- TemplateModule::remove_from_white_list(origin1, 1, account(2)),
+ TemplateModule::remove_from_allow_list(origin1, 1, account(2)),
Error::<Test>::CollectionNotFound
);
});
@@ -1171,14 +1171,14 @@
let origin1 = Origin::signed(1);
let origin2 = Origin::signed(2);
- assert_ok!(TemplateModule::add_to_white_list(
+ assert_ok!(TemplateModule::add_to_allow_list(
origin1.clone(),
collection_id,
account(2)
));
assert_ok!(TemplateModule::destroy_collection(origin1, collection_id));
assert_noop!(
- TemplateModule::remove_from_white_list(origin2, collection_id, account(2)),
+ TemplateModule::remove_from_allow_list(origin2, collection_id, account(2)),
Error::<Test>::CollectionNotFound
);
assert!(!TemplateModule::white_list(collection_id, 2));
@@ -1192,17 +1192,17 @@
let collection_id = create_test_collection(&CollectionMode::NFT, 1);
let origin1 = Origin::signed(1);
- assert_ok!(TemplateModule::add_to_white_list(
+ assert_ok!(TemplateModule::add_to_allow_list(
origin1.clone(),
collection_id,
account(2)
));
- assert_ok!(TemplateModule::remove_from_white_list(
+ assert_ok!(TemplateModule::remove_from_allow_list(
origin1.clone(),
collection_id,
account(2)
));
- assert_ok!(TemplateModule::remove_from_white_list(
+ assert_ok!(TemplateModule::remove_from_allow_list(
origin1,
collection_id,
account(2)
@@ -1225,9 +1225,9 @@
assert_ok!(TemplateModule::set_public_access_mode(
origin1.clone(),
collection_id,
- AccessMode::WhiteList
+ AccessMode::AllowList
));
- assert_ok!(TemplateModule::add_to_white_list(
+ assert_ok!(TemplateModule::add_to_allow_list(
origin1.clone(),
collection_id,
account(2)
@@ -1252,14 +1252,14 @@
assert_ok!(TemplateModule::set_public_access_mode(
origin1.clone(),
collection_id,
- AccessMode::WhiteList
+ AccessMode::AllowList
));
- assert_ok!(TemplateModule::add_to_white_list(
+ assert_ok!(TemplateModule::add_to_allow_list(
origin1.clone(),
1,
account(1)
));
- assert_ok!(TemplateModule::add_to_white_list(
+ assert_ok!(TemplateModule::add_to_allow_list(
origin1.clone(),
1,
account(2)
@@ -1275,7 +1275,7 @@
));
assert_eq!(TemplateModule::approved(1, (1, 1, 1)), 1);
- assert_ok!(TemplateModule::remove_from_white_list(
+ assert_ok!(TemplateModule::remove_from_allow_list(
origin1.clone(),
1,
account(1)
@@ -1302,9 +1302,9 @@
assert_ok!(TemplateModule::set_public_access_mode(
origin1.clone(),
collection_id,
- AccessMode::WhiteList
+ AccessMode::AllowList
));
- assert_ok!(TemplateModule::add_to_white_list(
+ assert_ok!(TemplateModule::add_to_allow_list(
origin1.clone(),
1,
account(1)
@@ -1330,14 +1330,14 @@
assert_ok!(TemplateModule::set_public_access_mode(
origin1.clone(),
collection_id,
- AccessMode::WhiteList
+ AccessMode::AllowList
));
- assert_ok!(TemplateModule::add_to_white_list(
+ assert_ok!(TemplateModule::add_to_allow_list(
origin1.clone(),
collection_id,
account(1)
));
- assert_ok!(TemplateModule::add_to_white_list(
+ assert_ok!(TemplateModule::add_to_allow_list(
origin1.clone(),
collection_id,
account(2)
@@ -1353,7 +1353,7 @@
));
assert_eq!(TemplateModule::approved(1, (1, 1, 1)), 1);
- assert_ok!(TemplateModule::remove_from_white_list(
+ assert_ok!(TemplateModule::remove_from_allow_list(
origin1.clone(),
collection_id,
account(2)
@@ -1380,7 +1380,7 @@
assert_ok!(TemplateModule::set_public_access_mode(
origin1.clone(),
collection_id,
- AccessMode::WhiteList
+ AccessMode::AllowList
));
assert_noop!(
TemplateModule::burn_item(origin1.clone(), 1, 1, 5),
@@ -1403,7 +1403,7 @@
assert_ok!(TemplateModule::set_public_access_mode(
origin1.clone(),
collection_id,
- AccessMode::WhiteList
+ AccessMode::AllowList
));
// do approve
@@ -1429,14 +1429,14 @@
assert_ok!(TemplateModule::set_public_access_mode(
origin1.clone(),
collection_id,
- AccessMode::WhiteList
+ AccessMode::AllowList
));
- assert_ok!(TemplateModule::add_to_white_list(
+ assert_ok!(TemplateModule::add_to_allow_list(
origin1.clone(),
collection_id,
account(1)
));
- assert_ok!(TemplateModule::add_to_white_list(
+ assert_ok!(TemplateModule::add_to_allow_list(
origin1.clone(),
collection_id,
account(2)
@@ -1459,14 +1459,14 @@
assert_ok!(TemplateModule::set_public_access_mode(
origin1.clone(),
collection_id,
- AccessMode::WhiteList
+ AccessMode::AllowList
));
- assert_ok!(TemplateModule::add_to_white_list(
+ assert_ok!(TemplateModule::add_to_allow_list(
origin1.clone(),
collection_id,
account(1)
));
- assert_ok!(TemplateModule::add_to_white_list(
+ assert_ok!(TemplateModule::add_to_allow_list(
origin1.clone(),
collection_id,
account(2)
@@ -1503,7 +1503,7 @@
assert_ok!(TemplateModule::set_public_access_mode(
origin1.clone(),
collection_id,
- AccessMode::WhiteList
+ AccessMode::AllowList
));
assert_ok!(TemplateModule::set_mint_permission(
origin1,
@@ -1528,7 +1528,7 @@
assert_ok!(TemplateModule::set_public_access_mode(
origin1.clone(),
collection_id,
- AccessMode::WhiteList
+ AccessMode::AllowList
));
assert_ok!(TemplateModule::set_mint_permission(
origin1.clone(),
@@ -1563,14 +1563,14 @@
assert_ok!(TemplateModule::set_public_access_mode(
origin1.clone(),
collection_id,
- AccessMode::WhiteList
+ AccessMode::AllowList
));
assert_ok!(TemplateModule::set_mint_permission(
origin1.clone(),
collection_id,
false
));
- assert_ok!(TemplateModule::add_to_white_list(
+ assert_ok!(TemplateModule::add_to_allow_list(
origin1,
collection_id,
account(2)
@@ -1595,7 +1595,7 @@
assert_ok!(TemplateModule::set_public_access_mode(
origin1.clone(),
collection_id,
- AccessMode::WhiteList
+ AccessMode::AllowList
));
assert_ok!(TemplateModule::set_mint_permission(
origin1,
@@ -1621,7 +1621,7 @@
assert_ok!(TemplateModule::set_public_access_mode(
origin1.clone(),
collection_id,
- AccessMode::WhiteList
+ AccessMode::AllowList
));
assert_ok!(TemplateModule::set_mint_permission(
origin1,
@@ -1646,7 +1646,7 @@
assert_ok!(TemplateModule::set_public_access_mode(
origin1.clone(),
collection_id,
- AccessMode::WhiteList
+ AccessMode::AllowList
));
assert_ok!(TemplateModule::set_mint_permission(
origin1.clone(),
@@ -1681,7 +1681,7 @@
assert_ok!(TemplateModule::set_public_access_mode(
origin1.clone(),
collection_id,
- AccessMode::WhiteList
+ AccessMode::AllowList
));
assert_ok!(TemplateModule::set_mint_permission(
origin1,
@@ -1708,14 +1708,14 @@
assert_ok!(TemplateModule::set_public_access_mode(
origin1.clone(),
collection_id,
- AccessMode::WhiteList
+ AccessMode::AllowList
));
assert_ok!(TemplateModule::set_mint_permission(
origin1.clone(),
collection_id,
true
));
- assert_ok!(TemplateModule::add_to_white_list(
+ assert_ok!(TemplateModule::add_to_allow_list(
origin1,
collection_id,
account(2)
@@ -2056,7 +2056,7 @@
collection_id,
true
));
- assert_ok!(TemplateModule::add_to_white_list(
+ assert_ok!(TemplateModule::add_to_allow_list(
origin1.clone(),
collection_id,
account(1)
@@ -2124,7 +2124,7 @@
collection_id,
true
));
- assert_ok!(TemplateModule::add_to_white_list(
+ assert_ok!(TemplateModule::add_to_allow_list(
origin2.clone(),
collection_id,
account(1)
@@ -2177,7 +2177,7 @@
collection_id,
true
));
- assert_ok!(TemplateModule::add_to_white_list(
+ assert_ok!(TemplateModule::add_to_allow_list(
origin2.clone(),
collection_id,
account(1)
pallets/nft/src/weights.rsdiffbeforeafterboth--- a/pallets/nft/src/weights.rs
+++ b/pallets/nft/src/weights.rs
@@ -33,8 +33,8 @@
pub trait WeightInfo {
fn create_collection() -> Weight;
fn destroy_collection() -> Weight;
- fn add_to_white_list() -> Weight;
- fn remove_from_white_list() -> Weight;
+ fn add_to_allow_list() -> Weight;
+ fn remove_from_allow_list() -> Weight;
fn set_public_access_mode() -> Weight;
fn set_mint_permission() -> Weight;
fn change_collection_owner() -> Weight;
@@ -75,14 +75,14 @@
}
// Storage: Common CollectionById (r:1 w:0)
// Storage: Common Allowlist (r:0 w:1)
- fn add_to_white_list() -> Weight {
+ fn add_to_allow_list() -> Weight {
(6_629_000 as Weight)
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
// Storage: Common CollectionById (r:1 w:0)
// Storage: Common Allowlist (r:0 w:1)
- fn remove_from_white_list() -> Weight {
+ fn remove_from_allow_list() -> Weight {
(6_596_000 as Weight)
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
@@ -205,14 +205,14 @@
}
// Storage: Common CollectionById (r:1 w:0)
// Storage: Common Allowlist (r:0 w:1)
- fn add_to_white_list() -> Weight {
+ fn add_to_allow_list() -> Weight {
(6_629_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(1 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
}
// Storage: Common CollectionById (r:1 w:0)
// Storage: Common Allowlist (r:0 w:1)
- fn remove_from_white_list() -> Weight {
+ fn remove_from_allow_list() -> Weight {
(6_596_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(1 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
pallets/nonfungible/src/lib.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/lib.rs
+++ b/pallets/nonfungible/src/lib.rs
@@ -169,7 +169,7 @@
<CommonError<T>>::NoPermission
);
- if collection.access == AccessMode::WhiteList {
+ if collection.access == AccessMode::AllowList {
collection.check_allowlist(sender)?;
}
@@ -227,7 +227,7 @@
<CommonError<T>>::NoPermission
);
- if collection.access == AccessMode::WhiteList {
+ if collection.access == AccessMode::AllowList {
collection.check_allowlist(from)?;
collection.check_allowlist(to)?;
}
@@ -445,7 +445,7 @@
token: TokenId,
spender: Option<&T::CrossAccountId>,
) -> DispatchResult {
- if collection.access == AccessMode::WhiteList {
+ if collection.access == AccessMode::AllowList {
collection.check_allowlist(&sender)?;
if let Some(spender) = spender {
collection.check_allowlist(&spender)?;
@@ -480,7 +480,7 @@
if spender == from {
return Self::transfer(collection, from, to, token);
}
- if collection.access == AccessMode::WhiteList {
+ if collection.access == AccessMode::AllowList {
// `from`, `to` checked in [`transfer`]
collection.check_allowlist(spender)?;
}
@@ -508,7 +508,7 @@
if spender == from {
return Self::burn(collection, from, token);
}
- if collection.access == AccessMode::WhiteList {
+ if collection.access == AccessMode::AllowList {
// `from` checked in [`burn`]
collection.check_allowlist(spender)?;
}
pallets/refungible/src/lib.rsdiffbeforeafterboth--- a/pallets/refungible/src/lib.rs
+++ b/pallets/refungible/src/lib.rs
@@ -272,7 +272,7 @@
<CommonError<T>>::TransferNotAllowed
);
- if collection.access == AccessMode::WhiteList {
+ if collection.access == AccessMode::AllowList {
collection.check_allowlist(from)?;
collection.check_allowlist(to)?;
}
@@ -483,7 +483,7 @@
token: TokenId,
amount: u128,
) -> DispatchResult {
- if collection.access == AccessMode::WhiteList {
+ if collection.access == AccessMode::AllowList {
collection.check_allowlist(&sender)?;
collection.check_allowlist(&spender)?;
}
@@ -514,7 +514,7 @@
if spender == from {
return Self::transfer(collection, from, to, token, amount);
}
- if collection.access == AccessMode::WhiteList {
+ if collection.access == AccessMode::AllowList {
// `from`, `to` checked in [`transfer`]
collection.check_allowlist(spender)?;
}
@@ -547,7 +547,7 @@
if spender == from {
return Self::burn(collection, from, token, amount);
}
- if collection.access == AccessMode::WhiteList {
+ if collection.access == AccessMode::AllowList {
// `from` checked in [`burn`]
collection.check_allowlist(spender)?;
}
primitives/nft/src/lib.rsdiffbeforeafterboth--- a/primitives/nft/src/lib.rs
+++ b/primitives/nft/src/lib.rs
@@ -141,7 +141,7 @@
#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
pub enum AccessMode {
Normal,
- WhiteList,
+ AllowList,
}
impl Default for AccessMode {
fn default() -> Self {
runtime/src/chain_extension.rsdiffbeforeafterboth1//! NFT Chain Extension23//4// This file is subject to the terms and conditions defined in5// file 'LICENSE', which is part of this source code package.6//78use codec::{Decode, Encode};9use max_encoded_len::MaxEncodedLen;10use derivative::Derivative;1112pub use pallet_contracts::chain_extension::RetVal;13use pallet_contracts::chain_extension::{14 ChainExtension, Environment, Ext, InitState, SysConfig, UncheckedFrom,15};1617pub use frame_support::debug;18use frame_support::dispatch::DispatchError;1920extern crate pallet_nft;21pub use pallet_nft::*;22use pallet_nft::CrossAccountId;23use nft_data_structs::*;2425/// Create item parameters26#[derive(Debug, PartialEq, Encode, Decode, MaxEncodedLen)]27pub struct NFTExtCreateItem<AccountId> {28 pub owner: AccountId,29 pub collection_id: u32,30 pub data: CreateItemData,31}3233/// Transfer parameters34#[derive(Debug, PartialEq, Encode, Decode, MaxEncodedLen)]35pub struct NFTExtTransfer<AccountId> {36 pub recipient: AccountId,37 pub collection_id: u32,38 pub token_id: u32,39 pub amount: u128,40}4142#[derive(Derivative, PartialEq, Encode, Decode, MaxEncodedLen)]43#[derivative(Debug)]44pub struct NFTExtCreateMultipleItems<AccountId> {45 pub owner: AccountId,46 pub collection_id: u32,47 #[derivative(Debug = "ignore")]48 pub data: BoundedVec<CreateItemData, MaxItemsPerBatch>,49}5051#[derive(Debug, PartialEq, Encode, Decode, MaxEncodedLen)]52pub struct NFTExtApprove<AccountId> {53 pub spender: AccountId,54 pub collection_id: u32,55 pub item_id: u32,56 pub amount: u128,57}5859#[derive(Debug, PartialEq, Encode, Decode, MaxEncodedLen)]60pub struct NFTExtTransferFrom<AccountId> {61 pub owner: AccountId,62 pub recipient: AccountId,63 pub collection_id: u32,64 pub item_id: u32,65 pub amount: u128,66}6768#[derive(Derivative, PartialEq, Encode, Decode, MaxEncodedLen)]69#[derivative(Debug)]70pub struct NFTExtSetVariableMetaData {71 pub collection_id: u32,72 pub item_id: u32,73 #[derivative(Debug = "ignore")]74 pub data: BoundedVec<u8, MaxDataSize>,75}7677#[derive(Debug, PartialEq, Encode, Decode, MaxEncodedLen)]78pub struct NFTExtToggleWhiteList<AccountId> {79 pub collection_id: u32,80 pub address: AccountId,81 pub whitelisted: bool,82}8384/// The chain Extension of NFT pallet85pub struct NFTExtension;8687pub type NftWeightInfoOf<C> = <C as pallet_nft::Config>::WeightInfo;8889pub type AccountIdOf<C> = <C as SysConfig>::AccountId;9091impl<C: Config + pallet_contracts::Config> ChainExtension<C> for NFTExtension {92 fn call<E: Ext>(func_id: u32, env: Environment<E, InitState>) -> Result<RetVal, DispatchError>93 where94 E: Ext<T = C>,95 C: pallet_nft::Config,96 <E::T as SysConfig>::AccountId: UncheckedFrom<<E::T as SysConfig>::Hash> + AsRef<[u8]>,97 {98 // The memory of the vm stores buf in scale-codec99 match func_id {100 0 => {101 let mut env = env.buf_in_buf_out();102 let input: NFTExtTransfer<AccountIdOf<C>> = env.read_as()?;103 env.charge_weight(NftWeightInfoOf::<C>::transfer())?;104105 let collection = pallet_nft::Module::<C>::get_collection(input.collection_id)?;106107 pallet_nft::Module::<C>::transfer_internal(108 &C::CrossAccountId::from_sub(env.ext().address().clone()),109 &C::CrossAccountId::from_sub(input.recipient),110 &collection,111 input.token_id,112 input.amount,113 )?;114115 collection.submit_logs()?;116 Ok(RetVal::Converging(0))117 }118 1 => {119 // Create Item120 let mut env = env.buf_in_buf_out();121 let input: NFTExtCreateItem<AccountIdOf<C>> = env.read_as()?;122 env.charge_weight(NftWeightInfoOf::<C>::create_item(input.data.data_size()))?;123124 let collection = pallet_nft::Module::<C>::get_collection(input.collection_id)?;125126 pallet_nft::Module::<C>::create_item_internal(127 &C::CrossAccountId::from_sub(env.ext().address().clone()),128 &collection,129 &C::CrossAccountId::from_sub(input.owner),130 input.data,131 )?;132133 collection.submit_logs()?;134 Ok(RetVal::Converging(0))135 }136 2 => {137 // Create multiple items138 let mut env = env.buf_in_buf_out();139 let input: NFTExtCreateMultipleItems<AccountIdOf<C>> = env.read_as()?;140 env.charge_weight(NftWeightInfoOf::<C>::create_item(141 input.data.iter().map(|i| i.data_size()).sum(),142 ))?;143144 let collection = pallet_nft::Module::<C>::get_collection(input.collection_id)?;145146 pallet_nft::Module::<C>::create_multiple_items_internal(147 &C::CrossAccountId::from_sub(env.ext().address().clone()),148 &collection,149 &C::CrossAccountId::from_sub(input.owner),150 input.data.into_inner(),151 )?;152153 collection.submit_logs()?;154 Ok(RetVal::Converging(0))155 }156 3 => {157 // Approve158 let mut env = env.buf_in_buf_out();159 let input: NFTExtApprove<AccountIdOf<C>> = env.read_as()?;160 env.charge_weight(NftWeightInfoOf::<C>::approve())?;161162 let collection = pallet_nft::Module::<C>::get_collection(input.collection_id)?;163164 pallet_nft::Module::<C>::approve_internal(165 &C::CrossAccountId::from_sub(env.ext().address().clone()),166 &C::CrossAccountId::from_sub(input.spender),167 &collection,168 input.item_id,169 input.amount,170 )?;171172 collection.submit_logs()?;173 Ok(RetVal::Converging(0))174 }175 4 => {176 // Transfer from177 let mut env = env.buf_in_buf_out();178 let input: NFTExtTransferFrom<AccountIdOf<C>> = env.read_as()?;179 env.charge_weight(NftWeightInfoOf::<C>::transfer_from())?;180181 let collection = pallet_nft::Module::<C>::get_collection(input.collection_id)?;182183 pallet_nft::Module::<C>::transfer_from_internal(184 &C::CrossAccountId::from_sub(env.ext().address().clone()),185 &C::CrossAccountId::from_sub(input.owner),186 &C::CrossAccountId::from_sub(input.recipient),187 &collection,188 input.item_id,189 input.amount,190 )?;191192 collection.submit_logs()?;193 Ok(RetVal::Converging(0))194 }195 5 => {196 // Set variable metadata197 let mut env = env.buf_in_buf_out();198 let input: NFTExtSetVariableMetaData = env.read_as()?;199 env.charge_weight(NftWeightInfoOf::<C>::set_variable_meta_data())?;200201 let collection = pallet_nft::Module::<C>::get_collection(input.collection_id)?;202203 pallet_nft::Module::<C>::set_variable_meta_data_internal(204 &C::CrossAccountId::from_sub(env.ext().address().clone()),205 &collection,206 input.item_id,207 input.data.into_inner(),208 )?;209210 collection.submit_logs()?;211 Ok(RetVal::Converging(0))212 }213 6 => {214 // Toggle whitelist215 let mut env = env.buf_in_buf_out();216 let input: NFTExtToggleWhiteList<AccountIdOf<C>> = env.read_as()?;217 env.charge_weight(NftWeightInfoOf::<C>::add_to_white_list())?;218219 let collection = pallet_nft::Module::<C>::get_collection(input.collection_id)?;220221 pallet_nft::Module::<C>::toggle_white_list_internal(222 &C::CrossAccountId::from_sub(env.ext().address().clone()),223 &collection,224 &C::CrossAccountId::from_sub(input.address),225 input.whitelisted,226 )?;227228 collection.submit_logs()?;229 Ok(RetVal::Converging(0))230 }231 _ => Err(DispatchError::Other("unknown chain_extension func_id")),232 }233 }234}1//! NFT Chain Extension23//4// This file is subject to the terms and conditions defined in5// file 'LICENSE', which is part of this source code package.6//78use codec::{Decode, Encode};9use max_encoded_len::MaxEncodedLen;10use derivative::Derivative;1112pub use pallet_contracts::chain_extension::RetVal;13use pallet_contracts::chain_extension::{14 ChainExtension, Environment, Ext, InitState, SysConfig, UncheckedFrom,15};1617pub use frame_support::debug;18use frame_support::dispatch::DispatchError;1920extern crate pallet_nft;21pub use pallet_nft::*;22use pallet_nft::CrossAccountId;23use nft_data_structs::*;2425/// Create item parameters26#[derive(Debug, PartialEq, Encode, Decode, MaxEncodedLen)]27pub struct NFTExtCreateItem<AccountId> {28 pub owner: AccountId,29 pub collection_id: u32,30 pub data: CreateItemData,31}3233/// Transfer parameters34#[derive(Debug, PartialEq, Encode, Decode, MaxEncodedLen)]35pub struct NFTExtTransfer<AccountId> {36 pub recipient: AccountId,37 pub collection_id: u32,38 pub token_id: u32,39 pub amount: u128,40}4142#[derive(Derivative, PartialEq, Encode, Decode, MaxEncodedLen)]43#[derivative(Debug)]44pub struct NFTExtCreateMultipleItems<AccountId> {45 pub owner: AccountId,46 pub collection_id: u32,47 #[derivative(Debug = "ignore")]48 pub data: BoundedVec<CreateItemData, MaxItemsPerBatch>,49}5051#[derive(Debug, PartialEq, Encode, Decode, MaxEncodedLen)]52pub struct NFTExtApprove<AccountId> {53 pub spender: AccountId,54 pub collection_id: u32,55 pub item_id: u32,56 pub amount: u128,57}5859#[derive(Debug, PartialEq, Encode, Decode, MaxEncodedLen)]60pub struct NFTExtTransferFrom<AccountId> {61 pub owner: AccountId,62 pub recipient: AccountId,63 pub collection_id: u32,64 pub item_id: u32,65 pub amount: u128,66}6768#[derive(Derivative, PartialEq, Encode, Decode, MaxEncodedLen)]69#[derivative(Debug)]70pub struct NFTExtSetVariableMetaData {71 pub collection_id: u32,72 pub item_id: u32,73 #[derivative(Debug = "ignore")]74 pub data: BoundedVec<u8, MaxDataSize>,75}7677#[derive(Debug, PartialEq, Encode, Decode, MaxEncodedLen)]78pub struct NFTExtToggleAllowList<AccountId> {79 pub collection_id: u32,80 pub address: AccountId,81 pub allowlisted: bool,82}8384/// The chain Extension of NFT pallet85pub struct NFTExtension;8687pub type NftWeightInfoOf<C> = <C as pallet_nft::Config>::WeightInfo;8889pub type AccountIdOf<C> = <C as SysConfig>::AccountId;9091impl<C: Config + pallet_contracts::Config> ChainExtension<C> for NFTExtension {92 fn call<E: Ext>(func_id: u32, env: Environment<E, InitState>) -> Result<RetVal, DispatchError>93 where94 E: Ext<T = C>,95 C: pallet_nft::Config,96 <E::T as SysConfig>::AccountId: UncheckedFrom<<E::T as SysConfig>::Hash> + AsRef<[u8]>,97 {98 // The memory of the vm stores buf in scale-codec99 match func_id {100 0 => {101 let mut env = env.buf_in_buf_out();102 let input: NFTExtTransfer<AccountIdOf<C>> = env.read_as()?;103 env.charge_weight(NftWeightInfoOf::<C>::transfer())?;104105 let collection = pallet_nft::Module::<C>::get_collection(input.collection_id)?;106107 pallet_nft::Module::<C>::transfer_internal(108 &C::CrossAccountId::from_sub(env.ext().address().clone()),109 &C::CrossAccountId::from_sub(input.recipient),110 &collection,111 input.token_id,112 input.amount,113 )?;114115 collection.submit_logs()?;116 Ok(RetVal::Converging(0))117 }118 1 => {119 // Create Item120 let mut env = env.buf_in_buf_out();121 let input: NFTExtCreateItem<AccountIdOf<C>> = env.read_as()?;122 env.charge_weight(NftWeightInfoOf::<C>::create_item(input.data.data_size()))?;123124 let collection = pallet_nft::Module::<C>::get_collection(input.collection_id)?;125126 pallet_nft::Module::<C>::create_item_internal(127 &C::CrossAccountId::from_sub(env.ext().address().clone()),128 &collection,129 &C::CrossAccountId::from_sub(input.owner),130 input.data,131 )?;132133 collection.submit_logs()?;134 Ok(RetVal::Converging(0))135 }136 2 => {137 // Create multiple items138 let mut env = env.buf_in_buf_out();139 let input: NFTExtCreateMultipleItems<AccountIdOf<C>> = env.read_as()?;140 env.charge_weight(NftWeightInfoOf::<C>::create_item(141 input.data.iter().map(|i| i.data_size()).sum(),142 ))?;143144 let collection = pallet_nft::Module::<C>::get_collection(input.collection_id)?;145146 pallet_nft::Module::<C>::create_multiple_items_internal(147 &C::CrossAccountId::from_sub(env.ext().address().clone()),148 &collection,149 &C::CrossAccountId::from_sub(input.owner),150 input.data.into_inner(),151 )?;152153 collection.submit_logs()?;154 Ok(RetVal::Converging(0))155 }156 3 => {157 // Approve158 let mut env = env.buf_in_buf_out();159 let input: NFTExtApprove<AccountIdOf<C>> = env.read_as()?;160 env.charge_weight(NftWeightInfoOf::<C>::approve())?;161162 let collection = pallet_nft::Module::<C>::get_collection(input.collection_id)?;163164 pallet_nft::Module::<C>::approve_internal(165 &C::CrossAccountId::from_sub(env.ext().address().clone()),166 &C::CrossAccountId::from_sub(input.spender),167 &collection,168 input.item_id,169 input.amount,170 )?;171172 collection.submit_logs()?;173 Ok(RetVal::Converging(0))174 }175 4 => {176 // Transfer from177 let mut env = env.buf_in_buf_out();178 let input: NFTExtTransferFrom<AccountIdOf<C>> = env.read_as()?;179 env.charge_weight(NftWeightInfoOf::<C>::transfer_from())?;180181 let collection = pallet_nft::Module::<C>::get_collection(input.collection_id)?;182183 pallet_nft::Module::<C>::transfer_from_internal(184 &C::CrossAccountId::from_sub(env.ext().address().clone()),185 &C::CrossAccountId::from_sub(input.owner),186 &C::CrossAccountId::from_sub(input.recipient),187 &collection,188 input.item_id,189 input.amount,190 )?;191192 collection.submit_logs()?;193 Ok(RetVal::Converging(0))194 }195 5 => {196 // Set variable metadata197 let mut env = env.buf_in_buf_out();198 let input: NFTExtSetVariableMetaData = env.read_as()?;199 env.charge_weight(NftWeightInfoOf::<C>::set_variable_meta_data())?;200201 let collection = pallet_nft::Module::<C>::get_collection(input.collection_id)?;202203 pallet_nft::Module::<C>::set_variable_meta_data_internal(204 &C::CrossAccountId::from_sub(env.ext().address().clone()),205 &collection,206 input.item_id,207 input.data.into_inner(),208 )?;209210 collection.submit_logs()?;211 Ok(RetVal::Converging(0))212 }213 6 => {214 // Toggle whitelist215 let mut env = env.buf_in_buf_out();216 let input: NFTExtToggleAllowList<AccountIdOf<C>> = env.read_as()?;217 env.charge_weight(NftWeightInfoOf::<C>::add_to_allow_list())?;218219 let collection = pallet_nft::Module::<C>::get_collection(input.collection_id)?;220221 pallet_nft::Module::<C>::toggle_white_list_internal(222 &C::CrossAccountId::from_sub(env.ext().address().clone()),223 &collection,224 &C::CrossAccountId::from_sub(input.address),225 input.allowlisted,226 )?;227228 collection.submit_logs()?;229 Ok(RetVal::Converging(0))230 }231 _ => Err(DispatchError::Other("unknown chain_extension func_id")),232 }233 }234}