Uniques: An economically-secure basic-featured NFT pallet (#8813)

* Uniques: An economically-secure basic-featured NFT pallet

* force_transfer

* freeze/thaw

* team management

* approvals

* Fixes

* force_asset_status

* class_metadata

* instance metadata

* Fixes

* use nmap

* Fixes

* class metadata has information field

* Intiial mock/tests and a fix

* Remove impl_non_fungibles

* Docs

* Update frame/uniques/src/lib.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* Update frame/uniques/src/lib.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* Update frame/uniques/src/lib.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* Update frame/uniques/src/lib.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* Reserve, don't transfer.

* Fixes

* Tests

* Tests

* refresh_deposit

* Tests and proper handling of metdata destruction

* test burn

* Tests

* Update impl_fungibles.rs

* Initial benchmarking

* benchmark

* Fixes

* cargo run --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_uniques --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/uniques/src/weights.rs --template=./.maintain/frame-weight-template.hbs

* Attributes

* Attribute metadata

* Fixes

* Update frame/uniques/README.md

* Docs

* Docs

* Docs

* Simple metadata

* Use BoundedVec

* cargo run --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_uniques --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/uniques/src/weights.rs --template=./.maintain/frame-weight-template.hbs

* Update frame/uniques/src/lib.rs

Co-authored-by: Lohann Paterno Coutinho Ferreira <developer@lohann.dev>

* Update frame/uniques/src/lib.rs

Co-authored-by: Lohann Paterno Coutinho Ferreira <developer@lohann.dev>

* Update frame/uniques/src/lib.rs

Co-authored-by: Lohann Paterno Coutinho Ferreira <developer@lohann.dev>

* Update frame/uniques/src/lib.rs

Co-authored-by: Lohann Paterno Coutinho Ferreira <developer@lohann.dev>

* Update frame/uniques/src/lib.rs

Co-authored-by: Lohann Paterno Coutinho Ferreira <developer@lohann.dev>

* Fixes

* Update frame/uniques/README.md

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>

* Update frame/uniques/README.md

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>

* Update frame/uniques/README.md

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>

* Docs

* Bump

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
Co-authored-by: Parity Bot <admin@parity.io>
Co-authored-by: Lohann Paterno Coutinho Ferreira <developer@lohann.dev>
Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>
This commit is contained in:
Gavin Wood
2021-06-01 17:03:13 +01:00
committed by GitHub
parent c408515501
commit e819fd03f9
17 changed files with 2973 additions and 15 deletions
+4 -4
View File
@@ -127,26 +127,26 @@ impl<T: Config<I>, I: 'static> fungibles::Unbalanced<T::AccountId> for Pallet<T,
});
}
fn decrease_balance(asset: T::AssetId, who: &T::AccountId, amount: Self::Balance)
-> Result<Self::Balance, DispatchError>
-> Result<Self::Balance, DispatchError>
{
let f = DebitFlags { keep_alive: false, best_effort: false };
Self::decrease_balance(asset, who, amount, f, |_, _| Ok(()))
}
fn decrease_balance_at_most(asset: T::AssetId, who: &T::AccountId, amount: Self::Balance)
-> Self::Balance
-> Self::Balance
{
let f = DebitFlags { keep_alive: false, best_effort: true };
Self::decrease_balance(asset, who, amount, f, |_, _| Ok(()))
.unwrap_or(Zero::zero())
}
fn increase_balance(asset: T::AssetId, who: &T::AccountId, amount: Self::Balance)
-> Result<Self::Balance, DispatchError>
-> Result<Self::Balance, DispatchError>
{
Self::increase_balance(asset, who, amount, |_| Ok(()))?;
Ok(amount)
}
fn increase_balance_at_most(asset: T::AssetId, who: &T::AccountId, amount: Self::Balance)
-> Self::Balance
-> Self::Balance
{
match Self::increase_balance(asset, who, amount, |_| Ok(())) {
Ok(()) => amount,
+7 -9
View File
@@ -417,8 +417,6 @@ pub mod pallet {
/// - `owner`: The owner of this class of assets. The owner has full superuser permissions
/// over this asset, but may later change and configure the permissions using `transfer_ownership`
/// and `set_team`.
/// - `max_zombies`: The total number of accounts which may hold assets in this class yet
/// have no existential deposit.
/// - `min_balance`: The minimum balance of this new asset that any single account must
/// have. If an account's balance is reduced below this, then it collapses to zero.
///
@@ -588,8 +586,8 @@ pub mod pallet {
/// to zero.
///
/// Weight: `O(1)`
/// Modes: Pre-existence of `target`; Post-existence of sender; Prior & post zombie-status
/// of sender; Account pre-existence of `target`.
/// Modes: Pre-existence of `target`; Post-existence of sender; Account pre-existence of
/// `target`.
#[pallet::weight(T::WeightInfo::transfer())]
pub(super) fn transfer(
origin: OriginFor<T>,
@@ -624,8 +622,8 @@ pub mod pallet {
/// to zero.
///
/// Weight: `O(1)`
/// Modes: Pre-existence of `target`; Post-existence of sender; Prior & post zombie-status
/// of sender; Account pre-existence of `target`.
/// Modes: Pre-existence of `target`; Post-existence of sender; Account pre-existence of
/// `target`.
#[pallet::weight(T::WeightInfo::transfer_keep_alive())]
pub(super) fn transfer_keep_alive(
origin: OriginFor<T>,
@@ -661,8 +659,8 @@ pub mod pallet {
/// to zero.
///
/// Weight: `O(1)`
/// Modes: Pre-existence of `dest`; Post-existence of `source`; Prior & post zombie-status
/// of `source`; Account pre-existence of `dest`.
/// Modes: Pre-existence of `dest`; Post-existence of `source`; Account pre-existence of
/// `dest`.
#[pallet::weight(T::WeightInfo::force_transfer())]
pub(super) fn force_transfer(
origin: OriginFor<T>,
@@ -779,7 +777,7 @@ pub mod pallet {
///
/// Origin must be Signed and the sender should be the Admin of the asset `id`.
///
/// - `id`: The identifier of the asset to be frozen.
/// - `id`: The identifier of the asset to be thawed.
///
/// Emits `Thawed`.
///