difftreelog
Code style and format
in: master
10 files changed
pallets/nft/src/lib.rsdiffbeforeafterboth--- a/pallets/nft/src/lib.rs
+++ b/pallets/nft/src/lib.rs
@@ -946,7 +946,7 @@
let mut target_collection = Self::get_collection(collection_id)?;
Self::check_owner_permissions(&target_collection, &sender)?;
-
+
target_collection.transfers_enabled = value;
Self::save_collection(target_collection);
@@ -1607,10 +1607,7 @@
);
// preliminary transfer check
- ensure!(
- collection.transfers_enabled,
- Error::<T>::TransferNotAllowed
- );
+ ensure!(collection.transfers_enabled, Error::<T>::TransferNotAllowed);
Ok(())
}
pallets/nft/src/tests.rsdiffbeforeafterboth--- a/pallets/nft/src/tests.rs
+++ b/pallets/nft/src/tests.rs
@@ -2387,7 +2387,9 @@
let origin1 = Origin::signed(1);
let collection_id = create_test_collection(&CollectionMode::NFT, 1);
- assert_ok!(TemplateModule::set_transfers_enabled_flag(origin1, 1, false));
+ assert_ok!(TemplateModule::set_transfers_enabled_flag(
+ origin1, 1, false
+ ));
let data = default_nft_data();
create_test_item(collection_id, &data.into());
runtime/src/lib.rsdiffbeforeafterboth--- a/runtime/src/lib.rs
+++ b/runtime/src/lib.rs
@@ -154,7 +154,7 @@
transaction_version: 1,
};
-pub const MILLISECS_PER_BLOCK: u64 = 12000;
+pub const MILLISECS_PER_BLOCK: u64 = 1200;
pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;
tests/src/change-collection-owner.test.tsdiffbeforeafterboth--- a/tests/src/change-collection-owner.test.ts
+++ b/tests/src/change-collection-owner.test.ts
@@ -7,7 +7,7 @@
import chaiAsPromised from 'chai-as-promised';
import privateKey from './substrate/privateKey';
import { default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync } from './substrate/substrate-api';
-import { createCollectionExpectSuccess, normalizeAccountId } from './util/helpers';
+import { createCollectionExpectSuccess } from './util/helpers';
chai.use(chaiAsPromised);
const expect = chai.expect;
tests/src/enableDisableTransfer.test.tsdiffbeforeafterboth--- a/tests/src/enableDisableTransfer.test.ts
+++ b/tests/src/enableDisableTransfer.test.ts
@@ -12,7 +12,7 @@
createCollectionExpectSuccess,
transferExpectSuccess,
transferExpectFailure,
- setTransferFlagExpectSuccess
+ setTransferFlagExpectSuccess,
} from './util/helpers';
chai.use(chaiAsPromised);
tests/src/pallet-presence.test.tsdiffbeforeafterboth--- a/tests/src/pallet-presence.test.ts
+++ b/tests/src/pallet-presence.test.ts
@@ -32,14 +32,14 @@
'nft',
'scheduler',
'nftpayment',
- 'charging'
+ 'charging',
];
// Pallets that depend on consensus and governance configuration
const consensusPallets = [
'sudo',
'aura',
- 'auraext'
+ 'auraext',
];
describe('Pallet presence', () => {
tests/src/setConstOnChainSchema.test.tsdiffbeforeafterboth1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//56import { Keyring } from '@polkadot/api';7import { IKeyringPair } from '@polkadot/types/types';8import chai from 'chai';9import chaiAsPromised from 'chai-as-promised';10import { default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync } from './substrate/substrate-api';11import {12 createCollectionExpectSuccess,13 destroyCollectionExpectSuccess,14 normalizeAccountId,15} from './util/helpers';1617chai.use(chaiAsPromised);18const expect = chai.expect;1920let Alice: IKeyringPair;21let Bob: IKeyringPair;22let Shema: any;23let largeShema: any;2425before(async () => {26 await usingApi(async () => {27 const keyring = new Keyring({ type: 'sr25519' });28 Alice = keyring.addFromUri('//Alice');29 Bob = keyring.addFromUri('//Bob');30 Shema = '0x31';31 largeShema = new Array(4097).fill(0xff);3233 });34});35describe('Integration Test ext. setConstOnChainSchema()', () => {3637 it('Run extrinsic with parameters of the collection id, set the scheme', async () => {38 await usingApi(async (api) => {39 const collectionId = await createCollectionExpectSuccess();40 const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();41 expect(collection.Owner).to.be.eq(Alice.address);42 const setShema = api.tx.nft.setConstOnChainSchema(collectionId, Shema);43 await submitTransactionAsync(Alice, setShema);44 });45 });4647 it('Checking collection data using the ConstOnChainSchema parameter', async () => {48 await usingApi(async (api) => {49 const collectionId = await createCollectionExpectSuccess();50 const setShema = api.tx.nft.setConstOnChainSchema(collectionId, Shema);51 await submitTransactionAsync(Alice, setShema);52 const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();53 expect(collection.ConstOnChainSchema.toString()).to.be.eq(Shema);5455 });56 });57});5859describe('Negative Integration Test ext. setConstOnChainSchema()', () => {6061 it('Set a non-existent collection', async () => {62 await usingApi(async (api) => {63 // tslint:disable-next-line: radix64 const collectionId = parseInt((await api.query.nft.createdCollectionCount()).toString()) + 1;65 const setShema = api.tx.nft.setConstOnChainSchema(collectionId, Shema);66 await expect(submitTransactionExpectFailAsync(Alice, setShema)).to.be.rejected;67 });68 });6970 it('Set a previously deleted collection', async () => {71 await usingApi(async (api) => {72 const collectionId = await createCollectionExpectSuccess();73 await destroyCollectionExpectSuccess(collectionId);74 const setShema = api.tx.nft.setConstOnChainSchema(collectionId, Shema);75 await expect(submitTransactionExpectFailAsync(Alice, setShema)).to.be.rejected;76 });77 });7879 it('Set invalid data in schema (size too large:> 1024b)', async () => {80 await usingApi(async (api) => {81 const collectionId = await createCollectionExpectSuccess();82 const setShema = api.tx.nft.setConstOnChainSchema(collectionId, largeShema);83 await expect(submitTransactionExpectFailAsync(Alice, setShema)).to.be.rejected;84 });85 });8687 it('Execute method not on behalf of the collection owner', async () => {88 await usingApi(async (api) => {89 const collectionId = await createCollectionExpectSuccess();90 const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();91 expect(collection.Owner).to.be.eq(Alice.address);92 const setShema = api.tx.nft.setConstOnChainSchema(collectionId, Shema);93 await expect(submitTransactionExpectFailAsync(Bob, setShema)).to.be.rejected;94 });95 });9697});1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//56import { Keyring } from '@polkadot/api';7import { IKeyringPair } from '@polkadot/types/types';8import chai from 'chai';9import chaiAsPromised from 'chai-as-promised';10import { default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync } from './substrate/substrate-api';11import {12 createCollectionExpectSuccess,13 destroyCollectionExpectSuccess,14} from './util/helpers';1516chai.use(chaiAsPromised);17const expect = chai.expect;1819let Alice: IKeyringPair;20let Bob: IKeyringPair;21let Shema: any;22let largeShema: any;2324before(async () => {25 await usingApi(async () => {26 const keyring = new Keyring({ type: 'sr25519' });27 Alice = keyring.addFromUri('//Alice');28 Bob = keyring.addFromUri('//Bob');29 Shema = '0x31';30 largeShema = new Array(4097).fill(0xff);3132 });33});34describe('Integration Test ext. setConstOnChainSchema()', () => {3536 it('Run extrinsic with parameters of the collection id, set the scheme', async () => {37 await usingApi(async (api) => {38 const collectionId = await createCollectionExpectSuccess();39 const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();40 expect(collection.Owner).to.be.eq(Alice.address);41 const setShema = api.tx.nft.setConstOnChainSchema(collectionId, Shema);42 await submitTransactionAsync(Alice, setShema);43 });44 });4546 it('Checking collection data using the ConstOnChainSchema parameter', async () => {47 await usingApi(async (api) => {48 const collectionId = await createCollectionExpectSuccess();49 const setShema = api.tx.nft.setConstOnChainSchema(collectionId, Shema);50 await submitTransactionAsync(Alice, setShema);51 const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();52 expect(collection.ConstOnChainSchema.toString()).to.be.eq(Shema);5354 });55 });56});5758describe('Negative Integration Test ext. setConstOnChainSchema()', () => {5960 it('Set a non-existent collection', async () => {61 await usingApi(async (api) => {62 // tslint:disable-next-line: radix63 const collectionId = parseInt((await api.query.nft.createdCollectionCount()).toString()) + 1;64 const setShema = api.tx.nft.setConstOnChainSchema(collectionId, Shema);65 await expect(submitTransactionExpectFailAsync(Alice, setShema)).to.be.rejected;66 });67 });6869 it('Set a previously deleted collection', async () => {70 await usingApi(async (api) => {71 const collectionId = await createCollectionExpectSuccess();72 await destroyCollectionExpectSuccess(collectionId);73 const setShema = api.tx.nft.setConstOnChainSchema(collectionId, Shema);74 await expect(submitTransactionExpectFailAsync(Alice, setShema)).to.be.rejected;75 });76 });7778 it('Set invalid data in schema (size too large:> 1024b)', async () => {79 await usingApi(async (api) => {80 const collectionId = await createCollectionExpectSuccess();81 const setShema = api.tx.nft.setConstOnChainSchema(collectionId, largeShema);82 await expect(submitTransactionExpectFailAsync(Alice, setShema)).to.be.rejected;83 });84 });8586 it('Execute method not on behalf of the collection owner', async () => {87 await usingApi(async (api) => {88 const collectionId = await createCollectionExpectSuccess();89 const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();90 expect(collection.Owner).to.be.eq(Alice.address);91 const setShema = api.tx.nft.setConstOnChainSchema(collectionId, Shema);92 await expect(submitTransactionExpectFailAsync(Bob, setShema)).to.be.rejected;93 });94 });9596});tests/src/setVariableOnChainSchema.test.tsdiffbeforeafterboth--- a/tests/src/setVariableOnChainSchema.test.ts
+++ b/tests/src/setVariableOnChainSchema.test.ts
@@ -11,7 +11,6 @@
import {
createCollectionExpectSuccess,
destroyCollectionExpectSuccess,
- normalizeAccountId,
} from './util/helpers';
chai.use(chaiAsPromised);
tests/src/substrate/substrate-api.tsdiffbeforeafterboth--- a/tests/src/substrate/substrate-api.ts
+++ b/tests/src/substrate/substrate-api.ts
@@ -48,12 +48,12 @@
console.warn = outFn;
try {
- await promisifySubstrate(api, async () => {
+ await promisifySubstrate(api, async () => {
if (api) {
await api.isReadyOrError;
result = await action(api);
}
- })();
+ })();
} finally {
await api.disconnect();
console.error = consoleErr;
tests/src/util/helpers.tsdiffbeforeafterboth--- a/tests/src/util/helpers.ts
+++ b/tests/src/util/helpers.ts
@@ -555,7 +555,7 @@
});
}
-export async function toggleContractWhitelistExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string, value: boolean = true) {
+export async function toggleContractWhitelistExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string, value = true) {
await usingApi(async (api) => {
const tx = api.tx.nft.toggleContractWhiteList(contractAddress, value);
const events = await submitTransactionAsync(sender, tx);
@@ -761,7 +761,7 @@
recipient: IKeyringPair,
value: number | bigint = 1,
blockTimeMs: number,
- blockSchedule: number
+ blockSchedule: number,
) {
await usingApi(async (api: ApiPromise) => {
const blockNumber: number | undefined = await getBlockNumber(api);