difftreelog
Tests: refactor fractionalizer tests to playgrounds
in: master
3 files changed
tests/package.jsondiffbeforeafterboth30 "testEth": "mocha --timeout 9999999 -r ts-node/register './**/eth/**/*.test.ts'",30 "testEth": "mocha --timeout 9999999 -r ts-node/register './**/eth/**/*.test.ts'",31 "testEthMarketplace": "mocha --timeout 9999999 -r ts-node/register './**/eth/marketplace/**/*.test.ts'",31 "testEthMarketplace": "mocha --timeout 9999999 -r ts-node/register './**/eth/marketplace/**/*.test.ts'",32 "testEthNesting": "mocha --timeout 9999999 -r ts-node/register './**/eth/nesting/**/*.test.ts'",32 "testEthNesting": "mocha --timeout 9999999 -r ts-node/register './**/eth/nesting/**/*.test.ts'",33 "testEthFractionalizer": "mocha --timeout 9999999 -r ts-node/register './**/eth/fractionalizer/**/*.test.ts'",33 "testEthPayable": "mocha --timeout 9999999 -r ts-node/register './**/eth/payable.test.ts'",34 "testEthPayable": "mocha --timeout 9999999 -r ts-node/register './**/eth/payable.test.ts'",34 "load": "mocha --timeout 9999999 -r ts-node/register './**/*.load.ts'",35 "load": "mocha --timeout 9999999 -r ts-node/register './**/*.load.ts'",35 "loadTransfer": "ts-node src/transfer.nload.ts",36 "loadTransfer": "ts-node src/transfer.nload.ts",tests/src/eth/fractionalizer/fractionalizer.test.tsdiffbeforeafterboth15// 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/>.1616171718import Web3 from 'web3';19import {ApiPromise} from '@polkadot/api';20import {evmToAddress} from '@polkadot/util-crypto';21import {readFile} from 'fs/promises';18import {readFile} from 'fs/promises';22import {executeTransaction, submitTransactionAsync} from '../../substrate/substrate-api';23import {getCreateCollectionResult, getCreateItemResult, UNIQUE, requirePallets, Pallets} from '../../util/helpers';24import {collectionIdToAddress, CompiledContract, createEthAccountWithBalance, createNonfungibleCollection, createRFTCollection, GAS_ARGS, itWeb3, tokenIdFromAddress, uniqueNFT, uniqueRefungible, uniqueRefungibleToken} from '../util/helpers';25import {Contract} from 'web3-eth-contract';26import * as solc from 'solc';271928import chai from 'chai';29import chaiLike from 'chai-like';30import {IKeyringPair} from '@polkadot/types/types';20import {IKeyringPair} from '@polkadot/types/types';31chai.use(chaiLike);32const expect = chai.expect;21import {evmToAddress} from '@polkadot/util-crypto';33let fractionalizer: CompiledContract;342235async function compileFractionalizer() {23import {Contract} from 'web3-eth-contract';36 if (!fractionalizer) {37 const input = {38 language: 'Solidity',39 sources: {40 ['Fractionalizer.sol']: {41 content: (await readFile(`${__dirname}/Fractionalizer.sol`)).toString(),42 },43 },44 settings: {45 outputSelection: {46 '*': {47 '*': ['*'],48 },49 },50 },51 };52 const json = JSON.parse(solc.compile(JSON.stringify(input), {import: await findImports()}));53 const out = json.contracts['Fractionalizer.sol']['Fractionalizer'];542455 fractionalizer = {25import {usingEthPlaygrounds, expect, itEth, EthUniqueHelper} from '../util/playgrounds';26import {CompiledContract} from '../util/playgrounds/types';27import {requirePalletsOrSkip, Pallets} from '../../util/playgrounds';282930let compiledFractionalizer: CompiledContract;3132const compileContract = async (helper: EthUniqueHelper): Promise<CompiledContract> => {56 abi: out.abi,33 if(!compiledFractionalizer) {34 compiledFractionalizer = await helper.ethContract.compile('Fractionalizer', (await readFile(`${__dirname}/Fractionalizer.sol`)).toString(), [35 {solPath: 'api/CollectionHelpers.sol', fsPath: `${__dirname}/../api/CollectionHelpers.sol`},57 object: '0x' + out.evm.bytecode.object,36 {solPath: 'api/ContractHelpers.sol', fsPath: `${__dirname}/../api/ContractHelpers.sol`},58 };37 {solPath: 'api/UniqueRefungibleToken.sol', fsPath: `${__dirname}/../api/UniqueRefungibleToken.sol`},38 {solPath: 'api/UniqueRefungible.sol', fsPath: `${__dirname}/../api/UniqueRefungible.sol`},39 {solPath: 'api/UniqueNFT.sol', fsPath: `${__dirname}/../api/UniqueNFT.sol`},40 ]);59 }41 }60 return fractionalizer;42 return compiledFractionalizer;61}43}624463async function findImports() {64 const collectionHelpers = (await readFile(`${__dirname}/../api/CollectionHelpers.sol`)).toString();65 const contractHelpers = (await readFile(`${__dirname}/../api/ContractHelpers.sol`)).toString();66 const uniqueRefungibleToken = (await readFile(`${__dirname}/../api/UniqueRefungibleToken.sol`)).toString();67 const uniqueRefungible = (await readFile(`${__dirname}/../api/UniqueRefungible.sol`)).toString();68 const uniqueNFT = (await readFile(`${__dirname}/../api/UniqueNFT.sol`)).toString();694570 return function(path: string) {46const deployContract = async (helper: EthUniqueHelper, owner: string): Promise<Contract> => {71 switch (path) {72 case 'api/CollectionHelpers.sol': return {contents: `${collectionHelpers}`};73 case 'api/ContractHelpers.sol': return {contents: `${contractHelpers}`};47 const compiled = await compileContract(helper);74 case 'api/UniqueRefungibleToken.sol': return {contents: `${uniqueRefungibleToken}`};48 return await helper.ethContract.deployByAbi(owner, compiled.abi, compiled.object);75 case 'api/UniqueRefungible.sol': return {contents: `${uniqueRefungible}`};76 case 'api/UniqueNFT.sol': return {contents: `${uniqueNFT}`};77 default: return {error: 'File not found'};78 }79 };80}49}815082async function deployFractionalizer(web3: Web3, owner: string) {83 const compiled = await compileFractionalizer();84 const fractionalizerContract = new web3.eth.Contract(compiled.abi, undefined, {85 data: compiled.object,86 from: owner,87 ...GAS_ARGS,88 });89 return await fractionalizerContract.deploy({data: compiled.object}).send({from: owner});90}915192async function initFractionalizer(api: ApiPromise, web3: Web3, privateKeyWrapper: (account: string) => IKeyringPair, owner: string) {52const initContract = async (helper: EthUniqueHelper, owner: string): Promise<{contract: Contract, rftCollectionAddress: string}> => {93 const fractionalizer = await deployFractionalizer(web3, owner);53 const fractionalizer = await deployContract(helper, owner);94 const amount = 10n * UNIQUE;54 const amount = 10n * helper.balance.getOneTokenNominal();95 await web3.eth.sendTransaction({from: owner, to: fractionalizer.options.address, value: `${amount}`, ...GAS_ARGS});55 const web3 = helper.getWeb3();56 await web3.eth.sendTransaction({from: owner, to: fractionalizer.options.address, value: `${amount}`, gas: helper.eth.DEFAULT_GAS});96 const result = await fractionalizer.methods.createAndSetRFTCollection('A', 'B', 'C').send({value: Number(2n * UNIQUE)});57 const result = await fractionalizer.methods.createAndSetRFTCollection('A', 'B', 'C').send({value: Number(2n * helper.balance.getOneTokenNominal())});97 const rftCollectionAddress = result.events.RFTCollectionSet.returnValues._collection;58 const rftCollectionAddress = result.events.RFTCollectionSet.returnValues._collection;98 return {fractionalizer, rftCollectionAddress};59 return {contract: fractionalizer, rftCollectionAddress};99}60}10061101async function createRFTToken(api: ApiPromise, web3: Web3, owner: string, fractionalizer: Contract, amount: bigint) {62const mintRFTToken = async (helper: EthUniqueHelper, owner: string, fractionalizer: Contract, amount: bigint): Promise<{102 const {collectionIdAddress: nftCollectionAddress} = await createNonfungibleCollection(api, web3, owner);63 nftCollectionAddress: string, nftTokenId: number, rftTokenAddress: string64}> => {65 const nftCollection = await helper.eth.createNonfungibleCollection(owner, 'nft', 'NFT collection', 'NFT');103 const nftContract = uniqueNFT(web3, nftCollectionAddress, owner);66 const nftContract = helper.ethNativeContract.collection(nftCollection.collectionAddress, 'nft', owner);104 const nftTokenId = await nftContract.methods.nextTokenId().call();67 const nftTokenId = await nftContract.methods.nextTokenId().call();105 await nftContract.methods.mint(owner, nftTokenId).send();68 await nftContract.methods.mint(owner, nftTokenId).send({from: owner});10669107 await fractionalizer.methods.setNftCollectionIsAllowed(nftCollectionAddress, true).send();70 await fractionalizer.methods.setNftCollectionIsAllowed(nftCollection.collectionAddress, true).send({from: owner});108 await nftContract.methods.approve(fractionalizer.options.address, nftTokenId).send();71 await nftContract.methods.approve(fractionalizer.options.address, nftTokenId).send({from: owner});109 const result = await fractionalizer.methods.nft2rft(nftCollectionAddress, nftTokenId, amount).send();72 const result = await fractionalizer.methods.nft2rft(nftCollection.collectionAddress, nftTokenId, amount).send({from: owner});110 const {_collection, _tokenId, _rftToken} = result.events.Fractionalized.returnValues;73 const {_collection, _tokenId, _rftToken} = result.events.Fractionalized.returnValues;111 return {74 return {112 nftCollectionAddress: _collection,75 nftCollectionAddress: _collection,115 };78 };116}79}1178081118describe('Fractionalizer contract usage', () => {82describe('Fractionalizer contract usage', () => {83 let donor: IKeyringPair;84119 before(async function() {85 before(async function() {120 await requirePallets(this, [Pallets.ReFungible]);86 await usingEthPlaygrounds(async (helper: EthUniqueHelper, privateKey) => {87 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);88 donor = privateKey('//Alice');89 });121 });90 });12291123 itWeb3('Set RFT collection', async ({api, web3, privateKeyWrapper}) => {92 itEth('Set RFT collection', async ({helper}) => {124 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);93 const owner = await helper.eth.createAccountWithBalance(donor, 10n);125 const fractionalizer = await deployFractionalizer(web3, owner);94 const fractionalizer = await deployContract(helper, owner);126 const {collectionIdAddress} = await createRFTCollection(api, web3, owner);95 const rftCollection = await helper.eth.createRefungibleCollection(owner, 'rft', 'RFT collection', 'RFT');127 const refungibleContract = uniqueRefungible(web3, collectionIdAddress, owner);96 const rftContract = helper.ethNativeContract.collection(rftCollection.collectionAddress, 'rft', owner);97128 await refungibleContract.methods.addCollectionAdmin(fractionalizer.options.address).send();98 await rftContract.methods.addCollectionAdmin(fractionalizer.options.address).send({from: owner});129 const result = await fractionalizer.methods.setRFTCollection(collectionIdAddress).send();99 const result = await fractionalizer.methods.setRFTCollection(rftCollection.collectionAddress).send({from: owner});130 expect(result.events).to.be.like({100 expect(result.events).to.be.like({131 RFTCollectionSet: {101 RFTCollectionSet: {132 returnValues: {102 returnValues: {133 _collection: collectionIdAddress,103 _collection: rftCollection.collectionAddress,134 },104 },135 },105 },136 });106 });137 });107 });138108139 itWeb3('Mint RFT collection', async ({api, web3, privateKeyWrapper}) => {109 itEth('Mint RFT collection', async ({helper}) => {140 const alice = privateKeyWrapper('//Alice');110 const owner = await helper.eth.createAccountWithBalance(donor, 10n);141 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);142 const fractionalizer = await deployFractionalizer(web3, owner);111 const fractionalizer = await deployContract(helper, owner);143 const tx = api.tx.balances.transfer(evmToAddress(fractionalizer.options.address), 10n * UNIQUE);112 await helper.balance.transferToSubstrate(donor, evmToAddress(fractionalizer.options.address), 10n * helper.balance.getOneTokenNominal());144 await executeTransaction(api, alice, tx);145113146 const result = await fractionalizer.methods.createAndSetRFTCollection('A', 'B', 'C').send({from: owner, value: Number(2n * UNIQUE)});114 const result = await fractionalizer.methods.createAndSetRFTCollection('A', 'B', 'C').send({from: owner, value: Number(2n * helper.balance.getOneTokenNominal())});147 expect(result.events).to.be.like({115 expect(result.events).to.be.like({148 RFTCollectionSet: {},116 RFTCollectionSet: {},149 });117 });150 expect(result.events.RFTCollectionSet.returnValues._collection).to.be.ok;118 expect(result.events.RFTCollectionSet.returnValues._collection).to.be.ok;151 });119 });152120153 itWeb3('Set Allowlist', async ({api, web3, privateKeyWrapper}) => {121 itEth('Set Allowlist', async ({helper}) => {154 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);122 const owner = await helper.eth.createAccountWithBalance(donor, 20n);155 const {fractionalizer} = await initFractionalizer(api, web3, privateKeyWrapper, owner);123 const {contract: fractionalizer} = await initContract(helper, owner);156 const {collectionIdAddress: nftCollectionAddress} = await createNonfungibleCollection(api, web3, owner);124 const nftCollection = await helper.eth.createNonfungibleCollection(owner, 'nft', 'NFT collection', 'NFT');125157 const result1 = await fractionalizer.methods.setNftCollectionIsAllowed(nftCollectionAddress, true).send({from: owner});126 const result1 = await fractionalizer.methods.setNftCollectionIsAllowed(nftCollection.collectionAddress, true).send({from: owner});158 expect(result1.events).to.be.like({127 expect(result1.events).to.be.like({159 AllowListSet: {128 AllowListSet: {160 returnValues: {129 returnValues: {161 _collection: nftCollectionAddress,130 _collection: nftCollection.collectionAddress,162 _status: true,131 _status: true,163 },132 },164 },133 },165 });134 });166 const result2 = await fractionalizer.methods.setNftCollectionIsAllowed(nftCollectionAddress, false).send({from: owner});135 const result2 = await fractionalizer.methods.setNftCollectionIsAllowed(nftCollection.collectionAddress, false).send({from: owner});167 expect(result2.events).to.be.like({136 expect(result2.events).to.be.like({168 AllowListSet: {137 AllowListSet: {169 returnValues: {138 returnValues: {170 _collection: nftCollectionAddress,139 _collection: nftCollection.collectionAddress,171 _status: false,140 _status: false,172 },141 },173 },142 },174 });143 });175 });144 });176145177 itWeb3('NFT to RFT', async ({api, web3, privateKeyWrapper}) => {146 itEth('NFT to RFT', async ({helper}) => {178 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);147 const owner = await helper.eth.createAccountWithBalance(donor, 20n);179148180 const {collectionIdAddress: nftCollectionAddress} = await createNonfungibleCollection(api, web3, owner);149 const nftCollection = await helper.eth.createNonfungibleCollection(owner, 'nft', 'NFT collection', 'NFT');181 const nftContract = uniqueNFT(web3, nftCollectionAddress, owner);150 const nftContract = helper.ethNativeContract.collection(nftCollection.collectionAddress, 'nft', owner);182 const nftTokenId = await nftContract.methods.nextTokenId().call();151 const nftTokenId = await nftContract.methods.nextTokenId().call();183 await nftContract.methods.mint(owner, nftTokenId).send();152 await nftContract.methods.mint(owner, nftTokenId).send({from: owner});184153185 const {fractionalizer} = await initFractionalizer(api, web3, privateKeyWrapper, owner);154 const {contract: fractionalizer} = await initContract(helper, owner);186155187 await fractionalizer.methods.setNftCollectionIsAllowed(nftCollectionAddress, true).send();156 await fractionalizer.methods.setNftCollectionIsAllowed(nftCollection.collectionAddress, true).send({from: owner});188 await nftContract.methods.approve(fractionalizer.options.address, nftTokenId).send();157 await nftContract.methods.approve(fractionalizer.options.address, nftTokenId).send({from: owner});189 const result = await fractionalizer.methods.nft2rft(nftCollectionAddress, nftTokenId, 100).send();158 const result = await fractionalizer.methods.nft2rft(nftCollection.collectionAddress, nftTokenId, 100).send({from: owner});190 expect(result.events).to.be.like({159 expect(result.events).to.be.like({191 Fractionalized: {160 Fractionalized: {192 returnValues: {161 returnValues: {193 _collection: nftCollectionAddress,162 _collection: nftCollection.collectionAddress,194 _tokenId: nftTokenId,163 _tokenId: nftTokenId,195 _amount: '100',164 _amount: '100',196 },165 },197 },166 },198 });167 });199 const rftTokenAddress = result.events.Fractionalized.returnValues._rftToken;168 const rftTokenAddress = result.events.Fractionalized.returnValues._rftToken;169200 const rftTokenContract = uniqueRefungibleToken(web3, rftTokenAddress, owner);170 const rftTokenContract = helper.ethNativeContract.rftToken(rftTokenAddress);201 expect(await rftTokenContract.methods.balanceOf(owner).call()).to.equal('100');171 expect(await rftTokenContract.methods.balanceOf(owner).call()).to.equal('100');202 });172 });203173204 itWeb3('RFT to NFT', async ({api, web3, privateKeyWrapper}) => {174 itEth('RFT to NFT', async ({helper}) => {205 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);175 const owner = await helper.eth.createAccountWithBalance(donor, 20n);206176207 const {fractionalizer, rftCollectionAddress} = await initFractionalizer(api, web3, privateKeyWrapper, owner);177 const {contract: fractionalizer, rftCollectionAddress} = await initContract(helper, owner);208 const {rftTokenAddress, nftCollectionAddress, nftTokenId} = await createRFTToken(api, web3, owner, fractionalizer, 100n);178 const {rftTokenAddress, nftCollectionAddress, nftTokenId} = await mintRFTToken(helper, owner, fractionalizer, 100n);209179210 const {collectionId, tokenId} = tokenIdFromAddress(rftTokenAddress);180 const {collectionId, tokenId} = helper.ethAddress.extractTokenId(rftTokenAddress);211 const refungibleAddress = collectionIdToAddress(collectionId);181 const refungibleAddress = helper.ethAddress.fromCollectionId(collectionId);212 expect(rftCollectionAddress).to.be.equal(refungibleAddress);182 expect(rftCollectionAddress).to.be.equal(refungibleAddress);213 const refungibleTokenContract = uniqueRefungibleToken(web3, rftTokenAddress, owner);183 const refungibleTokenContract = helper.ethNativeContract.rftToken(rftTokenAddress, owner);214 await refungibleTokenContract.methods.approve(fractionalizer.options.address, 100).send();184 await refungibleTokenContract.methods.approve(fractionalizer.options.address, 100).send({from: owner});215 const result = await fractionalizer.methods.rft2nft(refungibleAddress, tokenId).send();185 const result = await fractionalizer.methods.rft2nft(refungibleAddress, tokenId).send({from: owner});216 expect(result.events).to.be.like({186 expect(result.events).to.be.like({217 Defractionalized: {187 Defractionalized: {218 returnValues: {188 returnValues: {224 });194 });225 });195 });226196227 itWeb3('Test fractionalizer NFT <-> RFT mapping ', async ({api, web3, privateKeyWrapper}) => {197 itEth('Test fractionalizer NFT <-> RFT mapping ', async ({helper}) => {228 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);198 const owner = await helper.eth.createAccountWithBalance(donor, 20n);229199230 const {fractionalizer, rftCollectionAddress} = await initFractionalizer(api, web3, privateKeyWrapper, owner);200 const {contract: fractionalizer, rftCollectionAddress} = await initContract(helper, owner);231 const {rftTokenAddress, nftCollectionAddress, nftTokenId} = await createRFTToken(api, web3, owner, fractionalizer, 100n);201 const {rftTokenAddress, nftCollectionAddress, nftTokenId} = await mintRFTToken(helper, owner, fractionalizer, 100n);232202233 const {collectionId, tokenId} = tokenIdFromAddress(rftTokenAddress);203 const {collectionId, tokenId} = helper.ethAddress.extractTokenId(rftTokenAddress);234 const refungibleAddress = collectionIdToAddress(collectionId);204 const refungibleAddress = helper.ethAddress.fromCollectionId(collectionId);235 expect(rftCollectionAddress).to.be.equal(refungibleAddress);205 expect(rftCollectionAddress).to.be.equal(refungibleAddress);236 const refungibleTokenContract = uniqueRefungibleToken(web3, rftTokenAddress, owner);206 const refungibleTokenContract = helper.ethNativeContract.rftToken(rftTokenAddress, owner);237 await refungibleTokenContract.methods.approve(fractionalizer.options.address, 100).send();207 await refungibleTokenContract.methods.approve(fractionalizer.options.address, 100).send({from: owner});238208239 const rft2nft = await fractionalizer.methods.rft2nftMapping(rftTokenAddress).call();209 const rft2nft = await fractionalizer.methods.rft2nftMapping(rftTokenAddress).call();240 expect(rft2nft).to.be.like({210 expect(rft2nft).to.be.like({250220251221252describe('Negative Integration Tests for fractionalizer', () => {222describe('Negative Integration Tests for fractionalizer', () => {223 let donor: IKeyringPair;224253 before(async function() {225 before(async function() {254 await requirePallets(this, [Pallets.ReFungible]);226 await usingEthPlaygrounds(async (helper: EthUniqueHelper, privateKey) => {227 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);228 donor = privateKey('//Alice');229 });255 });230 });256231257 itWeb3('call setRFTCollection twice', async ({api, web3, privateKeyWrapper}) => {232 itEth('call setRFTCollection twice', async ({helper}) => {258 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);233 const owner = await helper.eth.createAccountWithBalance(donor, 20n);259 const {collectionIdAddress} = await createRFTCollection(api, web3, owner);234 const rftCollection = await helper.eth.createRefungibleCollection(owner, 'rft', 'RFT collection', 'RFT');260 const refungibleContract = uniqueRefungible(web3, collectionIdAddress, owner);235 const refungibleContract = helper.ethNativeContract.collection(rftCollection.collectionAddress, 'rft', owner);261236262 const fractionalizer = await deployFractionalizer(web3, owner);237 const fractionalizer = await deployContract(helper, owner);263 await refungibleContract.methods.addCollectionAdmin(fractionalizer.options.address).send();238 await refungibleContract.methods.addCollectionAdmin(fractionalizer.options.address).send({from: owner});264 await fractionalizer.methods.setRFTCollection(collectionIdAddress).send();239 await fractionalizer.methods.setRFTCollection(rftCollection.collectionAddress).send({from: owner});265240266 await expect(fractionalizer.methods.setRFTCollection(collectionIdAddress).call())241 await expect(fractionalizer.methods.setRFTCollection(rftCollection.collectionAddress).call())267 .to.be.rejectedWith(/RFT collection is already set$/g);242 .to.be.rejectedWith(/RFT collection is already set$/g);268 });243 });269244270 itWeb3('call setRFTCollection with NFT collection', async ({api, web3, privateKeyWrapper}) => {245 itEth('call setRFTCollection with NFT collection', async ({helper}) => {271 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);246 const owner = await helper.eth.createAccountWithBalance(donor, 20n);272 const {collectionIdAddress} = await createNonfungibleCollection(api, web3, owner);247 const nftCollection = await helper.eth.createNonfungibleCollection(owner, 'nft', 'NFT collection', 'NFT');273 const nftContract = uniqueNFT(web3, collectionIdAddress, owner);248 const nftContract = helper.ethNativeContract.collection(nftCollection.collectionAddress, 'nft', owner);274249275 const fractionalizer = await deployFractionalizer(web3, owner);250 const fractionalizer = await deployContract(helper, owner);276 await nftContract.methods.addCollectionAdmin(fractionalizer.options.address).send();251 await nftContract.methods.addCollectionAdmin(fractionalizer.options.address).send({from: owner});277252278 await expect(fractionalizer.methods.setRFTCollection(collectionIdAddress).call())253 await expect(fractionalizer.methods.setRFTCollection(nftCollection.collectionAddress).call())279 .to.be.rejectedWith(/Wrong collection type. Collection is not refungible.$/g);254 .to.be.rejectedWith(/Wrong collection type. Collection is not refungible.$/g);280 });255 });281256282 itWeb3('call setRFTCollection while not collection admin', async ({api, web3, privateKeyWrapper}) => {257 itEth('call setRFTCollection while not collection admin', async ({helper}) => {283 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);258 const owner = await helper.eth.createAccountWithBalance(donor, 20n);284 const fractionalizer = await deployFractionalizer(web3, owner);259 const fractionalizer = await deployContract(helper, owner);285 const {collectionIdAddress} = await createRFTCollection(api, web3, owner);260 const rftCollection = await helper.eth.createRefungibleCollection(owner, 'rft', 'RFT collection', 'RFT');286261287 await expect(fractionalizer.methods.setRFTCollection(collectionIdAddress).call())262 await expect(fractionalizer.methods.setRFTCollection(rftCollection.collectionAddress).call())288 .to.be.rejectedWith(/Fractionalizer contract should be an admin of the collection$/g);263 .to.be.rejectedWith(/Fractionalizer contract should be an admin of the collection$/g);289 });264 });290265291 itWeb3('call setRFTCollection after createAndSetRFTCollection', async ({api, web3, privateKeyWrapper}) => {266 itEth('call setRFTCollection after createAndSetRFTCollection', async ({helper}) => {292 const alice = privateKeyWrapper('//Alice');267 const owner = await helper.eth.createAccountWithBalance(donor, 20n);293 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);294 const fractionalizer = await deployFractionalizer(web3, owner);268 const fractionalizer = await deployContract(helper, owner);295 const tx = api.tx.balances.transfer(evmToAddress(fractionalizer.options.address), 10n * UNIQUE);269 await helper.balance.transferToSubstrate(donor, evmToAddress(fractionalizer.options.address), 10n * helper.balance.getOneTokenNominal());296 await submitTransactionAsync(alice, tx);297270298 const result = await fractionalizer.methods.createAndSetRFTCollection('A', 'B', 'C').send({from: owner, value: Number(2n * UNIQUE)});271 const result = await fractionalizer.methods.createAndSetRFTCollection('A', 'B', 'C').send({from: owner, value: Number(2n * helper.balance.getOneTokenNominal())});299 const collectionIdAddress = result.events.RFTCollectionSet.returnValues._collection;272 const collectionIdAddress = result.events.RFTCollectionSet.returnValues._collection;300273301 await expect(fractionalizer.methods.setRFTCollection(collectionIdAddress).call())274 await expect(fractionalizer.methods.setRFTCollection(collectionIdAddress).call())302 .to.be.rejectedWith(/RFT collection is already set$/g);275 .to.be.rejectedWith(/RFT collection is already set$/g);303 });276 });304277305 itWeb3('call nft2rft without setting RFT collection for contract', async ({api, web3, privateKeyWrapper}) => {278 itEth('call nft2rft without setting RFT collection for contract', async ({helper}) => {306 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);279 const owner = await helper.eth.createAccountWithBalance(donor, 20n);307280308 const {collectionIdAddress: nftCollectionAddress} = await createNonfungibleCollection(api, web3, owner);281 const nftCollection = await helper.eth.createNonfungibleCollection(owner, 'nft', 'NFT collection', 'NFT');309 const nftContract = uniqueNFT(web3, nftCollectionAddress, owner);282 const nftContract = helper.ethNativeContract.collection(nftCollection.collectionAddress, 'nft', owner);310 const nftTokenId = await nftContract.methods.nextTokenId().call();283 const nftTokenId = await nftContract.methods.nextTokenId().call();311 await nftContract.methods.mint(owner, nftTokenId).send();284 await nftContract.methods.mint(owner, nftTokenId).send({from: owner});312285313 const fractionalizer = await deployFractionalizer(web3, owner);286 const fractionalizer = await deployContract(helper, owner);314287315 await expect(fractionalizer.methods.nft2rft(nftCollectionAddress, nftTokenId, 100).call())288 await expect(fractionalizer.methods.nft2rft(nftCollection.collectionAddress, nftTokenId, 100).call())316 .to.be.rejectedWith(/RFT collection is not set$/g);289 .to.be.rejectedWith(/RFT collection is not set$/g);317 });290 });318291319 itWeb3('call nft2rft while not owner of NFT token', async ({api, web3, privateKeyWrapper}) => {292 itEth('call nft2rft while not owner of NFT token', async ({helper}) => {320 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);293 const owner = await helper.eth.createAccountWithBalance(donor, 20n);321 const nftOwner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);294 const nftOwner = await helper.eth.createAccountWithBalance(donor, 10n);322295323 const {collectionIdAddress: nftCollectionAddress} = await createNonfungibleCollection(api, web3, owner);296 const nftCollection = await helper.eth.createNonfungibleCollection(owner, 'nft', 'NFT collection', 'NFT');324 const nftContract = uniqueNFT(web3, nftCollectionAddress, owner);297 const nftContract = helper.ethNativeContract.collection(nftCollection.collectionAddress, 'nft', owner);325 const nftTokenId = await nftContract.methods.nextTokenId().call();298 const nftTokenId = await nftContract.methods.nextTokenId().call();326 await nftContract.methods.mint(owner, nftTokenId).send();299 await nftContract.methods.mint(owner, nftTokenId).send({from: owner});327 await nftContract.methods.transfer(nftOwner, 1).send();300 await nftContract.methods.transfer(nftOwner, 1).send({from: owner});328301329302330 const {fractionalizer} = await initFractionalizer(api, web3, privateKeyWrapper, owner);303 const {contract: fractionalizer} = await initContract(helper, owner);331 await fractionalizer.methods.setNftCollectionIsAllowed(nftCollectionAddress, true).send();304 await fractionalizer.methods.setNftCollectionIsAllowed(nftCollection.collectionAddress, true).send({from: owner});332305333 await expect(fractionalizer.methods.nft2rft(nftCollectionAddress, nftTokenId, 100).call())306 await expect(fractionalizer.methods.nft2rft(nftCollection.collectionAddress, nftTokenId, 100).call({from: owner}))334 .to.be.rejectedWith(/Only token owner could fractionalize it$/g);307 .to.be.rejectedWith(/Only token owner could fractionalize it$/g);335 });308 });336309337 itWeb3('call nft2rft while not in list of allowed accounts', async ({api, web3, privateKeyWrapper}) => {310 itEth('call nft2rft while not in list of allowed accounts', async ({helper}) => {338 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);311 const owner = await helper.eth.createAccountWithBalance(donor, 20n);339312340 const {collectionIdAddress: nftCollectionAddress} = await createNonfungibleCollection(api, web3, owner);313 const nftCollection = await helper.eth.createNonfungibleCollection(owner, 'nft', 'NFT collection', 'NFT');341 const nftContract = uniqueNFT(web3, nftCollectionAddress, owner);314 const nftContract = helper.ethNativeContract.collection(nftCollection.collectionAddress, 'nft', owner);342 const nftTokenId = await nftContract.methods.nextTokenId().call();315 const nftTokenId = await nftContract.methods.nextTokenId().call();343 await nftContract.methods.mint(owner, nftTokenId).send();316 await nftContract.methods.mint(owner, nftTokenId).send({from: owner});344317345 const {fractionalizer} = await initFractionalizer(api, web3, privateKeyWrapper, owner);318 const {contract: fractionalizer} = await initContract(helper, owner);346319347 await nftContract.methods.approve(fractionalizer.options.address, nftTokenId).send();320 await nftContract.methods.approve(fractionalizer.options.address, nftTokenId).send({from: owner});348 await expect(fractionalizer.methods.nft2rft(nftCollectionAddress, nftTokenId, 100).call())321 await expect(fractionalizer.methods.nft2rft(nftCollection.collectionAddress, nftTokenId, 100).call())349 .to.be.rejectedWith(/Fractionalization of this collection is not allowed by admin$/g);322 .to.be.rejectedWith(/Fractionalization of this collection is not allowed by admin$/g);350 });323 });351324352 itWeb3('call nft2rft while fractionalizer doesnt have approval for nft token', async ({api, web3, privateKeyWrapper}) => {325 itEth('call nft2rft while fractionalizer doesnt have approval for nft token', async ({helper}) => {353 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);326 const owner = await helper.eth.createAccountWithBalance(donor, 20n);354327355 const {collectionIdAddress: nftCollectionAddress} = await createNonfungibleCollection(api, web3, owner);328 const nftCollection = await helper.eth.createNonfungibleCollection(owner, 'nft', 'NFT collection', 'NFT');356 const nftContract = uniqueNFT(web3, nftCollectionAddress, owner);329 const nftContract = helper.ethNativeContract.collection(nftCollection.collectionAddress, 'nft', owner);357 const nftTokenId = await nftContract.methods.nextTokenId().call();330 const nftTokenId = await nftContract.methods.nextTokenId().call();358 await nftContract.methods.mint(owner, nftTokenId).send();331 await nftContract.methods.mint(owner, nftTokenId).send({from: owner});359332360 const {fractionalizer} = await initFractionalizer(api, web3, privateKeyWrapper, owner);333 const {contract: fractionalizer} = await initContract(helper, owner);361334362 await fractionalizer.methods.setNftCollectionIsAllowed(nftCollectionAddress, true).send();335 await fractionalizer.methods.setNftCollectionIsAllowed(nftCollection.collectionAddress, true).send({from: owner});363 await expect(fractionalizer.methods.nft2rft(nftCollectionAddress, nftTokenId, 100).call())336 await expect(fractionalizer.methods.nft2rft(nftCollection.collectionAddress, nftTokenId, 100).call())364 .to.be.rejectedWith(/ApprovedValueTooLow$/g);337 .to.be.rejectedWith(/ApprovedValueTooLow$/g);365 });338 });366339367 itWeb3('call rft2nft without setting RFT collection for contract', async ({api, web3, privateKeyWrapper}) => {340 itEth('call rft2nft without setting RFT collection for contract', async ({helper}) => {368 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);341 const owner = await helper.eth.createAccountWithBalance(donor, 20n);369342370 const fractionalizer = await deployFractionalizer(web3, owner);343 const fractionalizer = await deployContract(helper, owner);371 const {collectionIdAddress: rftCollectionAddress} = await createRFTCollection(api, web3, owner);344 const rftCollection = await helper.eth.createRefungibleCollection(owner, 'rft', 'RFT collection', 'RFT');372 const refungibleContract = uniqueRefungible(web3, rftCollectionAddress, owner);345 const refungibleContract = helper.ethNativeContract.collection(rftCollection.collectionAddress, 'rft', owner);373 const rftTokenId = await refungibleContract.methods.nextTokenId().call();346 const rftTokenId = await refungibleContract.methods.nextTokenId().call();374 await refungibleContract.methods.mint(owner, rftTokenId).send();347 await refungibleContract.methods.mint(owner, rftTokenId).send({from: owner});375 348 376 await expect(fractionalizer.methods.rft2nft(rftCollectionAddress, rftTokenId).call())349 await expect(fractionalizer.methods.rft2nft(rftCollection.collectionAddress, rftTokenId).call({from: owner}))377 .to.be.rejectedWith(/RFT collection is not set$/g);350 .to.be.rejectedWith(/RFT collection is not set$/g);378 });351 });379352380 itWeb3('call rft2nft for RFT token that is not from configured RFT collection', async ({api, web3, privateKeyWrapper}) => {353 itEth('call rft2nft for RFT token that is not from configured RFT collection', async ({helper}) => {381 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);354 const owner = await helper.eth.createAccountWithBalance(donor, 20n);382355383 const {fractionalizer} = await initFractionalizer(api, web3, privateKeyWrapper, owner);356 const {contract: fractionalizer} = await initContract(helper, owner);384 const {collectionIdAddress: rftCollectionAddress} = await createRFTCollection(api, web3, owner);357 const rftCollection = await helper.eth.createRefungibleCollection(owner, 'rft', 'RFT collection', 'RFT');385 const refungibleContract = uniqueRefungible(web3, rftCollectionAddress, owner);358 const refungibleContract = helper.ethNativeContract.collection(rftCollection.collectionAddress, 'rft', owner);386 const rftTokenId = await refungibleContract.methods.nextTokenId().call();359 const rftTokenId = await refungibleContract.methods.nextTokenId().call();387 await refungibleContract.methods.mint(owner, rftTokenId).send();360 await refungibleContract.methods.mint(owner, rftTokenId).send({from: owner});388 361 389 await expect(fractionalizer.methods.rft2nft(rftCollectionAddress, rftTokenId).call())362 await expect(fractionalizer.methods.rft2nft(rftCollection.collectionAddress, rftTokenId).call())390 .to.be.rejectedWith(/Wrong RFT collection$/g);363 .to.be.rejectedWith(/Wrong RFT collection$/g);391 });364 });392365393 itWeb3('call rft2nft for RFT token that was not minted by fractionalizer contract', async ({api, web3, privateKeyWrapper}) => {366 itEth('call rft2nft for RFT token that was not minted by fractionalizer contract', async ({helper}) => {394 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);367 const owner = await helper.eth.createAccountWithBalance(donor, 20n);395 const {collectionIdAddress: rftCollectionAddress} = await createRFTCollection(api, web3, owner);368 const rftCollection = await helper.eth.createRefungibleCollection(owner, 'rft', 'RFT collection', 'RFT');369 const refungibleContract = helper.ethNativeContract.collection(rftCollection.collectionAddress, 'rft', owner);396370397 const fractionalizer = await deployFractionalizer(web3, owner);371 const fractionalizer = await deployContract(helper, owner);398 const refungibleContract = uniqueRefungible(web3, rftCollectionAddress, owner);399372400 await refungibleContract.methods.addCollectionAdmin(fractionalizer.options.address).send();373 await refungibleContract.methods.addCollectionAdmin(fractionalizer.options.address).send({from: owner});401 await fractionalizer.methods.setRFTCollection(rftCollectionAddress).send();374 await fractionalizer.methods.setRFTCollection(rftCollection.collectionAddress).send({from: owner});402375403 const rftTokenId = await refungibleContract.methods.nextTokenId().call();376 const rftTokenId = await refungibleContract.methods.nextTokenId().call();404 await refungibleContract.methods.mint(owner, rftTokenId).send();377 await refungibleContract.methods.mint(owner, rftTokenId).send({from: owner});405 378 406 await expect(fractionalizer.methods.rft2nft(rftCollectionAddress, rftTokenId).call())379 await expect(fractionalizer.methods.rft2nft(rftCollection.collectionAddress, rftTokenId).call())407 .to.be.rejectedWith(/No corresponding NFT token found$/g);380 .to.be.rejectedWith(/No corresponding NFT token found$/g);408 });381 });409382410 itWeb3('call rft2nft without owning all RFT pieces', async ({api, web3, privateKeyWrapper}) => {383 itEth('call rft2nft without owning all RFT pieces', async ({helper}) => {411 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);384 const owner = await helper.eth.createAccountWithBalance(donor, 20n);412 const receiver = await createEthAccountWithBalance(api, web3, privateKeyWrapper);385 const receiver = await helper.eth.createAccountWithBalance(donor, 10n);413386414 const {fractionalizer, rftCollectionAddress} = await initFractionalizer(api, web3, privateKeyWrapper, owner);387 const {contract: fractionalizer, rftCollectionAddress} = await initContract(helper, owner);415 const {rftTokenAddress} = await createRFTToken(api, web3, owner, fractionalizer, 100n);388 const {rftTokenAddress} = await mintRFTToken(helper, owner, fractionalizer, 100n);416 389 417 const {tokenId} = tokenIdFromAddress(rftTokenAddress);390 const {tokenId} = helper.ethAddress.extractTokenId(rftTokenAddress);418 const refungibleTokenContract = uniqueRefungibleToken(web3, rftTokenAddress, owner);391 const refungibleTokenContract = helper.ethNativeContract.rftToken(rftTokenAddress, owner);419 await refungibleTokenContract.methods.transfer(receiver, 50).send();392 await refungibleTokenContract.methods.transfer(receiver, 50).send({from: owner});420 await refungibleTokenContract.methods.approve(fractionalizer.options.address, 50).send();393 await refungibleTokenContract.methods.approve(fractionalizer.options.address, 50).send({from: receiver});421 await expect(fractionalizer.methods.rft2nft(rftCollectionAddress, tokenId).call())394 await expect(fractionalizer.methods.rft2nft(rftCollectionAddress, tokenId).call({from: receiver}))422 .to.be.rejectedWith(/Not all pieces are owned by the caller$/g);395 .to.be.rejectedWith(/Not all pieces are owned by the caller$/g);423 });396 });424397425 itWeb3('send QTZ/UNQ to contract from non owner', async ({api, web3, privateKeyWrapper}) => {398 itEth('send QTZ/UNQ to contract from non owner', async ({helper}) => {426 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);399 const owner = await helper.eth.createAccountWithBalance(donor, 20n);427 const payer = await createEthAccountWithBalance(api, web3, privateKeyWrapper);400 const payer = await helper.eth.createAccountWithBalance(donor, 10n);428401429 const fractionalizer = await deployFractionalizer(web3, owner);402 const fractionalizer = await deployContract(helper, owner);430 const amount = 10n * UNIQUE;403 const amount = 10n * helper.balance.getOneTokenNominal();431 await expect(web3.eth.sendTransaction({from: payer, to: fractionalizer.options.address, value: `${amount}`, ...GAS_ARGS})).to.be.rejected;404 const web3 = helper.getWeb3();405 await expect(web3.eth.sendTransaction({from: payer, to: fractionalizer.options.address, value: `${amount}`, gas: helper.eth.DEFAULT_GAS})).to.be.rejected;432 });406 });433407434 itWeb3('fractionalize NFT with NFT transfers disallowed', async ({api, web3, privateKeyWrapper}) => {408 itEth('fractionalize NFT with NFT transfers disallowed', async ({helper}) => {435 const alice = privateKeyWrapper('//Alice');409 const nftCollection = await helper.nft.mintCollection(donor, {name: 'A', description: 'B', tokenPrefix: 'C'});436 let collectionId;437 {438 const tx = api.tx.unique.createCollectionEx({name: 'A', description: 'B', tokenPrefix: 'C', mode: 'NFT'});439 const events = await submitTransactionAsync(alice, tx);440 const result = getCreateCollectionResult(events);441 collectionId = result.collectionId;442 }443 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);444 let nftTokenId;445 {446 const createData = {nft: {}};447 const tx = api.tx.unique.createItem(collectionId, {Ethereum: owner}, createData as any);448 const events = await executeTransaction(api, alice, tx);449 const result = getCreateItemResult(events);450 nftTokenId = result.itemId;451 }452 {453 const tx = api.tx.unique.setTransfersEnabledFlag(collectionId, false);454 await executeTransaction(api, alice, tx);455 }456 const nftCollectionAddress = collectionIdToAddress(collectionId);457 const {fractionalizer} = await initFractionalizer(api, web3, privateKeyWrapper, owner);458 await fractionalizer.methods.setNftCollectionIsAllowed(nftCollectionAddress, true).send();459410460 const nftContract = uniqueNFT(web3, nftCollectionAddress, owner);411 const owner = await helper.eth.createAccountWithBalance(donor, 20n);412 const nftToken = await nftCollection.mintToken(donor, {Ethereum: owner});413 await helper.executeExtrinsic(donor, 'api.tx.unique.setTransfersEnabledFlag', [nftCollection.collectionId, false], true);414 const nftCollectionAddress = helper.ethAddress.fromCollectionId(nftCollection.collectionId);415 const {contract: fractionalizer} = await initContract(helper, owner);461 await nftContract.methods.approve(fractionalizer.options.address, nftTokenId).send();416 await fractionalizer.methods.setNftCollectionIsAllowed(nftCollectionAddress, true).send({from: owner});417418 const nftContract = helper.ethNativeContract.collection(nftCollectionAddress, 'nft', owner);419 await nftContract.methods.approve(fractionalizer.options.address, nftToken.tokenId).send({from: owner});462 await expect(fractionalizer.methods.nft2rft(nftCollectionAddress, nftTokenId, 100).call())420 await expect(fractionalizer.methods.nft2rft(nftCollectionAddress, nftToken.tokenId, 100).call())463 .to.be.rejectedWith(/TransferNotAllowed$/g);421 .to.be.rejectedWith(/TransferNotAllowed$/g);464 });422 });465 423 466 itWeb3('fractionalize NFT with RFT transfers disallowed', async ({api, web3, privateKeyWrapper}) => {424 itEth('fractionalize NFT with RFT transfers disallowed', async ({helper}) => {467 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);425 const owner = await helper.eth.createAccountWithBalance(donor, 20n);426427 const rftCollection = await helper.rft.mintCollection(donor, {name: 'A', description: 'B', tokenPrefix: 'C'});468 const alice = privateKeyWrapper('//Alice');428 const rftCollectionAddress = helper.ethAddress.fromCollectionId(rftCollection.collectionId);429 const fractionalizer = await deployContract(helper, owner);430 await rftCollection.addAdmin(donor, {Ethereum: fractionalizer.options.address});469431470 let collectionId;432 await fractionalizer.methods.setRFTCollection(rftCollectionAddress).send({from: owner});471 {472 const tx = api.tx.unique.createCollectionEx({name: 'A', description: 'B', tokenPrefix: 'C', mode: 'ReFungible'});473 const events = await submitTransactionAsync(alice, tx);474 const result = getCreateCollectionResult(events);475 collectionId = result.collectionId;476 }477 const rftCollectionAddress = collectionIdToAddress(collectionId);478 const fractionalizer = await deployFractionalizer(web3, owner);479 {480 const changeAdminTx = api.tx.unique.addCollectionAdmin(collectionId, {Ethereum: fractionalizer.options.address});481 await submitTransactionAsync(alice, changeAdminTx);433 await helper.executeExtrinsic(donor, 'api.tx.unique.setTransfersEnabledFlag', [rftCollection.collectionId, false], true);482 }483 await fractionalizer.methods.setRFTCollection(rftCollectionAddress).send();484 {485 const tx = api.tx.unique.setTransfersEnabledFlag(collectionId, false);486 await executeTransaction(api, alice, tx);487 }488434489 const {collectionIdAddress: nftCollectionAddress} = await createNonfungibleCollection(api, web3, owner);435 const nftCollection = await helper.eth.createNonfungibleCollection(owner, 'nft', 'NFT collection', 'NFT');490 const nftContract = uniqueNFT(web3, nftCollectionAddress, owner);436 const nftContract = helper.ethNativeContract.collection(nftCollection.collectionAddress, 'nft', owner);491 const nftTokenId = await nftContract.methods.nextTokenId().call();437 const nftTokenId = await nftContract.methods.nextTokenId().call();492 await nftContract.methods.mint(owner, nftTokenId).send();438 await nftContract.methods.mint(owner, nftTokenId).send({from: owner});493439494 await fractionalizer.methods.setNftCollectionIsAllowed(nftCollectionAddress, true).send();440 await fractionalizer.methods.setNftCollectionIsAllowed(nftCollection.collectionAddress, true).send({from: owner});495 await nftContract.methods.approve(fractionalizer.options.address, nftTokenId).send();441 await nftContract.methods.approve(fractionalizer.options.address, nftTokenId).send({from: owner});496442497 await expect(fractionalizer.methods.nft2rft(nftCollectionAddress, nftTokenId, 100n).call())443 await expect(fractionalizer.methods.nft2rft(nftCollection.collectionAddress, nftTokenId, 100n).call())498 .to.be.rejectedWith(/TransferNotAllowed$/g);444 .to.be.rejectedWith(/TransferNotAllowed$/g);499 });445 });500});446});tests/src/eth/util/playgrounds/index.tsdiffbeforeafterboth121213import chai from 'chai';13import chai from 'chai';14import chaiAsPromised from 'chai-as-promised';14import chaiAsPromised from 'chai-as-promised';15import chaiLike from 'chai-like';15import {requirePalletsOrSkip} from '../../../util/playgrounds';16import {requirePalletsOrSkip} from '../../../util/playgrounds';16chai.use(chaiAsPromised);17chai.use(chaiAsPromised);18chai.use(chaiLike);17export const expect = chai.expect;19export const expect = chai.expect;182019export const usingEthPlaygrounds = async (code: (helper: EthUniqueHelper, privateKey: (seed: string) => IKeyringPair) => Promise<void>) => {21export const usingEthPlaygrounds = async (code: (helper: EthUniqueHelper, privateKey: (seed: string) => IKeyringPair) => Promise<void>) => {