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

difftreelog

Merge pull request #34 from usetech-llc/feature/NFTPAR-110_contract_spam

str-mv2020-12-11parents: #8f2e7cc #6f036ae.patch.diff
in: master
Fix contract stponsoring rate limit enforcement

1 file changed

modifiedpallets/nft/src/lib.rsdiffbeforeafterboth
387 // Contract Sponsorship and Ownership387 // Contract Sponsorship and Ownership
388 pub ContractOwner get(fn contract_owner): map hasher(twox_64_concat) T::AccountId => T::AccountId;388 pub ContractOwner get(fn contract_owner): map hasher(twox_64_concat) T::AccountId => T::AccountId;
389 pub ContractSelfSponsoring get(fn contract_self_sponsoring): map hasher(twox_64_concat) T::AccountId => bool;389 pub ContractSelfSponsoring get(fn contract_self_sponsoring): map hasher(twox_64_concat) T::AccountId => bool;
390 pub ContractSponsorBasket get(fn contract_sponsor_basket): map hasher(twox_64_concat) T::AccountId => T::BlockNumber;390 pub ContractSponsorBasket get(fn contract_sponsor_basket): map hasher(twox_64_concat) (T::AccountId, T::AccountId) => T::BlockNumber;
391 pub ContractSponsoringRateLimit get(fn contract_sponsoring_rate_limit): map hasher(twox_64_concat) T::AccountId => T::BlockNumber;391 pub ContractSponsoringRateLimit get(fn contract_sponsoring_rate_limit): map hasher(twox_64_concat) T::AccountId => T::BlockNumber;
392 }392 }
393 add_extra_genesis {393 add_extra_genesis {
23042304
2305 let mut sponsor_transfer = false;2305 let mut sponsor_transfer = false;
2306 if <ContractSponsoringRateLimit<T>>::contains_key(called_contract.clone()) {2306 if <ContractSponsoringRateLimit<T>>::contains_key(called_contract.clone()) {
2307 let last_tx_block = <ContractSponsorBasket<T>>::get(&called_contract);2307 let last_tx_block = <ContractSponsorBasket<T>>::get((&called_contract, &who));
2308 let block_number = <system::Module<T>>::block_number() as T::BlockNumber;2308 let block_number = <system::Module<T>>::block_number() as T::BlockNumber;
2309 let rate_limit = <ContractSponsoringRateLimit<T>>::get(&called_contract);2309 let rate_limit = <ContractSponsoringRateLimit<T>>::get(&called_contract);
2310 let limit_time = last_tx_block + rate_limit;2310 let limit_time = last_tx_block + rate_limit;
23112311
2312 if block_number >= limit_time {2312 if block_number >= limit_time {
2313 <ContractSponsorBasket<T>>::insert(called_contract.clone(), block_number);2313 <ContractSponsorBasket<T>>::insert((called_contract.clone(), who.clone()), block_number);
2314 sponsor_transfer = true;2314 sponsor_transfer = true;
2315 }2315 }
2316 } else {2316 } else {