mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-19 20:25:40 +00:00
[NFTs] Offchain mint (#13158)
* Allow to mint with the pre-signed signatures * Another try * WIP: test encoder * Fix the deposits * Refactoring + tests + benchmarks * Add sp-core/runtime-benchmarks * Remove sp-core from dev deps * Enable full_crypto for benchmarks * Typo * Fix * Update frame/nfts/src/mock.rs Co-authored-by: Squirrel <gilescope@gmail.com> * ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_nfts * Add docs * Add attributes into the pre-signed object & track the deposit owner for attributes * Update docs * ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_nfts * Add the number of attributes provided to weights * Apply suggestions * Remove dead code * Remove Copy * Fix docs * Update frame/nfts/src/lib.rs Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Update frame/nfts/src/lib.rs Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> --------- Co-authored-by: Squirrel <gilescope@gmail.com> Co-authored-by: command-bot <> Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
This commit is contained in:
@@ -60,14 +60,16 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
.saturating_add(T::MetadataDepositBase::get());
|
||||
}
|
||||
|
||||
// the previous deposit was taken from the item's owner
|
||||
if old_deposit.account.is_some() && maybe_depositor.is_none() {
|
||||
T::Currency::unreserve(&old_deposit.account.unwrap(), old_deposit.amount);
|
||||
T::Currency::reserve(&collection_details.owner, deposit)?;
|
||||
let depositor = maybe_depositor.clone().unwrap_or(collection_details.owner.clone());
|
||||
let old_depositor = old_deposit.account.unwrap_or(collection_details.owner.clone());
|
||||
|
||||
if depositor != old_depositor {
|
||||
T::Currency::unreserve(&old_depositor, old_deposit.amount);
|
||||
T::Currency::reserve(&depositor, deposit)?;
|
||||
} else if deposit > old_deposit.amount {
|
||||
T::Currency::reserve(&collection_details.owner, deposit - old_deposit.amount)?;
|
||||
T::Currency::reserve(&depositor, deposit - old_deposit.amount)?;
|
||||
} else if deposit < old_deposit.amount {
|
||||
T::Currency::unreserve(&collection_details.owner, old_deposit.amount - deposit);
|
||||
T::Currency::unreserve(&depositor, old_deposit.amount - deposit);
|
||||
}
|
||||
|
||||
if maybe_depositor.is_none() {
|
||||
@@ -191,4 +193,11 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
|
||||
/// A helper method to construct metadata.
|
||||
pub fn construct_metadata(
|
||||
metadata: Vec<u8>,
|
||||
) -> Result<BoundedVec<u8, T::StringLimit>, DispatchError> {
|
||||
Ok(BoundedVec::try_from(metadata).map_err(|_| Error::<T, I>::IncorrectMetadata)?)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user