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
--- a/pallets/fungible/src/lib.rs
+++ b/pallets/fungible/src/lib.rs
@@ -236,7 +236,7 @@
 
 		// =========
 
-		<PalletStructure<T>>::try_nest_if_sent_to_token(
+		<PalletStructure<T>>::nest_if_sent_to_token(
 			from.clone(),
 			to,
 			collection.id,
@@ -320,7 +320,7 @@
 		<TotalSupply<T>>::insert(collection.id, total_supply);
 		for (user, amount) in balances {
 			<Balance<T>>::insert((collection.id, &user), amount);
-			<PalletStructure<T>>::nest_if_sent_to_token(&user, collection.id, TokenId::default());
+			<PalletStructure<T>>::nest_if_sent_to_token_unchecked(&user, collection.id, TokenId::default());
 			<PalletEvm<T>>::deposit_log(
 				ERC20Events::Transfer {
 					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
191 token_id: TokenId,191 token_id: TokenId,
192 nesting_budget: &dyn Budget192 nesting_budget: &dyn Budget
193 ) -> DispatchResult {193 ) -> DispatchResult {
194 Self::try_dispatched(194 Self::try_exec_if_owner_is_valid_nft(
195 under,195 under,
196 |d, parent_id| d.check_nesting(196 |d, parent_id| d.check_nesting(
197 from,197 from,
202 )202 )
203 }203 }
204204
205 pub fn try_nest_if_sent_to_token(205 pub fn nest_if_sent_to_token(
206 from: T::CrossAccountId,206 from: T::CrossAccountId,
207 under: &T::CrossAccountId,207 under: &T::CrossAccountId,
208 collection_id: CollectionId,208 collection_id: CollectionId,
209 token_id: TokenId,209 token_id: TokenId,
210 nesting_budget: &dyn Budget210 nesting_budget: &dyn Budget
211 ) -> DispatchResult {211 ) -> DispatchResult {
212 Self::try_dispatched(212 Self::try_exec_if_owner_is_valid_nft(
213 under,213 under,
214 |d, parent_id| {214 |d, parent_id| {
215 d.check_nesting(215 d.check_nesting(
226 )226 )
227 }227 }
228228
229 pub fn nest_if_sent_to_token(229 pub fn nest_if_sent_to_token_unchecked(
230 owner: &T::CrossAccountId,230 owner: &T::CrossAccountId,
231 collection_id: CollectionId,231 collection_id: CollectionId,
232 token_id: TokenId232 token_id: TokenId
233 ) {233 ) {
234 Self::dispatched(234 Self::exec_if_owner_is_valid_nft(
235 owner,235 owner,
236 |d, parent_id| d.nest(236 |d, parent_id| d.nest(
237 parent_id,237 parent_id,
245 collection_id: CollectionId,245 collection_id: CollectionId,
246 token_id: TokenId246 token_id: TokenId
247 ) {247 ) {
248 Self::dispatched(248 Self::exec_if_owner_is_valid_nft(
249 owner,249 owner,
250 |d, parent_id| d.unnest(250 |d, parent_id| d.unnest(
251 parent_id,251 parent_id,
254 );254 );
255 }255 }
256256
257 fn dispatched(257 fn exec_if_owner_is_valid_nft(
258 account: &T::CrossAccountId,258 account: &T::CrossAccountId,
259 action: impl FnOnce(&dyn CommonCollectionOperations<T>, TokenId)259 action: impl FnOnce(&dyn CommonCollectionOperations<T>, TokenId)
260 ) {260 ) {
261 Self::try_dispatched(261 Self::try_exec_if_owner_is_valid_nft(
262 account,262 account,
263 |d, id| {263 |d, id| {
264 action(d, id);264 action(d, id);
267 ).unwrap();267 ).unwrap();
268 }268 }
269269
270 fn try_dispatched(270 fn try_exec_if_owner_is_valid_nft(
271 account: &T::CrossAccountId,271 account: &T::CrossAccountId,
272 action: impl FnOnce(&dyn CommonCollectionOperations<T>, TokenId) -> DispatchResult272 action: impl FnOnce(&dyn CommonCollectionOperations<T>, TokenId) -> DispatchResult
273 ) -> DispatchResult {273 ) -> DispatchResult {