git.delta.rocks / unique-network / refs/commits / b5533c6f03d9

difftreelog

refactor rename structure dispatch* fns

Daniel Shiposha2022-05-27parent: #bb64e8b.patch.diff
in: master

4 files changed

modifiedpallets/fungible/src/lib.rsdiffbeforeafterboth
236236
237 // =========237 // =========
238238
239 <PalletStructure<T>>::try_nest_if_sent_to_token(239 <PalletStructure<T>>::nest_if_sent_to_token(
240 from.clone(),240 from.clone(),
241 to,241 to,
242 collection.id,242 collection.id,
320 <TotalSupply<T>>::insert(collection.id, total_supply);320 <TotalSupply<T>>::insert(collection.id, total_supply);
321 for (user, amount) in balances {321 for (user, amount) in balances {
322 <Balance<T>>::insert((collection.id, &user), amount);322 <Balance<T>>::insert((collection.id, &user), amount);
323 <PalletStructure<T>>::nest_if_sent_to_token(&user, collection.id, TokenId::default());323 <PalletStructure<T>>::nest_if_sent_to_token_unchecked(&user, collection.id, TokenId::default());
324 <PalletEvm<T>>::deposit_log(324 <PalletEvm<T>>::deposit_log(
325 ERC20Events::Transfer {325 ERC20Events::Transfer {
326 from: H160::default(),326 from: H160::default(),
modifiedpallets/nonfungible/src/lib.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/lib.rs
+++ b/pallets/nonfungible/src/lib.rs
@@ -585,7 +585,7 @@
 			None
 		};
 
-		<PalletStructure<T>>::try_nest_if_sent_to_token(
+		<PalletStructure<T>>::nest_if_sent_to_token(
 			from.clone(),
 			to,
 			collection.id,
@@ -704,7 +704,7 @@
 					},
 				);
 
-				<PalletStructure<T>>::nest_if_sent_to_token(&data.owner, collection.id, TokenId(token));
+				<PalletStructure<T>>::nest_if_sent_to_token_unchecked(&data.owner, collection.id, TokenId(token));
 
 				if let Err(e) = Self::set_token_properties(
 					collection,
modifiedpallets/refungible/src/lib.rsdiffbeforeafterboth
--- a/pallets/refungible/src/lib.rs
+++ b/pallets/refungible/src/lib.rs
@@ -375,7 +375,7 @@
 
 		// =========
 
-		<PalletStructure<T>>::try_nest_if_sent_to_token(
+		<PalletStructure<T>>::nest_if_sent_to_token(
 			from.clone(),
 			to,
 			collection.id,
@@ -518,7 +518,7 @@
 				}
 				<Balance<T>>::insert((collection.id, token_id, &user), amount);
 				<Owned<T>>::insert((collection.id, &user, TokenId(token_id)), true);
-				<PalletStructure<T>>::nest_if_sent_to_token(&user, collection.id, TokenId(token_id));
+				<PalletStructure<T>>::nest_if_sent_to_token_unchecked(&user, collection.id, TokenId(token_id));
 
 				// TODO: ERC20 transfer event
 				<PalletCommon<T>>::deposit_event(CommonEvent::ItemCreated(
modifiedpallets/structure/src/lib.rsdiffbeforeafterboth
--- a/pallets/structure/src/lib.rs
+++ b/pallets/structure/src/lib.rs
@@ -191,7 +191,7 @@
 		token_id: TokenId,
 		nesting_budget: &dyn Budget
 	) -> DispatchResult {
-		Self::try_dispatched(
+		Self::try_exec_if_owner_is_valid_nft(
 			under,
 			|d, parent_id| d.check_nesting(
 				from,
@@ -202,14 +202,14 @@
 		)
 	}
 
-	pub fn try_nest_if_sent_to_token(
+	pub fn nest_if_sent_to_token(
 		from: T::CrossAccountId,
 		under: &T::CrossAccountId,
 		collection_id: CollectionId,
 		token_id: TokenId,
 		nesting_budget: &dyn Budget
 	) -> DispatchResult {
-		Self::try_dispatched(
+		Self::try_exec_if_owner_is_valid_nft(
 			under,
 			|d, parent_id| {
 				d.check_nesting(
@@ -226,12 +226,12 @@
 		)
 	}
 
-	pub fn nest_if_sent_to_token(
+	pub fn nest_if_sent_to_token_unchecked(
 		owner: &T::CrossAccountId,
 		collection_id: CollectionId,
 		token_id: TokenId
 	) {
-		Self::dispatched(
+		Self::exec_if_owner_is_valid_nft(
 			owner,
 			|d, parent_id| d.nest(
 				parent_id,
@@ -245,7 +245,7 @@
 		collection_id: CollectionId,
 		token_id: TokenId
 	) {
-		Self::dispatched(
+		Self::exec_if_owner_is_valid_nft(
 			owner,
 			|d, parent_id| d.unnest(
 			parent_id,
@@ -254,11 +254,11 @@
 		);
 	}
 
-	fn dispatched(
+	fn exec_if_owner_is_valid_nft(
 		account: &T::CrossAccountId,
 		action: impl FnOnce(&dyn CommonCollectionOperations<T>, TokenId)
 	) {
-		Self::try_dispatched(
+		Self::try_exec_if_owner_is_valid_nft(
 			account,
 			|d, id| {
 				action(d, id);
@@ -267,7 +267,7 @@
 		).unwrap();
 	}
 
-	fn try_dispatched(
+	fn try_exec_if_owner_is_valid_nft(
 		account: &T::CrossAccountId,
 		action: impl FnOnce(&dyn CommonCollectionOperations<T>, TokenId) -> DispatchResult
 	) -> DispatchResult {