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

difftreelog

refactor switch charging logic to sponsoring primitive

Yaroslav Bolyukin2021-06-24parent: #c12e121.patch.diff
in: master

6 files changed

modifiedpallets/nft-charge-transaction/Cargo.tomldiffbeforeafterboth
--- a/pallets/nft-charge-transaction/Cargo.toml
+++ b/pallets/nft-charge-transaction/Cargo.toml
@@ -23,19 +23,14 @@
 frame-support = { default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.3' }
 frame-system = { default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.3' }
 pallet-balances = { default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.3' }
-pallet-contracts = { default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.3' }
-pallet-timestamp = { default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.3' }
 pallet-transaction-payment = { default-features = false, version = "3.0.0", git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.3' }
-pallet-randomness-collective-flip = { default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.3' }
 sp-std = { default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.3' }
 frame-benchmarking = { default-features = false, version = "3.0.0", optional = true, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.3' }
 sp-core = { default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.3' }
 sp-io = { default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.3' }
 sp-runtime = { default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.3' }
 
-pallet-nft = { default-features = false, path="../nft" }
 pallet-nft-transaction-payment = { default-features = false, path="../nft-transaction-payment" }
-nft-data-structs = { default-features = false, path="../../primitives", version = "0.9.0" }
 
 [features]
 default = ['std']
@@ -45,15 +40,10 @@
     'frame-support/std',
     'frame-system/std',
     'pallet-balances/std',
-    'pallet-timestamp/std',
-    'pallet-randomness-collective-flip/std',
-    'pallet-contracts/std',
-    'pallet-nft/std',
     'pallet-transaction-payment/std',
     'pallet-nft-transaction-payment/std',
     'sp-std/std',
     'sp-runtime/std',
-    'nft-data-structs/std',
     'frame-benchmarking/std',
 ]
 runtime-benchmarks = ["frame-benchmarking"]
modifiedpallets/nft-charge-transaction/src/lib.rsdiffbeforeafterboth
14#[cfg(feature = "runtime-benchmarks")]14#[cfg(feature = "runtime-benchmarks")]
15mod benchmarking;15mod benchmarking;
16
17#[cfg(test)]
18mod tests;
1916
20use codec::{Decode, Encode};17use codec::{Decode, Encode};
21use frame_support::traits::{ Get};18use frame_support::traits::Get;
22use frame_support::{19use frame_support::{
23 decl_module, decl_storage,20 decl_module, decl_storage,
24 traits::{
25 IsSubType,
26 },
27 weights::{21 weights::{
28 DispatchInfo, PostDispatchInfo, DispatchClass22 DispatchInfo, PostDispatchInfo, DispatchClass
29 }23 }
37 },31 },
38 FixedPointOperand, DispatchResult32 FixedPointOperand, DispatchResult
39};33};
40use pallet_contracts::chain_extension::UncheckedFrom;
41use pallet_transaction_payment::OnChargeTransaction;34use pallet_transaction_payment::OnChargeTransaction;
42use sp_std::prelude::*;35use sp_std::prelude::*;
4336
8376
84impl<T: Config> ChargeTransactionPayment<T>77impl<T: Config> ChargeTransactionPayment<T>
85where78where
86 T::Call: Dispatchable<Info=DispatchInfo, PostInfo=PostDispatchInfo> + IsSubType<pallet_nft::Call<T>> + IsSubType<pallet_contracts::Call<T>>,79 T::Call: Dispatchable<Info=DispatchInfo, PostInfo=PostDispatchInfo>,
87 BalanceOf<T>: Send + Sync + From<u64> + FixedPointOperand,80 BalanceOf<T>: Send + Sync + From<u64> + FixedPointOperand,
88 T::AccountId: AsRef<[u8]>,
89 T::AccountId: UncheckedFrom<T::Hash>,
90{81{
91 fn traditional_fee(82 fn traditional_fee(
92 len: usize,83 len: usize,
134 .map(|i| (fee, i));125 .map(|i| (fee, i));
135 }126 }
136
137 // check errors
138 let _error = <pallet_nft_transaction_payment::Module<T>>::check_error(who, call);
139 match _error {
140 Err(_error) => return Err(_error),
141 Ok(_error) => {}
142 };
143127
144 // Determine who is paying transaction fee based on ecnomic model128 // Determine who is paying transaction fee based on ecnomic model
145 // Parse call to extract collection ID and access collection sponsor 129 // Parse call to extract collection ID and access collection sponsor
156 for ChargeTransactionPayment<T>140 for ChargeTransactionPayment<T>
157where141where
158 BalanceOf<T>: Send + Sync + From<u64> + FixedPointOperand,142 BalanceOf<T>: Send + Sync + From<u64> + FixedPointOperand,
159 T::Call: Dispatchable<Info=DispatchInfo, PostInfo=PostDispatchInfo> + IsSubType<pallet_nft::Call<T>> + IsSubType<pallet_contracts::Call<T>>,143 T::Call: Dispatchable<Info=DispatchInfo, PostInfo=PostDispatchInfo>,
160 T::AccountId: AsRef<[u8]>,
161 T::AccountId: UncheckedFrom<T::Hash>,
162{144{
163 const IDENTIFIER: &'static str = "ChargeTransactionPayment";145 const IDENTIFIER: &'static str = "ChargeTransactionPayment";
164 type AccountId = T::AccountId;146 type AccountId = T::AccountId;
209 _result: &DispatchResult,191 _result: &DispatchResult,
210 ) -> Result<(), TransactionValidityError> {192 ) -> Result<(), TransactionValidityError> {
211 let (tip, who, imbalance) = pre;193 let (tip, who, imbalance) = pre;
212 let actual_fee = pallet_transaction_payment::Module::<T>::compute_actual_fee(194 let actual_fee = pallet_transaction_payment::Pallet::<T>::compute_actual_fee(
213 len as u32,195 len as u32,
214 info,196 info,
215 post_info,197 post_info,
modifiedpallets/nft-transaction-payment/Cargo.tomldiffbeforeafterboth
--- a/pallets/nft-transaction-payment/Cargo.toml
+++ b/pallets/nft-transaction-payment/Cargo.toml
@@ -22,19 +22,14 @@
 serde = { version = "1.0.119", default-features = false }
 frame-support = { default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.3' }
 frame-system = { default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.3' }
-pallet-balances = { default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.3' }
-pallet-contracts = { default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.3' }
-pallet-timestamp = { default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.3' }
 pallet-transaction-payment = { default-features = false, version = "3.0.0", git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.3' }
-pallet-randomness-collective-flip = { default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.3' }
 sp-std = { default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.3' }
 frame-benchmarking = { default-features = false, version = "3.0.0", optional = true, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.3' }
 sp-core = { default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.3' }
 sp-io = { default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.3' }
 sp-runtime = { default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.3' }
 
-pallet-nft = { default-features = false, path="../nft" }
-nft-data-structs = { default-features = false, path="../../primitives", version = "0.9.0" }
+up-sponsorship = { default-features = false, path = "../../primitives/sponsorship", version = "0.1.0" }
 
 [features]
 default = ['std']
@@ -43,15 +38,13 @@
     'serde/std',
     'frame-support/std',
     'frame-system/std',
-    'pallet-balances/std',
-    'pallet-timestamp/std',
-    'pallet-randomness-collective-flip/std',
-    'pallet-contracts/std',
-    'pallet-nft/std',
+    'sp-core/std',
+    'sp-io/std',
     'pallet-transaction-payment/std',
     'sp-std/std',
     'sp-runtime/std',
-    'nft-data-structs/std',
     'frame-benchmarking/std',
+
+    'up-sponsorship/std',
 ]
 runtime-benchmarks = ["frame-benchmarking"]
modifiedpallets/nft-transaction-payment/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/nft-transaction-payment/src/benchmarking.rs
+++ b/pallets/nft-transaction-payment/src/benchmarking.rs
@@ -1,7 +1,6 @@
 #![cfg(feature = "runtime-benchmarks")]
 
 use super::*;
-use crate::Module as NftTransactionPayment;
 
 use sp_std::prelude::*;
 use frame_system::RawOrigin;
modifiedpallets/nft-transaction-payment/src/lib.rsdiffbeforeafterboth
--- a/pallets/nft-transaction-payment/src/lib.rs
+++ b/pallets/nft-transaction-payment/src/lib.rs
@@ -14,388 +14,32 @@
 #[cfg(feature = "runtime-benchmarks")]
 mod benchmarking;
 
-#[cfg(test)]
-mod tests;
-
-use frame_support::{
-	decl_error, decl_module, decl_storage,
-	traits::{
-		IsSubType, 
-	},
-	weights::{
-		DispatchInfo
-	}
-};
-use sp_runtime::traits::StaticLookup;
-use sp_runtime::{
-	traits::{ 
-		Hash, Dispatchable,
-	},
-	transaction_validity::{
-        InvalidTransaction, TransactionValidityError,
-    },
-};
-use pallet_contracts::chain_extension::UncheckedFrom;
+use frame_support::{decl_module, decl_storage};
 use sp_std::prelude::*;
-use nft_data_structs::{
-	CreateItemData,
-	CollectionId, CollectionMode, TokenId
-};
-
-type CodeHash<T> = <T as frame_system::Config>::Hash;
+use up_sponsorship::SponsorshipHandler;
 
-	pub trait Config: frame_system::Config + pallet_contracts::Config + pallet_transaction_payment::Config + pallet_nft::Config {
-	}
-
-	// Error for non-fungible-token module.
-	
-	decl_error! {
-		/// Error for non-fungible-token module.
-		pub enum Error for Module<T: Config> {
-		/// No available class ID
-		NoAvailableClassId,
-		/// No available token ID
-		NoAvailableTokenId,
-		/// Token(ClassId, TokenId) not found
-		TokenNotFound,
-		/// Class not found
-		CollectionNotFound,
-		/// The operator is not the owner of the token and has no permission
-		NoPermission,
-		/// Arithmetic calculation overflow
-		NumOverflow,
-		/// Can not destroy class
-		/// Total issuance is not 0
-		CannotDestroyClass,
-	}
+pub trait Config: frame_system::Config + pallet_transaction_payment::Config {
+	type SponsorshipHandler: SponsorshipHandler<Self::AccountId, Self::Call>;
 }
-
-	decl_storage! {
-		trait Store for Module<T: Config> as NftTransactionPayment{
 
+decl_storage! {
+	trait Store for Module<T: Config> as NftTransactionPayment{
 	}
 }
 
 decl_module! {
-
 	pub struct Module<T: Config> for enum Call 
     where 
 		origin: T::Origin,
     {
 	}
 }
-
-impl<T: Config> Module<T> 
-{
 
-	pub fn check_error(
-		who: &T::AccountId,
-		call: &T::Call
-	) -> Result<bool, TransactionValidityError> where 
-		T::Call: Dispatchable<Info=DispatchInfo>,
-		T::Call: IsSubType<pallet_nft::Call<T>>, 
-		T::Call: IsSubType<pallet_contracts::Call<T>>,
-		T::AccountId: AsRef<[u8]>,
-		T::AccountId: UncheckedFrom<T::Hash>
-		{
-
-			match IsSubType::<pallet_contracts::Call<T>>::is_sub_type(call) {
-				Some(pallet_contracts::Call::call(dest, _value, _gas_limit, _data)) => {
-	
-					let called_contract: T::AccountId = T::Lookup::lookup((*dest).clone()).unwrap_or(T::AccountId::default());
-	
-					let owned_contract = pallet_nft::ContractOwner::<T>::get(called_contract.clone()).as_ref() == Some(who);
-					let white_list_enabled = pallet_nft::ContractWhiteListEnabled::<T>::contains_key(called_contract.clone());
-					  
-					if !owned_contract && white_list_enabled {
-						if !pallet_nft::ContractWhiteList::<T>::contains_key(called_contract.clone(), who) {
-							return Err(InvalidTransaction::Call.into());
-						}
-					}
-					Ok(true)
-				},
-				_ => { Ok(true) },
-			}
-		}
-
+impl<T: Config> Module<T> {
 	pub fn withdraw_type(
 		who: &T::AccountId,
 		call: &T::Call
-	) -> Option<T::AccountId> where 
-		T::Call: Dispatchable<Info=DispatchInfo>,
-		T::Call: IsSubType<pallet_nft::Call<T>>, 
-		T::Call: IsSubType<pallet_contracts::Call<T>>,
-		T::AccountId: AsRef<[u8]>,
-		T::AccountId: UncheckedFrom<T::Hash>
-		{
-
-        let mut sponsor: Option<T::AccountId> = match IsSubType::<pallet_nft::Call<T>>::is_sub_type(call)  {
-            Some(pallet_nft::Call::create_item(collection_id, _owner, _properties)) => {
-
-                Self::withdraw_create_item(who, collection_id, &_properties)
-            },
-            Some(pallet_nft::Call::transfer(_new_owner, collection_id, item_id, _value)) => {
-
-                Self::withdraw_transfer(who, collection_id, item_id)
-            },
-            Some(pallet_nft::Call::set_variable_meta_data(collection_id, item_id, data)) => {
-
-                Self::withdraw_set_variable_meta_data(collection_id, item_id, &data)
-			},
-			_ => None,
-        };
-
-        sponsor = sponsor.or_else(|| match IsSubType::<pallet_contracts::Call<T>>::is_sub_type(call) {
-            Some(pallet_contracts::Call::call(dest, _value, _gas_limit, _data)) => {
-
-                Self::withdraw_contract_call(who, dest)
-            },
-            Some(pallet_contracts::Call::instantiate(_endowment, _gas_limit, code_hash, _data, salt)) => {
-
-                Self::withdraw_contract_instantiate(&who, code_hash, salt)
-            },
-            Some(pallet_contracts::Call::instantiate_with_code(_endowment, _gas_limit, _code, _data, _salt))  => {
-
-                Self::withdraw_contract_instantiate(&who, &T::Hashing::hash(&_code), _salt)
-			},
-			_ => None,
-        });
-
-		sponsor
-	}
-
-
-
-	pub fn withdraw_create_item(
-		who: &T::AccountId,
-		collection_id: &CollectionId,
-		_properties: &CreateItemData,
 	) -> Option<T::AccountId> {
-	
-		let collection = pallet_nft::CollectionById::<T>::get(collection_id)?;
-
-		// sponsor timeout
-		let block_number = <frame_system::Pallet<T>>::block_number() as T::BlockNumber;
-
-		let limit = collection.limits.sponsor_transfer_timeout;
-		if pallet_nft::CreateItemBasket::<T>::contains_key((collection_id, &who)) {
-			let last_tx_block = pallet_nft::CreateItemBasket::<T>::get((collection_id, &who));
-			let limit_time = last_tx_block + limit.into();
-			if block_number <= limit_time {
-				return None;
-			}
-		}
-		pallet_nft::CreateItemBasket::<T>::insert((collection_id, who.clone()), block_number);
-
-		// check free create limit
-		if collection.limits.sponsored_data_size >= (_properties.len() as u32) {
-			collection.sponsorship.sponsor()
-				.cloned()
-		} else {
-			None
-		}
-	}
-
-	pub fn withdraw_transfer(
-		who: &T::AccountId,
-		collection_id: &CollectionId,
-		item_id: &TokenId,
-	) -> Option<T::AccountId> {
-
-		let collection = pallet_nft::CollectionById::<T>::get(collection_id)?;
-		let limits = pallet_nft::ChainLimit::get();
-
-		let mut sponsor_transfer = false;
-		if collection.sponsorship.confirmed() {
-
-			let collection_limits = collection.limits.clone();
-			let collection_mode = collection.mode.clone();
-
-			// sponsor timeout
-			let block_number = <frame_system::Pallet<T>>::block_number() as T::BlockNumber;
-			sponsor_transfer = match collection_mode {
-				CollectionMode::NFT => {
-
-					// get correct limit
-					let limit: u32 = if collection_limits.sponsor_transfer_timeout > 0 {
-						collection_limits.sponsor_transfer_timeout
-					} else {
-						limits.nft_sponsor_transfer_timeout
-					};
-
-					let mut sponsored = true;
-					if pallet_nft::NftTransferBasket::<T>::contains_key(collection_id, item_id) {
-						let last_tx_block = pallet_nft::NftTransferBasket::<T>::get(collection_id, item_id);
-						let limit_time = last_tx_block + limit.into();
-						if block_number <= limit_time {
-							sponsored = false;
-						}
-					}
-					if sponsored {
-						pallet_nft::NftTransferBasket::<T>::insert(collection_id, item_id, block_number);
-					}
-
-					sponsored
-				}
-				CollectionMode::Fungible(_) => {
-
-					// get correct limit
-					let limit: u32 = if collection_limits.sponsor_transfer_timeout > 0 {
-						collection_limits.sponsor_transfer_timeout
-					} else {
-						limits.fungible_sponsor_transfer_timeout
-					};
-
-					let block_number = <frame_system::Pallet<T>>::block_number() as T::BlockNumber;
-					let mut sponsored = true;
-					if pallet_nft::FungibleTransferBasket::<T>::contains_key(collection_id, who) {
-						let last_tx_block = pallet_nft::FungibleTransferBasket::<T>::get(collection_id, who);
-						let limit_time = last_tx_block + limit.into();
-						if block_number <= limit_time {
-							sponsored = false;
-						}
-					}
-					if sponsored {
-						pallet_nft::FungibleTransferBasket::<T>::insert(collection_id, who, block_number);
-					}
-
-					sponsored
-				}
-				CollectionMode::ReFungible => {
-
-					// get correct limit
-					let limit: u32 = if collection_limits.sponsor_transfer_timeout > 0 {
-						collection_limits.sponsor_transfer_timeout
-					} else {
-						limits.refungible_sponsor_transfer_timeout
-					};
-
-					let mut sponsored = true;
-					if pallet_nft::ReFungibleTransferBasket::<T>::contains_key(collection_id, item_id) {
-						let last_tx_block = pallet_nft::ReFungibleTransferBasket::<T>::get(collection_id, item_id);
-						let limit_time = last_tx_block + limit.into();
-						if block_number <= limit_time {
-							sponsored = false;
-						}
-					}
-					if sponsored {
-						pallet_nft::ReFungibleTransferBasket::<T>::insert(collection_id, item_id, block_number);
-					}
-
-					sponsored
-				}
-				_ => {
-					false
-				},
-			};
-		}
-
-		if !sponsor_transfer {
-			None
-		} else {
-			collection.sponsorship.sponsor()
-				.cloned()
-		}
-	}
-	
-	pub fn withdraw_set_variable_meta_data(
-		collection_id: &CollectionId,
-		item_id: &TokenId,
-		data: &Vec<u8>,
-	) -> Option<T::AccountId> {
-
-		let mut sponsor_metadata_changes = false;
-
-		let collection = pallet_nft::CollectionById::<T>::get(collection_id)?;
-
-		if
-			collection.sponsorship.confirmed() &&
-			// Can't sponsor fungible collection, this tx will be rejected
-			// as invalid
-			!matches!(collection.mode, CollectionMode::Fungible(_)) &&
-			data.len() <= collection.limits.sponsored_data_size as usize
-		{
-			if let Some(rate_limit) = collection.limits.sponsored_data_rate_limit {
-				let block_number = <frame_system::Pallet<T>>::block_number() as T::BlockNumber;
-
-				if pallet_nft::VariableMetaDataBasket::<T>::get(collection_id, item_id)
-					.map(|last_block| block_number - last_block > rate_limit)
-					.unwrap_or(true) 
-				{
-					sponsor_metadata_changes = true;
-					pallet_nft::VariableMetaDataBasket::<T>::insert(collection_id, item_id, block_number);
-				}
-			}
-		}
-
-		if !sponsor_metadata_changes {
-			None
-		} else {
-			collection.sponsorship.sponsor().cloned()
-		}
-
-	}
-
-	pub fn withdraw_contract_call(
-		who: &T::AccountId,
-		dest: &<T::Lookup as StaticLookup>::Source
-	) -> Option<T::AccountId> {
-
-		let called_contract: T::AccountId = T::Lookup::lookup((dest).clone()).unwrap_or(T::AccountId::default());
-
-		let owned_contract = pallet_nft::ContractOwner::<T>::get(called_contract.clone()).as_ref() == Some(who);
-		let white_list_enabled = pallet_nft::ContractWhiteListEnabled::<T>::contains_key(called_contract.clone());
-		  
-		// ???
-		if !owned_contract && white_list_enabled {
-		 	if !pallet_nft::ContractWhiteList::<T>::contains_key(called_contract.clone(), who) {
-				return Some(who.clone())
-		 		// return Err(InvalidTransaction::Call.into());
-		 	}
-		}
-
-		let mut sponsor_transfer = false;
-		if pallet_nft::ContractSponsoringRateLimit::<T>::contains_key(called_contract.clone()) {
-			let last_tx_block = pallet_nft::ContractSponsorBasket::<T>::get((&called_contract, &who));
-			let block_number = <frame_system::Pallet<T>>::block_number() as T::BlockNumber;
-			let rate_limit = pallet_nft::ContractSponsoringRateLimit::<T>::get(&called_contract);
-			let limit_time = last_tx_block + rate_limit;
-
-			if block_number >= limit_time {
-				pallet_nft::ContractSponsorBasket::<T>::insert((called_contract.clone(), who.clone()), block_number);
-				sponsor_transfer = true;
-			}
-		} else {
-			sponsor_transfer = false;
-		}
-	   
-		if sponsor_transfer {
-			if pallet_nft::ContractSelfSponsoring::<T>::contains_key(called_contract.clone()) {
-				if pallet_nft::ContractSelfSponsoring::<T>::get(called_contract.clone()) {
-					return Some(called_contract);
-				}
-			}
-		}
-
-		None
-	}
-
-	pub fn withdraw_contract_instantiate(
-		who: &T::AccountId,
-		code_hash: &CodeHash<T>,
-		salt: &[u8],
-	) -> Option<T::AccountId> where
-	T::AccountId: AsRef<[u8]>,
-	T::AccountId: UncheckedFrom<T::Hash>
-	{
-
-		let new_contract_address = <pallet_contracts::Pallet<T>>::contract_address(
-			&who,
-			code_hash,
-			salt,
-		);
-		pallet_nft::ContractOwner::<T>::insert(new_contract_address.clone(), who.clone());
-
-		None
+		T::SponsorshipHandler::get_sponsor(who, call)
 	}
 }
\ No newline at end of file
deletedpallets/nft-transaction-payment/src/tests.rsdiffbeforeafterboth
--- a/pallets/nft-transaction-payment/src/tests.rs
+++ /dev/null
@@ -1,241 +0,0 @@
-#[cfg(test)]
-mod tests {
-	use crate as pallet_inflation;
-
-	use frame_system;
-	use frame_support::{traits::{Currency}, parameter_types};
-	use frame_support::{traits::OnInitialize};
-	use sp_core::H256;
-	use sp_runtime::{traits::{BlakeTwo256, IdentityLookup}, testing::Header};
-
-	type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
-	type Block = frame_system::mocking::MockBlock<Test>;
-
-	const YEAR: u64 = 5_259_600;
-
-	parameter_types! {
-		pub const ExistentialDeposit: u64 = 1;
-		pub const MaxLocks: u32 = 50;
-	}
-	
-	impl pallet_balances::Config for Test {
-		type AccountStore = System;
-		type Balance = u64;
-		type DustRemoval = ();
-		type Event = ();
-		type ExistentialDeposit = ExistentialDeposit;
-		type WeightInfo = ();
-		type MaxLocks = MaxLocks;
-	}
-	
-	frame_support::construct_runtime!(
-		pub enum Test where
-			Block = Block,
-			NodeBlock = Block,
-			UncheckedExtrinsic = UncheckedExtrinsic,
-		{
-			Balances: pallet_balances::{Module, Call, Storage},
-			System: frame_system::{Module, Call, Config, Storage, Event<T>},
-			Inflation: pallet_inflation::{Module, Call, Storage},
-		}
-	);
-
-	parameter_types! {
-		pub const BlockHashCount: u64 = 250;
-		pub BlockWeights: frame_system::limits::BlockWeights =
-			frame_system::limits::BlockWeights::simple_max(1024);
-		pub const SS58Prefix: u8 = 42;
-	}
-
-	impl frame_system::Config for Test {
-		type BaseCallFilter = ();
-		type BlockWeights = ();
-		type BlockLength = ();
-		type DbWeight = ();
-		type Origin = Origin;
-		type Call = Call;
-		type Index = u64;
-		type BlockNumber = u64;
-		type Hash = H256;
-		type Hashing = BlakeTwo256;
-		type AccountId = u64;
-		type Lookup = IdentityLookup<Self::AccountId>;
-		type Header = Header;
-		type Event = ();
-		type BlockHashCount = BlockHashCount;
-		type Version = ();
-		type PalletInfo = PalletInfo;
-		type AccountData = pallet_balances::AccountData<u64>;
-		type OnNewAccount = ();
-		type OnKilledAccount = ();
-		type SystemWeightInfo = ();
-		type SS58Prefix = SS58Prefix;
-	}
-
-	parameter_types! {
-		pub TreasuryAccountId: u64 = 1234;
-		pub const InflationBlockInterval: u32 = 100; // every time per how many blocks inflation is applied
-	}
-		
-	impl pallet_inflation::Config for Test {
-		type Currency = Balances;
-		type TreasuryAccountId = TreasuryAccountId;
-		type InflationBlockInterval = InflationBlockInterval;
-	}
-
-	// Build genesis storage according to the mock runtime.
-	pub fn new_test_ext() -> sp_io::TestExternalities {
-		frame_system::GenesisConfig::default().build_storage::<Test>().unwrap().into()
-	}
-
-	#[test]
-	fn inflation_works() {
-		new_test_ext().execute_with(|| {
-			// Total issuance = 1_000_000_000
-			let initial_issuance: u64 = 1_000_000_000;
-			let _ = <Balances as Currency<_>>::deposit_creating(&1234, initial_issuance);
-			assert_eq!(Balances::free_balance(1234), initial_issuance);
-
-			// BlockInflation should be set after 1st block and 
-			// first inflation deposit should be equal to BlockInflation
-			Inflation::on_initialize(1);
-			assert!(Inflation::block_inflation() > 0);
-			assert_eq!(Balances::free_balance(1234) - initial_issuance, Inflation::block_inflation());
-		});
-	}
-
-	#[test]
-	fn inflation_second_deposit() {
-		new_test_ext().execute_with(|| {
-			// Total issuance = 1_000_000_000
-			let initial_issuance: u64 = 1_000_000_000;
-			let _ = <Balances as Currency<_>>::deposit_creating(&1234, initial_issuance);
-			assert_eq!(Balances::free_balance(1234), initial_issuance);
-			Inflation::on_initialize(1);
-
-			// Next inflation deposit happens when block is multiple of InflationBlockInterval
-			let mut block: u32 = 2;
-			let balance_before: u64 = Balances::free_balance(1234);
-			while block % InflationBlockInterval::get() != 0 {
-				Inflation::on_initialize(block as u64);
-				block += 1;
-			}
-			let balance_just_before: u64 = Balances::free_balance(1234);
-			assert_eq!(balance_before, balance_just_before);
-
-			// The block with inflation
-			Inflation::on_initialize(block as u64);
-			let balance_after: u64 = Balances::free_balance(1234);
-			assert_eq!(balance_after - balance_just_before, Inflation::block_inflation());
-		});
-	}
-
-	#[test]
-	fn inflation_in_1_year() {
-		new_test_ext().execute_with(|| {
-			// Total issuance = 1_000_000_000
-			let initial_issuance: u64 = 1_000_000_000;
-			let _ = <Balances as Currency<_>>::deposit_creating(&1234, initial_issuance);
-			assert_eq!(Balances::free_balance(1234), initial_issuance);
-			Inflation::on_initialize(1);
-			let block_inflation_year_0 = Inflation::block_inflation();
-
-			Inflation::on_initialize(YEAR);
-			let block_inflation_year_1 = Inflation::block_inflation();
-
-			// Assert that year 1 inflation is less than year 0
-			assert!(block_inflation_year_0 > block_inflation_year_1);
-		});
-	}
-
-	#[test]
-	fn inflation_in_1_to_9_years() {
-		new_test_ext().execute_with(|| {
-			// Total issuance = 1_000_000_000
-			let initial_issuance: u64 = 1_000_000_000;
-			let _ = <Balances as Currency<_>>::deposit_creating(&1234, initial_issuance);
-			assert_eq!(Balances::free_balance(1234), initial_issuance);
-			Inflation::on_initialize(1);
-
-			for year in 1..=9 {
-				let block_inflation_year_before = Inflation::block_inflation();
-				Inflation::on_initialize(YEAR * year);
-				let block_inflation_year_after = Inflation::block_inflation();
-
-				// Assert that next year inflation is less than previous year inflation
-				assert!(block_inflation_year_before > block_inflation_year_after);
-			}
-
-		});
-	}
-
-	#[test]
-	fn inflation_after_year_10_is_flat() {
-		new_test_ext().execute_with(|| {
-			// Total issuance = 1_000_000_000
-			let initial_issuance: u64 = 1_000_000_000;
-			let _ = <Balances as Currency<_>>::deposit_creating(&1234, initial_issuance);
-			assert_eq!(Balances::free_balance(1234), initial_issuance);
-			Inflation::on_initialize(YEAR * 9);
-
-			for year in 10..=20 {
-				let block_inflation_year_before = Inflation::block_inflation();
-				Inflation::on_initialize(YEAR * year);
-				let block_inflation_year_after = Inflation::block_inflation();
-
-				// Assert that next year inflation is equal to previous year inflation
-				assert_eq!(block_inflation_year_before, block_inflation_year_after);
-			}
-		});
-	}
-
-	#[test]
-	fn inflation_rate_by_year() {
-		new_test_ext().execute_with(|| {
-			let payouts: u64 = YEAR / InflationBlockInterval::get() as u64;
-
-			// Inflation starts at 10% and does down by 2/3% every year until year 9 (included), 
-			// then it is flat.
-			let payout_by_year: [u64; 11] = [
-				1000,
-				933,
-				867,
-				800,
-				733,
-				667,
-				600,
-				533,
-				467,
-				400,
-				400
-			];
-
-			// For accuracy total issuance = payout0 * payouts * 10;
-			let initial_issuance: u64 = payout_by_year[0] * payouts * 10;
-			let _ = <Balances as Currency<_>>::deposit_creating(&1234, initial_issuance);
-			assert_eq!(Balances::free_balance(1234), initial_issuance);
-
-			for year in 0..=10 {
-				// Year first block
-				Inflation::on_initialize(year*YEAR);
-				let mut actual_payout = Inflation::block_inflation();
-				assert_eq!(actual_payout, payout_by_year[year as usize]);
-
-				// Year second block
-				Inflation::on_initialize(year*YEAR+1);
-				actual_payout = Inflation::block_inflation();
-				assert_eq!(actual_payout, payout_by_year[year as usize]);
-
-				// Year middle block
-				Inflation::on_initialize(year*YEAR + YEAR/2);
-				actual_payout = Inflation::block_inflation();
-				assert_eq!(actual_payout, payout_by_year[year as usize]);
-
-				// Year last block
-				Inflation::on_initialize((year + 1)*YEAR-1);
-				actual_payout = Inflation::block_inflation();
-				assert_eq!(actual_payout, payout_by_year[year as usize]);
-			}
-		});
-	}
-}