difftreelog
Whitelist to allowlist renamed
in: master
9 files changed
pallets/fungible/src/lib.rsdiffbeforeafterboth123 .checked_sub(amount)123 .checked_sub(amount)124 .ok_or(<CommonError<T>>::TokenValueTooLow)?;124 .ok_or(<CommonError<T>>::TokenValueTooLow)?;125125126 if collection.access == AccessMode::WhiteList {126 if collection.access == AccessMode::AllowList {127 collection.check_allowlist(owner)?;127 collection.check_allowlist(owner)?;128 }128 }129129161 <CommonError<T>>::TransferNotAllowed161 <CommonError<T>>::TransferNotAllowed162 );162 );163163164 if collection.access == AccessMode::WhiteList {164 if collection.access == AccessMode::AllowList {165 collection.check_allowlist(from)?;165 collection.check_allowlist(from)?;166 collection.check_allowlist(to)?;166 collection.check_allowlist(to)?;167 }167 }305 spender: &T::CrossAccountId,305 spender: &T::CrossAccountId,306 amount: u128,306 amount: u128,307 ) -> DispatchResult {307 ) -> DispatchResult {308 if collection.access == AccessMode::WhiteList {308 if collection.access == AccessMode::AllowList {309 collection.check_allowlist(&owner)?;309 collection.check_allowlist(&owner)?;310 collection.check_allowlist(&spender)?;310 collection.check_allowlist(&spender)?;311 }311 }333 if spender == from {333 if spender == from {334 return Self::transfer(collection, from, to, amount);334 return Self::transfer(collection, from, to, amount);335 }335 }336 if collection.access == AccessMode::WhiteList {336 if collection.access == AccessMode::AllowList {337 // `from`, `to` checked in [`transfer`]337 // `from`, `to` checked in [`transfer`]338 collection.check_allowlist(spender)?;338 collection.check_allowlist(spender)?;339 }339 }365 if spender == from {365 if spender == from {366 return Self::burn(collection, from, amount);366 return Self::burn(collection, from, amount);367 }367 }368 if collection.access == AccessMode::WhiteList {368 if collection.access == AccessMode::AllowList {369 // `from` checked in [`burn`]369 // `from` checked in [`burn`]370 collection.check_allowlist(spender)?;370 collection.check_allowlist(spender)?;371 }371 }pallets/nft/src/benchmarking.rsdiffbeforeafterboth55 let collection = create_nft_collection::<T>(caller.clone())?;55 let collection = create_nft_collection::<T>(caller.clone())?;56 }: _(RawOrigin::Signed(caller.clone()), collection)56 }: _(RawOrigin::Signed(caller.clone()), collection)575758 add_to_white_list {58 add_to_allow_list {59 let caller: T::AccountId = account("caller", 0, SEED);59 let caller: T::AccountId = account("caller", 0, SEED);60 let whitelist_account: T::AccountId = account("admin", 0, SEED);60 let whitelist_account: T::AccountId = account("admin", 0, SEED);61 let collection = create_nft_collection::<T>(caller.clone())?;61 let collection = create_nft_collection::<T>(caller.clone())?;62 }: _(RawOrigin::Signed(caller.clone()), collection, T::CrossAccountId::from_sub(whitelist_account))62 }: _(RawOrigin::Signed(caller.clone()), collection, T::CrossAccountId::from_sub(whitelist_account))636364 remove_from_white_list {64 remove_from_allow_list {65 let caller: T::AccountId = account("caller", 0, SEED);65 let caller: T::AccountId = account("caller", 0, SEED);66 let whitelist_account: T::AccountId = account("admin", 0, SEED);66 let whitelist_account: T::AccountId = account("admin", 0, SEED);67 let collection = create_nft_collection::<T>(caller.clone())?;67 let collection = create_nft_collection::<T>(caller.clone())?;68 <Pallet<T>>::add_to_white_list(RawOrigin::Signed(caller.clone()).into(), collection, T::CrossAccountId::from_sub(whitelist_account.clone()))?;68 <Pallet<T>>::add_to_allow_list(RawOrigin::Signed(caller.clone()).into(), collection, T::CrossAccountId::from_sub(whitelist_account.clone()))?;69 }: _(RawOrigin::Signed(caller.clone()), collection, T::CrossAccountId::from_sub(whitelist_account))69 }: _(RawOrigin::Signed(caller.clone()), collection, T::CrossAccountId::from_sub(whitelist_account))707071 set_public_access_mode {71 set_public_access_mode {72 let caller: T::AccountId = account("caller", 0, SEED);72 let caller: T::AccountId = account("caller", 0, SEED);73 let collection = create_nft_collection::<T>(caller.clone())?;73 let collection = create_nft_collection::<T>(caller.clone())?;74 }: _(RawOrigin::Signed(caller.clone()), collection, AccessMode::WhiteList)74 }: _(RawOrigin::Signed(caller.clone()), collection, AccessMode::AllowList)757576 set_mint_permission {76 set_mint_permission {77 let caller: T::AccountId = account("caller", 0, SEED);77 let caller: T::AccountId = account("caller", 0, SEED);pallets/nft/src/lib.rsdiffbeforeafterboth274 /// * collection_id.274 /// * collection_id.275 ///275 ///276 /// * address.276 /// * address.277 #[weight = <SelfWeightOf<T>>::add_to_white_list()]277 #[weight = <SelfWeightOf<T>>::add_to_allow_list()]278 #[transactional]278 #[transactional]279 pub fn add_to_white_list(origin, collection_id: CollectionId, address: T::CrossAccountId) -> DispatchResult{279 pub fn add_to_allow_list(origin, collection_id: CollectionId, address: T::CrossAccountId) -> DispatchResult{280280281 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);281 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);282 let collection = <CollectionHandle<T>>::try_get(collection_id)?;282 let collection = <CollectionHandle<T>>::try_get(collection_id)?;303 /// * collection_id.303 /// * collection_id.304 ///304 ///305 /// * address.305 /// * address.306 #[weight = <SelfWeightOf<T>>::remove_from_white_list()]306 #[weight = <SelfWeightOf<T>>::remove_from_allow_list()]307 #[transactional]307 #[transactional]308 pub fn remove_from_white_list(origin, collection_id: CollectionId, address: T::CrossAccountId) -> DispatchResult{308 pub fn remove_from_allow_list(origin, collection_id: CollectionId, address: T::CrossAccountId) -> DispatchResult{309309310 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);310 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);311 let collection = <CollectionHandle<T>>::try_get(collection_id)?;311 let collection = <CollectionHandle<T>>::try_get(collection_id)?;pallets/nft/src/tests.rsdiffbeforeafterboth485 assert_ok!(TemplateModule::set_public_access_mode(485 assert_ok!(TemplateModule::set_public_access_mode(486 origin1.clone(),486 origin1.clone(),487 1,487 1,488 AccessMode::WhiteList488 AccessMode::AllowList489 ));489 ));490 assert_ok!(TemplateModule::add_to_white_list(490 assert_ok!(TemplateModule::add_to_allow_list(491 origin1.clone(),491 origin1.clone(),492 1,492 1,493 account(1)493 account(1)494 ));494 ));495 assert_ok!(TemplateModule::add_to_white_list(495 assert_ok!(TemplateModule::add_to_allow_list(496 origin1.clone(),496 origin1.clone(),497 1,497 1,498 account(2)498 account(2)499 ));499 ));500 assert_ok!(TemplateModule::add_to_white_list(500 assert_ok!(TemplateModule::add_to_allow_list(501 origin1.clone(),501 origin1.clone(),502 1,502 1,503 account(3)503 account(3)549 assert_ok!(TemplateModule::set_public_access_mode(549 assert_ok!(TemplateModule::set_public_access_mode(550 origin1.clone(),550 origin1.clone(),551 1,551 1,552 AccessMode::WhiteList552 AccessMode::AllowList553 ));553 ));554 assert_ok!(TemplateModule::add_to_white_list(554 assert_ok!(TemplateModule::add_to_allow_list(555 origin1.clone(),555 origin1.clone(),556 1,556 1,557 account(1)557 account(1)558 ));558 ));559 assert_ok!(TemplateModule::add_to_white_list(559 assert_ok!(TemplateModule::add_to_allow_list(560 origin1.clone(),560 origin1.clone(),561 1,561 1,562 account(2)562 account(2)563 ));563 ));564 assert_ok!(TemplateModule::add_to_white_list(564 assert_ok!(TemplateModule::add_to_allow_list(565 origin1.clone(),565 origin1.clone(),566 1,566 1,567 account(3)567 account(3)609 assert_ok!(TemplateModule::set_public_access_mode(609 assert_ok!(TemplateModule::set_public_access_mode(610 origin1.clone(),610 origin1.clone(),611 1,611 1,612 AccessMode::WhiteList612 AccessMode::AllowList613 ));613 ));614 assert_ok!(TemplateModule::add_to_white_list(614 assert_ok!(TemplateModule::add_to_allow_list(615 origin1.clone(),615 origin1.clone(),616 1,616 1,617 account(1)617 account(1)618 ));618 ));619 assert_ok!(TemplateModule::add_to_white_list(619 assert_ok!(TemplateModule::add_to_allow_list(620 origin1.clone(),620 origin1.clone(),621 1,621 1,622 account(2)622 account(2)623 ));623 ));624 assert_ok!(TemplateModule::add_to_white_list(624 assert_ok!(TemplateModule::add_to_allow_list(625 origin1.clone(),625 origin1.clone(),626 1,626 1,627 account(3)627 account(3)765 assert_ok!(TemplateModule::set_public_access_mode(765 assert_ok!(TemplateModule::set_public_access_mode(766 origin1.clone(),766 origin1.clone(),767 collection_id,767 collection_id,768 AccessMode::WhiteList768 AccessMode::AllowList769 ));769 ));770 assert_ok!(TemplateModule::add_to_white_list(770 assert_ok!(TemplateModule::add_to_allow_list(771 origin1.clone(),771 origin1.clone(),772 1,772 1,773 account(1)773 account(1)952 assert_ok!(TemplateModule::set_public_access_mode(952 assert_ok!(TemplateModule::set_public_access_mode(953 origin1.clone(),953 origin1.clone(),954 1,954 1,955 AccessMode::WhiteList955 AccessMode::AllowList956 ));956 ));957 assert_ok!(TemplateModule::add_to_white_list(957 assert_ok!(TemplateModule::add_to_allow_list(958 origin1.clone(),958 origin1.clone(),959 1,959 1,960 account(1)960 account(1)961 ));961 ));962 assert_ok!(TemplateModule::add_to_white_list(962 assert_ok!(TemplateModule::add_to_allow_list(963 origin1.clone(),963 origin1.clone(),964 1,964 1,965 account(2)965 account(2)966 ));966 ));967 assert_ok!(TemplateModule::add_to_white_list(origin1, 1, account(3)));967 assert_ok!(TemplateModule::add_to_allow_list(origin1, 1, account(3)));968968969 assert_ok!(TemplateModule::transfer_from(969 assert_ok!(TemplateModule::transfer_from(970 origin2,970 origin2,992 let collection_id = create_test_collection(&CollectionMode::NFT, 1);992 let collection_id = create_test_collection(&CollectionMode::NFT, 1);993993994 let origin1 = Origin::signed(1);994 let origin1 = Origin::signed(1);995 assert_ok!(TemplateModule::add_to_white_list(995 assert_ok!(TemplateModule::add_to_allow_list(996 origin1,996 origin1,997 collection_id,997 collection_id,998 account(2)998 account(2)1013 collection_id,1013 collection_id,1014 account(2)1014 account(2)1015 ));1015 ));1016 assert_ok!(TemplateModule::add_to_white_list(1016 assert_ok!(TemplateModule::add_to_allow_list(1017 origin2,1017 origin2,1018 collection_id,1018 collection_id,1019 account(3)1019 account(3)102910291030 let origin2 = Origin::signed(2);1030 let origin2 = Origin::signed(2);1031 assert_noop!(1031 assert_noop!(1032 TemplateModule::add_to_white_list(origin2, collection_id, account(3)),1032 TemplateModule::add_to_allow_list(origin2, collection_id, account(3)),1033 Error::<Test>::NoPermission1033 Error::<Test>::NoPermission1034 );1034 );1035 });1035 });1041 let origin1 = Origin::signed(1);1041 let origin1 = Origin::signed(1);104210421043 assert_noop!(1043 assert_noop!(1044 TemplateModule::add_to_white_list(origin1, 1, account(2)),1044 TemplateModule::add_to_allow_list(origin1, 1, account(2)),1045 Error::<Test>::CollectionNotFound1045 Error::<Test>::CollectionNotFound1046 );1046 );1047 });1047 });1058 collection_id1058 collection_id1059 ));1059 ));1060 assert_noop!(1060 assert_noop!(1061 TemplateModule::add_to_white_list(origin1, collection_id, account(2)),1061 TemplateModule::add_to_allow_list(origin1, collection_id, account(2)),1062 Error::<Test>::CollectionNotFound1062 Error::<Test>::CollectionNotFound1063 );1063 );1064 });1064 });1071 let collection_id = create_test_collection(&CollectionMode::NFT, 1);1071 let collection_id = create_test_collection(&CollectionMode::NFT, 1);1072 let origin1 = Origin::signed(1);1072 let origin1 = Origin::signed(1);107310731074 assert_ok!(TemplateModule::add_to_white_list(1074 assert_ok!(TemplateModule::add_to_allow_list(1075 origin1.clone(),1075 origin1.clone(),1076 collection_id,1076 collection_id,1077 account(2)1077 account(2)1078 ));1078 ));1079 assert_ok!(TemplateModule::add_to_white_list(1079 assert_ok!(TemplateModule::add_to_allow_list(1080 origin1,1080 origin1,1081 collection_id,1081 collection_id,1082 account(2)1082 account(2)1091 let collection_id = create_test_collection(&CollectionMode::NFT, 1);1091 let collection_id = create_test_collection(&CollectionMode::NFT, 1);109210921093 let origin1 = Origin::signed(1);1093 let origin1 = Origin::signed(1);1094 assert_ok!(TemplateModule::add_to_white_list(1094 assert_ok!(TemplateModule::add_to_allow_list(1095 origin1.clone(),1095 origin1.clone(),1096 collection_id,1096 collection_id,1097 account(2)1097 account(2)1098 ));1098 ));1099 assert_ok!(TemplateModule::remove_from_white_list(1099 assert_ok!(TemplateModule::remove_from_allow_list(1100 origin1,1100 origin1,1101 collection_id,1101 collection_id,1102 account(2)1102 account(2)1118 account(2)1118 account(2)1119 ));1119 ));112011201121 assert_ok!(TemplateModule::add_to_white_list(1121 assert_ok!(TemplateModule::add_to_allow_list(1122 origin1,1122 origin1,1123 collection_id,1123 collection_id,1124 account(3)1124 account(3)1125 ));1125 ));1126 assert_ok!(TemplateModule::remove_from_white_list(1126 assert_ok!(TemplateModule::remove_from_allow_list(1127 origin2,1127 origin2,1128 collection_id,1128 collection_id,1129 account(3)1129 account(3)1139 let origin1 = Origin::signed(1);1139 let origin1 = Origin::signed(1);1140 let origin2 = Origin::signed(2);1140 let origin2 = Origin::signed(2);114111411142 assert_ok!(TemplateModule::add_to_white_list(1142 assert_ok!(TemplateModule::add_to_allow_list(1143 origin1,1143 origin1,1144 collection_id,1144 collection_id,1145 account(2)1145 account(2)1146 ));1146 ));1147 assert_noop!(1147 assert_noop!(1148 TemplateModule::remove_from_white_list(origin2, collection_id, account(2)),1148 TemplateModule::remove_from_allow_list(origin2, collection_id, account(2)),1149 Error::<Test>::NoPermission1149 Error::<Test>::NoPermission1150 );1150 );1151 assert!(TemplateModule::white_list(collection_id, 2));1151 assert!(TemplateModule::white_list(collection_id, 2));1158 let origin1 = Origin::signed(1);1158 let origin1 = Origin::signed(1);115911591160 assert_noop!(1160 assert_noop!(1161 TemplateModule::remove_from_white_list(origin1, 1, account(2)),1161 TemplateModule::remove_from_allow_list(origin1, 1, account(2)),1162 Error::<Test>::CollectionNotFound1162 Error::<Test>::CollectionNotFound1163 );1163 );1164 });1164 });1171 let origin1 = Origin::signed(1);1171 let origin1 = Origin::signed(1);1172 let origin2 = Origin::signed(2);1172 let origin2 = Origin::signed(2);117311731174 assert_ok!(TemplateModule::add_to_white_list(1174 assert_ok!(TemplateModule::add_to_allow_list(1175 origin1.clone(),1175 origin1.clone(),1176 collection_id,1176 collection_id,1177 account(2)1177 account(2)1178 ));1178 ));1179 assert_ok!(TemplateModule::destroy_collection(origin1, collection_id));1179 assert_ok!(TemplateModule::destroy_collection(origin1, collection_id));1180 assert_noop!(1180 assert_noop!(1181 TemplateModule::remove_from_white_list(origin2, collection_id, account(2)),1181 TemplateModule::remove_from_allow_list(origin2, collection_id, account(2)),1182 Error::<Test>::CollectionNotFound1182 Error::<Test>::CollectionNotFound1183 );1183 );1184 assert!(!TemplateModule::white_list(collection_id, 2));1184 assert!(!TemplateModule::white_list(collection_id, 2));1192 let collection_id = create_test_collection(&CollectionMode::NFT, 1);1192 let collection_id = create_test_collection(&CollectionMode::NFT, 1);1193 let origin1 = Origin::signed(1);1193 let origin1 = Origin::signed(1);119411941195 assert_ok!(TemplateModule::add_to_white_list(1195 assert_ok!(TemplateModule::add_to_allow_list(1196 origin1.clone(),1196 origin1.clone(),1197 collection_id,1197 collection_id,1198 account(2)1198 account(2)1199 ));1199 ));1200 assert_ok!(TemplateModule::remove_from_white_list(1200 assert_ok!(TemplateModule::remove_from_allow_list(1201 origin1.clone(),1201 origin1.clone(),1202 collection_id,1202 collection_id,1203 account(2)1203 account(2)1204 ));1204 ));1205 assert_ok!(TemplateModule::remove_from_white_list(1205 assert_ok!(TemplateModule::remove_from_allow_list(1206 origin1,1206 origin1,1207 collection_id,1207 collection_id,1208 account(2)1208 account(2)1225 assert_ok!(TemplateModule::set_public_access_mode(1225 assert_ok!(TemplateModule::set_public_access_mode(1226 origin1.clone(),1226 origin1.clone(),1227 collection_id,1227 collection_id,1228 AccessMode::WhiteList1228 AccessMode::AllowList1229 ));1229 ));1230 assert_ok!(TemplateModule::add_to_white_list(1230 assert_ok!(TemplateModule::add_to_allow_list(1231 origin1.clone(),1231 origin1.clone(),1232 collection_id,1232 collection_id,1233 account(2)1233 account(2)1252 assert_ok!(TemplateModule::set_public_access_mode(1252 assert_ok!(TemplateModule::set_public_access_mode(1253 origin1.clone(),1253 origin1.clone(),1254 collection_id,1254 collection_id,1255 AccessMode::WhiteList1255 AccessMode::AllowList1256 ));1256 ));1257 assert_ok!(TemplateModule::add_to_white_list(1257 assert_ok!(TemplateModule::add_to_allow_list(1258 origin1.clone(),1258 origin1.clone(),1259 1,1259 1,1260 account(1)1260 account(1)1261 ));1261 ));1262 assert_ok!(TemplateModule::add_to_white_list(1262 assert_ok!(TemplateModule::add_to_allow_list(1263 origin1.clone(),1263 origin1.clone(),1264 1,1264 1,1265 account(2)1265 account(2)1275 ));1275 ));1276 assert_eq!(TemplateModule::approved(1, (1, 1, 1)), 1);1276 assert_eq!(TemplateModule::approved(1, (1, 1, 1)), 1);127712771278 assert_ok!(TemplateModule::remove_from_white_list(1278 assert_ok!(TemplateModule::remove_from_allow_list(1279 origin1.clone(),1279 origin1.clone(),1280 1,1280 1,1281 account(1)1281 account(1)1302 assert_ok!(TemplateModule::set_public_access_mode(1302 assert_ok!(TemplateModule::set_public_access_mode(1303 origin1.clone(),1303 origin1.clone(),1304 collection_id,1304 collection_id,1305 AccessMode::WhiteList1305 AccessMode::AllowList1306 ));1306 ));1307 assert_ok!(TemplateModule::add_to_white_list(1307 assert_ok!(TemplateModule::add_to_allow_list(1308 origin1.clone(),1308 origin1.clone(),1309 1,1309 1,1310 account(1)1310 account(1)1330 assert_ok!(TemplateModule::set_public_access_mode(1330 assert_ok!(TemplateModule::set_public_access_mode(1331 origin1.clone(),1331 origin1.clone(),1332 collection_id,1332 collection_id,1333 AccessMode::WhiteList1333 AccessMode::AllowList1334 ));1334 ));1335 assert_ok!(TemplateModule::add_to_white_list(1335 assert_ok!(TemplateModule::add_to_allow_list(1336 origin1.clone(),1336 origin1.clone(),1337 collection_id,1337 collection_id,1338 account(1)1338 account(1)1339 ));1339 ));1340 assert_ok!(TemplateModule::add_to_white_list(1340 assert_ok!(TemplateModule::add_to_allow_list(1341 origin1.clone(),1341 origin1.clone(),1342 collection_id,1342 collection_id,1343 account(2)1343 account(2)1353 ));1353 ));1354 assert_eq!(TemplateModule::approved(1, (1, 1, 1)), 1);1354 assert_eq!(TemplateModule::approved(1, (1, 1, 1)), 1);135513551356 assert_ok!(TemplateModule::remove_from_white_list(1356 assert_ok!(TemplateModule::remove_from_allow_list(1357 origin1.clone(),1357 origin1.clone(),1358 collection_id,1358 collection_id,1359 account(2)1359 account(2)1380 assert_ok!(TemplateModule::set_public_access_mode(1380 assert_ok!(TemplateModule::set_public_access_mode(1381 origin1.clone(),1381 origin1.clone(),1382 collection_id,1382 collection_id,1383 AccessMode::WhiteList1383 AccessMode::AllowList1384 ));1384 ));1385 assert_noop!(1385 assert_noop!(1386 TemplateModule::burn_item(origin1.clone(), 1, 1, 5),1386 TemplateModule::burn_item(origin1.clone(), 1, 1, 5),1403 assert_ok!(TemplateModule::set_public_access_mode(1403 assert_ok!(TemplateModule::set_public_access_mode(1404 origin1.clone(),1404 origin1.clone(),1405 collection_id,1405 collection_id,1406 AccessMode::WhiteList1406 AccessMode::AllowList1407 ));1407 ));140814081409 // do approve1409 // do approve1429 assert_ok!(TemplateModule::set_public_access_mode(1429 assert_ok!(TemplateModule::set_public_access_mode(1430 origin1.clone(),1430 origin1.clone(),1431 collection_id,1431 collection_id,1432 AccessMode::WhiteList1432 AccessMode::AllowList1433 ));1433 ));1434 assert_ok!(TemplateModule::add_to_white_list(1434 assert_ok!(TemplateModule::add_to_allow_list(1435 origin1.clone(),1435 origin1.clone(),1436 collection_id,1436 collection_id,1437 account(1)1437 account(1)1438 ));1438 ));1439 assert_ok!(TemplateModule::add_to_white_list(1439 assert_ok!(TemplateModule::add_to_allow_list(1440 origin1.clone(),1440 origin1.clone(),1441 collection_id,1441 collection_id,1442 account(2)1442 account(2)1459 assert_ok!(TemplateModule::set_public_access_mode(1459 assert_ok!(TemplateModule::set_public_access_mode(1460 origin1.clone(),1460 origin1.clone(),1461 collection_id,1461 collection_id,1462 AccessMode::WhiteList1462 AccessMode::AllowList1463 ));1463 ));1464 assert_ok!(TemplateModule::add_to_white_list(1464 assert_ok!(TemplateModule::add_to_allow_list(1465 origin1.clone(),1465 origin1.clone(),1466 collection_id,1466 collection_id,1467 account(1)1467 account(1)1468 ));1468 ));1469 assert_ok!(TemplateModule::add_to_white_list(1469 assert_ok!(TemplateModule::add_to_allow_list(1470 origin1.clone(),1470 origin1.clone(),1471 collection_id,1471 collection_id,1472 account(2)1472 account(2)1503 assert_ok!(TemplateModule::set_public_access_mode(1503 assert_ok!(TemplateModule::set_public_access_mode(1504 origin1.clone(),1504 origin1.clone(),1505 collection_id,1505 collection_id,1506 AccessMode::WhiteList1506 AccessMode::AllowList1507 ));1507 ));1508 assert_ok!(TemplateModule::set_mint_permission(1508 assert_ok!(TemplateModule::set_mint_permission(1509 origin1,1509 origin1,1528 assert_ok!(TemplateModule::set_public_access_mode(1528 assert_ok!(TemplateModule::set_public_access_mode(1529 origin1.clone(),1529 origin1.clone(),1530 collection_id,1530 collection_id,1531 AccessMode::WhiteList1531 AccessMode::AllowList1532 ));1532 ));1533 assert_ok!(TemplateModule::set_mint_permission(1533 assert_ok!(TemplateModule::set_mint_permission(1534 origin1.clone(),1534 origin1.clone(),1563 assert_ok!(TemplateModule::set_public_access_mode(1563 assert_ok!(TemplateModule::set_public_access_mode(1564 origin1.clone(),1564 origin1.clone(),1565 collection_id,1565 collection_id,1566 AccessMode::WhiteList1566 AccessMode::AllowList1567 ));1567 ));1568 assert_ok!(TemplateModule::set_mint_permission(1568 assert_ok!(TemplateModule::set_mint_permission(1569 origin1.clone(),1569 origin1.clone(),1570 collection_id,1570 collection_id,1571 false1571 false1572 ));1572 ));1573 assert_ok!(TemplateModule::add_to_white_list(1573 assert_ok!(TemplateModule::add_to_allow_list(1574 origin1,1574 origin1,1575 collection_id,1575 collection_id,1576 account(2)1576 account(2)1595 assert_ok!(TemplateModule::set_public_access_mode(1595 assert_ok!(TemplateModule::set_public_access_mode(1596 origin1.clone(),1596 origin1.clone(),1597 collection_id,1597 collection_id,1598 AccessMode::WhiteList1598 AccessMode::AllowList1599 ));1599 ));1600 assert_ok!(TemplateModule::set_mint_permission(1600 assert_ok!(TemplateModule::set_mint_permission(1601 origin1,1601 origin1,1621 assert_ok!(TemplateModule::set_public_access_mode(1621 assert_ok!(TemplateModule::set_public_access_mode(1622 origin1.clone(),1622 origin1.clone(),1623 collection_id,1623 collection_id,1624 AccessMode::WhiteList1624 AccessMode::AllowList1625 ));1625 ));1626 assert_ok!(TemplateModule::set_mint_permission(1626 assert_ok!(TemplateModule::set_mint_permission(1627 origin1,1627 origin1,1646 assert_ok!(TemplateModule::set_public_access_mode(1646 assert_ok!(TemplateModule::set_public_access_mode(1647 origin1.clone(),1647 origin1.clone(),1648 collection_id,1648 collection_id,1649 AccessMode::WhiteList1649 AccessMode::AllowList1650 ));1650 ));1651 assert_ok!(TemplateModule::set_mint_permission(1651 assert_ok!(TemplateModule::set_mint_permission(1652 origin1.clone(),1652 origin1.clone(),1681 assert_ok!(TemplateModule::set_public_access_mode(1681 assert_ok!(TemplateModule::set_public_access_mode(1682 origin1.clone(),1682 origin1.clone(),1683 collection_id,1683 collection_id,1684 AccessMode::WhiteList1684 AccessMode::AllowList1685 ));1685 ));1686 assert_ok!(TemplateModule::set_mint_permission(1686 assert_ok!(TemplateModule::set_mint_permission(1687 origin1,1687 origin1,1708 assert_ok!(TemplateModule::set_public_access_mode(1708 assert_ok!(TemplateModule::set_public_access_mode(1709 origin1.clone(),1709 origin1.clone(),1710 collection_id,1710 collection_id,1711 AccessMode::WhiteList1711 AccessMode::AllowList1712 ));1712 ));1713 assert_ok!(TemplateModule::set_mint_permission(1713 assert_ok!(TemplateModule::set_mint_permission(1714 origin1.clone(),1714 origin1.clone(),1715 collection_id,1715 collection_id,1716 true1716 true1717 ));1717 ));1718 assert_ok!(TemplateModule::add_to_white_list(1718 assert_ok!(TemplateModule::add_to_allow_list(1719 origin1,1719 origin1,1720 collection_id,1720 collection_id,1721 account(2)1721 account(2)2056 collection_id,2056 collection_id,2057 true2057 true2058 ));2058 ));2059 assert_ok!(TemplateModule::add_to_white_list(2059 assert_ok!(TemplateModule::add_to_allow_list(2060 origin1.clone(),2060 origin1.clone(),2061 collection_id,2061 collection_id,2062 account(1)2062 account(1)2124 collection_id,2124 collection_id,2125 true2125 true2126 ));2126 ));2127 assert_ok!(TemplateModule::add_to_white_list(2127 assert_ok!(TemplateModule::add_to_allow_list(2128 origin2.clone(),2128 origin2.clone(),2129 collection_id,2129 collection_id,2130 account(1)2130 account(1)2177 collection_id,2177 collection_id,2178 true2178 true2179 ));2179 ));2180 assert_ok!(TemplateModule::add_to_white_list(2180 assert_ok!(TemplateModule::add_to_allow_list(2181 origin2.clone(),2181 origin2.clone(),2182 collection_id,2182 collection_id,2183 account(1)2183 account(1)pallets/nft/src/weights.rsdiffbeforeafterboth33pub trait WeightInfo {33pub trait WeightInfo {34 fn create_collection() -> Weight;34 fn create_collection() -> Weight;35 fn destroy_collection() -> Weight;35 fn destroy_collection() -> Weight;36 fn add_to_white_list() -> Weight;36 fn add_to_allow_list() -> Weight;37 fn remove_from_white_list() -> Weight;37 fn remove_from_allow_list() -> Weight;38 fn set_public_access_mode() -> Weight;38 fn set_public_access_mode() -> Weight;39 fn set_mint_permission() -> Weight;39 fn set_mint_permission() -> Weight;40 fn change_collection_owner() -> Weight;40 fn change_collection_owner() -> Weight;75 }75 }76 // Storage: Common CollectionById (r:1 w:0)76 // Storage: Common CollectionById (r:1 w:0)77 // Storage: Common Allowlist (r:0 w:1)77 // Storage: Common Allowlist (r:0 w:1)78 fn add_to_white_list() -> Weight {78 fn add_to_allow_list() -> Weight {79 (6_629_000 as Weight)79 (6_629_000 as Weight)80 .saturating_add(T::DbWeight::get().reads(1 as Weight))80 .saturating_add(T::DbWeight::get().reads(1 as Weight))81 .saturating_add(T::DbWeight::get().writes(1 as Weight))81 .saturating_add(T::DbWeight::get().writes(1 as Weight))82 }82 }83 // Storage: Common CollectionById (r:1 w:0)83 // Storage: Common CollectionById (r:1 w:0)84 // Storage: Common Allowlist (r:0 w:1)84 // Storage: Common Allowlist (r:0 w:1)85 fn remove_from_white_list() -> Weight {85 fn remove_from_allow_list() -> Weight {86 (6_596_000 as Weight)86 (6_596_000 as Weight)87 .saturating_add(T::DbWeight::get().reads(1 as Weight))87 .saturating_add(T::DbWeight::get().reads(1 as Weight))88 .saturating_add(T::DbWeight::get().writes(1 as Weight))88 .saturating_add(T::DbWeight::get().writes(1 as Weight))205 }205 }206 // Storage: Common CollectionById (r:1 w:0)206 // Storage: Common CollectionById (r:1 w:0)207 // Storage: Common Allowlist (r:0 w:1)207 // Storage: Common Allowlist (r:0 w:1)208 fn add_to_white_list() -> Weight {208 fn add_to_allow_list() -> Weight {209 (6_629_000 as Weight)209 (6_629_000 as Weight)210 .saturating_add(RocksDbWeight::get().reads(1 as Weight))210 .saturating_add(RocksDbWeight::get().reads(1 as Weight))211 .saturating_add(RocksDbWeight::get().writes(1 as Weight))211 .saturating_add(RocksDbWeight::get().writes(1 as Weight))212 }212 }213 // Storage: Common CollectionById (r:1 w:0)213 // Storage: Common CollectionById (r:1 w:0)214 // Storage: Common Allowlist (r:0 w:1)214 // Storage: Common Allowlist (r:0 w:1)215 fn remove_from_white_list() -> Weight {215 fn remove_from_allow_list() -> Weight {216 (6_596_000 as Weight)216 (6_596_000 as Weight)217 .saturating_add(RocksDbWeight::get().reads(1 as Weight))217 .saturating_add(RocksDbWeight::get().reads(1 as Weight))218 .saturating_add(RocksDbWeight::get().writes(1 as Weight))218 .saturating_add(RocksDbWeight::get().writes(1 as Weight))pallets/nonfungible/src/lib.rsdiffbeforeafterboth169 <CommonError<T>>::NoPermission169 <CommonError<T>>::NoPermission170 );170 );171171172 if collection.access == AccessMode::WhiteList {172 if collection.access == AccessMode::AllowList {173 collection.check_allowlist(sender)?;173 collection.check_allowlist(sender)?;174 }174 }175175227 <CommonError<T>>::NoPermission227 <CommonError<T>>::NoPermission228 );228 );229229230 if collection.access == AccessMode::WhiteList {230 if collection.access == AccessMode::AllowList {231 collection.check_allowlist(from)?;231 collection.check_allowlist(from)?;232 collection.check_allowlist(to)?;232 collection.check_allowlist(to)?;233 }233 }445 token: TokenId,445 token: TokenId,446 spender: Option<&T::CrossAccountId>,446 spender: Option<&T::CrossAccountId>,447 ) -> DispatchResult {447 ) -> DispatchResult {448 if collection.access == AccessMode::WhiteList {448 if collection.access == AccessMode::AllowList {449 collection.check_allowlist(&sender)?;449 collection.check_allowlist(&sender)?;450 if let Some(spender) = spender {450 if let Some(spender) = spender {451 collection.check_allowlist(&spender)?;451 collection.check_allowlist(&spender)?;480 if spender == from {480 if spender == from {481 return Self::transfer(collection, from, to, token);481 return Self::transfer(collection, from, to, token);482 }482 }483 if collection.access == AccessMode::WhiteList {483 if collection.access == AccessMode::AllowList {484 // `from`, `to` checked in [`transfer`]484 // `from`, `to` checked in [`transfer`]485 collection.check_allowlist(spender)?;485 collection.check_allowlist(spender)?;486 }486 }508 if spender == from {508 if spender == from {509 return Self::burn(collection, from, token);509 return Self::burn(collection, from, token);510 }510 }511 if collection.access == AccessMode::WhiteList {511 if collection.access == AccessMode::AllowList {512 // `from` checked in [`burn`]512 // `from` checked in [`burn`]513 collection.check_allowlist(spender)?;513 collection.check_allowlist(spender)?;514 }514 }pallets/refungible/src/lib.rsdiffbeforeafterboth272 <CommonError<T>>::TransferNotAllowed272 <CommonError<T>>::TransferNotAllowed273 );273 );274274275 if collection.access == AccessMode::WhiteList {275 if collection.access == AccessMode::AllowList {276 collection.check_allowlist(from)?;276 collection.check_allowlist(from)?;277 collection.check_allowlist(to)?;277 collection.check_allowlist(to)?;278 }278 }483 token: TokenId,483 token: TokenId,484 amount: u128,484 amount: u128,485 ) -> DispatchResult {485 ) -> DispatchResult {486 if collection.access == AccessMode::WhiteList {486 if collection.access == AccessMode::AllowList {487 collection.check_allowlist(&sender)?;487 collection.check_allowlist(&sender)?;488 collection.check_allowlist(&spender)?;488 collection.check_allowlist(&spender)?;489 }489 }514 if spender == from {514 if spender == from {515 return Self::transfer(collection, from, to, token, amount);515 return Self::transfer(collection, from, to, token, amount);516 }516 }517 if collection.access == AccessMode::WhiteList {517 if collection.access == AccessMode::AllowList {518 // `from`, `to` checked in [`transfer`]518 // `from`, `to` checked in [`transfer`]519 collection.check_allowlist(spender)?;519 collection.check_allowlist(spender)?;520 }520 }547 if spender == from {547 if spender == from {548 return Self::burn(collection, from, token, amount);548 return Self::burn(collection, from, token, amount);549 }549 }550 if collection.access == AccessMode::WhiteList {550 if collection.access == AccessMode::AllowList {551 // `from` checked in [`burn`]551 // `from` checked in [`burn`]552 collection.check_allowlist(spender)?;552 collection.check_allowlist(spender)?;553 }553 }primitives/nft/src/lib.rsdiffbeforeafterboth141#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]141#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]142pub enum AccessMode {142pub enum AccessMode {143 Normal,143 Normal,144 WhiteList,144 AllowList,145}145}146impl Default for AccessMode {146impl Default for AccessMode {147 fn default() -> Self {147 fn default() -> Self {runtime/src/chain_extension.rsdiffbeforeafterboth75}75}767677#[derive(Debug, PartialEq, Encode, Decode, MaxEncodedLen)]77#[derive(Debug, PartialEq, Encode, Decode, MaxEncodedLen)]78pub struct NFTExtToggleWhiteList<AccountId> {78pub struct NFTExtToggleAllowList<AccountId> {79 pub collection_id: u32,79 pub collection_id: u32,80 pub address: AccountId,80 pub address: AccountId,81 pub whitelisted: bool,81 pub allowlisted: bool,82}82}838384/// The chain Extension of NFT pallet84/// The chain Extension of NFT pallet213 6 => {213 6 => {214 // Toggle whitelist214 // Toggle whitelist215 let mut env = env.buf_in_buf_out();215 let mut env = env.buf_in_buf_out();216 let input: NFTExtToggleWhiteList<AccountIdOf<C>> = env.read_as()?;216 let input: NFTExtToggleAllowList<AccountIdOf<C>> = env.read_as()?;217 env.charge_weight(NftWeightInfoOf::<C>::add_to_white_list())?;217 env.charge_weight(NftWeightInfoOf::<C>::add_to_allow_list())?;218218219 let collection = pallet_nft::Module::<C>::get_collection(input.collection_id)?;219 let collection = pallet_nft::Module::<C>::get_collection(input.collection_id)?;220220221 pallet_nft::Module::<C>::toggle_white_list_internal(221 pallet_nft::Module::<C>::toggle_white_list_internal(222 &C::CrossAccountId::from_sub(env.ext().address().clone()),222 &C::CrossAccountId::from_sub(env.ext().address().clone()),223 &collection,223 &collection,224 &C::CrossAccountId::from_sub(input.address),224 &C::CrossAccountId::from_sub(input.address),225 input.whitelisted,225 input.allowlisted,226 )?;226 )?;227227228 collection.submit_logs()?;228 collection.submit_logs()?;