From b5533c6f03d9b372e2426a78c3f9653ff611d3e4 Mon Sep 17 00:00:00 2001 From: Daniel Shiposha Date: Fri, 27 May 2022 13:53:15 +0000 Subject: [PATCH] refactor: rename structure dispatch* fns --- --- a/pallets/fungible/src/lib.rs +++ b/pallets/fungible/src/lib.rs @@ -236,7 +236,7 @@ // ========= - >::try_nest_if_sent_to_token( + >::nest_if_sent_to_token( from.clone(), to, collection.id, @@ -320,7 +320,7 @@ >::insert(collection.id, total_supply); for (user, amount) in balances { >::insert((collection.id, &user), amount); - >::nest_if_sent_to_token(&user, collection.id, TokenId::default()); + >::nest_if_sent_to_token_unchecked(&user, collection.id, TokenId::default()); >::deposit_log( ERC20Events::Transfer { from: H160::default(), --- a/pallets/nonfungible/src/lib.rs +++ b/pallets/nonfungible/src/lib.rs @@ -585,7 +585,7 @@ None }; - >::try_nest_if_sent_to_token( + >::nest_if_sent_to_token( from.clone(), to, collection.id, @@ -704,7 +704,7 @@ }, ); - >::nest_if_sent_to_token(&data.owner, collection.id, TokenId(token)); + >::nest_if_sent_to_token_unchecked(&data.owner, collection.id, TokenId(token)); if let Err(e) = Self::set_token_properties( collection, --- a/pallets/refungible/src/lib.rs +++ b/pallets/refungible/src/lib.rs @@ -375,7 +375,7 @@ // ========= - >::try_nest_if_sent_to_token( + >::nest_if_sent_to_token( from.clone(), to, collection.id, @@ -518,7 +518,7 @@ } >::insert((collection.id, token_id, &user), amount); >::insert((collection.id, &user, TokenId(token_id)), true); - >::nest_if_sent_to_token(&user, collection.id, TokenId(token_id)); + >::nest_if_sent_to_token_unchecked(&user, collection.id, TokenId(token_id)); // TODO: ERC20 transfer event >::deposit_event(CommonEvent::ItemCreated( --- 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, 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, TokenId) -> DispatchResult ) -> DispatchResult { -- gitstuff