git.delta.rocks / unique-network / refs/commits / b995e58942f3

difftreelog

Merge pull request #112 from usetech-llc/feature/NFTPAR-308_limited_owners_control

Greg Zaitsev2021-02-26parents: #6ea0c80 #4bce10c.patch.diff
in: master
Limited owners control

7 files changed

modifiedpallets/nft/src/lib.rsdiffbeforeafterboth
--- a/pallets/nft/src/lib.rs
+++ b/pallets/nft/src/lib.rs
@@ -382,6 +382,8 @@
         AccountTokenLimitExceeded,
         /// Collection limit bounds per collection exceeded
         CollectionLimitBoundsExceeded,
+        /// Tried to enable permissions which are only permitted to be disabled
+        OwnerPermissionsCantBeReverted,
         /// Schema data size limit bound exceeded
         SchemaDataLimitExceeded,
         /// Maximum refungibility exceeded
@@ -639,6 +641,11 @@
             let sender = ensure_signed(origin)?;
             Self::check_owner_permissions(collection_id, sender)?;
 
+            let target_collection = <Collection<T>>::get(collection_id);
+            if !target_collection.limits.owner_can_destroy {
+                fail!(Error::<T>::NoPermission);
+            }
+
             <AddressTokens<T>>::remove_prefix(collection_id);
             <Allowances<T>>::remove_prefix(collection_id);
             <Balance<T>>::remove_prefix(collection_id);
@@ -1022,9 +1029,14 @@
 
             // Transfer permissions check
             let target_collection = <Collection<T>>::get(collection_id);
-            ensure!(Self::is_item_owner(sender.clone(), collection_id, item_id) ||
-                Self::is_owner_or_admin_permissions(collection_id, sender.clone()),
-                Error::<T>::NoPermission);
+            ensure!(
+                Self::is_item_owner(sender.clone(), collection_id, item_id) ||
+                (
+                    target_collection.limits.owner_can_transfer &&
+                    Self::is_owner_or_admin_permissions(collection_id, sender.clone())
+                ),
+                Error::<T>::NoPermission
+            );
 
             if target_collection.access == AccessMode::WhiteList {
                 Self::check_white_list(collection_id, &sender)?;
@@ -1098,9 +1110,14 @@
 
             // Transfer permissions check
             let target_collection = <Collection<T>>::get(collection_id);
-            ensure!(Self::is_item_owner(sender.clone(), collection_id, item_id) ||
-                Self::is_owner_or_admin_permissions(collection_id, sender.clone()),
-                Error::<T>::NoPermission);
+            ensure!(
+                Self::is_item_owner(sender.clone(), collection_id, item_id) ||
+                (
+                    target_collection.limits.owner_can_transfer &&
+                    Self::is_owner_or_admin_permissions(collection_id, sender.clone())
+                ),
+                Error::<T>::NoPermission
+            );
 
             if target_collection.access == AccessMode::WhiteList {
                 Self::check_white_list(collection_id, &sender)?;
@@ -1156,8 +1173,14 @@
             Self::is_correct_transfer(collection_id, &target_collection, &recipient)?;
 
             // Transfer permissions check         
-            ensure!(appoved_transfer || Self::is_owner_or_admin_permissions(collection_id, sender.clone()),
-                Error::<T>::NoPermission);
+            ensure!(
+                appoved_transfer || 
+                (
+                    target_collection.limits.owner_can_transfer &&
+                    Self::is_owner_or_admin_permissions(collection_id, sender.clone())
+                ),
+                Error::<T>::NoPermission
+            );
 
             if target_collection.access == AccessMode::WhiteList {
                 Self::check_white_list(collection_id, &sender)?;
@@ -1524,25 +1547,32 @@
         pub fn set_collection_limits(
             origin,
             collection_id: u32,
-            limits: CollectionLimits,
+            new_limits: CollectionLimits,
         ) -> DispatchResult {
             let sender = ensure_signed(origin)?;
             Self::check_owner_permissions(collection_id, sender.clone())?;
             let mut target_collection = <Collection<T>>::get(collection_id);
+            let old_limits = target_collection.limits;
             let chain_limits = ChainLimit::get();
-            let climits = target_collection.limits;
 
             // collection bounds
-            ensure!(limits.sponsor_transfer_timeout <= MAX_SPONSOR_TIMEOUT &&
-                limits.account_token_ownership_limit <= MAX_TOKEN_OWNERSHIP,  
+            ensure!(new_limits.sponsor_transfer_timeout <= MAX_SPONSOR_TIMEOUT &&
+                new_limits.account_token_ownership_limit <= MAX_TOKEN_OWNERSHIP && 
+                new_limits.sponsored_data_size <= chain_limits.custom_data_limit &&
+                new_limits.sponsored_mint_size <= chain_limits.custom_data_limit,
                 Error::<T>::CollectionLimitBoundsExceeded);
 
             // token_limit   check  prev
-            ensure!(climits.token_limit > limits.token_limit && 
-                limits.token_limit <= chain_limits.account_token_ownership_limit, 
-                Error::<T>::AccountTokenLimitExceeded);
+            ensure!(old_limits.token_limit >= new_limits.token_limit, Error::<T>::CollectionTokenLimitExceeded);
+            ensure!(new_limits.token_limit > 0, Error::<T>::CollectionTokenLimitExceeded);
 
-            target_collection.limits = limits;
+            ensure!(
+                (old_limits.owner_can_transfer || !new_limits.owner_can_transfer) &&
+                (old_limits.owner_can_destroy || !new_limits.owner_can_destroy),
+                Error::<T>::OwnerPermissionsCantBeReverted,
+            );
+
+            target_collection.limits = new_limits;
             <Collection<T>>::insert(collection_id, target_collection);
 
             Ok(())
modifiedtests/src/approve.test.tsdiffbeforeafterboth
before · tests/src/approve.test.ts
1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//5import { ApiPromise } from '@polkadot/api';6import BN from 'bn.js';7import chai from 'chai';8import chaiAsPromised from 'chai-as-promised';9import privateKey from './substrate/privateKey';10import { default as usingApi } from './substrate/substrate-api';11import {12  approveExpectFail,13  approveExpectSuccess,14  createCollectionExpectSuccess,15  createFungibleItemExpectSuccess,16  createItemExpectSuccess,17  destroyCollectionExpectSuccess,18  transferFromExpectSuccess,19  U128_MAX,20} from './util/helpers';2122chai.use(chaiAsPromised);23const expect = chai.expect;2425describe('Integration Test approve(spender, collection_id, item_id, amount):', () => {26  it('Execute the extrinsic and check approvedList', async () => {27    await usingApi(async (api: ApiPromise) => {28      const Alice = privateKey('//Alice');29      const Bob = privateKey('//Bob');30      const nftCollectionId = await createCollectionExpectSuccess();31      // nft32      const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');33      await approveExpectSuccess(nftCollectionId, newNftTokenId, Alice, Bob);34      // fungible35      const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});36      const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible');37      await approveExpectSuccess(fungibleCollectionId, newFungibleTokenId, Alice, Bob);38      // reFungible39      const reFungibleCollectionId =40        await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});41      const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');42      await approveExpectSuccess(reFungibleCollectionId, newReFungibleTokenId, Alice, Bob);43    });44  });4546  it('Remove approval by using 0 amount', async () => {47    await usingApi(async (api: ApiPromise) => {48      const Alice = privateKey('//Alice');49      const Bob = privateKey('//Bob');50      const nftCollectionId = await createCollectionExpectSuccess();51      // nft52      const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');53      await approveExpectSuccess(nftCollectionId, newNftTokenId, Alice, Bob, 1);54      await approveExpectSuccess(nftCollectionId, newNftTokenId, Alice, Bob, 0);55      // fungible56      const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});57      const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible');58      await approveExpectSuccess(fungibleCollectionId, newFungibleTokenId, Alice, Bob, 1);59      await approveExpectSuccess(fungibleCollectionId, newFungibleTokenId, Alice, Bob, 0);60      // reFungible61      const reFungibleCollectionId =62        await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});63      const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');64      await approveExpectSuccess(reFungibleCollectionId, newReFungibleTokenId, Alice, Bob, 1);65      await approveExpectSuccess(reFungibleCollectionId, newReFungibleTokenId, Alice, Bob, 0);66    });67  });68});6970describe('Negative Integration Test approve(spender, collection_id, item_id, amount):', () => {71  it('Approve for a collection that does not exist', async () => {72    await usingApi(async (api: ApiPromise) => {73      const Alice = privateKey('//Alice');74      const Bob = privateKey('//Bob');75      // nft76      const nftCollectionCount = await api.query.nft.createdCollectionCount() as unknown as number;77      await approveExpectFail(nftCollectionCount + 1, 1, Alice, Bob);78      // fungible79      const fungibleCollectionCount = await api.query.nft.createdCollectionCount() as unknown as number;80      await approveExpectFail(fungibleCollectionCount + 1, 1, Alice, Bob);81      // reFungible82      const reFungibleCollectionCount = await api.query.nft.createdCollectionCount() as unknown as number;83      await approveExpectFail(reFungibleCollectionCount + 1, 1, Alice, Bob);84    });85  });8687  it('Approve for a collection that was destroyed', async () => {88    await usingApi(async (api: ApiPromise) => {89      const Alice = privateKey('//Alice');90      const Bob = privateKey('//Bob');91      // nft92      const nftCollectionId = await createCollectionExpectSuccess();93      await destroyCollectionExpectSuccess(nftCollectionId);94      await approveExpectFail(nftCollectionId, 1, Alice, Bob);95      // fungible96      const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});97      await destroyCollectionExpectSuccess(fungibleCollectionId);98      await approveExpectFail(fungibleCollectionId, 1, Alice, Bob);99      // reFungible100      const reFungibleCollectionId =101        await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});102      await destroyCollectionExpectSuccess(reFungibleCollectionId);103      await approveExpectFail(reFungibleCollectionId, 1, Alice, Bob);104    });105  });106107  it('Approve transfer of a token that does not exist', async () => {108    await usingApi(async (api: ApiPromise) => {109      const Alice = privateKey('//Alice');110      const Bob = privateKey('//Bob');111      // nft112      const nftCollectionId = await createCollectionExpectSuccess();113      await approveExpectFail(nftCollectionId, 2, Alice, Bob);114      // fungible115      const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});116      await approveExpectFail(fungibleCollectionId, 2, Alice, Bob);117      // reFungible118      const reFungibleCollectionId =119        await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});120      await approveExpectFail(reFungibleCollectionId, 2, Alice, Bob);121    });122  });123124  it('Approve using the address that does not own the approved token', async () => {125    await usingApi(async (api: ApiPromise) => {126      const Alice = privateKey('//Alice');127      const Bob = privateKey('//Bob');128      const nftCollectionId = await createCollectionExpectSuccess();129      // nft130      const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');131      await approveExpectFail(nftCollectionId, newNftTokenId, Bob, Alice);132      // fungible133      const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});134      const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible');135      await approveExpectFail(fungibleCollectionId, newFungibleTokenId, Bob, Alice);136      // reFungible137      const reFungibleCollectionId =138        await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});139      const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');140      await approveExpectFail(reFungibleCollectionId, newReFungibleTokenId, Bob, Alice);141    });142  });143});
after · tests/src/approve.test.ts
1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//5import { ApiPromise } from '@polkadot/api';6import { IKeyringPair } from '@polkadot/types/types';7import BN from 'bn.js';8import chai from 'chai';9import chaiAsPromised from 'chai-as-promised';10import privateKey from './substrate/privateKey';11import { default as usingApi } from './substrate/substrate-api';12import {13  approveExpectFail,14  approveExpectSuccess,15  createCollectionExpectSuccess,16  createFungibleItemExpectSuccess,17  createItemExpectSuccess,18  destroyCollectionExpectSuccess,19  setCollectionLimitsExpectSuccess,20  transferFromExpectSuccess,21  U128_MAX,22} from './util/helpers';2324chai.use(chaiAsPromised);25const expect = chai.expect;2627describe('Integration Test approve(spender, collection_id, item_id, amount):', () => {28  let Alice: IKeyringPair;29  let Bob: IKeyringPair;30  let Charlie: IKeyringPair;3132  before(async () => {33    await usingApi(async (api) => {34      Alice = privateKey('//Alice');35      Bob = privateKey('//Bob');36      Charlie = privateKey('//Charlie');37    });38  });3940  it('Execute the extrinsic and check approvedList', async () => {41    await usingApi(async (api: ApiPromise) => {42      const nftCollectionId = await createCollectionExpectSuccess();43      // nft44      const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');45      await approveExpectSuccess(nftCollectionId, newNftTokenId, Alice, Bob);46      // fungible47      const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});48      const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible');49      await approveExpectSuccess(fungibleCollectionId, newFungibleTokenId, Alice, Bob);50      // reFungible51      const reFungibleCollectionId =52        await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});53      const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');54      await approveExpectSuccess(reFungibleCollectionId, newReFungibleTokenId, Alice, Bob);55    });56  });5758  it('Remove approval by using 0 amount', async () => {59    await usingApi(async (api: ApiPromise) => {60      const nftCollectionId = await createCollectionExpectSuccess();61      // nft62      const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');63      await approveExpectSuccess(nftCollectionId, newNftTokenId, Alice, Bob, 1);64      await approveExpectSuccess(nftCollectionId, newNftTokenId, Alice, Bob, 0);65      // fungible66      const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});67      const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible');68      await approveExpectSuccess(fungibleCollectionId, newFungibleTokenId, Alice, Bob, 1);69      await approveExpectSuccess(fungibleCollectionId, newFungibleTokenId, Alice, Bob, 0);70      // reFungible71      const reFungibleCollectionId =72        await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});73      const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');74      await approveExpectSuccess(reFungibleCollectionId, newReFungibleTokenId, Alice, Bob, 1);75      await approveExpectSuccess(reFungibleCollectionId, newReFungibleTokenId, Alice, Bob, 0);76    });77  });7879  it('can be called by collection owner on non-owned item when OwnerCanTransfer == true', async () => {80    const collectionId = await createCollectionExpectSuccess();81    const itemId = await createItemExpectSuccess(Alice, collectionId, 'NFT', Bob.address);8283    await approveExpectSuccess(collectionId, itemId, Alice, Charlie);84  });85});8687describe('Negative Integration Test approve(spender, collection_id, item_id, amount):', () => {88  let Alice: IKeyringPair;89  let Bob: IKeyringPair;90  let Charlie: IKeyringPair;9192  before(async () => {93    await usingApi(async (api) => {94      Alice = privateKey('//Alice');95      Bob = privateKey('//Bob');96      Charlie = privateKey('//Charlie');97    });98  });99100  it('Approve for a collection that does not exist', async () => {101    await usingApi(async (api: ApiPromise) => {102      // nft103      const nftCollectionCount = await api.query.nft.createdCollectionCount() as unknown as number;104      await approveExpectFail(nftCollectionCount + 1, 1, Alice, Bob);105      // fungible106      const fungibleCollectionCount = await api.query.nft.createdCollectionCount() as unknown as number;107      await approveExpectFail(fungibleCollectionCount + 1, 1, Alice, Bob);108      // reFungible109      const reFungibleCollectionCount = await api.query.nft.createdCollectionCount() as unknown as number;110      await approveExpectFail(reFungibleCollectionCount + 1, 1, Alice, Bob);111    });112  });113114  it('Approve for a collection that was destroyed', async () => {115    await usingApi(async (api: ApiPromise) => {116      // nft117      const nftCollectionId = await createCollectionExpectSuccess();118      await destroyCollectionExpectSuccess(nftCollectionId);119      await approveExpectFail(nftCollectionId, 1, Alice, Bob);120      // fungible121      const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});122      await destroyCollectionExpectSuccess(fungibleCollectionId);123      await approveExpectFail(fungibleCollectionId, 1, Alice, Bob);124      // reFungible125      const reFungibleCollectionId =126        await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});127      await destroyCollectionExpectSuccess(reFungibleCollectionId);128      await approveExpectFail(reFungibleCollectionId, 1, Alice, Bob);129    });130  });131132  it('Approve transfer of a token that does not exist', async () => {133    await usingApi(async (api: ApiPromise) => {134      // nft135      const nftCollectionId = await createCollectionExpectSuccess();136      await approveExpectFail(nftCollectionId, 2, Alice, Bob);137      // fungible138      const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});139      await approveExpectFail(fungibleCollectionId, 2, Alice, Bob);140      // reFungible141      const reFungibleCollectionId =142        await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});143      await approveExpectFail(reFungibleCollectionId, 2, Alice, Bob);144    });145  });146147  it('Approve using the address that does not own the approved token', async () => {148    await usingApi(async (api: ApiPromise) => {149      const nftCollectionId = await createCollectionExpectSuccess();150      // nft151      const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');152      await approveExpectFail(nftCollectionId, newNftTokenId, Bob, Alice);153      // fungible154      const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});155      const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible');156      await approveExpectFail(fungibleCollectionId, newFungibleTokenId, Bob, Alice);157      // reFungible158      const reFungibleCollectionId =159        await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});160      const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');161      await approveExpectFail(reFungibleCollectionId, newReFungibleTokenId, Bob, Alice);162    });163  });164165  it('fails when called by collection owner on non-owned item when OwnerCanTransfer == false', async () => {166    const collectionId = await createCollectionExpectSuccess();167    const itemId = await createItemExpectSuccess(Alice, collectionId, 'NFT', Bob.address);168    await setCollectionLimitsExpectSuccess(Alice, collectionId, { OwnerCanTransfer: false });169170    await approveExpectFail(collectionId, itemId, Alice, Charlie);171  });172});
modifiedtests/src/destroyCollection.test.tsdiffbeforeafterboth
--- a/tests/src/destroyCollection.test.ts
+++ b/tests/src/destroyCollection.test.ts
@@ -3,10 +3,12 @@
 // file 'LICENSE', which is part of this source code package.
 //
 
+import { IKeyringPair } from '@polkadot/types/types';
 import chai from 'chai';
 import chaiAsPromised from 'chai-as-promised';
+import privateKey from './substrate/privateKey';
 import { default as usingApi } from "./substrate/substrate-api";
-import { createCollectionExpectSuccess, destroyCollectionExpectSuccess, destroyCollectionExpectFailure } from "./util/helpers";
+import { createCollectionExpectSuccess, destroyCollectionExpectSuccess, destroyCollectionExpectFailure, setCollectionLimitsExpectSuccess } from "./util/helpers";
 
 chai.use(chaiAsPromised);
 
@@ -26,6 +28,14 @@
 });
 
 describe('(!negative test!) integration test: ext. destroyCollection():', () => {
+  let alice: IKeyringPair;
+
+  before(async () => {
+    await usingApi(async (api) => {
+      alice = privateKey('//Alice');
+    });
+  });
+
   it('(!negative test!) Destroy a collection that never existed', async () => {
     await usingApi(async (api) => {
       // Find the collection that never existed
@@ -43,4 +53,10 @@
     await destroyCollectionExpectFailure(collectionId, '//Bob');
     await destroyCollectionExpectSuccess(collectionId, '//Alice');
   });
+  it('fails when OwnerCanDestroy == false', async () => {
+    const collectionId = await createCollectionExpectSuccess();
+    await setCollectionLimitsExpectSuccess(alice, collectionId, { OwnerCanDestroy: false });
+
+    await destroyCollectionExpectFailure(collectionId, '//Alice');
+  });
 });
modifiedtests/src/setCollectionLimits.test.tsdiffbeforeafterboth
--- a/tests/src/setCollectionLimits.test.ts
+++ b/tests/src/setCollectionLimits.test.ts
@@ -14,6 +14,8 @@
   createCollectionExpectSuccess, getCreatedCollectionCount,
   getCreateItemResult,
   getDetailedCollectionInfo,
+  setCollectionLimitsExpectFailure,
+  setCollectionLimitsExpectSuccess,
 } from './util/helpers';
 
 chai.use(chaiAsPromised);
@@ -26,21 +28,8 @@
 const accountTokenOwnershipLimit = 0;
 const sponsoredDataSize = 0;
 const sponsoredMintSize = 0;
-const tokenLimit = 0;
-
-describe('hooks', () => {
-  before(async () => {
-    await usingApi(async () => {
-      const keyring = new Keyring({ type: 'sr25519' });
-      alice = keyring.addFromUri('//Alice');
-    });
-  });
-  it('choose or create collection for testing', async () => {
-    await usingApi(async () => {
-      collectionIdForTesting = await createCollectionExpectSuccess({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: 'NFT'}});
-    });
-  });
-});
+const sponsorTimeout = 1;
+const tokenLimit = 1;
 
 describe('setCollectionLimits positive', () => {
   let tx;
@@ -48,6 +37,7 @@
     await usingApi(async () => {
       const keyring = new Keyring({ type: 'sr25519' });
       alice = keyring.addFromUri('//Alice');
+      collectionIdForTesting = await createCollectionExpectSuccess({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: 'NFT'}});
     });
   });
   it('execute setCollectionLimits with predefined params ', async () => {
@@ -55,25 +45,28 @@
       tx = api.tx.nft.setCollectionLimits(
         collectionIdForTesting,
         {
-          accountTokenOwnershipLimit,
-          sponsoredDataSize,
-          sponsoredMintSize,
-          tokenLimit,
+          AccountTokenOwnershipLimit: accountTokenOwnershipLimit,
+          SponsoredMintSize: sponsoredDataSize,
+          TokenLimit: tokenLimit,
+          SponsorTimeout: sponsorTimeout,
+          OwnerCanTransfer: true,
+          OwnerCanDestroy: true
         },
       );
       const events = await submitTransactionAsync(alice, tx);
       const result = getCreateItemResult(events);
+
+      // get collection limits defined previously
+      const collectionInfo = await getDetailedCollectionInfo(api, collectionIdForTesting) as ICollectionInterface;
+
       // tslint:disable-next-line:no-unused-expression
       expect(result.success).to.be.true;
-    });
-  });
-  it('get collection limits defined in previous test', async () => {
-    await usingApi(async (api: ApiPromise) => {
-      const collectionInfo = await getDetailedCollectionInfo(api, collectionIdForTesting) as ICollectionInterface;
       expect(collectionInfo.Limits.AccountTokenOwnershipLimit.toNumber()).to.be.equal(accountTokenOwnershipLimit);
-      expect(collectionInfo.Limits.SponsoredMintSize.toNumber()).to.be.equal(sponsoredMintSize);
+      expect(collectionInfo.Limits.SponsoredMintSize.toNumber()).to.be.equal(sponsoredDataSize);
       expect(collectionInfo.Limits.TokenLimit.toNumber()).to.be.equal(tokenLimit);
-      expect(collectionInfo.Limits.SponsorTimeout.toNumber()).to.be.equal(sponsoredDataSize);
+      expect(collectionInfo.Limits.SponsorTimeout.toNumber()).to.be.equal(sponsorTimeout);
+      expect(collectionInfo.Limits.OwnerCanTransfer.valueOf()).to.be.true;
+      expect(collectionInfo.Limits.OwnerCanDestroy.valueOf()).to.be.true;
     });
   });
 });
@@ -85,6 +78,7 @@
       const keyring = new Keyring({ type: 'sr25519' });
       alice = keyring.addFromUri('//Alice');
       bob = keyring.addFromUri('//Bob');
+      collectionIdForTesting = await createCollectionExpectSuccess({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: 'NFT'}});
     });
   });
   it('execute setCollectionLimits for not exists collection', async () => {
@@ -131,4 +125,44 @@
       await expect(submitTransactionExpectFailAsync(alice, tx)).to.be.rejected;
     });
   });
+
+  it('fails when trying to enable OwnerCanTransfer after it was disabled', async () => {
+    const collectionId = await createCollectionExpectSuccess();
+    await setCollectionLimitsExpectSuccess(alice, collectionId, { 
+      AccountTokenOwnershipLimit: accountTokenOwnershipLimit,
+      SponsoredMintSize: sponsoredDataSize,
+      TokenLimit: tokenLimit,
+      SponsorTimeout: sponsorTimeout,
+      OwnerCanTransfer: false,
+      OwnerCanDestroy: true
+    });
+    await setCollectionLimitsExpectFailure(alice, collectionId, { 
+      AccountTokenOwnershipLimit: accountTokenOwnershipLimit,
+      SponsoredMintSize: sponsoredDataSize,
+      TokenLimit: tokenLimit,
+      SponsorTimeout: sponsorTimeout,
+      OwnerCanTransfer: true,
+      OwnerCanDestroy: true
+    });
+  });
+
+  it('fails when trying to enable OwnerCanDestroy after it was disabled', async () => {
+    const collectionId = await createCollectionExpectSuccess();
+    await setCollectionLimitsExpectSuccess(alice, collectionId, {
+      AccountTokenOwnershipLimit: accountTokenOwnershipLimit,
+      SponsoredMintSize: sponsoredDataSize,
+      TokenLimit: tokenLimit,
+      SponsorTimeout: sponsorTimeout,
+      OwnerCanTransfer: true,
+      OwnerCanDestroy: false
+    });
+    await setCollectionLimitsExpectFailure(alice, collectionId, { 
+      AccountTokenOwnershipLimit: accountTokenOwnershipLimit,
+      SponsoredMintSize: sponsoredDataSize,
+      TokenLimit: tokenLimit,
+      SponsorTimeout: sponsorTimeout,
+      OwnerCanTransfer: true,
+      OwnerCanDestroy: true
+    });
+  });
 });
modifiedtests/src/transferFrom.test.tsdiffbeforeafterboth
--- a/tests/src/transferFrom.test.ts
+++ b/tests/src/transferFrom.test.ts
@@ -3,6 +3,7 @@
 // file 'LICENSE', which is part of this source code package.
 //
 import { ApiPromise } from '@polkadot/api';
+import { IKeyringPair } from '@polkadot/types/types';
 import chai from 'chai';
 import chaiAsPromised from 'chai-as-promised';
 import privateKey from './substrate/privateKey';
@@ -18,17 +19,27 @@
   transferFromExpectFail,
   transferFromExpectSuccess,
   burnItemExpectSuccess,
+  setCollectionLimitsExpectSuccess,
 } from './util/helpers';
 
 chai.use(chaiAsPromised);
 const expect = chai.expect;
 
 describe('Integration Test transferFrom(from, recipient, collection_id, item_id, value):', () => {
+  let Alice: IKeyringPair;
+  let Bob: IKeyringPair;
+  let Charlie: IKeyringPair;
+
+  before(async () => {
+    await usingApi(async (api) => {
+      Alice = privateKey('//Alice');
+      Bob = privateKey('//Bob');
+      Charlie = privateKey('//Charlie');
+    });
+  });
+
   it('Execute the extrinsic and check nftItemList - owner of token', async () => {
     await usingApi(async (api: ApiPromise) => {
-      const Alice = privateKey('//Alice');
-      const Bob = privateKey('//Bob');
-      const Charlie = privateKey('//Charlie');
       // nft
       const nftCollectionId = await createCollectionExpectSuccess();
       const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
@@ -66,14 +77,30 @@
       expect((await getAllowance(fungibleCollectionId, newFungibleTokenId, alice.address, bob.address)).toString()).to.equal('0');
     });
   });
+
+  it('can be called by collection owner on non-owned item when OwnerCanTransfer == true', async () => {
+    const collectionId = await createCollectionExpectSuccess();
+    const itemId = await createItemExpectSuccess(Alice, collectionId, 'NFT', Bob.address);
+
+    await transferFromExpectSuccess(collectionId, itemId, Alice, Bob, Charlie);
+  });
 });
 
 describe('Negative Integration Test transferFrom(from, recipient, collection_id, item_id, value):', () => {
+  let Alice: IKeyringPair;
+  let Bob: IKeyringPair;
+  let Charlie: IKeyringPair;
+
+  before(async () => {
+    await usingApi(async (api) => {
+      Alice = privateKey('//Alice');
+      Bob = privateKey('//Bob');
+      Charlie = privateKey('//Charlie');
+    });
+  });
+
   it('transferFrom for a collection that does not exist', async () => {
     await usingApi(async (api: ApiPromise) => {
-      const Alice = privateKey('//Alice');
-      const Bob = privateKey('//Bob');
-      const Charlie = privateKey('//Charlie');
       // nft
       const nftCollectionCount = await api.query.nft.createdCollectionCount() as unknown as number;
       await approveExpectFail(nftCollectionCount + 1, 1, Alice, Bob);
@@ -113,9 +140,6 @@
 
   it('transferFrom for not approved address', async () => {
     await usingApi(async (api: ApiPromise) => {
-      const Alice = privateKey('//Alice');
-      const Bob = privateKey('//Bob');
-      const Charlie = privateKey('//Charlie');
       // nft
       const nftCollectionId = await createCollectionExpectSuccess();
       const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
@@ -137,9 +161,6 @@
 
   it('transferFrom incorrect token count', async () => {
     await usingApi(async (api: ApiPromise) => {
-      const Alice = privateKey('//Alice');
-      const Bob = privateKey('//Bob');
-      const Charlie = privateKey('//Charlie');
       // nft
       const nftCollectionId = await createCollectionExpectSuccess();
       const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
@@ -164,9 +185,6 @@
 
   it('execute transferFrom from account that is not owner of collection', async () => {
     await usingApi(async (api: ApiPromise) => {
-      const Alice = privateKey('//Alice');
-      const Bob = privateKey('//Bob');
-      const Charlie = privateKey('//Charlie');
       const Dave = privateKey('//Dave');
       // nft
       const nftCollectionId = await createCollectionExpectSuccess();
@@ -206,9 +224,6 @@
   });
   it( 'transferFrom burnt token before approve NFT', async () => {
     await usingApi(async (api: ApiPromise) => {
-      const Alice = privateKey('//Alice');
-      const Bob = privateKey('//Bob');
-      const Charlie = privateKey('//Charlie');
       // nft
       const nftCollectionId = await createCollectionExpectSuccess();
       const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
@@ -219,9 +234,6 @@
   });
   it( 'transferFrom burnt token before approve Fungible', async () => {
     await usingApi(async (api: ApiPromise) => {
-    const Alice = privateKey('//Alice');
-      const Bob = privateKey('//Bob');
-      const Charlie = privateKey('//Charlie');
       const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
       const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible');
       await burnItemExpectSuccess(Alice, fungibleCollectionId, 1, 10);
@@ -232,9 +244,6 @@
   }); 
   it( 'transferFrom burnt token before approve ReFungible', async () => {
     await usingApi(async (api: ApiPromise) => {
-    const Alice = privateKey('//Alice');
-      const Bob = privateKey('//Bob');
-      const Charlie = privateKey('//Charlie');
       const reFungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
       const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');
       await burnItemExpectSuccess(Alice, reFungibleCollectionId, newReFungibleTokenId, 1);
@@ -246,9 +255,6 @@
   
   it( 'transferFrom burnt token after approve NFT', async () => {
     await usingApi(async (api: ApiPromise) => {
-      const Alice = privateKey('//Alice');
-      const Bob = privateKey('//Bob');
-      const Charlie = privateKey('//Charlie');
       // nft
       const nftCollectionId = await createCollectionExpectSuccess();
       const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
@@ -259,9 +265,6 @@
   });
   it( 'transferFrom burnt token after approve Fungible', async () => {
     await usingApi(async (api: ApiPromise) => {
-    const Alice = privateKey('//Alice');
-      const Bob = privateKey('//Bob');
-      const Charlie = privateKey('//Charlie');
       const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
       const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible');
       await approveExpectSuccess(fungibleCollectionId, newFungibleTokenId, Alice, Bob);
@@ -272,9 +275,6 @@
   }); 
   it( 'transferFrom burnt token after approve ReFungible', async () => {
     await usingApi(async (api: ApiPromise) => {
-    const Alice = privateKey('//Alice');
-      const Bob = privateKey('//Bob');
-      const Charlie = privateKey('//Charlie');
       const reFungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
       const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');
       await approveExpectSuccess(reFungibleCollectionId, newReFungibleTokenId, Alice, Bob);
@@ -282,5 +282,13 @@
       await transferFromExpectFail(reFungibleCollectionId, newReFungibleTokenId, Bob, Alice, Charlie, 1);
           
     });
-  }); 
+  });
+
+  it('fails when 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 setCollectionLimitsExpectSuccess(Alice, collectionId, { OwnerCanTransfer: false });
+
+    await transferFromExpectFail(collectionId, itemId, Alice, Bob, Charlie);
+  });
 });
modifiedtests/src/types.tsdiffbeforeafterboth
--- a/tests/src/types.ts
+++ b/tests/src/types.ts
@@ -17,6 +17,8 @@
     SponsoredMintSize: BN;
     TokenLimit: BN;
     SponsorTimeout: BN;
+    OwnerCanTransfer: boolean;
+    OwnerCanDestroy: boolean;
   };
   MintMode: boolean;
   Mode: {
modifiedtests/src/util/helpers.tsdiffbeforeafterboth
--- a/tests/src/util/helpers.ts
+++ b/tests/src/util/helpers.ts
@@ -333,6 +333,36 @@
   });
 }
 
+export async function queryCollectionLimits(collectionId: number) {
+  return await usingApi(async (api) => {
+    return ((await api.query.nft.collection(collectionId)).toJSON() as any).Limits;
+  });
+}
+
+export async function setCollectionLimitsExpectSuccess(sender: IKeyringPair, collectionId: number, limits: any) {
+  await usingApi(async (api) => {
+    const oldLimits = await queryCollectionLimits(collectionId);
+    const newLimits = { ...oldLimits as any, ...limits };
+    const tx = api.tx.nft.setCollectionLimits(collectionId, newLimits);
+    const events = await submitTransactionAsync(sender, tx);
+    const result = getGenericResult(events);
+
+    expect(result.success).to.be.true;
+  });
+}
+
+export async function setCollectionLimitsExpectFailure(sender: IKeyringPair, collectionId: number, limits: any) {
+  await usingApi(async (api) => {
+    const oldLimits = await queryCollectionLimits(collectionId);
+    const newLimits = { ...oldLimits as any, ...limits };
+    const tx = api.tx.nft.setCollectionLimits(collectionId, newLimits);
+    const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;
+    const result = getGenericResult(events);
+
+    expect(result.success).to.be.false;
+  });
+}
+
 export async function setCollectionSponsorExpectSuccess(collectionId: number, sponsor: string) {
   await usingApi(async (api) => {