difftreelog
fix make all extrinsics transactional
in: master
1 file changed
pallets/nft/src/lib.rsdiffbeforeafterboth28 WeightToFeePolynomial, DispatchClass,28 WeightToFeePolynomial, DispatchClass,29 },29 },30 StorageValue,30 StorageValue,31 transactional,31};32};323333use frame_system::{self as system, ensure_signed, ensure_root};34use frame_system::{self as system, ensure_signed, ensure_root};648 /// * mode: [CollectionMode] collection type and type dependent data.649 /// * mode: [CollectionMode] collection type and type dependent data.649 // returns collection ID650 // returns collection ID650 #[weight = <T as Config>::WeightInfo::create_collection()]651 #[weight = <T as Config>::WeightInfo::create_collection()]652 #[transactional]651 pub fn create_collection(origin,653 pub fn create_collection(origin,652 collection_name: Vec<u16>,654 collection_name: Vec<u16>,653 collection_description: Vec<u16>,655 collection_description: Vec<u16>,725 /// 727 /// 726 /// * collection_id: collection to destroy.728 /// * collection_id: collection to destroy.727 #[weight = <T as Config>::WeightInfo::destroy_collection()]729 #[weight = <T as Config>::WeightInfo::destroy_collection()]730 #[transactional]728 pub fn destroy_collection(origin, collection_id: CollectionId) -> DispatchResult {731 pub fn destroy_collection(origin, collection_id: CollectionId) -> DispatchResult {729732730 let sender = ensure_signed(origin)?;733 let sender = ensure_signed(origin)?;771 /// 774 /// 772 /// * address.775 /// * address.773 #[weight = <T as Config>::WeightInfo::add_to_white_list()]776 #[weight = <T as Config>::WeightInfo::add_to_white_list()]777 #[transactional]774 pub fn add_to_white_list(origin, collection_id: CollectionId, address: T::AccountId) -> DispatchResult{778 pub fn add_to_white_list(origin, collection_id: CollectionId, address: T::AccountId) -> DispatchResult{775779776 let sender = ensure_signed(origin)?;780 let sender = ensure_signed(origin)?;794 /// 798 /// 795 /// * address.799 /// * address.796 #[weight = <T as Config>::WeightInfo::remove_from_white_list()]800 #[weight = <T as Config>::WeightInfo::remove_from_white_list()]801 #[transactional]797 pub fn remove_from_white_list(origin, collection_id: CollectionId, address: T::AccountId) -> DispatchResult{802 pub fn remove_from_white_list(origin, collection_id: CollectionId, address: T::AccountId) -> DispatchResult{798803799 let sender = ensure_signed(origin)?;804 let sender = ensure_signed(origin)?;816 /// 821 /// 817 /// * mode: [AccessMode]822 /// * mode: [AccessMode]818 #[weight = <T as Config>::WeightInfo::set_public_access_mode()]823 #[weight = <T as Config>::WeightInfo::set_public_access_mode()]824 #[transactional]819 pub fn set_public_access_mode(origin, collection_id: CollectionId, mode: AccessMode) -> DispatchResult825 pub fn set_public_access_mode(origin, collection_id: CollectionId, mode: AccessMode) -> DispatchResult820 {826 {821 let sender = ensure_signed(origin)?;827 let sender = ensure_signed(origin)?;842 /// 848 /// 843 /// * mint_permission: Boolean parameter. If True, allows minting to Anyone with conditions above.849 /// * mint_permission: Boolean parameter. If True, allows minting to Anyone with conditions above.844 #[weight = <T as Config>::WeightInfo::set_mint_permission()]850 #[weight = <T as Config>::WeightInfo::set_mint_permission()]851 #[transactional]845 pub fn set_mint_permission(origin, collection_id: CollectionId, mint_permission: bool) -> DispatchResult852 pub fn set_mint_permission(origin, collection_id: CollectionId, mint_permission: bool) -> DispatchResult846 {853 {847 let sender = ensure_signed(origin)?;854 let sender = ensure_signed(origin)?;866 /// 873 /// 867 /// * new_owner.874 /// * new_owner.868 #[weight = <T as Config>::WeightInfo::change_collection_owner()]875 #[weight = <T as Config>::WeightInfo::change_collection_owner()]876 #[transactional]869 pub fn change_collection_owner(origin, collection_id: CollectionId, new_owner: T::AccountId) -> DispatchResult {877 pub fn change_collection_owner(origin, collection_id: CollectionId, new_owner: T::AccountId) -> DispatchResult {870878871 let sender = ensure_signed(origin)?;879 let sender = ensure_signed(origin)?;891 /// 899 /// 892 /// * new_admin_id: Address of new admin to add.900 /// * new_admin_id: Address of new admin to add.893 #[weight = <T as Config>::WeightInfo::add_collection_admin()]901 #[weight = <T as Config>::WeightInfo::add_collection_admin()]902 #[transactional]894 pub fn add_collection_admin(origin, collection_id: CollectionId, new_admin_id: T::AccountId) -> DispatchResult {903 pub fn add_collection_admin(origin, collection_id: CollectionId, new_admin_id: T::AccountId) -> DispatchResult {895904896 let sender = ensure_signed(origin)?;905 let sender = ensure_signed(origin)?;925 /// 934 /// 926 /// * account_id: Address of admin to remove.935 /// * account_id: Address of admin to remove.927 #[weight = <T as Config>::WeightInfo::remove_collection_admin()]936 #[weight = <T as Config>::WeightInfo::remove_collection_admin()]937 #[transactional]928 pub fn remove_collection_admin(origin, collection_id: CollectionId, account_id: T::AccountId) -> DispatchResult {938 pub fn remove_collection_admin(origin, collection_id: CollectionId, account_id: T::AccountId) -> DispatchResult {929939930 let sender = ensure_signed(origin)?;940 let sender = ensure_signed(origin)?;948 /// 958 /// 949 /// * new_sponsor.959 /// * new_sponsor.950 #[weight = <T as Config>::WeightInfo::set_collection_sponsor()]960 #[weight = <T as Config>::WeightInfo::set_collection_sponsor()]961 #[transactional]951 pub fn set_collection_sponsor(origin, collection_id: CollectionId, new_sponsor: T::AccountId) -> DispatchResult {962 pub fn set_collection_sponsor(origin, collection_id: CollectionId, new_sponsor: T::AccountId) -> DispatchResult {952963953 let sender = ensure_signed(origin)?;964 let sender = ensure_signed(origin)?;970 /// 981 /// 971 /// * collection_id.982 /// * collection_id.972 #[weight = <T as Config>::WeightInfo::confirm_sponsorship()]983 #[weight = <T as Config>::WeightInfo::confirm_sponsorship()]984 #[transactional]973 pub fn confirm_sponsorship(origin, collection_id: CollectionId) -> DispatchResult {985 pub fn confirm_sponsorship(origin, collection_id: CollectionId) -> DispatchResult {974986975 let sender = ensure_signed(origin)?;987 let sender = ensure_signed(origin)?;997 /// 1009 /// 998 /// * collection_id.1010 /// * collection_id.999 #[weight = <T as Config>::WeightInfo::remove_collection_sponsor()]1011 #[weight = <T as Config>::WeightInfo::remove_collection_sponsor()]1012 #[transactional]1000 pub fn remove_collection_sponsor(origin, collection_id: CollectionId) -> DispatchResult {1013 pub fn remove_collection_sponsor(origin, collection_id: CollectionId) -> DispatchResult {100110141002 let sender = ensure_signed(origin)?;1015 let sender = ensure_signed(origin)?;1036 // .saturating_add(RocksDbWeight::get().writes(8 as Weight))]1049 // .saturating_add(RocksDbWeight::get().writes(8 as Weight))]103710501038 #[weight = <T as Config>::WeightInfo::create_item(data.len())]1051 #[weight = <T as Config>::WeightInfo::create_item(data.len())]1052 #[transactional]1039 pub fn create_item(origin, collection_id: CollectionId, owner: T::AccountId, data: CreateItemData) -> DispatchResult {1053 pub fn create_item(origin, collection_id: CollectionId, owner: T::AccountId, data: CreateItemData) -> DispatchResult {104010541041 let sender = ensure_signed(origin)?;1055 let sender = ensure_signed(origin)?;1072 #[weight = <T as Config>::WeightInfo::create_item(items_data.into_iter()1086 #[weight = <T as Config>::WeightInfo::create_item(items_data.into_iter()1073 .map(|data| { data.len() })1087 .map(|data| { data.len() })1074 .sum())]1088 .sum())]1089 #[transactional]1075 pub fn create_multiple_items(origin, collection_id: CollectionId, owner: T::AccountId, items_data: Vec<CreateItemData>) -> DispatchResult {1090 pub fn create_multiple_items(origin, collection_id: CollectionId, owner: T::AccountId, items_data: Vec<CreateItemData>) -> DispatchResult {107610911077 ensure!(items_data.len() > 0, Error::<T>::EmptyArgument);1092 ensure!(items_data.len() > 0, Error::<T>::EmptyArgument);1106 /// 1121 /// 1107 /// * item_id: ID of NFT to burn.1122 /// * item_id: ID of NFT to burn.1108 #[weight = <T as Config>::WeightInfo::burn_item()]1123 #[weight = <T as Config>::WeightInfo::burn_item()]1124 #[transactional]1109 pub fn burn_item(origin, collection_id: CollectionId, item_id: TokenId, value: u128) -> DispatchResult {1125 pub fn burn_item(origin, collection_id: CollectionId, item_id: TokenId, value: u128) -> DispatchResult {111011261111 let sender = ensure_signed(origin)?;1127 let sender = ensure_signed(origin)?;1164 /// * Fungible Mode: Must specify transferred amount1180 /// * Fungible Mode: Must specify transferred amount1165 /// * Re-Fungible Mode: Must specify transferred portion (between 0 and 1)1181 /// * Re-Fungible Mode: Must specify transferred portion (between 0 and 1)1166 #[weight = <T as Config>::WeightInfo::transfer()]1182 #[weight = <T as Config>::WeightInfo::transfer()]1183 #[transactional]1167 pub fn transfer(origin, recipient: T::AccountId, collection_id: CollectionId, item_id: TokenId, value: u128) -> DispatchResult {1184 pub fn transfer(origin, recipient: T::AccountId, collection_id: CollectionId, item_id: TokenId, value: u128) -> DispatchResult {1168 let sender = ensure_signed(origin)?;1185 let sender = ensure_signed(origin)?;1169 Self::transfer_internal(sender, recipient, collection_id, item_id, value)1186 Self::transfer_internal(sender, recipient, collection_id, item_id, value)1185 /// 1202 /// 1186 /// * item_id: ID of the item.1203 /// * item_id: ID of the item.1187 #[weight = <T as Config>::WeightInfo::approve()]1204 #[weight = <T as Config>::WeightInfo::approve()]1205 #[transactional]1188 pub fn approve(origin, spender: T::AccountId, collection_id: CollectionId, item_id: TokenId, amount: u128) -> DispatchResult {1206 pub fn approve(origin, spender: T::AccountId, collection_id: CollectionId, item_id: TokenId, amount: u128) -> DispatchResult {118912071190 let sender = ensure_signed(origin)?;1208 let sender = ensure_signed(origin)?;1248 /// 1266 /// 1249 /// * value: Amount to transfer.1267 /// * value: Amount to transfer.1250 #[weight = <T as Config>::WeightInfo::transfer_from()]1268 #[weight = <T as Config>::WeightInfo::transfer_from()]1269 #[transactional]1251 pub fn transfer_from(origin, from: T::AccountId, recipient: T::AccountId, collection_id: CollectionId, item_id: TokenId, value: u128 ) -> DispatchResult {1270 pub fn transfer_from(origin, from: T::AccountId, recipient: T::AccountId, collection_id: CollectionId, item_id: TokenId, value: u128 ) -> DispatchResult {125212711253 let sender = ensure_signed(origin)?;1272 let sender = ensure_signed(origin)?;1328 /// 1347 /// 1329 /// * schema: String representing the offchain data schema.1348 /// * schema: String representing the offchain data schema.1330 #[weight = <T as Config>::WeightInfo::set_variable_meta_data()]1349 #[weight = <T as Config>::WeightInfo::set_variable_meta_data()]1350 #[transactional]1331 pub fn set_variable_meta_data (1351 pub fn set_variable_meta_data (1332 origin,1352 origin,1333 collection_id: CollectionId,1353 collection_id: CollectionId,1373 /// 1393 /// 1374 /// * schema: SchemaVersion: enum1394 /// * schema: SchemaVersion: enum1375 #[weight = <T as Config>::WeightInfo::set_schema_version()]1395 #[weight = <T as Config>::WeightInfo::set_schema_version()]1396 #[transactional]1376 pub fn set_schema_version(1397 pub fn set_schema_version(1377 origin,1398 origin,1378 collection_id: CollectionId,1399 collection_id: CollectionId,1400 /// 1421 /// 1401 /// * schema: String representing the offchain data schema.1422 /// * schema: String representing the offchain data schema.1402 #[weight = <T as Config>::WeightInfo::set_offchain_schema()]1423 #[weight = <T as Config>::WeightInfo::set_offchain_schema()]1424 #[transactional]1403 pub fn set_offchain_schema(1425 pub fn set_offchain_schema(1404 origin,1426 origin,1405 collection_id: CollectionId,1427 collection_id: CollectionId,1431 /// 1453 /// 1432 /// * schema: String representing the const on-chain data schema.1454 /// * schema: String representing the const on-chain data schema.1433 #[weight = <T as Config>::WeightInfo::set_const_on_chain_schema()]1455 #[weight = <T as Config>::WeightInfo::set_const_on_chain_schema()]1456 #[transactional]1434 pub fn set_const_on_chain_schema (1457 pub fn set_const_on_chain_schema (1435 origin,1458 origin,1436 collection_id: CollectionId,1459 collection_id: CollectionId,1462 /// 1485 /// 1463 /// * schema: String representing the variable on-chain data schema.1486 /// * schema: String representing the variable on-chain data schema.1464 #[weight = <T as Config>::WeightInfo::set_const_on_chain_schema()]1487 #[weight = <T as Config>::WeightInfo::set_const_on_chain_schema()]1488 #[transactional]1465 pub fn set_variable_on_chain_schema (1489 pub fn set_variable_on_chain_schema (1466 origin,1490 origin,1467 collection_id: CollectionId,1491 collection_id: CollectionId,148215061483 // Sudo permissions function1507 // Sudo permissions function1484 #[weight = <T as Config>::WeightInfo::set_chain_limits()]1508 #[weight = <T as Config>::WeightInfo::set_chain_limits()]1509 #[transactional]1485 pub fn set_chain_limits(1510 pub fn set_chain_limits(1486 origin,1511 origin,1487 limits: ChainLimits1512 limits: ChainLimits1506 /// * enable flag1531 /// * enable flag1507 /// 1532 /// 1508 #[weight = <T as Config>::WeightInfo::enable_contract_sponsoring()]1533 #[weight = <T as Config>::WeightInfo::enable_contract_sponsoring()]1534 #[transactional]1509 pub fn enable_contract_sponsoring(1535 pub fn enable_contract_sponsoring(1510 origin,1536 origin,1511 contract_address: T::AccountId,1537 contract_address: T::AccountId,1541 /// -`rate_limit`: Number of blocks to wait until the next sponsored transaction is allowed1567 /// -`rate_limit`: Number of blocks to wait until the next sponsored transaction is allowed1542 /// 1568 /// 1543 #[weight = <T as Config>::WeightInfo::set_contract_sponsoring_rate_limit()]1569 #[weight = <T as Config>::WeightInfo::set_contract_sponsoring_rate_limit()]1570 #[transactional]1544 pub fn set_contract_sponsoring_rate_limit(1571 pub fn set_contract_sponsoring_rate_limit(1545 origin,1572 origin,1546 contract_address: T::AccountId,1573 contract_address: T::AccountId,1568 /// 1595 /// 1569 /// - `enable`: . 1596 /// - `enable`: . 1570 #[weight = <T as Config>::WeightInfo::toggle_contract_white_list()]1597 #[weight = <T as Config>::WeightInfo::toggle_contract_white_list()]1598 #[transactional]1571 pub fn toggle_contract_white_list(1599 pub fn toggle_contract_white_list(1572 origin,1600 origin,1573 contract_address: T::AccountId,1601 contract_address: T::AccountId,1595 ///1623 ///1596 /// -`account_address`: Address to add.1624 /// -`account_address`: Address to add.1597 #[weight = <T as Config>::WeightInfo::add_to_contract_white_list()]1625 #[weight = <T as Config>::WeightInfo::add_to_contract_white_list()]1626 #[transactional]1598 pub fn add_to_contract_white_list(1627 pub fn add_to_contract_white_list(1599 origin,1628 origin,1600 contract_address: T::AccountId,1629 contract_address: T::AccountId,1622 ///1651 ///1623 /// -`account_address`: Address to remove.1652 /// -`account_address`: Address to remove.1624 #[weight = <T as Config>::WeightInfo::remove_from_contract_white_list()]1653 #[weight = <T as Config>::WeightInfo::remove_from_contract_white_list()]1654 #[transactional]1625 pub fn remove_from_contract_white_list(1655 pub fn remove_from_contract_white_list(1626 origin,1656 origin,1627 contract_address: T::AccountId,1657 contract_address: T::AccountId,1638 }1668 }163916691640 #[weight = <T as Config>::WeightInfo::set_collection_limits()]1670 #[weight = <T as Config>::WeightInfo::set_collection_limits()]1671 #[transactional]1641 pub fn set_collection_limits(1672 pub fn set_collection_limits(1642 origin,1673 origin,1643 collection_id: u32,1674 collection_id: u32,