difftreelog
feat add ApproveFrom eth mirror
in: master
26 files changed
pallets/common/src/lib.rsdiffbeforeafterboth--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -746,6 +746,8 @@
ApprovedValueTooLow,
/// Tried to approve more than owned
CantApproveMoreThanOwned,
+ /// Only spending from eth mirror could be approved
+ AddressIsNotEthMirror,
/// Can't transfer tokens to ethereum zero address
AddressIsZero,
@@ -1797,6 +1799,9 @@
/// The price of setting the permission of the operation from another user.
fn approve() -> Weight;
+ /// The price of setting the permission of the operation from another user for eth mirror.
+ fn approve_from() -> Weight;
+
/// Transfer price from another user.
fn transfer_from() -> Weight;
@@ -2008,6 +2013,22 @@
amount: u128,
) -> DispatchResultWithPostInfo;
+ /// Grant access to another account to transfer parts of the token owned by the calling user's eth mirror via [Self::transfer_from].
+ ///
+ /// * `sender` - The user who grants access to the token.
+ /// * `from` - Spender's eth mirror.
+ /// * `to` - The user to whom the rights are granted.
+ /// * `token` - The token to which access is granted.
+ /// * `amount` - The amount of pieces that another user can dispose of.
+ fn approve_from(
+ &self,
+ sender: T::CrossAccountId,
+ from: T::CrossAccountId,
+ to: T::CrossAccountId,
+ token: TokenId,
+ amount: u128,
+ ) -> DispatchResultWithPostInfo;
+
/// Send parts of a token owned by another user.
///
/// Before calling this method, you must grant rights to the calling user via [`Self::approve`].
pallets/evm-contract-helpers/src/stubs/ContractHelpers.rawdiffbeforeafterbothbinary blob — no preview
pallets/evm-contract-helpers/src/stubs/ContractHelpers.soldiffbeforeafterboth--- a/pallets/evm-contract-helpers/src/stubs/ContractHelpers.sol
+++ b/pallets/evm-contract-helpers/src/stubs/ContractHelpers.sol
@@ -283,8 +283,8 @@
/// Ethereum representation of Optional value with CrossAddress.
struct OptionCrossAddress {
- /// TODO: field description
+ /// Whether or not this CrossAdress is valid and has meaning.
bool status;
- /// TODO: field description
+ /// The underlying CrossAddress value. If the status is false, can be set to whatever.
CrossAddress value;
}
pallets/fungible/src/benchmarking.rsdiffbeforeafterboth--- a/pallets/fungible/src/benchmarking.rs
+++ b/pallets/fungible/src/benchmarking.rs
@@ -82,6 +82,16 @@
<Pallet<T>>::create_item(&collection, &owner, (sender.clone(), 200), &Unlimited)?;
}: {<Pallet<T>>::set_allowance(&collection, &sender, &spender, 100)?}
+ approve_from {
+ bench_init!{
+ owner: sub; collection: collection(owner);
+ owner: cross_from_sub; sender: cross_sub; spender: cross_sub;
+
+ };
+ let owner_eth = T::CrossAccountId::from_eth(*sender.as_eth());
+ <Pallet<T>>::create_item(&collection, &owner, (owner_eth.clone(), 200), &Unlimited)?;
+ }: {<Pallet<T>>::set_allowance_for(&collection, &sender, &owner_eth, &spender, 100)?}
+
transfer_from {
bench_init!{
owner: sub; collection: collection(owner);
pallets/fungible/src/common.rsdiffbeforeafterboth--- a/pallets/fungible/src/common.rs
+++ b/pallets/fungible/src/common.rs
@@ -87,6 +87,10 @@
<SelfWeightOf<T>>::approve()
}
+ fn approve_from() -> Weight {
+ <SelfWeightOf<T>>::approve_from()
+ }
+
fn transfer_from() -> Weight {
<SelfWeightOf<T>>::transfer_from()
}
@@ -254,6 +258,25 @@
)
}
+ fn approve_from(
+ &self,
+ sender: T::CrossAccountId,
+ from: T::CrossAccountId,
+ to: T::CrossAccountId,
+ token: TokenId,
+ amount: u128,
+ ) -> DispatchResultWithPostInfo {
+ ensure!(
+ token == TokenId::default(),
+ <Error<T>>::FungibleItemsHaveNoId
+ );
+
+ with_weight(
+ <Pallet<T>>::set_allowance_for(self, &sender, &from, &to, amount),
+ <CommonWeights<T>>::approve_from(),
+ )
+ }
+
fn transfer_from(
&self,
sender: T::CrossAccountId,
pallets/fungible/src/lib.rsdiffbeforeafterboth--- a/pallets/fungible/src/lib.rs
+++ b/pallets/fungible/src/lib.rs
@@ -613,6 +613,45 @@
Ok(())
}
+ /// Set allowance for the spender to `transfer` or `burn` owner's tokens from eth mirror.
+ ///
+ /// - `collection`: Collection that contains the token
+ /// - `sender`: Owner of tokens that sets the allowance.
+ /// - `from`: Owner's eth mirror.
+ /// - `to`: Recipient of the allowance rights.
+ /// - `amount`: Amount of tokens the spender is allowed to `transfer` or `burn`.
+ pub fn set_allowance_for(
+ collection: &FungibleHandle<T>,
+ sender: &T::CrossAccountId,
+ from: &T::CrossAccountId,
+ to: &T::CrossAccountId,
+ amount: u128,
+ ) -> DispatchResult {
+ if collection.permissions.access() == AccessMode::AllowList {
+ collection.check_allowlist(sender)?;
+ collection.check_allowlist(from)?;
+ collection.check_allowlist(to)?;
+ }
+
+ ensure!(
+ *sender.as_eth() == *from.as_eth(),
+ <CommonError<T>>::AddressIsNotEthMirror
+ );
+
+ if <Balance<T>>::get((collection.id, from)) < amount {
+ ensure!(
+ collection.limits.owner_can_transfer()
+ && (collection.is_owner_or_admin(sender) || collection.is_owner_or_admin(from)),
+ <CommonError<T>>::CantApproveMoreThanOwned
+ );
+ }
+
+ // =========
+
+ Self::set_allowance_unchecked(collection, from, to, amount);
+ Ok(())
+ }
+
/// Checks if a non-owner has (enough) allowance from the owner to perform operations on the tokens.
/// Returns the expected remaining allowance - it should be set manually if the transaction proceeds.
///
pallets/fungible/src/weights.rsdiffbeforeafterboth--- a/pallets/fungible/src/weights.rs
+++ b/pallets/fungible/src/weights.rs
@@ -39,6 +39,7 @@
fn burn_item() -> Weight;
fn transfer() -> Weight;
fn approve() -> Weight;
+ fn approve_from() -> Weight;
fn transfer_from() -> Weight;
fn burn_from() -> Weight;
}
@@ -84,6 +85,13 @@
.saturating_add(T::DbWeight::get().reads(1 as u64))
.saturating_add(T::DbWeight::get().writes(1 as u64))
}
+ // Storage: Fungible Balance (r:1 w:0)
+ // Storage: Fungible Allowance (r:0 w:1)
+ fn approve_from() -> Weight {
+ Weight::from_ref_time(19_817_000 as u64)
+ .saturating_add(T::DbWeight::get().reads(1 as u64))
+ .saturating_add(T::DbWeight::get().writes(1 as u64))
+ }
// Storage: Fungible Allowance (r:1 w:1)
// Storage: Fungible Balance (r:2 w:2)
fn transfer_from() -> Weight {
@@ -141,6 +149,13 @@
.saturating_add(RocksDbWeight::get().reads(1 as u64))
.saturating_add(RocksDbWeight::get().writes(1 as u64))
}
+ // Storage: Fungible Balance (r:1 w:0)
+ // Storage: Fungible Allowance (r:0 w:1)
+ fn approve_from() -> Weight {
+ Weight::from_ref_time(19_817_000 as u64)
+ .saturating_add(RocksDbWeight::get().reads(1 as u64))
+ .saturating_add(RocksDbWeight::get().writes(1 as u64))
+ }
// Storage: Fungible Allowance (r:1 w:1)
// Storage: Fungible Balance (r:2 w:2)
fn transfer_from() -> Weight {
pallets/nonfungible/src/benchmarking.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/benchmarking.rs
+++ b/pallets/nonfungible/src/benchmarking.rs
@@ -134,6 +134,15 @@
let item = create_max_item(&collection, &owner, sender.clone())?;
}: {<Pallet<T>>::set_allowance(&collection, &sender, item, Some(&spender))?}
+ approve_from {
+ bench_init!{
+ owner: sub; collection: collection(owner);
+ owner: cross_from_sub; sender: cross_sub; spender: cross_sub;
+ };
+ let owner_eth = T::CrossAccountId::from_eth(*sender.as_eth());
+ let item = create_max_item(&collection, &owner, owner_eth.clone())?;
+ }: {<Pallet<T>>::set_allowance_for(&collection, &sender, &owner_eth, item, Some(&spender))?}
+
transfer_from {
bench_init!{
owner: sub; collection: collection(owner);
pallets/nonfungible/src/common.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/common.rs
+++ b/pallets/nonfungible/src/common.rs
@@ -102,6 +102,10 @@
<SelfWeightOf<T>>::approve()
}
+ fn approve_from() -> Weight {
+ <SelfWeightOf<T>>::approve_from()
+ }
+
fn transfer_from() -> Weight {
<SelfWeightOf<T>>::transfer_from()
}
@@ -353,6 +357,26 @@
)
}
+ fn approve_from(
+ &self,
+ sender: T::CrossAccountId,
+ from: T::CrossAccountId,
+ to: T::CrossAccountId,
+ token: TokenId,
+ amount: u128,
+ ) -> DispatchResultWithPostInfo {
+ ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);
+
+ with_weight(
+ if amount == 1 {
+ <Pallet<T>>::set_allowance_for(self, &sender, &from, token, Some(&to))
+ } else {
+ <Pallet<T>>::set_allowance_for(self, &sender, &from, token, None)
+ },
+ <CommonWeights<T>>::approve_from(),
+ )
+ }
+
fn transfer_from(
&self,
sender: T::CrossAccountId,
pallets/nonfungible/src/lib.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/lib.rs
+++ b/pallets/nonfungible/src/lib.rs
@@ -1171,6 +1171,51 @@
Ok(())
}
+ /// Set allowance for the spender to `transfer` or `burn` sender's token from eth mirror.
+ ///
+ /// - `from`: Address of sender's eth mirror.
+ /// - `to`: Adress of spender.
+ /// - `token`: Token the spender is allowed to `transfer` or `burn`.
+ pub fn set_allowance_for(
+ collection: &NonfungibleHandle<T>,
+ sender: &T::CrossAccountId,
+ from: &T::CrossAccountId,
+ token: TokenId,
+ to: Option<&T::CrossAccountId>,
+ ) -> DispatchResult {
+ if collection.permissions.access() == AccessMode::AllowList {
+ collection.check_allowlist(sender)?;
+ collection.check_allowlist(from)?;
+ if let Some(to) = to {
+ collection.check_allowlist(to)?;
+ }
+ }
+
+ if let Some(to) = to {
+ <PalletCommon<T>>::ensure_correct_receiver(to)?;
+ }
+
+ ensure!(
+ *sender.as_eth() == *from.as_eth(),
+ <CommonError<T>>::AddressIsNotEthMirror
+ );
+
+ let token_data =
+ <TokenData<T>>::get((collection.id, token)).ok_or(<CommonError<T>>::TokenNotFound)?;
+ if token_data.owner != *from {
+ ensure!(
+ collection.limits.owner_can_transfer()
+ && (collection.is_owner_or_admin(sender) || collection.is_owner_or_admin(from)),
+ <CommonError<T>>::CantApproveMoreThanOwned
+ );
+ }
+
+ // =========
+
+ Self::set_allowance_unchecked(collection, from, token, to, false);
+ Ok(())
+ }
+
/// Checks allowance for the spender to use the token.
fn check_allowed(
collection: &NonfungibleHandle<T>,
pallets/nonfungible/src/weights.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/weights.rs
+++ b/pallets/nonfungible/src/weights.rs
@@ -42,6 +42,7 @@
fn burn_recursively_breadth_plus_self_plus_self_per_each_raw(b: u32, ) -> Weight;
fn transfer() -> Weight;
fn approve() -> Weight;
+ fn approve_from() -> Weight;
fn transfer_from() -> Weight;
fn burn_from() -> Weight;
fn set_token_property_permissions(b: u32, ) -> Weight;
@@ -147,6 +148,13 @@
.saturating_add(T::DbWeight::get().reads(2 as u64))
.saturating_add(T::DbWeight::get().writes(1 as u64))
}
+ // Storage: Nonfungible TokenData (r:1 w:0)
+ // Storage: Nonfungible Allowance (r:1 w:1)
+ fn approve_from() -> Weight {
+ Weight::from_ref_time(18_965_000 as u64)
+ .saturating_add(T::DbWeight::get().reads(2 as u64))
+ .saturating_add(T::DbWeight::get().writes(1 as u64))
+ }
// Storage: Nonfungible Allowance (r:1 w:1)
// Storage: Nonfungible TokenData (r:1 w:1)
// Storage: Nonfungible AccountBalance (r:2 w:2)
@@ -310,6 +318,13 @@
.saturating_add(RocksDbWeight::get().reads(2 as u64))
.saturating_add(RocksDbWeight::get().writes(1 as u64))
}
+ // Storage: Nonfungible TokenData (r:1 w:0)
+ // Storage: Nonfungible Allowance (r:1 w:1)
+ fn approve_from() -> Weight {
+ Weight::from_ref_time(18_965_000 as u64)
+ .saturating_add(RocksDbWeight::get().reads(2 as u64))
+ .saturating_add(RocksDbWeight::get().writes(1 as u64))
+ }
// Storage: Nonfungible Allowance (r:1 w:1)
// Storage: Nonfungible TokenData (r:1 w:1)
// Storage: Nonfungible AccountBalance (r:2 w:2)
pallets/refungible/src/benchmarking.rsdiffbeforeafterboth--- a/pallets/refungible/src/benchmarking.rs
+++ b/pallets/refungible/src/benchmarking.rs
@@ -163,6 +163,15 @@
let item = create_max_item(&collection, &owner, [(sender.clone(), 200)])?;
}: {<Pallet<T>>::set_allowance(&collection, &sender, &spender, item, 100)?}
+ approve_from {
+ bench_init!{
+ owner: sub; collection: collection(owner);
+ owner: cross_from_sub; sender: cross_sub; spender: cross_sub;
+ };
+ let owner_eth = T::CrossAccountId::from_eth(*sender.as_eth());
+ let item = create_max_item(&collection, &owner, [(owner_eth.clone(), 200)])?;
+ }: {<Pallet<T>>::set_allowance_for(&collection, &sender, &owner_eth, &spender, item, 100)?}
+
transfer_from_normal {
bench_init!{
owner: sub; collection: collection(owner);
pallets/refungible/src/common.rsdiffbeforeafterboth--- a/pallets/refungible/src/common.rs
+++ b/pallets/refungible/src/common.rs
@@ -127,6 +127,10 @@
<SelfWeightOf<T>>::approve()
}
+ fn approve_from() -> Weight {
+ <SelfWeightOf<T>>::approve_from()
+ }
+
fn transfer_from() -> Weight {
max_weight_of!(
transfer_from_normal(),
@@ -314,6 +318,20 @@
)
}
+ fn approve_from(
+ &self,
+ sender: T::CrossAccountId,
+ from: T::CrossAccountId,
+ to: T::CrossAccountId,
+ token_id: TokenId,
+ amount: u128,
+ ) -> DispatchResultWithPostInfo {
+ with_weight(
+ <Pallet<T>>::set_allowance_for(self, &sender, &from, &to, token_id, amount),
+ <CommonWeights<T>>::approve_from(),
+ )
+ }
+
fn transfer_from(
&self,
sender: T::CrossAccountId,
pallets/refungible/src/lib.rsdiffbeforeafterboth--- a/pallets/refungible/src/lib.rs
+++ b/pallets/refungible/src/lib.rs
@@ -1102,6 +1102,47 @@
Ok(())
}
+ /// Set allowance to spend from sender's eth mirror
+ ///
+ /// - `from`: Address of sender's eth mirror.
+ /// - `to`: Adress of spender.
+ /// - `amount`: Amount of token pieces the spender is allowed to `transfer` or `burn.
+ pub fn set_allowance_for(
+ collection: &RefungibleHandle<T>,
+ sender: &T::CrossAccountId,
+ from: &T::CrossAccountId,
+ to: &T::CrossAccountId,
+ token_id: TokenId,
+ amount: u128,
+ ) -> DispatchResult {
+ if collection.permissions.access() == AccessMode::AllowList {
+ collection.check_allowlist(sender)?;
+ collection.check_allowlist(from)?;
+ collection.check_allowlist(to)?;
+ }
+
+ <PalletCommon<T>>::ensure_correct_receiver(to)?;
+
+ ensure!(
+ *sender.as_eth() == *from.as_eth(),
+ <CommonError<T>>::AddressIsNotEthMirror
+ );
+
+ if <Balance<T>>::get((collection.id, token_id, from)) < amount {
+ ensure!(
+ collection.limits.owner_can_transfer()
+ && (collection.is_owner_or_admin(sender) || collection.is_owner_or_admin(from))
+ && Self::token_exists(collection, token_id),
+ <CommonError<T>>::CantApproveMoreThanOwned
+ );
+ }
+
+ // =========
+
+ Self::set_allowance_unchecked(collection, from, to, token_id, amount);
+ Ok(())
+ }
+
/// Returns allowance, which should be set after transaction
fn check_allowed(
collection: &RefungibleHandle<T>,
pallets/refungible/src/weights.rsdiffbeforeafterboth--- a/pallets/refungible/src/weights.rs
+++ b/pallets/refungible/src/weights.rs
@@ -45,6 +45,7 @@
fn transfer_removing() -> Weight;
fn transfer_creating_removing() -> Weight;
fn approve() -> Weight;
+ fn approve_from() -> Weight;
fn transfer_from_normal() -> Weight;
fn transfer_from_creating() -> Weight;
fn transfer_from_removing() -> Weight;
@@ -175,6 +176,13 @@
.saturating_add(T::DbWeight::get().reads(1 as u64))
.saturating_add(T::DbWeight::get().writes(1 as u64))
}
+ // Storage: Refungible Balance (r:1 w:0)
+ // Storage: Refungible Allowance (r:0 w:1)
+ fn approve_from() -> Weight {
+ Weight::from_ref_time(20_649_000 as u64)
+ .saturating_add(T::DbWeight::get().reads(1 as u64))
+ .saturating_add(T::DbWeight::get().writes(1 as u64))
+ }
// Storage: Refungible Allowance (r:1 w:1)
// Storage: Refungible CollectionAllowance (r:1 w:0)
// Storage: Refungible Balance (r:2 w:2)
@@ -400,6 +408,13 @@
.saturating_add(RocksDbWeight::get().reads(1 as u64))
.saturating_add(RocksDbWeight::get().writes(1 as u64))
}
+ // Storage: Refungible Balance (r:1 w:0)
+ // Storage: Refungible Allowance (r:0 w:1)
+ fn approve_from() -> Weight {
+ Weight::from_ref_time(20_649_000 as u64)
+ .saturating_add(RocksDbWeight::get().reads(1 as u64))
+ .saturating_add(RocksDbWeight::get().writes(1 as u64))
+ }
// Storage: Refungible Allowance (r:1 w:1)
// Storage: Refungible CollectionAllowance (r:1 w:0)
// Storage: Refungible Balance (r:2 w:2)
pallets/unique/src/lib.rsdiffbeforeafterboth--- a/pallets/unique/src/lib.rs
+++ b/pallets/unique/src/lib.rs
@@ -851,6 +851,29 @@
dispatch_tx::<T, _>(collection_id, |d| d.approve(sender, spender, item_id, amount))
}
+ /// Allow a non-permissioned address to transfer or burn an item from owner's eth mirror.
+ ///
+ /// # Permissions
+ ///
+ /// * Collection owner
+ /// * Collection admin
+ /// * Current item owner
+ ///
+ /// # Arguments
+ ///
+ /// * `from`: Owner's account eth mirror
+ /// * `to`: Account to be approved to make specific transactions on non-owned tokens.
+ /// * `collection_id`: ID of the collection the item belongs to.
+ /// * `item_id`: ID of the item transactions on which are now approved.
+ /// * `amount`: Number of pieces of the item approved for a transaction (maximum of 1 for NFTs).
+ /// Set to 0 to revoke the approval.
+ #[weight = T::CommonWeightInfo::approve_from()]
+ pub fn approve_from(origin, from:T::CrossAccountId, to: T::CrossAccountId, collection_id: CollectionId, item_id: TokenId, amount: u128) -> DispatchResultWithPostInfo {
+ let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
+
+ dispatch_tx::<T, _>(collection_id, |d| d.approve_from(sender, from, to, item_id, amount))
+ }
+
/// Change ownership of an item on behalf of the owner as a non-owner account.
///
/// See the [`approve`][`Pallet::approve`] method for additional information.
runtime/common/identity.rsdiffbeforeafterboth--- a/runtime/common/identity.rs
+++ b/runtime/common/identity.rs
@@ -21,9 +21,7 @@
use sp_runtime::{
traits::{DispatchInfoOf, SignedExtension},
- transaction_validity::{
- TransactionValidity, ValidTransaction, InvalidTransaction, TransactionValidityError,
- },
+ transaction_validity::{TransactionValidity, ValidTransaction, TransactionValidityError},
};
#[derive(Debug, Encode, Decode, PartialEq, Eq, Clone, TypeInfo)]
runtime/common/weights.rsdiffbeforeafterboth--- a/runtime/common/weights.rs
+++ b/runtime/common/weights.rs
@@ -101,6 +101,10 @@
dispatch_weight::<T>() + max_weight_of!(approve())
}
+ fn approve_from() -> Weight {
+ dispatch_weight::<T>() + max_weight_of!(approve_from())
+ }
+
fn transfer_from() -> Weight {
dispatch_weight::<T>() + max_weight_of!(transfer_from())
}
tests/src/approve.test.tsdiffbeforeafterboth--- a/tests/src/approve.test.ts
+++ b/tests/src/approve.test.ts
@@ -16,336 +16,521 @@
import {IKeyringPair} from '@polkadot/types/types';
import {expect, itSub, Pallets, usingPlaygrounds} from './util';
+import {CrossAccountId} from './util/playgrounds/unique';
+
-describe('Integration Test approve(spender, collection_id, item_id, amount):', () => {
- let alice: IKeyringPair;
- let bob: IKeyringPair;
- let charlie: IKeyringPair;
+[
+ {method: 'approveToken', account: (account: IKeyringPair) => CrossAccountId.fromKeyring(account)},
+ {method: 'approveTokenFromEth', account: (account: IKeyringPair) => CrossAccountId.fromKeyring(account).toEthereum()},
+].map(testCase => {
+ describe(`Integration Test ${testCase.method}(spender, collection_id, item_id, amount):`, () => {
+ let alice: IKeyringPair;
+ let bob: IKeyringPair;
+ let charlie: IKeyringPair;
- before(async () => {
- await usingPlaygrounds(async (helper, privateKey) => {
- const donor = await privateKey({filename: __filename});
- [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);
+ before(async () => {
+ await usingPlaygrounds(async (helper, privateKey) => {
+ const donor = await privateKey({filename: __filename});
+ [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);
+ });
});
- });
- itSub('[nft] Execute the extrinsic and check approvedList', async ({helper}) => {
- const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
- const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});
- await helper.nft.approveToken(alice, collectionId, tokenId, {Substrate: bob.address});
- expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: bob.address})).to.be.true;
- });
+ itSub('[nft] Execute the extrinsic and check approvedList', async ({helper}) => {
+ const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
+ const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: testCase.account(alice)});
+ await (helper.nft as any)[testCase.method](alice, collectionId, tokenId, {Substrate: bob.address});
+ expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: bob.address})).to.be.true;
+ });
+
+ itSub('[fungible] Execute the extrinsic and check approvedList', async ({helper}) => {
+ const {collectionId} = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}, 0);
+ await helper.ft.mintTokens(alice, collectionId, 10n, testCase.account(alice));
+ const tokenId = await helper.ft.getLastTokenId(collectionId);
+ await (helper.ft as any)[testCase.method](alice, collectionId, tokenId, {Substrate: bob.address});
+ const amount = await helper.ft.getTokenApprovedPieces(collectionId, tokenId, {Substrate: bob.address}, testCase.account(alice));
+ expect(amount).to.be.equal(BigInt(1));
+ });
+
+ itSub.ifWithPallets('[refungible] Execute the extrinsic and check approvedList', [Pallets.ReFungible], async ({helper}) => {
+ const {collectionId} = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
+ const {tokenId} = await helper.rft.mintToken(alice, {collectionId: collectionId, owner: testCase.account(alice), pieces: 100n});
+ await (helper.rft as any)[testCase.method](alice, collectionId, tokenId, {Substrate: bob.address});
+ const amount = await helper.rft.getTokenApprovedPieces(collectionId, tokenId, {Substrate: bob.address}, testCase.account(alice));
+ expect(amount).to.be.equal(BigInt(1));
+ });
+
+ itSub('[nft] Remove approval by using 0 amount', async ({helper}) => {
+ const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
+ const collectionId = collection.collectionId;
+ const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: testCase.account(alice)});
+ await (helper.nft as any)[testCase.method](alice, collectionId, tokenId, {Substrate: bob.address});
+ expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: bob.address})).to.be.true;
+ await (helper.nft as any)[testCase.method](alice, collectionId, tokenId, {Substrate: bob.address}, 0n);
+ expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: bob.address})).to.be.false;
+ });
- itSub('[fungible] Execute the extrinsic and check approvedList', async ({helper}) => {
- const {collectionId} = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}, 0);
- await helper.ft.mintTokens(alice, collectionId, 10n, {Substrate: alice.address});
- const tokenId = await helper.ft.getLastTokenId(collectionId);
- await helper.ft.approveToken(alice, collectionId, tokenId, {Substrate: bob.address});
- const amount = await helper.ft.getTokenApprovedPieces(collectionId, tokenId, {Substrate: bob.address}, {Substrate: alice.address});
- expect(amount).to.be.equal(BigInt(1));
- });
+ itSub('[fungible] Remove approval by using 0 amount', async ({helper}) => {
+ const {collectionId} = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}, 0);
+ await helper.ft.mintTokens(alice, collectionId, 10n, testCase.account(alice));
+ const tokenId = await helper.ft.getLastTokenId(collectionId);
+ await (helper.ft as any)[testCase.method](alice, collectionId, tokenId, {Substrate: bob.address});
+ const amountBefore = await helper.ft.getTokenApprovedPieces(collectionId, tokenId, {Substrate: bob.address}, testCase.account(alice));
+ expect(amountBefore).to.be.equal(BigInt(1));
- itSub.ifWithPallets('[refungible] Execute the extrinsic and check approvedList', [Pallets.ReFungible], async ({helper}) => {
- const {collectionId} = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
- const {tokenId} = await helper.rft.mintToken(alice, {collectionId: collectionId, owner: alice.address, pieces: 100n});
- await helper.rft.approveToken(alice, collectionId, tokenId, {Substrate: bob.address});
- const amount = await helper.rft.getTokenApprovedPieces(collectionId, tokenId, {Substrate: bob.address}, {Substrate: alice.address});
- expect(amount).to.be.equal(BigInt(1));
- });
+ await (helper.ft as any)[testCase.method](alice, collectionId, tokenId, {Substrate: bob.address}, 0n);
+ const amountAfter = await helper.ft.getTokenApprovedPieces(collectionId, tokenId, {Substrate: bob.address}, testCase.account(alice));
+ expect(amountAfter).to.be.equal(BigInt(0));
+ });
- itSub('[nft] Remove approval by using 0 amount', async ({helper}) => {
- const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
- const collectionId = collection.collectionId;
- const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});
- await helper.nft.approveToken(alice, collectionId, tokenId, {Substrate: bob.address});
- expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: bob.address})).to.be.true;
- await helper.signTransaction(alice, helper.constructApiCall('api.tx.unique.approve', [{Substrate: bob.address}, collectionId, tokenId, 0]));
- expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: bob.address})).to.be.false;
- });
+ itSub.ifWithPallets('[refungible] Remove approval by using 0 amount', [Pallets.ReFungible], async ({helper}) => {
+ const {collectionId} = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
+ const {tokenId} = await helper.rft.mintToken(alice, {collectionId: collectionId, owner: testCase.account(alice), pieces: 100n});
+ await (helper.rft as any)[testCase.method](alice, collectionId, tokenId, {Substrate: bob.address});
+ const amountBefore = await helper.rft.getTokenApprovedPieces(collectionId, tokenId, {Substrate: bob.address}, testCase.account(alice));
+ expect(amountBefore).to.be.equal(BigInt(1));
- itSub('[fungible] Remove approval by using 0 amount', async ({helper}) => {
- const {collectionId} = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}, 0);
- await helper.ft.mintTokens(alice, collectionId, 10n, {Substrate: alice.address});
- const tokenId = await helper.ft.getLastTokenId(collectionId);
- await helper.ft.approveToken(alice, collectionId, tokenId, {Substrate: bob.address});
- const amountBefore = await helper.ft.getTokenApprovedPieces(collectionId, tokenId, {Substrate: bob.address}, {Substrate: alice.address});
- expect(amountBefore).to.be.equal(BigInt(1));
+ await (helper.rft as any)[testCase.method](alice, collectionId, tokenId, {Substrate: bob.address}, 0n);
+ const amountAfter = await helper.rft.getTokenApprovedPieces(collectionId, tokenId, {Substrate: bob.address}, testCase.account(alice));
+ expect(amountAfter).to.be.equal(BigInt(0));
+ });
- await helper.ft.approveToken(alice, collectionId, tokenId, {Substrate: bob.address}, 0n);
- const amountAfter = await helper.ft.getTokenApprovedPieces(collectionId, tokenId, {Substrate: bob.address}, {Substrate: alice.address});
- expect(amountAfter).to.be.equal(BigInt(0));
+ itSub('can`t be called by collection owner on non-owned item when OwnerCanTransfer == false', async ({helper}) => {
+ const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
+ const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: testCase.account(bob)});
+ const result = (helper.nft as any)[testCase.method](alice, collectionId, tokenId, {Substrate: charlie.address});
+ await expect(result).to.be.rejected;
+ });
});
- itSub.ifWithPallets('[refungible] Remove approval by using 0 amount', [Pallets.ReFungible], async ({helper}) => {
- const {collectionId} = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
- const {tokenId} = await helper.rft.mintToken(alice, {collectionId: collectionId, owner: alice.address, pieces: 100n});
- await helper.rft.approveToken(alice, collectionId, tokenId, {Substrate: bob.address});
- const amountBefore = await helper.rft.getTokenApprovedPieces(collectionId, tokenId, {Substrate: bob.address}, {Substrate: alice.address});
- expect(amountBefore).to.be.equal(BigInt(1));
+ describe(`[${testCase.method}] Normal user can approve other users to transfer:`, () => {
+ let alice: IKeyringPair;
+ let bob: IKeyringPair;
+ let charlie: IKeyringPair;
- await helper.rft.approveToken(alice, collectionId, tokenId, {Substrate: bob.address}, 0n);
- const amountAfter = await helper.rft.getTokenApprovedPieces(collectionId, tokenId, {Substrate: bob.address}, {Substrate: alice.address});
- expect(amountAfter).to.be.equal(BigInt(0));
- });
+ before(async () => {
+ await usingPlaygrounds(async (helper, privateKey) => {
+ const donor = await privateKey({filename: __filename});
+ [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);
+ });
+ });
- itSub('can`t be called by collection owner on non-owned item when OwnerCanTransfer == false', async ({helper}) => {
- const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
- const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: bob.address});
- const approveTokenTx = () => helper.nft.approveToken(alice, collectionId, tokenId, {Substrate: charlie.address});
- await expect(approveTokenTx()).to.be.rejected;
- });
-});
+ itSub('NFT', async ({helper}) => {
+ const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
+ const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: testCase.account(bob)});
+ await (helper.nft as any)[testCase.method](bob, collectionId, tokenId, {Substrate: charlie.address});
+ expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: charlie.address})).to.be.true;
+ });
-describe('Normal user can approve other users to transfer:', () => {
- let alice: IKeyringPair;
- let bob: IKeyringPair;
- let charlie: IKeyringPair;
+ itSub('Fungible up to an approved amount', async ({helper}) => {
+ const {collectionId} = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}, 0);
+ await helper.ft.mintTokens(alice, collectionId, 10n, testCase.account(bob));
+ const tokenId = await helper.ft.getLastTokenId(collectionId);
+ await (helper.ft as any)[testCase.method](bob, collectionId, tokenId, {Substrate: charlie.address});
+ const amount = await helper.ft.getTokenApprovedPieces(collectionId, tokenId, {Substrate: charlie.address}, testCase.account(bob));
+ expect(amount).to.be.equal(BigInt(1));
+ });
- before(async () => {
- await usingPlaygrounds(async (helper, privateKey) => {
- const donor = await privateKey({filename: __filename});
- [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);
+ itSub.ifWithPallets('ReFungible up to an approved amount', [Pallets.ReFungible], async ({helper}) => {
+ const {collectionId} = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
+ const {tokenId} = await helper.rft.mintToken(alice, {collectionId: collectionId, owner: testCase.account(bob), pieces: 100n});
+ await (helper.rft as any)[testCase.method](bob, collectionId, tokenId, {Substrate: charlie.address}, 100n);
+ const amount = await helper.rft.getTokenApprovedPieces(collectionId, tokenId, {Substrate: charlie.address}, testCase.account(bob));
+ expect(amount).to.be.equal(BigInt(100n));
});
});
- itSub('NFT', async ({helper}) => {
- const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
- const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: bob.address});
- await helper.nft.approveToken(bob, collectionId, tokenId, {Substrate: charlie.address});
- expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: charlie.address})).to.be.true;
- });
+ describe(`[${testCase.method}] Approved users can transferFrom up to approved amount:`, () => {
+ let alice: IKeyringPair;
+ let bob: IKeyringPair;
+ let charlie: IKeyringPair;
- itSub('Fungible up to an approved amount', async ({helper}) => {
- const {collectionId} = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}, 0);
- await helper.ft.mintTokens(alice, collectionId, 10n, bob.address);
- const tokenId = await helper.ft.getLastTokenId(collectionId);
- await helper.ft.approveToken(bob, collectionId, tokenId, {Substrate: charlie.address});
- const amount = await helper.ft.getTokenApprovedPieces(collectionId, tokenId, {Substrate: charlie.address}, {Substrate: bob.address});
- expect(amount).to.be.equal(BigInt(1));
- });
+ before(async () => {
+ await usingPlaygrounds(async (helper, privateKey) => {
+ const donor = await privateKey({filename: __filename});
+ [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);
+ });
+ });
- itSub.ifWithPallets('ReFungible up to an approved amount', [Pallets.ReFungible], async ({helper}) => {
- const {collectionId} = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
- const {tokenId} = await helper.rft.mintToken(alice, {collectionId: collectionId, owner: bob.address, pieces: 100n});
- await helper.rft.approveToken(bob, collectionId, tokenId, {Substrate: charlie.address}, 100n);
- const amount = await helper.rft.getTokenApprovedPieces(collectionId, tokenId, {Substrate: charlie.address}, {Substrate: bob.address});
- expect(amount).to.be.equal(BigInt(100n));
+ itSub('NFT', async ({helper}) => {
+ const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
+ const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: testCase.account(bob)});
+ await (helper.nft as any)[testCase.method](bob, collectionId, tokenId, {Substrate: charlie.address});
+ await helper.nft.transferTokenFrom(charlie, collectionId, tokenId, testCase.account(bob), {Substrate: alice.address});
+ const owner = await helper.nft.getTokenOwner(collectionId, tokenId);
+ expect(owner.Substrate).to.be.equal(alice.address);
+ });
+
+ itSub('Fungible up to an approved amount', async ({helper}) => {
+ const {collectionId} = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}, 0);
+ await helper.ft.mintTokens(alice, collectionId, 10n, testCase.account(bob));
+ const tokenId = await helper.ft.getLastTokenId(collectionId);
+ await (helper.ft as any)[testCase.method](bob, collectionId, tokenId, {Substrate: charlie.address});
+ const before = await helper.ft.getBalance(collectionId, {Substrate: alice.address});
+ await helper.ft.transferTokenFrom(charlie, collectionId, tokenId, testCase.account(bob), {Substrate: alice.address}, 1n);
+ const after = await helper.ft.getBalance(collectionId, {Substrate: alice.address});
+ expect(after - before).to.be.equal(BigInt(1));
+ });
+
+ itSub.ifWithPallets('ReFungible up to an approved amount', [Pallets.ReFungible], async ({helper}) => {
+ const {collectionId} = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
+ const {tokenId} = await helper.rft.mintToken(alice, {collectionId: collectionId, owner: testCase.account(bob), pieces: 100n});
+ await (helper.rft as any)[testCase.method](bob, collectionId, tokenId, {Substrate: charlie.address});
+ const before = await helper.rft.getTokenBalance(collectionId, tokenId, {Substrate: alice.address});
+ await helper.rft.transferTokenFrom(charlie, collectionId, tokenId, testCase.account(bob), {Substrate: alice.address}, 1n);
+ const after = await helper.rft.getTokenBalance(collectionId, tokenId, {Substrate: alice.address});
+ expect(after - before).to.be.equal(BigInt(1));
+ });
});
-});
-describe('Approved users can transferFrom up to approved amount:', () => {
- let alice: IKeyringPair;
- let bob: IKeyringPair;
- let charlie: IKeyringPair;
+ describe(`[${testCase.method}] Approved users cannot use transferFrom to repeat transfers if approved amount was already transferred:`, () => {
+ let alice: IKeyringPair;
+ let bob: IKeyringPair;
+ let charlie: IKeyringPair;
+
+ before(async () => {
+ await usingPlaygrounds(async (helper, privateKey) => {
+ const donor = await privateKey({filename: __filename});
+ [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);
+ });
+ });
+
+ itSub('NFT', async ({helper}) => {
+ const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
+ const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: testCase.account(bob)});
+ await (helper.nft as any)[testCase.method](bob, collectionId, tokenId, {Substrate: charlie.address});
+ await helper.nft.transferTokenFrom(charlie, collectionId, tokenId, testCase.account(bob), {Substrate: alice.address});
+ const owner = await helper.nft.getTokenOwner(collectionId, tokenId);
+ expect(owner.Substrate).to.be.equal(alice.address);
+ const transferTokenFromTx = () => helper.nft.transferTokenFrom(charlie, collectionId, tokenId, testCase.account(bob), {Substrate: alice.address});
+ await expect(transferTokenFromTx()).to.be.rejected;
+ });
+
+ itSub('Fungible up to an approved amount', async ({helper}) => {
+ const {collectionId} = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}, 0);
+ await helper.ft.mintTokens(alice, collectionId, 10n, testCase.account(bob));
+ const tokenId = await helper.ft.getLastTokenId(collectionId);
+ await (helper.ft as any)[testCase.method](bob, collectionId, tokenId, {Substrate: charlie.address});
+ const before = await helper.ft.getBalance(collectionId, {Substrate: alice.address});
+ await helper.ft.transferTokenFrom(charlie, collectionId, tokenId, testCase.account(bob), {Substrate: alice.address}, 1n);
+ const after = await helper.ft.getBalance(collectionId, {Substrate: alice.address});
+ expect(after - before).to.be.equal(BigInt(1));
+
+ const transferTokenFromTx = () => helper.ft.transferTokenFrom(charlie, collectionId, tokenId, testCase.account(bob), {Substrate: alice.address}, 1n);
+ await expect(transferTokenFromTx()).to.be.rejected;
+ });
- before(async () => {
- await usingPlaygrounds(async (helper, privateKey) => {
- const donor = await privateKey({filename: __filename});
- [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);
+ itSub.ifWithPallets('ReFungible up to an approved amount', [Pallets.ReFungible], async ({helper}) => {
+ const {collectionId} = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
+ const {tokenId} = await helper.rft.mintToken(alice, {collectionId: collectionId, owner: testCase.account(bob), pieces: 100n});
+ await (helper.ft as any)[testCase.method](bob, collectionId, tokenId, {Substrate: charlie.address}, 100n);
+ const before = await helper.rft.getTokenBalance(collectionId, tokenId, {Substrate: alice.address});
+ await helper.rft.transferTokenFrom(charlie, collectionId, tokenId, testCase.account(bob), {Substrate: alice.address}, 100n);
+ const after = await helper.rft.getTokenBalance(collectionId, tokenId, {Substrate: alice.address});
+ expect(after - before).to.be.equal(BigInt(100));
+ const transferTokenFromTx = () => helper.rft.transferTokenFrom(charlie, collectionId, tokenId, testCase.account(bob), {Substrate: alice.address}, 100n);
+ await expect(transferTokenFromTx()).to.be.rejected;
});
});
- itSub('NFT', async ({helper}) => {
- const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
- const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: bob.address});
- await helper.nft.approveToken(bob, collectionId, tokenId, {Substrate: charlie.address});
- await helper.nft.transferTokenFrom(charlie, collectionId, tokenId, {Substrate: bob.address}, {Substrate: alice.address});
- const owner = await helper.nft.getTokenOwner(collectionId, tokenId);
- expect(owner.Substrate).to.be.equal(alice.address);
+ describe(`[${testCase.method}] Approved amount decreases by the transferred amount:`, () => {
+ let alice: IKeyringPair;
+ let bob: IKeyringPair;
+ let charlie: IKeyringPair;
+ let dave: IKeyringPair;
+
+ before(async () => {
+ await usingPlaygrounds(async (helper, privateKey) => {
+ const donor = await privateKey({filename: __filename});
+ [alice, bob, charlie, dave] = await helper.arrange.createAccounts([100n, 100n, 100n, 100n], donor);
+ });
+ });
+
+ itSub('If a user B is approved to transfer 10 Fungible tokens from user A, they can transfer 2 tokens to user C, which will result in decreasing approval from 10 to 8. Then user B can transfer 8 tokens to user D.', async ({helper}) => {
+ const {collectionId} = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}, 0);
+ await helper.ft.mintTokens(alice, collectionId, 10n, testCase.account(alice));
+ const tokenId = await helper.ft.getLastTokenId(collectionId);
+ await (helper.ft as any)[testCase.method](alice, collectionId, tokenId, {Substrate: bob.address}, 10n);
+
+ const charlieBefore = await helper.ft.getBalance(collectionId, {Substrate: charlie.address});
+ await helper.ft.transferTokenFrom(bob, collectionId, tokenId, testCase.account(alice), {Substrate: charlie.address}, 2n);
+ const charlieAfter = await helper.ft.getBalance(collectionId, {Substrate: charlie.address});
+ expect(charlieAfter - charlieBefore).to.be.equal(BigInt(2));
+
+ const daveBefore = await helper.ft.getBalance(collectionId, {Substrate: dave.address});
+ await helper.ft.transferTokenFrom(bob, collectionId, tokenId, testCase.account(alice), {Substrate: dave.address}, 8n);
+ const daveAfter = await helper.ft.getBalance(collectionId, {Substrate: dave.address});
+ expect(daveAfter - daveBefore).to.be.equal(BigInt(8));
+ });
});
- itSub('Fungible up to an approved amount', async ({helper}) => {
- const {collectionId} = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}, 0);
- await helper.ft.mintTokens(alice, collectionId, 10n, bob.address);
- const tokenId = await helper.ft.getLastTokenId(collectionId);
- await helper.ft.approveToken(bob, collectionId, tokenId, {Substrate: charlie.address});
- const before = await helper.ft.getBalance(collectionId, {Substrate: alice.address});
- await helper.ft.transferTokenFrom(charlie, collectionId, tokenId, {Substrate: bob.address}, {Substrate: alice.address}, 1n);
- const after = await helper.ft.getBalance(collectionId, {Substrate: alice.address});
- expect(after - before).to.be.equal(BigInt(1));
+ describe(`[${testCase.method}] User may clear the approvals to approving for 0 amount:`, () => {
+ let alice: IKeyringPair;
+ let bob: IKeyringPair;
+ let charlie: IKeyringPair;
+
+ before(async () => {
+ await usingPlaygrounds(async (helper, privateKey) => {
+ const donor = await privateKey({filename: __filename});
+ [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);
+ });
+ });
+
+ itSub('NFT', async ({helper}) => {
+ const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
+ const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: testCase.account(alice)});
+ await (helper.nft as any)[testCase.method](alice, collectionId, tokenId, {Substrate: bob.address});
+ expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: bob.address})).to.be.true;
+ await (helper.nft as any)[testCase.method](alice, collectionId, tokenId, {Substrate: bob.address}, 0n);
+ expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: bob.address})).to.be.false;
+ const transferTokenFromTx = () => helper.nft.transferTokenFrom(bob, collectionId, tokenId, {Substrate: bob.address}, {Substrate: bob.address});
+ await expect(transferTokenFromTx()).to.be.rejected;
+ });
+
+ itSub('Fungible', async ({helper}) => {
+ const {collectionId} = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}, 0);
+ await helper.ft.mintTokens(alice, collectionId, 10n, testCase.account(alice));
+ const tokenId = await helper.ft.getLastTokenId(collectionId);
+ await (helper.ft as any)[testCase.method](alice, collectionId, tokenId, {Substrate: bob.address});
+ const amountBefore = await helper.ft.getTokenApprovedPieces(collectionId, tokenId, {Substrate: bob.address}, testCase.account(alice));
+ expect(amountBefore).to.be.equal(BigInt(1));
+
+ await (helper.ft as any)[testCase.method](alice, collectionId, tokenId, {Substrate: bob.address}, 0n);
+ const amountAfter = await helper.ft.getTokenApprovedPieces(collectionId, tokenId, {Substrate: bob.address}, testCase.account(alice));
+ expect(amountAfter).to.be.equal(BigInt(0));
+
+ const transferTokenFromTx = () => helper.ft.transferTokenFrom(bob, collectionId, tokenId, {Substrate: bob.address}, {Substrate: charlie.address}, 1n);
+ await expect(transferTokenFromTx()).to.be.rejected;
+ });
+
+ itSub.ifWithPallets('ReFungible', [Pallets.ReFungible], async ({helper}) => {
+ const {collectionId} = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
+ const {tokenId} = await helper.rft.mintToken(alice, {collectionId: collectionId, owner: testCase.account(alice), pieces: 100n});
+ await (helper.rft as any)[testCase.method](alice, collectionId, tokenId, {Substrate: bob.address});
+ const amountBefore = await helper.rft.getTokenApprovedPieces(collectionId, tokenId, {Substrate: bob.address}, testCase.account(alice));
+ expect(amountBefore).to.be.equal(BigInt(1));
+
+ await (helper.rft as any)[testCase.method](alice, collectionId, tokenId, {Substrate: bob.address}, 0n);
+ const amountAfter = await helper.rft.getTokenApprovedPieces(collectionId, tokenId, {Substrate: bob.address}, testCase.account(alice));
+ expect(amountAfter).to.be.equal(BigInt(0));
+
+ const transferTokenFromTx = () => helper.rft.transferTokenFrom(bob, collectionId, tokenId, {Substrate: bob.address}, {Substrate: charlie.address}, 100n);
+ await expect(transferTokenFromTx()).to.be.rejected;
+ });
});
- itSub.ifWithPallets('ReFungible up to an approved amount', [Pallets.ReFungible], async ({helper}) => {
- const {collectionId} = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
- const {tokenId} = await helper.rft.mintToken(alice, {collectionId: collectionId, owner: bob.address, pieces: 100n});
- await helper.rft.approveToken(bob, collectionId, tokenId, {Substrate: charlie.address});
- const before = await helper.rft.getTokenBalance(collectionId, tokenId, {Substrate: alice.address});
- await helper.rft.transferTokenFrom(charlie, collectionId, tokenId, {Substrate: bob.address}, {Substrate: alice.address}, 1n);
- const after = await helper.rft.getTokenBalance(collectionId, tokenId, {Substrate: alice.address});
- expect(after - before).to.be.equal(BigInt(1));
+ describe(`[${testCase.method}] User cannot approve for the amount greater than they own:`, () => {
+ let alice: IKeyringPair;
+ let bob: IKeyringPair;
+ let charlie: IKeyringPair;
+
+ before(async () => {
+ await usingPlaygrounds(async (helper, privateKey) => {
+ const donor = await privateKey({filename: __filename});
+ [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);
+ });
+ });
+
+ itSub('1 for NFT', async ({helper}) => {
+ const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
+ const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: testCase.account(bob)});
+ const result = (helper.nft as any)[testCase.method](bob, collectionId, tokenId, {Substrate: charlie.address}, 2n);
+ await expect(result).to.be.rejected;
+ expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: charlie.address})).to.be.false;
+ });
+
+ itSub('Fungible', async ({helper}) => {
+ const {collectionId} = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}, 0);
+ await helper.ft.mintTokens(alice, collectionId, 10n, testCase.account(alice));
+ const tokenId = await helper.ft.getLastTokenId(collectionId);
+ const result = (helper.ft as any)[testCase.method](alice, collectionId, tokenId, {Substrate: bob.address}, 11n);
+ await expect(result).to.be.rejected;
+ });
+
+ itSub.ifWithPallets('ReFungible', [Pallets.ReFungible], async ({helper}) => {
+ const {collectionId} = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
+ const {tokenId} = await helper.rft.mintToken(alice, {collectionId: collectionId, owner: testCase.account(alice), pieces: 100n});
+ const result = (helper.rft as any)[testCase.method](alice, collectionId, tokenId, {Substrate: bob.address}, 101n);
+ await expect(result).to.be.rejected;
+ });
});
-});
-describe('Approved users cannot use transferFrom to repeat transfers if approved amount was already transferred:', () => {
- let alice: IKeyringPair;
- let bob: IKeyringPair;
- let charlie: IKeyringPair;
+ describe(`[${testCase.method}] Integration Test approve(spender, collection_id, item_id, amount) with collection admin permissions:`, () => {
+ let alice: IKeyringPair;
+ let bob: IKeyringPair;
+ let charlie: IKeyringPair;
+
+ before(async () => {
+ await usingPlaygrounds(async (helper, privateKey) => {
+ const donor = await privateKey({filename: __filename});
+ [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);
+ });
+ });
- before(async () => {
- await usingPlaygrounds(async (helper, privateKey) => {
- const donor = await privateKey({filename: __filename});
- [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);
+ itSub('can be called by collection admin on non-owned item', async ({helper}) => {
+ const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
+ const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: testCase.account(alice)});
+ await helper.collection.addAdmin(alice, collectionId, {Substrate: bob.address});
+ const result = (helper.nft as any)[testCase.method](bob, collectionId, tokenId, {Substrate: charlie.address});
+ await expect(result).to.be.rejected;
});
});
- itSub('NFT', async ({helper}) => {
- const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
- const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: bob.address});
- await helper.nft.approveToken(bob, collectionId, tokenId, {Substrate: charlie.address});
- await helper.nft.transferTokenFrom(charlie, collectionId, tokenId, {Substrate: bob.address}, {Substrate: alice.address});
- const owner = await helper.nft.getTokenOwner(collectionId, tokenId);
- expect(owner.Substrate).to.be.equal(alice.address);
- const transferTokenFromTx = () => helper.nft.transferTokenFrom(charlie, collectionId, tokenId, {Substrate: bob.address}, {Substrate: alice.address});
- await expect(transferTokenFromTx()).to.be.rejected;
- });
+ describe(`[${testCase.method}] Negative Integration Test approve(spender, collection_id, item_id, amount):`, () => {
+ let alice: IKeyringPair;
+ let bob: IKeyringPair;
+ let charlie: IKeyringPair;
- itSub('Fungible up to an approved amount', async ({helper}) => {
- const {collectionId} = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}, 0);
- await helper.ft.mintTokens(alice, collectionId, 10n, bob.address);
- const tokenId = await helper.ft.getLastTokenId(collectionId);
- await helper.ft.approveToken(bob, collectionId, tokenId, {Substrate: charlie.address});
- const before = await helper.ft.getBalance(collectionId, {Substrate: alice.address});
- await helper.ft.transferTokenFrom(charlie, collectionId, tokenId, {Substrate: bob.address}, {Substrate: alice.address}, 1n);
- const after = await helper.ft.getBalance(collectionId, {Substrate: alice.address});
- expect(after - before).to.be.equal(BigInt(1));
+ before(async () => {
+ await usingPlaygrounds(async (helper, privateKey) => {
+ const donor = await privateKey({filename: __filename});
+ [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);
+ });
+ });
- const transferTokenFromTx = () => helper.ft.transferTokenFrom(charlie, collectionId, tokenId, {Substrate: bob.address}, {Substrate: alice.address}, 1n);
- await expect(transferTokenFromTx()).to.be.rejected;
- });
+ itSub('[nft] Approve for a collection that does not exist', async ({helper}) => {
+ const collectionId = 1 << 32 - 1;
+ await expect((helper.nft as any)[testCase.method](bob, collectionId, 1, {Substrate: charlie.address})).to.be.rejected;
+ });
+
+ itSub('[fungible] Approve for a collection that does not exist', async ({helper}) => {
+ const collectionId = 1 << 32 - 1;
+ const approveTx = () => (helper.ft as any)[testCase.method](bob, collectionId, 1, {Substrate: charlie.address});
+ await expect(approveTx()).to.be.rejected;
+ });
- itSub.ifWithPallets('ReFungible up to an approved amount', [Pallets.ReFungible], async ({helper}) => {
- const {collectionId} = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
- const {tokenId} = await helper.rft.mintToken(alice, {collectionId: collectionId, owner: bob.address, pieces: 100n});
- await helper.rft.approveToken(bob, collectionId, tokenId, {Substrate: charlie.address}, 100n);
- const before = await helper.rft.getTokenBalance(collectionId, tokenId, {Substrate: alice.address});
- await helper.rft.transferTokenFrom(charlie, collectionId, tokenId, {Substrate: bob.address}, {Substrate: alice.address}, 100n);
- const after = await helper.rft.getTokenBalance(collectionId, tokenId, {Substrate: alice.address});
- expect(after - before).to.be.equal(BigInt(100));
- const transferTokenFromTx = () => helper.rft.transferTokenFrom(charlie, collectionId, tokenId, {Substrate: bob.address}, {Substrate: alice.address}, 100n);
- await expect(transferTokenFromTx()).to.be.rejected;
- });
-});
+ itSub.ifWithPallets('[refungible] Approve for a collection that does not exist', [Pallets.ReFungible], async ({helper}) => {
+ const collectionId = 1 << 32 - 1;
+ const approveTx = () => (helper.rft as any)[testCase.method](bob, collectionId, 1, {Substrate: charlie.address});
+ await expect(approveTx()).to.be.rejected;
+ });
-describe('Approved amount decreases by the transferred amount:', () => {
- let alice: IKeyringPair;
- let bob: IKeyringPair;
- let charlie: IKeyringPair;
- let dave: IKeyringPair;
+ itSub('[nft] Approve for a collection that was destroyed', async ({helper}) => {
+ const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
+ await helper.nft.burn(alice, collectionId);
+ const approveTx = () => (helper.nft as any)[testCase.method](alice, collectionId, 1, {Substrate: bob.address});
+ await expect(approveTx()).to.be.rejected;
+ });
- before(async () => {
- await usingPlaygrounds(async (helper, privateKey) => {
- const donor = await privateKey({filename: __filename});
- [alice, bob, charlie, dave] = await helper.arrange.createAccounts([100n, 100n, 100n, 100n], donor);
+ itSub('[fungible] Approve for a collection that was destroyed', async ({helper}) => {
+ const {collectionId} = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
+ await helper.ft.burn(alice, collectionId);
+ const approveTx = () => (helper.ft as any)[testCase.method](alice, collectionId, 1, {Substrate: bob.address});
+ await expect(approveTx()).to.be.rejected;
});
- });
- itSub('If a user B is approved to transfer 10 Fungible tokens from user A, they can transfer 2 tokens to user C, which will result in decreasing approval from 10 to 8. Then user B can transfer 8 tokens to user D.', async ({helper}) => {
- const {collectionId} = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}, 0);
- await helper.ft.mintTokens(alice, collectionId, 10n, alice.address);
- const tokenId = await helper.ft.getLastTokenId(collectionId);
- await helper.ft.approveToken(alice, collectionId, tokenId, {Substrate: bob.address}, 10n);
+ itSub.ifWithPallets('[refungible] Approve for a collection that was destroyed', [Pallets.ReFungible], async ({helper}) => {
+ const {collectionId} = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
+ await helper.rft.burn(alice, collectionId);
+ const approveTx = () => (helper.rft as any)[testCase.method](alice, collectionId, 1, {Substrate: bob.address});
+ await expect(approveTx()).to.be.rejected;
+ });
- const charlieBefore = await helper.ft.getBalance(collectionId, {Substrate: charlie.address});
- await helper.ft.transferTokenFrom(bob, collectionId, tokenId, {Substrate: alice.address}, {Substrate: charlie.address}, 2n);
- const charlieAfter = await helper.ft.getBalance(collectionId, {Substrate: charlie.address});
- expect(charlieAfter - charlieBefore).to.be.equal(BigInt(2));
+ itSub('[nft] Approve transfer of a token that does not exist', async ({helper}) => {
+ const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
+ const approveTx = () => (helper.nft as any)[testCase.method](alice, collectionId, 2, {Substrate: bob.address});
+ await expect(approveTx()).to.be.rejected;
+ });
- const daveBefore = await helper.ft.getBalance(collectionId, {Substrate: dave.address});
- await helper.ft.transferTokenFrom(bob, collectionId, tokenId, {Substrate: alice.address}, {Substrate: dave.address}, 8n);
- const daveAfter = await helper.ft.getBalance(collectionId, {Substrate: dave.address});
- expect(daveAfter - daveBefore).to.be.equal(BigInt(8));
- });
-});
+ itSub.ifWithPallets('[refungible] Approve transfer of a token that does not exist', [Pallets.ReFungible], async ({helper}) => {
+ const {collectionId} = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
+ const approveTx = () => (helper.rft as any)[testCase.method](alice, collectionId, 2, {Substrate: bob.address});
+ await expect(approveTx()).to.be.rejected;
+ });
-describe('User may clear the approvals to approving for 0 amount:', () => {
- let alice: IKeyringPair;
- let bob: IKeyringPair;
- let charlie: IKeyringPair;
+ itSub('[nft] Approve using the address that does not own the approved token', async ({helper}) => {
+ const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
+ const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: testCase.account(alice)});
+ const approveTx = () => (helper.nft as any)[testCase.method](bob, collectionId, tokenId, {Substrate: alice.address});
+ await expect(approveTx()).to.be.rejected;
+ });
- before(async () => {
- await usingPlaygrounds(async (helper, privateKey) => {
- const donor = await privateKey({filename: __filename});
- [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);
+ itSub('[fungible] Approve using the address that does not own the approved token', async ({helper}) => {
+ const {collectionId} = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
+ await helper.ft.mintTokens(alice, collectionId, 10n, testCase.account(alice));
+ const tokenId = await helper.ft.getLastTokenId(collectionId);
+ const approveTx = () => (helper.ft as any)[testCase.method](bob, collectionId, tokenId, {Substrate: alice.address});
+ await expect(approveTx()).to.be.rejected;
});
- });
- itSub('NFT', async ({helper}) => {
- const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
- const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});
- await helper.nft.approveToken(alice, collectionId, tokenId, {Substrate: bob.address});
- expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: bob.address})).to.be.true;
- await helper.signTransaction(alice, helper.constructApiCall('api.tx.unique.approve', [{Substrate: bob.address}, collectionId, tokenId, 0]));
- expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: bob.address})).to.be.false;
- const transferTokenFromTx = () => helper.nft.transferTokenFrom(bob, collectionId, tokenId, {Substrate: bob.address}, {Substrate: bob.address});
- await expect(transferTokenFromTx()).to.be.rejected;
- });
+ itSub.ifWithPallets('[refungible] Approve using the address that does not own the approved token', [Pallets.ReFungible], async ({helper}) => {
+ const {collectionId} = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
+ const {tokenId} = await helper.rft.mintToken(alice, {collectionId: collectionId, owner: testCase.account(alice), pieces: 100n});
+ const approveTx = () => (helper.rft as any)[testCase.method](bob, collectionId, tokenId, {Substrate: alice.address});
+ await expect(approveTx()).to.be.rejected;
+ });
- itSub('Fungible', async ({helper}) => {
- const {collectionId} = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}, 0);
- await helper.ft.mintTokens(alice, collectionId, 10n, alice.address);
- const tokenId = await helper.ft.getLastTokenId(collectionId);
- await helper.ft.approveToken(alice, collectionId, tokenId, {Substrate: bob.address});
- const amountBefore = await helper.ft.getTokenApprovedPieces(collectionId, tokenId, {Substrate: bob.address}, {Substrate: alice.address});
- expect(amountBefore).to.be.equal(BigInt(1));
+ itSub.ifWithPallets('should fail if approved more ReFungibles than owned', [Pallets.ReFungible], async ({helper}) => {
+ const {collectionId} = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
+ const {tokenId} = await helper.rft.mintToken(alice, {collectionId: collectionId, owner: alice.address, pieces: 100n});
+ await helper.rft.transferToken(alice, collectionId, tokenId, testCase.account(bob), 100n);
+ await (helper.rft as any)[testCase.method](bob, collectionId, tokenId, {Substrate: alice.address}, 100n);
- await helper.ft.approveToken(alice, collectionId, tokenId, {Substrate: bob.address}, 0n);
- const amountAfter = await helper.ft.getTokenApprovedPieces(collectionId, tokenId, {Substrate: bob.address}, {Substrate: alice.address});
- expect(amountAfter).to.be.equal(BigInt(0));
+ const approveTx = () => (helper.rft as any)[testCase.method](bob, collectionId, tokenId, {Substrate: alice.address}, 101n);
+ await expect(approveTx()).to.be.rejected;
+ });
- const transferTokenFromTx = () => helper.ft.transferTokenFrom(bob, collectionId, tokenId, {Substrate: bob.address}, {Substrate: charlie.address}, 1n);
- await expect(transferTokenFromTx()).to.be.rejected;
- });
+ itSub('should fail if approved more Fungibles than owned', async ({helper}) => {
+ const {collectionId} = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
+ await helper.ft.mintTokens(alice, collectionId, 10n, alice.address);
+ const tokenId = await helper.ft.getLastTokenId(collectionId);
- itSub.ifWithPallets('ReFungible', [Pallets.ReFungible], async ({helper}) => {
- const {collectionId} = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
- const {tokenId} = await helper.rft.mintToken(alice, {collectionId: collectionId, owner: alice.address, pieces: 100n});
- await helper.rft.approveToken(alice, collectionId, tokenId, {Substrate: bob.address});
- const amountBefore = await helper.rft.getTokenApprovedPieces(collectionId, tokenId, {Substrate: bob.address}, {Substrate: alice.address});
- expect(amountBefore).to.be.equal(BigInt(1));
+ await helper.ft.transferToken(alice, collectionId, tokenId, testCase.account(bob), 10n);
+ await (helper.ft as any)[testCase.method](bob, collectionId, tokenId, {Substrate: alice.address}, 10n);
+ const approveTx = () => (helper.ft as any)[testCase.method](bob, collectionId, tokenId, {Substrate: alice.address}, 11n);
+ await expect(approveTx()).to.be.rejected;
+ });
- await helper.rft.approveToken(alice, collectionId, tokenId, {Substrate: bob.address}, 0n);
- const amountAfter = await helper.rft.getTokenApprovedPieces(collectionId, tokenId, {Substrate: bob.address}, {Substrate: alice.address});
- expect(amountAfter).to.be.equal(BigInt(0));
+ itSub('fails when called by collection owner on non-owned item when OwnerCanTransfer == false', async ({helper}) => {
+ const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
+ const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: testCase.account(bob)});
+ await helper.collection.setLimits(alice, collectionId, {ownerCanTransfer: false});
- const transferTokenFromTx = () => helper.rft.transferTokenFrom(bob, collectionId, tokenId, {Substrate: bob.address}, {Substrate: charlie.address}, 100n);
- await expect(transferTokenFromTx()).to.be.rejected;
+ const approveTx = () => (helper.nft as any)[testCase.method](alice, collectionId, tokenId, {Substrate: charlie.address});
+ await expect(approveTx()).to.be.rejected;
+ });
});
});
-describe('User cannot approve for the amount greater than they own:', () => {
+describe('Normal user can approve other users to be wallet operator:', () => {
let alice: IKeyringPair;
let bob: IKeyringPair;
- let charlie: IKeyringPair;
before(async () => {
await usingPlaygrounds(async (helper, privateKey) => {
const donor = await privateKey({filename: __filename});
- [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);
+ [alice, bob] = await helper.arrange.createAccounts([100n, 100n], donor);
});
});
- itSub('1 for NFT', async ({helper}) => {
+ itSub('[nft] Enable and disable approval', async ({helper}) => {
const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
- const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: bob.address});
- const approveTx = () => helper.signTransaction(bob, helper.constructApiCall('api.tx.unique.approve', [{Substrate: charlie.address}, collectionId, tokenId, 2]));
- await expect(approveTx()).to.be.rejected;
- expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: charlie.address})).to.be.false;
- });
- itSub('Fungible', async ({helper}) => {
- const {collectionId} = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}, 0);
- await helper.ft.mintTokens(alice, collectionId, 10n, alice.address);
- const tokenId = await helper.ft.getLastTokenId(collectionId);
- const approveTx = () => helper.ft.approveToken(alice, collectionId, tokenId, {Substrate: bob.address}, 11n);
- await expect(approveTx()).to.be.rejected;
+ const checkBeforeApproval = await helper.nft.allowanceForAll(collectionId, {Substrate: alice.address}, {Substrate: bob.address});
+ expect(checkBeforeApproval).to.be.false;
+
+ await helper.nft.setAllowanceForAll(alice, collectionId, {Substrate: bob.address}, true);
+ const checkAfterApproval = await helper.nft.allowanceForAll(collectionId, {Substrate: alice.address}, {Substrate: bob.address});
+ expect(checkAfterApproval).to.be.true;
+
+ await helper.nft.setAllowanceForAll(alice, collectionId, {Substrate: bob.address}, false);
+ const checkAfterDisapproval = await helper.nft.allowanceForAll(collectionId, {Substrate: alice.address}, {Substrate: bob.address});
+ expect(checkAfterDisapproval).to.be.false;
});
- itSub.ifWithPallets('ReFungible', [Pallets.ReFungible], async ({helper}) => {
+ itSub.ifWithPallets('[rft] Enable and disable approval', [Pallets.ReFungible], async ({helper}) => {
const {collectionId} = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
- const {tokenId} = await helper.rft.mintToken(alice, {collectionId: collectionId, owner: alice.address, pieces: 100n});
- const approveTx = () => helper.rft.approveToken(alice, collectionId, tokenId, {Substrate: bob.address}, 101n);
- await expect(approveTx()).to.be.rejected;
+
+ const checkBeforeApproval = await helper.rft.allowanceForAll(collectionId, {Substrate: alice.address}, {Substrate: bob.address});
+ expect(checkBeforeApproval).to.be.false;
+
+ await helper.rft.setAllowanceForAll(alice, collectionId, {Substrate: bob.address}, true);
+ const checkAfterApproval = await helper.rft.allowanceForAll(collectionId, {Substrate: alice.address}, {Substrate: bob.address});
+ expect(checkAfterApproval).to.be.true;
+
+ await helper.rft.setAllowanceForAll(alice, collectionId, {Substrate: bob.address}, false);
+ const checkAfterDisapproval = await helper.rft.allowanceForAll(collectionId, {Substrate: alice.address}, {Substrate: bob.address});
+ expect(checkAfterDisapproval).to.be.false;
});
});
@@ -464,184 +649,5 @@
await token.approve(dave, {Substrate: bob.address}, 50n);
await expect(token.approve(dave, {Substrate: charlie.address}, 51n))
.to.be.rejectedWith('this test would fail (since it is skipped), replace this expecting message with what would have been received');
- });
-});
-
-describe('Integration Test approve(spender, collection_id, item_id, amount) with collection admin permissions:', () => {
- let alice: IKeyringPair;
- let bob: IKeyringPair;
- let charlie: IKeyringPair;
-
- before(async () => {
- await usingPlaygrounds(async (helper, privateKey) => {
- const donor = await privateKey({filename: __filename});
- [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);
- });
- });
-
- itSub('can be called by collection admin on non-owned item', async ({helper}) => {
- const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
- const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});
- await helper.collection.addAdmin(alice, collectionId, {Substrate: bob.address});
- const approveTx = () => helper.nft.approveToken(bob, collectionId, tokenId, {Substrate: charlie.address});
- await expect(approveTx()).to.be.rejected;
- });
-});
-
-describe('Negative Integration Test approve(spender, collection_id, item_id, amount):', () => {
- let alice: IKeyringPair;
- let bob: IKeyringPair;
- let charlie: IKeyringPair;
-
- before(async () => {
- await usingPlaygrounds(async (helper, privateKey) => {
- const donor = await privateKey({filename: __filename});
- [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);
- });
- });
-
- itSub('[nft] Approve for a collection that does not exist', async ({helper}) => {
- const collectionId = 1 << 32 - 1;
- const approveTx = () => helper.nft.approveToken(bob, collectionId, 1, {Substrate: charlie.address});
- await expect(approveTx()).to.be.rejected;
- });
-
- itSub('[fungible] Approve for a collection that does not exist', async ({helper}) => {
- const collectionId = 1 << 32 - 1;
- const approveTx = () => helper.ft.approveToken(bob, collectionId, 1, {Substrate: charlie.address});
- await expect(approveTx()).to.be.rejected;
- });
-
- itSub.ifWithPallets('[refungible] Approve for a collection that does not exist', [Pallets.ReFungible], async ({helper}) => {
- const collectionId = 1 << 32 - 1;
- const approveTx = () => helper.rft.approveToken(bob, collectionId, 1, {Substrate: charlie.address});
- await expect(approveTx()).to.be.rejected;
- });
-
- itSub('[nft] Approve for a collection that was destroyed', async ({helper}) => {
- const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
- await helper.nft.burn(alice, collectionId);
- const approveTx = () => helper.nft.approveToken(alice, collectionId, 1, {Substrate: bob.address});
- await expect(approveTx()).to.be.rejected;
- });
-
- itSub('[fungible] Approve for a collection that was destroyed', async ({helper}) => {
- const {collectionId} = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
- await helper.ft.burn(alice, collectionId);
- const approveTx = () => helper.ft.approveToken(alice, collectionId, 1, {Substrate: bob.address});
- await expect(approveTx()).to.be.rejected;
- });
-
- itSub.ifWithPallets('[refungible] Approve for a collection that was destroyed', [Pallets.ReFungible], async ({helper}) => {
- const {collectionId} = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
- await helper.rft.burn(alice, collectionId);
- const approveTx = () => helper.rft.approveToken(alice, collectionId, 1, {Substrate: bob.address});
- await expect(approveTx()).to.be.rejected;
- });
-
- itSub('[nft] Approve transfer of a token that does not exist', async ({helper}) => {
- const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
- const approveTx = () => helper.nft.approveToken(alice, collectionId, 2, {Substrate: bob.address});
- await expect(approveTx()).to.be.rejected;
- });
-
- itSub.ifWithPallets('[refungible] Approve transfer of a token that does not exist', [Pallets.ReFungible], async ({helper}) => {
- const {collectionId} = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
- const approveTx = () => helper.rft.approveToken(alice, collectionId, 2, {Substrate: bob.address});
- await expect(approveTx()).to.be.rejected;
- });
-
- itSub('[nft] Approve using the address that does not own the approved token', async ({helper}) => {
- const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
- const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});
- const approveTx = () => helper.nft.approveToken(bob, collectionId, tokenId, {Substrate: alice.address});
- await expect(approveTx()).to.be.rejected;
- });
-
- itSub('[fungible] Approve using the address that does not own the approved token', async ({helper}) => {
- const {collectionId} = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
- await helper.ft.mintTokens(alice, collectionId, 10n, alice.address);
- const tokenId = await helper.ft.getLastTokenId(collectionId);
- const approveTx = () => helper.ft.approveToken(bob, collectionId, tokenId, {Substrate: alice.address});
- await expect(approveTx()).to.be.rejected;
- });
-
- itSub.ifWithPallets('[refungible] Approve using the address that does not own the approved token', [Pallets.ReFungible], async ({helper}) => {
- const {collectionId} = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
- const {tokenId} = await helper.rft.mintToken(alice, {collectionId: collectionId, owner: alice.address, pieces: 100n});
- const approveTx = () => helper.rft.approveToken(bob, collectionId, tokenId, {Substrate: alice.address});
- await expect(approveTx()).to.be.rejected;
- });
-
- itSub.ifWithPallets('should fail if approved more ReFungibles than owned', [Pallets.ReFungible], async ({helper}) => {
- const {collectionId} = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
- const {tokenId} = await helper.rft.mintToken(alice, {collectionId: collectionId, owner: alice.address, pieces: 100n});
- await helper.rft.transferToken(alice, collectionId, tokenId, {Substrate: bob.address}, 100n);
- await helper.rft.approveToken(bob, collectionId, tokenId, {Substrate: alice.address}, 100n);
-
- const approveTx = () => helper.rft.approveToken(bob, collectionId, tokenId, {Substrate: alice.address}, 101n);
- await expect(approveTx()).to.be.rejected;
- });
-
- itSub('should fail if approved more Fungibles than owned', async ({helper}) => {
- const {collectionId} = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
- await helper.ft.mintTokens(alice, collectionId, 10n, alice.address);
- const tokenId = await helper.ft.getLastTokenId(collectionId);
-
- await helper.ft.transferToken(alice, collectionId, tokenId, {Substrate: bob.address}, 10n);
- await helper.ft.approveToken(bob, collectionId, tokenId, {Substrate: alice.address}, 10n);
- const approveTx = () => helper.ft.approveToken(bob, collectionId, tokenId, {Substrate: alice.address}, 11n);
- await expect(approveTx()).to.be.rejected;
- });
-
- itSub('fails when called by collection owner on non-owned item when OwnerCanTransfer == false', async ({helper}) => {
- const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
- const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: bob.address});
- await helper.collection.setLimits(alice, collectionId, {ownerCanTransfer: false});
-
- const approveTx = () => helper.nft.approveToken(alice, collectionId, tokenId, {Substrate: charlie.address});
- await expect(approveTx()).to.be.rejected;
- });
-});
-
-describe('Normal user can approve other users to be wallet operator:', () => {
- let alice: IKeyringPair;
- let bob: IKeyringPair;
-
- before(async () => {
- await usingPlaygrounds(async (helper, privateKey) => {
- const donor = await privateKey({filename: __filename});
- [alice, bob] = await helper.arrange.createAccounts([100n, 100n], donor);
- });
- });
-
- itSub('[nft] Enable and disable approval', async ({helper}) => {
- const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
-
- const checkBeforeApproval = await helper.nft.allowanceForAll(collectionId, {Substrate: alice.address}, {Substrate: bob.address});
- expect(checkBeforeApproval).to.be.false;
-
- await helper.nft.setAllowanceForAll(alice, collectionId, {Substrate: bob.address}, true);
- const checkAfterApproval = await helper.nft.allowanceForAll(collectionId, {Substrate: alice.address}, {Substrate: bob.address});
- expect(checkAfterApproval).to.be.true;
-
- await helper.nft.setAllowanceForAll(alice, collectionId, {Substrate: bob.address}, false);
- const checkAfterDisapproval = await helper.nft.allowanceForAll(collectionId, {Substrate: alice.address}, {Substrate: bob.address});
- expect(checkAfterDisapproval).to.be.false;
- });
-
- itSub.ifWithPallets('[rft] Enable and disable approval', [Pallets.ReFungible], async ({helper}) => {
- const {collectionId} = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
-
- const checkBeforeApproval = await helper.rft.allowanceForAll(collectionId, {Substrate: alice.address}, {Substrate: bob.address});
- expect(checkBeforeApproval).to.be.false;
-
- await helper.rft.setAllowanceForAll(alice, collectionId, {Substrate: bob.address}, true);
- const checkAfterApproval = await helper.rft.allowanceForAll(collectionId, {Substrate: alice.address}, {Substrate: bob.address});
- expect(checkAfterApproval).to.be.true;
-
- await helper.rft.setAllowanceForAll(alice, collectionId, {Substrate: bob.address}, false);
- const checkAfterDisapproval = await helper.rft.allowanceForAll(collectionId, {Substrate: alice.address}, {Substrate: bob.address});
- expect(checkAfterDisapproval).to.be.false;
});
});
tests/src/eth/api/ContractHelpers.soldiffbeforeafterboth--- a/tests/src/eth/api/ContractHelpers.sol
+++ b/tests/src/eth/api/ContractHelpers.sol
@@ -183,9 +183,9 @@
/// Ethereum representation of Optional value with CrossAddress.
struct OptionCrossAddress {
- /// TODO: field description
+ /// Whether or not this CrossAdress is valid and has meaning.
bool status;
- /// TODO: field description
+ /// The underlying CrossAddress value. If the status is false, can be set to whatever.
CrossAddress value;
}
tests/src/interfaces/augment-api-errors.tsdiffbeforeafterboth1// Auto-generated via `yarn polkadot-types-from-chain`, do not edit2/* eslint-disable */34// import type lookup before we augment - in some environments5// this is required to allow for ambient/previous definitions6import '@polkadot/api-base/types/errors';78import type { ApiTypes, AugmentedError } from '@polkadot/api-base/types';910export type __AugmentedError<ApiType extends ApiTypes> = AugmentedError<ApiType>;1112declare module '@polkadot/api-base/types/errors' {13 interface AugmentedErrors<ApiType extends ApiTypes> {14 appPromotion: {15 /**16 * Error due to action requiring admin to be set.17 **/18 AdminNotSet: AugmentedError<ApiType>;19 /**20 * Errors caused by incorrect actions with a locked balance.21 **/22 IncorrectLockedBalanceOperation: AugmentedError<ApiType>;23 /**24 * No permission to perform an action.25 **/26 NoPermission: AugmentedError<ApiType>;27 /**28 * Insufficient funds to perform an action.29 **/30 NotSufficientFunds: AugmentedError<ApiType>;31 /**32 * Occurs when a pending unstake cannot be added in this block. PENDING_LIMIT_PER_BLOCK` limits exceeded.33 **/34 PendingForBlockOverflow: AugmentedError<ApiType>;35 /**36 * The error is due to the fact that the collection/contract must already be sponsored in order to perform the action.37 **/38 SponsorNotSet: AugmentedError<ApiType>;39 /**40 * Generic error41 **/42 [key: string]: AugmentedError<ApiType>;43 };44 balances: {45 /**46 * Beneficiary account must pre-exist47 **/48 DeadAccount: AugmentedError<ApiType>;49 /**50 * Value too low to create account due to existential deposit51 **/52 ExistentialDeposit: AugmentedError<ApiType>;53 /**54 * A vesting schedule already exists for this account55 **/56 ExistingVestingSchedule: AugmentedError<ApiType>;57 /**58 * Balance too low to send value.59 **/60 InsufficientBalance: AugmentedError<ApiType>;61 /**62 * Transfer/payment would kill account63 **/64 KeepAlive: AugmentedError<ApiType>;65 /**66 * Account liquidity restrictions prevent withdrawal67 **/68 LiquidityRestrictions: AugmentedError<ApiType>;69 /**70 * Number of named reserves exceed MaxReserves71 **/72 TooManyReserves: AugmentedError<ApiType>;73 /**74 * Vesting balance too high to send value75 **/76 VestingBalance: AugmentedError<ApiType>;77 /**78 * Generic error79 **/80 [key: string]: AugmentedError<ApiType>;81 };82 common: {83 /**84 * Account token limit exceeded per collection85 **/86 AccountTokenLimitExceeded: AugmentedError<ApiType>;87 /**88 * Can't transfer tokens to ethereum zero address89 **/90 AddressIsZero: AugmentedError<ApiType>;91 /**92 * Address is not in allow list.93 **/94 AddressNotInAllowlist: AugmentedError<ApiType>;95 /**96 * Requested value is more than the approved97 **/98 ApprovedValueTooLow: AugmentedError<ApiType>;99 /**100 * Tried to approve more than owned101 **/102 CantApproveMoreThanOwned: AugmentedError<ApiType>;103 /**104 * Destroying only empty collections is allowed105 **/106 CantDestroyNotEmptyCollection: AugmentedError<ApiType>;107 /**108 * Exceeded max admin count109 **/110 CollectionAdminCountExceeded: AugmentedError<ApiType>;111 /**112 * Collection description can not be longer than 255 char.113 **/114 CollectionDescriptionLimitExceeded: AugmentedError<ApiType>;115 /**116 * Tried to store more data than allowed in collection field117 **/118 CollectionFieldSizeExceeded: AugmentedError<ApiType>;119 /**120 * Tried to access an external collection with an internal API121 **/122 CollectionIsExternal: AugmentedError<ApiType>;123 /**124 * Tried to access an internal collection with an external API125 **/126 CollectionIsInternal: AugmentedError<ApiType>;127 /**128 * Collection limit bounds per collection exceeded129 **/130 CollectionLimitBoundsExceeded: AugmentedError<ApiType>;131 /**132 * Collection name can not be longer than 63 char.133 **/134 CollectionNameLimitExceeded: AugmentedError<ApiType>;135 /**136 * This collection does not exist.137 **/138 CollectionNotFound: AugmentedError<ApiType>;139 /**140 * Collection token limit exceeded141 **/142 CollectionTokenLimitExceeded: AugmentedError<ApiType>;143 /**144 * Token prefix can not be longer than 15 char.145 **/146 CollectionTokenPrefixLimitExceeded: AugmentedError<ApiType>;147 /**148 * This address is not set as sponsor, use setCollectionSponsor first.149 **/150 ConfirmSponsorshipFail: AugmentedError<ApiType>;151 /**152 * Empty property keys are forbidden153 **/154 EmptyPropertyKey: AugmentedError<ApiType>;155 /**156 * Only ASCII letters, digits, and symbols `_`, `-`, and `.` are allowed157 **/158 InvalidCharacterInPropertyKey: AugmentedError<ApiType>;159 /**160 * Metadata flag frozen161 **/162 MetadataFlagFrozen: AugmentedError<ApiType>;163 /**164 * Sender parameter and item owner must be equal.165 **/166 MustBeTokenOwner: AugmentedError<ApiType>;167 /**168 * No permission to perform action169 **/170 NoPermission: AugmentedError<ApiType>;171 /**172 * Tried to store more property data than allowed173 **/174 NoSpaceForProperty: AugmentedError<ApiType>;175 /**176 * Insufficient funds to perform an action177 **/178 NotSufficientFounds: AugmentedError<ApiType>;179 /**180 * Tried to enable permissions which are only permitted to be disabled181 **/182 OwnerPermissionsCantBeReverted: AugmentedError<ApiType>;183 /**184 * Property key is too long185 **/186 PropertyKeyIsTooLong: AugmentedError<ApiType>;187 /**188 * Tried to store more property keys than allowed189 **/190 PropertyLimitReached: AugmentedError<ApiType>;191 /**192 * Collection is not in mint mode.193 **/194 PublicMintingNotAllowed: AugmentedError<ApiType>;195 /**196 * Only tokens from specific collections may nest tokens under this one197 **/198 SourceCollectionIsNotAllowedToNest: AugmentedError<ApiType>;199 /**200 * Item does not exist201 **/202 TokenNotFound: AugmentedError<ApiType>;203 /**204 * Item is balance not enough205 **/206 TokenValueTooLow: AugmentedError<ApiType>;207 /**208 * Total collections bound exceeded.209 **/210 TotalCollectionsLimitExceeded: AugmentedError<ApiType>;211 /**212 * Collection settings not allowing items transferring213 **/214 TransferNotAllowed: AugmentedError<ApiType>;215 /**216 * The operation is not supported217 **/218 UnsupportedOperation: AugmentedError<ApiType>;219 /**220 * User does not satisfy the nesting rule221 **/222 UserIsNotAllowedToNest: AugmentedError<ApiType>;223 /**224 * The user is not an administrator.225 **/226 UserIsNotCollectionAdmin: AugmentedError<ApiType>;227 /**228 * Generic error229 **/230 [key: string]: AugmentedError<ApiType>;231 };232 configuration: {233 InconsistentConfiguration: AugmentedError<ApiType>;234 /**235 * Generic error236 **/237 [key: string]: AugmentedError<ApiType>;238 };239 cumulusXcm: {240 /**241 * Generic error242 **/243 [key: string]: AugmentedError<ApiType>;244 };245 dmpQueue: {246 /**247 * The amount of weight given is possibly not enough for executing the message.248 **/249 OverLimit: AugmentedError<ApiType>;250 /**251 * The message index given is unknown.252 **/253 Unknown: AugmentedError<ApiType>;254 /**255 * Generic error256 **/257 [key: string]: AugmentedError<ApiType>;258 };259 ethereum: {260 /**261 * Signature is invalid.262 **/263 InvalidSignature: AugmentedError<ApiType>;264 /**265 * Pre-log is present, therefore transact is not allowed.266 **/267 PreLogExists: AugmentedError<ApiType>;268 /**269 * Generic error270 **/271 [key: string]: AugmentedError<ApiType>;272 };273 evm: {274 /**275 * Not enough balance to perform action276 **/277 BalanceLow: AugmentedError<ApiType>;278 /**279 * Calculating total fee overflowed280 **/281 FeeOverflow: AugmentedError<ApiType>;282 /**283 * Gas limit is too high.284 **/285 GasLimitTooHigh: AugmentedError<ApiType>;286 /**287 * Gas limit is too low.288 **/289 GasLimitTooLow: AugmentedError<ApiType>;290 /**291 * Gas price is too low.292 **/293 GasPriceTooLow: AugmentedError<ApiType>;294 /**295 * Nonce is invalid296 **/297 InvalidNonce: AugmentedError<ApiType>;298 /**299 * Calculating total payment overflowed300 **/301 PaymentOverflow: AugmentedError<ApiType>;302 /**303 * EVM reentrancy304 **/305 Reentrancy: AugmentedError<ApiType>;306 /**307 * EIP-3607,308 **/309 TransactionMustComeFromEOA: AugmentedError<ApiType>;310 /**311 * Undefined error.312 **/313 Undefined: AugmentedError<ApiType>;314 /**315 * Withdraw fee failed316 **/317 WithdrawFailed: AugmentedError<ApiType>;318 /**319 * Generic error320 **/321 [key: string]: AugmentedError<ApiType>;322 };323 evmCoderSubstrate: {324 OutOfFund: AugmentedError<ApiType>;325 OutOfGas: AugmentedError<ApiType>;326 /**327 * Generic error328 **/329 [key: string]: AugmentedError<ApiType>;330 };331 evmContractHelpers: {332 /**333 * No pending sponsor for contract.334 **/335 NoPendingSponsor: AugmentedError<ApiType>;336 /**337 * This method is only executable by contract owner338 **/339 NoPermission: AugmentedError<ApiType>;340 /**341 * Number of methods that sponsored limit is defined for exceeds maximum.342 **/343 TooManyMethodsHaveSponsoredLimit: AugmentedError<ApiType>;344 /**345 * Generic error346 **/347 [key: string]: AugmentedError<ApiType>;348 };349 evmMigration: {350 /**351 * Migration of this account is not yet started, or already finished.352 **/353 AccountIsNotMigrating: AugmentedError<ApiType>;354 /**355 * Can only migrate to empty address.356 **/357 AccountNotEmpty: AugmentedError<ApiType>;358 /**359 * Failed to decode event bytes360 **/361 BadEvent: AugmentedError<ApiType>;362 /**363 * Generic error364 **/365 [key: string]: AugmentedError<ApiType>;366 };367 foreignAssets: {368 /**369 * AssetId exists370 **/371 AssetIdExisted: AugmentedError<ApiType>;372 /**373 * AssetId not exists374 **/375 AssetIdNotExists: AugmentedError<ApiType>;376 /**377 * The given location could not be used (e.g. because it cannot be expressed in the378 * desired version of XCM).379 **/380 BadLocation: AugmentedError<ApiType>;381 /**382 * MultiLocation existed383 **/384 MultiLocationExisted: AugmentedError<ApiType>;385 /**386 * Generic error387 **/388 [key: string]: AugmentedError<ApiType>;389 };390 fungible: {391 /**392 * Fungible token does not support nesting.393 **/394 FungibleDisallowsNesting: AugmentedError<ApiType>;395 /**396 * Tried to set data for fungible item.397 **/398 FungibleItemsDontHaveData: AugmentedError<ApiType>;399 /**400 * Fungible tokens hold no ID, and the default value of TokenId for Fungible collection is 0.401 **/402 FungibleItemsHaveNoId: AugmentedError<ApiType>;403 /**404 * Only a fungible collection could be possibly broken; any fungible token is valid.405 **/406 FungibleTokensAreAlwaysValid: AugmentedError<ApiType>;407 /**408 * Not Fungible item data used to mint in Fungible collection.409 **/410 NotFungibleDataUsedToMintFungibleCollectionToken: AugmentedError<ApiType>;411 /**412 * Setting allowance for all is not allowed.413 **/414 SettingAllowanceForAllNotAllowed: AugmentedError<ApiType>;415 /**416 * Setting item properties is not allowed.417 **/418 SettingPropertiesNotAllowed: AugmentedError<ApiType>;419 /**420 * Generic error421 **/422 [key: string]: AugmentedError<ApiType>;423 };424 maintenance: {425 /**426 * Generic error427 **/428 [key: string]: AugmentedError<ApiType>;429 };430 nonfungible: {431 /**432 * Unable to burn NFT with children433 **/434 CantBurnNftWithChildren: AugmentedError<ApiType>;435 /**436 * Used amount > 1 with NFT437 **/438 NonfungibleItemsHaveNoAmount: AugmentedError<ApiType>;439 /**440 * Not Nonfungible item data used to mint in Nonfungible collection.441 **/442 NotNonfungibleDataUsedToMintFungibleCollectionToken: AugmentedError<ApiType>;443 /**444 * Generic error445 **/446 [key: string]: AugmentedError<ApiType>;447 };448 parachainSystem: {449 /**450 * The inherent which supplies the host configuration did not run this block451 **/452 HostConfigurationNotAvailable: AugmentedError<ApiType>;453 /**454 * No code upgrade has been authorized.455 **/456 NothingAuthorized: AugmentedError<ApiType>;457 /**458 * No validation function upgrade is currently scheduled.459 **/460 NotScheduled: AugmentedError<ApiType>;461 /**462 * Attempt to upgrade validation function while existing upgrade pending463 **/464 OverlappingUpgrades: AugmentedError<ApiType>;465 /**466 * Polkadot currently prohibits this parachain from upgrading its validation function467 **/468 ProhibitedByPolkadot: AugmentedError<ApiType>;469 /**470 * The supplied validation function has compiled into a blob larger than Polkadot is471 * willing to run472 **/473 TooBig: AugmentedError<ApiType>;474 /**475 * The given code upgrade has not been authorized.476 **/477 Unauthorized: AugmentedError<ApiType>;478 /**479 * The inherent which supplies the validation data did not run this block480 **/481 ValidationDataNotAvailable: AugmentedError<ApiType>;482 /**483 * Generic error484 **/485 [key: string]: AugmentedError<ApiType>;486 };487 polkadotXcm: {488 /**489 * The location is invalid since it already has a subscription from us.490 **/491 AlreadySubscribed: AugmentedError<ApiType>;492 /**493 * The given location could not be used (e.g. because it cannot be expressed in the494 * desired version of XCM).495 **/496 BadLocation: AugmentedError<ApiType>;497 /**498 * The version of the `Versioned` value used is not able to be interpreted.499 **/500 BadVersion: AugmentedError<ApiType>;501 /**502 * Could not re-anchor the assets to declare the fees for the destination chain.503 **/504 CannotReanchor: AugmentedError<ApiType>;505 /**506 * The destination `MultiLocation` provided cannot be inverted.507 **/508 DestinationNotInvertible: AugmentedError<ApiType>;509 /**510 * The assets to be sent are empty.511 **/512 Empty: AugmentedError<ApiType>;513 /**514 * The message execution fails the filter.515 **/516 Filtered: AugmentedError<ApiType>;517 /**518 * Origin is invalid for sending.519 **/520 InvalidOrigin: AugmentedError<ApiType>;521 /**522 * The referenced subscription could not be found.523 **/524 NoSubscription: AugmentedError<ApiType>;525 /**526 * There was some other issue (i.e. not to do with routing) in sending the message. Perhaps527 * a lack of space for buffering the message.528 **/529 SendFailure: AugmentedError<ApiType>;530 /**531 * Too many assets have been attempted for transfer.532 **/533 TooManyAssets: AugmentedError<ApiType>;534 /**535 * The desired destination was unreachable, generally because there is a no way of routing536 * to it.537 **/538 Unreachable: AugmentedError<ApiType>;539 /**540 * The message's weight could not be determined.541 **/542 UnweighableMessage: AugmentedError<ApiType>;543 /**544 * Generic error545 **/546 [key: string]: AugmentedError<ApiType>;547 };548 refungible: {549 /**550 * Not Refungible item data used to mint in Refungible collection.551 **/552 NotRefungibleDataUsedToMintFungibleCollectionToken: AugmentedError<ApiType>;553 /**554 * Refungible token can't nest other tokens.555 **/556 RefungibleDisallowsNesting: AugmentedError<ApiType>;557 /**558 * Refungible token can't be repartitioned by user who isn't owns all pieces.559 **/560 RepartitionWhileNotOwningAllPieces: AugmentedError<ApiType>;561 /**562 * Setting item properties is not allowed.563 **/564 SettingPropertiesNotAllowed: AugmentedError<ApiType>;565 /**566 * Maximum refungibility exceeded.567 **/568 WrongRefungiblePieces: AugmentedError<ApiType>;569 /**570 * Generic error571 **/572 [key: string]: AugmentedError<ApiType>;573 };574 rmrkCore: {575 /**576 * Not the target owner of the sent NFT.577 **/578 CannotAcceptNonOwnedNft: AugmentedError<ApiType>;579 /**580 * Not the target owner of the sent NFT.581 **/582 CannotRejectNonOwnedNft: AugmentedError<ApiType>;583 /**584 * NFT was not sent and is not pending.585 **/586 CannotRejectNonPendingNft: AugmentedError<ApiType>;587 /**588 * If an NFT is sent to a descendant, that would form a nesting loop, an ouroboros.589 * Sending to self is redundant.590 **/591 CannotSendToDescendentOrSelf: AugmentedError<ApiType>;592 /**593 * Too many tokens created in the collection, no new ones are allowed.594 **/595 CollectionFullOrLocked: AugmentedError<ApiType>;596 /**597 * Only destroying collections without tokens is allowed.598 **/599 CollectionNotEmpty: AugmentedError<ApiType>;600 /**601 * Collection does not exist, has a wrong type, or does not map to a Unique ID.602 **/603 CollectionUnknown: AugmentedError<ApiType>;604 /**605 * Property of the type of RMRK collection could not be read successfully.606 **/607 CorruptedCollectionType: AugmentedError<ApiType>;608 /**609 * Could not find an ID for a collection. It is likely there were too many collections created on the chain, causing an overflow.610 **/611 NoAvailableCollectionId: AugmentedError<ApiType>;612 /**613 * Token does not exist, or there is no suitable ID for it, likely too many tokens were created in a collection, causing an overflow.614 **/615 NoAvailableNftId: AugmentedError<ApiType>;616 /**617 * Could not find an ID for the resource. It is likely there were too many resources created on an NFT, causing an overflow.618 **/619 NoAvailableResourceId: AugmentedError<ApiType>;620 /**621 * Token is marked as non-transferable, and thus cannot be transferred.622 **/623 NonTransferable: AugmentedError<ApiType>;624 /**625 * No permission to perform action.626 **/627 NoPermission: AugmentedError<ApiType>;628 /**629 * No such resource found.630 **/631 ResourceDoesntExist: AugmentedError<ApiType>;632 /**633 * Resource is not pending for the operation.634 **/635 ResourceNotPending: AugmentedError<ApiType>;636 /**637 * Could not find a property by the supplied key.638 **/639 RmrkPropertyIsNotFound: AugmentedError<ApiType>;640 /**641 * Too many symbols supplied as the property key. The maximum is [256](up_data_structs::MAX_PROPERTY_KEY_LENGTH).642 **/643 RmrkPropertyKeyIsTooLong: AugmentedError<ApiType>;644 /**645 * Too many bytes supplied as the property value. The maximum is [32768](up_data_structs::MAX_PROPERTY_VALUE_LENGTH).646 **/647 RmrkPropertyValueIsTooLong: AugmentedError<ApiType>;648 /**649 * Something went wrong when decoding encoded data from the storage.650 * Perhaps, there was a wrong key supplied for the type, or the data was improperly stored.651 **/652 UnableToDecodeRmrkData: AugmentedError<ApiType>;653 /**654 * Generic error655 **/656 [key: string]: AugmentedError<ApiType>;657 };658 rmrkEquip: {659 /**660 * Base collection linked to this ID does not exist.661 **/662 BaseDoesntExist: AugmentedError<ApiType>;663 /**664 * No Theme named "default" is associated with the Base.665 **/666 NeedsDefaultThemeFirst: AugmentedError<ApiType>;667 /**668 * Could not find an ID for a Base collection. It is likely there were too many collections created on the chain, causing an overflow.669 **/670 NoAvailableBaseId: AugmentedError<ApiType>;671 /**672 * Could not find a suitable ID for a Part, likely too many Part tokens were created in the Base, causing an overflow673 **/674 NoAvailablePartId: AugmentedError<ApiType>;675 /**676 * Cannot assign equippables to a fixed Part.677 **/678 NoEquippableOnFixedPart: AugmentedError<ApiType>;679 /**680 * Part linked to this ID does not exist.681 **/682 PartDoesntExist: AugmentedError<ApiType>;683 /**684 * No permission to perform action.685 **/686 PermissionError: AugmentedError<ApiType>;687 /**688 * Generic error689 **/690 [key: string]: AugmentedError<ApiType>;691 };692 structure: {693 /**694 * While nesting, reached the breadth limit of nesting, exceeding the provided budget.695 **/696 BreadthLimit: AugmentedError<ApiType>;697 /**698 * While nesting, reached the depth limit of nesting, exceeding the provided budget.699 **/700 DepthLimit: AugmentedError<ApiType>;701 /**702 * While nesting, encountered an already checked account, detecting a loop.703 **/704 OuroborosDetected: AugmentedError<ApiType>;705 /**706 * Couldn't find the token owner that is itself a token.707 **/708 TokenNotFound: AugmentedError<ApiType>;709 /**710 * Generic error711 **/712 [key: string]: AugmentedError<ApiType>;713 };714 sudo: {715 /**716 * Sender must be the Sudo account717 **/718 RequireSudo: AugmentedError<ApiType>;719 /**720 * Generic error721 **/722 [key: string]: AugmentedError<ApiType>;723 };724 system: {725 /**726 * The origin filter prevent the call to be dispatched.727 **/728 CallFiltered: AugmentedError<ApiType>;729 /**730 * Failed to extract the runtime version from the new runtime.731 * 732 * Either calling `Core_version` or decoding `RuntimeVersion` failed.733 **/734 FailedToExtractRuntimeVersion: AugmentedError<ApiType>;735 /**736 * The name of specification does not match between the current runtime737 * and the new runtime.738 **/739 InvalidSpecName: AugmentedError<ApiType>;740 /**741 * Suicide called when the account has non-default composite data.742 **/743 NonDefaultComposite: AugmentedError<ApiType>;744 /**745 * There is a non-zero reference count preventing the account from being purged.746 **/747 NonZeroRefCount: AugmentedError<ApiType>;748 /**749 * The specification version is not allowed to decrease between the current runtime750 * and the new runtime.751 **/752 SpecVersionNeedsToIncrease: AugmentedError<ApiType>;753 /**754 * Generic error755 **/756 [key: string]: AugmentedError<ApiType>;757 };758 testUtils: {759 TestPalletDisabled: AugmentedError<ApiType>;760 TriggerRollback: AugmentedError<ApiType>;761 /**762 * Generic error763 **/764 [key: string]: AugmentedError<ApiType>;765 };766 tokens: {767 /**768 * Cannot convert Amount into Balance type769 **/770 AmountIntoBalanceFailed: AugmentedError<ApiType>;771 /**772 * The balance is too low773 **/774 BalanceTooLow: AugmentedError<ApiType>;775 /**776 * Beneficiary account must pre-exist777 **/778 DeadAccount: AugmentedError<ApiType>;779 /**780 * Value too low to create account due to existential deposit781 **/782 ExistentialDeposit: AugmentedError<ApiType>;783 /**784 * Transfer/payment would kill account785 **/786 KeepAlive: AugmentedError<ApiType>;787 /**788 * Failed because liquidity restrictions due to locking789 **/790 LiquidityRestrictions: AugmentedError<ApiType>;791 /**792 * Failed because the maximum locks was exceeded793 **/794 MaxLocksExceeded: AugmentedError<ApiType>;795 TooManyReserves: AugmentedError<ApiType>;796 /**797 * Generic error798 **/799 [key: string]: AugmentedError<ApiType>;800 };801 treasury: {802 /**803 * The spend origin is valid but the amount it is allowed to spend is lower than the804 * amount to be spent.805 **/806 InsufficientPermission: AugmentedError<ApiType>;807 /**808 * Proposer's balance is too low.809 **/810 InsufficientProposersBalance: AugmentedError<ApiType>;811 /**812 * No proposal or bounty at that index.813 **/814 InvalidIndex: AugmentedError<ApiType>;815 /**816 * Proposal has not been approved.817 **/818 ProposalNotApproved: AugmentedError<ApiType>;819 /**820 * Too many approvals in the queue.821 **/822 TooManyApprovals: AugmentedError<ApiType>;823 /**824 * Generic error825 **/826 [key: string]: AugmentedError<ApiType>;827 };828 unique: {829 /**830 * Decimal_points parameter must be lower than [`up_data_structs::MAX_DECIMAL_POINTS`].831 **/832 CollectionDecimalPointLimitExceeded: AugmentedError<ApiType>;833 /**834 * Length of items properties must be greater than 0.835 **/836 EmptyArgument: AugmentedError<ApiType>;837 /**838 * Repertition is only supported by refungible collection.839 **/840 RepartitionCalledOnNonRefungibleCollection: AugmentedError<ApiType>;841 /**842 * Generic error843 **/844 [key: string]: AugmentedError<ApiType>;845 };846 vesting: {847 /**848 * The vested transfer amount is too low849 **/850 AmountLow: AugmentedError<ApiType>;851 /**852 * Insufficient amount of balance to lock853 **/854 InsufficientBalanceToLock: AugmentedError<ApiType>;855 /**856 * Failed because the maximum vesting schedules was exceeded857 **/858 MaxVestingSchedulesExceeded: AugmentedError<ApiType>;859 /**860 * This account have too many vesting schedules861 **/862 TooManyVestingSchedules: AugmentedError<ApiType>;863 /**864 * Vesting period is zero865 **/866 ZeroVestingPeriod: AugmentedError<ApiType>;867 /**868 * Number of vests is zero869 **/870 ZeroVestingPeriodCount: AugmentedError<ApiType>;871 /**872 * Generic error873 **/874 [key: string]: AugmentedError<ApiType>;875 };876 xcmpQueue: {877 /**878 * Bad overweight index.879 **/880 BadOverweightIndex: AugmentedError<ApiType>;881 /**882 * Bad XCM data.883 **/884 BadXcm: AugmentedError<ApiType>;885 /**886 * Bad XCM origin.887 **/888 BadXcmOrigin: AugmentedError<ApiType>;889 /**890 * Failed to send XCM message.891 **/892 FailedToSend: AugmentedError<ApiType>;893 /**894 * Provided weight is possibly not enough to execute the message.895 **/896 WeightOverLimit: AugmentedError<ApiType>;897 /**898 * Generic error899 **/900 [key: string]: AugmentedError<ApiType>;901 };902 xTokens: {903 /**904 * Asset has no reserve location.905 **/906 AssetHasNoReserve: AugmentedError<ApiType>;907 /**908 * The specified index does not exist in a MultiAssets struct.909 **/910 AssetIndexNonExistent: AugmentedError<ApiType>;911 /**912 * The version of the `Versioned` value used is not able to be913 * interpreted.914 **/915 BadVersion: AugmentedError<ApiType>;916 /**917 * Could not re-anchor the assets to declare the fees for the918 * destination chain.919 **/920 CannotReanchor: AugmentedError<ApiType>;921 /**922 * The destination `MultiLocation` provided cannot be inverted.923 **/924 DestinationNotInvertible: AugmentedError<ApiType>;925 /**926 * We tried sending distinct asset and fee but they have different927 * reserve chains.928 **/929 DistinctReserveForAssetAndFee: AugmentedError<ApiType>;930 /**931 * Fee is not enough.932 **/933 FeeNotEnough: AugmentedError<ApiType>;934 /**935 * Could not get ancestry of asset reserve location.936 **/937 InvalidAncestry: AugmentedError<ApiType>;938 /**939 * The MultiAsset is invalid.940 **/941 InvalidAsset: AugmentedError<ApiType>;942 /**943 * Invalid transfer destination.944 **/945 InvalidDest: AugmentedError<ApiType>;946 /**947 * MinXcmFee not registered for certain reserve location948 **/949 MinXcmFeeNotDefined: AugmentedError<ApiType>;950 /**951 * Not cross-chain transfer.952 **/953 NotCrossChainTransfer: AugmentedError<ApiType>;954 /**955 * Currency is not cross-chain transferable.956 **/957 NotCrossChainTransferableCurrency: AugmentedError<ApiType>;958 /**959 * Not supported MultiLocation960 **/961 NotSupportedMultiLocation: AugmentedError<ApiType>;962 /**963 * The number of assets to be sent is over the maximum.964 **/965 TooManyAssetsBeingSent: AugmentedError<ApiType>;966 /**967 * The message's weight could not be determined.968 **/969 UnweighableMessage: AugmentedError<ApiType>;970 /**971 * XCM execution failed.972 **/973 XcmExecutionFailed: AugmentedError<ApiType>;974 /**975 * The transfering asset amount is zero.976 **/977 ZeroAmount: AugmentedError<ApiType>;978 /**979 * The fee is zero.980 **/981 ZeroFee: AugmentedError<ApiType>;982 /**983 * Generic error984 **/985 [key: string]: AugmentedError<ApiType>;986 };987 } // AugmentedErrors988} // declare module1// Auto-generated via `yarn polkadot-types-from-chain`, do not edit2/* eslint-disable */34// import type lookup before we augment - in some environments5// this is required to allow for ambient/previous definitions6import '@polkadot/api-base/types/errors';78import type { ApiTypes, AugmentedError } from '@polkadot/api-base/types';910export type __AugmentedError<ApiType extends ApiTypes> = AugmentedError<ApiType>;1112declare module '@polkadot/api-base/types/errors' {13 interface AugmentedErrors<ApiType extends ApiTypes> {14 appPromotion: {15 /**16 * Error due to action requiring admin to be set.17 **/18 AdminNotSet: AugmentedError<ApiType>;19 /**20 * Errors caused by incorrect actions with a locked balance.21 **/22 IncorrectLockedBalanceOperation: AugmentedError<ApiType>;23 /**24 * No permission to perform an action.25 **/26 NoPermission: AugmentedError<ApiType>;27 /**28 * Insufficient funds to perform an action.29 **/30 NotSufficientFunds: AugmentedError<ApiType>;31 /**32 * Occurs when a pending unstake cannot be added in this block. PENDING_LIMIT_PER_BLOCK` limits exceeded.33 **/34 PendingForBlockOverflow: AugmentedError<ApiType>;35 /**36 * The error is due to the fact that the collection/contract must already be sponsored in order to perform the action.37 **/38 SponsorNotSet: AugmentedError<ApiType>;39 /**40 * Generic error41 **/42 [key: string]: AugmentedError<ApiType>;43 };44 balances: {45 /**46 * Beneficiary account must pre-exist47 **/48 DeadAccount: AugmentedError<ApiType>;49 /**50 * Value too low to create account due to existential deposit51 **/52 ExistentialDeposit: AugmentedError<ApiType>;53 /**54 * A vesting schedule already exists for this account55 **/56 ExistingVestingSchedule: AugmentedError<ApiType>;57 /**58 * Balance too low to send value.59 **/60 InsufficientBalance: AugmentedError<ApiType>;61 /**62 * Transfer/payment would kill account63 **/64 KeepAlive: AugmentedError<ApiType>;65 /**66 * Account liquidity restrictions prevent withdrawal67 **/68 LiquidityRestrictions: AugmentedError<ApiType>;69 /**70 * Number of named reserves exceed MaxReserves71 **/72 TooManyReserves: AugmentedError<ApiType>;73 /**74 * Vesting balance too high to send value75 **/76 VestingBalance: AugmentedError<ApiType>;77 /**78 * Generic error79 **/80 [key: string]: AugmentedError<ApiType>;81 };82 common: {83 /**84 * Account token limit exceeded per collection85 **/86 AccountTokenLimitExceeded: AugmentedError<ApiType>;87 /**88 * Only spending from eth mirror could be approved89 **/90 AddressIsNotEthMirror: AugmentedError<ApiType>;91 /**92 * Can't transfer tokens to ethereum zero address93 **/94 AddressIsZero: AugmentedError<ApiType>;95 /**96 * Address is not in allow list.97 **/98 AddressNotInAllowlist: AugmentedError<ApiType>;99 /**100 * Requested value is more than the approved101 **/102 ApprovedValueTooLow: AugmentedError<ApiType>;103 /**104 * Tried to approve more than owned105 **/106 CantApproveMoreThanOwned: AugmentedError<ApiType>;107 /**108 * Destroying only empty collections is allowed109 **/110 CantDestroyNotEmptyCollection: AugmentedError<ApiType>;111 /**112 * Exceeded max admin count113 **/114 CollectionAdminCountExceeded: AugmentedError<ApiType>;115 /**116 * Collection description can not be longer than 255 char.117 **/118 CollectionDescriptionLimitExceeded: AugmentedError<ApiType>;119 /**120 * Tried to store more data than allowed in collection field121 **/122 CollectionFieldSizeExceeded: AugmentedError<ApiType>;123 /**124 * Tried to access an external collection with an internal API125 **/126 CollectionIsExternal: AugmentedError<ApiType>;127 /**128 * Tried to access an internal collection with an external API129 **/130 CollectionIsInternal: AugmentedError<ApiType>;131 /**132 * Collection limit bounds per collection exceeded133 **/134 CollectionLimitBoundsExceeded: AugmentedError<ApiType>;135 /**136 * Collection name can not be longer than 63 char.137 **/138 CollectionNameLimitExceeded: AugmentedError<ApiType>;139 /**140 * This collection does not exist.141 **/142 CollectionNotFound: AugmentedError<ApiType>;143 /**144 * Collection token limit exceeded145 **/146 CollectionTokenLimitExceeded: AugmentedError<ApiType>;147 /**148 * Token prefix can not be longer than 15 char.149 **/150 CollectionTokenPrefixLimitExceeded: AugmentedError<ApiType>;151 /**152 * This address is not set as sponsor, use setCollectionSponsor first.153 **/154 ConfirmSponsorshipFail: AugmentedError<ApiType>;155 /**156 * Empty property keys are forbidden157 **/158 EmptyPropertyKey: AugmentedError<ApiType>;159 /**160 * Only ASCII letters, digits, and symbols `_`, `-`, and `.` are allowed161 **/162 InvalidCharacterInPropertyKey: AugmentedError<ApiType>;163 /**164 * Metadata flag frozen165 **/166 MetadataFlagFrozen: AugmentedError<ApiType>;167 /**168 * Sender parameter and item owner must be equal.169 **/170 MustBeTokenOwner: AugmentedError<ApiType>;171 /**172 * No permission to perform action173 **/174 NoPermission: AugmentedError<ApiType>;175 /**176 * Tried to store more property data than allowed177 **/178 NoSpaceForProperty: AugmentedError<ApiType>;179 /**180 * Insufficient funds to perform an action181 **/182 NotSufficientFounds: AugmentedError<ApiType>;183 /**184 * Tried to enable permissions which are only permitted to be disabled185 **/186 OwnerPermissionsCantBeReverted: AugmentedError<ApiType>;187 /**188 * Property key is too long189 **/190 PropertyKeyIsTooLong: AugmentedError<ApiType>;191 /**192 * Tried to store more property keys than allowed193 **/194 PropertyLimitReached: AugmentedError<ApiType>;195 /**196 * Collection is not in mint mode.197 **/198 PublicMintingNotAllowed: AugmentedError<ApiType>;199 /**200 * Only tokens from specific collections may nest tokens under this one201 **/202 SourceCollectionIsNotAllowedToNest: AugmentedError<ApiType>;203 /**204 * Item does not exist205 **/206 TokenNotFound: AugmentedError<ApiType>;207 /**208 * Item is balance not enough209 **/210 TokenValueTooLow: AugmentedError<ApiType>;211 /**212 * Total collections bound exceeded.213 **/214 TotalCollectionsLimitExceeded: AugmentedError<ApiType>;215 /**216 * Collection settings not allowing items transferring217 **/218 TransferNotAllowed: AugmentedError<ApiType>;219 /**220 * The operation is not supported221 **/222 UnsupportedOperation: AugmentedError<ApiType>;223 /**224 * User does not satisfy the nesting rule225 **/226 UserIsNotAllowedToNest: AugmentedError<ApiType>;227 /**228 * The user is not an administrator.229 **/230 UserIsNotCollectionAdmin: AugmentedError<ApiType>;231 /**232 * Generic error233 **/234 [key: string]: AugmentedError<ApiType>;235 };236 configuration: {237 InconsistentConfiguration: AugmentedError<ApiType>;238 /**239 * Generic error240 **/241 [key: string]: AugmentedError<ApiType>;242 };243 cumulusXcm: {244 /**245 * Generic error246 **/247 [key: string]: AugmentedError<ApiType>;248 };249 dmpQueue: {250 /**251 * The amount of weight given is possibly not enough for executing the message.252 **/253 OverLimit: AugmentedError<ApiType>;254 /**255 * The message index given is unknown.256 **/257 Unknown: AugmentedError<ApiType>;258 /**259 * Generic error260 **/261 [key: string]: AugmentedError<ApiType>;262 };263 ethereum: {264 /**265 * Signature is invalid.266 **/267 InvalidSignature: AugmentedError<ApiType>;268 /**269 * Pre-log is present, therefore transact is not allowed.270 **/271 PreLogExists: AugmentedError<ApiType>;272 /**273 * Generic error274 **/275 [key: string]: AugmentedError<ApiType>;276 };277 evm: {278 /**279 * Not enough balance to perform action280 **/281 BalanceLow: AugmentedError<ApiType>;282 /**283 * Calculating total fee overflowed284 **/285 FeeOverflow: AugmentedError<ApiType>;286 /**287 * Gas limit is too high.288 **/289 GasLimitTooHigh: AugmentedError<ApiType>;290 /**291 * Gas limit is too low.292 **/293 GasLimitTooLow: AugmentedError<ApiType>;294 /**295 * Gas price is too low.296 **/297 GasPriceTooLow: AugmentedError<ApiType>;298 /**299 * Nonce is invalid300 **/301 InvalidNonce: AugmentedError<ApiType>;302 /**303 * Calculating total payment overflowed304 **/305 PaymentOverflow: AugmentedError<ApiType>;306 /**307 * EVM reentrancy308 **/309 Reentrancy: AugmentedError<ApiType>;310 /**311 * EIP-3607,312 **/313 TransactionMustComeFromEOA: AugmentedError<ApiType>;314 /**315 * Undefined error.316 **/317 Undefined: AugmentedError<ApiType>;318 /**319 * Withdraw fee failed320 **/321 WithdrawFailed: AugmentedError<ApiType>;322 /**323 * Generic error324 **/325 [key: string]: AugmentedError<ApiType>;326 };327 evmCoderSubstrate: {328 OutOfFund: AugmentedError<ApiType>;329 OutOfGas: AugmentedError<ApiType>;330 /**331 * Generic error332 **/333 [key: string]: AugmentedError<ApiType>;334 };335 evmContractHelpers: {336 /**337 * No pending sponsor for contract.338 **/339 NoPendingSponsor: AugmentedError<ApiType>;340 /**341 * This method is only executable by contract owner342 **/343 NoPermission: AugmentedError<ApiType>;344 /**345 * Number of methods that sponsored limit is defined for exceeds maximum.346 **/347 TooManyMethodsHaveSponsoredLimit: AugmentedError<ApiType>;348 /**349 * Generic error350 **/351 [key: string]: AugmentedError<ApiType>;352 };353 evmMigration: {354 /**355 * Migration of this account is not yet started, or already finished.356 **/357 AccountIsNotMigrating: AugmentedError<ApiType>;358 /**359 * Can only migrate to empty address.360 **/361 AccountNotEmpty: AugmentedError<ApiType>;362 /**363 * Failed to decode event bytes364 **/365 BadEvent: AugmentedError<ApiType>;366 /**367 * Generic error368 **/369 [key: string]: AugmentedError<ApiType>;370 };371 foreignAssets: {372 /**373 * AssetId exists374 **/375 AssetIdExisted: AugmentedError<ApiType>;376 /**377 * AssetId not exists378 **/379 AssetIdNotExists: AugmentedError<ApiType>;380 /**381 * The given location could not be used (e.g. because it cannot be expressed in the382 * desired version of XCM).383 **/384 BadLocation: AugmentedError<ApiType>;385 /**386 * MultiLocation existed387 **/388 MultiLocationExisted: AugmentedError<ApiType>;389 /**390 * Generic error391 **/392 [key: string]: AugmentedError<ApiType>;393 };394 fungible: {395 /**396 * Fungible token does not support nesting.397 **/398 FungibleDisallowsNesting: AugmentedError<ApiType>;399 /**400 * Tried to set data for fungible item.401 **/402 FungibleItemsDontHaveData: AugmentedError<ApiType>;403 /**404 * Fungible tokens hold no ID, and the default value of TokenId for Fungible collection is 0.405 **/406 FungibleItemsHaveNoId: AugmentedError<ApiType>;407 /**408 * Only a fungible collection could be possibly broken; any fungible token is valid.409 **/410 FungibleTokensAreAlwaysValid: AugmentedError<ApiType>;411 /**412 * Not Fungible item data used to mint in Fungible collection.413 **/414 NotFungibleDataUsedToMintFungibleCollectionToken: AugmentedError<ApiType>;415 /**416 * Setting allowance for all is not allowed.417 **/418 SettingAllowanceForAllNotAllowed: AugmentedError<ApiType>;419 /**420 * Setting item properties is not allowed.421 **/422 SettingPropertiesNotAllowed: AugmentedError<ApiType>;423 /**424 * Generic error425 **/426 [key: string]: AugmentedError<ApiType>;427 };428 maintenance: {429 /**430 * Generic error431 **/432 [key: string]: AugmentedError<ApiType>;433 };434 nonfungible: {435 /**436 * Unable to burn NFT with children437 **/438 CantBurnNftWithChildren: AugmentedError<ApiType>;439 /**440 * Used amount > 1 with NFT441 **/442 NonfungibleItemsHaveNoAmount: AugmentedError<ApiType>;443 /**444 * Not Nonfungible item data used to mint in Nonfungible collection.445 **/446 NotNonfungibleDataUsedToMintFungibleCollectionToken: AugmentedError<ApiType>;447 /**448 * Generic error449 **/450 [key: string]: AugmentedError<ApiType>;451 };452 parachainSystem: {453 /**454 * The inherent which supplies the host configuration did not run this block455 **/456 HostConfigurationNotAvailable: AugmentedError<ApiType>;457 /**458 * No code upgrade has been authorized.459 **/460 NothingAuthorized: AugmentedError<ApiType>;461 /**462 * No validation function upgrade is currently scheduled.463 **/464 NotScheduled: AugmentedError<ApiType>;465 /**466 * Attempt to upgrade validation function while existing upgrade pending467 **/468 OverlappingUpgrades: AugmentedError<ApiType>;469 /**470 * Polkadot currently prohibits this parachain from upgrading its validation function471 **/472 ProhibitedByPolkadot: AugmentedError<ApiType>;473 /**474 * The supplied validation function has compiled into a blob larger than Polkadot is475 * willing to run476 **/477 TooBig: AugmentedError<ApiType>;478 /**479 * The given code upgrade has not been authorized.480 **/481 Unauthorized: AugmentedError<ApiType>;482 /**483 * The inherent which supplies the validation data did not run this block484 **/485 ValidationDataNotAvailable: AugmentedError<ApiType>;486 /**487 * Generic error488 **/489 [key: string]: AugmentedError<ApiType>;490 };491 polkadotXcm: {492 /**493 * The location is invalid since it already has a subscription from us.494 **/495 AlreadySubscribed: AugmentedError<ApiType>;496 /**497 * The given location could not be used (e.g. because it cannot be expressed in the498 * desired version of XCM).499 **/500 BadLocation: AugmentedError<ApiType>;501 /**502 * The version of the `Versioned` value used is not able to be interpreted.503 **/504 BadVersion: AugmentedError<ApiType>;505 /**506 * Could not re-anchor the assets to declare the fees for the destination chain.507 **/508 CannotReanchor: AugmentedError<ApiType>;509 /**510 * The destination `MultiLocation` provided cannot be inverted.511 **/512 DestinationNotInvertible: AugmentedError<ApiType>;513 /**514 * The assets to be sent are empty.515 **/516 Empty: AugmentedError<ApiType>;517 /**518 * The message execution fails the filter.519 **/520 Filtered: AugmentedError<ApiType>;521 /**522 * Origin is invalid for sending.523 **/524 InvalidOrigin: AugmentedError<ApiType>;525 /**526 * The referenced subscription could not be found.527 **/528 NoSubscription: AugmentedError<ApiType>;529 /**530 * There was some other issue (i.e. not to do with routing) in sending the message. Perhaps531 * a lack of space for buffering the message.532 **/533 SendFailure: AugmentedError<ApiType>;534 /**535 * Too many assets have been attempted for transfer.536 **/537 TooManyAssets: AugmentedError<ApiType>;538 /**539 * The desired destination was unreachable, generally because there is a no way of routing540 * to it.541 **/542 Unreachable: AugmentedError<ApiType>;543 /**544 * The message's weight could not be determined.545 **/546 UnweighableMessage: AugmentedError<ApiType>;547 /**548 * Generic error549 **/550 [key: string]: AugmentedError<ApiType>;551 };552 refungible: {553 /**554 * Not Refungible item data used to mint in Refungible collection.555 **/556 NotRefungibleDataUsedToMintFungibleCollectionToken: AugmentedError<ApiType>;557 /**558 * Refungible token can't nest other tokens.559 **/560 RefungibleDisallowsNesting: AugmentedError<ApiType>;561 /**562 * Refungible token can't be repartitioned by user who isn't owns all pieces.563 **/564 RepartitionWhileNotOwningAllPieces: AugmentedError<ApiType>;565 /**566 * Setting item properties is not allowed.567 **/568 SettingPropertiesNotAllowed: AugmentedError<ApiType>;569 /**570 * Maximum refungibility exceeded.571 **/572 WrongRefungiblePieces: AugmentedError<ApiType>;573 /**574 * Generic error575 **/576 [key: string]: AugmentedError<ApiType>;577 };578 rmrkCore: {579 /**580 * Not the target owner of the sent NFT.581 **/582 CannotAcceptNonOwnedNft: AugmentedError<ApiType>;583 /**584 * Not the target owner of the sent NFT.585 **/586 CannotRejectNonOwnedNft: AugmentedError<ApiType>;587 /**588 * NFT was not sent and is not pending.589 **/590 CannotRejectNonPendingNft: AugmentedError<ApiType>;591 /**592 * If an NFT is sent to a descendant, that would form a nesting loop, an ouroboros.593 * Sending to self is redundant.594 **/595 CannotSendToDescendentOrSelf: AugmentedError<ApiType>;596 /**597 * Too many tokens created in the collection, no new ones are allowed.598 **/599 CollectionFullOrLocked: AugmentedError<ApiType>;600 /**601 * Only destroying collections without tokens is allowed.602 **/603 CollectionNotEmpty: AugmentedError<ApiType>;604 /**605 * Collection does not exist, has a wrong type, or does not map to a Unique ID.606 **/607 CollectionUnknown: AugmentedError<ApiType>;608 /**609 * Property of the type of RMRK collection could not be read successfully.610 **/611 CorruptedCollectionType: AugmentedError<ApiType>;612 /**613 * Could not find an ID for a collection. It is likely there were too many collections created on the chain, causing an overflow.614 **/615 NoAvailableCollectionId: AugmentedError<ApiType>;616 /**617 * Token does not exist, or there is no suitable ID for it, likely too many tokens were created in a collection, causing an overflow.618 **/619 NoAvailableNftId: AugmentedError<ApiType>;620 /**621 * Could not find an ID for the resource. It is likely there were too many resources created on an NFT, causing an overflow.622 **/623 NoAvailableResourceId: AugmentedError<ApiType>;624 /**625 * Token is marked as non-transferable, and thus cannot be transferred.626 **/627 NonTransferable: AugmentedError<ApiType>;628 /**629 * No permission to perform action.630 **/631 NoPermission: AugmentedError<ApiType>;632 /**633 * No such resource found.634 **/635 ResourceDoesntExist: AugmentedError<ApiType>;636 /**637 * Resource is not pending for the operation.638 **/639 ResourceNotPending: AugmentedError<ApiType>;640 /**641 * Could not find a property by the supplied key.642 **/643 RmrkPropertyIsNotFound: AugmentedError<ApiType>;644 /**645 * Too many symbols supplied as the property key. The maximum is [256](up_data_structs::MAX_PROPERTY_KEY_LENGTH).646 **/647 RmrkPropertyKeyIsTooLong: AugmentedError<ApiType>;648 /**649 * Too many bytes supplied as the property value. The maximum is [32768](up_data_structs::MAX_PROPERTY_VALUE_LENGTH).650 **/651 RmrkPropertyValueIsTooLong: AugmentedError<ApiType>;652 /**653 * Something went wrong when decoding encoded data from the storage.654 * Perhaps, there was a wrong key supplied for the type, or the data was improperly stored.655 **/656 UnableToDecodeRmrkData: AugmentedError<ApiType>;657 /**658 * Generic error659 **/660 [key: string]: AugmentedError<ApiType>;661 };662 rmrkEquip: {663 /**664 * Base collection linked to this ID does not exist.665 **/666 BaseDoesntExist: AugmentedError<ApiType>;667 /**668 * No Theme named "default" is associated with the Base.669 **/670 NeedsDefaultThemeFirst: AugmentedError<ApiType>;671 /**672 * Could not find an ID for a Base collection. It is likely there were too many collections created on the chain, causing an overflow.673 **/674 NoAvailableBaseId: AugmentedError<ApiType>;675 /**676 * Could not find a suitable ID for a Part, likely too many Part tokens were created in the Base, causing an overflow677 **/678 NoAvailablePartId: AugmentedError<ApiType>;679 /**680 * Cannot assign equippables to a fixed Part.681 **/682 NoEquippableOnFixedPart: AugmentedError<ApiType>;683 /**684 * Part linked to this ID does not exist.685 **/686 PartDoesntExist: AugmentedError<ApiType>;687 /**688 * No permission to perform action.689 **/690 PermissionError: AugmentedError<ApiType>;691 /**692 * Generic error693 **/694 [key: string]: AugmentedError<ApiType>;695 };696 structure: {697 /**698 * While nesting, reached the breadth limit of nesting, exceeding the provided budget.699 **/700 BreadthLimit: AugmentedError<ApiType>;701 /**702 * While nesting, reached the depth limit of nesting, exceeding the provided budget.703 **/704 DepthLimit: AugmentedError<ApiType>;705 /**706 * While nesting, encountered an already checked account, detecting a loop.707 **/708 OuroborosDetected: AugmentedError<ApiType>;709 /**710 * Couldn't find the token owner that is itself a token.711 **/712 TokenNotFound: AugmentedError<ApiType>;713 /**714 * Generic error715 **/716 [key: string]: AugmentedError<ApiType>;717 };718 sudo: {719 /**720 * Sender must be the Sudo account721 **/722 RequireSudo: AugmentedError<ApiType>;723 /**724 * Generic error725 **/726 [key: string]: AugmentedError<ApiType>;727 };728 system: {729 /**730 * The origin filter prevent the call to be dispatched.731 **/732 CallFiltered: AugmentedError<ApiType>;733 /**734 * Failed to extract the runtime version from the new runtime.735 * 736 * Either calling `Core_version` or decoding `RuntimeVersion` failed.737 **/738 FailedToExtractRuntimeVersion: AugmentedError<ApiType>;739 /**740 * The name of specification does not match between the current runtime741 * and the new runtime.742 **/743 InvalidSpecName: AugmentedError<ApiType>;744 /**745 * Suicide called when the account has non-default composite data.746 **/747 NonDefaultComposite: AugmentedError<ApiType>;748 /**749 * There is a non-zero reference count preventing the account from being purged.750 **/751 NonZeroRefCount: AugmentedError<ApiType>;752 /**753 * The specification version is not allowed to decrease between the current runtime754 * and the new runtime.755 **/756 SpecVersionNeedsToIncrease: AugmentedError<ApiType>;757 /**758 * Generic error759 **/760 [key: string]: AugmentedError<ApiType>;761 };762 testUtils: {763 TestPalletDisabled: AugmentedError<ApiType>;764 TriggerRollback: AugmentedError<ApiType>;765 /**766 * Generic error767 **/768 [key: string]: AugmentedError<ApiType>;769 };770 tokens: {771 /**772 * Cannot convert Amount into Balance type773 **/774 AmountIntoBalanceFailed: AugmentedError<ApiType>;775 /**776 * The balance is too low777 **/778 BalanceTooLow: AugmentedError<ApiType>;779 /**780 * Beneficiary account must pre-exist781 **/782 DeadAccount: AugmentedError<ApiType>;783 /**784 * Value too low to create account due to existential deposit785 **/786 ExistentialDeposit: AugmentedError<ApiType>;787 /**788 * Transfer/payment would kill account789 **/790 KeepAlive: AugmentedError<ApiType>;791 /**792 * Failed because liquidity restrictions due to locking793 **/794 LiquidityRestrictions: AugmentedError<ApiType>;795 /**796 * Failed because the maximum locks was exceeded797 **/798 MaxLocksExceeded: AugmentedError<ApiType>;799 TooManyReserves: AugmentedError<ApiType>;800 /**801 * Generic error802 **/803 [key: string]: AugmentedError<ApiType>;804 };805 treasury: {806 /**807 * The spend origin is valid but the amount it is allowed to spend is lower than the808 * amount to be spent.809 **/810 InsufficientPermission: AugmentedError<ApiType>;811 /**812 * Proposer's balance is too low.813 **/814 InsufficientProposersBalance: AugmentedError<ApiType>;815 /**816 * No proposal or bounty at that index.817 **/818 InvalidIndex: AugmentedError<ApiType>;819 /**820 * Proposal has not been approved.821 **/822 ProposalNotApproved: AugmentedError<ApiType>;823 /**824 * Too many approvals in the queue.825 **/826 TooManyApprovals: AugmentedError<ApiType>;827 /**828 * Generic error829 **/830 [key: string]: AugmentedError<ApiType>;831 };832 unique: {833 /**834 * Decimal_points parameter must be lower than [`up_data_structs::MAX_DECIMAL_POINTS`].835 **/836 CollectionDecimalPointLimitExceeded: AugmentedError<ApiType>;837 /**838 * Length of items properties must be greater than 0.839 **/840 EmptyArgument: AugmentedError<ApiType>;841 /**842 * Repertition is only supported by refungible collection.843 **/844 RepartitionCalledOnNonRefungibleCollection: AugmentedError<ApiType>;845 /**846 * Generic error847 **/848 [key: string]: AugmentedError<ApiType>;849 };850 vesting: {851 /**852 * The vested transfer amount is too low853 **/854 AmountLow: AugmentedError<ApiType>;855 /**856 * Insufficient amount of balance to lock857 **/858 InsufficientBalanceToLock: AugmentedError<ApiType>;859 /**860 * Failed because the maximum vesting schedules was exceeded861 **/862 MaxVestingSchedulesExceeded: AugmentedError<ApiType>;863 /**864 * This account have too many vesting schedules865 **/866 TooManyVestingSchedules: AugmentedError<ApiType>;867 /**868 * Vesting period is zero869 **/870 ZeroVestingPeriod: AugmentedError<ApiType>;871 /**872 * Number of vests is zero873 **/874 ZeroVestingPeriodCount: AugmentedError<ApiType>;875 /**876 * Generic error877 **/878 [key: string]: AugmentedError<ApiType>;879 };880 xcmpQueue: {881 /**882 * Bad overweight index.883 **/884 BadOverweightIndex: AugmentedError<ApiType>;885 /**886 * Bad XCM data.887 **/888 BadXcm: AugmentedError<ApiType>;889 /**890 * Bad XCM origin.891 **/892 BadXcmOrigin: AugmentedError<ApiType>;893 /**894 * Failed to send XCM message.895 **/896 FailedToSend: AugmentedError<ApiType>;897 /**898 * Provided weight is possibly not enough to execute the message.899 **/900 WeightOverLimit: AugmentedError<ApiType>;901 /**902 * Generic error903 **/904 [key: string]: AugmentedError<ApiType>;905 };906 xTokens: {907 /**908 * Asset has no reserve location.909 **/910 AssetHasNoReserve: AugmentedError<ApiType>;911 /**912 * The specified index does not exist in a MultiAssets struct.913 **/914 AssetIndexNonExistent: AugmentedError<ApiType>;915 /**916 * The version of the `Versioned` value used is not able to be917 * interpreted.918 **/919 BadVersion: AugmentedError<ApiType>;920 /**921 * Could not re-anchor the assets to declare the fees for the922 * destination chain.923 **/924 CannotReanchor: AugmentedError<ApiType>;925 /**926 * The destination `MultiLocation` provided cannot be inverted.927 **/928 DestinationNotInvertible: AugmentedError<ApiType>;929 /**930 * We tried sending distinct asset and fee but they have different931 * reserve chains.932 **/933 DistinctReserveForAssetAndFee: AugmentedError<ApiType>;934 /**935 * Fee is not enough.936 **/937 FeeNotEnough: AugmentedError<ApiType>;938 /**939 * Could not get ancestry of asset reserve location.940 **/941 InvalidAncestry: AugmentedError<ApiType>;942 /**943 * The MultiAsset is invalid.944 **/945 InvalidAsset: AugmentedError<ApiType>;946 /**947 * Invalid transfer destination.948 **/949 InvalidDest: AugmentedError<ApiType>;950 /**951 * MinXcmFee not registered for certain reserve location952 **/953 MinXcmFeeNotDefined: AugmentedError<ApiType>;954 /**955 * Not cross-chain transfer.956 **/957 NotCrossChainTransfer: AugmentedError<ApiType>;958 /**959 * Currency is not cross-chain transferable.960 **/961 NotCrossChainTransferableCurrency: AugmentedError<ApiType>;962 /**963 * Not supported MultiLocation964 **/965 NotSupportedMultiLocation: AugmentedError<ApiType>;966 /**967 * The number of assets to be sent is over the maximum.968 **/969 TooManyAssetsBeingSent: AugmentedError<ApiType>;970 /**971 * The message's weight could not be determined.972 **/973 UnweighableMessage: AugmentedError<ApiType>;974 /**975 * XCM execution failed.976 **/977 XcmExecutionFailed: AugmentedError<ApiType>;978 /**979 * The transfering asset amount is zero.980 **/981 ZeroAmount: AugmentedError<ApiType>;982 /**983 * The fee is zero.984 **/985 ZeroFee: AugmentedError<ApiType>;986 /**987 * Generic error988 **/989 [key: string]: AugmentedError<ApiType>;990 };991 } // AugmentedErrors992} // declare moduletests/src/interfaces/augment-api-tx.tsdiffbeforeafterboth--- a/tests/src/interfaces/augment-api-tx.ts
+++ b/tests/src/interfaces/augment-api-tx.ts
@@ -1214,6 +1214,25 @@
**/
approve: AugmentedSubmittable<(spender: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, collectionId: u32 | AnyNumber | Uint8Array, itemId: u32 | AnyNumber | Uint8Array, amount: u128 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [PalletEvmAccountBasicCrossAccountIdRepr, u32, u32, u128]>;
/**
+ * Allow a non-permissioned address to transfer or burn an item from owner's eth mirror.
+ *
+ * # Permissions
+ *
+ * * Collection owner
+ * * Collection admin
+ * * Current item owner
+ *
+ * # Arguments
+ *
+ * * `from`: Owner's account eth mirror
+ * * `to`: Account to be approved to make specific transactions on non-owned tokens.
+ * * `collection_id`: ID of the collection the item belongs to.
+ * * `item_id`: ID of the item transactions on which are now approved.
+ * * `amount`: Number of pieces of the item approved for a transaction (maximum of 1 for NFTs).
+ * Set to 0 to revoke the approval.
+ **/
+ approveFrom: AugmentedSubmittable<(from: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, to: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, collectionId: u32 | AnyNumber | Uint8Array, itemId: u32 | AnyNumber | Uint8Array, amount: u128 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [PalletEvmAccountBasicCrossAccountIdRepr, PalletEvmAccountBasicCrossAccountIdRepr, u32, u32, u128]>;
+ /**
* Destroy a token on behalf of the owner as a non-owner account.
*
* See also: [`approve`][`Pallet::approve`].
tests/src/interfaces/default/types.tsdiffbeforeafterboth--- a/tests/src/interfaces/default/types.ts
+++ b/tests/src/interfaces/default/types.ts
@@ -1216,6 +1216,7 @@
readonly isTokenValueTooLow: boolean;
readonly isApprovedValueTooLow: boolean;
readonly isCantApproveMoreThanOwned: boolean;
+ readonly isAddressIsNotEthMirror: boolean;
readonly isAddressIsZero: boolean;
readonly isUnsupportedOperation: boolean;
readonly isNotSufficientFounds: boolean;
@@ -1231,7 +1232,7 @@
readonly isCollectionIsInternal: boolean;
readonly isConfirmSponsorshipFail: boolean;
readonly isUserIsNotCollectionAdmin: boolean;
- readonly type: 'CollectionNotFound' | 'MustBeTokenOwner' | 'NoPermission' | 'CantDestroyNotEmptyCollection' | 'PublicMintingNotAllowed' | 'AddressNotInAllowlist' | 'CollectionNameLimitExceeded' | 'CollectionDescriptionLimitExceeded' | 'CollectionTokenPrefixLimitExceeded' | 'TotalCollectionsLimitExceeded' | 'CollectionAdminCountExceeded' | 'CollectionLimitBoundsExceeded' | 'OwnerPermissionsCantBeReverted' | 'TransferNotAllowed' | 'AccountTokenLimitExceeded' | 'CollectionTokenLimitExceeded' | 'MetadataFlagFrozen' | 'TokenNotFound' | 'TokenValueTooLow' | 'ApprovedValueTooLow' | 'CantApproveMoreThanOwned' | 'AddressIsZero' | 'UnsupportedOperation' | 'NotSufficientFounds' | 'UserIsNotAllowedToNest' | 'SourceCollectionIsNotAllowedToNest' | 'CollectionFieldSizeExceeded' | 'NoSpaceForProperty' | 'PropertyLimitReached' | 'PropertyKeyIsTooLong' | 'InvalidCharacterInPropertyKey' | 'EmptyPropertyKey' | 'CollectionIsExternal' | 'CollectionIsInternal' | 'ConfirmSponsorshipFail' | 'UserIsNotCollectionAdmin';
+ readonly type: 'CollectionNotFound' | 'MustBeTokenOwner' | 'NoPermission' | 'CantDestroyNotEmptyCollection' | 'PublicMintingNotAllowed' | 'AddressNotInAllowlist' | 'CollectionNameLimitExceeded' | 'CollectionDescriptionLimitExceeded' | 'CollectionTokenPrefixLimitExceeded' | 'TotalCollectionsLimitExceeded' | 'CollectionAdminCountExceeded' | 'CollectionLimitBoundsExceeded' | 'OwnerPermissionsCantBeReverted' | 'TransferNotAllowed' | 'AccountTokenLimitExceeded' | 'CollectionTokenLimitExceeded' | 'MetadataFlagFrozen' | 'TokenNotFound' | 'TokenValueTooLow' | 'ApprovedValueTooLow' | 'CantApproveMoreThanOwned' | 'AddressIsNotEthMirror' | 'AddressIsZero' | 'UnsupportedOperation' | 'NotSufficientFounds' | 'UserIsNotAllowedToNest' | 'SourceCollectionIsNotAllowedToNest' | 'CollectionFieldSizeExceeded' | 'NoSpaceForProperty' | 'PropertyLimitReached' | 'PropertyKeyIsTooLong' | 'InvalidCharacterInPropertyKey' | 'EmptyPropertyKey' | 'CollectionIsExternal' | 'CollectionIsInternal' | 'ConfirmSponsorshipFail' | 'UserIsNotCollectionAdmin';
}
/** @name PalletCommonEvent */
@@ -2306,6 +2307,14 @@
readonly itemId: u32;
readonly amount: u128;
} & Struct;
+ readonly isApproveFrom: boolean;
+ readonly asApproveFrom: {
+ readonly from: PalletEvmAccountBasicCrossAccountIdRepr;
+ readonly to: PalletEvmAccountBasicCrossAccountIdRepr;
+ readonly collectionId: u32;
+ readonly itemId: u32;
+ readonly amount: u128;
+ } & Struct;
readonly isTransferFrom: boolean;
readonly asTransferFrom: {
readonly from: PalletEvmAccountBasicCrossAccountIdRepr;
@@ -2345,7 +2354,7 @@
readonly collectionId: u32;
readonly itemId: u32;
} & Struct;
- readonly type: 'CreateCollection' | 'CreateCollectionEx' | 'DestroyCollection' | 'AddToAllowList' | 'RemoveFromAllowList' | 'ChangeCollectionOwner' | 'AddCollectionAdmin' | 'RemoveCollectionAdmin' | 'SetCollectionSponsor' | 'ConfirmSponsorship' | 'RemoveCollectionSponsor' | 'CreateItem' | 'CreateMultipleItems' | 'SetCollectionProperties' | 'DeleteCollectionProperties' | 'SetTokenProperties' | 'DeleteTokenProperties' | 'SetTokenPropertyPermissions' | 'CreateMultipleItemsEx' | 'SetTransfersEnabledFlag' | 'BurnItem' | 'BurnFrom' | 'Transfer' | 'Approve' | 'TransferFrom' | 'SetCollectionLimits' | 'SetCollectionPermissions' | 'Repartition' | 'SetAllowanceForAll' | 'ForceRepairCollection' | 'ForceRepairItem';
+ readonly type: 'CreateCollection' | 'CreateCollectionEx' | 'DestroyCollection' | 'AddToAllowList' | 'RemoveFromAllowList' | 'ChangeCollectionOwner' | 'AddCollectionAdmin' | 'RemoveCollectionAdmin' | 'SetCollectionSponsor' | 'ConfirmSponsorship' | 'RemoveCollectionSponsor' | 'CreateItem' | 'CreateMultipleItems' | 'SetCollectionProperties' | 'DeleteCollectionProperties' | 'SetTokenProperties' | 'DeleteTokenProperties' | 'SetTokenPropertyPermissions' | 'CreateMultipleItemsEx' | 'SetTransfersEnabledFlag' | 'BurnItem' | 'BurnFrom' | 'Transfer' | 'Approve' | 'ApproveFrom' | 'TransferFrom' | 'SetCollectionLimits' | 'SetCollectionPermissions' | 'Repartition' | 'SetAllowanceForAll' | 'ForceRepairCollection' | 'ForceRepairItem';
}
/** @name PalletUniqueError */
tests/src/interfaces/lookup.tsdiffbeforeafterboth--- a/tests/src/interfaces/lookup.ts
+++ b/tests/src/interfaces/lookup.ts
@@ -2264,6 +2264,13 @@
itemId: 'u32',
amount: 'u128',
},
+ approve_from: {
+ from: 'PalletEvmAccountBasicCrossAccountIdRepr',
+ to: 'PalletEvmAccountBasicCrossAccountIdRepr',
+ collectionId: 'u32',
+ itemId: 'u32',
+ amount: 'u128',
+ },
transfer_from: {
from: 'PalletEvmAccountBasicCrossAccountIdRepr',
recipient: 'PalletEvmAccountBasicCrossAccountIdRepr',
@@ -3280,7 +3287,7 @@
* Lookup423: pallet_common::pallet::Error<T>
**/
PalletCommonError: {
- _enum: ['CollectionNotFound', 'MustBeTokenOwner', 'NoPermission', 'CantDestroyNotEmptyCollection', 'PublicMintingNotAllowed', 'AddressNotInAllowlist', 'CollectionNameLimitExceeded', 'CollectionDescriptionLimitExceeded', 'CollectionTokenPrefixLimitExceeded', 'TotalCollectionsLimitExceeded', 'CollectionAdminCountExceeded', 'CollectionLimitBoundsExceeded', 'OwnerPermissionsCantBeReverted', 'TransferNotAllowed', 'AccountTokenLimitExceeded', 'CollectionTokenLimitExceeded', 'MetadataFlagFrozen', 'TokenNotFound', 'TokenValueTooLow', 'ApprovedValueTooLow', 'CantApproveMoreThanOwned', 'AddressIsZero', 'UnsupportedOperation', 'NotSufficientFounds', 'UserIsNotAllowedToNest', 'SourceCollectionIsNotAllowedToNest', 'CollectionFieldSizeExceeded', 'NoSpaceForProperty', 'PropertyLimitReached', 'PropertyKeyIsTooLong', 'InvalidCharacterInPropertyKey', 'EmptyPropertyKey', 'CollectionIsExternal', 'CollectionIsInternal', 'ConfirmSponsorshipFail', 'UserIsNotCollectionAdmin']
+ _enum: ['CollectionNotFound', 'MustBeTokenOwner', 'NoPermission', 'CantDestroyNotEmptyCollection', 'PublicMintingNotAllowed', 'AddressNotInAllowlist', 'CollectionNameLimitExceeded', 'CollectionDescriptionLimitExceeded', 'CollectionTokenPrefixLimitExceeded', 'TotalCollectionsLimitExceeded', 'CollectionAdminCountExceeded', 'CollectionLimitBoundsExceeded', 'OwnerPermissionsCantBeReverted', 'TransferNotAllowed', 'AccountTokenLimitExceeded', 'CollectionTokenLimitExceeded', 'MetadataFlagFrozen', 'TokenNotFound', 'TokenValueTooLow', 'ApprovedValueTooLow', 'CantApproveMoreThanOwned', 'AddressIsNotEthMirror', 'AddressIsZero', 'UnsupportedOperation', 'NotSufficientFounds', 'UserIsNotAllowedToNest', 'SourceCollectionIsNotAllowedToNest', 'CollectionFieldSizeExceeded', 'NoSpaceForProperty', 'PropertyLimitReached', 'PropertyKeyIsTooLong', 'InvalidCharacterInPropertyKey', 'EmptyPropertyKey', 'CollectionIsExternal', 'CollectionIsInternal', 'ConfirmSponsorshipFail', 'UserIsNotCollectionAdmin']
},
/**
* Lookup425: pallet_fungible::pallet::Error<T>
tests/src/interfaces/types-lookup.tsdiffbeforeafterboth--- a/tests/src/interfaces/types-lookup.ts
+++ b/tests/src/interfaces/types-lookup.ts
@@ -2493,6 +2493,14 @@
readonly itemId: u32;
readonly amount: u128;
} & Struct;
+ readonly isApproveFrom: boolean;
+ readonly asApproveFrom: {
+ readonly from: PalletEvmAccountBasicCrossAccountIdRepr;
+ readonly to: PalletEvmAccountBasicCrossAccountIdRepr;
+ readonly collectionId: u32;
+ readonly itemId: u32;
+ readonly amount: u128;
+ } & Struct;
readonly isTransferFrom: boolean;
readonly asTransferFrom: {
readonly from: PalletEvmAccountBasicCrossAccountIdRepr;
@@ -2532,7 +2540,7 @@
readonly collectionId: u32;
readonly itemId: u32;
} & Struct;
- readonly type: 'CreateCollection' | 'CreateCollectionEx' | 'DestroyCollection' | 'AddToAllowList' | 'RemoveFromAllowList' | 'ChangeCollectionOwner' | 'AddCollectionAdmin' | 'RemoveCollectionAdmin' | 'SetCollectionSponsor' | 'ConfirmSponsorship' | 'RemoveCollectionSponsor' | 'CreateItem' | 'CreateMultipleItems' | 'SetCollectionProperties' | 'DeleteCollectionProperties' | 'SetTokenProperties' | 'DeleteTokenProperties' | 'SetTokenPropertyPermissions' | 'CreateMultipleItemsEx' | 'SetTransfersEnabledFlag' | 'BurnItem' | 'BurnFrom' | 'Transfer' | 'Approve' | 'TransferFrom' | 'SetCollectionLimits' | 'SetCollectionPermissions' | 'Repartition' | 'SetAllowanceForAll' | 'ForceRepairCollection' | 'ForceRepairItem';
+ readonly type: 'CreateCollection' | 'CreateCollectionEx' | 'DestroyCollection' | 'AddToAllowList' | 'RemoveFromAllowList' | 'ChangeCollectionOwner' | 'AddCollectionAdmin' | 'RemoveCollectionAdmin' | 'SetCollectionSponsor' | 'ConfirmSponsorship' | 'RemoveCollectionSponsor' | 'CreateItem' | 'CreateMultipleItems' | 'SetCollectionProperties' | 'DeleteCollectionProperties' | 'SetTokenProperties' | 'DeleteTokenProperties' | 'SetTokenPropertyPermissions' | 'CreateMultipleItemsEx' | 'SetTransfersEnabledFlag' | 'BurnItem' | 'BurnFrom' | 'Transfer' | 'Approve' | 'ApproveFrom' | 'TransferFrom' | 'SetCollectionLimits' | 'SetCollectionPermissions' | 'Repartition' | 'SetAllowanceForAll' | 'ForceRepairCollection' | 'ForceRepairItem';
}
/** @name UpDataStructsCollectionMode (236) */
@@ -3564,6 +3572,7 @@
readonly isTokenValueTooLow: boolean;
readonly isApprovedValueTooLow: boolean;
readonly isCantApproveMoreThanOwned: boolean;
+ readonly isAddressIsNotEthMirror: boolean;
readonly isAddressIsZero: boolean;
readonly isUnsupportedOperation: boolean;
readonly isNotSufficientFounds: boolean;
@@ -3579,7 +3588,7 @@
readonly isCollectionIsInternal: boolean;
readonly isConfirmSponsorshipFail: boolean;
readonly isUserIsNotCollectionAdmin: boolean;
- readonly type: 'CollectionNotFound' | 'MustBeTokenOwner' | 'NoPermission' | 'CantDestroyNotEmptyCollection' | 'PublicMintingNotAllowed' | 'AddressNotInAllowlist' | 'CollectionNameLimitExceeded' | 'CollectionDescriptionLimitExceeded' | 'CollectionTokenPrefixLimitExceeded' | 'TotalCollectionsLimitExceeded' | 'CollectionAdminCountExceeded' | 'CollectionLimitBoundsExceeded' | 'OwnerPermissionsCantBeReverted' | 'TransferNotAllowed' | 'AccountTokenLimitExceeded' | 'CollectionTokenLimitExceeded' | 'MetadataFlagFrozen' | 'TokenNotFound' | 'TokenValueTooLow' | 'ApprovedValueTooLow' | 'CantApproveMoreThanOwned' | 'AddressIsZero' | 'UnsupportedOperation' | 'NotSufficientFounds' | 'UserIsNotAllowedToNest' | 'SourceCollectionIsNotAllowedToNest' | 'CollectionFieldSizeExceeded' | 'NoSpaceForProperty' | 'PropertyLimitReached' | 'PropertyKeyIsTooLong' | 'InvalidCharacterInPropertyKey' | 'EmptyPropertyKey' | 'CollectionIsExternal' | 'CollectionIsInternal' | 'ConfirmSponsorshipFail' | 'UserIsNotCollectionAdmin';
+ readonly type: 'CollectionNotFound' | 'MustBeTokenOwner' | 'NoPermission' | 'CantDestroyNotEmptyCollection' | 'PublicMintingNotAllowed' | 'AddressNotInAllowlist' | 'CollectionNameLimitExceeded' | 'CollectionDescriptionLimitExceeded' | 'CollectionTokenPrefixLimitExceeded' | 'TotalCollectionsLimitExceeded' | 'CollectionAdminCountExceeded' | 'CollectionLimitBoundsExceeded' | 'OwnerPermissionsCantBeReverted' | 'TransferNotAllowed' | 'AccountTokenLimitExceeded' | 'CollectionTokenLimitExceeded' | 'MetadataFlagFrozen' | 'TokenNotFound' | 'TokenValueTooLow' | 'ApprovedValueTooLow' | 'CantApproveMoreThanOwned' | 'AddressIsNotEthMirror' | 'AddressIsZero' | 'UnsupportedOperation' | 'NotSufficientFounds' | 'UserIsNotAllowedToNest' | 'SourceCollectionIsNotAllowedToNest' | 'CollectionFieldSizeExceeded' | 'NoSpaceForProperty' | 'PropertyLimitReached' | 'PropertyKeyIsTooLong' | 'InvalidCharacterInPropertyKey' | 'EmptyPropertyKey' | 'CollectionIsExternal' | 'CollectionIsInternal' | 'ConfirmSponsorshipFail' | 'UserIsNotCollectionAdmin';
}
/** @name PalletFungibleError (425) */
tests/src/util/playgrounds/unique.tsdiffbeforeafterboth--- a/tests/src/util/playgrounds/unique.ts
+++ b/tests/src/util/playgrounds/unique.ts
@@ -633,6 +633,10 @@
let call = this.getApi() as any;
for(const part of apiCall.slice(4).split('.')) {
call = call[part];
+ if (!call) {
+ const advice = part.includes('_') ? ' Looks like it needs to be converted to camel case.' : '';
+ throw Error(`Function ${part} of api call ${apiCall} not found.${advice}`);
+ }
}
return call(...params);
}
@@ -1259,6 +1263,42 @@
}
/**
+ * Set, change, or remove approved address to transfer the ownership of the NFT from eth mirror.
+ *
+ * @param signer keyring of signer
+ * @param collectionId ID of collection
+ * @param tokenId ID of token
+ * @param fromAddressObj Signer's Ethereum address containing her tokens
+ * @param toAddressObj Substrate or Ethereum address which gets approved use of the signer's tokens
+ * @param amount amount of token to be approved. For NFT must be set to 1n
+ * @returns ```true``` if extrinsic success, otherwise ```false```
+ */
+ async approveTokenFrom(signer: IKeyringPair, collectionId: number, tokenId: number, fromAddressObj: ICrossAccountId, toAddressObj: ICrossAccountId, amount=1n) {
+ const approveResult = await this.helper.executeExtrinsic(
+ signer,
+ 'api.tx.unique.approveFrom', [fromAddressObj, toAddressObj, collectionId, tokenId, amount],
+ true, // `Unable to approve token for ${label}`,
+ );
+
+ return this.helper.util.findCollectionInEvents(approveResult.result.events, collectionId, 'common', 'Approved');
+ }
+
+ /**
+ * Set, change, or remove approved address to transfer the ownership of the NFT from eth mirror.
+ *
+ * @param signer keyring of signer
+ * @param collectionId ID of collection
+ * @param tokenId ID of token
+ * @param toAddressObj Substrate or Ethereum address which gets approved use of the signer's tokens
+ * @param amount amount of token to be approved. For NFT must be set to 1n
+ * @returns ```true``` if extrinsic success, otherwise ```false```
+ */
+ async approveTokenFromEth(signer: IKeyringPair, collectionId: number, tokenId: number, toAddressObj: ICrossAccountId, amount=1n) {
+ const ethMirror = CrossAccountId.fromKeyring(signer).toEthereum();
+ return await this.approveTokenFrom(signer, collectionId, tokenId, ethMirror, toAddressObj, amount);
+ }
+
+ /**
* Get the amount of token pieces approved to transfer or burn. Normally 0.
*
* @param collectionId ID of collection
@@ -1756,8 +1796,8 @@
* @example approveToken(aliceKeyring, 10, 5, {Substrate: "5DyN4Y92vZCjv38fg..."})
* @returns ```true``` if extrinsic success, otherwise ```false```
*/
- approveToken(signer: IKeyringPair, collectionId: number, tokenId: number, toAddressObj: ICrossAccountId) {
- return super.approveToken(signer, collectionId, tokenId, toAddressObj, 1n);
+ approveToken(signer: IKeyringPair, collectionId: number, tokenId: number, toAddressObj: ICrossAccountId, amount=1n) {
+ return super.approveToken(signer, collectionId, tokenId, toAddressObj, amount);
}
}