difftreelog
fix handle sponsoring for ERC721Mintable
in: master
2 files changed
pallets/unique/src/eth/sponsoring.rsdiffbeforeafterboth29use pallet_common::account::CrossAccountId;29use pallet_common::account::CrossAccountId;303031use pallet_nonfungible::erc::{UniqueNFTCall, ERC721UniqueExtensionsCall, ERC721Call};31use pallet_nonfungible::erc::{32 UniqueNFTCall, ERC721UniqueExtensionsCall, ERC721MintableCall, ERC721Call,33};32use pallet_fungible::erc::{UniqueFungibleCall, ERC20Call};34use pallet_fungible::erc::{UniqueFungibleCall, ERC20Call};333551 let token_id: TokenId = token_id.try_into().ok()?;53 let token_id: TokenId = token_id.try_into().ok()?;52 withdraw_transfer::<T>(&collection, &who, &token_id).map(|()| sponsor)54 withdraw_transfer::<T>(&collection, &who, &token_id).map(|()| sponsor)53 }55 }56 UniqueNFTCall::ERC721Mintable(57 ERC721MintableCall::Mint { token_id, .. }58 | ERC721MintableCall::MintWithTokenUri { token_id, .. },59 ) => {60 let _token_id: TokenId = token_id.try_into().ok()?;61 withdraw_create_item::<T>(62 &collection,63 who.as_sub(),64 &CreateItemData::NFT(CreateNftData::default()),65 )66 .map(|()| sponsor)67 }54 UniqueNFTCall::ERC721(ERC721Call::TransferFrom { token_id, from, .. }) => {68 UniqueNFTCall::ERC721(ERC721Call::TransferFrom { token_id, from, .. }) => {55 let token_id: TokenId = token_id.try_into().ok()?;69 let token_id: TokenId = token_id.try_into().ok()?;56 let from = T::CrossAccountId::from_eth(from);70 let from = T::CrossAccountId::from_eth(from);pallets/unique/src/sponsorship.rsdiffbeforeafterboth103103104pub fn withdraw_create_item<T: Config>(104pub fn withdraw_create_item<T: Config>(105 collection: &CollectionHandle<T>,105 collection: &CollectionHandle<T>,106 who: &T::AccountId,106 who: &T::CrossAccountId,107 _properties: &CreateItemData,107 _properties: &CreateItemData,108) -> Option<()> {108) -> Option<()> {109 if _properties.data_size() as u32 > collection.limits.sponsored_data_size() {109 if _properties.data_size() as u32 > collection.limits.sponsored_data_size() {120 CreateItemData::ReFungible(_) => REFUNGIBLE_SPONSOR_TRANSFER_TIMEOUT,120 CreateItemData::ReFungible(_) => REFUNGIBLE_SPONSOR_TRANSFER_TIMEOUT,121 });121 });122122123 if let Some(last_tx_block) = <CreateItemBasket<T>>::get((collection.id, &who)) {123 if let Some(last_tx_block) = <CreateItemBasket<T>>::get((collection.id, who.as_sub())) {124 let timeout = last_tx_block + limit.into();124 let timeout = last_tx_block + limit.into();125 if block_number < timeout {125 if block_number < timeout {126 return None;126 return None;127 }127 }128 }128 }129129130 CreateItemBasket::<T>::insert((collection.id, who.clone()), block_number);130 CreateItemBasket::<T>::insert((collection.id, who.as_sub()), block_number);131131132 Some(())132 Some(())133}133}