difftreelog
Merge branch 'develop' into feature/NFTPAR-536_code_style
in: master
8 files changed
Cargo.lockdiffbeforeafterboth5993 "sp-std",5993 "sp-std",5994]5994]59955996[[package]]5997name = "pallet-scheduler"5998version = "3.0.0"5999dependencies = [6000 "frame-benchmarking",6001 "frame-support",6002 "frame-system",6003 "log",6004 "parity-scale-codec 2.1.3",6005 "serde",6006 "sp-core",6007 "sp-io",6008 "sp-runtime",6009 "sp-std",6010 "substrate-test-utils",6011 "up-sponsorship",6012]601359956014[[package]]5996[[package]]6015name = "pallet-scheduler"5997name = "pallet-scheduler"6026 "sp-std",6008 "sp-std",6027]6009]60106011[[package]]6012name = "pallet-scheduler"6013version = "3.0.0"6014dependencies = [6015 "frame-benchmarking",6016 "frame-support",6017 "frame-system",6018 "log",6019 "parity-scale-codec 2.1.3",6020 "serde",6021 "sp-core",6022 "sp-io",6023 "sp-runtime",6024 "sp-std",6025 "substrate-test-utils",6026 "up-sponsorship",6027]602860286029[[package]]6029[[package]]6030name = "pallet-session"6030name = "pallet-session"launch-config.jsondiffbeforeafterboth45 "nodes": [45 "nodes": [46 {46 {47 "port": 31200,47 "port": 31200,48 "wsPort": "9944",48 "name": "alice",49 "name": "alice",49 "flags": []50 "flags": []50 }51 },52 {53 "port": 31201,54 "wsPort": "9945",55 "name": "bob",56 "flags": []57 }51 ]58 ]52 }59 }53 ],60 ],runtime/src/lib.rsdiffbeforeafterboth212/// by Operational extrinsics.212/// by Operational extrinsics.213const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);213const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);214/// We allow for 2 seconds of compute with a 6 second average block time.214/// We allow for 2 seconds of compute with a 6 second average block time.215const MAXIMUM_BLOCK_WEIGHT: Weight = 2 * WEIGHT_PER_SECOND;215const MAXIMUM_BLOCK_WEIGHT: Weight = WEIGHT_PER_SECOND / 2;216216217parameter_types! {217parameter_types! {218 pub const BlockHashCount: BlockNumber = 2400;218 pub const BlockHashCount: BlockNumber = 2400;tests/src/config.tsdiffbeforeafterboth6import process from 'process';6import process from 'process';778const config = {8const config = {9<<<<<<< HEAD9 substrateUrl: process.env.substrateUrl || 'ws://127.0.0.1:9844',10 substrateUrl: process.env.substrateUrl || 'ws://127.0.0.1:9844',10};11};12=======13 substrateUrl: process.env.substrateUrl || 'ws://127.0.0.1:9944'14}15>>>>>>> develop111612export default config;17export default config;tests/src/contracts.test.tsdiffbeforeafterboth177 const result = getGenericResult(events);177 const result = getGenericResult(events);178 expect(result.success).to.be.true;178 expect(result.success).to.be.true;179179180 await transferFromExpectSuccess(collectionId, tokenId, bob, contract.address.toString(), charlie, 1, 'NFT');180 await transferFromExpectSuccess(collectionId, tokenId, bob, normalizeAccountId(contract.address.toString()), charlie, 1, 'NFT');181 });181 });182 });182 });183183tests/src/removeFromWhiteList.test.tsdiffbeforeafterboth16 findNotExistingCollection,16 findNotExistingCollection,17 removeFromWhiteListExpectFailure,17 removeFromWhiteListExpectFailure,18 disableWhiteListExpectSuccess,18 disableWhiteListExpectSuccess,19 normalizeAccountId19} from './util/helpers';20} from './util/helpers';20import { IKeyringPair } from '@polkadot/types/types';21import { IKeyringPair } from '@polkadot/types/types';21import privateKey from './substrate/privateKey';22import privateKey from './substrate/privateKey';40 await enableWhiteListExpectSuccess(alice, collectionId);41 await enableWhiteListExpectSuccess(alice, collectionId);41 await addToWhiteListExpectSuccess(alice, collectionId, bob.address);42 await addToWhiteListExpectSuccess(alice, collectionId, bob.address);424343 await removeFromWhiteListExpectSuccess(alice, collectionId, bob.address);44 await removeFromWhiteListExpectSuccess(alice, collectionId, normalizeAccountId(bob.address));44 expect(await isWhitelisted(collectionId, bob.address)).to.be.false;45 expect(await isWhitelisted(collectionId, bob.address)).to.be.false;45 });46 });46 });47 });52 await addToWhiteListExpectSuccess(alice, collectionWithoutWhitelistId, bob.address);53 await addToWhiteListExpectSuccess(alice, collectionWithoutWhitelistId, bob.address);53 await disableWhiteListExpectSuccess(alice, collectionWithoutWhitelistId);54 await disableWhiteListExpectSuccess(alice, collectionWithoutWhitelistId);545555 await removeFromWhiteListExpectSuccess(alice, collectionWithoutWhitelistId, bob.address);56 await removeFromWhiteListExpectSuccess(alice, collectionWithoutWhitelistId, normalizeAccountId(bob.address));56 });57 });57 });58 });58});59});72 await usingApi(async (api) => {73 await usingApi(async (api) => {73 const collectionId = await findNotExistingCollection(api);74 const collectionId = await findNotExistingCollection(api);747575 await removeFromWhiteListExpectFailure(alice, collectionId, bob.address);76 await removeFromWhiteListExpectFailure(alice, collectionId, normalizeAccountId(bob.address));76 });77 });77 });78 });787983 await addToWhiteListExpectSuccess(alice, collectionId, bob.address);84 await addToWhiteListExpectSuccess(alice, collectionId, bob.address);84 await destroyCollectionExpectSuccess(collectionId);85 await destroyCollectionExpectSuccess(collectionId);858686 await removeFromWhiteListExpectFailure(alice, collectionId, bob.address);87 await removeFromWhiteListExpectFailure(alice, collectionId, normalizeAccountId(bob.address));87 });88 });88 });89 });89});90});tests/src/toggleContractWhiteList.test.tsdiffbeforeafterboth45 const [contract, deployer] = await deployFlipper(api);45 const [contract, deployer] = await deployFlipper(api);464647 let flipValueBefore = await getFlipValue(contract, deployer);47 let flipValueBefore = await getFlipValue(contract, deployer);48 const flip = contract.exec('flip', value, gasLimit);48 const flip = contract.tx.flip(value, gasLimit);49 await submitTransactionAsync(bob, flip);49 await submitTransactionAsync(bob, flip);50 const flipValueAfter = await getFlipValue(contract,deployer);50 const flipValueAfter = await getFlipValue(contract,deployer);51 expect(flipValueAfter).to.be.eq(!flipValueBefore, 'Anyone can call new contract.');51 expect(flipValueAfter).to.be.eq(!flipValueBefore, 'Anyone can call new contract.');525253 const deployerCanFlip = async () => {53 const deployerCanFlip = async () => {54 const flipValueBefore = await getFlipValue(contract, deployer);54 let flipValueBefore = await getFlipValue(contract, deployer);55 const deployerFlip = contract.exec('flip', value, gasLimit);55 const deployerFlip = contract.tx.flip(value, gasLimit);56 await submitTransactionAsync(deployer, deployerFlip);56 await submitTransactionAsync(deployer, deployerFlip);57 const aliceFlip1Response = await getFlipValue(contract, deployer);57 const aliceFlip1Response = await getFlipValue(contract, deployer);58 expect(aliceFlip1Response).to.be.eq(!flipValueBefore, 'Deployer always can flip.');58 expect(aliceFlip1Response).to.be.eq(!flipValueBefore, 'Deployer always can flip.');62 flipValueBefore = await getFlipValue(contract, deployer);62 flipValueBefore = await getFlipValue(contract, deployer);63 const enableWhiteListTx = api.tx.nft.toggleContractWhiteList(contract.address, true);63 const enableWhiteListTx = api.tx.nft.toggleContractWhiteList(contract.address, true);64 await submitTransactionAsync(deployer, enableWhiteListTx);64 await submitTransactionAsync(deployer, enableWhiteListTx);65 const flipWithEnabledWhiteList = contract.exec('flip', value, gasLimit);65 const flipWithEnabledWhiteList = contract.tx.flip(value, gasLimit);66 await expect(submitTransactionExpectFailAsync(bob, flipWithEnabledWhiteList)).to.be.rejected;66 await expect(submitTransactionExpectFailAsync(bob, flipWithEnabledWhiteList)).to.be.rejected;67 const flipValueAfterEnableWhiteList = await getFlipValue(contract, deployer);67 const flipValueAfterEnableWhiteList = await getFlipValue(contract, deployer);68 expect(flipValueAfterEnableWhiteList).to.be.eq(flipValueBefore, 'Enabling whitelist doesn\'t make it possible to call contract for everyone.');68 expect(flipValueAfterEnableWhiteList).to.be.eq(flipValueBefore, 'Enabling whitelist doesn\'t make it possible to call contract for everyone.');72 flipValueBefore = await getFlipValue(contract, deployer);72 flipValueBefore = await getFlipValue(contract, deployer);73 const addBobToWhiteListTx = api.tx.nft.addToContractWhiteList(contract.address, bob.address);73 const addBobToWhiteListTx = api.tx.nft.addToContractWhiteList(contract.address, bob.address);74 await submitTransactionAsync(deployer, addBobToWhiteListTx);74 await submitTransactionAsync(deployer, addBobToWhiteListTx);75 const flipWithWhitelistedBob = contract.exec('flip', value, gasLimit);75 const flipWithWhitelistedBob = contract.tx.flip(value, gasLimit);76 await submitTransactionAsync(bob, flipWithWhitelistedBob);76 await submitTransactionAsync(bob, flipWithWhitelistedBob);77 const flipAfterWhiteListed = await getFlipValue(contract,deployer);77 const flipAfterWhiteListed = await getFlipValue(contract,deployer);78 expect(flipAfterWhiteListed).to.be.eq(!flipValueBefore, 'Bob was whitelisted, now he can flip.');78 expect(flipAfterWhiteListed).to.be.eq(!flipValueBefore, 'Bob was whitelisted, now he can flip.');82 flipValueBefore = await getFlipValue(contract, deployer);82 flipValueBefore = await getFlipValue(contract, deployer);83 const removeBobFromWhiteListTx = api.tx.nft.removeFromContractWhiteList(contract.address, bob.address);83 const removeBobFromWhiteListTx = api.tx.nft.removeFromContractWhiteList(contract.address, bob.address);84 await submitTransactionAsync(deployer, removeBobFromWhiteListTx);84 await submitTransactionAsync(deployer, removeBobFromWhiteListTx);85 const bobRemoved = contract.exec('flip', value, gasLimit);85 const bobRemoved = contract.tx.flip(value, gasLimit);86 await expect(submitTransactionExpectFailAsync(bob, bobRemoved)).to.be.rejected;86 await expect(submitTransactionExpectFailAsync(bob, bobRemoved)).to.be.rejected;87 const afterBobRemoved = await getFlipValue(contract, deployer);87 const afterBobRemoved = await getFlipValue(contract, deployer);88 expect(afterBobRemoved).to.be.eq(flipValueBefore, 'Bob can\'t call contract, now when he is removeed from white list.');88 expect(afterBobRemoved).to.be.eq(flipValueBefore, 'Bob can\'t call contract, now when he is removeed from white list.');92 flipValueBefore = await getFlipValue(contract, deployer);92 flipValueBefore = await getFlipValue(contract, deployer);93 const disableWhiteListTx = api.tx.nft.toggleContractWhiteList(contract.address, false);93 const disableWhiteListTx = api.tx.nft.toggleContractWhiteList(contract.address, false);94 await submitTransactionAsync(deployer, disableWhiteListTx);94 await submitTransactionAsync(deployer, disableWhiteListTx);95 const whiteListDisabledFlip = contract.exec('flip', value, gasLimit);95 const whiteListDisabledFlip = contract.tx.flip(value, gasLimit);96 await submitTransactionAsync(bob, whiteListDisabledFlip);96 await submitTransactionAsync(bob, whiteListDisabledFlip);97 const afterWhiteListDisabled = await getFlipValue(contract,deployer);97 const afterWhiteListDisabled = await getFlipValue(contract,deployer);98 expect(afterWhiteListDisabled).to.be.eq(!flipValueBefore, 'Anyone can call contract with disabled whitelist.');98 expect(afterWhiteListDisabled).to.be.eq(!flipValueBefore, 'Anyone can call contract with disabled whitelist.');tests/src/util/helpers.tsdiffbeforeafterboth25} | {25} | {26 ethereum: string,26 ethereum: string,27};27};28export function normalizeAccountId(input: string | CrossAccountId | IKeyringPair): CrossAccountId {28export function normalizeAccountId(input: string | AccountId | CrossAccountId | IKeyringPair): CrossAccountId {29 if (typeof input === 'string')29 if (typeof input === 'string')30 return { substrate: input };30 return { substrate: input };31 if ('address' in input) {31 if ('address' in input) {32 return { substrate: input.address };32 return { substrate: input.address };33 }33 }34 if ('ethereum' in input) {34 if ('ethereum' in input) {35 input.ethereum = input.ethereum.toLowerCase();35 input.ethereum = input.ethereum.toLowerCase();36 return input;36 }37 }38 if ('substrate' in input) {37 return input;39 return input;40 }4142 // AccountId43 return {substrate: input.toString()}38}44}39export function toSubstrateAddress(input: string | CrossAccountId | IKeyringPair): string {45export function toSubstrateAddress(input: string | CrossAccountId | IKeyringPair): string {40 input = normalizeAccountId(input);46 input = normalizeAccountId(input);