difftreelog
Merge pull request #387 from UniqueNetwork/refactor/set-token-property-permissions
in: master
19 files changed
pallets/common/src/lib.rsdiffbeforeafterboth--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -1019,7 +1019,7 @@
}
#[transactional]
- pub fn set_property_permissions(
+ pub fn set_token_property_permissions(
collection: &CollectionHandle<T>,
sender: &T::CrossAccountId,
property_permissions: Vec<PropertyKeyPermission>,
@@ -1239,7 +1239,7 @@
fn delete_collection_properties(amount: u32) -> Weight;
fn set_token_properties(amount: u32) -> Weight;
fn delete_token_properties(amount: u32) -> Weight;
- fn set_property_permissions(amount: u32) -> Weight;
+ fn set_token_property_permissions(amount: u32) -> Weight;
fn transfer() -> Weight;
fn approve() -> Weight;
fn transfer_from() -> Weight;
@@ -1318,7 +1318,7 @@
token_id: TokenId,
property_keys: Vec<PropertyKey>,
) -> DispatchResultWithPostInfo;
- fn set_property_permissions(
+ fn set_token_property_permissions(
&self,
sender: &T::CrossAccountId,
property_permissions: Vec<PropertyKeyPermission>,
pallets/fungible/src/common.rsdiffbeforeafterboth--- a/pallets/fungible/src/common.rs
+++ b/pallets/fungible/src/common.rs
@@ -72,7 +72,7 @@
0
}
- fn set_property_permissions(_amount: u32) -> Weight {
+ fn set_token_property_permissions(_amount: u32) -> Weight {
// Error
0
}
@@ -302,7 +302,7 @@
fail!(<Error<T>>::SettingPropertiesNotAllowed)
}
- fn set_property_permissions(
+ fn set_token_property_permissions(
&self,
_sender: &T::CrossAccountId,
_property_permissions: Vec<PropertyKeyPermission>,
pallets/nonfungible/src/benchmarking.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/benchmarking.rs
+++ b/pallets/nonfungible/src/benchmarking.rs
@@ -147,7 +147,7 @@
<Pallet<T>>::set_allowance(&collection, &sender, item, Some(&burner))?;
}: {<Pallet<T>>::burn_from(&collection, &burner, &sender, item, &Unlimited)?}
- set_property_permissions {
+ set_token_property_permissions {
let b in 0..MAX_PROPERTIES_PER_ITEM;
bench_init!{
owner: sub; collection: collection(owner);
@@ -161,7 +161,7 @@
token_owner: false,
},
}).collect::<Vec<_>>();
- }: {<Pallet<T>>::set_property_permissions(&collection, &owner, perms)?}
+ }: {<Pallet<T>>::set_token_property_permissions(&collection, &owner, perms)?}
set_token_properties {
let b in 0..MAX_PROPERTIES_PER_ITEM;
@@ -177,7 +177,7 @@
token_owner: true,
},
}).collect::<Vec<_>>();
- <Pallet<T>>::set_property_permissions(&collection, &owner, perms)?;
+ <Pallet<T>>::set_token_property_permissions(&collection, &owner, perms)?;
let props = (0..b).map(|k| Property {
key: property_key(k as usize),
value: property_value(),
@@ -199,7 +199,7 @@
token_owner: true,
},
}).collect::<Vec<_>>();
- <Pallet<T>>::set_property_permissions(&collection, &owner, perms)?;
+ <Pallet<T>>::set_token_property_permissions(&collection, &owner, perms)?;
let props = (0..b).map(|k| Property {
key: property_key(k as usize),
value: property_value(),
pallets/nonfungible/src/common.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/common.rs
+++ b/pallets/nonfungible/src/common.rs
@@ -89,8 +89,8 @@
<SelfWeightOf<T>>::delete_token_properties(amount)
}
- fn set_property_permissions(amount: u32) -> Weight {
- <SelfWeightOf<T>>::set_property_permissions(amount)
+ fn set_token_property_permissions(amount: u32) -> Weight {
+ <SelfWeightOf<T>>::set_token_property_permissions(amount)
}
fn transfer() -> Weight {
@@ -242,16 +242,16 @@
)
}
- fn set_property_permissions(
+ fn set_token_property_permissions(
&self,
sender: &T::CrossAccountId,
property_permissions: Vec<PropertyKeyPermission>,
) -> DispatchResultWithPostInfo {
let weight =
- <CommonWeights<T>>::set_property_permissions(property_permissions.len() as u32);
+ <CommonWeights<T>>::set_token_property_permissions(property_permissions.len() as u32);
with_weight(
- <Pallet<T>>::set_property_permissions(self, sender, property_permissions),
+ <Pallet<T>>::set_token_property_permissions(self, sender, property_permissions),
weight,
)
}
pallets/nonfungible/src/lib.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/lib.rs
+++ b/pallets/nonfungible/src/lib.rs
@@ -594,12 +594,12 @@
<PalletCommon<T>>::delete_collection_properties(collection, sender, property_keys)
}
- pub fn set_property_permissions(
+ pub fn set_token_property_permissions(
collection: &CollectionHandle<T>,
sender: &T::CrossAccountId,
property_permissions: Vec<PropertyKeyPermission>,
) -> DispatchResult {
- <PalletCommon<T>>::set_property_permissions(collection, sender, property_permissions)
+ <PalletCommon<T>>::set_token_property_permissions(collection, sender, property_permissions)
}
pub fn set_property_permission(
pallets/nonfungible/src/weights.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/weights.rs
+++ b/pallets/nonfungible/src/weights.rs
@@ -42,7 +42,7 @@
fn approve() -> Weight;
fn transfer_from() -> Weight;
fn burn_from() -> Weight;
- fn set_property_permissions(b: u32) -> Weight;
+ fn set_token_property_permissions(b: u32) -> Weight;
fn set_token_properties(b: u32) -> Weight;
fn delete_token_properties(b: u32) -> Weight;
}
@@ -159,7 +159,7 @@
.saturating_add(T::DbWeight::get().writes(5 as Weight))
}
// Storage: Common CollectionPropertyPermissions (r:1 w:1)
- fn set_property_permissions(b: u32, ) -> Weight {
+ fn set_token_property_permissions(b: u32, ) -> Weight {
(0 as Weight)
// Standard Error: 3_432_000
.saturating_add((126_888_000 as Weight).saturating_mul(b as Weight))
@@ -299,7 +299,7 @@
.saturating_add(RocksDbWeight::get().writes(5 as Weight))
}
// Storage: Common CollectionPropertyPermissions (r:1 w:1)
- fn set_property_permissions(b: u32, ) -> Weight {
+ fn set_token_property_permissions(b: u32, ) -> Weight {
(0 as Weight)
// Standard Error: 3_432_000
.saturating_add((126_888_000 as Weight).saturating_mul(b as Weight))
pallets/refungible/src/common.rsdiffbeforeafterboth--- a/pallets/refungible/src/common.rs
+++ b/pallets/refungible/src/common.rs
@@ -85,8 +85,8 @@
<SelfWeightOf<T>>::delete_token_properties(amount)
}
- fn set_property_permissions(amount: u32) -> Weight {
- <SelfWeightOf<T>>::set_property_permissions(amount)
+ fn set_token_property_permissions(amount: u32) -> Weight {
+ <SelfWeightOf<T>>::set_token_property_permissions(amount)
}
fn transfer() -> Weight {
@@ -315,7 +315,7 @@
fail!(<Error<T>>::SettingPropertiesNotAllowed)
}
- fn set_property_permissions(
+ fn set_token_property_permissions(
&self,
_sender: &T::CrossAccountId,
_property_permissions: Vec<PropertyKeyPermission>,
pallets/refungible/src/weights.rsdiffbeforeafterboth--- a/pallets/refungible/src/weights.rs
+++ b/pallets/refungible/src/weights.rs
@@ -40,7 +40,7 @@
fn burn_item_fully() -> Weight;
fn set_token_properties(amount: u32) -> Weight;
fn delete_token_properties(amount: u32) -> Weight;
- fn set_property_permissions(amount: u32) -> Weight;
+ fn set_token_property_permissions(amount: u32) -> Weight;
fn transfer_normal() -> Weight;
fn transfer_creating() -> Weight;
fn transfer_removing() -> Weight;
@@ -142,7 +142,7 @@
0
}
- fn set_property_permissions(_amount: u32) -> Weight {
+ fn set_token_property_permissions(_amount: u32) -> Weight {
// Error
0
}
@@ -320,7 +320,7 @@
0
}
- fn set_property_permissions(_amount: u32) -> Weight {
+ fn set_token_property_permissions(_amount: u32) -> Weight {
// Error
0
}
pallets/unique/src/lib.rsdiffbeforeafterboth--- a/pallets/unique/src/lib.rs
+++ b/pallets/unique/src/lib.rs
@@ -670,9 +670,9 @@
dispatch_tx::<T, _>(collection_id, |d| d.delete_token_properties(sender, token_id, property_keys))
}
- #[weight = T::CommonWeightInfo::set_property_permissions(property_permissions.len() as u32)]
+ #[weight = T::CommonWeightInfo::set_token_property_permissions(property_permissions.len() as u32)]
#[transactional]
- pub fn set_property_permissions(
+ pub fn set_token_property_permissions(
origin,
collection_id: CollectionId,
property_permissions: Vec<PropertyKeyPermission>,
@@ -681,7 +681,7 @@
let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
- dispatch_tx::<T, _>(collection_id, |d| d.set_property_permissions(&sender, property_permissions))
+ dispatch_tx::<T, _>(collection_id, |d| d.set_token_property_permissions(&sender, property_permissions))
}
#[weight = T::CommonWeightInfo::create_multiple_items_ex(&data)]
runtime/common/src/weights.rsdiffbeforeafterboth--- a/runtime/common/src/weights.rs
+++ b/runtime/common/src/weights.rs
@@ -70,8 +70,8 @@
dispatch_weight::<T>() + max_weight_of!(delete_token_properties(amount))
}
- fn set_property_permissions(amount: u32) -> Weight {
- dispatch_weight::<T>() + max_weight_of!(set_property_permissions(amount))
+ fn set_token_property_permissions(amount: u32) -> Weight {
+ dispatch_weight::<T>() + max_weight_of!(set_token_property_permissions(amount))
}
fn transfer() -> Weight {
tests/src/createMultipleItems.test.tsdiffbeforeafterboth--- a/tests/src/createMultipleItems.test.ts
+++ b/tests/src/createMultipleItems.test.ts
@@ -48,7 +48,7 @@
const alice = privateKeyWrapper('//Alice');
await submitTransactionAsync(
alice,
- api.tx.unique.setPropertyPermissions(collectionId, [{key: 'data', permission: {tokenOwner: true}}]),
+ api.tx.unique.setTokenPropertyPermissions(collectionId, [{key: 'data', permission: {tokenOwner: true}}]),
);
const args = [
@@ -470,7 +470,7 @@
const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
- const tx1 = api.tx.unique.setPropertyPermissions(collectionId, propPerms);
+ const tx1 = api.tx.unique.setTokenPropertyPermissions(collectionId, propPerms);
await expect(executeTransaction(api, alice, tx1)).to.be.rejectedWith(/common\.PropertyLimitReached/);
const itemsListIndexBefore = await getLastTokenId(api, collectionId);
tests/src/createMultipleItemsEx.test.tsdiffbeforeafterboth--- a/tests/src/createMultipleItemsEx.test.ts
+++ b/tests/src/createMultipleItemsEx.test.ts
@@ -222,7 +222,7 @@
const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
await usingApi(async (api, privateKeyWrapper) => {
const alice = privateKeyWrapper('//Alice');
- await expect(executeTransaction(api, alice, api.tx.unique.setPropertyPermissions(collection, propPerms))).to.be.rejectedWith(/common\.PropertyLimitReached/);
+ await expect(executeTransaction(api, alice, api.tx.unique.setTokenPropertyPermissions(collection, propPerms))).to.be.rejectedWith(/common\.PropertyLimitReached/);
});
});
tests/src/eth/tokenProperties.test.tsdiffbeforeafterboth--- a/tests/src/eth/tokenProperties.test.ts
+++ b/tests/src/eth/tokenProperties.test.ts
@@ -29,7 +29,7 @@
const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
const token = await createItemExpectSuccess(alice, collection, 'NFT');
- await executeTransaction(api, alice, api.tx.unique.setPropertyPermissions(collection, [{
+ await executeTransaction(api, alice, api.tx.unique.setTokenPropertyPermissions(collection, [{
key: 'testKey',
permission: {
collectionAdmin: true,
@@ -52,7 +52,7 @@
const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
const token = await createItemExpectSuccess(alice, collection, 'NFT');
- await executeTransaction(api, alice, api.tx.unique.setPropertyPermissions(collection, [{
+ await executeTransaction(api, alice, api.tx.unique.setTokenPropertyPermissions(collection, [{
key: 'testKey',
permission: {
mutable: true,
@@ -77,7 +77,7 @@
const collection = await createCollectionExpectSuccess({mode: {type:'NFT'}});
const token = await createItemExpectSuccess(alice, collection, 'NFT');
- await executeTransaction(api, alice, api.tx.unique.setPropertyPermissions(collection, [{
+ await executeTransaction(api, alice, api.tx.unique.setTokenPropertyPermissions(collection, [{
key: 'testKey',
permission: {
collectionAdmin: true,
tests/src/interfaces/augment-api-tx.tsdiffbeforeafterboth--- a/tests/src/interfaces/augment-api-tx.ts
+++ b/tests/src/interfaces/augment-api-tx.ts
@@ -974,8 +974,8 @@
* * new_sponsor.
**/
setCollectionSponsor: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, newSponsor: AccountId32 | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, AccountId32]>;
- setPropertyPermissions: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, propertyPermissions: Vec<UpDataStructsPropertyKeyPermission> | (UpDataStructsPropertyKeyPermission | { key?: any; permission?: any } | string | Uint8Array)[]) => SubmittableExtrinsic<ApiType>, [u32, Vec<UpDataStructsPropertyKeyPermission>]>;
setTokenProperties: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, tokenId: u32 | AnyNumber | Uint8Array, properties: Vec<UpDataStructsProperty> | (UpDataStructsProperty | { key?: any; value?: any } | string | Uint8Array)[]) => SubmittableExtrinsic<ApiType>, [u32, u32, Vec<UpDataStructsProperty>]>;
+ setTokenPropertyPermissions: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, propertyPermissions: Vec<UpDataStructsPropertyKeyPermission> | (UpDataStructsPropertyKeyPermission | { key?: any; permission?: any } | string | Uint8Array)[]) => SubmittableExtrinsic<ApiType>, [u32, Vec<UpDataStructsPropertyKeyPermission>]>;
/**
* Set transfers_enabled value for particular collection
*
tests/src/interfaces/default/types.tsdiffbeforeafterboth--- a/tests/src/interfaces/default/types.ts
+++ b/tests/src/interfaces/default/types.ts
@@ -1690,8 +1690,8 @@
readonly tokenId: u32;
readonly propertyKeys: Vec<Bytes>;
} & Struct;
- readonly isSetPropertyPermissions: boolean;
- readonly asSetPropertyPermissions: {
+ readonly isSetTokenPropertyPermissions: boolean;
+ readonly asSetTokenPropertyPermissions: {
readonly collectionId: u32;
readonly propertyPermissions: Vec<UpDataStructsPropertyKeyPermission>;
} & Struct;
@@ -1750,7 +1750,7 @@
readonly collectionId: u32;
readonly newLimit: UpDataStructsCollectionPermissions;
} & Struct;
- readonly type: 'CreateCollection' | 'CreateCollectionEx' | 'DestroyCollection' | 'AddToAllowList' | 'RemoveFromAllowList' | 'ChangeCollectionOwner' | 'AddCollectionAdmin' | 'RemoveCollectionAdmin' | 'SetCollectionSponsor' | 'ConfirmSponsorship' | 'RemoveCollectionSponsor' | 'CreateItem' | 'CreateMultipleItems' | 'SetCollectionProperties' | 'DeleteCollectionProperties' | 'SetTokenProperties' | 'DeleteTokenProperties' | 'SetPropertyPermissions' | 'CreateMultipleItemsEx' | 'SetTransfersEnabledFlag' | 'BurnItem' | 'BurnFrom' | 'Transfer' | 'Approve' | 'TransferFrom' | 'SetCollectionLimits' | 'SetCollectionPermissions';
+ readonly type: 'CreateCollection' | 'CreateCollectionEx' | 'DestroyCollection' | 'AddToAllowList' | 'RemoveFromAllowList' | 'ChangeCollectionOwner' | 'AddCollectionAdmin' | 'RemoveCollectionAdmin' | 'SetCollectionSponsor' | 'ConfirmSponsorship' | 'RemoveCollectionSponsor' | 'CreateItem' | 'CreateMultipleItems' | 'SetCollectionProperties' | 'DeleteCollectionProperties' | 'SetTokenProperties' | 'DeleteTokenProperties' | 'SetTokenPropertyPermissions' | 'CreateMultipleItemsEx' | 'SetTransfersEnabledFlag' | 'BurnItem' | 'BurnFrom' | 'Transfer' | 'Approve' | 'TransferFrom' | 'SetCollectionLimits' | 'SetCollectionPermissions';
}
/** @name PalletUniqueError */
tests/src/interfaces/lookup.tsdiffbeforeafterboth--- a/tests/src/interfaces/lookup.ts
+++ b/tests/src/interfaces/lookup.ts
@@ -1313,7 +1313,7 @@
tokenId: 'u32',
propertyKeys: 'Vec<Bytes>',
},
- set_property_permissions: {
+ set_token_property_permissions: {
collectionId: 'u32',
propertyPermissions: 'Vec<UpDataStructsPropertyKeyPermission>',
},
tests/src/interfaces/types-lookup.tsdiffbeforeafterboth--- a/tests/src/interfaces/types-lookup.ts
+++ b/tests/src/interfaces/types-lookup.ts
@@ -1438,8 +1438,8 @@
readonly tokenId: u32;
readonly propertyKeys: Vec<Bytes>;
} & Struct;
- readonly isSetPropertyPermissions: boolean;
- readonly asSetPropertyPermissions: {
+ readonly isSetTokenPropertyPermissions: boolean;
+ readonly asSetTokenPropertyPermissions: {
readonly collectionId: u32;
readonly propertyPermissions: Vec<UpDataStructsPropertyKeyPermission>;
} & Struct;
@@ -1498,7 +1498,7 @@
readonly collectionId: u32;
readonly newLimit: UpDataStructsCollectionPermissions;
} & Struct;
- readonly type: 'CreateCollection' | 'CreateCollectionEx' | 'DestroyCollection' | 'AddToAllowList' | 'RemoveFromAllowList' | 'ChangeCollectionOwner' | 'AddCollectionAdmin' | 'RemoveCollectionAdmin' | 'SetCollectionSponsor' | 'ConfirmSponsorship' | 'RemoveCollectionSponsor' | 'CreateItem' | 'CreateMultipleItems' | 'SetCollectionProperties' | 'DeleteCollectionProperties' | 'SetTokenProperties' | 'DeleteTokenProperties' | 'SetPropertyPermissions' | 'CreateMultipleItemsEx' | 'SetTransfersEnabledFlag' | 'BurnItem' | 'BurnFrom' | 'Transfer' | 'Approve' | 'TransferFrom' | 'SetCollectionLimits' | 'SetCollectionPermissions';
+ readonly type: 'CreateCollection' | 'CreateCollectionEx' | 'DestroyCollection' | 'AddToAllowList' | 'RemoveFromAllowList' | 'ChangeCollectionOwner' | 'AddCollectionAdmin' | 'RemoveCollectionAdmin' | 'SetCollectionSponsor' | 'ConfirmSponsorship' | 'RemoveCollectionSponsor' | 'CreateItem' | 'CreateMultipleItems' | 'SetCollectionProperties' | 'DeleteCollectionProperties' | 'SetTokenProperties' | 'DeleteTokenProperties' | 'SetTokenPropertyPermissions' | 'CreateMultipleItemsEx' | 'SetTransfersEnabledFlag' | 'BurnItem' | 'BurnFrom' | 'Transfer' | 'Approve' | 'TransferFrom' | 'SetCollectionLimits' | 'SetCollectionPermissions';
}
/** @name UpDataStructsCollectionMode (156) */
tests/src/nesting/properties.test.tsdiffbeforeafterboth--- a/tests/src/nesting/properties.test.ts
+++ b/tests/src/nesting/properties.test.ts
@@ -38,7 +38,7 @@
await expect(executeTransaction(
api,
alice,
- api.tx.unique.setPropertyPermissions(collectionId, propertyPermissions),
+ api.tx.unique.setTokenPropertyPermissions(collectionId, propertyPermissions),
)).to.not.be.rejected;
const collectionProperties = [
@@ -362,7 +362,7 @@
await expect(executeTransaction(
api,
alice,
- api.tx.unique.setPropertyPermissions(collection, [{key: 'skullduggery', permission: {mutable: true}}]),
+ api.tx.unique.setTokenPropertyPermissions(collection, [{key: 'skullduggery', permission: {mutable: true}}]),
)).to.not.be.rejected;
await addCollectionAdminExpectSuccess(alice, collection, bob.address);
@@ -370,7 +370,7 @@
await expect(executeTransaction(
api,
alice,
- api.tx.unique.setPropertyPermissions(collection, [{key: 'mindgame', permission: {collectionAdmin: true, tokenOwner: false}}]),
+ api.tx.unique.setTokenPropertyPermissions(collection, [{key: 'mindgame', permission: {collectionAdmin: true, tokenOwner: false}}]),
)).to.not.be.rejected;
const propertyRights = (await api.rpc.unique.propertyPermissions(collection, ['skullduggery', 'mindgame'])).toHuman();
@@ -388,13 +388,13 @@
await expect(executeTransaction(
api,
alice,
- api.tx.unique.setPropertyPermissions(collection, [{key: 'skullduggery', permission: {mutable: true, collectionAdmin: true}}]),
+ api.tx.unique.setTokenPropertyPermissions(collection, [{key: 'skullduggery', permission: {mutable: true, collectionAdmin: true}}]),
)).to.not.be.rejected;
await expect(executeTransaction(
api,
alice,
- api.tx.unique.setPropertyPermissions(collection, [{key: 'skullduggery', permission: {mutable: false, tokenOwner: true}}]),
+ api.tx.unique.setTokenPropertyPermissions(collection, [{key: 'skullduggery', permission: {mutable: false, tokenOwner: true}}]),
)).to.not.be.rejected;
const propertyRights = (await api.rpc.unique.propertyPermissions(collection, ['skullduggery'])).toHuman();
@@ -420,7 +420,7 @@
await expect(executeTransaction(
api,
bob,
- api.tx.unique.setPropertyPermissions(collection, [{key: 'skullduggery', permission: {mutable: true, tokenOwner: true}}]),
+ api.tx.unique.setTokenPropertyPermissions(collection, [{key: 'skullduggery', permission: {mutable: true, tokenOwner: true}}]),
)).to.be.rejectedWith(/common\.NoPermission/);
const propertyRights = (await api.rpc.unique.propertyPermissions(collection, ['skullduggery'])).toJSON();
@@ -443,7 +443,7 @@
await expect(executeTransaction(
api,
alice,
- api.tx.unique.setPropertyPermissions(collection, constitution),
+ api.tx.unique.setTokenPropertyPermissions(collection, constitution),
)).to.be.rejectedWith(/common\.PropertyLimitReached/);
const propertyRights = (await api.query.common.collectionPropertyPermissions(collection)).toJSON();
@@ -458,13 +458,13 @@
await expect(executeTransaction(
api,
alice,
- api.tx.unique.setPropertyPermissions(collection, [{key: 'skullduggery', permission: {mutable: false, tokenOwner: true}}]),
+ api.tx.unique.setTokenPropertyPermissions(collection, [{key: 'skullduggery', permission: {mutable: false, tokenOwner: true}}]),
)).to.not.be.rejected;
await expect(executeTransaction(
api,
alice,
- api.tx.unique.setPropertyPermissions(collection, [{key: 'skullduggery', permission: {}}]),
+ api.tx.unique.setTokenPropertyPermissions(collection, [{key: 'skullduggery', permission: {}}]),
)).to.be.rejectedWith(/common\.NoPermission/);
const propertyRights = (await api.rpc.unique.propertyPermissions(collection, ['skullduggery'])).toHuman();
@@ -488,21 +488,21 @@
await expect(executeTransaction(
api,
alice,
- api.tx.unique.setPropertyPermissions(collection, invalidProperties[i]),
+ api.tx.unique.setTokenPropertyPermissions(collection, invalidProperties[i]),
), `on setting the new badly-named property #${i}`).to.be.rejectedWith(/common\.InvalidCharacterInPropertyKey/);
}
await expect(executeTransaction(
api,
alice,
- api.tx.unique.setPropertyPermissions(collection, [{key: '', permission: {}}]),
+ api.tx.unique.setTokenPropertyPermissions(collection, [{key: '', permission: {}}]),
), 'on rejecting an unnamed property').to.be.rejectedWith(/common\.EmptyPropertyKey/);
const correctKey = '--0x03116e387820CA05'; // PolkadotJS would parse this as an already encoded hex-string
await expect(executeTransaction(
api,
alice,
- api.tx.unique.setPropertyPermissions(collection, [
+ api.tx.unique.setTokenPropertyPermissions(collection, [
{key: correctKey, permission: {collectionAdmin: true}},
]),
), 'on setting the correctly-but-still-badly-named property').to.not.be.rejected;
@@ -576,7 +576,7 @@
await expect(executeTransaction(
api,
alice,
- api.tx.unique.setPropertyPermissions(collection, [{key: key, permission: permission.permission}]),
+ api.tx.unique.setTokenPropertyPermissions(collection, [{key: key, permission: permission.permission}]),
), `on setting permission ${i} by ${signer.address}`).to.not.be.rejected;
await expect(executeTransaction(
@@ -612,7 +612,7 @@
await expect(executeTransaction(
api,
alice,
- api.tx.unique.setPropertyPermissions(collection, [{key: key, permission: permission.permission}]),
+ api.tx.unique.setTokenPropertyPermissions(collection, [{key: key, permission: permission.permission}]),
), `on setting permission ${i} by ${signer.address}`).to.not.be.rejected;
await expect(executeTransaction(
@@ -655,7 +655,7 @@
await expect(executeTransaction(
api,
alice,
- api.tx.unique.setPropertyPermissions(collection, [{key: key, permission: permission.permission}]),
+ api.tx.unique.setTokenPropertyPermissions(collection, [{key: key, permission: permission.permission}]),
), `on setting permission ${i} by ${signer.address}`).to.not.be.rejected;
await expect(executeTransaction(
@@ -721,7 +721,7 @@
await expect(executeTransaction(
api,
alice,
- api.tx.unique.setPropertyPermissions(collection, [{key: `${i}`, permission: passage.permission}]),
+ api.tx.unique.setTokenPropertyPermissions(collection, [{key: `${i}`, permission: passage.permission}]),
), `on setting permission ${i} by ${signer.address}`).to.not.be.rejected;
await expect(executeTransaction(
@@ -798,7 +798,7 @@
await expect(executeTransaction(
api,
alice,
- api.tx.unique.setPropertyPermissions(collection, [{key: 'now-existent', permission: {}}]),
+ api.tx.unique.setTokenPropertyPermissions(collection, [{key: 'now-existent', permission: {}}]),
), 'on setting a new non-permitted property').to.not.be.rejected;
await expect(executeTransaction(
@@ -818,7 +818,7 @@
await expect(executeTransaction(
api,
alice,
- api.tx.unique.setPropertyPermissions(collection, [
+ api.tx.unique.setTokenPropertyPermissions(collection, [
{key: 'a_holy_book', permission: {collectionAdmin: true, tokenOwner: true}},
{key: 'young_years', permission: {collectionAdmin: true, tokenOwner: true}},
]),
tests/src/rmrk/rmrk.test.tsdiffbeforeafterboth1import {expect} from 'chai';2import privateKey from '../substrate/privateKey';3import usingApi, {executeTransaction} from '../substrate/substrate-api';4import {5 createCollectionExpectSuccess,6 createItemExpectSuccess,7 getCreateCollectionResult,8 getDetailedCollectionInfo,9 getGenericResult,10 normalizeAccountId,11} from '../util/helpers';12import {IKeyringPair} from '@polkadot/types/types';13import {ApiPromise} from '@polkadot/api';14import {it} from 'mocha';1516let alice: IKeyringPair;17let bob: IKeyringPair;1819async function createRmrkCollection(api: ApiPromise, sender: IKeyringPair): Promise<{uniqueId: number, rmrkId: number}> {20 const tx = api.tx.rmrkCore.createCollection('metadata', null, 'symbol');21 const events = await executeTransaction(api, sender, tx);2223 const uniqueResult = getCreateCollectionResult(events);24 const rmrkResult = getGenericResult(events, 'rmrkCore', 'CollectionCreated', (data) => {25 return parseInt(data[1].toString(), 10);26 });2728 return {29 uniqueId: uniqueResult.collectionId,30 rmrkId: rmrkResult.data!,31 };32}3334async function createRmrkNft(api: ApiPromise, sender: IKeyringPair, collectionId: number): Promise<number> {35 const tx = api.tx.rmrkCore.mintNft(36 sender.address,37 collectionId,38 sender.address,39 null,40 'nft-metadata',41 true,42 null,43 );44 const events = await executeTransaction(api, sender, tx);45 const result = getGenericResult(events, 'rmrkCore', 'NftMinted', (data) => {46 return parseInt(data[2].toString(), 10);47 });4849 return result.data!;50}5152async function isUnique(): Promise<boolean> {53 return usingApi(async api => {54 const chain = await api.rpc.system.chain();5556 return chain.eq('UNIQUE');57 });58}5960describe('RMRK External Integration Test', async () => {61 const it_rmrk = (await isUnique() ? it : it.skip);6263 before(async () => {64 await usingApi(async (api, privateKeyWrapper) => {65 alice = privateKeyWrapper('//Alice');6667 68 });69 });7071 it_rmrk('Creates a new RMRK collection that is mapped to a different ID and is tagged as external', async () => {72 await usingApi(async api => {73 // throwaway collection to bump last Unique collection ID to test ID mapping74 await createCollectionExpectSuccess();7576 const collectionIds = await createRmrkCollection(api, alice);7778 expect(collectionIds.rmrkId).to.be.lessThan(collectionIds.uniqueId, 'collection ID mapping');7980 const collection = (await getDetailedCollectionInfo(api, collectionIds.uniqueId))!;81 expect(collection.readOnly.toHuman(), 'tagged external').to.be.true;82 });83 });84});8586describe('Negative Integration Test: External Collections, Internal Ops', async () => {87 let uniqueCollectionId: number;88 let rmrkCollectionId: number;89 let rmrkNftId: number;9091 const it_rmrk = (await isUnique() ? it : it.skip);9293 before(async () => {94 await usingApi(async (api, privateKeyWrapper) => {95 alice = privateKeyWrapper('//Alice');96 bob = privateKeyWrapper('//Bob');9798 const collectionIds = await createRmrkCollection(api, alice);99 uniqueCollectionId = collectionIds.uniqueId;100 rmrkCollectionId = collectionIds.rmrkId;101102 rmrkNftId = await createRmrkNft(api, alice, rmrkCollectionId);103 });104 });105106 it_rmrk('[Negative] Forbids Unique operations with an external collection, handled by dispatch_call', async () => {107 await usingApi(async api => {108 // Collection item creation109110 const txCreateItem = api.tx.unique.createItem(uniqueCollectionId, normalizeAccountId(alice), 'NFT');111 await expect(executeTransaction(api, alice, txCreateItem), 'creating item')112 .to.be.rejectedWith(/common\.CollectionIsExternal/);113114 const txCreateMultipleItems = api.tx.unique.createMultipleItems(uniqueCollectionId, normalizeAccountId(alice), [{NFT: {}}, {NFT: {}}]);115 await expect(executeTransaction(api, alice, txCreateMultipleItems), 'creating multiple')116 .to.be.rejectedWith(/common\.CollectionIsExternal/);117118 const txCreateMultipleItemsEx = api.tx.unique.createMultipleItemsEx(uniqueCollectionId, {NFT: [{}]});119 await expect(executeTransaction(api, alice, txCreateMultipleItemsEx), 'creating multiple ex')120 .to.be.rejectedWith(/common\.CollectionIsExternal/);121122 // Collection properties123124 const txSetCollectionProperties = api.tx.unique.setCollectionProperties(uniqueCollectionId, [{key: 'a', value: '1'}, {key: 'b'}]);125 await expect(executeTransaction(api, alice, txSetCollectionProperties), 'setting collection properties')126 .to.be.rejectedWith(/common\.CollectionIsExternal/);127128 const txDeleteCollectionProperties = api.tx.unique.deleteCollectionProperties(uniqueCollectionId, ['a']);129 await expect(executeTransaction(api, alice, txDeleteCollectionProperties), 'deleting collection properties')130 .to.be.rejectedWith(/common\.CollectionIsExternal/);131132 const txSetPropertyPermissions = api.tx.unique.setPropertyPermissions(uniqueCollectionId, [{key: 'a', permission: {mutable: true}}]);133 await expect(executeTransaction(api, alice, txSetPropertyPermissions), 'setting property permissions')134 .to.be.rejectedWith(/common\.CollectionIsExternal/);135136 // NFT137138 const txBurn = api.tx.unique.burnItem(uniqueCollectionId, rmrkNftId, 1);139 await expect(executeTransaction(api, alice, txBurn), 'burning').to.be.rejectedWith(/common\.CollectionIsExternal/);140141 const txBurnFrom = api.tx.unique.burnFrom(uniqueCollectionId, normalizeAccountId(alice), rmrkNftId, 1);142 await expect(executeTransaction(api, alice, txBurnFrom), 'burning-from').to.be.rejectedWith(/common\.CollectionIsExternal/);143144 const txTransfer = api.tx.unique.transfer(normalizeAccountId(bob), uniqueCollectionId, rmrkNftId, 1);145 await expect(executeTransaction(api, alice, txTransfer), 'transferring').to.be.rejectedWith(/common\.CollectionIsExternal/);146147 const txApprove = api.tx.unique.approve(normalizeAccountId(bob), uniqueCollectionId, rmrkNftId, 1);148 await expect(executeTransaction(api, alice, txApprove), 'approving').to.be.rejectedWith(/common\.CollectionIsExternal/);149150 const txTransferFrom = api.tx.unique.transferFrom(normalizeAccountId(alice), normalizeAccountId(bob), uniqueCollectionId, rmrkNftId, 1);151 await expect(executeTransaction(api, alice, txTransferFrom), 'transferring-from').to.be.rejectedWith(/common\.CollectionIsExternal/);152153 // NFT properties154155 const txSetTokenProperties = api.tx.unique.setTokenProperties(uniqueCollectionId, rmrkNftId, [{key: 'a', value: '2'}]);156 await expect(executeTransaction(api, alice, txSetTokenProperties), 'setting token properties')157 .to.be.rejectedWith(/common\.CollectionIsExternal/);158159 const txDeleteTokenProperties = api.tx.unique.deleteTokenProperties(uniqueCollectionId, rmrkNftId, ['a']);160 await expect(executeTransaction(api, alice, txDeleteTokenProperties), 'deleting token properties')161 .to.be.rejectedWith(/common\.CollectionIsExternal/);162 });163 });164165 it_rmrk('[Negative] Forbids Unique collection operations with an external collection', async () => {166 await usingApi(async api => {167 const txDestroyCollection = api.tx.unique.destroyCollection(uniqueCollectionId);168 await expect(executeTransaction(api, alice, txDestroyCollection), 'destroying collection')169 .to.be.rejectedWith(/common\.CollectionIsExternal/);170171 // Allow list172173 const txAddAllowList = api.tx.unique.addToAllowList(uniqueCollectionId, normalizeAccountId(bob));174 await expect(executeTransaction(api, alice, txAddAllowList), 'adding to allow list')175 .to.be.rejectedWith(/common\.CollectionIsExternal/);176177 const txRemoveAllowList = api.tx.unique.removeFromAllowList(uniqueCollectionId, normalizeAccountId(bob));178 await expect(executeTransaction(api, alice, txRemoveAllowList), 'removing from allowlist')179 .to.be.rejectedWith(/common\.CollectionIsExternal/);180181 // Owner / Admin / Sponsor182183 const txChangeOwner = api.tx.unique.changeCollectionOwner(uniqueCollectionId, bob.address);184 await expect(executeTransaction(api, alice, txChangeOwner), 'changing owner')185 .to.be.rejectedWith(/common\.CollectionIsExternal/);186187 const txAddAdmin = api.tx.unique.addCollectionAdmin(uniqueCollectionId, normalizeAccountId(bob));188 await expect(executeTransaction(api, alice, txAddAdmin), 'adding admin')189 .to.be.rejectedWith(/common\.CollectionIsExternal/);190191 const txRemoveAdmin = api.tx.unique.removeCollectionAdmin(uniqueCollectionId, normalizeAccountId(bob));192 await expect(executeTransaction(api, alice, txRemoveAdmin), 'removing admin')193 .to.be.rejectedWith(/common\.CollectionIsExternal/);194195 const txAddCollectionSponsor = api.tx.unique.setCollectionSponsor(uniqueCollectionId, bob.address);196 await expect(executeTransaction(api, alice, txAddCollectionSponsor), 'setting sponsor')197 .to.be.rejectedWith(/common\.CollectionIsExternal/);198199 const txConfirmCollectionSponsor = api.tx.unique.confirmSponsorship(uniqueCollectionId);200 await expect(executeTransaction(api, alice, txConfirmCollectionSponsor), 'confirming sponsor')201 .to.be.rejectedWith(/common\.CollectionIsExternal/);202203 const txRemoveCollectionSponsor = api.tx.unique.removeCollectionSponsor(uniqueCollectionId);204 await expect(executeTransaction(api, alice, txRemoveCollectionSponsor), 'removing sponsor')205 .to.be.rejectedWith(/common\.CollectionIsExternal/);206 207 // Limits / permissions / transfers208209 const txSetTransfers = api.tx.unique.setTransfersEnabledFlag(uniqueCollectionId, true);210 await expect(executeTransaction(api, alice, txSetTransfers), 'setting transfers enabled flag')211 .to.be.rejectedWith(/common\.CollectionIsExternal/);212213 const txSetLimits = api.tx.unique.setCollectionLimits(uniqueCollectionId, {transfersEnabled: false});214 await expect(executeTransaction(api, alice, txSetLimits), 'setting collection limits')215 .to.be.rejectedWith(/common\.CollectionIsExternal/);216217 const txSetPermissions = api.tx.unique.setCollectionPermissions(uniqueCollectionId, {access: 'AllowList'});218 await expect(executeTransaction(api, alice, txSetPermissions), 'setting collection permissions')219 .to.be.rejectedWith(/common\.CollectionIsExternal/);220 });221 });222});223224describe('Negative Integration Test: Internal Collections, External Ops', async () => {225 let collectionId: number;226 let nftId: number;227228 const it_rmrk = (await isUnique() ? it : it.skip);229230 before(async () => {231 await usingApi(async (api, privateKeyWrapper) => {232 alice = privateKeyWrapper('//Alice');233 bob = privateKeyWrapper('//Bob');234235 collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});236 nftId = await createItemExpectSuccess(alice, collectionId, 'NFT');237 });238 });239240 it_rmrk('[Negative] Forbids RMRK operations with the internal collection and NFT (due to the lack of mapping)', async () => {241 await usingApi(async api => {242 const txChangeOwner = api.tx.rmrkCore.changeCollectionIssuer(collectionId, bob.address);243 await expect(executeTransaction(api, alice, txChangeOwner), 'changing collection issuer')244 .to.be.rejectedWith(/rmrkCore\.CollectionUnknown/);245246 const maxBurns = 10;247 const txBurnItem = api.tx.rmrkCore.burnNft(collectionId, nftId, maxBurns);248 await expect(executeTransaction(api, alice, txBurnItem), 'burning NFT').to.be.rejectedWith(/rmrkCore\.CollectionUnknown/);249 });250 });251});1import {expect} from 'chai';2import privateKey from '../substrate/privateKey';3import usingApi, {executeTransaction} from '../substrate/substrate-api';4import {5 createCollectionExpectSuccess,6 createItemExpectSuccess,7 getCreateCollectionResult,8 getDetailedCollectionInfo,9 getGenericResult,10 normalizeAccountId,11} from '../util/helpers';12import {IKeyringPair} from '@polkadot/types/types';13import {ApiPromise} from '@polkadot/api';14import {it} from 'mocha';1516let alice: IKeyringPair;17let bob: IKeyringPair;1819async function createRmrkCollection(api: ApiPromise, sender: IKeyringPair): Promise<{uniqueId: number, rmrkId: number}> {20 const tx = api.tx.rmrkCore.createCollection('metadata', null, 'symbol');21 const events = await executeTransaction(api, sender, tx);2223 const uniqueResult = getCreateCollectionResult(events);24 const rmrkResult = getGenericResult(events, 'rmrkCore', 'CollectionCreated', (data) => {25 return parseInt(data[1].toString(), 10);26 });2728 return {29 uniqueId: uniqueResult.collectionId,30 rmrkId: rmrkResult.data!,31 };32}3334async function createRmrkNft(api: ApiPromise, sender: IKeyringPair, collectionId: number): Promise<number> {35 const tx = api.tx.rmrkCore.mintNft(36 sender.address,37 collectionId,38 sender.address,39 null,40 'nft-metadata',41 true,42 null,43 );44 const events = await executeTransaction(api, sender, tx);45 const result = getGenericResult(events, 'rmrkCore', 'NftMinted', (data) => {46 return parseInt(data[2].toString(), 10);47 });4849 return result.data!;50}5152async function isUnique(): Promise<boolean> {53 return usingApi(async api => {54 const chain = await api.rpc.system.chain();5556 return chain.eq('UNIQUE');57 });58}5960describe('RMRK External Integration Test', async () => {61 const it_rmrk = (await isUnique() ? it : it.skip);6263 before(async () => {64 await usingApi(async (api, privateKeyWrapper) => {65 alice = privateKeyWrapper('//Alice');6667 68 });69 });7071 it_rmrk('Creates a new RMRK collection that is mapped to a different ID and is tagged as external', async () => {72 await usingApi(async api => {73 // throwaway collection to bump last Unique collection ID to test ID mapping74 await createCollectionExpectSuccess();7576 const collectionIds = await createRmrkCollection(api, alice);7778 expect(collectionIds.rmrkId).to.be.lessThan(collectionIds.uniqueId, 'collection ID mapping');7980 const collection = (await getDetailedCollectionInfo(api, collectionIds.uniqueId))!;81 expect(collection.readOnly.toHuman(), 'tagged external').to.be.true;82 });83 });84});8586describe('Negative Integration Test: External Collections, Internal Ops', async () => {87 let uniqueCollectionId: number;88 let rmrkCollectionId: number;89 let rmrkNftId: number;9091 const it_rmrk = (await isUnique() ? it : it.skip);9293 before(async () => {94 await usingApi(async (api, privateKeyWrapper) => {95 alice = privateKeyWrapper('//Alice');96 bob = privateKeyWrapper('//Bob');9798 const collectionIds = await createRmrkCollection(api, alice);99 uniqueCollectionId = collectionIds.uniqueId;100 rmrkCollectionId = collectionIds.rmrkId;101102 rmrkNftId = await createRmrkNft(api, alice, rmrkCollectionId);103 });104 });105106 it_rmrk('[Negative] Forbids Unique operations with an external collection, handled by dispatch_call', async () => {107 await usingApi(async api => {108 // Collection item creation109110 const txCreateItem = api.tx.unique.createItem(uniqueCollectionId, normalizeAccountId(alice), 'NFT');111 await expect(executeTransaction(api, alice, txCreateItem), 'creating item')112 .to.be.rejectedWith(/common\.CollectionIsExternal/);113114 const txCreateMultipleItems = api.tx.unique.createMultipleItems(uniqueCollectionId, normalizeAccountId(alice), [{NFT: {}}, {NFT: {}}]);115 await expect(executeTransaction(api, alice, txCreateMultipleItems), 'creating multiple')116 .to.be.rejectedWith(/common\.CollectionIsExternal/);117118 const txCreateMultipleItemsEx = api.tx.unique.createMultipleItemsEx(uniqueCollectionId, {NFT: [{}]});119 await expect(executeTransaction(api, alice, txCreateMultipleItemsEx), 'creating multiple ex')120 .to.be.rejectedWith(/common\.CollectionIsExternal/);121122 // Collection properties123124 const txSetCollectionProperties = api.tx.unique.setCollectionProperties(uniqueCollectionId, [{key: 'a', value: '1'}, {key: 'b'}]);125 await expect(executeTransaction(api, alice, txSetCollectionProperties), 'setting collection properties')126 .to.be.rejectedWith(/common\.CollectionIsExternal/);127128 const txDeleteCollectionProperties = api.tx.unique.deleteCollectionProperties(uniqueCollectionId, ['a']);129 await expect(executeTransaction(api, alice, txDeleteCollectionProperties), 'deleting collection properties')130 .to.be.rejectedWith(/common\.CollectionIsExternal/);131132 const txsetTokenPropertyPermissions = api.tx.unique.setTokenPropertyPermissions(uniqueCollectionId, [{key: 'a', permission: {mutable: true}}]);133 await expect(executeTransaction(api, alice, txsetTokenPropertyPermissions), 'setting property permissions')134 .to.be.rejectedWith(/common\.CollectionIsExternal/);135136 // NFT137138 const txBurn = api.tx.unique.burnItem(uniqueCollectionId, rmrkNftId, 1);139 await expect(executeTransaction(api, alice, txBurn), 'burning').to.be.rejectedWith(/common\.CollectionIsExternal/);140141 const txBurnFrom = api.tx.unique.burnFrom(uniqueCollectionId, normalizeAccountId(alice), rmrkNftId, 1);142 await expect(executeTransaction(api, alice, txBurnFrom), 'burning-from').to.be.rejectedWith(/common\.CollectionIsExternal/);143144 const txTransfer = api.tx.unique.transfer(normalizeAccountId(bob), uniqueCollectionId, rmrkNftId, 1);145 await expect(executeTransaction(api, alice, txTransfer), 'transferring').to.be.rejectedWith(/common\.CollectionIsExternal/);146147 const txApprove = api.tx.unique.approve(normalizeAccountId(bob), uniqueCollectionId, rmrkNftId, 1);148 await expect(executeTransaction(api, alice, txApprove), 'approving').to.be.rejectedWith(/common\.CollectionIsExternal/);149150 const txTransferFrom = api.tx.unique.transferFrom(normalizeAccountId(alice), normalizeAccountId(bob), uniqueCollectionId, rmrkNftId, 1);151 await expect(executeTransaction(api, alice, txTransferFrom), 'transferring-from').to.be.rejectedWith(/common\.CollectionIsExternal/);152153 // NFT properties154155 const txSetTokenProperties = api.tx.unique.setTokenProperties(uniqueCollectionId, rmrkNftId, [{key: 'a', value: '2'}]);156 await expect(executeTransaction(api, alice, txSetTokenProperties), 'setting token properties')157 .to.be.rejectedWith(/common\.CollectionIsExternal/);158159 const txDeleteTokenProperties = api.tx.unique.deleteTokenProperties(uniqueCollectionId, rmrkNftId, ['a']);160 await expect(executeTransaction(api, alice, txDeleteTokenProperties), 'deleting token properties')161 .to.be.rejectedWith(/common\.CollectionIsExternal/);162 });163 });164165 it_rmrk('[Negative] Forbids Unique collection operations with an external collection', async () => {166 await usingApi(async api => {167 const txDestroyCollection = api.tx.unique.destroyCollection(uniqueCollectionId);168 await expect(executeTransaction(api, alice, txDestroyCollection), 'destroying collection')169 .to.be.rejectedWith(/common\.CollectionIsExternal/);170171 // Allow list172173 const txAddAllowList = api.tx.unique.addToAllowList(uniqueCollectionId, normalizeAccountId(bob));174 await expect(executeTransaction(api, alice, txAddAllowList), 'adding to allow list')175 .to.be.rejectedWith(/common\.CollectionIsExternal/);176177 const txRemoveAllowList = api.tx.unique.removeFromAllowList(uniqueCollectionId, normalizeAccountId(bob));178 await expect(executeTransaction(api, alice, txRemoveAllowList), 'removing from allowlist')179 .to.be.rejectedWith(/common\.CollectionIsExternal/);180181 // Owner / Admin / Sponsor182183 const txChangeOwner = api.tx.unique.changeCollectionOwner(uniqueCollectionId, bob.address);184 await expect(executeTransaction(api, alice, txChangeOwner), 'changing owner')185 .to.be.rejectedWith(/common\.CollectionIsExternal/);186187 const txAddAdmin = api.tx.unique.addCollectionAdmin(uniqueCollectionId, normalizeAccountId(bob));188 await expect(executeTransaction(api, alice, txAddAdmin), 'adding admin')189 .to.be.rejectedWith(/common\.CollectionIsExternal/);190191 const txRemoveAdmin = api.tx.unique.removeCollectionAdmin(uniqueCollectionId, normalizeAccountId(bob));192 await expect(executeTransaction(api, alice, txRemoveAdmin), 'removing admin')193 .to.be.rejectedWith(/common\.CollectionIsExternal/);194195 const txAddCollectionSponsor = api.tx.unique.setCollectionSponsor(uniqueCollectionId, bob.address);196 await expect(executeTransaction(api, alice, txAddCollectionSponsor), 'setting sponsor')197 .to.be.rejectedWith(/common\.CollectionIsExternal/);198199 const txConfirmCollectionSponsor = api.tx.unique.confirmSponsorship(uniqueCollectionId);200 await expect(executeTransaction(api, alice, txConfirmCollectionSponsor), 'confirming sponsor')201 .to.be.rejectedWith(/common\.CollectionIsExternal/);202203 const txRemoveCollectionSponsor = api.tx.unique.removeCollectionSponsor(uniqueCollectionId);204 await expect(executeTransaction(api, alice, txRemoveCollectionSponsor), 'removing sponsor')205 .to.be.rejectedWith(/common\.CollectionIsExternal/);206 207 // Limits / permissions / transfers208209 const txSetTransfers = api.tx.unique.setTransfersEnabledFlag(uniqueCollectionId, true);210 await expect(executeTransaction(api, alice, txSetTransfers), 'setting transfers enabled flag')211 .to.be.rejectedWith(/common\.CollectionIsExternal/);212213 const txSetLimits = api.tx.unique.setCollectionLimits(uniqueCollectionId, {transfersEnabled: false});214 await expect(executeTransaction(api, alice, txSetLimits), 'setting collection limits')215 .to.be.rejectedWith(/common\.CollectionIsExternal/);216217 const txSetPermissions = api.tx.unique.setCollectionPermissions(uniqueCollectionId, {access: 'AllowList'});218 await expect(executeTransaction(api, alice, txSetPermissions), 'setting collection permissions')219 .to.be.rejectedWith(/common\.CollectionIsExternal/);220 });221 });222});223224describe('Negative Integration Test: Internal Collections, External Ops', async () => {225 let collectionId: number;226 let nftId: number;227228 const it_rmrk = (await isUnique() ? it : it.skip);229230 before(async () => {231 await usingApi(async (api, privateKeyWrapper) => {232 alice = privateKeyWrapper('//Alice');233 bob = privateKeyWrapper('//Bob');234235 collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});236 nftId = await createItemExpectSuccess(alice, collectionId, 'NFT');237 });238 });239240 it_rmrk('[Negative] Forbids RMRK operations with the internal collection and NFT (due to the lack of mapping)', async () => {241 await usingApi(async api => {242 const txChangeOwner = api.tx.rmrkCore.changeCollectionIssuer(collectionId, bob.address);243 await expect(executeTransaction(api, alice, txChangeOwner), 'changing collection issuer')244 .to.be.rejectedWith(/rmrkCore\.CollectionUnknown/);245246 const maxBurns = 10;247 const txBurnItem = api.tx.rmrkCore.burnNft(collectionId, nftId, maxBurns);248 await expect(executeTransaction(api, alice, txBurnItem), 'burning NFT').to.be.rejectedWith(/rmrkCore\.CollectionUnknown/);249 });250 });251});