difftreelog
Merge pull request #665 from UniqueNetwork/tests/fix-eslint
in: master
Fix eslint errors
8 files changed
Cargo.lockdiffbeforeafterboth--- a/Cargo.lock
+++ b/Cargo.lock
@@ -6711,24 +6711,6 @@
]
[[package]]
-name = "pallet-unique-scheduler-v2"
-version = "0.1.0"
-dependencies = [
- "frame-benchmarking",
- "frame-support",
- "frame-system",
- "log",
- "pallet-preimage",
- "parity-scale-codec 3.2.1",
- "scale-info",
- "sp-core",
- "sp-io",
- "sp-runtime",
- "sp-std",
- "substrate-test-utils",
-]
-
-[[package]]
name = "pallet-utility"
version = "4.0.0-dev"
source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.29#cc370aa61e15c18d23a2f686b812fd576a630afe"
tests/src/eth/base.test.tsdiffbeforeafterboth--- a/tests/src/eth/base.test.ts
+++ b/tests/src/eth/base.test.ts
@@ -14,8 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
-import {Contract} from 'web3-eth-contract';
-
import {IKeyringPair} from '@polkadot/types/types';
import {EthUniqueHelper, itEth, usingEthPlaygrounds, expect} from './util';
@@ -44,7 +42,7 @@
from: userA,
to: userB,
value: '1000000',
- gas: helper.eth.DEFAULT_GAS
+ gas: helper.eth.DEFAULT_GAS,
}));
const balanceB = await helper.balance.getEthereum(userB);
expect(cost - balanceB < BigInt(0.2 * Number(helper.balance.getOneTokenNominal()))).to.be.true;
@@ -93,7 +91,7 @@
const donor = await privateKey({filename: __filename});
const [alice] = await helper.arrange.createAccounts([10n], donor);
({collectionId: simpleNftCollectionId} = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'}));
- minter = helper.eth.createAccount();
+ minter = await helper.eth.createAccountWithBalance(donor);
({collectionId: erc721MetadataCompatibleNftCollectionId} = await helper.eth.createERC721MetadataCompatibleNFTCollection(minter, 'n', 'd', 'p', BASE_URI));
});
});
tests/src/eth/collectionProperties.test.tsdiffbeforeafterboth--- a/tests/src/eth/collectionProperties.test.ts
+++ b/tests/src/eth/collectionProperties.test.ts
@@ -18,7 +18,6 @@
import {Pallets} from '../util';
import {IProperty, ITokenPropertyPermission} from '../util/playgrounds/types';
import {IKeyringPair} from '@polkadot/types/types';
-import {Contract} from 'web3-eth-contract';
describe('EVM collection properties', () => {
let donor: IKeyringPair;
@@ -87,20 +86,20 @@
const caller = await helper.eth.createAccountWithBalance(donor);
const bruh = await helper.eth.createAccountWithBalance(donor);
- const BASE_URI = 'base/'
- const SUFFIX = 'suffix1'
- const URI = 'uri1'
+ const BASE_URI = 'base/';
+ const SUFFIX = 'suffix1';
+ const URI = 'uri1';
const collectionHelpers = helper.ethNativeContract.collectionHelpers(caller);
- const creatorMethod = mode === 'rft' ? 'createRFTCollection' : 'createNFTCollection'
+ const creatorMethod = mode === 'rft' ? 'createRFTCollection' : 'createNFTCollection';
- const {collectionId, collectionAddress} = await helper.eth[creatorMethod](caller, 'n', 'd', 'p')
+ const {collectionId, collectionAddress} = await helper.eth[creatorMethod](caller, 'n', 'd', 'p');
const contract = helper.ethNativeContract.collectionById(collectionId, mode, caller);
await contract.methods.addCollectionAdmin(bruh).send(); // to check that admin will work too
- const collection1 = await helper.nft.getCollectionObject(collectionId);
- const data1 = await collection1.getData()
+ const collection1 = helper.nft.getCollectionObject(collectionId);
+ const data1 = await collection1.getData();
expect(data1?.raw.flags.erc721metadata).to.be.false;
expect(await contract.methods.supportsInterface('0x5b5e139f').call()).to.be.false;
@@ -109,37 +108,37 @@
expect(await contract.methods.supportsInterface('0x5b5e139f').call()).to.be.true;
- const collection2 = await helper.nft.getCollectionObject(collectionId);
- const data2 = await collection2.getData()
+ const collection2 = helper.nft.getCollectionObject(collectionId);
+ const data2 = await collection2.getData();
expect(data2?.raw.flags.erc721metadata).to.be.true;
- const TPPs = data2?.raw.tokenPropertyPermissions
- expect(TPPs?.length).to.equal(2);
+ const propertyPermissions = data2?.raw.tokenPropertyPermissions;
+ expect(propertyPermissions?.length).to.equal(2);
- expect(TPPs.find((tpp: ITokenPropertyPermission) => {
- return tpp.key === "URI" && tpp.permission.mutable && tpp.permission.collectionAdmin && !tpp.permission.tokenOwner
- })).to.be.not.null
+ expect(propertyPermissions.find((tpp: ITokenPropertyPermission) => {
+ return tpp.key === 'URI' && tpp.permission.mutable && tpp.permission.collectionAdmin && !tpp.permission.tokenOwner;
+ })).to.be.not.null;
- expect(TPPs.find((tpp: ITokenPropertyPermission) => {
- return tpp.key === "URISuffix" && tpp.permission.mutable && tpp.permission.collectionAdmin && !tpp.permission.tokenOwner
- })).to.be.not.null
+ expect(propertyPermissions.find((tpp: ITokenPropertyPermission) => {
+ return tpp.key === 'URISuffix' && tpp.permission.mutable && tpp.permission.collectionAdmin && !tpp.permission.tokenOwner;
+ })).to.be.not.null;
expect(data2?.raw.properties?.find((property: IProperty) => {
- return property.key === "baseURI" && property.value === BASE_URI
- })).to.be.not.null
+ return property.key === 'baseURI' && property.value === BASE_URI;
+ })).to.be.not.null;
const token1Result = await contract.methods.mint(bruh).send();
const tokenId1 = token1Result.events.Transfer.returnValues.tokenId;
expect(await contract.methods.tokenURI(tokenId1).call()).to.equal(BASE_URI);
- await contract.methods.setProperty(tokenId1, "URISuffix", Buffer.from(SUFFIX)).send();
+ await contract.methods.setProperty(tokenId1, 'URISuffix', Buffer.from(SUFFIX)).send();
expect(await contract.methods.tokenURI(tokenId1).call()).to.equal(BASE_URI + SUFFIX);
- await contract.methods.setProperty(tokenId1, "URI", Buffer.from(URI)).send();
+ await contract.methods.setProperty(tokenId1, 'URI', Buffer.from(URI)).send();
expect(await contract.methods.tokenURI(tokenId1).call()).to.equal(URI);
- await contract.methods.deleteProperty(tokenId1, "URI").send();
+ await contract.methods.deleteProperty(tokenId1, 'URI').send();
expect(await contract.methods.tokenURI(tokenId1).call()).to.equal(BASE_URI + SUFFIX);
const token2Result = await contract.methods.mintWithTokenURI(bruh, URI).send();
@@ -147,12 +146,12 @@
expect(await contract.methods.tokenURI(tokenId2).call()).to.equal(URI);
- await contract.methods.deleteProperty(tokenId2, "URI").send();
+ await contract.methods.deleteProperty(tokenId2, 'URI').send();
expect(await contract.methods.tokenURI(tokenId2).call()).to.equal(BASE_URI);
- await contract.methods.setProperty(tokenId2, "URISuffix", Buffer.from(SUFFIX)).send();
+ await contract.methods.setProperty(tokenId2, 'URISuffix', Buffer.from(SUFFIX)).send();
expect(await contract.methods.tokenURI(tokenId2).call()).to.equal(BASE_URI + SUFFIX);
- }
+ };
itEth('ERC721Metadata property can be set for NFT collection', async({helper}) => {
await checkERC721Metadata(helper, 'nft');
tests/src/eth/collectionSponsoring.test.tsdiffbeforeafterboth--- a/tests/src/eth/collectionSponsoring.test.ts
+++ b/tests/src/eth/collectionSponsoring.test.ts
@@ -247,7 +247,7 @@
const userCollectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', user);
- let result = await userCollectionEvm.methods.mintWithTokenURI(user, 'Test URI',).send();
+ const result = await userCollectionEvm.methods.mintWithTokenURI(user, 'Test URI').send();
const tokenId = result.events.Transfer.returnValues.tokenId;
const events = helper.eth.normalizeEvents(result.events);
tests/src/eth/proxy/nonFungibleProxy.test.tsdiffbeforeafterboth1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617import {readFile} from 'fs/promises';18import {IKeyringPair} from '@polkadot/types/types';19import {EthUniqueHelper, itEth, usingEthPlaygrounds, expect} from '../util';202122async function proxyWrap(helper: EthUniqueHelper, wrapped: any, donor: IKeyringPair) {23 // Proxy owner has no special privilegies, we don't need to reuse them24 const owner = await helper.eth.createAccountWithBalance(donor);25 const web3 = helper.getWeb3();26 const proxyContract = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/UniqueNFTProxy.abi`)).toString()), undefined, {27 from: owner,28 gas: helper.eth.DEFAULT_GAS,29 });30 const proxy = await proxyContract.deploy({data: (await readFile(`${__dirname}/UniqueNFTProxy.bin`)).toString(), arguments: [wrapped.options.address]}).send({from: owner});31 return proxy;32}3334describe('NFT (Via EVM proxy): Information getting', () => {35 let alice: IKeyringPair;36 let donor: IKeyringPair;3738 before(async function() {39 await usingEthPlaygrounds(async (helper, privateKey) => {40 donor = await privateKey({filename: __filename});41 [alice] = await helper.arrange.createAccounts([10n], donor);42 });43 });4445 itEth('totalSupply', async ({helper}) => {46 const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});47 const caller = await helper.eth.createAccountWithBalance(donor);48 await collection.mintToken(alice, {Substrate: alice.address});4950 const address = helper.ethAddress.fromCollectionId(collection.collectionId);51 const evmCollection = helper.ethNativeContract.collection(address, 'nft', caller);52 const contract = await proxyWrap(helper, evmCollection, donor);53 const totalSupply = await contract.methods.totalSupply().call();5455 expect(totalSupply).to.equal('1');56 });5758 itEth('balanceOf', async ({helper}) => {59 const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});6061 const caller = await helper.eth.createAccountWithBalance(donor);62 await collection.mintMultipleTokens(alice, [63 {owner: {Ethereum: caller}},64 {owner: {Ethereum: caller}},65 {owner: {Ethereum: caller}},66 ]);6768 const address = helper.ethAddress.fromCollectionId(collection.collectionId);69 const evmCollection = helper.ethNativeContract.collection(address, 'nft', caller);70 const contract = await proxyWrap(helper, evmCollection, donor);71 const balance = await contract.methods.balanceOf(caller).call();7273 expect(balance).to.equal('3');74 });7576 itEth('ownerOf', async ({helper}) => {77 const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});7879 const caller = await helper.eth.createAccountWithBalance(donor);80 const {tokenId} = await collection.mintToken(alice, {Ethereum: caller});8182 const address = helper.ethAddress.fromCollectionId(collection.collectionId);83 const evmCollection = helper.ethNativeContract.collection(address, 'nft', caller);84 const contract = await proxyWrap(helper, evmCollection, donor);85 const owner = await contract.methods.ownerOf(tokenId).call();8687 expect(owner).to.equal(caller);88 });89});9091describe('NFT (Via EVM proxy): Plain calls', () => {92 let alice: IKeyringPair;93 let donor: IKeyringPair;9495 before(async function() {96 await usingEthPlaygrounds(async (helper, privateKey) => {97 donor = await privateKey({filename: __filename});98 [alice] = await helper.arrange.createAccounts([10n], donor);99 });100 });101102 itEth('Can perform mint()', async ({helper}) => {103 const owner = await helper.eth.createAccountWithBalance(donor);104 const {collectionAddress} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner, 'A', 'A', 'A', '');105 const caller = await helper.eth.createAccountWithBalance(donor);106 const receiver = helper.eth.createAccount();107108 const collectionEvmOwned = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);109 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', caller);110 const contract = await proxyWrap(helper, collectionEvm, donor);111 await collectionEvmOwned.methods.addCollectionAdmin(contract.options.address).send();112113 {114 const nextTokenId = await contract.methods.nextTokenId().call()115 const result = await contract.methods.mintWithTokenURI(receiver, nextTokenId, 'Test URI').send({from: caller});116 const tokenId = result.events.Transfer.returnValues.tokenId;117 expect(tokenId).to.be.equal('1');118119 const events = helper.eth.normalizeEvents(result.events);120 events[0].address = events[0].address.toLocaleLowerCase();121122 expect(events).to.be.deep.equal([123 {124 address: collectionAddress.toLocaleLowerCase(),125 event: 'Transfer',126 args: {127 from: '0x0000000000000000000000000000000000000000',128 to: receiver,129 tokenId,130 },131 },132 ]);133134 expect(await contract.methods.tokenURI(tokenId).call()).to.be.equal('Test URI');135 }136 });137138 //TODO: CORE-302 add eth methods139 itEth.skip('Can perform mintBulk()', async ({helper}) => {140 const collection = await helper.nft.mintCollection(donor, {name: 'New', description: 'New collection', tokenPrefix: 'NEW'});141142 const caller = await helper.eth.createAccountWithBalance(donor, 30n);143 const receiver = helper.eth.createAccount();144145 const address = helper.ethAddress.fromCollectionId(collection.collectionId);146 const evmCollection = helper.ethNativeContract.collection(address, 'nft', caller);147 const contract = await proxyWrap(helper, evmCollection, donor);148 await collection.addAdmin(donor, {Ethereum: contract.options.address});149150 {151 const nextTokenId = await contract.methods.nextTokenId().call();152 expect(nextTokenId).to.be.equal('1');153 const result = await contract.methods.mintBulkWithTokenURI(154 receiver,155 [156 [nextTokenId, 'Test URI 0'],157 [+nextTokenId + 1, 'Test URI 1'],158 [+nextTokenId + 2, 'Test URI 2'],159 ],160 ).send({from: caller});161 const events = helper.eth.normalizeEvents(result.events);162163 expect(events).to.be.deep.equal([164 {165 address,166 event: 'Transfer',167 args: {168 from: '0x0000000000000000000000000000000000000000',169 to: receiver,170 tokenId: nextTokenId,171 },172 },173 {174 address,175 event: 'Transfer',176 args: {177 from: '0x0000000000000000000000000000000000000000',178 to: receiver,179 tokenId: String(+nextTokenId + 1),180 },181 },182 {183 address,184 event: 'Transfer',185 args: {186 from: '0x0000000000000000000000000000000000000000',187 to: receiver,188 tokenId: String(+nextTokenId + 2),189 },190 },191 ]);192193 expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('Test URI 0');194 expect(await contract.methods.tokenURI(+nextTokenId + 1).call()).to.be.equal('Test URI 1');195 expect(await contract.methods.tokenURI(+nextTokenId + 2).call()).to.be.equal('Test URI 2');196 }197 });198199 itEth('Can perform burn()', async ({helper}) => {200 const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});201 const caller = await helper.eth.createAccountWithBalance(donor);202203 const address = helper.ethAddress.fromCollectionId(collection.collectionId);204 const evmCollection = helper.ethNativeContract.collection(address, 'nft', caller);205 const contract = await proxyWrap(helper, evmCollection, donor);206 const {tokenId} = await collection.mintToken(alice, {Ethereum: contract.options.address});207 await collection.addAdmin(alice, {Ethereum: contract.options.address});208209 {210 const result = await contract.methods.burn(tokenId).send({from: caller});211 const events = helper.eth.normalizeEvents(result.events);212213 expect(events).to.be.deep.equal([214 {215 address,216 event: 'Transfer',217 args: {218 from: contract.options.address,219 to: '0x0000000000000000000000000000000000000000',220 tokenId: tokenId.toString(),221 },222 },223 ]);224 }225 });226227 itEth('Can perform approve()', async ({helper}) => {228 const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});229 const caller = await helper.eth.createAccountWithBalance(donor);230 const spender = helper.eth.createAccount();231232 const address = helper.ethAddress.fromCollectionId(collection.collectionId);233 const evmCollection = helper.ethNativeContract.collection(address, 'nft', caller);234 const contract = await proxyWrap(helper, evmCollection, donor);235 const {tokenId} = await collection.mintToken(alice, {Ethereum: contract.options.address});236237 {238 const result = await contract.methods.approve(spender, tokenId).send({from: caller, gas: helper.eth.DEFAULT_GAS});239 const events = helper.eth.normalizeEvents(result.events);240241 expect(events).to.be.deep.equal([242 {243 address,244 event: 'Approval',245 args: {246 owner: contract.options.address,247 approved: spender,248 tokenId: tokenId.toString(),249 },250 },251 ]);252 }253 });254255 itEth('Can perform transferFrom()', async ({helper}) => {256 const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});257 const caller = await helper.eth.createAccountWithBalance(donor);258 const owner = await helper.eth.createAccountWithBalance(donor);259260 const receiver = helper.eth.createAccount();261262 const address = helper.ethAddress.fromCollectionId(collection.collectionId);263 const evmCollection = helper.ethNativeContract.collection(address, 'nft', caller);264 const contract = await proxyWrap(helper, evmCollection, donor);265 const {tokenId} = await collection.mintToken(alice, {Ethereum: owner});266267 await evmCollection.methods.approve(contract.options.address, tokenId).send({from: owner});268269 {270 const result = await contract.methods.transferFrom(owner, receiver, tokenId).send({from: caller});271 const events = helper.eth.normalizeEvents(result.events);272 expect(events).to.be.deep.equal([273 {274 address,275 event: 'Transfer',276 args: {277 from: owner,278 to: receiver,279 tokenId: tokenId.toString(),280 },281 },282 ]);283 }284285 {286 const balance = await contract.methods.balanceOf(receiver).call();287 expect(+balance).to.equal(1);288 }289290 {291 const balance = await contract.methods.balanceOf(contract.options.address).call();292 expect(+balance).to.equal(0);293 }294 });295296 itEth('Can perform transfer()', async ({helper}) => {297 const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});298 const caller = await helper.eth.createAccountWithBalance(donor);299 const receiver = helper.eth.createAccount();300301 const address = helper.ethAddress.fromCollectionId(collection.collectionId);302 const evmCollection = helper.ethNativeContract.collection(address, 'nft', caller);303 const contract = await proxyWrap(helper, evmCollection, donor);304 const {tokenId} = await collection.mintToken(alice, {Ethereum: contract.options.address});305306 {307 const result = await contract.methods.transfer(receiver, tokenId).send({from: caller});308 const events = helper.eth.normalizeEvents(result.events);309 expect(events).to.be.deep.equal([310 {311 address,312 event: 'Transfer',313 args: {314 from: contract.options.address,315 to: receiver,316 tokenId: tokenId.toString(),317 },318 },319 ]);320 }321322 {323 const balance = await contract.methods.balanceOf(contract.options.address).call();324 expect(+balance).to.equal(0);325 }326327 {328 const balance = await contract.methods.balanceOf(receiver).call();329 expect(+balance).to.equal(1);330 }331 });332});1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617import {readFile} from 'fs/promises';18import {IKeyringPair} from '@polkadot/types/types';19import {EthUniqueHelper, itEth, usingEthPlaygrounds, expect} from '../util';202122async function proxyWrap(helper: EthUniqueHelper, wrapped: any, donor: IKeyringPair) {23 // Proxy owner has no special privilegies, we don't need to reuse them24 const owner = await helper.eth.createAccountWithBalance(donor);25 const web3 = helper.getWeb3();26 const proxyContract = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/UniqueNFTProxy.abi`)).toString()), undefined, {27 from: owner,28 gas: helper.eth.DEFAULT_GAS,29 });30 const proxy = await proxyContract.deploy({data: (await readFile(`${__dirname}/UniqueNFTProxy.bin`)).toString(), arguments: [wrapped.options.address]}).send({from: owner});31 return proxy;32}3334describe('NFT (Via EVM proxy): Information getting', () => {35 let alice: IKeyringPair;36 let donor: IKeyringPair;3738 before(async function() {39 await usingEthPlaygrounds(async (helper, privateKey) => {40 donor = await privateKey({filename: __filename});41 [alice] = await helper.arrange.createAccounts([10n], donor);42 });43 });4445 itEth('totalSupply', async ({helper}) => {46 const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});47 const caller = await helper.eth.createAccountWithBalance(donor);48 await collection.mintToken(alice, {Substrate: alice.address});4950 const address = helper.ethAddress.fromCollectionId(collection.collectionId);51 const evmCollection = helper.ethNativeContract.collection(address, 'nft', caller);52 const contract = await proxyWrap(helper, evmCollection, donor);53 const totalSupply = await contract.methods.totalSupply().call();5455 expect(totalSupply).to.equal('1');56 });5758 itEth('balanceOf', async ({helper}) => {59 const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});6061 const caller = await helper.eth.createAccountWithBalance(donor);62 await collection.mintMultipleTokens(alice, [63 {owner: {Ethereum: caller}},64 {owner: {Ethereum: caller}},65 {owner: {Ethereum: caller}},66 ]);6768 const address = helper.ethAddress.fromCollectionId(collection.collectionId);69 const evmCollection = helper.ethNativeContract.collection(address, 'nft', caller);70 const contract = await proxyWrap(helper, evmCollection, donor);71 const balance = await contract.methods.balanceOf(caller).call();7273 expect(balance).to.equal('3');74 });7576 itEth('ownerOf', async ({helper}) => {77 const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});7879 const caller = await helper.eth.createAccountWithBalance(donor);80 const {tokenId} = await collection.mintToken(alice, {Ethereum: caller});8182 const address = helper.ethAddress.fromCollectionId(collection.collectionId);83 const evmCollection = helper.ethNativeContract.collection(address, 'nft', caller);84 const contract = await proxyWrap(helper, evmCollection, donor);85 const owner = await contract.methods.ownerOf(tokenId).call();8687 expect(owner).to.equal(caller);88 });89});9091describe('NFT (Via EVM proxy): Plain calls', () => {92 let alice: IKeyringPair;93 let donor: IKeyringPair;9495 before(async function() {96 await usingEthPlaygrounds(async (helper, privateKey) => {97 donor = await privateKey({filename: __filename});98 [alice] = await helper.arrange.createAccounts([10n], donor);99 });100 });101102 itEth('Can perform mint()', async ({helper}) => {103 const owner = await helper.eth.createAccountWithBalance(donor);104 const {collectionAddress} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner, 'A', 'A', 'A', '');105 const caller = await helper.eth.createAccountWithBalance(donor);106 const receiver = helper.eth.createAccount();107108 const collectionEvmOwned = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);109 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', caller);110 const contract = await proxyWrap(helper, collectionEvm, donor);111 await collectionEvmOwned.methods.addCollectionAdmin(contract.options.address).send();112113 {114 const nextTokenId = await contract.methods.nextTokenId().call();115 const result = await contract.methods.mintWithTokenURI(receiver, nextTokenId, 'Test URI').send({from: caller});116 const tokenId = result.events.Transfer.returnValues.tokenId;117 expect(tokenId).to.be.equal('1');118119 const events = helper.eth.normalizeEvents(result.events);120 events[0].address = events[0].address.toLocaleLowerCase();121122 expect(events).to.be.deep.equal([123 {124 address: collectionAddress.toLocaleLowerCase(),125 event: 'Transfer',126 args: {127 from: '0x0000000000000000000000000000000000000000',128 to: receiver,129 tokenId,130 },131 },132 ]);133134 expect(await contract.methods.tokenURI(tokenId).call()).to.be.equal('Test URI');135 }136 });137138 //TODO: CORE-302 add eth methods139 itEth.skip('Can perform mintBulk()', async ({helper}) => {140 const collection = await helper.nft.mintCollection(donor, {name: 'New', description: 'New collection', tokenPrefix: 'NEW'});141142 const caller = await helper.eth.createAccountWithBalance(donor, 30n);143 const receiver = helper.eth.createAccount();144145 const address = helper.ethAddress.fromCollectionId(collection.collectionId);146 const evmCollection = helper.ethNativeContract.collection(address, 'nft', caller);147 const contract = await proxyWrap(helper, evmCollection, donor);148 await collection.addAdmin(donor, {Ethereum: contract.options.address});149150 {151 const nextTokenId = await contract.methods.nextTokenId().call();152 expect(nextTokenId).to.be.equal('1');153 const result = await contract.methods.mintBulkWithTokenURI(154 receiver,155 [156 [nextTokenId, 'Test URI 0'],157 [+nextTokenId + 1, 'Test URI 1'],158 [+nextTokenId + 2, 'Test URI 2'],159 ],160 ).send({from: caller});161 const events = helper.eth.normalizeEvents(result.events);162163 expect(events).to.be.deep.equal([164 {165 address,166 event: 'Transfer',167 args: {168 from: '0x0000000000000000000000000000000000000000',169 to: receiver,170 tokenId: nextTokenId,171 },172 },173 {174 address,175 event: 'Transfer',176 args: {177 from: '0x0000000000000000000000000000000000000000',178 to: receiver,179 tokenId: String(+nextTokenId + 1),180 },181 },182 {183 address,184 event: 'Transfer',185 args: {186 from: '0x0000000000000000000000000000000000000000',187 to: receiver,188 tokenId: String(+nextTokenId + 2),189 },190 },191 ]);192193 expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('Test URI 0');194 expect(await contract.methods.tokenURI(+nextTokenId + 1).call()).to.be.equal('Test URI 1');195 expect(await contract.methods.tokenURI(+nextTokenId + 2).call()).to.be.equal('Test URI 2');196 }197 });198199 itEth('Can perform burn()', async ({helper}) => {200 const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});201 const caller = await helper.eth.createAccountWithBalance(donor);202203 const address = helper.ethAddress.fromCollectionId(collection.collectionId);204 const evmCollection = helper.ethNativeContract.collection(address, 'nft', caller);205 const contract = await proxyWrap(helper, evmCollection, donor);206 const {tokenId} = await collection.mintToken(alice, {Ethereum: contract.options.address});207 await collection.addAdmin(alice, {Ethereum: contract.options.address});208209 {210 const result = await contract.methods.burn(tokenId).send({from: caller});211 const events = helper.eth.normalizeEvents(result.events);212213 expect(events).to.be.deep.equal([214 {215 address,216 event: 'Transfer',217 args: {218 from: contract.options.address,219 to: '0x0000000000000000000000000000000000000000',220 tokenId: tokenId.toString(),221 },222 },223 ]);224 }225 });226227 itEth('Can perform approve()', async ({helper}) => {228 const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});229 const caller = await helper.eth.createAccountWithBalance(donor);230 const spender = helper.eth.createAccount();231232 const address = helper.ethAddress.fromCollectionId(collection.collectionId);233 const evmCollection = helper.ethNativeContract.collection(address, 'nft', caller);234 const contract = await proxyWrap(helper, evmCollection, donor);235 const {tokenId} = await collection.mintToken(alice, {Ethereum: contract.options.address});236237 {238 const result = await contract.methods.approve(spender, tokenId).send({from: caller, gas: helper.eth.DEFAULT_GAS});239 const events = helper.eth.normalizeEvents(result.events);240241 expect(events).to.be.deep.equal([242 {243 address,244 event: 'Approval',245 args: {246 owner: contract.options.address,247 approved: spender,248 tokenId: tokenId.toString(),249 },250 },251 ]);252 }253 });254255 itEth('Can perform transferFrom()', async ({helper}) => {256 const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});257 const caller = await helper.eth.createAccountWithBalance(donor);258 const owner = await helper.eth.createAccountWithBalance(donor);259260 const receiver = helper.eth.createAccount();261262 const address = helper.ethAddress.fromCollectionId(collection.collectionId);263 const evmCollection = helper.ethNativeContract.collection(address, 'nft', caller);264 const contract = await proxyWrap(helper, evmCollection, donor);265 const {tokenId} = await collection.mintToken(alice, {Ethereum: owner});266267 await evmCollection.methods.approve(contract.options.address, tokenId).send({from: owner});268269 {270 const result = await contract.methods.transferFrom(owner, receiver, tokenId).send({from: caller});271 const events = helper.eth.normalizeEvents(result.events);272 expect(events).to.be.deep.equal([273 {274 address,275 event: 'Transfer',276 args: {277 from: owner,278 to: receiver,279 tokenId: tokenId.toString(),280 },281 },282 ]);283 }284285 {286 const balance = await contract.methods.balanceOf(receiver).call();287 expect(+balance).to.equal(1);288 }289290 {291 const balance = await contract.methods.balanceOf(contract.options.address).call();292 expect(+balance).to.equal(0);293 }294 });295296 itEth('Can perform transfer()', async ({helper}) => {297 const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});298 const caller = await helper.eth.createAccountWithBalance(donor);299 const receiver = helper.eth.createAccount();300301 const address = helper.ethAddress.fromCollectionId(collection.collectionId);302 const evmCollection = helper.ethNativeContract.collection(address, 'nft', caller);303 const contract = await proxyWrap(helper, evmCollection, donor);304 const {tokenId} = await collection.mintToken(alice, {Ethereum: contract.options.address});305306 {307 const result = await contract.methods.transfer(receiver, tokenId).send({from: caller});308 const events = helper.eth.normalizeEvents(result.events);309 expect(events).to.be.deep.equal([310 {311 address,312 event: 'Transfer',313 args: {314 from: contract.options.address,315 to: receiver,316 tokenId: tokenId.toString(),317 },318 },319 ]);320 }321322 {323 const balance = await contract.methods.balanceOf(contract.options.address).call();324 expect(+balance).to.equal(0);325 }326327 {328 const balance = await contract.methods.balanceOf(receiver).call();329 expect(+balance).to.equal(1);330 }331 });332});tests/src/eth/util/index.tsdiffbeforeafterboth--- a/tests/src/eth/util/index.ts
+++ b/tests/src/eth/util/index.ts
@@ -14,7 +14,7 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import chaiLike from 'chai-like';
-import {getTestSeed, requirePalletsOrSkip} from '../../util';
+import {getTestSeed, MINIMUM_DONOR_FUND, requirePalletsOrSkip} from '../../util';
chai.use(chaiAsPromised);
chai.use(chaiLike);
@@ -43,7 +43,7 @@
else {
const actualSeed = getTestSeed(seed.filename);
let account = helper.util.fromSeed(actualSeed, ss58Format);
- if (await helper.balance.getSubstrate(account.address) == 0n) {
+ if (await helper.balance.getSubstrate(account.address) < MINIMUM_DONOR_FUND) {
console.warn(`${path.basename(seed.filename)}: Not enough funds present on the filename account. Using the default one as the donor instead.`);
account = helper.util.fromSeed('//Alice', ss58Format);
}
tests/src/eth/util/playgrounds/unique.dev.tsdiffbeforeafterboth--- a/tests/src/eth/util/playgrounds/unique.dev.ts
+++ b/tests/src/eth/util/playgrounds/unique.dev.ts
@@ -189,7 +189,7 @@
async createERC721MetadataCompatibleNFTCollection(signer: string, name: string, description: string, tokenPrefix: string, baseUri: string): Promise<{collectionId: number, collectionAddress: string}> {
const collectionHelper = this.helper.ethNativeContract.collectionHelpers(signer);
- const {collectionId, collectionAddress} = await this.createNFTCollection(signer, name, description, tokenPrefix)
+ const {collectionId, collectionAddress} = await this.createNFTCollection(signer, name, description, tokenPrefix);
await collectionHelper.methods.makeCollectionERC721MetadataCompatible(collectionAddress, baseUri).send();
@@ -211,7 +211,7 @@
async createERC721MetadataCompatibleRFTCollection(signer: string, name: string, description: string, tokenPrefix: string, baseUri: string): Promise<{collectionId: number, collectionAddress: string}> {
const collectionHelper = this.helper.ethNativeContract.collectionHelpers(signer);
- const {collectionId, collectionAddress} = await this.createRFTCollection(signer, name, description, tokenPrefix)
+ const {collectionId, collectionAddress} = await this.createRFTCollection(signer, name, description, tokenPrefix);
await collectionHelper.methods.makeCollectionERC721MetadataCompatible(collectionAddress, baseUri).send();
tests/src/pallet-presence.test.tsdiffbeforeafterboth--- a/tests/src/pallet-presence.test.ts
+++ b/tests/src/pallet-presence.test.ts
@@ -62,7 +62,7 @@
const chain = await helper.callRpc('api.rpc.system.chain', []);
const refungible = 'refungible';
- const scheduler = 'scheduler';
+ // const scheduler = 'scheduler';
const foreignAssets = 'foreignassets';
const rmrkPallets = ['rmrkcore', 'rmrkequip'];
const appPromotion = 'apppromotion';
@@ -70,7 +70,7 @@
if (chain.eq('OPAL by UNIQUE')) {
requiredPallets.push(
refungible,
- scheduler,
+ // scheduler,
foreignAssets,
appPromotion,
...rmrkPallets,