difftreelog
Merge branch 'develop' into feature/conditional-rmrk
in: master
21 files changed
pallets/common/src/benchmarking.rsdiffbeforeafterboth--- a/pallets/common/src/benchmarking.rs
+++ b/pallets/common/src/benchmarking.rs
@@ -96,7 +96,7 @@
permissions: Some(CollectionPermissions {
nesting: Some(NestingPermissions {
token_owner: false,
- admin: false,
+ collection_admin: false,
restricted: None,
permissive: true,
}),
pallets/common/src/lib.rsdiffbeforeafterboth--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -1164,6 +1164,7 @@
old_limit: &CollectionLimits,
mut new_limit: CollectionLimits,
) -> Result<CollectionLimits, DispatchError> {
+ let limits = old_limit;
limit_default!(old_limit, new_limit,
account_token_ownership_limit => ensure!(
new_limit <= MAX_TOKEN_OWNERSHIP,
@@ -1190,6 +1191,7 @@
),
sponsor_approve_timeout => {},
owner_can_transfer => ensure!(
+ !limits.owner_can_transfer_instaled() ||
old_limit || !new_limit,
<Error<T>>::OwnerPermissionsCantBeReverted,
),
pallets/nonfungible/src/lib.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/lib.rs
+++ b/pallets/nonfungible/src/lib.rs
@@ -1008,7 +1008,7 @@
nesting_budget,
)? {
// Pass
- } else if nesting.admin && handle.is_owner_or_admin(&sender) {
+ } else if nesting.collection_admin && handle.is_owner_or_admin(&sender) {
// Pass
} else {
fail!(<CommonError<T>>::UserIsNotAllowedToNest);
pallets/proxy-rmrk-core/src/lib.rsdiffbeforeafterboth--- a/pallets/proxy-rmrk-core/src/lib.rs
+++ b/pallets/proxy-rmrk-core/src/lib.rs
@@ -199,7 +199,7 @@
permissions: Some(CollectionPermissions {
nesting: Some(NestingPermissions {
token_owner: true,
- admin: false,
+ collection_admin: false,
restricted: None,
permissive: false,
primitives/data-structs/src/lib.rsdiffbeforeafterboth--- a/primitives/data-structs/src/lib.rs
+++ b/primitives/data-structs/src/lib.rs
@@ -409,7 +409,10 @@
.min(MAX_SPONSOR_TIMEOUT)
}
pub fn owner_can_transfer(&self) -> bool {
- self.owner_can_transfer.unwrap_or(true)
+ self.owner_can_transfer.unwrap_or(false)
+ }
+ pub fn owner_can_transfer_instaled(&self) -> bool {
+ self.owner_can_transfer.is_some()
}
pub fn owner_can_destroy(&self) -> bool {
self.owner_can_destroy.unwrap_or(true)
@@ -447,7 +450,7 @@
pub fn nesting(&self) -> &NestingPermissions {
static DEFAULT: NestingPermissions = NestingPermissions {
token_owner: false,
- admin: false,
+ collection_admin: false,
restricted: None,
permissive: false,
@@ -490,7 +493,7 @@
/// Owner of token can nest tokens under it
pub token_owner: bool,
/// Admin of token collection can nest tokens under token
- pub admin: bool,
+ pub collection_admin: bool,
/// If set - only tokens from specified collections can be nested
pub restricted: Option<OwnerRestrictedSet>,
tests/package.jsondiffbeforeafterboth--- a/tests/package.json
+++ b/tests/package.json
@@ -28,6 +28,7 @@
"test": "mocha --timeout 9999999 -r ts-node/register './src/**/*.test.ts'",
"testEth": "mocha --timeout 9999999 -r ts-node/register './**/eth/**/*.test.ts'",
"testEthMarketplace": "mocha --timeout 9999999 -r ts-node/register './**/eth/marketplace/**/*.test.ts'",
+ "testEthNesting": "mocha --timeout 9999999 -r ts-node/register './**/eth/nesting/**/*.test.ts'",
"load": "mocha --timeout 9999999 -r ts-node/register './**/*.load.ts'",
"loadTransfer": "ts-node src/transfer.nload.ts",
"testCollision": "mocha --timeout 9999999 -r ts-node/register ./src/collision-tests/*.test.ts",
tests/src/approve.test.tsdiffbeforeafterboth--- a/tests/src/approve.test.ts
+++ b/tests/src/approve.test.ts
@@ -28,7 +28,7 @@
setCollectionLimitsExpectSuccess,
transferExpectSuccess,
addCollectionAdminExpectSuccess,
- adminApproveFromExpectSuccess,
+ adminApproveFromExpectFail,
getCreatedCollectionCount,
transferFromExpectSuccess,
transferFromExpectFail,
@@ -84,11 +84,11 @@
await approveExpectSuccess(reFungibleCollectionId, newReFungibleTokenId, alice, bob.address, 0);
});
- it('can be called by collection owner on non-owned item when OwnerCanTransfer == true', async () => {
+ it('can`t be called by collection owner on non-owned item when OwnerCanTransfer == false', async () => {
const collectionId = await createCollectionExpectSuccess();
const itemId = await createItemExpectSuccess(alice, collectionId, 'NFT', bob.address);
- await adminApproveFromExpectSuccess(collectionId, itemId, alice, bob.address, charlie.address);
+ await adminApproveFromExpectFail(collectionId, itemId, alice, bob.address, charlie.address);
});
});
@@ -292,7 +292,7 @@
});
});
-describe('Administrator and collection owner do not need approval in order to execute TransferFrom:', () => {
+describe('Administrator and collection owner do not need approval in order to execute TransferFrom (with owner_can_transfer_flag = true):', () => {
let alice: IKeyringPair;
let bob: IKeyringPair;
let charlie: IKeyringPair;
@@ -309,6 +309,7 @@
it('NFT', async () => {
const collectionId = await createCollectionExpectSuccess();
+ await setCollectionLimitsExpectSuccess(alice, collectionId, {ownerCanTransfer: true});
const itemId = await createItemExpectSuccess(alice, collectionId, 'NFT', charlie.address);
await transferFromExpectSuccess(collectionId, itemId, alice, charlie, dave, 1, 'NFT');
await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
@@ -317,6 +318,7 @@
it('Fungible up to an approved amount', async () => {
const collectionId = await createCollectionExpectSuccess({mode:{type: 'Fungible', decimalPoints: 0}});
+ await setCollectionLimitsExpectSuccess(alice, collectionId, {ownerCanTransfer: true});
const itemId = await createItemExpectSuccess(alice, collectionId, 'Fungible', charlie.address);
await transferFromExpectSuccess(collectionId, itemId, alice, charlie, dave, 1, 'Fungible');
await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
@@ -325,6 +327,7 @@
it('ReFungible up to an approved amount', async () => {
const collectionId = await createCollectionExpectSuccess({mode:{type: 'ReFungible'}});
+ await setCollectionLimitsExpectSuccess(alice, collectionId, {ownerCanTransfer: true});
const itemId = await createItemExpectSuccess(alice, collectionId, 'ReFungible', charlie.address);
await transferFromExpectSuccess(collectionId, itemId, alice, charlie, dave, 1, 'ReFungible');
await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
@@ -402,7 +405,7 @@
const itemId = await createItemExpectSuccess(alice, collectionId, 'NFT', alice.address);
await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
- await adminApproveFromExpectSuccess(collectionId, itemId, bob, alice.address, charlie.address);
+ await adminApproveFromExpectFail(collectionId, itemId, bob, alice.address, charlie.address);
});
});
tests/src/burnItem.test.tsdiffbeforeafterboth--- a/tests/src/burnItem.test.ts
+++ b/tests/src/burnItem.test.ts
@@ -23,6 +23,7 @@
normalizeAccountId,
addCollectionAdminExpectSuccess,
getBalance,
+ setCollectionLimitsExpectSuccess,
isTokenExists,
} from './util/helpers';
@@ -149,6 +150,7 @@
it('Burn item in NFT collection', async () => {
const createMode = 'NFT';
const collectionId = await createCollectionExpectSuccess({mode: {type: createMode}});
+ await setCollectionLimitsExpectSuccess(alice, collectionId, {ownerCanTransfer: true});
const tokenId = await createItemExpectSuccess(alice, collectionId, createMode);
await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
@@ -167,6 +169,7 @@
it('Burn item in Fungible collection', async () => {
const createMode = 'Fungible';
const collectionId = await createCollectionExpectSuccess({mode: {type: createMode, decimalPoints: 0}});
+ await setCollectionLimitsExpectSuccess(alice, collectionId, {ownerCanTransfer: true});
const tokenId = await createItemExpectSuccess(alice, collectionId, createMode); // Helper creates 10 fungible tokens
await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
@@ -189,6 +192,7 @@
it('Burn item in ReFungible collection', async () => {
const createMode = 'ReFungible';
const collectionId = await createCollectionExpectSuccess({mode: {type: createMode}});
+ await setCollectionLimitsExpectSuccess(alice, collectionId, {ownerCanTransfer: true});
const tokenId = await createItemExpectSuccess(alice, collectionId, createMode);
await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
tests/src/eth/crossTransfer.test.tsdiffbeforeafterboth--- a/tests/src/eth/crossTransfer.test.ts
+++ b/tests/src/eth/crossTransfer.test.ts
@@ -18,6 +18,7 @@
createFungibleItemExpectSuccess,
transferExpectSuccess,
transferFromExpectSuccess,
+ setCollectionLimitsExpectSuccess,
createItemExpectSuccess} from '../util/helpers';
import {collectionIdToAddress,
createEthAccountWithBalance,
@@ -35,6 +36,7 @@
const alice = privateKeyWrapper('//Alice');
const bob = privateKeyWrapper('//Bob');
const charlie = privateKeyWrapper('//Charlie');
+ await setCollectionLimitsExpectSuccess(alice, collection, {ownerCanTransfer: true});
await createFungibleItemExpectSuccess(alice, collection, {Value: 200n}, {Substrate: alice.address});
await transferExpectSuccess(collection, 0, alice, {Ethereum: subToEth(charlie.address)} , 200, 'Fungible');
await transferFromExpectSuccess(collection, 0, alice, {Ethereum: subToEth(charlie.address)}, charlie, 50, 'Fungible');
@@ -48,6 +50,7 @@
});
const alice = privateKeyWrapper('//Alice');
const bob = privateKeyWrapper('//Bob');
+ await setCollectionLimitsExpectSuccess(alice, collection, {ownerCanTransfer: true});
const bobProxy = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
const aliceProxy = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
@@ -71,6 +74,7 @@
const alice = privateKeyWrapper('//Alice');
const bob = privateKeyWrapper('//Bob');
const charlie = privateKeyWrapper('//Charlie');
+ await setCollectionLimitsExpectSuccess(alice, collection, {ownerCanTransfer: true});
const tokenId = await createItemExpectSuccess(alice, collection, 'NFT', {Substrate: alice.address});
await transferExpectSuccess(collection, tokenId, alice, {Ethereum: subToEth(charlie.address)}, 1, 'NFT');
await transferFromExpectSuccess(collection, tokenId, alice, {Ethereum: subToEth(charlie.address)}, charlie, 1, 'NFT');
@@ -85,6 +89,7 @@
const alice = privateKeyWrapper('//Alice');
const bob = privateKeyWrapper('//Bob');
const charlie = privateKeyWrapper('//Charlie');
+ await setCollectionLimitsExpectSuccess(alice, collection, {ownerCanTransfer: true});
const bobProxy = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
const aliceProxy = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
const tokenId = await createItemExpectSuccess(alice, collection, 'NFT', {Substrate: alice.address});
tests/src/eth/nesting/nest.test.tsdiffbeforeafterboth--- /dev/null
+++ b/tests/src/eth/nesting/nest.test.ts
@@ -0,0 +1,214 @@
+import {ApiPromise} from '@polkadot/api';
+import {Contract} from 'web3-eth-contract';
+import {expect} from 'chai';
+import Web3 from 'web3';
+import {createEthAccountWithBalance, evmCollectionHelpers, GAS_ARGS, getCollectionAddressFromResult, itWeb3, tokenIdToAddress} from '../../eth/util/helpers';
+import nonFungibleAbi from '../nonFungibleAbi.json';
+
+const createNestingCollection = async (
+ api: ApiPromise,
+ web3: Web3,
+ owner: string,
+): Promise<{ collectionId: number, collectionAddress: string, contract: Contract }> => {
+ const collectionHelper = evmCollectionHelpers(web3, owner);
+
+ const result = await collectionHelper.methods
+ .createNonfungibleCollection('A', 'B', 'C')
+ .send();
+ const {collectionIdAddress: collectionAddress, collectionId} = await getCollectionAddressFromResult(api, result);
+
+ const contract = new web3.eth.Contract(nonFungibleAbi as any, collectionAddress, {from: owner, ...GAS_ARGS});
+ await contract.methods.setCollectionNesting(true).send({from: owner});
+
+ return {collectionId, collectionAddress, contract};
+};
+
+describe('Integration Test: EVM Nesting', () => {
+ itWeb3('NFT: allows an Owner to nest/unnest their token', async ({api, web3, privateKeyWrapper}) => {
+ const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
+ const {collectionId, contract} = await createNestingCollection(api, web3, owner);
+
+ // Create a token to be nested
+ const nftTokenId = await contract.methods.nextTokenId().call();
+ await contract.methods.mint(
+ owner,
+ nftTokenId,
+ ).send({from: owner});
+
+ // Nest into a token
+ const firstTargetNftTokenId = await contract.methods.nextTokenId().call();
+ await contract.methods.mint(
+ owner,
+ firstTargetNftTokenId,
+ ).send({from: owner});
+
+ const targetNftTokenAddress = tokenIdToAddress(collectionId, firstTargetNftTokenId);
+
+ await contract.methods.transfer(targetNftTokenAddress, nftTokenId).send({from: owner});
+ expect(await contract.methods.ownerOf(nftTokenId).call()).to.be.equal(targetNftTokenAddress);
+
+ // Re-nest into another
+ const secondTargetNftTokenId = await contract.methods.nextTokenId().call();
+ await contract.methods.mint(
+ owner,
+ secondTargetNftTokenId,
+ ).send({from: owner});
+ const nextNftTokenAddress = tokenIdToAddress(collectionId, secondTargetNftTokenId);
+
+ await contract.methods.transfer(nextNftTokenAddress, nftTokenId).send({from: owner});
+ expect(await contract.methods.ownerOf(nftTokenId).call()).to.be.equal(nextNftTokenAddress);
+ });
+
+ itWeb3('NFT: allows an Owner to nest/unnest their token (Restricted nesting)', async ({api, web3, privateKeyWrapper}) => {
+ const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
+
+ const {collectionId: collectionIdA, collectionAddress: collectionAddressA, contract: contractA} = await createNestingCollection(api, web3, owner);
+ const {collectionAddress: collectionAddressB, contract: contractB} = await createNestingCollection(api, web3, owner);
+ await contractA.methods.setCollectionNesting(true, [collectionAddressA, collectionAddressB]).send({from: owner});
+
+ // Create a token to nest into
+ const targetNftTokenId = await contractA.methods.nextTokenId().call();
+ await contractA.methods.mint(
+ owner,
+ targetNftTokenId,
+ ).send({from: owner});
+ const nftTokenAddressA1 = tokenIdToAddress(collectionIdA, targetNftTokenId);
+
+ // Create a token for nesting in the same collection as the target
+ const nftTokenIdA = await contractA.methods.nextTokenId().call();
+ await contractA.methods.mint(
+ owner,
+ nftTokenIdA,
+ ).send({from: owner});
+
+ // Create a token for nesting in a different collection
+ const nftTokenIdB = await contractB.methods.nextTokenId().call();
+ await contractB.methods.mint(
+ owner,
+ nftTokenIdB,
+ ).send({from: owner});
+
+ // Nest
+ await contractA.methods.transfer(nftTokenAddressA1, nftTokenIdA).send({from: owner});
+ expect(await contractA.methods.ownerOf(nftTokenIdA).call()).to.be.equal(nftTokenAddressA1);
+
+ await contractB.methods.transfer(nftTokenAddressA1, nftTokenIdB).send({from: owner});
+ expect(await contractB.methods.ownerOf(nftTokenIdB).call()).to.be.equal(nftTokenAddressA1);
+ });
+});
+
+describe('Negative Test: EVM Nesting', async() => {
+ itWeb3('NFT: disallows to nest token if nesting is disabled', async ({api, web3, privateKeyWrapper}) => {
+ const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
+
+ const {collectionId, contract} = await createNestingCollection(api, web3, owner);
+ await contract.methods.setCollectionNesting(false).send({from: owner});
+
+ // Create a token to nest into
+ const targetNftTokenId = await contract.methods.nextTokenId().call();
+ await contract.methods.mint(
+ owner,
+ targetNftTokenId,
+ ).send({from: owner});
+
+ const targetNftTokenAddress = tokenIdToAddress(collectionId, targetNftTokenId);
+
+ // Create a token to nest
+ const nftTokenId = await contract.methods.nextTokenId().call();
+ await contract.methods.mint(
+ owner,
+ nftTokenId,
+ ).send({from: owner});
+
+ // Try to nest
+ await expect(contract.methods
+ .transfer(targetNftTokenAddress, nftTokenId)
+ .call({from: owner})).to.be.rejectedWith('UserIsNotAllowedToNest');
+ });
+
+ itWeb3('NFT: disallows a non-Owner to nest someone else\'s token', async ({api, web3, privateKeyWrapper}) => {
+ const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
+ const malignant = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
+
+ const {collectionId, contract} = await createNestingCollection(api, web3, owner);
+
+ // Mint a token
+ const targetTokenId = await contract.methods.nextTokenId().call();
+ await contract.methods.mint(
+ owner,
+ targetTokenId,
+ ).send({from: owner});
+ const targetTokenAddress = tokenIdToAddress(collectionId, targetTokenId);
+
+ // Mint a token belonging to a different account
+ const tokenId = await contract.methods.nextTokenId().call();
+ await contract.methods.mint(
+ malignant,
+ tokenId,
+ ).send({from: owner});
+
+ // Try to nest one token in another as a non-owner account
+ await expect(contract.methods
+ .transfer(targetTokenAddress, tokenId)
+ .call({from: malignant})).to.be.rejectedWith('UserIsNotAllowedToNest');
+ });
+
+ itWeb3('NFT: disallows a non-Owner to nest someone else\'s token (Restricted nesting)', async ({api, web3, privateKeyWrapper}) => {
+ const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
+ const malignant = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
+
+ const {collectionId: collectionIdA, collectionAddress: collectionAddressA, contract: contractA} = await createNestingCollection(api, web3, owner);
+ const {collectionAddress: collectionAddressB, contract: contractB} = await createNestingCollection(api, web3, owner);
+
+ await contractA.methods.setCollectionNesting(true, [collectionAddressA, collectionAddressB]).send({from: owner});
+
+ // Create a token in one collection
+ const nftTokenIdA = await contractA.methods.nextTokenId().call();
+ await contractA.methods.mint(
+ owner,
+ nftTokenIdA,
+ ).send({from: owner});
+ const nftTokenAddressA = tokenIdToAddress(collectionIdA, nftTokenIdA);
+
+ // Create a token in another collection belonging to someone else
+ const nftTokenIdB = await contractB.methods.nextTokenId().call();
+ await contractB.methods.mint(
+ malignant,
+ nftTokenIdB,
+ ).send({from: owner});
+
+ // Try to drag someone else's token into the other collection and nest
+ await expect(contractB.methods
+ .transfer(nftTokenAddressA, nftTokenIdB)
+ .call({from: malignant})).to.be.rejectedWith('UserIsNotAllowedToNest');
+ });
+
+ itWeb3('NFT: disallows to nest token in an unlisted collection', async ({api, web3, privateKeyWrapper}) => {
+ const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
+
+ const {collectionId: collectionIdA, collectionAddress: collectionAddressA, contract: contractA} = await createNestingCollection(api, web3, owner);
+ const {contract: contractB} = await createNestingCollection(api, web3, owner);
+
+ await contractA.methods.setCollectionNesting(true, [collectionAddressA]).send({from: owner});
+
+ // Create a token in one collection
+ const nftTokenIdA = await contractA.methods.nextTokenId().call();
+ await contractA.methods.mint(
+ owner,
+ nftTokenIdA,
+ ).send({from: owner});
+ const nftTokenAddressA = tokenIdToAddress(collectionIdA, nftTokenIdA);
+
+ // Create a token in another collection
+ const nftTokenIdB = await contractB.methods.nextTokenId().call();
+ await contractB.methods.mint(
+ owner,
+ nftTokenIdB,
+ ).send({from: owner});
+
+ // Try to nest into a token in the other collection, disallowed in the first
+ await expect(contractB.methods
+ .transfer(nftTokenAddressA, nftTokenIdB)
+ .call()).to.be.rejectedWith('SourceCollectionIsNotAllowedToNest');
+ });
+});
tests/src/interfaces/augment-api-errors.tsdiffbeforeafterboth--- a/tests/src/interfaces/augment-api-errors.ts
+++ b/tests/src/interfaces/augment-api-errors.ts
@@ -458,6 +458,7 @@
ResourceNotPending: AugmentedError<ApiType>;
RmrkPropertyKeyIsTooLong: AugmentedError<ApiType>;
RmrkPropertyValueIsTooLong: AugmentedError<ApiType>;
+ UnableToDecodeRmrkData: AugmentedError<ApiType>;
/**
* Generic error
**/
tests/src/interfaces/augment-api-query.tsdiffbeforeafterboth--- a/tests/src/interfaces/augment-api-query.ts
+++ b/tests/src/interfaces/augment-api-query.ts
@@ -417,7 +417,6 @@
};
rmrkCore: {
collectionIndex: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;
- rmrkInernalCollectionId: AugmentedQuery<ApiType, (arg: u32 | AnyNumber | Uint8Array) => Observable<u32>, [u32]> & QueryableStorageEntry<ApiType, [u32]>;
uniqueCollectionId: AugmentedQuery<ApiType, (arg: u32 | AnyNumber | Uint8Array) => Observable<u32>, [u32]> & QueryableStorageEntry<ApiType, [u32]>;
/**
* Generic query
tests/src/interfaces/augment-api-tx.tsdiffbeforeafterboth--- a/tests/src/interfaces/augment-api-tx.ts
+++ b/tests/src/interfaces/augment-api-tx.ts
@@ -5,7 +5,7 @@
import type { Bytes, Compact, Option, U256, U8aFixed, Vec, bool, u128, u16, u32, u64, u8 } from '@polkadot/types-codec';
import type { AnyNumber, IMethod, ITuple } from '@polkadot/types-codec/types';
import type { AccountId32, Call, H160, H256, MultiAddress, Perbill, Permill } from '@polkadot/types/interfaces/runtime';
-import type { CumulusPrimitivesParachainInherentParachainInherentData, EthereumTransactionTransactionV2, FrameSupportScheduleMaybeHashed, OrmlVestingVestingSchedule, PalletEvmAccountBasicCrossAccountIdRepr, RmrkTraitsNftAccountIdOrCollectionNftTuple, RmrkTraitsPartPartType, RmrkTraitsResourceBasicResource, RmrkTraitsResourceComposableResource, RmrkTraitsResourceSlotResource, RmrkTraitsTheme, UpDataStructsCollectionLimits, UpDataStructsCollectionMode, UpDataStructsCollectionPermissions, UpDataStructsCreateCollectionData, UpDataStructsCreateItemData, UpDataStructsCreateItemExData, UpDataStructsProperty, UpDataStructsPropertyKeyPermission, XcmV1MultiLocation, XcmV2WeightLimit, XcmVersionedMultiAssets, XcmVersionedMultiLocation, XcmVersionedXcm } from '@polkadot/types/lookup';
+import type { CumulusPrimitivesParachainInherentParachainInherentData, EthereumTransactionTransactionV2, FrameSupportScheduleMaybeHashed, OrmlVestingVestingSchedule, PalletEvmAccountBasicCrossAccountIdRepr, RmrkTraitsNftAccountIdOrCollectionNftTuple, RmrkTraitsPartPartType, RmrkTraitsResourceBasicResource, RmrkTraitsResourceComposableResource, RmrkTraitsResourceResourceTypes, RmrkTraitsResourceSlotResource, RmrkTraitsTheme, UpDataStructsCollectionLimits, UpDataStructsCollectionMode, UpDataStructsCollectionPermissions, UpDataStructsCreateCollectionData, UpDataStructsCreateItemData, UpDataStructsCreateItemExData, UpDataStructsProperty, UpDataStructsPropertyKeyPermission, XcmV1MultiLocation, XcmV2WeightLimit, XcmVersionedMultiAssets, XcmVersionedMultiLocation, XcmVersionedXcm } from '@polkadot/types/lookup';
declare module '@polkadot/api-base/types/submittable' {
export interface AugmentedSubmittables<ApiType extends ApiTypes> {
@@ -373,7 +373,7 @@
/**
* Create composable resource
**/
- addComposableResource: AugmentedSubmittable<(rmrkCollectionId: u32 | AnyNumber | Uint8Array, nftId: u32 | AnyNumber | Uint8Array, resourceId: Bytes | string | Uint8Array, resource: RmrkTraitsResourceComposableResource | { parts?: any; base?: any; src?: any; metadata?: any; license?: any; thumb?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, u32, Bytes, RmrkTraitsResourceComposableResource]>;
+ addComposableResource: AugmentedSubmittable<(rmrkCollectionId: u32 | AnyNumber | Uint8Array, nftId: u32 | AnyNumber | Uint8Array, resource: RmrkTraitsResourceComposableResource | { parts?: any; base?: any; src?: any; metadata?: any; license?: any; thumb?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, u32, RmrkTraitsResourceComposableResource]>;
/**
* Create slot resource
**/
@@ -381,7 +381,7 @@
/**
* burn nft
**/
- burnNft: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, nftId: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, u32]>;
+ burnNft: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, nftId: u32 | AnyNumber | Uint8Array, maxBurns: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, u32, u32]>;
/**
* Change the issuer of a collection
*
@@ -415,7 +415,7 @@
* - `metadata`: Arbitrary data about an nft, e.g. IPFS hash
* - `transferable`: Ability to transfer this NFT
**/
- mintNft: AugmentedSubmittable<(owner: AccountId32 | string | Uint8Array, collectionId: u32 | AnyNumber | Uint8Array, recipient: Option<AccountId32> | null | object | string | Uint8Array, royaltyAmount: Option<Permill> | null | object | string | Uint8Array, metadata: Bytes | string | Uint8Array, transferable: bool | boolean | Uint8Array) => SubmittableExtrinsic<ApiType>, [AccountId32, u32, Option<AccountId32>, Option<Permill>, Bytes, bool]>;
+ mintNft: AugmentedSubmittable<(owner: AccountId32 | string | Uint8Array, collectionId: u32 | AnyNumber | Uint8Array, recipient: Option<AccountId32> | null | object | string | Uint8Array, royaltyAmount: Option<Permill> | null | object | string | Uint8Array, metadata: Bytes | string | Uint8Array, transferable: bool | boolean | Uint8Array, resources: Option<Vec<RmrkTraitsResourceResourceTypes>> | null | object | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [AccountId32, u32, Option<AccountId32>, Option<Permill>, Bytes, bool, Option<Vec<RmrkTraitsResourceResourceTypes>>]>;
/**
* Rejects an NFT sent from another account to self or owned NFT
*
tests/src/interfaces/default/types.tsdiffbeforeafterboth--- a/tests/src/interfaces/default/types.ts
+++ b/tests/src/interfaces/default/types.ts
@@ -1214,11 +1214,13 @@
readonly royaltyAmount: Option<Permill>;
readonly metadata: Bytes;
readonly transferable: bool;
+ readonly resources: Option<Vec<RmrkTraitsResourceResourceTypes>>;
} & Struct;
readonly isBurnNft: boolean;
readonly asBurnNft: {
readonly collectionId: u32;
readonly nftId: u32;
+ readonly maxBurns: u32;
} & Struct;
readonly isSend: boolean;
readonly asSend: {
@@ -1272,7 +1274,6 @@
readonly asAddComposableResource: {
readonly rmrkCollectionId: u32;
readonly nftId: u32;
- readonly resourceId: Bytes;
readonly resource: RmrkTraitsResourceComposableResource;
} & Struct;
readonly isAddSlotResource: boolean;
@@ -1296,6 +1297,7 @@
readonly isNftTypeEncodeError: boolean;
readonly isRmrkPropertyKeyIsTooLong: boolean;
readonly isRmrkPropertyValueIsTooLong: boolean;
+ readonly isUnableToDecodeRmrkData: boolean;
readonly isCollectionNotEmpty: boolean;
readonly isNoAvailableCollectionId: boolean;
readonly isNoAvailableNftId: boolean;
@@ -1308,7 +1310,7 @@
readonly isCannotAcceptNonOwnedNft: boolean;
readonly isCannotRejectNonOwnedNft: boolean;
readonly isResourceNotPending: boolean;
- readonly type: 'CorruptedCollectionType' | 'NftTypeEncodeError' | 'RmrkPropertyKeyIsTooLong' | 'RmrkPropertyValueIsTooLong' | 'CollectionNotEmpty' | 'NoAvailableCollectionId' | 'NoAvailableNftId' | 'CollectionUnknown' | 'NoPermission' | 'NonTransferable' | 'CollectionFullOrLocked' | 'ResourceDoesntExist' | 'CannotSendToDescendentOrSelf' | 'CannotAcceptNonOwnedNft' | 'CannotRejectNonOwnedNft' | 'ResourceNotPending';
+ readonly type: 'CorruptedCollectionType' | 'NftTypeEncodeError' | 'RmrkPropertyKeyIsTooLong' | 'RmrkPropertyValueIsTooLong' | 'UnableToDecodeRmrkData' | 'CollectionNotEmpty' | 'NoAvailableCollectionId' | 'NoAvailableNftId' | 'CollectionUnknown' | 'NoPermission' | 'NonTransferable' | 'CollectionFullOrLocked' | 'ResourceDoesntExist' | 'CannotSendToDescendentOrSelf' | 'CannotAcceptNonOwnedNft' | 'CannotRejectNonOwnedNft' | 'ResourceNotPending';
}
/** @name PalletRmrkCoreEvent */
@@ -2427,7 +2429,7 @@
/** @name UpDataStructsNestingPermissions */
export interface UpDataStructsNestingPermissions extends Struct {
readonly tokenOwner: bool;
- readonly admin: bool;
+ readonly collectionAdmin: bool;
readonly restricted: Option<UpDataStructsOwnerRestrictedSet>;
readonly permissive: bool;
}
tests/src/interfaces/lookup.tsdiffbeforeafterboth--- a/tests/src/interfaces/lookup.ts
+++ b/tests/src/interfaces/lookup.ts
@@ -1432,7 +1432,7 @@
**/
UpDataStructsNestingPermissions: {
tokenOwner: 'bool',
- admin: 'bool',
+ collectionAdmin: 'bool',
restricted: 'Option<UpDataStructsOwnerRestrictedSet>',
permissive: 'bool'
},
@@ -1593,10 +1593,12 @@
royaltyAmount: 'Option<Permill>',
metadata: 'Bytes',
transferable: 'bool',
+ resources: 'Option<Vec<RmrkTraitsResourceResourceTypes>>',
},
burn_nft: {
collectionId: 'u32',
nftId: 'u32',
+ maxBurns: 'u32',
},
send: {
rmrkCollectionId: 'u32',
@@ -1641,7 +1643,6 @@
add_composable_resource: {
rmrkCollectionId: 'u32',
nftId: 'u32',
- resourceId: 'Bytes',
resource: 'RmrkTraitsResourceComposableResource',
},
add_slot_resource: {
@@ -1657,12 +1658,13 @@
}
},
/**
- * Lookup215: rmrk_traits::nft::AccountIdOrCollectionNftTuple<sp_core::crypto::AccountId32>
+ * Lookup217: rmrk_traits::resource::ResourceTypes<frame_support::storage::bounded_vec::BoundedVec<T, S>, frame_support::storage::bounded_vec::BoundedVec<T, S>>
**/
- RmrkTraitsNftAccountIdOrCollectionNftTuple: {
+ RmrkTraitsResourceResourceTypes: {
_enum: {
- AccountId: 'AccountId32',
- CollectionAndNftTuple: '(u32,u32)'
+ Basic: 'RmrkTraitsResourceBasicResource',
+ Composable: 'RmrkTraitsResourceComposableResource',
+ Slot: 'RmrkTraitsResourceSlotResource'
}
},
/**
@@ -1675,7 +1677,7 @@
thumb: 'Option<Bytes>'
},
/**
- * Lookup222: rmrk_traits::resource::ComposableResource<frame_support::storage::bounded_vec::BoundedVec<T, S>, frame_support::storage::bounded_vec::BoundedVec<T, S>>
+ * Lookup221: rmrk_traits::resource::ComposableResource<frame_support::storage::bounded_vec::BoundedVec<T, S>, frame_support::storage::bounded_vec::BoundedVec<T, S>>
**/
RmrkTraitsResourceComposableResource: {
parts: 'Vec<u32>',
@@ -1686,7 +1688,7 @@
thumb: 'Option<Bytes>'
},
/**
- * Lookup224: rmrk_traits::resource::SlotResource<frame_support::storage::bounded_vec::BoundedVec<T, S>>
+ * Lookup222: rmrk_traits::resource::SlotResource<frame_support::storage::bounded_vec::BoundedVec<T, S>>
**/
RmrkTraitsResourceSlotResource: {
base: 'u32',
@@ -1697,8 +1699,17 @@
thumb: 'Option<Bytes>'
},
/**
- * Lookup225: pallet_rmrk_equip::pallet::Call<T>
+ * Lookup224: rmrk_traits::nft::AccountIdOrCollectionNftTuple<sp_core::crypto::AccountId32>
**/
+ RmrkTraitsNftAccountIdOrCollectionNftTuple: {
+ _enum: {
+ AccountId: 'AccountId32',
+ CollectionAndNftTuple: '(u32,u32)'
+ }
+ },
+ /**
+ * Lookup228: pallet_rmrk_equip::pallet::Call<T>
+ **/
PalletRmrkEquipCall: {
_enum: {
create_base: {
@@ -1713,7 +1724,7 @@
}
},
/**
- * Lookup227: rmrk_traits::part::PartType<frame_support::storage::bounded_vec::BoundedVec<T, S>, frame_support::storage::bounded_vec::BoundedVec<T, S>>
+ * Lookup230: rmrk_traits::part::PartType<frame_support::storage::bounded_vec::BoundedVec<T, S>, frame_support::storage::bounded_vec::BoundedVec<T, S>>
**/
RmrkTraitsPartPartType: {
_enum: {
@@ -1722,7 +1733,7 @@
}
},
/**
- * Lookup229: rmrk_traits::part::FixedPart<frame_support::storage::bounded_vec::BoundedVec<T, S>>
+ * Lookup232: rmrk_traits::part::FixedPart<frame_support::storage::bounded_vec::BoundedVec<T, S>>
**/
RmrkTraitsPartFixedPart: {
id: 'u32',
@@ -1730,7 +1741,7 @@
src: 'Bytes'
},
/**
- * Lookup230: rmrk_traits::part::SlotPart<frame_support::storage::bounded_vec::BoundedVec<T, S>, frame_support::storage::bounded_vec::BoundedVec<T, S>>
+ * Lookup233: rmrk_traits::part::SlotPart<frame_support::storage::bounded_vec::BoundedVec<T, S>, frame_support::storage::bounded_vec::BoundedVec<T, S>>
**/
RmrkTraitsPartSlotPart: {
id: 'u32',
@@ -1739,7 +1750,7 @@
z: 'u32'
},
/**
- * Lookup231: rmrk_traits::part::EquippableList<frame_support::storage::bounded_vec::BoundedVec<T, S>>
+ * Lookup234: rmrk_traits::part::EquippableList<frame_support::storage::bounded_vec::BoundedVec<T, S>>
**/
RmrkTraitsPartEquippableList: {
_enum: {
@@ -1749,7 +1760,7 @@
}
},
/**
- * Lookup233: rmrk_traits::theme::Theme<frame_support::storage::bounded_vec::BoundedVec<T, S>, PropertyList>
+ * Lookup236: rmrk_traits::theme::Theme<frame_support::storage::bounded_vec::BoundedVec<T, S>, PropertyList>
**/
RmrkTraitsTheme: {
name: 'Bytes',
@@ -1757,14 +1768,14 @@
inherit: 'bool'
},
/**
- * Lookup235: rmrk_traits::theme::ThemeProperty<frame_support::storage::bounded_vec::BoundedVec<T, S>>
+ * Lookup238: rmrk_traits::theme::ThemeProperty<frame_support::storage::bounded_vec::BoundedVec<T, S>>
**/
RmrkTraitsThemeThemeProperty: {
key: 'Bytes',
value: 'Bytes'
},
/**
- * Lookup236: pallet_evm::pallet::Call<T>
+ * Lookup239: pallet_evm::pallet::Call<T>
**/
PalletEvmCall: {
_enum: {
@@ -1807,7 +1818,7 @@
}
},
/**
- * Lookup242: pallet_ethereum::pallet::Call<T>
+ * Lookup245: pallet_ethereum::pallet::Call<T>
**/
PalletEthereumCall: {
_enum: {
@@ -1817,7 +1828,7 @@
}
},
/**
- * Lookup243: ethereum::transaction::TransactionV2
+ * Lookup246: ethereum::transaction::TransactionV2
**/
EthereumTransactionTransactionV2: {
_enum: {
@@ -1827,7 +1838,7 @@
}
},
/**
- * Lookup244: ethereum::transaction::LegacyTransaction
+ * Lookup247: ethereum::transaction::LegacyTransaction
**/
EthereumTransactionLegacyTransaction: {
nonce: 'U256',
@@ -1839,7 +1850,7 @@
signature: 'EthereumTransactionTransactionSignature'
},
/**
- * Lookup245: ethereum::transaction::TransactionAction
+ * Lookup248: ethereum::transaction::TransactionAction
**/
EthereumTransactionTransactionAction: {
_enum: {
@@ -1848,7 +1859,7 @@
}
},
/**
- * Lookup246: ethereum::transaction::TransactionSignature
+ * Lookup249: ethereum::transaction::TransactionSignature
**/
EthereumTransactionTransactionSignature: {
v: 'u64',
@@ -1856,7 +1867,7 @@
s: 'H256'
},
/**
- * Lookup248: ethereum::transaction::EIP2930Transaction
+ * Lookup251: ethereum::transaction::EIP2930Transaction
**/
EthereumTransactionEip2930Transaction: {
chainId: 'u64',
@@ -1872,14 +1883,14 @@
s: 'H256'
},
/**
- * Lookup250: ethereum::transaction::AccessListItem
+ * Lookup253: ethereum::transaction::AccessListItem
**/
EthereumTransactionAccessListItem: {
address: 'H160',
storageKeys: 'Vec<H256>'
},
/**
- * Lookup251: ethereum::transaction::EIP1559Transaction
+ * Lookup254: ethereum::transaction::EIP1559Transaction
**/
EthereumTransactionEip1559Transaction: {
chainId: 'u64',
@@ -1896,7 +1907,7 @@
s: 'H256'
},
/**
- * Lookup252: pallet_evm_migration::pallet::Call<T>
+ * Lookup255: pallet_evm_migration::pallet::Call<T>
**/
PalletEvmMigrationCall: {
_enum: {
@@ -1914,7 +1925,7 @@
}
},
/**
- * Lookup255: pallet_sudo::pallet::Event<T>
+ * Lookup258: pallet_sudo::pallet::Event<T>
**/
PalletSudoEvent: {
_enum: {
@@ -1930,7 +1941,7 @@
}
},
/**
- * Lookup257: sp_runtime::DispatchError
+ * Lookup260: sp_runtime::DispatchError
**/
SpRuntimeDispatchError: {
_enum: {
@@ -1947,38 +1958,38 @@
}
},
/**
- * Lookup258: sp_runtime::ModuleError
+ * Lookup261: sp_runtime::ModuleError
**/
SpRuntimeModuleError: {
index: 'u8',
error: '[u8;4]'
},
/**
- * Lookup259: sp_runtime::TokenError
+ * Lookup262: sp_runtime::TokenError
**/
SpRuntimeTokenError: {
_enum: ['NoFunds', 'WouldDie', 'BelowMinimum', 'CannotCreate', 'UnknownAsset', 'Frozen', 'Unsupported']
},
/**
- * Lookup260: sp_runtime::ArithmeticError
+ * Lookup263: sp_runtime::ArithmeticError
**/
SpRuntimeArithmeticError: {
_enum: ['Underflow', 'Overflow', 'DivisionByZero']
},
/**
- * Lookup261: sp_runtime::TransactionalError
+ * Lookup264: sp_runtime::TransactionalError
**/
SpRuntimeTransactionalError: {
_enum: ['LimitReached', 'NoLayer']
},
/**
- * Lookup262: pallet_sudo::pallet::Error<T>
+ * Lookup265: pallet_sudo::pallet::Error<T>
**/
PalletSudoError: {
_enum: ['RequireSudo']
},
/**
- * Lookup263: frame_system::AccountInfo<Index, pallet_balances::AccountData<Balance>>
+ * Lookup266: frame_system::AccountInfo<Index, pallet_balances::AccountData<Balance>>
**/
FrameSystemAccountInfo: {
nonce: 'u32',
@@ -1988,7 +1999,7 @@
data: 'PalletBalancesAccountData'
},
/**
- * Lookup264: frame_support::weights::PerDispatchClass<T>
+ * Lookup267: frame_support::weights::PerDispatchClass<T>
**/
FrameSupportWeightsPerDispatchClassU64: {
normal: 'u64',
@@ -1996,13 +2007,13 @@
mandatory: 'u64'
},
/**
- * Lookup265: sp_runtime::generic::digest::Digest
+ * Lookup268: sp_runtime::generic::digest::Digest
**/
SpRuntimeDigest: {
logs: 'Vec<SpRuntimeDigestDigestItem>'
},
/**
- * Lookup267: sp_runtime::generic::digest::DigestItem
+ * Lookup270: sp_runtime::generic::digest::DigestItem
**/
SpRuntimeDigestDigestItem: {
_enum: {
@@ -2018,7 +2029,7 @@
}
},
/**
- * Lookup269: frame_system::EventRecord<opal_runtime::Event, primitive_types::H256>
+ * Lookup272: frame_system::EventRecord<opal_runtime::Event, primitive_types::H256>
**/
FrameSystemEventRecord: {
phase: 'FrameSystemPhase',
@@ -2026,7 +2037,7 @@
topics: 'Vec<H256>'
},
/**
- * Lookup271: frame_system::pallet::Event<T>
+ * Lookup274: frame_system::pallet::Event<T>
**/
FrameSystemEvent: {
_enum: {
@@ -2054,7 +2065,7 @@
}
},
/**
- * Lookup272: frame_support::weights::DispatchInfo
+ * Lookup275: frame_support::weights::DispatchInfo
**/
FrameSupportWeightsDispatchInfo: {
weight: 'u64',
@@ -2062,19 +2073,19 @@
paysFee: 'FrameSupportWeightsPays'
},
/**
- * Lookup273: frame_support::weights::DispatchClass
+ * Lookup276: frame_support::weights::DispatchClass
**/
FrameSupportWeightsDispatchClass: {
_enum: ['Normal', 'Operational', 'Mandatory']
},
/**
- * Lookup274: frame_support::weights::Pays
+ * Lookup277: frame_support::weights::Pays
**/
FrameSupportWeightsPays: {
_enum: ['Yes', 'No']
},
/**
- * Lookup275: orml_vesting::module::Event<T>
+ * Lookup278: orml_vesting::module::Event<T>
**/
OrmlVestingModuleEvent: {
_enum: {
@@ -2093,7 +2104,7 @@
}
},
/**
- * Lookup276: cumulus_pallet_xcmp_queue::pallet::Event<T>
+ * Lookup279: cumulus_pallet_xcmp_queue::pallet::Event<T>
**/
CumulusPalletXcmpQueueEvent: {
_enum: {
@@ -2108,7 +2119,7 @@
}
},
/**
- * Lookup277: pallet_xcm::pallet::Event<T>
+ * Lookup280: pallet_xcm::pallet::Event<T>
**/
PalletXcmEvent: {
_enum: {
@@ -2131,7 +2142,7 @@
}
},
/**
- * Lookup278: xcm::v2::traits::Outcome
+ * Lookup281: xcm::v2::traits::Outcome
**/
XcmV2TraitsOutcome: {
_enum: {
@@ -2141,7 +2152,7 @@
}
},
/**
- * Lookup280: cumulus_pallet_xcm::pallet::Event<T>
+ * Lookup283: cumulus_pallet_xcm::pallet::Event<T>
**/
CumulusPalletXcmEvent: {
_enum: {
@@ -2151,7 +2162,7 @@
}
},
/**
- * Lookup281: cumulus_pallet_dmp_queue::pallet::Event<T>
+ * Lookup284: cumulus_pallet_dmp_queue::pallet::Event<T>
**/
CumulusPalletDmpQueueEvent: {
_enum: {
@@ -2164,7 +2175,7 @@
}
},
/**
- * Lookup282: pallet_unique::RawEvent<sp_core::crypto::AccountId32, pallet_evm::account::BasicCrossAccountIdRepr<sp_core::crypto::AccountId32>>
+ * Lookup285: pallet_unique::RawEvent<sp_core::crypto::AccountId32, pallet_evm::account::BasicCrossAccountIdRepr<sp_core::crypto::AccountId32>>
**/
PalletUniqueRawEvent: {
_enum: {
@@ -2181,7 +2192,7 @@
}
},
/**
- * Lookup283: pallet_unique_scheduler::pallet::Event<T>
+ * Lookup286: pallet_unique_scheduler::pallet::Event<T>
**/
PalletUniqueSchedulerEvent: {
_enum: {
@@ -2206,13 +2217,13 @@
}
},
/**
- * Lookup285: frame_support::traits::schedule::LookupError
+ * Lookup288: frame_support::traits::schedule::LookupError
**/
FrameSupportScheduleLookupError: {
_enum: ['Unknown', 'BadFormat']
},
/**
- * Lookup286: pallet_common::pallet::Event<T>
+ * Lookup289: pallet_common::pallet::Event<T>
**/
PalletCommonEvent: {
_enum: {
@@ -2230,7 +2241,7 @@
}
},
/**
- * Lookup287: pallet_structure::pallet::Event<T>
+ * Lookup290: pallet_structure::pallet::Event<T>
**/
PalletStructureEvent: {
_enum: {
@@ -2238,7 +2249,7 @@
}
},
/**
- * Lookup288: pallet_rmrk_core::pallet::Event<T>
+ * Lookup291: pallet_rmrk_core::pallet::Event<T>
**/
PalletRmrkCoreEvent: {
_enum: {
@@ -2315,7 +2326,7 @@
}
},
/**
- * Lookup289: pallet_rmrk_equip::pallet::Event<T>
+ * Lookup292: pallet_rmrk_equip::pallet::Event<T>
**/
PalletRmrkEquipEvent: {
_enum: {
@@ -2326,7 +2337,7 @@
}
},
/**
- * Lookup290: pallet_evm::pallet::Event<T>
+ * Lookup293: pallet_evm::pallet::Event<T>
**/
PalletEvmEvent: {
_enum: {
@@ -2340,7 +2351,7 @@
}
},
/**
- * Lookup291: ethereum::log::Log
+ * Lookup294: ethereum::log::Log
**/
EthereumLog: {
address: 'H160',
@@ -2348,7 +2359,7 @@
data: 'Bytes'
},
/**
- * Lookup292: pallet_ethereum::pallet::Event
+ * Lookup295: pallet_ethereum::pallet::Event
**/
PalletEthereumEvent: {
_enum: {
@@ -2356,7 +2367,7 @@
}
},
/**
- * Lookup293: evm_core::error::ExitReason
+ * Lookup296: evm_core::error::ExitReason
**/
EvmCoreErrorExitReason: {
_enum: {
@@ -2367,13 +2378,13 @@
}
},
/**
- * Lookup294: evm_core::error::ExitSucceed
+ * Lookup297: evm_core::error::ExitSucceed
**/
EvmCoreErrorExitSucceed: {
_enum: ['Stopped', 'Returned', 'Suicided']
},
/**
- * Lookup295: evm_core::error::ExitError
+ * Lookup298: evm_core::error::ExitError
**/
EvmCoreErrorExitError: {
_enum: {
@@ -2395,13 +2406,13 @@
}
},
/**
- * Lookup298: evm_core::error::ExitRevert
+ * Lookup301: evm_core::error::ExitRevert
**/
EvmCoreErrorExitRevert: {
_enum: ['Reverted']
},
/**
- * Lookup299: evm_core::error::ExitFatal
+ * Lookup302: evm_core::error::ExitFatal
**/
EvmCoreErrorExitFatal: {
_enum: {
@@ -2412,7 +2423,7 @@
}
},
/**
- * Lookup300: frame_system::Phase
+ * Lookup303: frame_system::Phase
**/
FrameSystemPhase: {
_enum: {
@@ -2422,14 +2433,14 @@
}
},
/**
- * Lookup302: frame_system::LastRuntimeUpgradeInfo
+ * Lookup305: frame_system::LastRuntimeUpgradeInfo
**/
FrameSystemLastRuntimeUpgradeInfo: {
specVersion: 'Compact<u32>',
specName: 'Text'
},
/**
- * Lookup303: frame_system::limits::BlockWeights
+ * Lookup306: frame_system::limits::BlockWeights
**/
FrameSystemLimitsBlockWeights: {
baseBlock: 'u64',
@@ -2437,7 +2448,7 @@
perClass: 'FrameSupportWeightsPerDispatchClassWeightsPerClass'
},
/**
- * Lookup304: frame_support::weights::PerDispatchClass<frame_system::limits::WeightsPerClass>
+ * Lookup307: frame_support::weights::PerDispatchClass<frame_system::limits::WeightsPerClass>
**/
FrameSupportWeightsPerDispatchClassWeightsPerClass: {
normal: 'FrameSystemLimitsWeightsPerClass',
@@ -2445,7 +2456,7 @@
mandatory: 'FrameSystemLimitsWeightsPerClass'
},
/**
- * Lookup305: frame_system::limits::WeightsPerClass
+ * Lookup308: frame_system::limits::WeightsPerClass
**/
FrameSystemLimitsWeightsPerClass: {
baseExtrinsic: 'u64',
@@ -2454,13 +2465,13 @@
reserved: 'Option<u64>'
},
/**
- * Lookup307: frame_system::limits::BlockLength
+ * Lookup310: frame_system::limits::BlockLength
**/
FrameSystemLimitsBlockLength: {
max: 'FrameSupportWeightsPerDispatchClassU32'
},
/**
- * Lookup308: frame_support::weights::PerDispatchClass<T>
+ * Lookup311: frame_support::weights::PerDispatchClass<T>
**/
FrameSupportWeightsPerDispatchClassU32: {
normal: 'u32',
@@ -2468,14 +2479,14 @@
mandatory: 'u32'
},
/**
- * Lookup309: frame_support::weights::RuntimeDbWeight
+ * Lookup312: frame_support::weights::RuntimeDbWeight
**/
FrameSupportWeightsRuntimeDbWeight: {
read: 'u64',
write: 'u64'
},
/**
- * Lookup310: sp_version::RuntimeVersion
+ * Lookup313: sp_version::RuntimeVersion
**/
SpVersionRuntimeVersion: {
specName: 'Text',
@@ -2488,19 +2499,19 @@
stateVersion: 'u8'
},
/**
- * Lookup314: frame_system::pallet::Error<T>
+ * Lookup317: frame_system::pallet::Error<T>
**/
FrameSystemError: {
_enum: ['InvalidSpecName', 'SpecVersionNeedsToIncrease', 'FailedToExtractRuntimeVersion', 'NonDefaultComposite', 'NonZeroRefCount', 'CallFiltered']
},
/**
- * Lookup316: orml_vesting::module::Error<T>
+ * Lookup319: orml_vesting::module::Error<T>
**/
OrmlVestingModuleError: {
_enum: ['ZeroVestingPeriod', 'ZeroVestingPeriodCount', 'InsufficientBalanceToLock', 'TooManyVestingSchedules', 'AmountLow', 'MaxVestingSchedulesExceeded']
},
/**
- * Lookup318: cumulus_pallet_xcmp_queue::InboundChannelDetails
+ * Lookup321: cumulus_pallet_xcmp_queue::InboundChannelDetails
**/
CumulusPalletXcmpQueueInboundChannelDetails: {
sender: 'u32',
@@ -2508,19 +2519,19 @@
messageMetadata: 'Vec<(u32,PolkadotParachainPrimitivesXcmpMessageFormat)>'
},
/**
- * Lookup319: cumulus_pallet_xcmp_queue::InboundState
+ * Lookup322: cumulus_pallet_xcmp_queue::InboundState
**/
CumulusPalletXcmpQueueInboundState: {
_enum: ['Ok', 'Suspended']
},
/**
- * Lookup322: polkadot_parachain::primitives::XcmpMessageFormat
+ * Lookup325: polkadot_parachain::primitives::XcmpMessageFormat
**/
PolkadotParachainPrimitivesXcmpMessageFormat: {
_enum: ['ConcatenatedVersionedXcm', 'ConcatenatedEncodedBlob', 'Signals']
},
/**
- * Lookup325: cumulus_pallet_xcmp_queue::OutboundChannelDetails
+ * Lookup328: cumulus_pallet_xcmp_queue::OutboundChannelDetails
**/
CumulusPalletXcmpQueueOutboundChannelDetails: {
recipient: 'u32',
@@ -2530,13 +2541,13 @@
lastIndex: 'u16'
},
/**
- * Lookup326: cumulus_pallet_xcmp_queue::OutboundState
+ * Lookup329: cumulus_pallet_xcmp_queue::OutboundState
**/
CumulusPalletXcmpQueueOutboundState: {
_enum: ['Ok', 'Suspended']
},
/**
- * Lookup328: cumulus_pallet_xcmp_queue::QueueConfigData
+ * Lookup331: cumulus_pallet_xcmp_queue::QueueConfigData
**/
CumulusPalletXcmpQueueQueueConfigData: {
suspendThreshold: 'u32',
@@ -2547,29 +2558,29 @@
xcmpMaxIndividualWeight: 'u64'
},
/**
- * Lookup330: cumulus_pallet_xcmp_queue::pallet::Error<T>
+ * Lookup333: cumulus_pallet_xcmp_queue::pallet::Error<T>
**/
CumulusPalletXcmpQueueError: {
_enum: ['FailedToSend', 'BadXcmOrigin', 'BadXcm', 'BadOverweightIndex', 'WeightOverLimit']
},
/**
- * Lookup331: pallet_xcm::pallet::Error<T>
+ * Lookup334: pallet_xcm::pallet::Error<T>
**/
PalletXcmError: {
_enum: ['Unreachable', 'SendFailure', 'Filtered', 'UnweighableMessage', 'DestinationNotInvertible', 'Empty', 'CannotReanchor', 'TooManyAssets', 'InvalidOrigin', 'BadVersion', 'BadLocation', 'NoSubscription', 'AlreadySubscribed']
},
/**
- * Lookup332: cumulus_pallet_xcm::pallet::Error<T>
+ * Lookup335: cumulus_pallet_xcm::pallet::Error<T>
**/
CumulusPalletXcmError: 'Null',
/**
- * Lookup333: cumulus_pallet_dmp_queue::ConfigData
+ * Lookup336: cumulus_pallet_dmp_queue::ConfigData
**/
CumulusPalletDmpQueueConfigData: {
maxIndividual: 'u64'
},
/**
- * Lookup334: cumulus_pallet_dmp_queue::PageIndexData
+ * Lookup337: cumulus_pallet_dmp_queue::PageIndexData
**/
CumulusPalletDmpQueuePageIndexData: {
beginUsed: 'u32',
@@ -2577,19 +2588,19 @@
overweightCount: 'u64'
},
/**
- * Lookup337: cumulus_pallet_dmp_queue::pallet::Error<T>
+ * Lookup340: cumulus_pallet_dmp_queue::pallet::Error<T>
**/
CumulusPalletDmpQueueError: {
_enum: ['Unknown', 'OverLimit']
},
/**
- * Lookup341: pallet_unique::Error<T>
+ * Lookup344: pallet_unique::Error<T>
**/
PalletUniqueError: {
_enum: ['CollectionDecimalPointLimitExceeded', 'ConfirmUnsetSponsorFail', 'EmptyArgument']
},
/**
- * Lookup344: pallet_unique_scheduler::ScheduledV3<frame_support::traits::schedule::MaybeHashed<opal_runtime::Call, primitive_types::H256>, BlockNumber, opal_runtime::OriginCaller, sp_core::crypto::AccountId32>
+ * Lookup347: pallet_unique_scheduler::ScheduledV3<frame_support::traits::schedule::MaybeHashed<opal_runtime::Call, primitive_types::H256>, BlockNumber, opal_runtime::OriginCaller, sp_core::crypto::AccountId32>
**/
PalletUniqueSchedulerScheduledV3: {
maybeId: 'Option<[u8;16]>',
@@ -2599,7 +2610,7 @@
origin: 'OpalRuntimeOriginCaller'
},
/**
- * Lookup345: opal_runtime::OriginCaller
+ * Lookup348: opal_runtime::OriginCaller
**/
OpalRuntimeOriginCaller: {
_enum: {
@@ -2708,7 +2719,7 @@
}
},
/**
- * Lookup346: frame_support::dispatch::RawOrigin<sp_core::crypto::AccountId32>
+ * Lookup349: frame_support::dispatch::RawOrigin<sp_core::crypto::AccountId32>
**/
FrameSupportDispatchRawOrigin: {
_enum: {
@@ -2718,7 +2729,7 @@
}
},
/**
- * Lookup347: pallet_xcm::pallet::Origin
+ * Lookup350: pallet_xcm::pallet::Origin
**/
PalletXcmOrigin: {
_enum: {
@@ -2727,7 +2738,7 @@
}
},
/**
- * Lookup348: cumulus_pallet_xcm::pallet::Origin
+ * Lookup351: cumulus_pallet_xcm::pallet::Origin
**/
CumulusPalletXcmOrigin: {
_enum: {
@@ -2736,7 +2747,7 @@
}
},
/**
- * Lookup349: pallet_ethereum::RawOrigin
+ * Lookup352: pallet_ethereum::RawOrigin
**/
PalletEthereumRawOrigin: {
_enum: {
@@ -2744,17 +2755,17 @@
}
},
/**
- * Lookup350: sp_core::Void
+ * Lookup353: sp_core::Void
**/
SpCoreVoid: 'Null',
/**
- * Lookup351: pallet_unique_scheduler::pallet::Error<T>
+ * Lookup354: pallet_unique_scheduler::pallet::Error<T>
**/
PalletUniqueSchedulerError: {
_enum: ['FailedToSchedule', 'NotFound', 'TargetBlockNumberInPast', 'RescheduleNoChange']
},
/**
- * Lookup352: up_data_structs::Collection<sp_core::crypto::AccountId32>
+ * Lookup355: up_data_structs::Collection<sp_core::crypto::AccountId32>
**/
UpDataStructsCollection: {
owner: 'AccountId32',
@@ -2768,7 +2779,7 @@
externalCollection: 'bool'
},
/**
- * Lookup353: up_data_structs::SponsorshipState<sp_core::crypto::AccountId32>
+ * Lookup356: up_data_structs::SponsorshipState<sp_core::crypto::AccountId32>
**/
UpDataStructsSponsorshipState: {
_enum: {
@@ -2778,7 +2789,7 @@
}
},
/**
- * Lookup354: up_data_structs::Properties
+ * Lookup357: up_data_structs::Properties
**/
UpDataStructsProperties: {
map: 'UpDataStructsPropertiesMapBoundedVec',
@@ -2786,15 +2797,15 @@
spaceLimit: 'u32'
},
/**
- * Lookup355: up_data_structs::PropertiesMap<frame_support::storage::bounded_vec::BoundedVec<T, S>>
+ * Lookup358: up_data_structs::PropertiesMap<frame_support::storage::bounded_vec::BoundedVec<T, S>>
**/
UpDataStructsPropertiesMapBoundedVec: 'BTreeMap<Bytes, Bytes>',
/**
- * Lookup360: up_data_structs::PropertiesMap<up_data_structs::PropertyPermission>
+ * Lookup363: up_data_structs::PropertiesMap<up_data_structs::PropertyPermission>
**/
UpDataStructsPropertiesMapPropertyPermission: 'BTreeMap<Bytes, UpDataStructsPropertyPermission>',
/**
- * Lookup367: up_data_structs::CollectionStats
+ * Lookup370: up_data_structs::CollectionStats
**/
UpDataStructsCollectionStats: {
created: 'u32',
@@ -2802,25 +2813,25 @@
alive: 'u32'
},
/**
- * Lookup368: up_data_structs::TokenChild
+ * Lookup371: up_data_structs::TokenChild
**/
UpDataStructsTokenChild: {
token: 'u32',
collection: 'u32'
},
/**
- * Lookup369: PhantomType::up_data_structs<T>
+ * Lookup372: PhantomType::up_data_structs<T>
**/
PhantomTypeUpDataStructs: '[(UpDataStructsTokenData,UpDataStructsRpcCollection,RmrkTraitsCollectionCollectionInfo,RmrkTraitsNftNftInfo,RmrkTraitsResourceResourceInfo,RmrkTraitsPropertyPropertyInfo,RmrkTraitsBaseBaseInfo,RmrkTraitsPartPartType,RmrkTraitsTheme,RmrkTraitsNftNftChild);0]',
/**
- * Lookup371: up_data_structs::TokenData<pallet_evm::account::BasicCrossAccountIdRepr<sp_core::crypto::AccountId32>>
+ * Lookup374: up_data_structs::TokenData<pallet_evm::account::BasicCrossAccountIdRepr<sp_core::crypto::AccountId32>>
**/
UpDataStructsTokenData: {
properties: 'Vec<UpDataStructsProperty>',
owner: 'Option<PalletEvmAccountBasicCrossAccountIdRepr>'
},
/**
- * Lookup373: up_data_structs::RpcCollection<sp_core::crypto::AccountId32>
+ * Lookup376: up_data_structs::RpcCollection<sp_core::crypto::AccountId32>
**/
UpDataStructsRpcCollection: {
owner: 'AccountId32',
@@ -2836,7 +2847,7 @@
readOnly: 'bool'
},
/**
- * Lookup374: rmrk_traits::collection::CollectionInfo<frame_support::storage::bounded_vec::BoundedVec<T, S>, frame_support::storage::bounded_vec::BoundedVec<T, S>, sp_core::crypto::AccountId32>
+ * Lookup377: rmrk_traits::collection::CollectionInfo<frame_support::storage::bounded_vec::BoundedVec<T, S>, frame_support::storage::bounded_vec::BoundedVec<T, S>, sp_core::crypto::AccountId32>
**/
RmrkTraitsCollectionCollectionInfo: {
issuer: 'AccountId32',
@@ -2846,7 +2857,7 @@
nftsCount: 'u32'
},
/**
- * Lookup375: rmrk_traits::nft::NftInfo<sp_core::crypto::AccountId32, sp_arithmetic::per_things::Permill, frame_support::storage::bounded_vec::BoundedVec<T, S>>
+ * Lookup378: rmrk_traits::nft::NftInfo<sp_core::crypto::AccountId32, sp_arithmetic::per_things::Permill, frame_support::storage::bounded_vec::BoundedVec<T, S>>
**/
RmrkTraitsNftNftInfo: {
owner: 'RmrkTraitsNftAccountIdOrCollectionNftTuple',
@@ -2856,14 +2867,14 @@
pending: 'bool'
},
/**
- * Lookup377: rmrk_traits::nft::RoyaltyInfo<sp_core::crypto::AccountId32, sp_arithmetic::per_things::Permill>
+ * Lookup380: rmrk_traits::nft::RoyaltyInfo<sp_core::crypto::AccountId32, sp_arithmetic::per_things::Permill>
**/
RmrkTraitsNftRoyaltyInfo: {
recipient: 'AccountId32',
amount: 'Permill'
},
/**
- * Lookup378: rmrk_traits::resource::ResourceInfo<frame_support::storage::bounded_vec::BoundedVec<T, S>, frame_support::storage::bounded_vec::BoundedVec<T, S>>
+ * Lookup381: rmrk_traits::resource::ResourceInfo<frame_support::storage::bounded_vec::BoundedVec<T, S>, frame_support::storage::bounded_vec::BoundedVec<T, S>>
**/
RmrkTraitsResourceResourceInfo: {
id: 'u32',
@@ -2872,24 +2883,14 @@
pendingRemoval: 'bool'
},
/**
- * Lookup379: rmrk_traits::resource::ResourceTypes<frame_support::storage::bounded_vec::BoundedVec<T, S>, frame_support::storage::bounded_vec::BoundedVec<T, S>>
- **/
- RmrkTraitsResourceResourceTypes: {
- _enum: {
- Basic: 'RmrkTraitsResourceBasicResource',
- Composable: 'RmrkTraitsResourceComposableResource',
- Slot: 'RmrkTraitsResourceSlotResource'
- }
- },
- /**
- * Lookup380: rmrk_traits::property::PropertyInfo<frame_support::storage::bounded_vec::BoundedVec<T, S>, frame_support::storage::bounded_vec::BoundedVec<T, S>>
+ * Lookup382: rmrk_traits::property::PropertyInfo<frame_support::storage::bounded_vec::BoundedVec<T, S>, frame_support::storage::bounded_vec::BoundedVec<T, S>>
**/
RmrkTraitsPropertyPropertyInfo: {
key: 'Bytes',
value: 'Bytes'
},
/**
- * Lookup381: rmrk_traits::base::BaseInfo<sp_core::crypto::AccountId32, frame_support::storage::bounded_vec::BoundedVec<T, S>>
+ * Lookup383: rmrk_traits::base::BaseInfo<sp_core::crypto::AccountId32, frame_support::storage::bounded_vec::BoundedVec<T, S>>
**/
RmrkTraitsBaseBaseInfo: {
issuer: 'AccountId32',
@@ -2897,74 +2898,74 @@
symbol: 'Bytes'
},
/**
- * Lookup382: rmrk_traits::nft::NftChild
+ * Lookup384: rmrk_traits::nft::NftChild
**/
RmrkTraitsNftNftChild: {
collectionId: 'u32',
nftId: 'u32'
},
/**
- * Lookup384: pallet_common::pallet::Error<T>
+ * Lookup386: 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']
},
/**
- * Lookup386: pallet_fungible::pallet::Error<T>
+ * Lookup388: pallet_fungible::pallet::Error<T>
**/
PalletFungibleError: {
_enum: ['NotFungibleDataUsedToMintFungibleCollectionToken', 'FungibleItemsHaveNoId', 'FungibleItemsDontHaveData', 'FungibleDisallowsNesting', 'SettingPropertiesNotAllowed']
},
/**
- * Lookup387: pallet_refungible::ItemData
+ * Lookup389: pallet_refungible::ItemData
**/
PalletRefungibleItemData: {
constData: 'Bytes'
},
/**
- * Lookup391: pallet_refungible::pallet::Error<T>
+ * Lookup393: pallet_refungible::pallet::Error<T>
**/
PalletRefungibleError: {
_enum: ['NotRefungibleDataUsedToMintFungibleCollectionToken', 'WrongRefungiblePieces', 'RefungibleDisallowsNesting', 'SettingPropertiesNotAllowed']
},
/**
- * Lookup392: pallet_nonfungible::ItemData<pallet_evm::account::BasicCrossAccountIdRepr<sp_core::crypto::AccountId32>>
+ * Lookup394: pallet_nonfungible::ItemData<pallet_evm::account::BasicCrossAccountIdRepr<sp_core::crypto::AccountId32>>
**/
PalletNonfungibleItemData: {
owner: 'PalletEvmAccountBasicCrossAccountIdRepr'
},
/**
- * Lookup394: pallet_nonfungible::pallet::Error<T>
+ * Lookup396: pallet_nonfungible::pallet::Error<T>
**/
PalletNonfungibleError: {
_enum: ['NotNonfungibleDataUsedToMintFungibleCollectionToken', 'NonfungibleItemsHaveNoAmount', 'CantBurnNftWithChildren']
},
/**
- * Lookup395: pallet_structure::pallet::Error<T>
+ * Lookup397: pallet_structure::pallet::Error<T>
**/
PalletStructureError: {
_enum: ['OuroborosDetected', 'DepthLimit', 'BreadthLimit', 'TokenNotFound']
},
/**
- * Lookup396: pallet_rmrk_core::pallet::Error<T>
+ * Lookup398: pallet_rmrk_core::pallet::Error<T>
**/
PalletRmrkCoreError: {
- _enum: ['CorruptedCollectionType', 'NftTypeEncodeError', 'RmrkPropertyKeyIsTooLong', 'RmrkPropertyValueIsTooLong', 'CollectionNotEmpty', 'NoAvailableCollectionId', 'NoAvailableNftId', 'CollectionUnknown', 'NoPermission', 'NonTransferable', 'CollectionFullOrLocked', 'ResourceDoesntExist', 'CannotSendToDescendentOrSelf', 'CannotAcceptNonOwnedNft', 'CannotRejectNonOwnedNft', 'ResourceNotPending']
+ _enum: ['CorruptedCollectionType', 'NftTypeEncodeError', 'RmrkPropertyKeyIsTooLong', 'RmrkPropertyValueIsTooLong', 'UnableToDecodeRmrkData', 'CollectionNotEmpty', 'NoAvailableCollectionId', 'NoAvailableNftId', 'CollectionUnknown', 'NoPermission', 'NonTransferable', 'CollectionFullOrLocked', 'ResourceDoesntExist', 'CannotSendToDescendentOrSelf', 'CannotAcceptNonOwnedNft', 'CannotRejectNonOwnedNft', 'ResourceNotPending']
},
/**
- * Lookup398: pallet_rmrk_equip::pallet::Error<T>
+ * Lookup400: pallet_rmrk_equip::pallet::Error<T>
**/
PalletRmrkEquipError: {
_enum: ['PermissionError', 'NoAvailableBaseId', 'NoAvailablePartId', 'BaseDoesntExist', 'NeedsDefaultThemeFirst']
},
/**
- * Lookup401: pallet_evm::pallet::Error<T>
+ * Lookup403: pallet_evm::pallet::Error<T>
**/
PalletEvmError: {
_enum: ['BalanceLow', 'FeeOverflow', 'PaymentOverflow', 'WithdrawFailed', 'GasPriceTooLow', 'InvalidNonce']
},
/**
- * Lookup404: fp_rpc::TransactionStatus
+ * Lookup406: fp_rpc::TransactionStatus
**/
FpRpcTransactionStatus: {
transactionHash: 'H256',
@@ -2976,11 +2977,11 @@
logsBloom: 'EthbloomBloom'
},
/**
- * Lookup406: ethbloom::Bloom
+ * Lookup408: ethbloom::Bloom
**/
EthbloomBloom: '[u8;256]',
/**
- * Lookup408: ethereum::receipt::ReceiptV3
+ * Lookup410: ethereum::receipt::ReceiptV3
**/
EthereumReceiptReceiptV3: {
_enum: {
@@ -2990,7 +2991,7 @@
}
},
/**
- * Lookup409: ethereum::receipt::EIP658ReceiptData
+ * Lookup411: ethereum::receipt::EIP658ReceiptData
**/
EthereumReceiptEip658ReceiptData: {
statusCode: 'u8',
@@ -2999,7 +3000,7 @@
logs: 'Vec<EthereumLog>'
},
/**
- * Lookup410: ethereum::block::Block<ethereum::transaction::TransactionV2>
+ * Lookup412: ethereum::block::Block<ethereum::transaction::TransactionV2>
**/
EthereumBlock: {
header: 'EthereumHeader',
@@ -3007,7 +3008,7 @@
ommers: 'Vec<EthereumHeader>'
},
/**
- * Lookup411: ethereum::header::Header
+ * Lookup413: ethereum::header::Header
**/
EthereumHeader: {
parentHash: 'H256',
@@ -3027,41 +3028,41 @@
nonce: 'EthereumTypesHashH64'
},
/**
- * Lookup412: ethereum_types::hash::H64
+ * Lookup414: ethereum_types::hash::H64
**/
EthereumTypesHashH64: '[u8;8]',
/**
- * Lookup417: pallet_ethereum::pallet::Error<T>
+ * Lookup419: pallet_ethereum::pallet::Error<T>
**/
PalletEthereumError: {
_enum: ['InvalidSignature', 'PreLogExists']
},
/**
- * Lookup418: pallet_evm_coder_substrate::pallet::Error<T>
+ * Lookup420: pallet_evm_coder_substrate::pallet::Error<T>
**/
PalletEvmCoderSubstrateError: {
_enum: ['OutOfGas', 'OutOfFund']
},
/**
- * Lookup419: pallet_evm_contract_helpers::SponsoringModeT
+ * Lookup421: pallet_evm_contract_helpers::SponsoringModeT
**/
PalletEvmContractHelpersSponsoringModeT: {
_enum: ['Disabled', 'Allowlisted', 'Generous']
},
/**
- * Lookup421: pallet_evm_contract_helpers::pallet::Error<T>
+ * Lookup423: pallet_evm_contract_helpers::pallet::Error<T>
**/
PalletEvmContractHelpersError: {
_enum: ['NoPermission']
},
/**
- * Lookup422: pallet_evm_migration::pallet::Error<T>
+ * Lookup424: pallet_evm_migration::pallet::Error<T>
**/
PalletEvmMigrationError: {
_enum: ['AccountNotEmpty', 'AccountIsNotMigrating']
},
/**
- * Lookup424: sp_runtime::MultiSignature
+ * Lookup426: sp_runtime::MultiSignature
**/
SpRuntimeMultiSignature: {
_enum: {
@@ -3071,43 +3072,43 @@
}
},
/**
- * Lookup425: sp_core::ed25519::Signature
+ * Lookup427: sp_core::ed25519::Signature
**/
SpCoreEd25519Signature: '[u8;64]',
/**
- * Lookup427: sp_core::sr25519::Signature
+ * Lookup429: sp_core::sr25519::Signature
**/
SpCoreSr25519Signature: '[u8;64]',
/**
- * Lookup428: sp_core::ecdsa::Signature
+ * Lookup430: sp_core::ecdsa::Signature
**/
SpCoreEcdsaSignature: '[u8;65]',
/**
- * Lookup431: frame_system::extensions::check_spec_version::CheckSpecVersion<T>
+ * Lookup433: frame_system::extensions::check_spec_version::CheckSpecVersion<T>
**/
FrameSystemExtensionsCheckSpecVersion: 'Null',
/**
- * Lookup432: frame_system::extensions::check_genesis::CheckGenesis<T>
+ * Lookup434: frame_system::extensions::check_genesis::CheckGenesis<T>
**/
FrameSystemExtensionsCheckGenesis: 'Null',
/**
- * Lookup435: frame_system::extensions::check_nonce::CheckNonce<T>
+ * Lookup437: frame_system::extensions::check_nonce::CheckNonce<T>
**/
FrameSystemExtensionsCheckNonce: 'Compact<u32>',
/**
- * Lookup436: frame_system::extensions::check_weight::CheckWeight<T>
+ * Lookup438: frame_system::extensions::check_weight::CheckWeight<T>
**/
FrameSystemExtensionsCheckWeight: 'Null',
/**
- * Lookup437: pallet_template_transaction_payment::ChargeTransactionPayment<opal_runtime::Runtime>
+ * Lookup439: pallet_template_transaction_payment::ChargeTransactionPayment<opal_runtime::Runtime>
**/
PalletTemplateTransactionPaymentChargeTransactionPayment: 'Compact<u128>',
/**
- * Lookup438: opal_runtime::Runtime
+ * Lookup440: opal_runtime::Runtime
**/
OpalRuntimeRuntime: 'Null',
/**
- * Lookup439: pallet_ethereum::FakeTransactionFinalizer<opal_runtime::Runtime>
+ * Lookup441: pallet_ethereum::FakeTransactionFinalizer<opal_runtime::Runtime>
**/
PalletEthereumFakeTransactionFinalizer: 'Null'
};
tests/src/interfaces/types-lookup.tsdiffbeforeafterboth--- a/tests/src/interfaces/types-lookup.ts
+++ b/tests/src/interfaces/types-lookup.ts
@@ -1562,7 +1562,7 @@
/** @name UpDataStructsNestingPermissions (169) */
export interface UpDataStructsNestingPermissions extends Struct {
readonly tokenOwner: bool;
- readonly admin: bool;
+ readonly collectionAdmin: bool;
readonly restricted: Option<UpDataStructsOwnerRestrictedSet>;
readonly permissive: bool;
}
@@ -1719,11 +1719,13 @@
readonly royaltyAmount: Option<Permill>;
readonly metadata: Bytes;
readonly transferable: bool;
+ readonly resources: Option<Vec<RmrkTraitsResourceResourceTypes>>;
} & Struct;
readonly isBurnNft: boolean;
readonly asBurnNft: {
readonly collectionId: u32;
readonly nftId: u32;
+ readonly maxBurns: u32;
} & Struct;
readonly isSend: boolean;
readonly asSend: {
@@ -1777,7 +1779,6 @@
readonly asAddComposableResource: {
readonly rmrkCollectionId: u32;
readonly nftId: u32;
- readonly resourceId: Bytes;
readonly resource: RmrkTraitsResourceComposableResource;
} & Struct;
readonly isAddSlotResource: boolean;
@@ -1795,13 +1796,15 @@
readonly type: 'CreateCollection' | 'DestroyCollection' | 'ChangeCollectionIssuer' | 'LockCollection' | 'MintNft' | 'BurnNft' | 'Send' | 'AcceptNft' | 'RejectNft' | 'AcceptResource' | 'AcceptResourceRemoval' | 'SetProperty' | 'SetPriority' | 'AddBasicResource' | 'AddComposableResource' | 'AddSlotResource' | 'RemoveResource';
}
- /** @name RmrkTraitsNftAccountIdOrCollectionNftTuple (215) */
- export interface RmrkTraitsNftAccountIdOrCollectionNftTuple extends Enum {
- readonly isAccountId: boolean;
- readonly asAccountId: AccountId32;
- readonly isCollectionAndNftTuple: boolean;
- readonly asCollectionAndNftTuple: ITuple<[u32, u32]>;
- readonly type: 'AccountId' | 'CollectionAndNftTuple';
+ /** @name RmrkTraitsResourceResourceTypes (217) */
+ export interface RmrkTraitsResourceResourceTypes extends Enum {
+ readonly isBasic: boolean;
+ readonly asBasic: RmrkTraitsResourceBasicResource;
+ readonly isComposable: boolean;
+ readonly asComposable: RmrkTraitsResourceComposableResource;
+ readonly isSlot: boolean;
+ readonly asSlot: RmrkTraitsResourceSlotResource;
+ readonly type: 'Basic' | 'Composable' | 'Slot';
}
/** @name RmrkTraitsResourceBasicResource (219) */
@@ -1812,7 +1815,7 @@
readonly thumb: Option<Bytes>;
}
- /** @name RmrkTraitsResourceComposableResource (222) */
+ /** @name RmrkTraitsResourceComposableResource (221) */
export interface RmrkTraitsResourceComposableResource extends Struct {
readonly parts: Vec<u32>;
readonly base: u32;
@@ -1822,7 +1825,7 @@
readonly thumb: Option<Bytes>;
}
- /** @name RmrkTraitsResourceSlotResource (224) */
+ /** @name RmrkTraitsResourceSlotResource (222) */
export interface RmrkTraitsResourceSlotResource extends Struct {
readonly base: u32;
readonly src: Option<Bytes>;
@@ -1832,7 +1835,16 @@
readonly thumb: Option<Bytes>;
}
- /** @name PalletRmrkEquipCall (225) */
+ /** @name RmrkTraitsNftAccountIdOrCollectionNftTuple (224) */
+ export interface RmrkTraitsNftAccountIdOrCollectionNftTuple extends Enum {
+ readonly isAccountId: boolean;
+ readonly asAccountId: AccountId32;
+ readonly isCollectionAndNftTuple: boolean;
+ readonly asCollectionAndNftTuple: ITuple<[u32, u32]>;
+ readonly type: 'AccountId' | 'CollectionAndNftTuple';
+ }
+
+ /** @name PalletRmrkEquipCall (228) */
export interface PalletRmrkEquipCall extends Enum {
readonly isCreateBase: boolean;
readonly asCreateBase: {
@@ -1848,7 +1860,7 @@
readonly type: 'CreateBase' | 'ThemeAdd';
}
- /** @name RmrkTraitsPartPartType (227) */
+ /** @name RmrkTraitsPartPartType (230) */
export interface RmrkTraitsPartPartType extends Enum {
readonly isFixedPart: boolean;
readonly asFixedPart: RmrkTraitsPartFixedPart;
@@ -1857,14 +1869,14 @@
readonly type: 'FixedPart' | 'SlotPart';
}
- /** @name RmrkTraitsPartFixedPart (229) */
+ /** @name RmrkTraitsPartFixedPart (232) */
export interface RmrkTraitsPartFixedPart extends Struct {
readonly id: u32;
readonly z: u32;
readonly src: Bytes;
}
- /** @name RmrkTraitsPartSlotPart (230) */
+ /** @name RmrkTraitsPartSlotPart (233) */
export interface RmrkTraitsPartSlotPart extends Struct {
readonly id: u32;
readonly equippable: RmrkTraitsPartEquippableList;
@@ -1872,7 +1884,7 @@
readonly z: u32;
}
- /** @name RmrkTraitsPartEquippableList (231) */
+ /** @name RmrkTraitsPartEquippableList (234) */
export interface RmrkTraitsPartEquippableList extends Enum {
readonly isAll: boolean;
readonly isEmpty: boolean;
@@ -1881,20 +1893,20 @@
readonly type: 'All' | 'Empty' | 'Custom';
}
- /** @name RmrkTraitsTheme (233) */
+ /** @name RmrkTraitsTheme (236) */
export interface RmrkTraitsTheme extends Struct {
readonly name: Bytes;
readonly properties: Vec<RmrkTraitsThemeThemeProperty>;
readonly inherit: bool;
}
- /** @name RmrkTraitsThemeThemeProperty (235) */
+ /** @name RmrkTraitsThemeThemeProperty (238) */
export interface RmrkTraitsThemeThemeProperty extends Struct {
readonly key: Bytes;
readonly value: Bytes;
}
- /** @name PalletEvmCall (236) */
+ /** @name PalletEvmCall (239) */
export interface PalletEvmCall extends Enum {
readonly isWithdraw: boolean;
readonly asWithdraw: {
@@ -1939,7 +1951,7 @@
readonly type: 'Withdraw' | 'Call' | 'Create' | 'Create2';
}
- /** @name PalletEthereumCall (242) */
+ /** @name PalletEthereumCall (245) */
export interface PalletEthereumCall extends Enum {
readonly isTransact: boolean;
readonly asTransact: {
@@ -1948,7 +1960,7 @@
readonly type: 'Transact';
}
- /** @name EthereumTransactionTransactionV2 (243) */
+ /** @name EthereumTransactionTransactionV2 (246) */
export interface EthereumTransactionTransactionV2 extends Enum {
readonly isLegacy: boolean;
readonly asLegacy: EthereumTransactionLegacyTransaction;
@@ -1959,7 +1971,7 @@
readonly type: 'Legacy' | 'Eip2930' | 'Eip1559';
}
- /** @name EthereumTransactionLegacyTransaction (244) */
+ /** @name EthereumTransactionLegacyTransaction (247) */
export interface EthereumTransactionLegacyTransaction extends Struct {
readonly nonce: U256;
readonly gasPrice: U256;
@@ -1970,7 +1982,7 @@
readonly signature: EthereumTransactionTransactionSignature;
}
- /** @name EthereumTransactionTransactionAction (245) */
+ /** @name EthereumTransactionTransactionAction (248) */
export interface EthereumTransactionTransactionAction extends Enum {
readonly isCall: boolean;
readonly asCall: H160;
@@ -1978,14 +1990,14 @@
readonly type: 'Call' | 'Create';
}
- /** @name EthereumTransactionTransactionSignature (246) */
+ /** @name EthereumTransactionTransactionSignature (249) */
export interface EthereumTransactionTransactionSignature extends Struct {
readonly v: u64;
readonly r: H256;
readonly s: H256;
}
- /** @name EthereumTransactionEip2930Transaction (248) */
+ /** @name EthereumTransactionEip2930Transaction (251) */
export interface EthereumTransactionEip2930Transaction extends Struct {
readonly chainId: u64;
readonly nonce: U256;
@@ -2000,13 +2012,13 @@
readonly s: H256;
}
- /** @name EthereumTransactionAccessListItem (250) */
+ /** @name EthereumTransactionAccessListItem (253) */
export interface EthereumTransactionAccessListItem extends Struct {
readonly address: H160;
readonly storageKeys: Vec<H256>;
}
- /** @name EthereumTransactionEip1559Transaction (251) */
+ /** @name EthereumTransactionEip1559Transaction (254) */
export interface EthereumTransactionEip1559Transaction extends Struct {
readonly chainId: u64;
readonly nonce: U256;
@@ -2022,7 +2034,7 @@
readonly s: H256;
}
- /** @name PalletEvmMigrationCall (252) */
+ /** @name PalletEvmMigrationCall (255) */
export interface PalletEvmMigrationCall extends Enum {
readonly isBegin: boolean;
readonly asBegin: {
@@ -2041,7 +2053,7 @@
readonly type: 'Begin' | 'SetData' | 'Finish';
}
- /** @name PalletSudoEvent (255) */
+ /** @name PalletSudoEvent (258) */
export interface PalletSudoEvent extends Enum {
readonly isSudid: boolean;
readonly asSudid: {
@@ -2058,7 +2070,7 @@
readonly type: 'Sudid' | 'KeyChanged' | 'SudoAsDone';
}
- /** @name SpRuntimeDispatchError (257) */
+ /** @name SpRuntimeDispatchError (260) */
export interface SpRuntimeDispatchError extends Enum {
readonly isOther: boolean;
readonly isCannotLookup: boolean;
@@ -2077,13 +2089,13 @@
readonly type: 'Other' | 'CannotLookup' | 'BadOrigin' | 'Module' | 'ConsumerRemaining' | 'NoProviders' | 'TooManyConsumers' | 'Token' | 'Arithmetic' | 'Transactional';
}
- /** @name SpRuntimeModuleError (258) */
+ /** @name SpRuntimeModuleError (261) */
export interface SpRuntimeModuleError extends Struct {
readonly index: u8;
readonly error: U8aFixed;
}
- /** @name SpRuntimeTokenError (259) */
+ /** @name SpRuntimeTokenError (262) */
export interface SpRuntimeTokenError extends Enum {
readonly isNoFunds: boolean;
readonly isWouldDie: boolean;
@@ -2095,7 +2107,7 @@
readonly type: 'NoFunds' | 'WouldDie' | 'BelowMinimum' | 'CannotCreate' | 'UnknownAsset' | 'Frozen' | 'Unsupported';
}
- /** @name SpRuntimeArithmeticError (260) */
+ /** @name SpRuntimeArithmeticError (263) */
export interface SpRuntimeArithmeticError extends Enum {
readonly isUnderflow: boolean;
readonly isOverflow: boolean;
@@ -2103,20 +2115,20 @@
readonly type: 'Underflow' | 'Overflow' | 'DivisionByZero';
}
- /** @name SpRuntimeTransactionalError (261) */
+ /** @name SpRuntimeTransactionalError (264) */
export interface SpRuntimeTransactionalError extends Enum {
readonly isLimitReached: boolean;
readonly isNoLayer: boolean;
readonly type: 'LimitReached' | 'NoLayer';
}
- /** @name PalletSudoError (262) */
+ /** @name PalletSudoError (265) */
export interface PalletSudoError extends Enum {
readonly isRequireSudo: boolean;
readonly type: 'RequireSudo';
}
- /** @name FrameSystemAccountInfo (263) */
+ /** @name FrameSystemAccountInfo (266) */
export interface FrameSystemAccountInfo extends Struct {
readonly nonce: u32;
readonly consumers: u32;
@@ -2125,19 +2137,19 @@
readonly data: PalletBalancesAccountData;
}
- /** @name FrameSupportWeightsPerDispatchClassU64 (264) */
+ /** @name FrameSupportWeightsPerDispatchClassU64 (267) */
export interface FrameSupportWeightsPerDispatchClassU64 extends Struct {
readonly normal: u64;
readonly operational: u64;
readonly mandatory: u64;
}
- /** @name SpRuntimeDigest (265) */
+ /** @name SpRuntimeDigest (268) */
export interface SpRuntimeDigest extends Struct {
readonly logs: Vec<SpRuntimeDigestDigestItem>;
}
- /** @name SpRuntimeDigestDigestItem (267) */
+ /** @name SpRuntimeDigestDigestItem (270) */
export interface SpRuntimeDigestDigestItem extends Enum {
readonly isOther: boolean;
readonly asOther: Bytes;
@@ -2151,14 +2163,14 @@
readonly type: 'Other' | 'Consensus' | 'Seal' | 'PreRuntime' | 'RuntimeEnvironmentUpdated';
}
- /** @name FrameSystemEventRecord (269) */
+ /** @name FrameSystemEventRecord (272) */
export interface FrameSystemEventRecord extends Struct {
readonly phase: FrameSystemPhase;
readonly event: Event;
readonly topics: Vec<H256>;
}
- /** @name FrameSystemEvent (271) */
+ /** @name FrameSystemEvent (274) */
export interface FrameSystemEvent extends Enum {
readonly isExtrinsicSuccess: boolean;
readonly asExtrinsicSuccess: {
@@ -2186,14 +2198,14 @@
readonly type: 'ExtrinsicSuccess' | 'ExtrinsicFailed' | 'CodeUpdated' | 'NewAccount' | 'KilledAccount' | 'Remarked';
}
- /** @name FrameSupportWeightsDispatchInfo (272) */
+ /** @name FrameSupportWeightsDispatchInfo (275) */
export interface FrameSupportWeightsDispatchInfo extends Struct {
readonly weight: u64;
readonly class: FrameSupportWeightsDispatchClass;
readonly paysFee: FrameSupportWeightsPays;
}
- /** @name FrameSupportWeightsDispatchClass (273) */
+ /** @name FrameSupportWeightsDispatchClass (276) */
export interface FrameSupportWeightsDispatchClass extends Enum {
readonly isNormal: boolean;
readonly isOperational: boolean;
@@ -2201,14 +2213,14 @@
readonly type: 'Normal' | 'Operational' | 'Mandatory';
}
- /** @name FrameSupportWeightsPays (274) */
+ /** @name FrameSupportWeightsPays (277) */
export interface FrameSupportWeightsPays extends Enum {
readonly isYes: boolean;
readonly isNo: boolean;
readonly type: 'Yes' | 'No';
}
- /** @name OrmlVestingModuleEvent (275) */
+ /** @name OrmlVestingModuleEvent (278) */
export interface OrmlVestingModuleEvent extends Enum {
readonly isVestingScheduleAdded: boolean;
readonly asVestingScheduleAdded: {
@@ -2228,7 +2240,7 @@
readonly type: 'VestingScheduleAdded' | 'Claimed' | 'VestingSchedulesUpdated';
}
- /** @name CumulusPalletXcmpQueueEvent (276) */
+ /** @name CumulusPalletXcmpQueueEvent (279) */
export interface CumulusPalletXcmpQueueEvent extends Enum {
readonly isSuccess: boolean;
readonly asSuccess: Option<H256>;
@@ -2249,7 +2261,7 @@
readonly type: 'Success' | 'Fail' | 'BadVersion' | 'BadFormat' | 'UpwardMessageSent' | 'XcmpMessageSent' | 'OverweightEnqueued' | 'OverweightServiced';
}
- /** @name PalletXcmEvent (277) */
+ /** @name PalletXcmEvent (280) */
export interface PalletXcmEvent extends Enum {
readonly isAttempted: boolean;
readonly asAttempted: XcmV2TraitsOutcome;
@@ -2286,7 +2298,7 @@
readonly type: 'Attempted' | 'Sent' | 'UnexpectedResponse' | 'ResponseReady' | 'Notified' | 'NotifyOverweight' | 'NotifyDispatchError' | 'NotifyDecodeFailed' | 'InvalidResponder' | 'InvalidResponderVersion' | 'ResponseTaken' | 'AssetsTrapped' | 'VersionChangeNotified' | 'SupportedVersionChanged' | 'NotifyTargetSendFail' | 'NotifyTargetMigrationFail';
}
- /** @name XcmV2TraitsOutcome (278) */
+ /** @name XcmV2TraitsOutcome (281) */
export interface XcmV2TraitsOutcome extends Enum {
readonly isComplete: boolean;
readonly asComplete: u64;
@@ -2297,7 +2309,7 @@
readonly type: 'Complete' | 'Incomplete' | 'Error';
}
- /** @name CumulusPalletXcmEvent (280) */
+ /** @name CumulusPalletXcmEvent (283) */
export interface CumulusPalletXcmEvent extends Enum {
readonly isInvalidFormat: boolean;
readonly asInvalidFormat: U8aFixed;
@@ -2308,7 +2320,7 @@
readonly type: 'InvalidFormat' | 'UnsupportedVersion' | 'ExecutedDownward';
}
- /** @name CumulusPalletDmpQueueEvent (281) */
+ /** @name CumulusPalletDmpQueueEvent (284) */
export interface CumulusPalletDmpQueueEvent extends Enum {
readonly isInvalidFormat: boolean;
readonly asInvalidFormat: U8aFixed;
@@ -2325,7 +2337,7 @@
readonly type: 'InvalidFormat' | 'UnsupportedVersion' | 'ExecutedDownward' | 'WeightExhausted' | 'OverweightEnqueued' | 'OverweightServiced';
}
- /** @name PalletUniqueRawEvent (282) */
+ /** @name PalletUniqueRawEvent (285) */
export interface PalletUniqueRawEvent extends Enum {
readonly isCollectionSponsorRemoved: boolean;
readonly asCollectionSponsorRemoved: u32;
@@ -2350,7 +2362,7 @@
readonly type: 'CollectionSponsorRemoved' | 'CollectionAdminAdded' | 'CollectionOwnedChanged' | 'CollectionSponsorSet' | 'SponsorshipConfirmed' | 'CollectionAdminRemoved' | 'AllowListAddressRemoved' | 'AllowListAddressAdded' | 'CollectionLimitSet' | 'CollectionPermissionSet';
}
- /** @name PalletUniqueSchedulerEvent (283) */
+ /** @name PalletUniqueSchedulerEvent (286) */
export interface PalletUniqueSchedulerEvent extends Enum {
readonly isScheduled: boolean;
readonly asScheduled: {
@@ -2377,14 +2389,14 @@
readonly type: 'Scheduled' | 'Canceled' | 'Dispatched' | 'CallLookupFailed';
}
- /** @name FrameSupportScheduleLookupError (285) */
+ /** @name FrameSupportScheduleLookupError (288) */
export interface FrameSupportScheduleLookupError extends Enum {
readonly isUnknown: boolean;
readonly isBadFormat: boolean;
readonly type: 'Unknown' | 'BadFormat';
}
- /** @name PalletCommonEvent (286) */
+ /** @name PalletCommonEvent (289) */
export interface PalletCommonEvent extends Enum {
readonly isCollectionCreated: boolean;
readonly asCollectionCreated: ITuple<[u32, u8, AccountId32]>;
@@ -2411,14 +2423,14 @@
readonly type: 'CollectionCreated' | 'CollectionDestroyed' | 'ItemCreated' | 'ItemDestroyed' | 'Transfer' | 'Approved' | 'CollectionPropertySet' | 'CollectionPropertyDeleted' | 'TokenPropertySet' | 'TokenPropertyDeleted' | 'PropertyPermissionSet';
}
- /** @name PalletStructureEvent (287) */
+ /** @name PalletStructureEvent (290) */
export interface PalletStructureEvent extends Enum {
readonly isExecuted: boolean;
readonly asExecuted: Result<Null, SpRuntimeDispatchError>;
readonly type: 'Executed';
}
- /** @name PalletRmrkCoreEvent (288) */
+ /** @name PalletRmrkCoreEvent (291) */
export interface PalletRmrkCoreEvent extends Enum {
readonly isCollectionCreated: boolean;
readonly asCollectionCreated: {
@@ -2508,7 +2520,7 @@
readonly type: 'CollectionCreated' | 'CollectionDestroyed' | 'IssuerChanged' | 'CollectionLocked' | 'NftMinted' | 'NftBurned' | 'NftSent' | 'NftAccepted' | 'NftRejected' | 'PropertySet' | 'ResourceAdded' | 'ResourceRemoval' | 'ResourceAccepted' | 'ResourceRemovalAccepted' | 'PrioritySet';
}
- /** @name PalletRmrkEquipEvent (289) */
+ /** @name PalletRmrkEquipEvent (292) */
export interface PalletRmrkEquipEvent extends Enum {
readonly isBaseCreated: boolean;
readonly asBaseCreated: {
@@ -2518,7 +2530,7 @@
readonly type: 'BaseCreated';
}
- /** @name PalletEvmEvent (290) */
+ /** @name PalletEvmEvent (293) */
export interface PalletEvmEvent extends Enum {
readonly isLog: boolean;
readonly asLog: EthereumLog;
@@ -2537,21 +2549,21 @@
readonly type: 'Log' | 'Created' | 'CreatedFailed' | 'Executed' | 'ExecutedFailed' | 'BalanceDeposit' | 'BalanceWithdraw';
}
- /** @name EthereumLog (291) */
+ /** @name EthereumLog (294) */
export interface EthereumLog extends Struct {
readonly address: H160;
readonly topics: Vec<H256>;
readonly data: Bytes;
}
- /** @name PalletEthereumEvent (292) */
+ /** @name PalletEthereumEvent (295) */
export interface PalletEthereumEvent extends Enum {
readonly isExecuted: boolean;
readonly asExecuted: ITuple<[H160, H160, H256, EvmCoreErrorExitReason]>;
readonly type: 'Executed';
}
- /** @name EvmCoreErrorExitReason (293) */
+ /** @name EvmCoreErrorExitReason (296) */
export interface EvmCoreErrorExitReason extends Enum {
readonly isSucceed: boolean;
readonly asSucceed: EvmCoreErrorExitSucceed;
@@ -2564,7 +2576,7 @@
readonly type: 'Succeed' | 'Error' | 'Revert' | 'Fatal';
}
- /** @name EvmCoreErrorExitSucceed (294) */
+ /** @name EvmCoreErrorExitSucceed (297) */
export interface EvmCoreErrorExitSucceed extends Enum {
readonly isStopped: boolean;
readonly isReturned: boolean;
@@ -2572,7 +2584,7 @@
readonly type: 'Stopped' | 'Returned' | 'Suicided';
}
- /** @name EvmCoreErrorExitError (295) */
+ /** @name EvmCoreErrorExitError (298) */
export interface EvmCoreErrorExitError extends Enum {
readonly isStackUnderflow: boolean;
readonly isStackOverflow: boolean;
@@ -2593,13 +2605,13 @@
readonly type: 'StackUnderflow' | 'StackOverflow' | 'InvalidJump' | 'InvalidRange' | 'DesignatedInvalid' | 'CallTooDeep' | 'CreateCollision' | 'CreateContractLimit' | 'OutOfOffset' | 'OutOfGas' | 'OutOfFund' | 'PcUnderflow' | 'CreateEmpty' | 'Other' | 'InvalidCode';
}
- /** @name EvmCoreErrorExitRevert (298) */
+ /** @name EvmCoreErrorExitRevert (301) */
export interface EvmCoreErrorExitRevert extends Enum {
readonly isReverted: boolean;
readonly type: 'Reverted';
}
- /** @name EvmCoreErrorExitFatal (299) */
+ /** @name EvmCoreErrorExitFatal (302) */
export interface EvmCoreErrorExitFatal extends Enum {
readonly isNotSupported: boolean;
readonly isUnhandledInterrupt: boolean;
@@ -2610,7 +2622,7 @@
readonly type: 'NotSupported' | 'UnhandledInterrupt' | 'CallErrorAsFatal' | 'Other';
}
- /** @name FrameSystemPhase (300) */
+ /** @name FrameSystemPhase (303) */
export interface FrameSystemPhase extends Enum {
readonly isApplyExtrinsic: boolean;
readonly asApplyExtrinsic: u32;
@@ -2619,27 +2631,27 @@
readonly type: 'ApplyExtrinsic' | 'Finalization' | 'Initialization';
}
- /** @name FrameSystemLastRuntimeUpgradeInfo (302) */
+ /** @name FrameSystemLastRuntimeUpgradeInfo (305) */
export interface FrameSystemLastRuntimeUpgradeInfo extends Struct {
readonly specVersion: Compact<u32>;
readonly specName: Text;
}
- /** @name FrameSystemLimitsBlockWeights (303) */
+ /** @name FrameSystemLimitsBlockWeights (306) */
export interface FrameSystemLimitsBlockWeights extends Struct {
readonly baseBlock: u64;
readonly maxBlock: u64;
readonly perClass: FrameSupportWeightsPerDispatchClassWeightsPerClass;
}
- /** @name FrameSupportWeightsPerDispatchClassWeightsPerClass (304) */
+ /** @name FrameSupportWeightsPerDispatchClassWeightsPerClass (307) */
export interface FrameSupportWeightsPerDispatchClassWeightsPerClass extends Struct {
readonly normal: FrameSystemLimitsWeightsPerClass;
readonly operational: FrameSystemLimitsWeightsPerClass;
readonly mandatory: FrameSystemLimitsWeightsPerClass;
}
- /** @name FrameSystemLimitsWeightsPerClass (305) */
+ /** @name FrameSystemLimitsWeightsPerClass (308) */
export interface FrameSystemLimitsWeightsPerClass extends Struct {
readonly baseExtrinsic: u64;
readonly maxExtrinsic: Option<u64>;
@@ -2647,25 +2659,25 @@
readonly reserved: Option<u64>;
}
- /** @name FrameSystemLimitsBlockLength (307) */
+ /** @name FrameSystemLimitsBlockLength (310) */
export interface FrameSystemLimitsBlockLength extends Struct {
readonly max: FrameSupportWeightsPerDispatchClassU32;
}
- /** @name FrameSupportWeightsPerDispatchClassU32 (308) */
+ /** @name FrameSupportWeightsPerDispatchClassU32 (311) */
export interface FrameSupportWeightsPerDispatchClassU32 extends Struct {
readonly normal: u32;
readonly operational: u32;
readonly mandatory: u32;
}
- /** @name FrameSupportWeightsRuntimeDbWeight (309) */
+ /** @name FrameSupportWeightsRuntimeDbWeight (312) */
export interface FrameSupportWeightsRuntimeDbWeight extends Struct {
readonly read: u64;
readonly write: u64;
}
- /** @name SpVersionRuntimeVersion (310) */
+ /** @name SpVersionRuntimeVersion (313) */
export interface SpVersionRuntimeVersion extends Struct {
readonly specName: Text;
readonly implName: Text;
@@ -2677,7 +2689,7 @@
readonly stateVersion: u8;
}
- /** @name FrameSystemError (314) */
+ /** @name FrameSystemError (317) */
export interface FrameSystemError extends Enum {
readonly isInvalidSpecName: boolean;
readonly isSpecVersionNeedsToIncrease: boolean;
@@ -2688,7 +2700,7 @@
readonly type: 'InvalidSpecName' | 'SpecVersionNeedsToIncrease' | 'FailedToExtractRuntimeVersion' | 'NonDefaultComposite' | 'NonZeroRefCount' | 'CallFiltered';
}
- /** @name OrmlVestingModuleError (316) */
+ /** @name OrmlVestingModuleError (319) */
export interface OrmlVestingModuleError extends Enum {
readonly isZeroVestingPeriod: boolean;
readonly isZeroVestingPeriodCount: boolean;
@@ -2699,21 +2711,21 @@
readonly type: 'ZeroVestingPeriod' | 'ZeroVestingPeriodCount' | 'InsufficientBalanceToLock' | 'TooManyVestingSchedules' | 'AmountLow' | 'MaxVestingSchedulesExceeded';
}
- /** @name CumulusPalletXcmpQueueInboundChannelDetails (318) */
+ /** @name CumulusPalletXcmpQueueInboundChannelDetails (321) */
export interface CumulusPalletXcmpQueueInboundChannelDetails extends Struct {
readonly sender: u32;
readonly state: CumulusPalletXcmpQueueInboundState;
readonly messageMetadata: Vec<ITuple<[u32, PolkadotParachainPrimitivesXcmpMessageFormat]>>;
}
- /** @name CumulusPalletXcmpQueueInboundState (319) */
+ /** @name CumulusPalletXcmpQueueInboundState (322) */
export interface CumulusPalletXcmpQueueInboundState extends Enum {
readonly isOk: boolean;
readonly isSuspended: boolean;
readonly type: 'Ok' | 'Suspended';
}
- /** @name PolkadotParachainPrimitivesXcmpMessageFormat (322) */
+ /** @name PolkadotParachainPrimitivesXcmpMessageFormat (325) */
export interface PolkadotParachainPrimitivesXcmpMessageFormat extends Enum {
readonly isConcatenatedVersionedXcm: boolean;
readonly isConcatenatedEncodedBlob: boolean;
@@ -2721,7 +2733,7 @@
readonly type: 'ConcatenatedVersionedXcm' | 'ConcatenatedEncodedBlob' | 'Signals';
}
- /** @name CumulusPalletXcmpQueueOutboundChannelDetails (325) */
+ /** @name CumulusPalletXcmpQueueOutboundChannelDetails (328) */
export interface CumulusPalletXcmpQueueOutboundChannelDetails extends Struct {
readonly recipient: u32;
readonly state: CumulusPalletXcmpQueueOutboundState;
@@ -2730,14 +2742,14 @@
readonly lastIndex: u16;
}
- /** @name CumulusPalletXcmpQueueOutboundState (326) */
+ /** @name CumulusPalletXcmpQueueOutboundState (329) */
export interface CumulusPalletXcmpQueueOutboundState extends Enum {
readonly isOk: boolean;
readonly isSuspended: boolean;
readonly type: 'Ok' | 'Suspended';
}
- /** @name CumulusPalletXcmpQueueQueueConfigData (328) */
+ /** @name CumulusPalletXcmpQueueQueueConfigData (331) */
export interface CumulusPalletXcmpQueueQueueConfigData extends Struct {
readonly suspendThreshold: u32;
readonly dropThreshold: u32;
@@ -2747,7 +2759,7 @@
readonly xcmpMaxIndividualWeight: u64;
}
- /** @name CumulusPalletXcmpQueueError (330) */
+ /** @name CumulusPalletXcmpQueueError (333) */
export interface CumulusPalletXcmpQueueError extends Enum {
readonly isFailedToSend: boolean;
readonly isBadXcmOrigin: boolean;
@@ -2757,7 +2769,7 @@
readonly type: 'FailedToSend' | 'BadXcmOrigin' | 'BadXcm' | 'BadOverweightIndex' | 'WeightOverLimit';
}
- /** @name PalletXcmError (331) */
+ /** @name PalletXcmError (334) */
export interface PalletXcmError extends Enum {
readonly isUnreachable: boolean;
readonly isSendFailure: boolean;
@@ -2775,29 +2787,29 @@
readonly type: 'Unreachable' | 'SendFailure' | 'Filtered' | 'UnweighableMessage' | 'DestinationNotInvertible' | 'Empty' | 'CannotReanchor' | 'TooManyAssets' | 'InvalidOrigin' | 'BadVersion' | 'BadLocation' | 'NoSubscription' | 'AlreadySubscribed';
}
- /** @name CumulusPalletXcmError (332) */
+ /** @name CumulusPalletXcmError (335) */
export type CumulusPalletXcmError = Null;
- /** @name CumulusPalletDmpQueueConfigData (333) */
+ /** @name CumulusPalletDmpQueueConfigData (336) */
export interface CumulusPalletDmpQueueConfigData extends Struct {
readonly maxIndividual: u64;
}
- /** @name CumulusPalletDmpQueuePageIndexData (334) */
+ /** @name CumulusPalletDmpQueuePageIndexData (337) */
export interface CumulusPalletDmpQueuePageIndexData extends Struct {
readonly beginUsed: u32;
readonly endUsed: u32;
readonly overweightCount: u64;
}
- /** @name CumulusPalletDmpQueueError (337) */
+ /** @name CumulusPalletDmpQueueError (340) */
export interface CumulusPalletDmpQueueError extends Enum {
readonly isUnknown: boolean;
readonly isOverLimit: boolean;
readonly type: 'Unknown' | 'OverLimit';
}
- /** @name PalletUniqueError (341) */
+ /** @name PalletUniqueError (344) */
export interface PalletUniqueError extends Enum {
readonly isCollectionDecimalPointLimitExceeded: boolean;
readonly isConfirmUnsetSponsorFail: boolean;
@@ -2805,7 +2817,7 @@
readonly type: 'CollectionDecimalPointLimitExceeded' | 'ConfirmUnsetSponsorFail' | 'EmptyArgument';
}
- /** @name PalletUniqueSchedulerScheduledV3 (344) */
+ /** @name PalletUniqueSchedulerScheduledV3 (347) */
export interface PalletUniqueSchedulerScheduledV3 extends Struct {
readonly maybeId: Option<U8aFixed>;
readonly priority: u8;
@@ -2814,7 +2826,7 @@
readonly origin: OpalRuntimeOriginCaller;
}
- /** @name OpalRuntimeOriginCaller (345) */
+ /** @name OpalRuntimeOriginCaller (348) */
export interface OpalRuntimeOriginCaller extends Enum {
readonly isVoid: boolean;
readonly isSystem: boolean;
@@ -2828,7 +2840,7 @@
readonly type: 'Void' | 'System' | 'PolkadotXcm' | 'CumulusXcm' | 'Ethereum';
}
- /** @name FrameSupportDispatchRawOrigin (346) */
+ /** @name FrameSupportDispatchRawOrigin (349) */
export interface FrameSupportDispatchRawOrigin extends Enum {
readonly isRoot: boolean;
readonly isSigned: boolean;
@@ -2837,7 +2849,7 @@
readonly type: 'Root' | 'Signed' | 'None';
}
- /** @name PalletXcmOrigin (347) */
+ /** @name PalletXcmOrigin (350) */
export interface PalletXcmOrigin extends Enum {
readonly isXcm: boolean;
readonly asXcm: XcmV1MultiLocation;
@@ -2846,7 +2858,7 @@
readonly type: 'Xcm' | 'Response';
}
- /** @name CumulusPalletXcmOrigin (348) */
+ /** @name CumulusPalletXcmOrigin (351) */
export interface CumulusPalletXcmOrigin extends Enum {
readonly isRelay: boolean;
readonly isSiblingParachain: boolean;
@@ -2854,17 +2866,17 @@
readonly type: 'Relay' | 'SiblingParachain';
}
- /** @name PalletEthereumRawOrigin (349) */
+ /** @name PalletEthereumRawOrigin (352) */
export interface PalletEthereumRawOrigin extends Enum {
readonly isEthereumTransaction: boolean;
readonly asEthereumTransaction: H160;
readonly type: 'EthereumTransaction';
}
- /** @name SpCoreVoid (350) */
+ /** @name SpCoreVoid (353) */
export type SpCoreVoid = Null;
- /** @name PalletUniqueSchedulerError (351) */
+ /** @name PalletUniqueSchedulerError (354) */
export interface PalletUniqueSchedulerError extends Enum {
readonly isFailedToSchedule: boolean;
readonly isNotFound: boolean;
@@ -2873,7 +2885,7 @@
readonly type: 'FailedToSchedule' | 'NotFound' | 'TargetBlockNumberInPast' | 'RescheduleNoChange';
}
- /** @name UpDataStructsCollection (352) */
+ /** @name UpDataStructsCollection (355) */
export interface UpDataStructsCollection extends Struct {
readonly owner: AccountId32;
readonly mode: UpDataStructsCollectionMode;
@@ -2886,7 +2898,7 @@
readonly externalCollection: bool;
}
- /** @name UpDataStructsSponsorshipState (353) */
+ /** @name UpDataStructsSponsorshipState (356) */
export interface UpDataStructsSponsorshipState extends Enum {
readonly isDisabled: boolean;
readonly isUnconfirmed: boolean;
@@ -2896,42 +2908,42 @@
readonly type: 'Disabled' | 'Unconfirmed' | 'Confirmed';
}
- /** @name UpDataStructsProperties (354) */
+ /** @name UpDataStructsProperties (357) */
export interface UpDataStructsProperties extends Struct {
readonly map: UpDataStructsPropertiesMapBoundedVec;
readonly consumedSpace: u32;
readonly spaceLimit: u32;
}
- /** @name UpDataStructsPropertiesMapBoundedVec (355) */
+ /** @name UpDataStructsPropertiesMapBoundedVec (358) */
export interface UpDataStructsPropertiesMapBoundedVec extends BTreeMap<Bytes, Bytes> {}
- /** @name UpDataStructsPropertiesMapPropertyPermission (360) */
+ /** @name UpDataStructsPropertiesMapPropertyPermission (363) */
export interface UpDataStructsPropertiesMapPropertyPermission extends BTreeMap<Bytes, UpDataStructsPropertyPermission> {}
- /** @name UpDataStructsCollectionStats (367) */
+ /** @name UpDataStructsCollectionStats (370) */
export interface UpDataStructsCollectionStats extends Struct {
readonly created: u32;
readonly destroyed: u32;
readonly alive: u32;
}
- /** @name UpDataStructsTokenChild (368) */
+ /** @name UpDataStructsTokenChild (371) */
export interface UpDataStructsTokenChild extends Struct {
readonly token: u32;
readonly collection: u32;
}
- /** @name PhantomTypeUpDataStructs (369) */
+ /** @name PhantomTypeUpDataStructs (372) */
export interface PhantomTypeUpDataStructs extends Vec<ITuple<[UpDataStructsTokenData, UpDataStructsRpcCollection, RmrkTraitsCollectionCollectionInfo, RmrkTraitsNftNftInfo, RmrkTraitsResourceResourceInfo, RmrkTraitsPropertyPropertyInfo, RmrkTraitsBaseBaseInfo, RmrkTraitsPartPartType, RmrkTraitsTheme, RmrkTraitsNftNftChild]>> {}
- /** @name UpDataStructsTokenData (371) */
+ /** @name UpDataStructsTokenData (374) */
export interface UpDataStructsTokenData extends Struct {
readonly properties: Vec<UpDataStructsProperty>;
readonly owner: Option<PalletEvmAccountBasicCrossAccountIdRepr>;
}
- /** @name UpDataStructsRpcCollection (373) */
+ /** @name UpDataStructsRpcCollection (376) */
export interface UpDataStructsRpcCollection extends Struct {
readonly owner: AccountId32;
readonly mode: UpDataStructsCollectionMode;
@@ -2946,7 +2958,7 @@
readonly readOnly: bool;
}
- /** @name RmrkTraitsCollectionCollectionInfo (374) */
+ /** @name RmrkTraitsCollectionCollectionInfo (377) */
export interface RmrkTraitsCollectionCollectionInfo extends Struct {
readonly issuer: AccountId32;
readonly metadata: Bytes;
@@ -2955,7 +2967,7 @@
readonly nftsCount: u32;
}
- /** @name RmrkTraitsNftNftInfo (375) */
+ /** @name RmrkTraitsNftNftInfo (378) */
export interface RmrkTraitsNftNftInfo extends Struct {
readonly owner: RmrkTraitsNftAccountIdOrCollectionNftTuple;
readonly royalty: Option<RmrkTraitsNftRoyaltyInfo>;
@@ -2964,13 +2976,13 @@
readonly pending: bool;
}
- /** @name RmrkTraitsNftRoyaltyInfo (377) */
+ /** @name RmrkTraitsNftRoyaltyInfo (380) */
export interface RmrkTraitsNftRoyaltyInfo extends Struct {
readonly recipient: AccountId32;
readonly amount: Permill;
}
- /** @name RmrkTraitsResourceResourceInfo (378) */
+ /** @name RmrkTraitsResourceResourceInfo (381) */
export interface RmrkTraitsResourceResourceInfo extends Struct {
readonly id: u32;
readonly resource: RmrkTraitsResourceResourceTypes;
@@ -2978,37 +2990,26 @@
readonly pendingRemoval: bool;
}
- /** @name RmrkTraitsResourceResourceTypes (379) */
- export interface RmrkTraitsResourceResourceTypes extends Enum {
- readonly isBasic: boolean;
- readonly asBasic: RmrkTraitsResourceBasicResource;
- readonly isComposable: boolean;
- readonly asComposable: RmrkTraitsResourceComposableResource;
- readonly isSlot: boolean;
- readonly asSlot: RmrkTraitsResourceSlotResource;
- readonly type: 'Basic' | 'Composable' | 'Slot';
- }
-
- /** @name RmrkTraitsPropertyPropertyInfo (380) */
+ /** @name RmrkTraitsPropertyPropertyInfo (382) */
export interface RmrkTraitsPropertyPropertyInfo extends Struct {
readonly key: Bytes;
readonly value: Bytes;
}
- /** @name RmrkTraitsBaseBaseInfo (381) */
+ /** @name RmrkTraitsBaseBaseInfo (383) */
export interface RmrkTraitsBaseBaseInfo extends Struct {
readonly issuer: AccountId32;
readonly baseType: Bytes;
readonly symbol: Bytes;
}
- /** @name RmrkTraitsNftNftChild (382) */
+ /** @name RmrkTraitsNftNftChild (384) */
export interface RmrkTraitsNftNftChild extends Struct {
readonly collectionId: u32;
readonly nftId: u32;
}
- /** @name PalletCommonError (384) */
+ /** @name PalletCommonError (386) */
export interface PalletCommonError extends Enum {
readonly isCollectionNotFound: boolean;
readonly isMustBeTokenOwner: boolean;
@@ -3047,7 +3048,7 @@
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';
}
- /** @name PalletFungibleError (386) */
+ /** @name PalletFungibleError (388) */
export interface PalletFungibleError extends Enum {
readonly isNotFungibleDataUsedToMintFungibleCollectionToken: boolean;
readonly isFungibleItemsHaveNoId: boolean;
@@ -3057,12 +3058,12 @@
readonly type: 'NotFungibleDataUsedToMintFungibleCollectionToken' | 'FungibleItemsHaveNoId' | 'FungibleItemsDontHaveData' | 'FungibleDisallowsNesting' | 'SettingPropertiesNotAllowed';
}
- /** @name PalletRefungibleItemData (387) */
+ /** @name PalletRefungibleItemData (389) */
export interface PalletRefungibleItemData extends Struct {
readonly constData: Bytes;
}
- /** @name PalletRefungibleError (391) */
+ /** @name PalletRefungibleError (393) */
export interface PalletRefungibleError extends Enum {
readonly isNotRefungibleDataUsedToMintFungibleCollectionToken: boolean;
readonly isWrongRefungiblePieces: boolean;
@@ -3071,12 +3072,12 @@
readonly type: 'NotRefungibleDataUsedToMintFungibleCollectionToken' | 'WrongRefungiblePieces' | 'RefungibleDisallowsNesting' | 'SettingPropertiesNotAllowed';
}
- /** @name PalletNonfungibleItemData (392) */
+ /** @name PalletNonfungibleItemData (394) */
export interface PalletNonfungibleItemData extends Struct {
readonly owner: PalletEvmAccountBasicCrossAccountIdRepr;
}
- /** @name PalletNonfungibleError (394) */
+ /** @name PalletNonfungibleError (396) */
export interface PalletNonfungibleError extends Enum {
readonly isNotNonfungibleDataUsedToMintFungibleCollectionToken: boolean;
readonly isNonfungibleItemsHaveNoAmount: boolean;
@@ -3084,7 +3085,7 @@
readonly type: 'NotNonfungibleDataUsedToMintFungibleCollectionToken' | 'NonfungibleItemsHaveNoAmount' | 'CantBurnNftWithChildren';
}
- /** @name PalletStructureError (395) */
+ /** @name PalletStructureError (397) */
export interface PalletStructureError extends Enum {
readonly isOuroborosDetected: boolean;
readonly isDepthLimit: boolean;
@@ -3093,12 +3094,13 @@
readonly type: 'OuroborosDetected' | 'DepthLimit' | 'BreadthLimit' | 'TokenNotFound';
}
- /** @name PalletRmrkCoreError (396) */
+ /** @name PalletRmrkCoreError (398) */
export interface PalletRmrkCoreError extends Enum {
readonly isCorruptedCollectionType: boolean;
readonly isNftTypeEncodeError: boolean;
readonly isRmrkPropertyKeyIsTooLong: boolean;
readonly isRmrkPropertyValueIsTooLong: boolean;
+ readonly isUnableToDecodeRmrkData: boolean;
readonly isCollectionNotEmpty: boolean;
readonly isNoAvailableCollectionId: boolean;
readonly isNoAvailableNftId: boolean;
@@ -3111,10 +3113,10 @@
readonly isCannotAcceptNonOwnedNft: boolean;
readonly isCannotRejectNonOwnedNft: boolean;
readonly isResourceNotPending: boolean;
- readonly type: 'CorruptedCollectionType' | 'NftTypeEncodeError' | 'RmrkPropertyKeyIsTooLong' | 'RmrkPropertyValueIsTooLong' | 'CollectionNotEmpty' | 'NoAvailableCollectionId' | 'NoAvailableNftId' | 'CollectionUnknown' | 'NoPermission' | 'NonTransferable' | 'CollectionFullOrLocked' | 'ResourceDoesntExist' | 'CannotSendToDescendentOrSelf' | 'CannotAcceptNonOwnedNft' | 'CannotRejectNonOwnedNft' | 'ResourceNotPending';
+ readonly type: 'CorruptedCollectionType' | 'NftTypeEncodeError' | 'RmrkPropertyKeyIsTooLong' | 'RmrkPropertyValueIsTooLong' | 'UnableToDecodeRmrkData' | 'CollectionNotEmpty' | 'NoAvailableCollectionId' | 'NoAvailableNftId' | 'CollectionUnknown' | 'NoPermission' | 'NonTransferable' | 'CollectionFullOrLocked' | 'ResourceDoesntExist' | 'CannotSendToDescendentOrSelf' | 'CannotAcceptNonOwnedNft' | 'CannotRejectNonOwnedNft' | 'ResourceNotPending';
}
- /** @name PalletRmrkEquipError (398) */
+ /** @name PalletRmrkEquipError (400) */
export interface PalletRmrkEquipError extends Enum {
readonly isPermissionError: boolean;
readonly isNoAvailableBaseId: boolean;
@@ -3124,7 +3126,7 @@
readonly type: 'PermissionError' | 'NoAvailableBaseId' | 'NoAvailablePartId' | 'BaseDoesntExist' | 'NeedsDefaultThemeFirst';
}
- /** @name PalletEvmError (401) */
+ /** @name PalletEvmError (403) */
export interface PalletEvmError extends Enum {
readonly isBalanceLow: boolean;
readonly isFeeOverflow: boolean;
@@ -3135,7 +3137,7 @@
readonly type: 'BalanceLow' | 'FeeOverflow' | 'PaymentOverflow' | 'WithdrawFailed' | 'GasPriceTooLow' | 'InvalidNonce';
}
- /** @name FpRpcTransactionStatus (404) */
+ /** @name FpRpcTransactionStatus (406) */
export interface FpRpcTransactionStatus extends Struct {
readonly transactionHash: H256;
readonly transactionIndex: u32;
@@ -3146,10 +3148,10 @@
readonly logsBloom: EthbloomBloom;
}
- /** @name EthbloomBloom (406) */
+ /** @name EthbloomBloom (408) */
export interface EthbloomBloom extends U8aFixed {}
- /** @name EthereumReceiptReceiptV3 (408) */
+ /** @name EthereumReceiptReceiptV3 (410) */
export interface EthereumReceiptReceiptV3 extends Enum {
readonly isLegacy: boolean;
readonly asLegacy: EthereumReceiptEip658ReceiptData;
@@ -3160,7 +3162,7 @@
readonly type: 'Legacy' | 'Eip2930' | 'Eip1559';
}
- /** @name EthereumReceiptEip658ReceiptData (409) */
+ /** @name EthereumReceiptEip658ReceiptData (411) */
export interface EthereumReceiptEip658ReceiptData extends Struct {
readonly statusCode: u8;
readonly usedGas: U256;
@@ -3168,14 +3170,14 @@
readonly logs: Vec<EthereumLog>;
}
- /** @name EthereumBlock (410) */
+ /** @name EthereumBlock (412) */
export interface EthereumBlock extends Struct {
readonly header: EthereumHeader;
readonly transactions: Vec<EthereumTransactionTransactionV2>;
readonly ommers: Vec<EthereumHeader>;
}
- /** @name EthereumHeader (411) */
+ /** @name EthereumHeader (413) */
export interface EthereumHeader extends Struct {
readonly parentHash: H256;
readonly ommersHash: H256;
@@ -3194,24 +3196,24 @@
readonly nonce: EthereumTypesHashH64;
}
- /** @name EthereumTypesHashH64 (412) */
+ /** @name EthereumTypesHashH64 (414) */
export interface EthereumTypesHashH64 extends U8aFixed {}
- /** @name PalletEthereumError (417) */
+ /** @name PalletEthereumError (419) */
export interface PalletEthereumError extends Enum {
readonly isInvalidSignature: boolean;
readonly isPreLogExists: boolean;
readonly type: 'InvalidSignature' | 'PreLogExists';
}
- /** @name PalletEvmCoderSubstrateError (418) */
+ /** @name PalletEvmCoderSubstrateError (420) */
export interface PalletEvmCoderSubstrateError extends Enum {
readonly isOutOfGas: boolean;
readonly isOutOfFund: boolean;
readonly type: 'OutOfGas' | 'OutOfFund';
}
- /** @name PalletEvmContractHelpersSponsoringModeT (419) */
+ /** @name PalletEvmContractHelpersSponsoringModeT (421) */
export interface PalletEvmContractHelpersSponsoringModeT extends Enum {
readonly isDisabled: boolean;
readonly isAllowlisted: boolean;
@@ -3219,20 +3221,20 @@
readonly type: 'Disabled' | 'Allowlisted' | 'Generous';
}
- /** @name PalletEvmContractHelpersError (421) */
+ /** @name PalletEvmContractHelpersError (423) */
export interface PalletEvmContractHelpersError extends Enum {
readonly isNoPermission: boolean;
readonly type: 'NoPermission';
}
- /** @name PalletEvmMigrationError (422) */
+ /** @name PalletEvmMigrationError (424) */
export interface PalletEvmMigrationError extends Enum {
readonly isAccountNotEmpty: boolean;
readonly isAccountIsNotMigrating: boolean;
readonly type: 'AccountNotEmpty' | 'AccountIsNotMigrating';
}
- /** @name SpRuntimeMultiSignature (424) */
+ /** @name SpRuntimeMultiSignature (426) */
export interface SpRuntimeMultiSignature extends Enum {
readonly isEd25519: boolean;
readonly asEd25519: SpCoreEd25519Signature;
@@ -3243,34 +3245,34 @@
readonly type: 'Ed25519' | 'Sr25519' | 'Ecdsa';
}
- /** @name SpCoreEd25519Signature (425) */
+ /** @name SpCoreEd25519Signature (427) */
export interface SpCoreEd25519Signature extends U8aFixed {}
- /** @name SpCoreSr25519Signature (427) */
+ /** @name SpCoreSr25519Signature (429) */
export interface SpCoreSr25519Signature extends U8aFixed {}
- /** @name SpCoreEcdsaSignature (428) */
+ /** @name SpCoreEcdsaSignature (430) */
export interface SpCoreEcdsaSignature extends U8aFixed {}
- /** @name FrameSystemExtensionsCheckSpecVersion (431) */
+ /** @name FrameSystemExtensionsCheckSpecVersion (433) */
export type FrameSystemExtensionsCheckSpecVersion = Null;
- /** @name FrameSystemExtensionsCheckGenesis (432) */
+ /** @name FrameSystemExtensionsCheckGenesis (434) */
export type FrameSystemExtensionsCheckGenesis = Null;
- /** @name FrameSystemExtensionsCheckNonce (435) */
+ /** @name FrameSystemExtensionsCheckNonce (437) */
export interface FrameSystemExtensionsCheckNonce extends Compact<u32> {}
- /** @name FrameSystemExtensionsCheckWeight (436) */
+ /** @name FrameSystemExtensionsCheckWeight (438) */
export type FrameSystemExtensionsCheckWeight = Null;
- /** @name PalletTemplateTransactionPaymentChargeTransactionPayment (437) */
+ /** @name PalletTemplateTransactionPaymentChargeTransactionPayment (439) */
export interface PalletTemplateTransactionPaymentChargeTransactionPayment extends Compact<u128> {}
- /** @name OpalRuntimeRuntime (438) */
+ /** @name OpalRuntimeRuntime (440) */
export type OpalRuntimeRuntime = Null;
- /** @name PalletEthereumFakeTransactionFinalizer (439) */
+ /** @name PalletEthereumFakeTransactionFinalizer (441) */
export type PalletEthereumFakeTransactionFinalizer = Null;
} // declare module
tests/src/limits.test.tsdiffbeforeafterboth--- a/tests/src/limits.test.ts
+++ b/tests/src/limits.test.ts
@@ -406,6 +406,7 @@
it('Effective collection limits', async () => {
await usingApi(async (api) => {
const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
+ await setCollectionLimitsExpectSuccess(alice, collectionId, {ownerCanTransfer: true});
{ // Check that limits is undefined
const collection = await api.rpc.unique.collectionById(collectionId);
@@ -419,7 +420,7 @@
expect(limits.tokenLimit.toHuman()).to.be.null;
expect(limits.sponsorTransferTimeout.toHuman()).to.be.null;
expect(limits.sponsorApproveTimeout.toHuman()).to.be.null;
- expect(limits.ownerCanTransfer.toHuman()).to.be.null;
+ expect(limits.ownerCanTransfer.toHuman()).to.be.true;
expect(limits.ownerCanDestroy.toHuman()).to.be.null;
expect(limits.transfersEnabled.toHuman()).to.be.null;
}
tests/src/nesting/graphs.test.tsdiffbeforeafterboth--- a/tests/src/nesting/graphs.test.ts
+++ b/tests/src/nesting/graphs.test.ts
@@ -3,7 +3,7 @@
import {expect} from 'chai';
import {tokenIdToCross} from '../eth/util/helpers';
import usingApi, {executeTransaction} from '../substrate/substrate-api';
-import {getCreateCollectionResult, transferExpectSuccess} from '../util/helpers';
+import {getCreateCollectionResult, transferExpectSuccess, setCollectionLimitsExpectSuccess} from '../util/helpers';
/**
* ```dot
@@ -36,6 +36,7 @@
await usingApi(async (api, privateKeyWrapper) => {
const alice = privateKeyWrapper('//Alice');
const collection = await buildComplexObjectGraph(api, alice);
+ await setCollectionLimitsExpectSuccess(alice, collection, {ownerCanTransfer: true});
// to self
await expect(
tests/src/nesting/nest.test.tsdiffbeforeafterboth--- a/tests/src/nesting/nest.test.ts
+++ b/tests/src/nesting/nest.test.ts
@@ -2,6 +2,7 @@
import {tokenIdToAddress} from '../eth/util/helpers';
import usingApi, {executeTransaction} from '../substrate/substrate-api';
import {
+ addCollectionAdminExpectSuccess,
addToAllowListExpectSuccess,
createCollectionExpectSuccess,
createItemExpectSuccess,
@@ -15,15 +16,17 @@
transferExpectFailure,
transferExpectSuccess,
transferFromExpectSuccess,
+ setCollectionLimitsExpectSuccess,
} from '../util/helpers';
import {IKeyringPair} from '@polkadot/types/types';
let alice: IKeyringPair;
let bob: IKeyringPair;
+let charlie: IKeyringPair;
-describe('Integration Test: Nesting', () => {
+describe('Integration Test: Composite nesting tests', () => {
before(async () => {
- await usingApi(async (api, privateKeyWrapper) => {
+ await usingApi(async (_, privateKeyWrapper) => {
alice = privateKeyWrapper('//Alice');
bob = privateKeyWrapper('//Bob');
});
@@ -92,6 +95,7 @@
it('Checks token children', async () => {
await usingApi(async api => {
const collectionA = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
+ await setCollectionLimitsExpectSuccess(alice, collectionA, {ownerCanTransfer: true});
await setCollectionPermissionsExpectSuccess(alice, collectionA, {nesting: {tokenOwner: true}});
const collectionB = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
@@ -145,6 +149,78 @@
], 'Children contents check at deeper nesting');
});
});
+});
+
+describe('Integration Test: Various token type nesting', async () => {
+ before(async () => {
+ await usingApi(async (_, privateKeyWrapper) => {
+ alice = privateKeyWrapper('//Alice');
+ bob = privateKeyWrapper('//Bob');
+ charlie = privateKeyWrapper('//Charlie');
+ });
+ });
+
+ it('Admin (NFT): allows an Admin to nest a token', async () => {
+ await usingApi(async api => {
+ const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
+ await setCollectionPermissionsExpectSuccess(alice, collection, {nesting: {collectionAdmin: true}});
+ await addCollectionAdminExpectSuccess(alice, collection, bob.address);
+ const targetToken = await createItemExpectSuccess(alice, collection, 'NFT', charlie.address);
+
+ // Create a nested token
+ const nestedToken = await createItemExpectSuccess(bob, collection, 'NFT', {Ethereum: tokenIdToAddress(collection, targetToken)});
+ expect(await getTopmostTokenOwner(api, collection, nestedToken)).to.be.deep.equal({Substrate: charlie.address});
+ expect(await getTokenOwner(api, collection, nestedToken)).to.be.deep.equal({Ethereum: tokenIdToAddress(collection, targetToken).toLowerCase()});
+
+ // Create a token to be nested and nest
+ const newToken = await createItemExpectSuccess(bob, collection, 'NFT');
+ await transferExpectSuccess(collection, newToken, bob, {Ethereum: tokenIdToAddress(collection, targetToken)});
+ expect(await getTopmostTokenOwner(api, collection, newToken)).to.be.deep.equal({Substrate: charlie.address});
+ expect(await getTokenOwner(api, collection, newToken)).to.be.deep.equal({Ethereum: tokenIdToAddress(collection, targetToken).toLowerCase()});
+ });
+ });
+
+ it('Admin (NFT): Admin and Token Owner can operate together', async () => {
+ await usingApi(async api => {
+ const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
+ await setCollectionPermissionsExpectSuccess(alice, collection, {nesting: {tokenOwner: true, collectionAdmin: true}});
+ await addCollectionAdminExpectSuccess(alice, collection, bob.address);
+ const targetToken = await createItemExpectSuccess(alice, collection, 'NFT', charlie.address);
+
+ // Create a nested token by an administrator
+ const nestedToken = await createItemExpectSuccess(bob, collection, 'NFT', {Ethereum: tokenIdToAddress(collection, targetToken)});
+ expect(await getTopmostTokenOwner(api, collection, nestedToken)).to.be.deep.equal({Substrate: charlie.address});
+ expect(await getTokenOwner(api, collection, nestedToken)).to.be.deep.equal({Ethereum: tokenIdToAddress(collection, targetToken).toLowerCase()});
+
+ // Create a token and allow the owner to nest too
+ const newToken = await createItemExpectSuccess(alice, collection, 'NFT', charlie.address);
+ await transferExpectSuccess(collection, newToken, charlie, {Ethereum: tokenIdToAddress(collection, nestedToken)});
+ expect(await getTopmostTokenOwner(api, collection, newToken)).to.be.deep.equal({Substrate: charlie.address});
+ expect(await getTokenOwner(api, collection, newToken)).to.be.deep.equal({Ethereum: tokenIdToAddress(collection, nestedToken).toLowerCase()});
+ });
+ });
+
+ it('Admin (NFT): allows an Admin to nest a token (Restricted nesting)', async () => {
+ await usingApi(async api => {
+ const collectionA = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
+ await addCollectionAdminExpectSuccess(alice, collectionA, bob.address);
+ const collectionB = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
+ await addCollectionAdminExpectSuccess(alice, collectionB, bob.address);
+ await setCollectionPermissionsExpectSuccess(alice, collectionA, {nesting: {collectionAdmin: true, restricted:[collectionA, collectionB]}});
+ const targetToken = await createItemExpectSuccess(alice, collectionA, 'NFT', charlie.address);
+
+ // Create a nested token
+ const nestedToken = await createItemExpectSuccess(bob, collectionB, 'NFT', {Ethereum: tokenIdToAddress(collectionA, targetToken)});
+ expect(await getTopmostTokenOwner(api, collectionB, nestedToken)).to.be.deep.equal({Substrate: charlie.address});
+ expect(await getTokenOwner(api, collectionB, nestedToken)).to.be.deep.equal({Ethereum: tokenIdToAddress(collectionA, targetToken).toLowerCase()});
+
+ // Create a token to be nested and nest
+ const newToken = await createItemExpectSuccess(bob, collectionB, 'NFT');
+ await transferExpectSuccess(collectionB, newToken, bob, {Ethereum: tokenIdToAddress(collectionA, targetToken)});
+ expect(await getTopmostTokenOwner(api, collectionB, newToken)).to.be.deep.equal({Substrate: charlie.address});
+ expect(await getTokenOwner(api, collectionB, newToken)).to.be.deep.equal({Ethereum: tokenIdToAddress(collectionA, targetToken).toLowerCase()});
+ });
+ });
// ---------- Non-Fungible ----------
@@ -248,7 +324,7 @@
await expect(executeTransaction(api, alice, api.tx.unique.createItem(
collectionRFT,
targetAddress,
- {ReFungible: {const_data: [], pieces: 100}},
+ {ReFungible: {pieces: 100}},
))).to.not.be.rejected;
// Nest a new token
@@ -271,7 +347,7 @@
await expect(executeTransaction(api, alice, api.tx.unique.createItem(
collectionRFT,
targetAddress,
- {ReFungible: {const_data: [], pieces: 100}},
+ {ReFungible: {pieces: 100}},
))).to.not.be.rejected;
// Nest a new token
@@ -283,7 +359,7 @@
describe('Negative Test: Nesting', async() => {
before(async () => {
- await usingApi(async (api, privateKeyWrapper) => {
+ await usingApi(async (_, privateKeyWrapper) => {
alice = privateKeyWrapper('//Alice');
bob = privateKeyWrapper('//Bob');
});
@@ -314,13 +390,121 @@
await expect(executeTransaction(api, alice, api.tx.unique.createItem(
collection,
{Ethereum: tokenIdToAddress(collection, prevToken)},
- {nft: {const_data: [], variable_data: []}} as any,
+ {nft: {}} as any,
)), 'while creating nested token').to.be.rejectedWith(/^structure\.DepthLimit$/);
expect(await getTopmostTokenOwner(api, collection, prevToken)).to.be.deep.equal({Substrate: alice.address});
});
});
+ // ---------- Admin ------------
+
+ it('Admin (NFT): disallows an Admin to operate nesting when only TokenOwner is allowed', async () => {
+ await usingApi(async api => {
+ const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
+ await setCollectionPermissionsExpectSuccess(alice, collection, {nesting: {tokenOwner: true}});
+ await addCollectionAdminExpectSuccess(alice, collection, bob.address);
+ const targetToken = await createItemExpectSuccess(alice, collection, 'NFT');
+
+ // Try to create a nested token as collection admin when it's disallowed
+ await expect(executeTransaction(api, bob, api.tx.unique.createItem(
+ collection,
+ {Ethereum: tokenIdToAddress(collection, targetToken)},
+ {nft: {}} as any,
+ )), 'while creating nested token').to.be.rejectedWith(/common\.UserIsNotAllowedToNest/);
+
+ // Try to create and nest a token in the wrong collection
+ const newToken = await createItemExpectSuccess(bob, collection, 'NFT');
+ await expect(executeTransaction(
+ api,
+ bob,
+ api.tx.unique.transfer({Ethereum: tokenIdToAddress(collection, targetToken)}, collection, newToken, 1),
+ ), 'while nesting new token').to.be.rejectedWith(/common\.UserIsNotAllowedToNest/);
+ expect(await getTokenOwner(api, collection, newToken)).to.be.deep.equal({Substrate: bob.address});
+ });
+ });
+
+ it('Admin (NFT): disallows a Token Owner to operate nesting when only Admin is allowed', async () => {
+ await usingApi(async api => {
+ const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
+ await setCollectionPermissionsExpectSuccess(alice, collection, {nesting: {collectionAdmin: true}});
+ await addToAllowListExpectSuccess(alice, collection, bob.address);
+ await enableAllowListExpectSuccess(alice, collection);
+ await enablePublicMintingExpectSuccess(alice, collection);
+ const targetToken = await createItemExpectSuccess(alice, collection, 'NFT');
+
+ // Try to create a nested token as collection admin when it's disallowed
+ await expect(executeTransaction(api, bob, api.tx.unique.createItem(
+ collection,
+ {Ethereum: tokenIdToAddress(collection, targetToken)},
+ {nft: {}} as any,
+ )), 'while creating nested token').to.be.rejectedWith(/common\.AddressNotInAllowlist/);
+
+ // Try to create and nest a token in the wrong collection
+ const newToken = await createItemExpectSuccess(bob, collection, 'NFT');
+ await expect(executeTransaction(
+ api,
+ bob,
+ api.tx.unique.transfer({Ethereum: tokenIdToAddress(collection, targetToken)}, collection, newToken, 1),
+ ), 'while nesting new token').to.be.rejectedWith(/common\.AddressNotInAllowlist/);
+ expect(await getTokenOwner(api, collection, newToken)).to.be.deep.equal({Substrate: bob.address});
+ });
+ });
+
+ it('Admin (NFT): disallows an Admin to nest and unnest someone else\'s token', async () => {
+ await usingApi(async api => {
+ const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
+ await setCollectionPermissionsExpectSuccess(alice, collection, {nesting: {collectionAdmin: true}});
+
+ await addToAllowListExpectSuccess(alice, collection, bob.address);
+ await enableAllowListExpectSuccess(alice, collection);
+ await enablePublicMintingExpectSuccess(alice, collection);
+
+ // Create a token to attempt to be nested into
+ const targetToken = await createItemExpectSuccess(bob, collection, 'NFT');
+ const targetAddress = {Ethereum: tokenIdToAddress(collection, targetToken).toLowerCase()};
+
+ // Try to nest somebody else's token
+ const newToken = await createItemExpectSuccess(bob, collection, 'NFT');
+ await expect(executeTransaction(
+ api,
+ alice,
+ api.tx.unique.transfer(targetAddress, collection, newToken, 1),
+ ), 'while nesting another\'s token token').to.be.rejectedWith(/common\.AddressNotInAllowlist/);
+ expect(await getTokenOwner(api, collection, newToken)).to.be.deep.equal({Substrate: bob.address});
+
+ // Nest a token as admin and try to unnest it, now belonging to someone else
+ const nestedToken = await createItemExpectSuccess(alice, collection, 'NFT', targetAddress);
+ await expect(executeTransaction(
+ api,
+ alice,
+ api.tx.unique.transferFrom(targetAddress, normalizeAccountId(alice), collection, nestedToken, 1),
+ ), 'while unnesting another\'s token').to.be.rejectedWith(/common\.AddressNotInAllowlist/);
+ expect(await getTokenOwner(api, collection, nestedToken)).to.be.deep.equal(targetAddress);
+ expect(await getTopmostTokenOwner(api, collection, nestedToken)).to.be.deep.equal({Substrate: bob.address});
+ });
+ });
+
+ it('Admin (NFT): disallows an Admin to nest a token from an unlisted collection (Restricted nesting)', async () => {
+ await usingApi(async api => {
+ const collectionA = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
+ const collectionB = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
+ await setCollectionPermissionsExpectSuccess(alice, collectionA, {nesting: {collectionAdmin: true, restricted:[collectionA]}});
+
+ // Create a token to attempt to be nested into
+ const targetToken = await createItemExpectSuccess(alice, collectionA, 'NFT');
+
+ // Try to create and nest a token in the wrong collection
+ const newToken = await createItemExpectSuccess(alice, collectionB, 'NFT');
+ await expect(executeTransaction(
+ api,
+ alice,
+ api.tx.unique.transfer({Ethereum: tokenIdToAddress(collectionA, targetToken)}, collectionB, newToken, 1),
+ ), 'while nesting a foreign token').to.be.rejectedWith(/common\.SourceCollectionIsNotAllowedToNest/);
+ expect(await getTokenOwner(api, collectionB, newToken)).to.be.deep.equal({Substrate: alice.address});
+ });
+ });
+
// ---------- Non-Fungible ----------
it('NFT: disallows to nest token if nesting is disabled', async () => {
@@ -333,7 +517,7 @@
await expect(executeTransaction(api, alice, api.tx.unique.createItem(
collection,
{Ethereum: tokenIdToAddress(collection, targetToken)},
- {nft: {const_data: [], variable_data: []}} as any,
+ {nft: {}} as any,
)), 'while creating nested token').to.be.rejectedWith(/^common\.UserIsNotAllowedToNest$/);
// Create a token to be nested
@@ -361,7 +545,7 @@
await expect(executeTransaction(api, alice, api.tx.unique.createItem(
collection,
{Ethereum: tokenIdToAddress(collection, targetToken)},
- {nft: {const_data: [], variable_data: []}} as any,
+ {nft: {}} as any,
)), 'while creating nested token').to.be.rejectedWith(/common\.UserIsNotAllowedToNest/);
// Try to create and nest a token in the wrong collection
@@ -387,7 +571,7 @@
await expect(executeTransaction(api, alice, api.tx.unique.createItem(
collection,
{Ethereum: tokenIdToAddress(collection, targetToken)},
- {nft: {const_data: [], variable_data: []}} as any,
+ {nft: {}} as any,
)), 'while creating nested token').to.be.rejectedWith(/common\.UserIsNotAllowedToNest/);
// Try to create and nest a token in the wrong collection
@@ -409,7 +593,7 @@
await expect(executeTransaction(api, alice, api.tx.unique.createItem(
collection,
{Ethereum: tokenIdToAddress(collection, targetToken)},
- {nft: {const_data: [], variable_data: []}} as any,
+ {nft: {}} as any,
)), 'while creating nested token').to.be.rejectedWith(/common\.SourceCollectionIsNotAllowedToNest/);
// Try to create and nest a token in the wrong collection
@@ -543,7 +727,7 @@
await expect(executeTransaction(api, alice, api.tx.unique.createItem(
collectionRFT,
targetAddress,
- {ReFungible: {const_data: [], pieces: 100}},
+ {ReFungible: {pieces: 100}},
)), 'while creating a nested token').to.be.rejectedWith(/^common\.UserIsNotAllowedToNest$/);
// Create a token to be nested
@@ -579,7 +763,7 @@
await expect(executeTransaction(api, alice, api.tx.unique.createItem(
collectionRFT,
targetAddress,
- {ReFungible: {const_data: [], pieces: 100}},
+ {ReFungible: {pieces: 100}},
)), 'while creating a nested token').to.be.rejectedWith(/common\.UserIsNotAllowedToNest/);
// Try to create and nest a token in the wrong collection
@@ -606,7 +790,7 @@
await expect(executeTransaction(api, alice, api.tx.unique.createItem(
collectionRFT,
targetAddress,
- {ReFungible: {const_data: [], pieces: 100}},
+ {ReFungible: {pieces: 100}},
)), 'while creating a nested token').to.be.rejectedWith(/common\.UserIsNotAllowedToNest/);
// Try to create and nest a token in the wrong collection
@@ -630,7 +814,7 @@
await expect(executeTransaction(api, alice, api.tx.unique.createItem(
collectionRFT,
targetAddress,
- {ReFungible: {const_data: [], pieces: 100}},
+ {ReFungible: {pieces: 100}},
)), 'while creating a nested token').to.be.rejectedWith(/common\.SourceCollectionIsNotAllowedToNest/);
// Try to create and nest a token in the wrong collection
tests/src/transferFrom.test.tsdiffbeforeafterboth--- a/tests/src/transferFrom.test.ts
+++ b/tests/src/transferFrom.test.ts
@@ -99,6 +99,7 @@
it('can be called by collection owner on non-owned item when OwnerCanTransfer == true', async () => {
const collectionId = await createCollectionExpectSuccess();
+ await setCollectionLimitsExpectSuccess(alice, collectionId, {ownerCanTransfer: true});
const itemId = await createItemExpectSuccess(alice, collectionId, 'NFT', bob.address);
await transferFromExpectSuccess(collectionId, itemId, alice, bob, charlie);
@@ -257,6 +258,7 @@
await usingApi(async () => {
// nft
const nftCollectionId = await createCollectionExpectSuccess();
+ await setCollectionLimitsExpectSuccess(alice, nftCollectionId, {ownerCanTransfer: true});
const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');
await burnItemExpectSuccess(alice, nftCollectionId, newNftTokenId, 1);
await approveExpectFail(nftCollectionId, newNftTokenId, alice, bob);
@@ -266,6 +268,7 @@
it('transferFrom burnt token before approve Fungible', async () => {
await usingApi(async () => {
const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
+ await setCollectionLimitsExpectSuccess(alice, fungibleCollectionId, {ownerCanTransfer: true});
const newFungibleTokenId = await createItemExpectSuccess(alice, fungibleCollectionId, 'Fungible');
await burnItemExpectSuccess(alice, fungibleCollectionId, newFungibleTokenId, 10);
await approveExpectSuccess(fungibleCollectionId, newFungibleTokenId, alice, bob.address);
@@ -276,6 +279,7 @@
it('transferFrom burnt token before approve ReFungible', async () => {
await usingApi(async () => {
const reFungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
+ await setCollectionLimitsExpectSuccess(alice, reFungibleCollectionId, {ownerCanTransfer: true});
const newReFungibleTokenId = await createItemExpectSuccess(alice, reFungibleCollectionId, 'ReFungible');
await burnItemExpectSuccess(alice, reFungibleCollectionId, newReFungibleTokenId, 100);
await approveExpectFail(reFungibleCollectionId, newReFungibleTokenId, alice, bob);
tests/src/util/helpers.tsdiffbeforeafterboth1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617import '../interfaces/augment-api-rpc';18import '../interfaces/augment-api-query';19import {ApiPromise} from '@polkadot/api';20import type {AccountId, EventRecord, Event} from '@polkadot/types/interfaces';21import type {GenericEventData} from '@polkadot/types';22import {AnyTuple, IEvent, IKeyringPair} from '@polkadot/types/types';23import {evmToAddress} from '@polkadot/util-crypto';24import BN from 'bn.js';25import chai from 'chai';26import chaiAsPromised from 'chai-as-promised';27import {default as usingApi, executeTransaction, submitTransactionAsync, submitTransactionExpectFailAsync} from '../substrate/substrate-api';28import {hexToStr, strToUTF16, utf16ToStr} from './util';29import {UpDataStructsRpcCollection, UpDataStructsCreateItemData, UpDataStructsProperty} from '@polkadot/types/lookup';30import {UpDataStructsTokenChild} from '../interfaces';3132chai.use(chaiAsPromised);33const expect = chai.expect;3435export type CrossAccountId = {36 Substrate: string,37} | {38 Ethereum: string,39};4041export function normalizeAccountId(input: string | AccountId | CrossAccountId | IKeyringPair): CrossAccountId {42 if (typeof input === 'string') {43 if (input.length >= 47) {44 return {Substrate: input};45 } else if (input.length === 42 && input.startsWith('0x')) {46 return {Ethereum: input.toLowerCase()};47 } else if (input.length === 40 && !input.startsWith('0x')) {48 return {Ethereum: '0x' + input.toLowerCase()};49 } else {50 throw new Error(`Unknown address format: "${input}"`);51 }52 }53 if ('address' in input) {54 return {Substrate: input.address};55 }56 if ('Ethereum' in input) {57 return {58 Ethereum: input.Ethereum.toLowerCase(),59 };60 } else if ('ethereum' in input) {61 return {62 Ethereum: (input as any).ethereum.toLowerCase(),63 };64 } else if ('Substrate' in input) {65 return input;66 } else if ('substrate' in input) {67 return {68 Substrate: (input as any).substrate,69 };70 }7172 // AccountId73 return {Substrate: input.toString()};74}75export function toSubstrateAddress(input: string | CrossAccountId | IKeyringPair): string {76 input = normalizeAccountId(input);77 if ('Substrate' in input) {78 return input.Substrate;79 } else {80 return evmToAddress(input.Ethereum);81 }82}8384export const U128_MAX = (1n << 128n) - 1n;8586const MICROUNIQUE = 1_000_000_000_000n;87const MILLIUNIQUE = 1_000n * MICROUNIQUE;88const CENTIUNIQUE = 10n * MILLIUNIQUE;89export const UNIQUE = 100n * CENTIUNIQUE;9091interface GenericResult<T> {92 success: boolean;93 data: T | null;94}9596interface CreateCollectionResult {97 success: boolean;98 collectionId: number;99}100101interface CreateItemResult {102 success: boolean;103 collectionId: number;104 itemId: number;105 recipient?: CrossAccountId;106}107108interface TransferResult {109 collectionId: number;110 itemId: number;111 sender?: CrossAccountId;112 recipient?: CrossAccountId;113 value: bigint;114}115116interface IReFungibleOwner {117 fraction: BN;118 owner: number[];119}120121interface IGetMessage {122 checkMsgUnqMethod: string;123 checkMsgTrsMethod: string;124 checkMsgSysMethod: string;125}126127export interface IFungibleTokenDataType {128 value: number;129}130131export interface IChainLimits {132 collectionNumbersLimit: number;133 accountTokenOwnershipLimit: number;134 collectionsAdminsLimit: number;135 customDataLimit: number;136 nftSponsorTransferTimeout: number;137 fungibleSponsorTransferTimeout: number;138 refungibleSponsorTransferTimeout: number;139 //offchainSchemaLimit: number;140 //constOnChainSchemaLimit: number;141}142143export interface IReFungibleTokenDataType {144 owner: IReFungibleOwner[];145}146147export function uniqueEventMessage(events: EventRecord[]): IGetMessage {148 let checkMsgUnqMethod = '';149 let checkMsgTrsMethod = '';150 let checkMsgSysMethod = '';151 events.forEach(({event: {method, section}}) => {152 if (section === 'common') {153 checkMsgUnqMethod = method;154 } else if (section === 'treasury') {155 checkMsgTrsMethod = method;156 } else if (section === 'system') {157 checkMsgSysMethod = method;158 } else { return null; }159 });160 const result: IGetMessage = {161 checkMsgUnqMethod,162 checkMsgTrsMethod,163 checkMsgSysMethod,164 };165 return result;166}167168export function getEvent<T extends Event>(events: EventRecord[], check: (event: IEvent<AnyTuple>) => event is T): T | undefined {169 const event = events.find(r => check(r.event));170 if (!event) return;171 return event.event as T;172}173174export function getGenericResult<T>(events: EventRecord[]): GenericResult<T>;175export function getGenericResult<T>(176 events: EventRecord[],177 expectSection: string,178 expectMethod: string,179 extractAction: (data: GenericEventData) => T180): GenericResult<T>;181182export function getGenericResult<T>(183 events: EventRecord[],184 expectSection?: string,185 expectMethod?: string,186 extractAction?: (data: GenericEventData) => T,187): GenericResult<T> {188 let success = false;189 let successData = null;190191 events.forEach(({event: {data, method, section}}) => {192 // console.log(` ${phase}: ${section}.${method}:: ${data}`);193 if (method === 'ExtrinsicSuccess') {194 success = true;195 } else if ((expectSection == section) && (expectMethod == method)) {196 successData = extractAction!(data as any);197 }198 });199200 const result: GenericResult<T> = {201 success,202 data: successData,203 };204 return result;205}206207export function getCreateCollectionResult(events: EventRecord[]): CreateCollectionResult {208 const genericResult = getGenericResult(events, 'common', 'CollectionCreated', (data) => parseInt(data[0].toString(), 10));209 const result: CreateCollectionResult = {210 success: genericResult.success,211 collectionId: genericResult.data ?? 0,212 };213 return result;214}215216export function getCreateItemsResult(events: EventRecord[]): CreateItemResult[] {217 const results: CreateItemResult[] = [];218 219 const genericResult = getGenericResult<CreateItemResult[]>(events, 'common', 'ItemCreated', (data) => {220 const collectionId = parseInt(data[0].toString(), 10);221 const itemId = parseInt(data[1].toString(), 10);222 const recipient = normalizeAccountId(data[2].toJSON() as any);223224 const itemRes: CreateItemResult = {225 success: true,226 collectionId,227 itemId,228 recipient,229 };230231 results.push(itemRes);232 return results;233 });234235 if (!genericResult.success) return [];236 return results;237}238239export function getCreateItemResult(events: EventRecord[]): CreateItemResult {240 const genericResult = getGenericResult<[number, number, CrossAccountId?]>(events, 'common', 'ItemCreated', (data) => [241 parseInt(data[0].toString(), 10),242 parseInt(data[1].toString(), 10),243 normalizeAccountId(data[2].toJSON() as any),244 ]);245246 if (genericResult.data == null) genericResult.data = [0, 0];247248 const result: CreateItemResult = {249 success: genericResult.success,250 collectionId: genericResult.data[0],251 itemId: genericResult.data[1],252 recipient: genericResult.data![2],253 };254 255 return result;256}257258export function getTransferResult(api: ApiPromise, events: EventRecord[]): TransferResult {259 for (const {event} of events) {260 if (api.events.common.Transfer.is(event)) {261 const [collection, token, sender, recipient, value] = event.data;262 return {263 collectionId: collection.toNumber(),264 itemId: token.toNumber(),265 sender: normalizeAccountId(sender.toJSON() as any),266 recipient: normalizeAccountId(recipient.toJSON() as any),267 value: value.toBigInt(),268 };269 }270 }271 throw new Error('no transfer event');272}273274interface Nft {275 type: 'NFT';276}277278interface Fungible {279 type: 'Fungible';280 decimalPoints: number;281}282283interface ReFungible {284 type: 'ReFungible';285}286287type CollectionMode = Nft | Fungible | ReFungible;288289export type Property = {290 key: any,291 value: any,292};293294type Permission = {295 mutable: boolean;296 collectionAdmin: boolean;297 tokenOwner: boolean;298}299300type PropertyPermission = {301 key: any;302 permission: Permission;303}304305export type CreateCollectionParams = {306 mode: CollectionMode,307 name: string,308 description: string,309 tokenPrefix: string,310 properties?: Array<Property>,311 propPerm?: Array<PropertyPermission>312};313314const defaultCreateCollectionParams: CreateCollectionParams = {315 description: 'description',316 mode: {type: 'NFT'},317 name: 'name',318 tokenPrefix: 'prefix',319};320321export async function createCollectionExpectSuccess(params: Partial<CreateCollectionParams> = {}): Promise<number> {322 const {name, description, mode, tokenPrefix} = {...defaultCreateCollectionParams, ...params};323324 let collectionId = 0;325 await usingApi(async (api, privateKeyWrapper) => {326 // Get number of collections before the transaction327 const collectionCountBefore = await getCreatedCollectionCount(api);328329 // Run the CreateCollection transaction330 const alicePrivateKey = privateKeyWrapper('//Alice');331332 let modeprm = {};333 if (mode.type === 'NFT') {334 modeprm = {nft: null};335 } else if (mode.type === 'Fungible') {336 modeprm = {fungible: mode.decimalPoints};337 } else if (mode.type === 'ReFungible') {338 modeprm = {refungible: null};339 }340341 const tx = api.tx.unique.createCollectionEx({342 name: strToUTF16(name),343 description: strToUTF16(description),344 tokenPrefix: strToUTF16(tokenPrefix),345 mode: modeprm as any,346 });347 const events = await submitTransactionAsync(alicePrivateKey, tx);348 const result = getCreateCollectionResult(events);349350 // Get number of collections after the transaction351 const collectionCountAfter = await getCreatedCollectionCount(api);352353 // Get the collection354 const collection = await queryCollectionExpectSuccess(api, result.collectionId);355356 // What to expect357 // tslint:disable-next-line:no-unused-expression358 expect(result.success).to.be.true;359 expect(result.collectionId).to.be.equal(collectionCountAfter);360 // tslint:disable-next-line:no-unused-expression361 expect(collection).to.be.not.null;362 expect(collectionCountAfter).to.be.equal(collectionCountBefore + 1, 'Error: NFT collection NOT created.');363 expect(collection.owner.toString()).to.be.equal(toSubstrateAddress(alicePrivateKey));364 expect(utf16ToStr(collection.name.toJSON() as any)).to.be.equal(name);365 expect(utf16ToStr(collection.description.toJSON() as any)).to.be.equal(description);366 expect(hexToStr(collection.tokenPrefix.toJSON())).to.be.equal(tokenPrefix);367368 collectionId = result.collectionId;369 });370371 return collectionId;372}373374export async function createCollectionWithPropsExpectSuccess(params: Partial<CreateCollectionParams> = {}): Promise<number> {375 const {name, description, mode, tokenPrefix} = {...defaultCreateCollectionParams, ...params};376377 let collectionId = 0;378 await usingApi(async (api, privateKeyWrapper) => {379 // Get number of collections before the transaction380 const collectionCountBefore = await getCreatedCollectionCount(api);381382 // Run the CreateCollection transaction383 const alicePrivateKey = privateKeyWrapper('//Alice');384385 let modeprm = {};386 if (mode.type === 'NFT') {387 modeprm = {nft: null};388 } else if (mode.type === 'Fungible') {389 modeprm = {fungible: mode.decimalPoints};390 } else if (mode.type === 'ReFungible') {391 modeprm = {refungible: null};392 }393394 const tx = api.tx.unique.createCollectionEx({name: strToUTF16(name), description: strToUTF16(description), tokenPrefix: strToUTF16(tokenPrefix), mode: modeprm as any, properties: params.properties, tokenPropertyPermissions: params.propPerm});395 const events = await submitTransactionAsync(alicePrivateKey, tx);396 const result = getCreateCollectionResult(events);397398 // Get number of collections after the transaction399 const collectionCountAfter = await getCreatedCollectionCount(api);400401 // Get the collection402 const collection = await queryCollectionExpectSuccess(api, result.collectionId);403404 // What to expect405 // tslint:disable-next-line:no-unused-expression406 expect(result.success).to.be.true;407 expect(result.collectionId).to.be.equal(collectionCountAfter);408 // tslint:disable-next-line:no-unused-expression409 expect(collection).to.be.not.null;410 expect(collectionCountAfter).to.be.equal(collectionCountBefore + 1, 'Error: NFT collection NOT created.');411 expect(collection.owner.toString()).to.be.equal(toSubstrateAddress(alicePrivateKey));412 expect(utf16ToStr(collection.name.toJSON() as any)).to.be.equal(name);413 expect(utf16ToStr(collection.description.toJSON() as any)).to.be.equal(description);414 expect(hexToStr(collection.tokenPrefix.toJSON())).to.be.equal(tokenPrefix);415416417 collectionId = result.collectionId;418 });419420 return collectionId;421}422423export async function createCollectionWithPropsExpectFailure(params: Partial<CreateCollectionParams> = {}) {424 const {name, description, mode, tokenPrefix} = {...defaultCreateCollectionParams, ...params};425426 await usingApi(async (api, privateKeyWrapper) => {427 // Get number of collections before the transaction428 const collectionCountBefore = await getCreatedCollectionCount(api);429430 // Run the CreateCollection transaction431 const alicePrivateKey = privateKeyWrapper('//Alice');432433 let modeprm = {};434 if (mode.type === 'NFT') {435 modeprm = {nft: null};436 } else if (mode.type === 'Fungible') {437 modeprm = {fungible: mode.decimalPoints};438 } else if (mode.type === 'ReFungible') {439 modeprm = {refungible: null};440 }441442 const tx = api.tx.unique.createCollectionEx({name: strToUTF16(name), description: strToUTF16(description), tokenPrefix: strToUTF16(tokenPrefix), mode: modeprm as any, properties: params.properties, tokenPropertyPermissions: params.propPerm});443 await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;444445446 // Get number of collections after the transaction447 const collectionCountAfter = await getCreatedCollectionCount(api);448449 expect(collectionCountAfter).to.be.equal(collectionCountBefore, 'Error: Collection with incorrect data created.');450 });451}452453export async function createCollectionExpectFailure(params: Partial<CreateCollectionParams> = {}) {454 const {name, description, mode, tokenPrefix} = {...defaultCreateCollectionParams, ...params};455456 let modeprm = {};457 if (mode.type === 'NFT') {458 modeprm = {nft: null};459 } else if (mode.type === 'Fungible') {460 modeprm = {fungible: mode.decimalPoints};461 } else if (mode.type === 'ReFungible') {462 modeprm = {refungible: null};463 }464465 await usingApi(async (api, privateKeyWrapper) => {466 // Get number of collections before the transaction467 const collectionCountBefore = await getCreatedCollectionCount(api);468469 // Run the CreateCollection transaction470 const alicePrivateKey = privateKeyWrapper('//Alice');471 const tx = api.tx.unique.createCollectionEx({name: strToUTF16(name), description: strToUTF16(description), tokenPrefix: strToUTF16(tokenPrefix), mode: modeprm as any});472 await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;473474 // Get number of collections after the transaction475 const collectionCountAfter = await getCreatedCollectionCount(api);476477 // What to expect478 expect(collectionCountAfter).to.be.equal(collectionCountBefore, 'Error: Collection with incorrect data created.');479 });480}481482export async function findUnusedAddress(api: ApiPromise, privateKeyWrapper: (account: string) => IKeyringPair, seedAddition = ''): Promise<IKeyringPair> {483 let bal = 0n;484 let unused;485 do {486 const randomSeed = 'seed' + Math.floor(Math.random() * Math.floor(10000)) + seedAddition;487 unused = privateKeyWrapper(`//${randomSeed}`);488 bal = (await api.query.system.account(unused.address)).data.free.toBigInt();489 } while (bal !== 0n);490 return unused;491}492493export async function getAllowance(api: ApiPromise, collectionId: number, owner: CrossAccountId | string, approved: CrossAccountId | string, tokenId: number) {494 return (await api.rpc.unique.allowance(collectionId, normalizeAccountId(owner), normalizeAccountId(approved), tokenId)).toBigInt();495}496497export function findUnusedAddresses(api: ApiPromise, privateKeyWrapper: (account: string) => IKeyringPair, amount: number): Promise<IKeyringPair[]> {498 return Promise.all(new Array(amount).fill(null).map(() => findUnusedAddress(api, privateKeyWrapper, '_' + Date.now())));499}500501export async function findNotExistingCollection(api: ApiPromise): Promise<number> {502 const totalNumber = await getCreatedCollectionCount(api);503 const newCollection: number = totalNumber + 1;504 return newCollection;505}506507function getDestroyResult(events: EventRecord[]): boolean {508 let success = false;509 events.forEach(({event: {method}}) => {510 if (method == 'ExtrinsicSuccess') {511 success = true;512 }513 });514 return success;515}516517export async function destroyCollectionExpectFailure(collectionId: number, senderSeed = '//Alice') {518 await usingApi(async (api, privateKeyWrapper) => {519 // Run the DestroyCollection transaction520 const alicePrivateKey = privateKeyWrapper(senderSeed);521 const tx = api.tx.unique.destroyCollection(collectionId);522 await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;523 });524}525526export async function destroyCollectionExpectSuccess(collectionId: number, senderSeed = '//Alice') {527 await usingApi(async (api, privateKeyWrapper) => {528 // Run the DestroyCollection transaction529 const alicePrivateKey = privateKeyWrapper(senderSeed);530 const tx = api.tx.unique.destroyCollection(collectionId);531 const events = await submitTransactionAsync(alicePrivateKey, tx);532 const result = getDestroyResult(events);533 expect(result).to.be.true;534535 // What to expect536 expect(await getDetailedCollectionInfo(api, collectionId)).to.be.null;537 });538}539540export async function setCollectionLimitsExpectSuccess(sender: IKeyringPair, collectionId: number, limits: any) {541 await usingApi(async (api) => {542 const tx = api.tx.unique.setCollectionLimits(collectionId, limits);543 const events = await submitTransactionAsync(sender, tx);544 const result = getGenericResult(events);545546 expect(result.success).to.be.true;547 });548}549550export const setCollectionPermissionsExpectSuccess = async (sender: IKeyringPair, collectionId: number, permissions: any) => {551 await usingApi(async(api) => {552 const tx = api.tx.unique.setCollectionPermissions(collectionId, permissions);553 const events = await submitTransactionAsync(sender, tx);554 const result = getGenericResult(events);555556 expect(result.success).to.be.true;557 });558};559560export async function setCollectionLimitsExpectFailure(sender: IKeyringPair, collectionId: number, limits: any) {561 await usingApi(async (api) => {562 const tx = api.tx.unique.setCollectionLimits(collectionId, limits);563 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;564 const result = getGenericResult(events);565566 expect(result.success).to.be.false;567 });568}569570export async function setCollectionSponsorExpectSuccess(collectionId: number, sponsor: string, sender = '//Alice') {571 await usingApi(async (api, privateKeyWrapper) => {572573 // Run the transaction574 const senderPrivateKey = privateKeyWrapper(sender);575 const tx = api.tx.unique.setCollectionSponsor(collectionId, sponsor);576 const events = await submitTransactionAsync(senderPrivateKey, tx);577 const result = getGenericResult(events);578579 // Get the collection580 const collection = await queryCollectionExpectSuccess(api, collectionId);581582 // What to expect583 expect(result.success).to.be.true;584 expect(collection.sponsorship.toJSON()).to.deep.equal({585 unconfirmed: sponsor,586 });587 });588}589590export async function removeCollectionSponsorExpectSuccess(collectionId: number, sender = '//Alice') {591 await usingApi(async (api, privateKeyWrapper) => {592593 // Run the transaction594 const alicePrivateKey = privateKeyWrapper(sender);595 const tx = api.tx.unique.removeCollectionSponsor(collectionId);596 const events = await submitTransactionAsync(alicePrivateKey, tx);597 const result = getGenericResult(events);598599 // Get the collection600 const collection = await queryCollectionExpectSuccess(api, collectionId);601602 // What to expect603 expect(result.success).to.be.true;604 expect(collection.sponsorship.toJSON()).to.be.deep.equal({disabled: null});605 });606}607608export async function removeCollectionSponsorExpectFailure(collectionId: number, senderSeed = '//Alice') {609 await usingApi(async (api, privateKeyWrapper) => {610611 // Run the transaction612 const alicePrivateKey = privateKeyWrapper(senderSeed);613 const tx = api.tx.unique.removeCollectionSponsor(collectionId);614 await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;615 });616}617618export async function setCollectionSponsorExpectFailure(collectionId: number, sponsor: string, senderSeed = '//Alice') {619 await usingApi(async (api, privateKeyWrapper) => {620621 // Run the transaction622 const alicePrivateKey = privateKeyWrapper(senderSeed);623 const tx = api.tx.unique.setCollectionSponsor(collectionId, sponsor);624 await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;625 });626}627628export async function confirmSponsorshipExpectSuccess(collectionId: number, senderSeed = '//Alice') {629 await usingApi(async (api, privateKeyWrapper) => {630631 // Run the transaction632 const sender = privateKeyWrapper(senderSeed);633 await confirmSponsorshipByKeyExpectSuccess(collectionId, sender);634 });635}636637export async function confirmSponsorshipByKeyExpectSuccess(collectionId: number, sender: IKeyringPair) {638 await usingApi(async (api, privateKeyWrapper) => {639640 // Run the transaction641 const tx = api.tx.unique.confirmSponsorship(collectionId);642 const events = await submitTransactionAsync(sender, tx);643 const result = getGenericResult(events);644645 // Get the collection646 const collection = await queryCollectionExpectSuccess(api, collectionId);647648 // What to expect649 expect(result.success).to.be.true;650 expect(collection.sponsorship.toJSON()).to.be.deep.equal({651 confirmed: sender.address,652 });653 });654}655656657export async function confirmSponsorshipExpectFailure(collectionId: number, senderSeed = '//Alice') {658 await usingApi(async (api, privateKeyWrapper) => {659660 // Run the transaction661 const sender = privateKeyWrapper(senderSeed);662 const tx = api.tx.unique.confirmSponsorship(collectionId);663 await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;664 });665}666667export async function enableContractSponsoringExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string, enable: boolean) {668 await usingApi(async (api) => {669 const tx = api.tx.unique.enableContractSponsoring(contractAddress, enable);670 const events = await submitTransactionAsync(sender, tx);671 const result = getGenericResult(events);672673 expect(result.success).to.be.true;674 });675}676677export async function enableContractSponsoringExpectFailure(sender: IKeyringPair, contractAddress: AccountId | string, enable: boolean) {678 await usingApi(async (api) => {679 const tx = api.tx.unique.enableContractSponsoring(contractAddress, enable);680 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;681 const result = getGenericResult(events);682683 expect(result.success).to.be.false;684 });685}686687export async function setTransferFlagExpectSuccess(sender: IKeyringPair, collectionId: number, enabled: boolean) {688689 await usingApi(async (api) => {690691 const tx = api.tx.unique.setTransfersEnabledFlag(collectionId, enabled);692 const events = await submitTransactionAsync(sender, tx);693 const result = getGenericResult(events);694695 expect(result.success).to.be.true;696 });697}698699export async function setTransferFlagExpectFailure(sender: IKeyringPair, collectionId: number, enabled: boolean) {700701 await usingApi(async (api) => {702703 const tx = api.tx.unique.setTransfersEnabledFlag(collectionId, enabled);704 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;705 const result = getGenericResult(events);706707 expect(result.success).to.be.false;708 });709}710711export async function setContractSponsoringRateLimitExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string, rateLimit: number) {712 await usingApi(async (api) => {713 const tx = api.tx.unique.setContractSponsoringRateLimit(contractAddress, rateLimit);714 const events = await submitTransactionAsync(sender, tx);715 const result = getGenericResult(events);716717 expect(result.success).to.be.true;718 });719}720721export async function setContractSponsoringRateLimitExpectFailure(sender: IKeyringPair, contractAddress: AccountId | string, rateLimit: number) {722 await usingApi(async (api) => {723 const tx = api.tx.unique.setContractSponsoringRateLimit(contractAddress, rateLimit);724 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;725 const result = getGenericResult(events);726727 expect(result.success).to.be.false;728 });729}730731export async function getNextSponsored(732 api: ApiPromise,733 collectionId: number,734 account: string | CrossAccountId,735 tokenId: number,736): Promise<number> {737 return Number((await api.rpc.unique.nextSponsored(collectionId, account, tokenId)).unwrapOr(-1));738}739740export async function toggleContractAllowlistExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string, value = true) {741 await usingApi(async (api) => {742 const tx = api.tx.unique.toggleContractAllowList(contractAddress, value);743 const events = await submitTransactionAsync(sender, tx);744 const result = getGenericResult(events);745746 expect(result.success).to.be.true;747 });748}749750export async function isAllowlistedInContract(contractAddress: AccountId | string, user: string) {751 let allowlisted = false;752 await usingApi(async (api) => {753 allowlisted = (await api.query.unique.contractAllowList(contractAddress, user)).toJSON() as boolean;754 });755 return allowlisted;756}757758export async function addToContractAllowListExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string, user: AccountId | string) {759 await usingApi(async (api) => {760 const tx = api.tx.unique.addToContractAllowList(contractAddress.toString(), user.toString());761 const events = await submitTransactionAsync(sender, tx);762 const result = getGenericResult(events);763764 expect(result.success).to.be.true;765 });766}767768export async function removeFromContractAllowListExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string, user: AccountId | string) {769 await usingApi(async (api) => {770 const tx = api.tx.unique.removeFromContractAllowList(contractAddress.toString(), user.toString());771 const events = await submitTransactionAsync(sender, tx);772 const result = getGenericResult(events);773774 expect(result.success).to.be.true;775 });776}777778export async function removeFromContractAllowListExpectFailure(sender: IKeyringPair, contractAddress: AccountId | string, user: AccountId | string) {779 await usingApi(async (api) => {780 const tx = api.tx.unique.removeFromContractAllowList(contractAddress.toString(), user.toString());781 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;782 const result = getGenericResult(events);783784 expect(result.success).to.be.false;785 });786}787788export interface CreateFungibleData {789 readonly Value: bigint;790}791792export interface CreateReFungibleData { }793export interface CreateNftData { }794795export type CreateItemData = {796 NFT: CreateNftData;797} | {798 Fungible: CreateFungibleData;799} | {800 ReFungible: CreateReFungibleData;801};802803export async function burnItemExpectSuccess(sender: IKeyringPair, collectionId: number, tokenId: number, value = 1) {804 await usingApi(async (api) => {805 const balanceBefore = await getBalance(api, collectionId, normalizeAccountId(sender), tokenId);806 // if burning token by admin - use adminButnItemExpectSuccess807 expect(balanceBefore >= BigInt(value)).to.be.true;808809 const tx = api.tx.unique.burnItem(collectionId, tokenId, value);810 const events = await submitTransactionAsync(sender, tx);811 const result = getGenericResult(events);812 expect(result.success).to.be.true;813814 const balanceAfter = await getBalance(api, collectionId, normalizeAccountId(sender), tokenId);815 expect(balanceAfter + BigInt(value)).to.be.equal(balanceBefore);816 });817}818819export async function820approveExpectSuccess(821 collectionId: number,822 tokenId: number, owner: IKeyringPair, approved: CrossAccountId | string, amount: number | bigint = 1,823) {824 await usingApi(async (api: ApiPromise) => {825 const approveUniqueTx = api.tx.unique.approve(normalizeAccountId(approved), collectionId, tokenId, amount);826 const events = await submitTransactionAsync(owner, approveUniqueTx);827 const result = getGenericResult(events);828 expect(result.success).to.be.true;829830 expect(await getAllowance(api, collectionId, owner.address, approved, tokenId)).to.be.equal(BigInt(amount));831 });832}833834export async function adminApproveFromExpectSuccess(835 collectionId: number,836 tokenId: number, admin: IKeyringPair, owner: CrossAccountId | string, approved: CrossAccountId | string, amount: number | bigint = 1,837) {838 await usingApi(async (api: ApiPromise) => {839 const approveUniqueTx = api.tx.unique.approve(normalizeAccountId(approved), collectionId, tokenId, amount);840 const events = await submitTransactionAsync(admin, approveUniqueTx);841 const result = getGenericResult(events);842 expect(result.success).to.be.true;843844 expect(await getAllowance(api, collectionId, owner, approved, tokenId)).to.be.equal(BigInt(amount));845 });846}847848export async function849transferFromExpectSuccess(850 collectionId: number,851 tokenId: number,852 accountApproved: IKeyringPair,853 accountFrom: IKeyringPair | CrossAccountId,854 accountTo: IKeyringPair | CrossAccountId,855 value: number | bigint = 1,856 type = 'NFT',857) {858 await usingApi(async (api: ApiPromise) => {859 const from = normalizeAccountId(accountFrom);860 const to = normalizeAccountId(accountTo);861 let balanceBefore = 0n;862 if (type === 'Fungible' || type === 'ReFungible') {863 balanceBefore = await getBalance(api, collectionId, to, tokenId);864 }865 const transferFromTx = api.tx.unique.transferFrom(normalizeAccountId(accountFrom), to, collectionId, tokenId, value);866 const events = await submitTransactionAsync(accountApproved, transferFromTx);867 const result = getGenericResult(events);868 // tslint:disable-next-line:no-unused-expression869 expect(result.success).to.be.true;870 if (type === 'NFT') {871 expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal(to);872 }873 if (type === 'Fungible') {874 const balanceAfter = await getBalance(api, collectionId, to, tokenId);875 if (JSON.stringify(to) !== JSON.stringify(from)) {876 expect(balanceAfter - balanceBefore).to.be.equal(BigInt(value));877 } else {878 expect(balanceAfter).to.be.equal(balanceBefore);879 }880 }881 if (type === 'ReFungible') {882 expect(await getBalance(api, collectionId, to, tokenId)).to.be.equal(balanceBefore + BigInt(value));883 }884 });885}886887export async function888transferFromExpectFail(889 collectionId: number,890 tokenId: number,891 accountApproved: IKeyringPair,892 accountFrom: IKeyringPair,893 accountTo: IKeyringPair,894 value: number | bigint = 1,895) {896 await usingApi(async (api: ApiPromise) => {897 const transferFromTx = api.tx.unique.transferFrom(normalizeAccountId(accountFrom.address), normalizeAccountId(accountTo.address), collectionId, tokenId, value);898 const events = await expect(submitTransactionExpectFailAsync(accountApproved, transferFromTx)).to.be.rejected;899 const result = getCreateCollectionResult(events);900 // tslint:disable-next-line:no-unused-expression901 expect(result.success).to.be.false;902 });903}904905/* eslint no-async-promise-executor: "off" */906export async function getBlockNumber(api: ApiPromise): Promise<number> {907 return new Promise<number>(async (resolve) => {908 const unsubscribe = await api.rpc.chain.subscribeNewHeads((head) => {909 unsubscribe();910 resolve(head.number.toNumber());911 });912 });913}914915export async function addCollectionAdminExpectSuccess(sender: IKeyringPair, collectionId: number, address: string | CrossAccountId) {916 await usingApi(async (api) => {917 const changeAdminTx = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(address));918 const events = await submitTransactionAsync(sender, changeAdminTx);919 const result = getCreateCollectionResult(events);920 expect(result.success).to.be.true;921 });922}923924export async function925getFreeBalance(account: IKeyringPair): Promise<bigint> {926 let balance = 0n;927 await usingApi(async (api) => {928 balance = BigInt((await api.query.system.account(account.address)).data.free.toString());929 });930931 return balance;932}933934export async function transferBalanceTo(api: ApiPromise, source: IKeyringPair, target: string, amount = 1000n * UNIQUE) {935 const tx = api.tx.balances.transfer(target, amount);936 const events = await submitTransactionAsync(source, tx);937 const result = getGenericResult(events);938 expect(result.success).to.be.true;939}940941export async function942scheduleExpectSuccess(943 operationTx: any,944 sender: IKeyringPair,945 blockSchedule: number,946 scheduledId: string,947 period = 1,948 repetitions = 1,949) {950 await usingApi(async (api: ApiPromise) => {951 const blockNumber: number | undefined = await getBlockNumber(api);952 const expectedBlockNumber = blockNumber + blockSchedule;953954 expect(blockNumber).to.be.greaterThan(0);955 const scheduleTx = api.tx.scheduler.scheduleNamed( // schedule956 scheduledId,957 expectedBlockNumber, 958 repetitions > 1 ? [period, repetitions] : null, 959 0, 960 {value: operationTx as any},961 );962963 const events = await submitTransactionAsync(sender, scheduleTx);964 expect(getGenericResult(events).success).to.be.true;965 });966}967968export async function969scheduleExpectFailure(970 operationTx: any,971 sender: IKeyringPair,972 blockSchedule: number,973 scheduledId: string,974 period = 1,975 repetitions = 1,976) {977 await usingApi(async (api: ApiPromise) => {978 const blockNumber: number | undefined = await getBlockNumber(api);979 const expectedBlockNumber = blockNumber + blockSchedule;980981 expect(blockNumber).to.be.greaterThan(0);982 const scheduleTx = api.tx.scheduler.scheduleNamed( // schedule983 scheduledId,984 expectedBlockNumber, 985 repetitions <= 1 ? null : [period, repetitions], 986 0, 987 {value: operationTx as any},988 );989990 //const events = 991 await expect(submitTransactionExpectFailAsync(sender, scheduleTx)).to.be.rejected;992 //expect(getGenericResult(events).success).to.be.false;993 });994}995996export async function997scheduleTransferAndWaitExpectSuccess(998 collectionId: number,999 tokenId: number,1000 sender: IKeyringPair,1001 recipient: IKeyringPair,1002 value: number | bigint = 1,1003 blockSchedule: number,1004 scheduledId: string,1005) {1006 await usingApi(async (api: ApiPromise) => {1007 await scheduleTransferExpectSuccess(collectionId, tokenId, sender, recipient, value, blockSchedule, scheduledId);10081009 const recipientBalanceBefore = (await api.query.system.account(recipient.address)).data.free.toBigInt();10101011 // sleep for n + 1 blocks1012 await waitNewBlocks(blockSchedule + 1);10131014 const recipientBalanceAfter = (await api.query.system.account(recipient.address)).data.free.toBigInt();10151016 expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal(normalizeAccountId(recipient.address));1017 expect(recipientBalanceAfter).to.be.equal(recipientBalanceBefore);1018 });1019}10201021export async function1022scheduleTransferExpectSuccess(1023 collectionId: number,1024 tokenId: number,1025 sender: IKeyringPair,1026 recipient: IKeyringPair,1027 value: number | bigint = 1,1028 blockSchedule: number,1029 scheduledId: string,1030) {1031 await usingApi(async (api: ApiPromise) => {1032 const transferTx = api.tx.unique.transfer(normalizeAccountId(recipient.address), collectionId, tokenId, value);10331034 await scheduleExpectSuccess(transferTx, sender, blockSchedule, scheduledId);10351036 expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal(normalizeAccountId(sender.address));1037 });1038}10391040export async function1041scheduleTransferFundsPeriodicExpectSuccess(1042 amount: bigint,1043 sender: IKeyringPair,1044 recipient: IKeyringPair,1045 blockSchedule: number,1046 scheduledId: string,1047 period: number,1048 repetitions: number,1049) {1050 await usingApi(async (api: ApiPromise) => {1051 const transferTx = api.tx.balances.transfer(recipient.address, amount);10521053 const balanceBefore = await getFreeBalance(recipient);1054 1055 await scheduleExpectSuccess(transferTx, sender, blockSchedule, scheduledId, period, repetitions);10561057 expect(await getFreeBalance(recipient)).to.be.equal(balanceBefore);1058 });1059}10601061export async function1062transferExpectSuccess(1063 collectionId: number,1064 tokenId: number,1065 sender: IKeyringPair,1066 recipient: IKeyringPair | CrossAccountId,1067 value: number | bigint = 1,1068 type = 'NFT',1069) {1070 await usingApi(async (api: ApiPromise) => {1071 const from = normalizeAccountId(sender);1072 const to = normalizeAccountId(recipient);10731074 let balanceBefore = 0n;1075 if (type === 'Fungible') {1076 balanceBefore = await getBalance(api, collectionId, to, tokenId);1077 }1078 const transferTx = api.tx.unique.transfer(to, collectionId, tokenId, value);1079 const events = await executeTransaction(api, sender, transferTx);10801081 const result = getTransferResult(api, events);1082 expect(result.collectionId).to.be.equal(collectionId);1083 expect(result.itemId).to.be.equal(tokenId);1084 expect(result.sender).to.be.deep.equal(normalizeAccountId(sender.address));1085 expect(result.recipient).to.be.deep.equal(to);1086 expect(result.value).to.be.equal(BigInt(value));10871088 if (type === 'NFT') {1089 expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal(to);1090 }1091 if (type === 'Fungible') {1092 const balanceAfter = await getBalance(api, collectionId, to, tokenId);1093 if (JSON.stringify(to) !== JSON.stringify(from)) {1094 expect(balanceAfter - balanceBefore).to.be.equal(BigInt(value));1095 } else {1096 expect(balanceAfter).to.be.equal(balanceBefore);1097 }1098 }1099 if (type === 'ReFungible') {1100 expect(await getBalance(api, collectionId, to, tokenId) >= value).to.be.true;1101 }1102 });1103}11041105export async function1106transferExpectFailure(1107 collectionId: number,1108 tokenId: number,1109 sender: IKeyringPair,1110 recipient: IKeyringPair | CrossAccountId,1111 value: number | bigint = 1,1112) {1113 await usingApi(async (api: ApiPromise) => {1114 const transferTx = api.tx.unique.transfer(normalizeAccountId(recipient), collectionId, tokenId, value);1115 const events = await expect(submitTransactionExpectFailAsync(sender, transferTx)).to.be.rejected;1116 const result = getGenericResult(events);1117 // if (events && Array.isArray(events)) {1118 // const result = getCreateCollectionResult(events);1119 // tslint:disable-next-line:no-unused-expression1120 expect(result.success).to.be.false;1121 //}1122 });1123}11241125export async function1126approveExpectFail(1127 collectionId: number,1128 tokenId: number, owner: IKeyringPair, approved: IKeyringPair, amount: number | bigint = 1,1129) {1130 await usingApi(async (api: ApiPromise) => {1131 const approveUniqueTx = api.tx.unique.approve(normalizeAccountId(approved.address), collectionId, tokenId, amount);1132 const events = await expect(submitTransactionExpectFailAsync(owner, approveUniqueTx)).to.be.rejected;1133 const result = getCreateCollectionResult(events);1134 // tslint:disable-next-line:no-unused-expression1135 expect(result.success).to.be.false;1136 });1137}11381139export async function getBalance(1140 api: ApiPromise,1141 collectionId: number,1142 owner: string | CrossAccountId,1143 token: number,1144): Promise<bigint> {1145 return (await api.rpc.unique.balance(collectionId, normalizeAccountId(owner), token)).toBigInt();1146}1147export async function getTokenOwner(1148 api: ApiPromise,1149 collectionId: number,1150 token: number,1151): Promise<CrossAccountId> {1152 const owner = (await api.rpc.unique.tokenOwner(collectionId, token)).toJSON() as any;1153 if (owner == null) throw new Error('owner == null');1154 return normalizeAccountId(owner);1155}1156export async function getTopmostTokenOwner(1157 api: ApiPromise,1158 collectionId: number,1159 token: number,1160): Promise<CrossAccountId> {1161 const owner = (await api.rpc.unique.topmostTokenOwner(collectionId, token)).toJSON() as any;1162 if (owner == null) throw new Error('owner == null');1163 return normalizeAccountId(owner);1164}1165export async function getTokenChildren(1166 api: ApiPromise,1167 collectionId: number,1168 tokenId: number,1169): Promise<UpDataStructsTokenChild[]> {1170 return (await api.rpc.unique.tokenChildren(collectionId, tokenId)).toJSON() as any;1171}1172export async function isTokenExists(1173 api: ApiPromise,1174 collectionId: number,1175 token: number,1176): Promise<boolean> {1177 return (await api.rpc.unique.tokenExists(collectionId, token)).toJSON();1178}1179export async function getLastTokenId(1180 api: ApiPromise,1181 collectionId: number,1182): Promise<number> {1183 return (await api.rpc.unique.lastTokenId(collectionId)).toJSON();1184}1185export async function getAdminList(1186 api: ApiPromise,1187 collectionId: number,1188): Promise<string[]> {1189 return (await api.rpc.unique.adminlist(collectionId)).toHuman() as any;1190}1191export async function getTokenProperties(1192 api: ApiPromise,1193 collectionId: number,1194 tokenId: number,1195 propertyKeys: string[],1196): Promise<UpDataStructsProperty[]> {1197 return (await api.rpc.unique.tokenProperties(collectionId, tokenId, propertyKeys)).toHuman() as any;1198}11991200export async function createFungibleItemExpectSuccess(1201 sender: IKeyringPair,1202 collectionId: number,1203 data: CreateFungibleData,1204 owner: CrossAccountId | string = sender.address,1205) {1206 return await usingApi(async (api) => {1207 const tx = api.tx.unique.createItem(collectionId, normalizeAccountId(owner), {Fungible: data});12081209 const events = await submitTransactionAsync(sender, tx);1210 const result = getCreateItemResult(events);12111212 expect(result.success).to.be.true;1213 return result.itemId;1214 });1215}12161217export async function createMultipleItemsWithPropsExpectSuccess(sender: IKeyringPair, collectionId: number, itemsData: any, owner: CrossAccountId | string = sender.address) {1218 await usingApi(async (api) => {1219 const to = normalizeAccountId(owner);1220 const tx = api.tx.unique.createMultipleItems(collectionId, to, itemsData);12211222 const events = await submitTransactionAsync(sender, tx);1223 const result = getCreateItemsResult(events);12241225 for (const res of result) {1226 expect(await api.rpc.unique.tokenProperties(collectionId, res.itemId)).not.to.be.empty;1227 }1228 });1229}12301231export async function createMultipleItemsExWithPropsExpectSuccess(sender: IKeyringPair, collectionId: number, itemsData: any) {1232 await usingApi(async (api) => {1233 const tx = api.tx.unique.createMultipleItemsEx(collectionId, itemsData);12341235 const events = await submitTransactionAsync(sender, tx);1236 const result = getCreateItemsResult(events);12371238 for (const res of result) {1239 expect(await api.rpc.unique.tokenProperties(collectionId, res.itemId)).not.to.be.empty;1240 }1241 });1242}12431244export async function createItemWithPropsExpectSuccess(sender: IKeyringPair, collectionId: number, createMode: string, props: Array<Property>, owner: CrossAccountId | string = sender.address) {1245 let newItemId = 0;1246 await usingApi(async (api) => {1247 const to = normalizeAccountId(owner);1248 const itemCountBefore = await getLastTokenId(api, collectionId);1249 const itemBalanceBefore = await getBalance(api, collectionId, to, newItemId);12501251 let tx;1252 if (createMode === 'Fungible') {1253 const createData = {fungible: {value: 10}};1254 tx = api.tx.unique.createItem(collectionId, to, createData as any);1255 } else if (createMode === 'ReFungible') {1256 const createData = {refungible: {pieces: 100}};1257 tx = api.tx.unique.createItem(collectionId, to, createData as any);1258 } else {1259 const data = api.createType('UpDataStructsCreateItemData', {NFT: {properties: props}});1260 tx = api.tx.unique.createItem(collectionId, to, data as UpDataStructsCreateItemData);1261 }12621263 const events = await submitTransactionAsync(sender, tx);1264 const result = getCreateItemResult(events);12651266 const itemCountAfter = await getLastTokenId(api, collectionId);1267 const itemBalanceAfter = await getBalance(api, collectionId, to, newItemId);12681269 if (createMode === 'NFT') {1270 expect(await api.rpc.unique.tokenProperties(collectionId, result.itemId)).not.to.be.empty;1271 }12721273 // What to expect1274 // tslint:disable-next-line:no-unused-expression1275 expect(result.success).to.be.true;1276 if (createMode === 'Fungible') {1277 expect(itemBalanceAfter - itemBalanceBefore).to.be.equal(10n);1278 } else {1279 expect(itemCountAfter).to.be.equal(itemCountBefore + 1);1280 }1281 expect(collectionId).to.be.equal(result.collectionId);1282 expect(itemCountAfter.toString()).to.be.equal(result.itemId.toString());1283 expect(to).to.be.deep.equal(result.recipient);1284 newItemId = result.itemId;1285 });1286 return newItemId;1287}12881289export async function createItemWithPropsExpectFailure(sender: IKeyringPair, collectionId: number, createMode: string, props: Array<Property>, owner: CrossAccountId | string = sender.address) {1290 await usingApi(async (api) => {12911292 let tx;1293 if (createMode === 'NFT') {1294 const data = api.createType('UpDataStructsCreateItemData', {NFT: {properties: props}});1295 tx = api.tx.unique.createItem(collectionId, normalizeAccountId(owner), data);1296 } else {1297 tx = api.tx.unique.createItem(collectionId, normalizeAccountId(owner), createMode);1298 }129913001301 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;1302 if(events.message && events.message.toString().indexOf('1002: Verification Error') > -1) return;1303 const result = getCreateItemResult(events);13041305 expect(result.success).to.be.false;1306 });1307}13081309export async function createItemExpectSuccess(sender: IKeyringPair, collectionId: number, createMode: string, owner: CrossAccountId | string = sender.address) {1310 let newItemId = 0;1311 await usingApi(async (api) => {1312 const to = normalizeAccountId(owner);1313 const itemCountBefore = await getLastTokenId(api, collectionId);1314 const itemBalanceBefore = await getBalance(api, collectionId, to, newItemId);13151316 let tx;1317 if (createMode === 'Fungible') {1318 const createData = {fungible: {value: 10}};1319 tx = api.tx.unique.createItem(collectionId, to, createData as any);1320 } else if (createMode === 'ReFungible') {1321 const createData = {refungible: {pieces: 100}};1322 tx = api.tx.unique.createItem(collectionId, to, createData as any);1323 } else {1324 const createData = {nft: {}};1325 tx = api.tx.unique.createItem(collectionId, to, createData as any);1326 }13271328 const events = await submitTransactionAsync(sender, tx);1329 const result = getCreateItemResult(events);13301331 const itemCountAfter = await getLastTokenId(api, collectionId);1332 const itemBalanceAfter = await getBalance(api, collectionId, to, newItemId);13331334 // What to expect1335 // tslint:disable-next-line:no-unused-expression1336 expect(result.success).to.be.true;1337 if (createMode === 'Fungible') {1338 expect(itemBalanceAfter - itemBalanceBefore).to.be.equal(10n);1339 } else {1340 expect(itemCountAfter).to.be.equal(itemCountBefore + 1);1341 }1342 expect(collectionId).to.be.equal(result.collectionId);1343 expect(itemCountAfter.toString()).to.be.equal(result.itemId.toString());1344 expect(to).to.be.deep.equal(result.recipient);1345 newItemId = result.itemId;1346 });1347 return newItemId;1348}13491350export async function createItemExpectFailure(sender: IKeyringPair, collectionId: number, createMode: string, owner: CrossAccountId | string = sender.address) {1351 await usingApi(async (api) => {1352 const tx = api.tx.unique.createItem(collectionId, normalizeAccountId(owner), createMode);13531354 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;1355 const result = getCreateItemResult(events);13561357 expect(result.success).to.be.false;1358 });1359}13601361export async function setPublicAccessModeExpectSuccess(1362 sender: IKeyringPair, collectionId: number,1363 accessMode: 'Normal' | 'AllowList',1364) {1365 await usingApi(async (api) => {13661367 // Run the transaction1368 const tx = api.tx.unique.setCollectionPermissions(collectionId, {access: accessMode});1369 const events = await submitTransactionAsync(sender, tx);1370 const result = getGenericResult(events);13711372 // Get the collection1373 const collection = await queryCollectionExpectSuccess(api, collectionId);13741375 // What to expect1376 // tslint:disable-next-line:no-unused-expression1377 expect(result.success).to.be.true;1378 expect(collection.permissions.access.toHuman()).to.be.equal(accessMode);1379 });1380}13811382export async function setPublicAccessModeExpectFail(1383 sender: IKeyringPair, collectionId: number,1384 accessMode: 'Normal' | 'AllowList',1385) {1386 await usingApi(async (api) => {13871388 // Run the transaction1389 const tx = api.tx.unique.setCollectionPermissions(collectionId, {access: accessMode});1390 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;1391 const result = getGenericResult(events);13921393 // What to expect1394 // tslint:disable-next-line:no-unused-expression1395 expect(result.success).to.be.false;1396 });1397}13981399export async function enableAllowListExpectSuccess(sender: IKeyringPair, collectionId: number) {1400 await setPublicAccessModeExpectSuccess(sender, collectionId, 'AllowList');1401}14021403export async function enableAllowListExpectFail(sender: IKeyringPair, collectionId: number) {1404 await setPublicAccessModeExpectFail(sender, collectionId, 'AllowList');1405}14061407export async function disableAllowListExpectSuccess(sender: IKeyringPair, collectionId: number) {1408 await setPublicAccessModeExpectSuccess(sender, collectionId, 'Normal');1409}14101411export async function setMintPermissionExpectSuccess(sender: IKeyringPair, collectionId: number, enabled: boolean) {1412 await usingApi(async (api) => {14131414 // Run the transaction1415 const tx = api.tx.unique.setCollectionPermissions(collectionId, {mintMode: enabled});1416 const events = await submitTransactionAsync(sender, tx);1417 const result = getGenericResult(events);1418 expect(result.success).to.be.true;14191420 // Get the collection1421 const collection = await queryCollectionExpectSuccess(api, collectionId);14221423 expect(collection.permissions.mintMode.toHuman()).to.be.equal(enabled);1424 });1425}14261427export async function enablePublicMintingExpectSuccess(sender: IKeyringPair, collectionId: number) {1428 await setMintPermissionExpectSuccess(sender, collectionId, true);1429}14301431export async function setMintPermissionExpectFailure(sender: IKeyringPair, collectionId: number, enabled: boolean) {1432 await usingApi(async (api) => {1433 // Run the transaction1434 const tx = api.tx.unique.setCollectionPermissions(collectionId, {mintMode: enabled});1435 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;1436 const result = getCreateCollectionResult(events);1437 // tslint:disable-next-line:no-unused-expression1438 expect(result.success).to.be.false;1439 });1440}14411442export async function setChainLimitsExpectFailure(sender: IKeyringPair, limits: IChainLimits) {1443 await usingApi(async (api) => {1444 // Run the transaction1445 const tx = api.tx.unique.setChainLimits(limits);1446 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;1447 const result = getCreateCollectionResult(events);1448 // tslint:disable-next-line:no-unused-expression1449 expect(result.success).to.be.false;1450 });1451}14521453export async function isAllowlisted(api: ApiPromise, collectionId: number, address: string | CrossAccountId) {1454 return (await api.rpc.unique.allowed(collectionId, normalizeAccountId(address))).toJSON();1455}14561457export async function addToAllowListExpectSuccess(sender: IKeyringPair, collectionId: number, address: string | AccountId | CrossAccountId) {1458 await usingApi(async (api) => {1459 expect(await isAllowlisted(api, collectionId, normalizeAccountId(address))).to.be.false;14601461 // Run the transaction1462 const tx = api.tx.unique.addToAllowList(collectionId, normalizeAccountId(address));1463 const events = await submitTransactionAsync(sender, tx);1464 const result = getGenericResult(events);1465 expect(result.success).to.be.true;14661467 expect(await isAllowlisted(api, collectionId, normalizeAccountId(address))).to.be.true;1468 });1469}14701471export async function addToAllowListAgainExpectSuccess(sender: IKeyringPair, collectionId: number, address: string | AccountId) {1472 await usingApi(async (api) => {14731474 expect(await isAllowlisted(api, collectionId, normalizeAccountId(address))).to.be.true;14751476 // Run the transaction1477 const tx = api.tx.unique.addToAllowList(collectionId, normalizeAccountId(address));1478 const events = await submitTransactionAsync(sender, tx);1479 const result = getGenericResult(events);1480 expect(result.success).to.be.true;14811482 expect(await isAllowlisted(api, collectionId, normalizeAccountId(address))).to.be.true;1483 });1484}14851486export async function addToAllowListExpectFail(sender: IKeyringPair, collectionId: number, address: string | AccountId) {1487 await usingApi(async (api) => {14881489 // Run the transaction1490 const tx = api.tx.unique.addToAllowList(collectionId, normalizeAccountId(address));1491 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;1492 const result = getGenericResult(events);14931494 // What to expect1495 // tslint:disable-next-line:no-unused-expression1496 expect(result.success).to.be.false;1497 });1498}14991500export async function removeFromAllowListExpectSuccess(sender: IKeyringPair, collectionId: number, address: CrossAccountId) {1501 await usingApi(async (api) => {1502 // Run the transaction1503 const tx = api.tx.unique.removeFromAllowList(collectionId, normalizeAccountId(address));1504 const events = await submitTransactionAsync(sender, tx);1505 const result = getGenericResult(events);15061507 // What to expect1508 // tslint:disable-next-line:no-unused-expression1509 expect(result.success).to.be.true;1510 });1511}15121513export async function removeFromAllowListExpectFailure(sender: IKeyringPair, collectionId: number, address: CrossAccountId) {1514 await usingApi(async (api) => {1515 // Run the transaction1516 const tx = api.tx.unique.removeFromAllowList(collectionId, normalizeAccountId(address));1517 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;1518 const result = getGenericResult(events);15191520 // What to expect1521 // tslint:disable-next-line:no-unused-expression1522 expect(result.success).to.be.false;1523 });1524}15251526export const getDetailedCollectionInfo = async (api: ApiPromise, collectionId: number)1527 : Promise<UpDataStructsRpcCollection | null> => {1528 return (await api.rpc.unique.collectionById(collectionId)).unwrapOr(null);1529};15301531export const getCreatedCollectionCount = async (api: ApiPromise): Promise<number> => {1532 // set global object - collectionsCount1533 return (await api.rpc.unique.collectionStats()).created.toNumber();1534};15351536export async function queryCollectionExpectSuccess(api: ApiPromise, collectionId: number): Promise<UpDataStructsRpcCollection> {1537 return (await api.rpc.unique.collectionById(collectionId)).unwrap();1538}15391540export async function waitNewBlocks(blocksCount = 1): Promise<void> {1541 await usingApi(async (api) => {1542 const promise = new Promise<void>(async (resolve) => {1543 const unsubscribe = await api.rpc.chain.subscribeNewHeads(() => {1544 if (blocksCount > 0) {1545 blocksCount--;1546 } else {1547 unsubscribe();1548 resolve();1549 }1550 });1551 });1552 return promise;1553 });1554}1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617import '../interfaces/augment-api-rpc';18import '../interfaces/augment-api-query';19import {ApiPromise} from '@polkadot/api';20import type {AccountId, EventRecord, Event} from '@polkadot/types/interfaces';21import type {GenericEventData} from '@polkadot/types';22import {AnyTuple, IEvent, IKeyringPair} from '@polkadot/types/types';23import {evmToAddress} from '@polkadot/util-crypto';24import BN from 'bn.js';25import chai from 'chai';26import chaiAsPromised from 'chai-as-promised';27import {default as usingApi, executeTransaction, submitTransactionAsync, submitTransactionExpectFailAsync} from '../substrate/substrate-api';28import {hexToStr, strToUTF16, utf16ToStr} from './util';29import {UpDataStructsRpcCollection, UpDataStructsCreateItemData, UpDataStructsProperty} from '@polkadot/types/lookup';30import {UpDataStructsTokenChild} from '../interfaces';3132chai.use(chaiAsPromised);33const expect = chai.expect;3435export type CrossAccountId = {36 Substrate: string,37} | {38 Ethereum: string,39};4041export function normalizeAccountId(input: string | AccountId | CrossAccountId | IKeyringPair): CrossAccountId {42 if (typeof input === 'string') {43 if (input.length >= 47) {44 return {Substrate: input};45 } else if (input.length === 42 && input.startsWith('0x')) {46 return {Ethereum: input.toLowerCase()};47 } else if (input.length === 40 && !input.startsWith('0x')) {48 return {Ethereum: '0x' + input.toLowerCase()};49 } else {50 throw new Error(`Unknown address format: "${input}"`);51 }52 }53 if ('address' in input) {54 return {Substrate: input.address};55 }56 if ('Ethereum' in input) {57 return {58 Ethereum: input.Ethereum.toLowerCase(),59 };60 } else if ('ethereum' in input) {61 return {62 Ethereum: (input as any).ethereum.toLowerCase(),63 };64 } else if ('Substrate' in input) {65 return input;66 } else if ('substrate' in input) {67 return {68 Substrate: (input as any).substrate,69 };70 }7172 // AccountId73 return {Substrate: input.toString()};74}75export function toSubstrateAddress(input: string | CrossAccountId | IKeyringPair): string {76 input = normalizeAccountId(input);77 if ('Substrate' in input) {78 return input.Substrate;79 } else {80 return evmToAddress(input.Ethereum);81 }82}8384export const U128_MAX = (1n << 128n) - 1n;8586const MICROUNIQUE = 1_000_000_000_000n;87const MILLIUNIQUE = 1_000n * MICROUNIQUE;88const CENTIUNIQUE = 10n * MILLIUNIQUE;89export const UNIQUE = 100n * CENTIUNIQUE;9091interface GenericResult<T> {92 success: boolean;93 data: T | null;94}9596interface CreateCollectionResult {97 success: boolean;98 collectionId: number;99}100101interface CreateItemResult {102 success: boolean;103 collectionId: number;104 itemId: number;105 recipient?: CrossAccountId;106}107108interface TransferResult {109 collectionId: number;110 itemId: number;111 sender?: CrossAccountId;112 recipient?: CrossAccountId;113 value: bigint;114}115116interface IReFungibleOwner {117 fraction: BN;118 owner: number[];119}120121interface IGetMessage {122 checkMsgUnqMethod: string;123 checkMsgTrsMethod: string;124 checkMsgSysMethod: string;125}126127export interface IFungibleTokenDataType {128 value: number;129}130131export interface IChainLimits {132 collectionNumbersLimit: number;133 accountTokenOwnershipLimit: number;134 collectionsAdminsLimit: number;135 customDataLimit: number;136 nftSponsorTransferTimeout: number;137 fungibleSponsorTransferTimeout: number;138 refungibleSponsorTransferTimeout: number;139 //offchainSchemaLimit: number;140 //constOnChainSchemaLimit: number;141}142143export interface IReFungibleTokenDataType {144 owner: IReFungibleOwner[];145}146147export function uniqueEventMessage(events: EventRecord[]): IGetMessage {148 let checkMsgUnqMethod = '';149 let checkMsgTrsMethod = '';150 let checkMsgSysMethod = '';151 events.forEach(({event: {method, section}}) => {152 if (section === 'common') {153 checkMsgUnqMethod = method;154 } else if (section === 'treasury') {155 checkMsgTrsMethod = method;156 } else if (section === 'system') {157 checkMsgSysMethod = method;158 } else { return null; }159 });160 const result: IGetMessage = {161 checkMsgUnqMethod,162 checkMsgTrsMethod,163 checkMsgSysMethod,164 };165 return result;166}167168export function getEvent<T extends Event>(events: EventRecord[], check: (event: IEvent<AnyTuple>) => event is T): T | undefined {169 const event = events.find(r => check(r.event));170 if (!event) return;171 return event.event as T;172}173174export function getGenericResult<T>(events: EventRecord[]): GenericResult<T>;175export function getGenericResult<T>(176 events: EventRecord[],177 expectSection: string,178 expectMethod: string,179 extractAction: (data: GenericEventData) => T180): GenericResult<T>;181182export function getGenericResult<T>(183 events: EventRecord[],184 expectSection?: string,185 expectMethod?: string,186 extractAction?: (data: GenericEventData) => T,187): GenericResult<T> {188 let success = false;189 let successData = null;190191 events.forEach(({event: {data, method, section}}) => {192 // console.log(` ${phase}: ${section}.${method}:: ${data}`);193 if (method === 'ExtrinsicSuccess') {194 success = true;195 } else if ((expectSection == section) && (expectMethod == method)) {196 successData = extractAction!(data as any);197 }198 });199200 const result: GenericResult<T> = {201 success,202 data: successData,203 };204 return result;205}206207export function getCreateCollectionResult(events: EventRecord[]): CreateCollectionResult {208 const genericResult = getGenericResult(events, 'common', 'CollectionCreated', (data) => parseInt(data[0].toString(), 10));209 const result: CreateCollectionResult = {210 success: genericResult.success,211 collectionId: genericResult.data ?? 0,212 };213 return result;214}215216export function getCreateItemsResult(events: EventRecord[]): CreateItemResult[] {217 const results: CreateItemResult[] = [];218 219 const genericResult = getGenericResult<CreateItemResult[]>(events, 'common', 'ItemCreated', (data) => {220 const collectionId = parseInt(data[0].toString(), 10);221 const itemId = parseInt(data[1].toString(), 10);222 const recipient = normalizeAccountId(data[2].toJSON() as any);223224 const itemRes: CreateItemResult = {225 success: true,226 collectionId,227 itemId,228 recipient,229 };230231 results.push(itemRes);232 return results;233 });234235 if (!genericResult.success) return [];236 return results;237}238239export function getCreateItemResult(events: EventRecord[]): CreateItemResult {240 const genericResult = getGenericResult<[number, number, CrossAccountId?]>(events, 'common', 'ItemCreated', (data) => [241 parseInt(data[0].toString(), 10),242 parseInt(data[1].toString(), 10),243 normalizeAccountId(data[2].toJSON() as any),244 ]);245246 if (genericResult.data == null) genericResult.data = [0, 0];247248 const result: CreateItemResult = {249 success: genericResult.success,250 collectionId: genericResult.data[0],251 itemId: genericResult.data[1],252 recipient: genericResult.data![2],253 };254 255 return result;256}257258export function getTransferResult(api: ApiPromise, events: EventRecord[]): TransferResult {259 for (const {event} of events) {260 if (api.events.common.Transfer.is(event)) {261 const [collection, token, sender, recipient, value] = event.data;262 return {263 collectionId: collection.toNumber(),264 itemId: token.toNumber(),265 sender: normalizeAccountId(sender.toJSON() as any),266 recipient: normalizeAccountId(recipient.toJSON() as any),267 value: value.toBigInt(),268 };269 }270 }271 throw new Error('no transfer event');272}273274interface Nft {275 type: 'NFT';276}277278interface Fungible {279 type: 'Fungible';280 decimalPoints: number;281}282283interface ReFungible {284 type: 'ReFungible';285}286287type CollectionMode = Nft | Fungible | ReFungible;288289export type Property = {290 key: any,291 value: any,292};293294type Permission = {295 mutable: boolean;296 collectionAdmin: boolean;297 tokenOwner: boolean;298}299300type PropertyPermission = {301 key: any;302 permission: Permission;303}304305export type CreateCollectionParams = {306 mode: CollectionMode,307 name: string,308 description: string,309 tokenPrefix: string,310 properties?: Array<Property>,311 propPerm?: Array<PropertyPermission>312};313314const defaultCreateCollectionParams: CreateCollectionParams = {315 description: 'description',316 mode: {type: 'NFT'},317 name: 'name',318 tokenPrefix: 'prefix',319};320321export async function createCollectionExpectSuccess(params: Partial<CreateCollectionParams> = {}): Promise<number> {322 const {name, description, mode, tokenPrefix} = {...defaultCreateCollectionParams, ...params};323324 let collectionId = 0;325 await usingApi(async (api, privateKeyWrapper) => {326 // Get number of collections before the transaction327 const collectionCountBefore = await getCreatedCollectionCount(api);328329 // Run the CreateCollection transaction330 const alicePrivateKey = privateKeyWrapper('//Alice');331332 let modeprm = {};333 if (mode.type === 'NFT') {334 modeprm = {nft: null};335 } else if (mode.type === 'Fungible') {336 modeprm = {fungible: mode.decimalPoints};337 } else if (mode.type === 'ReFungible') {338 modeprm = {refungible: null};339 }340341 const tx = api.tx.unique.createCollectionEx({342 name: strToUTF16(name),343 description: strToUTF16(description),344 tokenPrefix: strToUTF16(tokenPrefix),345 mode: modeprm as any,346 });347 const events = await submitTransactionAsync(alicePrivateKey, tx);348 const result = getCreateCollectionResult(events);349350 // Get number of collections after the transaction351 const collectionCountAfter = await getCreatedCollectionCount(api);352353 // Get the collection354 const collection = await queryCollectionExpectSuccess(api, result.collectionId);355356 // What to expect357 // tslint:disable-next-line:no-unused-expression358 expect(result.success).to.be.true;359 expect(result.collectionId).to.be.equal(collectionCountAfter);360 // tslint:disable-next-line:no-unused-expression361 expect(collection).to.be.not.null;362 expect(collectionCountAfter).to.be.equal(collectionCountBefore + 1, 'Error: NFT collection NOT created.');363 expect(collection.owner.toString()).to.be.equal(toSubstrateAddress(alicePrivateKey));364 expect(utf16ToStr(collection.name.toJSON() as any)).to.be.equal(name);365 expect(utf16ToStr(collection.description.toJSON() as any)).to.be.equal(description);366 expect(hexToStr(collection.tokenPrefix.toJSON())).to.be.equal(tokenPrefix);367368 collectionId = result.collectionId;369 });370371 return collectionId;372}373374export async function createCollectionWithPropsExpectSuccess(params: Partial<CreateCollectionParams> = {}): Promise<number> {375 const {name, description, mode, tokenPrefix} = {...defaultCreateCollectionParams, ...params};376377 let collectionId = 0;378 await usingApi(async (api, privateKeyWrapper) => {379 // Get number of collections before the transaction380 const collectionCountBefore = await getCreatedCollectionCount(api);381382 // Run the CreateCollection transaction383 const alicePrivateKey = privateKeyWrapper('//Alice');384385 let modeprm = {};386 if (mode.type === 'NFT') {387 modeprm = {nft: null};388 } else if (mode.type === 'Fungible') {389 modeprm = {fungible: mode.decimalPoints};390 } else if (mode.type === 'ReFungible') {391 modeprm = {refungible: null};392 }393394 const tx = api.tx.unique.createCollectionEx({name: strToUTF16(name), description: strToUTF16(description), tokenPrefix: strToUTF16(tokenPrefix), mode: modeprm as any, properties: params.properties, tokenPropertyPermissions: params.propPerm});395 const events = await submitTransactionAsync(alicePrivateKey, tx);396 const result = getCreateCollectionResult(events);397398 // Get number of collections after the transaction399 const collectionCountAfter = await getCreatedCollectionCount(api);400401 // Get the collection402 const collection = await queryCollectionExpectSuccess(api, result.collectionId);403404 // What to expect405 // tslint:disable-next-line:no-unused-expression406 expect(result.success).to.be.true;407 expect(result.collectionId).to.be.equal(collectionCountAfter);408 // tslint:disable-next-line:no-unused-expression409 expect(collection).to.be.not.null;410 expect(collectionCountAfter).to.be.equal(collectionCountBefore + 1, 'Error: NFT collection NOT created.');411 expect(collection.owner.toString()).to.be.equal(toSubstrateAddress(alicePrivateKey));412 expect(utf16ToStr(collection.name.toJSON() as any)).to.be.equal(name);413 expect(utf16ToStr(collection.description.toJSON() as any)).to.be.equal(description);414 expect(hexToStr(collection.tokenPrefix.toJSON())).to.be.equal(tokenPrefix);415416417 collectionId = result.collectionId;418 });419420 return collectionId;421}422423export async function createCollectionWithPropsExpectFailure(params: Partial<CreateCollectionParams> = {}) {424 const {name, description, mode, tokenPrefix} = {...defaultCreateCollectionParams, ...params};425426 await usingApi(async (api, privateKeyWrapper) => {427 // Get number of collections before the transaction428 const collectionCountBefore = await getCreatedCollectionCount(api);429430 // Run the CreateCollection transaction431 const alicePrivateKey = privateKeyWrapper('//Alice');432433 let modeprm = {};434 if (mode.type === 'NFT') {435 modeprm = {nft: null};436 } else if (mode.type === 'Fungible') {437 modeprm = {fungible: mode.decimalPoints};438 } else if (mode.type === 'ReFungible') {439 modeprm = {refungible: null};440 }441442 const tx = api.tx.unique.createCollectionEx({name: strToUTF16(name), description: strToUTF16(description), tokenPrefix: strToUTF16(tokenPrefix), mode: modeprm as any, properties: params.properties, tokenPropertyPermissions: params.propPerm});443 await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;444445446 // Get number of collections after the transaction447 const collectionCountAfter = await getCreatedCollectionCount(api);448449 expect(collectionCountAfter).to.be.equal(collectionCountBefore, 'Error: Collection with incorrect data created.');450 });451}452453export async function createCollectionExpectFailure(params: Partial<CreateCollectionParams> = {}) {454 const {name, description, mode, tokenPrefix} = {...defaultCreateCollectionParams, ...params};455456 let modeprm = {};457 if (mode.type === 'NFT') {458 modeprm = {nft: null};459 } else if (mode.type === 'Fungible') {460 modeprm = {fungible: mode.decimalPoints};461 } else if (mode.type === 'ReFungible') {462 modeprm = {refungible: null};463 }464465 await usingApi(async (api, privateKeyWrapper) => {466 // Get number of collections before the transaction467 const collectionCountBefore = await getCreatedCollectionCount(api);468469 // Run the CreateCollection transaction470 const alicePrivateKey = privateKeyWrapper('//Alice');471 const tx = api.tx.unique.createCollectionEx({name: strToUTF16(name), description: strToUTF16(description), tokenPrefix: strToUTF16(tokenPrefix), mode: modeprm as any});472 await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;473474 // Get number of collections after the transaction475 const collectionCountAfter = await getCreatedCollectionCount(api);476477 // What to expect478 expect(collectionCountAfter).to.be.equal(collectionCountBefore, 'Error: Collection with incorrect data created.');479 });480}481482export async function findUnusedAddress(api: ApiPromise, privateKeyWrapper: (account: string) => IKeyringPair, seedAddition = ''): Promise<IKeyringPair> {483 let bal = 0n;484 let unused;485 do {486 const randomSeed = 'seed' + Math.floor(Math.random() * Math.floor(10000)) + seedAddition;487 unused = privateKeyWrapper(`//${randomSeed}`);488 bal = (await api.query.system.account(unused.address)).data.free.toBigInt();489 } while (bal !== 0n);490 return unused;491}492493export async function getAllowance(api: ApiPromise, collectionId: number, owner: CrossAccountId | string, approved: CrossAccountId | string, tokenId: number) {494 return (await api.rpc.unique.allowance(collectionId, normalizeAccountId(owner), normalizeAccountId(approved), tokenId)).toBigInt();495}496497export function findUnusedAddresses(api: ApiPromise, privateKeyWrapper: (account: string) => IKeyringPair, amount: number): Promise<IKeyringPair[]> {498 return Promise.all(new Array(amount).fill(null).map(() => findUnusedAddress(api, privateKeyWrapper, '_' + Date.now())));499}500501export async function findNotExistingCollection(api: ApiPromise): Promise<number> {502 const totalNumber = await getCreatedCollectionCount(api);503 const newCollection: number = totalNumber + 1;504 return newCollection;505}506507function getDestroyResult(events: EventRecord[]): boolean {508 let success = false;509 events.forEach(({event: {method}}) => {510 if (method == 'ExtrinsicSuccess') {511 success = true;512 }513 });514 return success;515}516517export async function destroyCollectionExpectFailure(collectionId: number, senderSeed = '//Alice') {518 await usingApi(async (api, privateKeyWrapper) => {519 // Run the DestroyCollection transaction520 const alicePrivateKey = privateKeyWrapper(senderSeed);521 const tx = api.tx.unique.destroyCollection(collectionId);522 await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;523 });524}525526export async function destroyCollectionExpectSuccess(collectionId: number, senderSeed = '//Alice') {527 await usingApi(async (api, privateKeyWrapper) => {528 // Run the DestroyCollection transaction529 const alicePrivateKey = privateKeyWrapper(senderSeed);530 const tx = api.tx.unique.destroyCollection(collectionId);531 const events = await submitTransactionAsync(alicePrivateKey, tx);532 const result = getDestroyResult(events);533 expect(result).to.be.true;534535 // What to expect536 expect(await getDetailedCollectionInfo(api, collectionId)).to.be.null;537 });538}539540export async function setCollectionLimitsExpectSuccess(sender: IKeyringPair, collectionId: number, limits: any) {541 await usingApi(async (api) => {542 const tx = api.tx.unique.setCollectionLimits(collectionId, limits);543 const events = await submitTransactionAsync(sender, tx);544 const result = getGenericResult(events);545546 expect(result.success).to.be.true;547 });548}549550export const setCollectionPermissionsExpectSuccess = async (sender: IKeyringPair, collectionId: number, permissions: any) => {551 await usingApi(async(api) => {552 const tx = api.tx.unique.setCollectionPermissions(collectionId, permissions);553 const events = await submitTransactionAsync(sender, tx);554 const result = getGenericResult(events);555556 expect(result.success).to.be.true;557 });558};559560export async function setCollectionLimitsExpectFailure(sender: IKeyringPair, collectionId: number, limits: any) {561 await usingApi(async (api) => {562 const tx = api.tx.unique.setCollectionLimits(collectionId, limits);563 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;564 const result = getGenericResult(events);565566 expect(result.success).to.be.false;567 });568}569570export async function setCollectionSponsorExpectSuccess(collectionId: number, sponsor: string, sender = '//Alice') {571 await usingApi(async (api, privateKeyWrapper) => {572573 // Run the transaction574 const senderPrivateKey = privateKeyWrapper(sender);575 const tx = api.tx.unique.setCollectionSponsor(collectionId, sponsor);576 const events = await submitTransactionAsync(senderPrivateKey, tx);577 const result = getGenericResult(events);578579 // Get the collection580 const collection = await queryCollectionExpectSuccess(api, collectionId);581582 // What to expect583 expect(result.success).to.be.true;584 expect(collection.sponsorship.toJSON()).to.deep.equal({585 unconfirmed: sponsor,586 });587 });588}589590export async function removeCollectionSponsorExpectSuccess(collectionId: number, sender = '//Alice') {591 await usingApi(async (api, privateKeyWrapper) => {592593 // Run the transaction594 const alicePrivateKey = privateKeyWrapper(sender);595 const tx = api.tx.unique.removeCollectionSponsor(collectionId);596 const events = await submitTransactionAsync(alicePrivateKey, tx);597 const result = getGenericResult(events);598599 // Get the collection600 const collection = await queryCollectionExpectSuccess(api, collectionId);601602 // What to expect603 expect(result.success).to.be.true;604 expect(collection.sponsorship.toJSON()).to.be.deep.equal({disabled: null});605 });606}607608export async function removeCollectionSponsorExpectFailure(collectionId: number, senderSeed = '//Alice') {609 await usingApi(async (api, privateKeyWrapper) => {610611 // Run the transaction612 const alicePrivateKey = privateKeyWrapper(senderSeed);613 const tx = api.tx.unique.removeCollectionSponsor(collectionId);614 await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;615 });616}617618export async function setCollectionSponsorExpectFailure(collectionId: number, sponsor: string, senderSeed = '//Alice') {619 await usingApi(async (api, privateKeyWrapper) => {620621 // Run the transaction622 const alicePrivateKey = privateKeyWrapper(senderSeed);623 const tx = api.tx.unique.setCollectionSponsor(collectionId, sponsor);624 await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;625 });626}627628export async function confirmSponsorshipExpectSuccess(collectionId: number, senderSeed = '//Alice') {629 await usingApi(async (api, privateKeyWrapper) => {630631 // Run the transaction632 const sender = privateKeyWrapper(senderSeed);633 await confirmSponsorshipByKeyExpectSuccess(collectionId, sender);634 });635}636637export async function confirmSponsorshipByKeyExpectSuccess(collectionId: number, sender: IKeyringPair) {638 await usingApi(async (api, privateKeyWrapper) => {639640 // Run the transaction641 const tx = api.tx.unique.confirmSponsorship(collectionId);642 const events = await submitTransactionAsync(sender, tx);643 const result = getGenericResult(events);644645 // Get the collection646 const collection = await queryCollectionExpectSuccess(api, collectionId);647648 // What to expect649 expect(result.success).to.be.true;650 expect(collection.sponsorship.toJSON()).to.be.deep.equal({651 confirmed: sender.address,652 });653 });654}655656657export async function confirmSponsorshipExpectFailure(collectionId: number, senderSeed = '//Alice') {658 await usingApi(async (api, privateKeyWrapper) => {659660 // Run the transaction661 const sender = privateKeyWrapper(senderSeed);662 const tx = api.tx.unique.confirmSponsorship(collectionId);663 await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;664 });665}666667export async function enableContractSponsoringExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string, enable: boolean) {668 await usingApi(async (api) => {669 const tx = api.tx.unique.enableContractSponsoring(contractAddress, enable);670 const events = await submitTransactionAsync(sender, tx);671 const result = getGenericResult(events);672673 expect(result.success).to.be.true;674 });675}676677export async function enableContractSponsoringExpectFailure(sender: IKeyringPair, contractAddress: AccountId | string, enable: boolean) {678 await usingApi(async (api) => {679 const tx = api.tx.unique.enableContractSponsoring(contractAddress, enable);680 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;681 const result = getGenericResult(events);682683 expect(result.success).to.be.false;684 });685}686687export async function setTransferFlagExpectSuccess(sender: IKeyringPair, collectionId: number, enabled: boolean) {688689 await usingApi(async (api) => {690691 const tx = api.tx.unique.setTransfersEnabledFlag(collectionId, enabled);692 const events = await submitTransactionAsync(sender, tx);693 const result = getGenericResult(events);694695 expect(result.success).to.be.true;696 });697}698699export async function setTransferFlagExpectFailure(sender: IKeyringPair, collectionId: number, enabled: boolean) {700701 await usingApi(async (api) => {702703 const tx = api.tx.unique.setTransfersEnabledFlag(collectionId, enabled);704 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;705 const result = getGenericResult(events);706707 expect(result.success).to.be.false;708 });709}710711export async function setContractSponsoringRateLimitExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string, rateLimit: number) {712 await usingApi(async (api) => {713 const tx = api.tx.unique.setContractSponsoringRateLimit(contractAddress, rateLimit);714 const events = await submitTransactionAsync(sender, tx);715 const result = getGenericResult(events);716717 expect(result.success).to.be.true;718 });719}720721export async function setContractSponsoringRateLimitExpectFailure(sender: IKeyringPair, contractAddress: AccountId | string, rateLimit: number) {722 await usingApi(async (api) => {723 const tx = api.tx.unique.setContractSponsoringRateLimit(contractAddress, rateLimit);724 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;725 const result = getGenericResult(events);726727 expect(result.success).to.be.false;728 });729}730731export async function getNextSponsored(732 api: ApiPromise,733 collectionId: number,734 account: string | CrossAccountId,735 tokenId: number,736): Promise<number> {737 return Number((await api.rpc.unique.nextSponsored(collectionId, account, tokenId)).unwrapOr(-1));738}739740export async function toggleContractAllowlistExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string, value = true) {741 await usingApi(async (api) => {742 const tx = api.tx.unique.toggleContractAllowList(contractAddress, value);743 const events = await submitTransactionAsync(sender, tx);744 const result = getGenericResult(events);745746 expect(result.success).to.be.true;747 });748}749750export async function isAllowlistedInContract(contractAddress: AccountId | string, user: string) {751 let allowlisted = false;752 await usingApi(async (api) => {753 allowlisted = (await api.query.unique.contractAllowList(contractAddress, user)).toJSON() as boolean;754 });755 return allowlisted;756}757758export async function addToContractAllowListExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string, user: AccountId | string) {759 await usingApi(async (api) => {760 const tx = api.tx.unique.addToContractAllowList(contractAddress.toString(), user.toString());761 const events = await submitTransactionAsync(sender, tx);762 const result = getGenericResult(events);763764 expect(result.success).to.be.true;765 });766}767768export async function removeFromContractAllowListExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string, user: AccountId | string) {769 await usingApi(async (api) => {770 const tx = api.tx.unique.removeFromContractAllowList(contractAddress.toString(), user.toString());771 const events = await submitTransactionAsync(sender, tx);772 const result = getGenericResult(events);773774 expect(result.success).to.be.true;775 });776}777778export async function removeFromContractAllowListExpectFailure(sender: IKeyringPair, contractAddress: AccountId | string, user: AccountId | string) {779 await usingApi(async (api) => {780 const tx = api.tx.unique.removeFromContractAllowList(contractAddress.toString(), user.toString());781 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;782 const result = getGenericResult(events);783784 expect(result.success).to.be.false;785 });786}787788export interface CreateFungibleData {789 readonly Value: bigint;790}791792export interface CreateReFungibleData { }793export interface CreateNftData { }794795export type CreateItemData = {796 NFT: CreateNftData;797} | {798 Fungible: CreateFungibleData;799} | {800 ReFungible: CreateReFungibleData;801};802803export async function burnItemExpectSuccess(sender: IKeyringPair, collectionId: number, tokenId: number, value = 1) {804 await usingApi(async (api) => {805 const balanceBefore = await getBalance(api, collectionId, normalizeAccountId(sender), tokenId);806 // if burning token by admin - use adminButnItemExpectSuccess807 expect(balanceBefore >= BigInt(value)).to.be.true;808809 const tx = api.tx.unique.burnItem(collectionId, tokenId, value);810 const events = await submitTransactionAsync(sender, tx);811 const result = getGenericResult(events);812 expect(result.success).to.be.true;813814 const balanceAfter = await getBalance(api, collectionId, normalizeAccountId(sender), tokenId);815 expect(balanceAfter + BigInt(value)).to.be.equal(balanceBefore);816 });817}818819export async function820approveExpectSuccess(821 collectionId: number,822 tokenId: number, owner: IKeyringPair, approved: CrossAccountId | string, amount: number | bigint = 1,823) {824 await usingApi(async (api: ApiPromise) => {825 const approveUniqueTx = api.tx.unique.approve(normalizeAccountId(approved), collectionId, tokenId, amount);826 const events = await submitTransactionAsync(owner, approveUniqueTx);827 const result = getGenericResult(events);828 expect(result.success).to.be.true;829830 expect(await getAllowance(api, collectionId, owner.address, approved, tokenId)).to.be.equal(BigInt(amount));831 });832}833834export async function adminApproveFromExpectSuccess(835 collectionId: number,836 tokenId: number, admin: IKeyringPair, owner: CrossAccountId | string, approved: CrossAccountId | string, amount: number | bigint = 1,837) {838 await usingApi(async (api: ApiPromise) => {839 const approveUniqueTx = api.tx.unique.approve(normalizeAccountId(approved), collectionId, tokenId, amount);840 const events = await submitTransactionAsync(admin, approveUniqueTx);841 const result = getGenericResult(events);842 expect(result.success).to.be.true;843844 expect(await getAllowance(api, collectionId, owner, approved, tokenId)).to.be.equal(BigInt(amount));845 });846}847848export async function849transferFromExpectSuccess(850 collectionId: number,851 tokenId: number,852 accountApproved: IKeyringPair,853 accountFrom: IKeyringPair | CrossAccountId,854 accountTo: IKeyringPair | CrossAccountId,855 value: number | bigint = 1,856 type = 'NFT',857) {858 await usingApi(async (api: ApiPromise) => {859 const from = normalizeAccountId(accountFrom);860 const to = normalizeAccountId(accountTo);861 let balanceBefore = 0n;862 if (type === 'Fungible' || type === 'ReFungible') {863 balanceBefore = await getBalance(api, collectionId, to, tokenId);864 }865 const transferFromTx = api.tx.unique.transferFrom(normalizeAccountId(accountFrom), to, collectionId, tokenId, value);866 const events = await submitTransactionAsync(accountApproved, transferFromTx);867 const result = getGenericResult(events);868 // tslint:disable-next-line:no-unused-expression869 expect(result.success).to.be.true;870 if (type === 'NFT') {871 expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal(to);872 }873 if (type === 'Fungible') {874 const balanceAfter = await getBalance(api, collectionId, to, tokenId);875 if (JSON.stringify(to) !== JSON.stringify(from)) {876 expect(balanceAfter - balanceBefore).to.be.equal(BigInt(value));877 } else {878 expect(balanceAfter).to.be.equal(balanceBefore);879 }880 }881 if (type === 'ReFungible') {882 expect(await getBalance(api, collectionId, to, tokenId)).to.be.equal(balanceBefore + BigInt(value));883 }884 });885}886887export async function888transferFromExpectFail(889 collectionId: number,890 tokenId: number,891 accountApproved: IKeyringPair,892 accountFrom: IKeyringPair,893 accountTo: IKeyringPair,894 value: number | bigint = 1,895) {896 await usingApi(async (api: ApiPromise) => {897 const transferFromTx = api.tx.unique.transferFrom(normalizeAccountId(accountFrom.address), normalizeAccountId(accountTo.address), collectionId, tokenId, value);898 const events = await expect(submitTransactionExpectFailAsync(accountApproved, transferFromTx)).to.be.rejected;899 const result = getCreateCollectionResult(events);900 // tslint:disable-next-line:no-unused-expression901 expect(result.success).to.be.false;902 });903}904905/* eslint no-async-promise-executor: "off" */906export async function getBlockNumber(api: ApiPromise): Promise<number> {907 return new Promise<number>(async (resolve) => {908 const unsubscribe = await api.rpc.chain.subscribeNewHeads((head) => {909 unsubscribe();910 resolve(head.number.toNumber());911 });912 });913}914915export async function addCollectionAdminExpectSuccess(sender: IKeyringPair, collectionId: number, address: string | CrossAccountId) {916 await usingApi(async (api) => {917 const changeAdminTx = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(address));918 const events = await submitTransactionAsync(sender, changeAdminTx);919 const result = getCreateCollectionResult(events);920 expect(result.success).to.be.true;921 });922}923924export async function adminApproveFromExpectFail(925 collectionId: number,926 tokenId: number, admin: IKeyringPair, owner: CrossAccountId | string, approved: CrossAccountId | string, amount: number | bigint = 1,927) {928 await usingApi(async (api: ApiPromise) => {929 const approveUniqueTx = api.tx.unique.approve(normalizeAccountId(approved), collectionId, tokenId, amount);930 const events = await expect(submitTransactionAsync(admin, approveUniqueTx)).to.be.rejected;931 const result = getGenericResult(events);932 expect(result.success).to.be.false;933 });934}935936export async function937getFreeBalance(account: IKeyringPair): Promise<bigint> {938 let balance = 0n;939 await usingApi(async (api) => {940 balance = BigInt((await api.query.system.account(account.address)).data.free.toString());941 });942943 return balance;944}945946export async function transferBalanceTo(api: ApiPromise, source: IKeyringPair, target: string, amount = 1000n * UNIQUE) {947 const tx = api.tx.balances.transfer(target, amount);948 const events = await submitTransactionAsync(source, tx);949 const result = getGenericResult(events);950 expect(result.success).to.be.true;951}952953export async function954scheduleExpectSuccess(955 operationTx: any,956 sender: IKeyringPair,957 blockSchedule: number,958 scheduledId: string,959 period = 1,960 repetitions = 1,961) {962 await usingApi(async (api: ApiPromise) => {963 const blockNumber: number | undefined = await getBlockNumber(api);964 const expectedBlockNumber = blockNumber + blockSchedule;965966 expect(blockNumber).to.be.greaterThan(0);967 const scheduleTx = api.tx.scheduler.scheduleNamed( // schedule968 scheduledId,969 expectedBlockNumber, 970 repetitions > 1 ? [period, repetitions] : null, 971 0, 972 {value: operationTx as any},973 );974975 const events = await submitTransactionAsync(sender, scheduleTx);976 expect(getGenericResult(events).success).to.be.true;977 });978}979980export async function981scheduleExpectFailure(982 operationTx: any,983 sender: IKeyringPair,984 blockSchedule: number,985 scheduledId: string,986 period = 1,987 repetitions = 1,988) {989 await usingApi(async (api: ApiPromise) => {990 const blockNumber: number | undefined = await getBlockNumber(api);991 const expectedBlockNumber = blockNumber + blockSchedule;992993 expect(blockNumber).to.be.greaterThan(0);994 const scheduleTx = api.tx.scheduler.scheduleNamed( // schedule995 scheduledId,996 expectedBlockNumber, 997 repetitions <= 1 ? null : [period, repetitions], 998 0, 999 {value: operationTx as any},1000 );10011002 //const events = 1003 await expect(submitTransactionExpectFailAsync(sender, scheduleTx)).to.be.rejected;1004 //expect(getGenericResult(events).success).to.be.false;1005 });1006}10071008export async function1009scheduleTransferAndWaitExpectSuccess(1010 collectionId: number,1011 tokenId: number,1012 sender: IKeyringPair,1013 recipient: IKeyringPair,1014 value: number | bigint = 1,1015 blockSchedule: number,1016 scheduledId: string,1017) {1018 await usingApi(async (api: ApiPromise) => {1019 await scheduleTransferExpectSuccess(collectionId, tokenId, sender, recipient, value, blockSchedule, scheduledId);10201021 const recipientBalanceBefore = (await api.query.system.account(recipient.address)).data.free.toBigInt();10221023 // sleep for n + 1 blocks1024 await waitNewBlocks(blockSchedule + 1);10251026 const recipientBalanceAfter = (await api.query.system.account(recipient.address)).data.free.toBigInt();10271028 expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal(normalizeAccountId(recipient.address));1029 expect(recipientBalanceAfter).to.be.equal(recipientBalanceBefore);1030 });1031}10321033export async function1034scheduleTransferExpectSuccess(1035 collectionId: number,1036 tokenId: number,1037 sender: IKeyringPair,1038 recipient: IKeyringPair,1039 value: number | bigint = 1,1040 blockSchedule: number,1041 scheduledId: string,1042) {1043 await usingApi(async (api: ApiPromise) => {1044 const transferTx = api.tx.unique.transfer(normalizeAccountId(recipient.address), collectionId, tokenId, value);10451046 await scheduleExpectSuccess(transferTx, sender, blockSchedule, scheduledId);10471048 expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal(normalizeAccountId(sender.address));1049 });1050}10511052export async function1053scheduleTransferFundsPeriodicExpectSuccess(1054 amount: bigint,1055 sender: IKeyringPair,1056 recipient: IKeyringPair,1057 blockSchedule: number,1058 scheduledId: string,1059 period: number,1060 repetitions: number,1061) {1062 await usingApi(async (api: ApiPromise) => {1063 const transferTx = api.tx.balances.transfer(recipient.address, amount);10641065 const balanceBefore = await getFreeBalance(recipient);1066 1067 await scheduleExpectSuccess(transferTx, sender, blockSchedule, scheduledId, period, repetitions);10681069 expect(await getFreeBalance(recipient)).to.be.equal(balanceBefore);1070 });1071}10721073export async function1074transferExpectSuccess(1075 collectionId: number,1076 tokenId: number,1077 sender: IKeyringPair,1078 recipient: IKeyringPair | CrossAccountId,1079 value: number | bigint = 1,1080 type = 'NFT',1081) {1082 await usingApi(async (api: ApiPromise) => {1083 const from = normalizeAccountId(sender);1084 const to = normalizeAccountId(recipient);10851086 let balanceBefore = 0n;1087 if (type === 'Fungible') {1088 balanceBefore = await getBalance(api, collectionId, to, tokenId);1089 }1090 const transferTx = api.tx.unique.transfer(to, collectionId, tokenId, value);1091 const events = await executeTransaction(api, sender, transferTx);10921093 const result = getTransferResult(api, events);1094 expect(result.collectionId).to.be.equal(collectionId);1095 expect(result.itemId).to.be.equal(tokenId);1096 expect(result.sender).to.be.deep.equal(normalizeAccountId(sender.address));1097 expect(result.recipient).to.be.deep.equal(to);1098 expect(result.value).to.be.equal(BigInt(value));10991100 if (type === 'NFT') {1101 expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal(to);1102 }1103 if (type === 'Fungible') {1104 const balanceAfter = await getBalance(api, collectionId, to, tokenId);1105 if (JSON.stringify(to) !== JSON.stringify(from)) {1106 expect(balanceAfter - balanceBefore).to.be.equal(BigInt(value));1107 } else {1108 expect(balanceAfter).to.be.equal(balanceBefore);1109 }1110 }1111 if (type === 'ReFungible') {1112 expect(await getBalance(api, collectionId, to, tokenId) >= value).to.be.true;1113 }1114 });1115}11161117export async function1118transferExpectFailure(1119 collectionId: number,1120 tokenId: number,1121 sender: IKeyringPair,1122 recipient: IKeyringPair | CrossAccountId,1123 value: number | bigint = 1,1124) {1125 await usingApi(async (api: ApiPromise) => {1126 const transferTx = api.tx.unique.transfer(normalizeAccountId(recipient), collectionId, tokenId, value);1127 const events = await expect(submitTransactionExpectFailAsync(sender, transferTx)).to.be.rejected;1128 const result = getGenericResult(events);1129 // if (events && Array.isArray(events)) {1130 // const result = getCreateCollectionResult(events);1131 // tslint:disable-next-line:no-unused-expression1132 expect(result.success).to.be.false;1133 //}1134 });1135}11361137export async function1138approveExpectFail(1139 collectionId: number,1140 tokenId: number, owner: IKeyringPair, approved: IKeyringPair, amount: number | bigint = 1,1141) {1142 await usingApi(async (api: ApiPromise) => {1143 const approveUniqueTx = api.tx.unique.approve(normalizeAccountId(approved.address), collectionId, tokenId, amount);1144 const events = await expect(submitTransactionExpectFailAsync(owner, approveUniqueTx)).to.be.rejected;1145 const result = getCreateCollectionResult(events);1146 // tslint:disable-next-line:no-unused-expression1147 expect(result.success).to.be.false;1148 });1149}11501151export async function getBalance(1152 api: ApiPromise,1153 collectionId: number,1154 owner: string | CrossAccountId,1155 token: number,1156): Promise<bigint> {1157 return (await api.rpc.unique.balance(collectionId, normalizeAccountId(owner), token)).toBigInt();1158}1159export async function getTokenOwner(1160 api: ApiPromise,1161 collectionId: number,1162 token: number,1163): Promise<CrossAccountId> {1164 const owner = (await api.rpc.unique.tokenOwner(collectionId, token)).toJSON() as any;1165 if (owner == null) throw new Error('owner == null');1166 return normalizeAccountId(owner);1167}1168export async function getTopmostTokenOwner(1169 api: ApiPromise,1170 collectionId: number,1171 token: number,1172): Promise<CrossAccountId> {1173 const owner = (await api.rpc.unique.topmostTokenOwner(collectionId, token)).toJSON() as any;1174 if (owner == null) throw new Error('owner == null');1175 return normalizeAccountId(owner);1176}1177export async function getTokenChildren(1178 api: ApiPromise,1179 collectionId: number,1180 tokenId: number,1181): Promise<UpDataStructsTokenChild[]> {1182 return (await api.rpc.unique.tokenChildren(collectionId, tokenId)).toJSON() as any;1183}1184export async function isTokenExists(1185 api: ApiPromise,1186 collectionId: number,1187 token: number,1188): Promise<boolean> {1189 return (await api.rpc.unique.tokenExists(collectionId, token)).toJSON();1190}1191export async function getLastTokenId(1192 api: ApiPromise,1193 collectionId: number,1194): Promise<number> {1195 return (await api.rpc.unique.lastTokenId(collectionId)).toJSON();1196}1197export async function getAdminList(1198 api: ApiPromise,1199 collectionId: number,1200): Promise<string[]> {1201 return (await api.rpc.unique.adminlist(collectionId)).toHuman() as any;1202}1203export async function getTokenProperties(1204 api: ApiPromise,1205 collectionId: number,1206 tokenId: number,1207 propertyKeys: string[],1208): Promise<UpDataStructsProperty[]> {1209 return (await api.rpc.unique.tokenProperties(collectionId, tokenId, propertyKeys)).toHuman() as any;1210}12111212export async function createFungibleItemExpectSuccess(1213 sender: IKeyringPair,1214 collectionId: number,1215 data: CreateFungibleData,1216 owner: CrossAccountId | string = sender.address,1217) {1218 return await usingApi(async (api) => {1219 const tx = api.tx.unique.createItem(collectionId, normalizeAccountId(owner), {Fungible: data});12201221 const events = await submitTransactionAsync(sender, tx);1222 const result = getCreateItemResult(events);12231224 expect(result.success).to.be.true;1225 return result.itemId;1226 });1227}12281229export async function createMultipleItemsWithPropsExpectSuccess(sender: IKeyringPair, collectionId: number, itemsData: any, owner: CrossAccountId | string = sender.address) {1230 await usingApi(async (api) => {1231 const to = normalizeAccountId(owner);1232 const tx = api.tx.unique.createMultipleItems(collectionId, to, itemsData);12331234 const events = await submitTransactionAsync(sender, tx);1235 const result = getCreateItemsResult(events);12361237 for (const res of result) {1238 expect(await api.rpc.unique.tokenProperties(collectionId, res.itemId)).not.to.be.empty;1239 }1240 });1241}12421243export async function createMultipleItemsExWithPropsExpectSuccess(sender: IKeyringPair, collectionId: number, itemsData: any) {1244 await usingApi(async (api) => {1245 const tx = api.tx.unique.createMultipleItemsEx(collectionId, itemsData);12461247 const events = await submitTransactionAsync(sender, tx);1248 const result = getCreateItemsResult(events);12491250 for (const res of result) {1251 expect(await api.rpc.unique.tokenProperties(collectionId, res.itemId)).not.to.be.empty;1252 }1253 });1254}12551256export async function createItemWithPropsExpectSuccess(sender: IKeyringPair, collectionId: number, createMode: string, props: Array<Property>, owner: CrossAccountId | string = sender.address) {1257 let newItemId = 0;1258 await usingApi(async (api) => {1259 const to = normalizeAccountId(owner);1260 const itemCountBefore = await getLastTokenId(api, collectionId);1261 const itemBalanceBefore = await getBalance(api, collectionId, to, newItemId);12621263 let tx;1264 if (createMode === 'Fungible') {1265 const createData = {fungible: {value: 10}};1266 tx = api.tx.unique.createItem(collectionId, to, createData as any);1267 } else if (createMode === 'ReFungible') {1268 const createData = {refungible: {pieces: 100}};1269 tx = api.tx.unique.createItem(collectionId, to, createData as any);1270 } else {1271 const data = api.createType('UpDataStructsCreateItemData', {NFT: {properties: props}});1272 tx = api.tx.unique.createItem(collectionId, to, data as UpDataStructsCreateItemData);1273 }12741275 const events = await submitTransactionAsync(sender, tx);1276 const result = getCreateItemResult(events);12771278 const itemCountAfter = await getLastTokenId(api, collectionId);1279 const itemBalanceAfter = await getBalance(api, collectionId, to, newItemId);12801281 if (createMode === 'NFT') {1282 expect(await api.rpc.unique.tokenProperties(collectionId, result.itemId)).not.to.be.empty;1283 }12841285 // What to expect1286 // tslint:disable-next-line:no-unused-expression1287 expect(result.success).to.be.true;1288 if (createMode === 'Fungible') {1289 expect(itemBalanceAfter - itemBalanceBefore).to.be.equal(10n);1290 } else {1291 expect(itemCountAfter).to.be.equal(itemCountBefore + 1);1292 }1293 expect(collectionId).to.be.equal(result.collectionId);1294 expect(itemCountAfter.toString()).to.be.equal(result.itemId.toString());1295 expect(to).to.be.deep.equal(result.recipient);1296 newItemId = result.itemId;1297 });1298 return newItemId;1299}13001301export async function createItemWithPropsExpectFailure(sender: IKeyringPair, collectionId: number, createMode: string, props: Array<Property>, owner: CrossAccountId | string = sender.address) {1302 await usingApi(async (api) => {13031304 let tx;1305 if (createMode === 'NFT') {1306 const data = api.createType('UpDataStructsCreateItemData', {NFT: {properties: props}});1307 tx = api.tx.unique.createItem(collectionId, normalizeAccountId(owner), data);1308 } else {1309 tx = api.tx.unique.createItem(collectionId, normalizeAccountId(owner), createMode);1310 }131113121313 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;1314 if(events.message && events.message.toString().indexOf('1002: Verification Error') > -1) return;1315 const result = getCreateItemResult(events);13161317 expect(result.success).to.be.false;1318 });1319}13201321export async function createItemExpectSuccess(sender: IKeyringPair, collectionId: number, createMode: string, owner: CrossAccountId | string = sender.address) {1322 let newItemId = 0;1323 await usingApi(async (api) => {1324 const to = normalizeAccountId(owner);1325 const itemCountBefore = await getLastTokenId(api, collectionId);1326 const itemBalanceBefore = await getBalance(api, collectionId, to, newItemId);13271328 let tx;1329 if (createMode === 'Fungible') {1330 const createData = {fungible: {value: 10}};1331 tx = api.tx.unique.createItem(collectionId, to, createData as any);1332 } else if (createMode === 'ReFungible') {1333 const createData = {refungible: {pieces: 100}};1334 tx = api.tx.unique.createItem(collectionId, to, createData as any);1335 } else {1336 const createData = {nft: {}};1337 tx = api.tx.unique.createItem(collectionId, to, createData as any);1338 }13391340 const events = await submitTransactionAsync(sender, tx);1341 const result = getCreateItemResult(events);13421343 const itemCountAfter = await getLastTokenId(api, collectionId);1344 const itemBalanceAfter = await getBalance(api, collectionId, to, newItemId);13451346 // What to expect1347 // tslint:disable-next-line:no-unused-expression1348 expect(result.success).to.be.true;1349 if (createMode === 'Fungible') {1350 expect(itemBalanceAfter - itemBalanceBefore).to.be.equal(10n);1351 } else {1352 expect(itemCountAfter).to.be.equal(itemCountBefore + 1);1353 }1354 expect(collectionId).to.be.equal(result.collectionId);1355 expect(itemCountAfter.toString()).to.be.equal(result.itemId.toString());1356 expect(to).to.be.deep.equal(result.recipient);1357 newItemId = result.itemId;1358 });1359 return newItemId;1360}13611362export async function createItemExpectFailure(sender: IKeyringPair, collectionId: number, createMode: string, owner: CrossAccountId | string = sender.address) {1363 await usingApi(async (api) => {1364 const tx = api.tx.unique.createItem(collectionId, normalizeAccountId(owner), createMode);13651366 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;1367 const result = getCreateItemResult(events);13681369 expect(result.success).to.be.false;1370 });1371}13721373export async function setPublicAccessModeExpectSuccess(1374 sender: IKeyringPair, collectionId: number,1375 accessMode: 'Normal' | 'AllowList',1376) {1377 await usingApi(async (api) => {13781379 // Run the transaction1380 const tx = api.tx.unique.setCollectionPermissions(collectionId, {access: accessMode});1381 const events = await submitTransactionAsync(sender, tx);1382 const result = getGenericResult(events);13831384 // Get the collection1385 const collection = await queryCollectionExpectSuccess(api, collectionId);13861387 // What to expect1388 // tslint:disable-next-line:no-unused-expression1389 expect(result.success).to.be.true;1390 expect(collection.permissions.access.toHuman()).to.be.equal(accessMode);1391 });1392}13931394export async function setPublicAccessModeExpectFail(1395 sender: IKeyringPair, collectionId: number,1396 accessMode: 'Normal' | 'AllowList',1397) {1398 await usingApi(async (api) => {13991400 // Run the transaction1401 const tx = api.tx.unique.setCollectionPermissions(collectionId, {access: accessMode});1402 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;1403 const result = getGenericResult(events);14041405 // What to expect1406 // tslint:disable-next-line:no-unused-expression1407 expect(result.success).to.be.false;1408 });1409}14101411export async function enableAllowListExpectSuccess(sender: IKeyringPair, collectionId: number) {1412 await setPublicAccessModeExpectSuccess(sender, collectionId, 'AllowList');1413}14141415export async function enableAllowListExpectFail(sender: IKeyringPair, collectionId: number) {1416 await setPublicAccessModeExpectFail(sender, collectionId, 'AllowList');1417}14181419export async function disableAllowListExpectSuccess(sender: IKeyringPair, collectionId: number) {1420 await setPublicAccessModeExpectSuccess(sender, collectionId, 'Normal');1421}14221423export async function setMintPermissionExpectSuccess(sender: IKeyringPair, collectionId: number, enabled: boolean) {1424 await usingApi(async (api) => {14251426 // Run the transaction1427 const tx = api.tx.unique.setCollectionPermissions(collectionId, {mintMode: enabled});1428 const events = await submitTransactionAsync(sender, tx);1429 const result = getGenericResult(events);1430 expect(result.success).to.be.true;14311432 // Get the collection1433 const collection = await queryCollectionExpectSuccess(api, collectionId);14341435 expect(collection.permissions.mintMode.toHuman()).to.be.equal(enabled);1436 });1437}14381439export async function enablePublicMintingExpectSuccess(sender: IKeyringPair, collectionId: number) {1440 await setMintPermissionExpectSuccess(sender, collectionId, true);1441}14421443export async function setMintPermissionExpectFailure(sender: IKeyringPair, collectionId: number, enabled: boolean) {1444 await usingApi(async (api) => {1445 // Run the transaction1446 const tx = api.tx.unique.setCollectionPermissions(collectionId, {mintMode: enabled});1447 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;1448 const result = getCreateCollectionResult(events);1449 // tslint:disable-next-line:no-unused-expression1450 expect(result.success).to.be.false;1451 });1452}14531454export async function setChainLimitsExpectFailure(sender: IKeyringPair, limits: IChainLimits) {1455 await usingApi(async (api) => {1456 // Run the transaction1457 const tx = api.tx.unique.setChainLimits(limits);1458 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;1459 const result = getCreateCollectionResult(events);1460 // tslint:disable-next-line:no-unused-expression1461 expect(result.success).to.be.false;1462 });1463}14641465export async function isAllowlisted(api: ApiPromise, collectionId: number, address: string | CrossAccountId) {1466 return (await api.rpc.unique.allowed(collectionId, normalizeAccountId(address))).toJSON();1467}14681469export async function addToAllowListExpectSuccess(sender: IKeyringPair, collectionId: number, address: string | AccountId | CrossAccountId) {1470 await usingApi(async (api) => {1471 expect(await isAllowlisted(api, collectionId, normalizeAccountId(address))).to.be.false;14721473 // Run the transaction1474 const tx = api.tx.unique.addToAllowList(collectionId, normalizeAccountId(address));1475 const events = await submitTransactionAsync(sender, tx);1476 const result = getGenericResult(events);1477 expect(result.success).to.be.true;14781479 expect(await isAllowlisted(api, collectionId, normalizeAccountId(address))).to.be.true;1480 });1481}14821483export async function addToAllowListAgainExpectSuccess(sender: IKeyringPair, collectionId: number, address: string | AccountId) {1484 await usingApi(async (api) => {14851486 expect(await isAllowlisted(api, collectionId, normalizeAccountId(address))).to.be.true;14871488 // Run the transaction1489 const tx = api.tx.unique.addToAllowList(collectionId, normalizeAccountId(address));1490 const events = await submitTransactionAsync(sender, tx);1491 const result = getGenericResult(events);1492 expect(result.success).to.be.true;14931494 expect(await isAllowlisted(api, collectionId, normalizeAccountId(address))).to.be.true;1495 });1496}14971498export async function addToAllowListExpectFail(sender: IKeyringPair, collectionId: number, address: string | AccountId) {1499 await usingApi(async (api) => {15001501 // Run the transaction1502 const tx = api.tx.unique.addToAllowList(collectionId, normalizeAccountId(address));1503 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;1504 const result = getGenericResult(events);15051506 // What to expect1507 // tslint:disable-next-line:no-unused-expression1508 expect(result.success).to.be.false;1509 });1510}15111512export async function removeFromAllowListExpectSuccess(sender: IKeyringPair, collectionId: number, address: CrossAccountId) {1513 await usingApi(async (api) => {1514 // Run the transaction1515 const tx = api.tx.unique.removeFromAllowList(collectionId, normalizeAccountId(address));1516 const events = await submitTransactionAsync(sender, tx);1517 const result = getGenericResult(events);15181519 // What to expect1520 // tslint:disable-next-line:no-unused-expression1521 expect(result.success).to.be.true;1522 });1523}15241525export async function removeFromAllowListExpectFailure(sender: IKeyringPair, collectionId: number, address: CrossAccountId) {1526 await usingApi(async (api) => {1527 // Run the transaction1528 const tx = api.tx.unique.removeFromAllowList(collectionId, normalizeAccountId(address));1529 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;1530 const result = getGenericResult(events);15311532 // What to expect1533 // tslint:disable-next-line:no-unused-expression1534 expect(result.success).to.be.false;1535 });1536}15371538export const getDetailedCollectionInfo = async (api: ApiPromise, collectionId: number)1539 : Promise<UpDataStructsRpcCollection | null> => {1540 return (await api.rpc.unique.collectionById(collectionId)).unwrapOr(null);1541};15421543export const getCreatedCollectionCount = async (api: ApiPromise): Promise<number> => {1544 // set global object - collectionsCount1545 return (await api.rpc.unique.collectionStats()).created.toNumber();1546};15471548export async function queryCollectionExpectSuccess(api: ApiPromise, collectionId: number): Promise<UpDataStructsRpcCollection> {1549 return (await api.rpc.unique.collectionById(collectionId)).unwrap();1550}15511552export async function waitNewBlocks(blocksCount = 1): Promise<void> {1553 await usingApi(async (api) => {1554 const promise = new Promise<void>(async (resolve) => {1555 const unsubscribe = await api.rpc.chain.subscribeNewHeads(() => {1556 if (blocksCount > 0) {1557 blocksCount--;1558 } else {1559 unsubscribe();1560 resolve();1561 }1562 });1563 });1564 return promise;1565 });1566}