git.delta.rocks / unique-network / refs/commits / 39148f6db4ae

difftreelog

Merge pull request #665 from UniqueNetwork/tests/fix-eslint

ut-akuznetsov2022-10-19parents: #2e3c4de #f921c01.patch.diff
in: master
Fix eslint errors

8 files changed

modifiedCargo.lockdiffbeforeafterboth
6710 "up-sponsorship",6710 "up-sponsorship",
6711]6711]
6712
6713[[package]]
6714name = "pallet-unique-scheduler-v2"
6715version = "0.1.0"
6716dependencies = [
6717 "frame-benchmarking",
6718 "frame-support",
6719 "frame-system",
6720 "log",
6721 "pallet-preimage",
6722 "parity-scale-codec 3.2.1",
6723 "scale-info",
6724 "sp-core",
6725 "sp-io",
6726 "sp-runtime",
6727 "sp-std",
6728 "substrate-test-utils",
6729]
67306712
6731[[package]]6713[[package]]
6732name = "pallet-utility"6714name = "pallet-utility"
modifiedtests/src/eth/base.test.tsdiffbeforeafterboth
14// You should have received a copy of the GNU General Public License14// You should have received a copy of the GNU General Public License
15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
16
17import {Contract} from 'web3-eth-contract';
1816
19import {IKeyringPair} from '@polkadot/types/types';17import {IKeyringPair} from '@polkadot/types/types';
20import {EthUniqueHelper, itEth, usingEthPlaygrounds, expect} from './util';18import {EthUniqueHelper, itEth, usingEthPlaygrounds, expect} from './util';
93 const donor = await privateKey({filename: __filename});91 const donor = await privateKey({filename: __filename});
94 const [alice] = await helper.arrange.createAccounts([10n], donor);92 const [alice] = await helper.arrange.createAccounts([10n], donor);
95 ({collectionId: simpleNftCollectionId} = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'}));93 ({collectionId: simpleNftCollectionId} = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'}));
96 minter = helper.eth.createAccount();94 minter = await helper.eth.createAccountWithBalance(donor);
97 ({collectionId: erc721MetadataCompatibleNftCollectionId} = await helper.eth.createERC721MetadataCompatibleNFTCollection(minter, 'n', 'd', 'p', BASE_URI));95 ({collectionId: erc721MetadataCompatibleNftCollectionId} = await helper.eth.createERC721MetadataCompatibleNFTCollection(minter, 'n', 'd', 'p', BASE_URI));
98 });96 });
99 });97 });
modifiedtests/src/eth/collectionProperties.test.tsdiffbeforeafterboth
18import {Pallets} from '../util';18import {Pallets} from '../util';
19import {IProperty, ITokenPropertyPermission} from '../util/playgrounds/types';19import {IProperty, ITokenPropertyPermission} from '../util/playgrounds/types';
20import {IKeyringPair} from '@polkadot/types/types';20import {IKeyringPair} from '@polkadot/types/types';
21import {Contract} from 'web3-eth-contract';
2221
23describe('EVM collection properties', () => {22describe('EVM collection properties', () => {
24 let donor: IKeyringPair;23 let donor: IKeyringPair;
87 const caller = await helper.eth.createAccountWithBalance(donor);86 const caller = await helper.eth.createAccountWithBalance(donor);
88 const bruh = await helper.eth.createAccountWithBalance(donor);87 const bruh = await helper.eth.createAccountWithBalance(donor);
8988
90 const BASE_URI = 'base/'89 const BASE_URI = 'base/';
91 const SUFFIX = 'suffix1'90 const SUFFIX = 'suffix1';
92 const URI = 'uri1'91 const URI = 'uri1';
9392
94 const collectionHelpers = helper.ethNativeContract.collectionHelpers(caller);93 const collectionHelpers = helper.ethNativeContract.collectionHelpers(caller);
95 const creatorMethod = mode === 'rft' ? 'createRFTCollection' : 'createNFTCollection'94 const creatorMethod = mode === 'rft' ? 'createRFTCollection' : 'createNFTCollection';
9695
97 const {collectionId, collectionAddress} = await helper.eth[creatorMethod](caller, 'n', 'd', 'p')96 const {collectionId, collectionAddress} = await helper.eth[creatorMethod](caller, 'n', 'd', 'p');
9897
99 const contract = helper.ethNativeContract.collectionById(collectionId, mode, caller);98 const contract = helper.ethNativeContract.collectionById(collectionId, mode, caller);
100 await contract.methods.addCollectionAdmin(bruh).send(); // to check that admin will work too99 await contract.methods.addCollectionAdmin(bruh).send(); // to check that admin will work too
101100
102 const collection1 = await helper.nft.getCollectionObject(collectionId);101 const collection1 = helper.nft.getCollectionObject(collectionId);
103 const data1 = await collection1.getData()102 const data1 = await collection1.getData();
104 expect(data1?.raw.flags.erc721metadata).to.be.false;103 expect(data1?.raw.flags.erc721metadata).to.be.false;
105 expect(await contract.methods.supportsInterface('0x5b5e139f').call()).to.be.false;104 expect(await contract.methods.supportsInterface('0x5b5e139f').call()).to.be.false;
106105
109108
110 expect(await contract.methods.supportsInterface('0x5b5e139f').call()).to.be.true;109 expect(await contract.methods.supportsInterface('0x5b5e139f').call()).to.be.true;
111110
112 const collection2 = await helper.nft.getCollectionObject(collectionId);111 const collection2 = helper.nft.getCollectionObject(collectionId);
113 const data2 = await collection2.getData()112 const data2 = await collection2.getData();
114 expect(data2?.raw.flags.erc721metadata).to.be.true;113 expect(data2?.raw.flags.erc721metadata).to.be.true;
115114
116 const TPPs = data2?.raw.tokenPropertyPermissions115 const propertyPermissions = data2?.raw.tokenPropertyPermissions;
117 expect(TPPs?.length).to.equal(2);116 expect(propertyPermissions?.length).to.equal(2);
118117
119 expect(TPPs.find((tpp: ITokenPropertyPermission) => {118 expect(propertyPermissions.find((tpp: ITokenPropertyPermission) => {
120 return tpp.key === "URI" && tpp.permission.mutable && tpp.permission.collectionAdmin && !tpp.permission.tokenOwner119 return tpp.key === 'URI' && tpp.permission.mutable && tpp.permission.collectionAdmin && !tpp.permission.tokenOwner;
121 })).to.be.not.null120 })).to.be.not.null;
122121
123 expect(TPPs.find((tpp: ITokenPropertyPermission) => {122 expect(propertyPermissions.find((tpp: ITokenPropertyPermission) => {
124 return tpp.key === "URISuffix" && tpp.permission.mutable && tpp.permission.collectionAdmin && !tpp.permission.tokenOwner123 return tpp.key === 'URISuffix' && tpp.permission.mutable && tpp.permission.collectionAdmin && !tpp.permission.tokenOwner;
125 })).to.be.not.null124 })).to.be.not.null;
126125
127 expect(data2?.raw.properties?.find((property: IProperty) => {126 expect(data2?.raw.properties?.find((property: IProperty) => {
128 return property.key === "baseURI" && property.value === BASE_URI127 return property.key === 'baseURI' && property.value === BASE_URI;
129 })).to.be.not.null128 })).to.be.not.null;
130129
131 const token1Result = await contract.methods.mint(bruh).send();130 const token1Result = await contract.methods.mint(bruh).send();
132 const tokenId1 = token1Result.events.Transfer.returnValues.tokenId;131 const tokenId1 = token1Result.events.Transfer.returnValues.tokenId;
133132
134 expect(await contract.methods.tokenURI(tokenId1).call()).to.equal(BASE_URI);133 expect(await contract.methods.tokenURI(tokenId1).call()).to.equal(BASE_URI);
135134
136 await contract.methods.setProperty(tokenId1, "URISuffix", Buffer.from(SUFFIX)).send();135 await contract.methods.setProperty(tokenId1, 'URISuffix', Buffer.from(SUFFIX)).send();
137 expect(await contract.methods.tokenURI(tokenId1).call()).to.equal(BASE_URI + SUFFIX);136 expect(await contract.methods.tokenURI(tokenId1).call()).to.equal(BASE_URI + SUFFIX);
138137
139 await contract.methods.setProperty(tokenId1, "URI", Buffer.from(URI)).send();138 await contract.methods.setProperty(tokenId1, 'URI', Buffer.from(URI)).send();
140 expect(await contract.methods.tokenURI(tokenId1).call()).to.equal(URI);139 expect(await contract.methods.tokenURI(tokenId1).call()).to.equal(URI);
141140
142 await contract.methods.deleteProperty(tokenId1, "URI").send();141 await contract.methods.deleteProperty(tokenId1, 'URI').send();
143 expect(await contract.methods.tokenURI(tokenId1).call()).to.equal(BASE_URI + SUFFIX);142 expect(await contract.methods.tokenURI(tokenId1).call()).to.equal(BASE_URI + SUFFIX);
144143
145 const token2Result = await contract.methods.mintWithTokenURI(bruh, URI).send();144 const token2Result = await contract.methods.mintWithTokenURI(bruh, URI).send();
146 const tokenId2 = token2Result.events.Transfer.returnValues.tokenId;145 const tokenId2 = token2Result.events.Transfer.returnValues.tokenId;
147146
148 expect(await contract.methods.tokenURI(tokenId2).call()).to.equal(URI);147 expect(await contract.methods.tokenURI(tokenId2).call()).to.equal(URI);
149148
150 await contract.methods.deleteProperty(tokenId2, "URI").send();149 await contract.methods.deleteProperty(tokenId2, 'URI').send();
151 expect(await contract.methods.tokenURI(tokenId2).call()).to.equal(BASE_URI);150 expect(await contract.methods.tokenURI(tokenId2).call()).to.equal(BASE_URI);
152151
153 await contract.methods.setProperty(tokenId2, "URISuffix", Buffer.from(SUFFIX)).send();152 await contract.methods.setProperty(tokenId2, 'URISuffix', Buffer.from(SUFFIX)).send();
154 expect(await contract.methods.tokenURI(tokenId2).call()).to.equal(BASE_URI + SUFFIX);153 expect(await contract.methods.tokenURI(tokenId2).call()).to.equal(BASE_URI + SUFFIX);
155 }154 };
156155
157 itEth('ERC721Metadata property can be set for NFT collection', async({helper}) => {156 itEth('ERC721Metadata property can be set for NFT collection', async({helper}) => {
158 await checkERC721Metadata(helper, 'nft');157 await checkERC721Metadata(helper, 'nft');
modifiedtests/src/eth/collectionSponsoring.test.tsdiffbeforeafterboth
247247
248 const userCollectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', user);248 const userCollectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', user);
249249
250 let result = await userCollectionEvm.methods.mintWithTokenURI(user, 'Test URI',).send();250 const result = await userCollectionEvm.methods.mintWithTokenURI(user, 'Test URI').send();
251 const tokenId = result.events.Transfer.returnValues.tokenId;251 const tokenId = result.events.Transfer.returnValues.tokenId;
252252
253 const events = helper.eth.normalizeEvents(result.events);253 const events = helper.eth.normalizeEvents(result.events);
modifiedtests/src/eth/proxy/nonFungibleProxy.test.tsdiffbeforeafterboth
111 await collectionEvmOwned.methods.addCollectionAdmin(contract.options.address).send();111 await collectionEvmOwned.methods.addCollectionAdmin(contract.options.address).send();
112112
113 {113 {
114 const nextTokenId = await contract.methods.nextTokenId().call()114 const nextTokenId = await contract.methods.nextTokenId().call();
115 const result = await contract.methods.mintWithTokenURI(receiver, nextTokenId, 'Test URI').send({from: caller});115 const result = await contract.methods.mintWithTokenURI(receiver, nextTokenId, 'Test URI').send({from: caller});
116 const tokenId = result.events.Transfer.returnValues.tokenId;116 const tokenId = result.events.Transfer.returnValues.tokenId;
117 expect(tokenId).to.be.equal('1');117 expect(tokenId).to.be.equal('1');
modifiedtests/src/eth/util/index.tsdiffbeforeafterboth
14import chai from 'chai';14import chai from 'chai';
15import chaiAsPromised from 'chai-as-promised';15import chaiAsPromised from 'chai-as-promised';
16import chaiLike from 'chai-like';16import chaiLike from 'chai-like';
17import {getTestSeed, requirePalletsOrSkip} from '../../util';17import {getTestSeed, MINIMUM_DONOR_FUND, requirePalletsOrSkip} from '../../util';
1818
19chai.use(chaiAsPromised);19chai.use(chaiAsPromised);
20chai.use(chaiLike);20chai.use(chaiLike);
43 else {43 else {
44 const actualSeed = getTestSeed(seed.filename);44 const actualSeed = getTestSeed(seed.filename);
45 let account = helper.util.fromSeed(actualSeed, ss58Format);45 let account = helper.util.fromSeed(actualSeed, ss58Format);
46 if (await helper.balance.getSubstrate(account.address) == 0n) {46 if (await helper.balance.getSubstrate(account.address) < MINIMUM_DONOR_FUND) {
47 console.warn(`${path.basename(seed.filename)}: Not enough funds present on the filename account. Using the default one as the donor instead.`);47 console.warn(`${path.basename(seed.filename)}: Not enough funds present on the filename account. Using the default one as the donor instead.`);
48 account = helper.util.fromSeed('//Alice', ss58Format);48 account = helper.util.fromSeed('//Alice', ss58Format);
49 }49 }
modifiedtests/src/eth/util/playgrounds/unique.dev.tsdiffbeforeafterboth
189 async createERC721MetadataCompatibleNFTCollection(signer: string, name: string, description: string, tokenPrefix: string, baseUri: string): Promise<{collectionId: number, collectionAddress: string}> {189 async createERC721MetadataCompatibleNFTCollection(signer: string, name: string, description: string, tokenPrefix: string, baseUri: string): Promise<{collectionId: number, collectionAddress: string}> {
190 const collectionHelper = this.helper.ethNativeContract.collectionHelpers(signer);190 const collectionHelper = this.helper.ethNativeContract.collectionHelpers(signer);
191191
192 const {collectionId, collectionAddress} = await this.createNFTCollection(signer, name, description, tokenPrefix)192 const {collectionId, collectionAddress} = await this.createNFTCollection(signer, name, description, tokenPrefix);
193193
194 await collectionHelper.methods.makeCollectionERC721MetadataCompatible(collectionAddress, baseUri).send();194 await collectionHelper.methods.makeCollectionERC721MetadataCompatible(collectionAddress, baseUri).send();
195195
211 async createERC721MetadataCompatibleRFTCollection(signer: string, name: string, description: string, tokenPrefix: string, baseUri: string): Promise<{collectionId: number, collectionAddress: string}> {211 async createERC721MetadataCompatibleRFTCollection(signer: string, name: string, description: string, tokenPrefix: string, baseUri: string): Promise<{collectionId: number, collectionAddress: string}> {
212 const collectionHelper = this.helper.ethNativeContract.collectionHelpers(signer);212 const collectionHelper = this.helper.ethNativeContract.collectionHelpers(signer);
213213
214 const {collectionId, collectionAddress} = await this.createRFTCollection(signer, name, description, tokenPrefix)214 const {collectionId, collectionAddress} = await this.createRFTCollection(signer, name, description, tokenPrefix);
215215
216 await collectionHelper.methods.makeCollectionERC721MetadataCompatible(collectionAddress, baseUri).send();216 await collectionHelper.methods.makeCollectionERC721MetadataCompatible(collectionAddress, baseUri).send();
217217
modifiedtests/src/pallet-presence.test.tsdiffbeforeafterboth
62 const chain = await helper.callRpc('api.rpc.system.chain', []);62 const chain = await helper.callRpc('api.rpc.system.chain', []);
6363
64 const refungible = 'refungible';64 const refungible = 'refungible';
65 const scheduler = 'scheduler';65 // const scheduler = 'scheduler';
66 const foreignAssets = 'foreignassets';66 const foreignAssets = 'foreignassets';
67 const rmrkPallets = ['rmrkcore', 'rmrkequip'];67 const rmrkPallets = ['rmrkcore', 'rmrkequip'];
68 const appPromotion = 'apppromotion';68 const appPromotion = 'apppromotion';
6969
70 if (chain.eq('OPAL by UNIQUE')) {70 if (chain.eq('OPAL by UNIQUE')) {
71 requiredPallets.push(71 requiredPallets.push(
72 refungible,72 refungible,
73 scheduler,73 // scheduler,
74 foreignAssets,74 foreignAssets,
75 appPromotion,75 appPromotion,
76 ...rmrkPallets,76 ...rmrkPallets,