git.delta.rocks / unique-network / refs/commits / 79ed02e181a1

difftreelog

CORE-346 Some changes for broken tests

Trubnikov Sergey2022-05-27parent: #4f3a569.patch.diff
in: master

5 files changed

modifiedtests/src/eth/contractSponsoring.test.tsdiffbeforeafterboth
before · tests/src/eth/contractSponsoring.test.ts
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 privateKey from '../substrate/privateKey';18import {expect} from 'chai';19import {20  contractHelpers,21  createEthAccountWithBalance,22  transferBalanceToEth,23  deployFlipper,24  itWeb3,25  SponsoringMode,26  createEthAccount,27  collectionIdToAddress,28  GAS_ARGS,29  normalizeEvents,30  subToEth,31  executeEthTxOnSub,32} from './util/helpers';33import {34  addCollectionAdminExpectSuccess,35  createCollectionExpectSuccess,36  getCreateCollectionResult,37  transferBalanceTo,38} from '../util/helpers';39import nonFungibleAbi from './nonFungibleAbi.json';40import {41  submitTransactionAsync,42} from '../substrate/substrate-api';43import getBalance from '../substrate/get-balance';44import {alicesPublicKey} from '../accounts';4546describe('Sponsoring EVM contracts', () => {47  itWeb3('Sponsoring can be set by the address that has deployed the contract', async ({api, web3}) => {48    const owner = await createEthAccountWithBalance(api, web3);49    const flipper = await deployFlipper(web3, owner);50    const helpers = contractHelpers(web3, owner);51    expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.false;52    await helpers.methods.setSponsoringMode(flipper.options.address, SponsoringMode.Allowlisted).send({from: owner});53    expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.true;54  });5556  itWeb3('Sponsoring cannot be set by the address that did not deployed the contract', async ({api, web3}) => {57    const owner = await createEthAccountWithBalance(api, web3);58    const notOwner = await createEthAccountWithBalance(api, web3);59    const flipper = await deployFlipper(web3, owner);60    const helpers = contractHelpers(web3, owner);61    expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.false;62    await expect(helpers.methods.setSponsoringMode(notOwner, SponsoringMode.Allowlisted).send({from: notOwner})).to.rejected;63    expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.false;64  });6566  itWeb3('In generous mode, non-allowlisted user transaction will be sponsored', async ({api, web3}) => {67    const alice = privateKey('//Alice');6869    const owner = await createEthAccountWithBalance(api, web3);70    const caller = await createEthAccountWithBalance(api, web3);7172    const flipper = await deployFlipper(web3, owner);7374    const helpers = contractHelpers(web3, owner);7576    expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.false;77    await helpers.methods.setSponsoringMode(flipper.options.address, SponsoringMode.Generous).send({from: owner});78    await helpers.methods.setSponsoringRateLimit(flipper.options.address, 0).send({from: owner});79    expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.true;8081    await transferBalanceToEth(api, alice, flipper.options.address);8283    const originalFlipperBalance = await web3.eth.getBalance(flipper.options.address);84    expect(originalFlipperBalance).to.be.not.equal('0');8586    await flipper.methods.flip().send({from: caller});87    expect(await flipper.methods.getValue().call()).to.be.true;8889    // Balance should be taken from flipper instead of caller90    const balanceAfter = await web3.eth.getBalance(flipper.options.address);91    expect(+balanceAfter).to.be.lessThan(+originalFlipperBalance);92  });9394  itWeb3('Sponsoring is set, an address that has no UNQ can send a transaction and it works. Sponsor balance should decrease (allowlisted)', async ({api, web3}) => {95    const alice = privateKey('//Alice');9697    const owner = await createEthAccountWithBalance(api, web3);98    const caller = createEthAccount(web3);99100    const flipper = await deployFlipper(web3, owner);101102    const helpers = contractHelpers(web3, owner);103    await helpers.methods.toggleAllowlist(flipper.options.address, true).send({from: owner});104    await helpers.methods.toggleAllowed(flipper.options.address, caller, true).send({from: owner});105106    expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.false;107    await helpers.methods.setSponsoringMode(flipper.options.address, SponsoringMode.Allowlisted).send({from: owner});108    await helpers.methods.setSponsoringRateLimit(flipper.options.address, 0).send({from: owner});109    expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.true;110111    await transferBalanceToEth(api, alice, flipper.options.address);112113    const originalFlipperBalance = await web3.eth.getBalance(flipper.options.address);114    expect(originalFlipperBalance).to.be.not.equal('0');115116    await flipper.methods.flip().send({from: caller});117    expect(await flipper.methods.getValue().call()).to.be.true;118119    // Balance should be taken from flipper instead of caller120    const balanceAfter = await web3.eth.getBalance(flipper.options.address);121    expect(+balanceAfter).to.be.lessThan(+originalFlipperBalance);122  });123124  itWeb3('Sponsoring is set, an address that has no UNQ can send a transaction and it works. Sponsor balance should not decrease (non-allowlisted)', async ({api, web3}) => {125    const alice = privateKey('//Alice');126127    const owner = await createEthAccountWithBalance(api, web3);128    const caller = createEthAccount(web3);129130    const flipper = await deployFlipper(web3, owner);131132    const helpers = contractHelpers(web3, owner);133134    expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.false;135    await helpers.methods.setSponsoringMode(flipper.options.address, SponsoringMode.Allowlisted).send({from: owner});136    await helpers.methods.setSponsoringRateLimit(flipper.options.address, 0).send({from: owner});137    expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.true;138139    await transferBalanceToEth(api, alice, flipper.options.address);140141    const originalFlipperBalance = await web3.eth.getBalance(flipper.options.address);142    expect(originalFlipperBalance).to.be.not.equal('0');143144    await expect(flipper.methods.flip().send({from: caller})).to.be.rejectedWith(/InvalidTransaction::Payment/);145    expect(await flipper.methods.getValue().call()).to.be.false;146147    // Balance should be taken from flipper instead of caller148    const balanceAfter = await web3.eth.getBalance(flipper.options.address);149    expect(+balanceAfter).to.be.equals(+originalFlipperBalance);150  });151152  itWeb3('Sponsoring is set, an address that has UNQ can send a transaction and it works. User balance should not change', async ({api, web3}) => {153    const alice = privateKey('//Alice');154155    const owner = await createEthAccountWithBalance(api, web3);156    const caller = await createEthAccountWithBalance(api, web3);157    const originalCallerBalance = await web3.eth.getBalance(caller);158159    const flipper = await deployFlipper(web3, owner);160161    const helpers = contractHelpers(web3, owner);162    await helpers.methods.toggleAllowlist(flipper.options.address, true).send({from: owner});163    await helpers.methods.toggleAllowed(flipper.options.address, caller, true).send({from: owner});164165    expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.false;166    await helpers.methods.setSponsoringMode(flipper.options.address, SponsoringMode.Allowlisted).send({from: owner});167    await helpers.methods.setSponsoringRateLimit(flipper.options.address, 0).send({from: owner});168    expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.true;169170    await transferBalanceToEth(api, alice, flipper.options.address);171172    const originalFlipperBalance = await web3.eth.getBalance(flipper.options.address);173    expect(originalFlipperBalance).to.be.not.equal('0');174175    await flipper.methods.flip().send({from: caller});176    expect(await flipper.methods.getValue().call()).to.be.true;177178    expect(await web3.eth.getBalance(caller)).to.be.equals(originalCallerBalance);179  });180181  itWeb3('Sponsoring is limited, with setContractRateLimit. The limitation is working if transactions are sent more often, the sender pays the commission.', async ({api, web3}) => {182    const alice = privateKey('//Alice');183184    const owner = await createEthAccountWithBalance(api, web3);185    const caller = await createEthAccountWithBalance(api, web3);186    const originalCallerBalance = await web3.eth.getBalance(caller);187188    const flipper = await deployFlipper(web3, owner);189190    const helpers = contractHelpers(web3, owner);191    await helpers.methods.toggleAllowlist(flipper.options.address, true).send({from: owner});192    await helpers.methods.toggleAllowed(flipper.options.address, caller, true).send({from: owner});193194    expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.false;195    await helpers.methods.setSponsoringMode(flipper.options.address, SponsoringMode.Allowlisted).send({from: owner});196    await helpers.methods.setSponsoringRateLimit(flipper.options.address, 10).send({from: owner});197    expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.true;198199    await transferBalanceToEth(api, alice, flipper.options.address);200201    const originalFlipperBalance = await web3.eth.getBalance(flipper.options.address);202    expect(originalFlipperBalance).to.be.not.equal('0');203204    await flipper.methods.flip().send({from: caller});205    expect(await flipper.methods.getValue().call()).to.be.true;206    expect(await web3.eth.getBalance(caller)).to.be.equals(originalCallerBalance);207208    const newFlipperBalance = await web3.eth.getBalance(flipper.options.address);209    expect(newFlipperBalance).to.be.not.equals(originalFlipperBalance);210211    await flipper.methods.flip().send({from: caller});212    expect(await web3.eth.getBalance(flipper.options.address)).to.be.equal(newFlipperBalance);213    expect(await web3.eth.getBalance(caller)).to.be.not.equals(originalCallerBalance);214  });215216  // TODO: Find a way to calculate default rate limit217  itWeb3('Default rate limit equals 7200', async ({api, web3}) => {218    const owner = await createEthAccountWithBalance(api, web3);219    const flipper = await deployFlipper(web3, owner);220    const helpers = contractHelpers(web3, owner);221    expect(await helpers.methods.getSponsoringRateLimit(flipper.options.address).call()).to.be.equals('7200');222  });223224  itWeb3('Sponsoring evm address from substrate collection', async ({api, web3}) => {225    const owner = privateKey('//Alice');226    const userEth = createEthAccount(web3);227    const collectionId = await createCollectionExpectSuccess();228229    {230      const tx = api.tx.unique.setCollectionSponsor(collectionId, owner.address);231      const events = await submitTransactionAsync(owner, tx);232      const result = getCreateCollectionResult(events);233      expect(result.success).to.be.true;234    }235    {236      const tx = api.tx.unique.confirmSponsorship(collectionId);237      const events = await submitTransactionAsync(owner, tx);238      const result = getCreateCollectionResult(events);239      expect(result.success).to.be.true;240    }241242    const address = collectionIdToAddress(collectionId);243    const contract = new web3.eth.Contract(nonFungibleAbi as any, address, {from: userEth, ...GAS_ARGS});244245    { // This part should fail, because user not in access list and user have no money246      const nextTokenId = await contract.methods.nextTokenId().call();247      expect(nextTokenId).to.be.equal('1');248      await expect(contract.methods.mintWithTokenURI(249        userEth,250        nextTokenId,251        'Test URI',252      ).call({from: userEth})).to.be.rejectedWith(/PublicMintingNotAllowed/);253    }254255    {256      const tx = api.tx.unique.setPublicAccessMode(collectionId, 'AllowList');257      const events = await submitTransactionAsync(owner, tx);258      const result = getCreateCollectionResult(events);259      expect(result.success).to.be.true;260    }261    {262      const tx = api.tx.unique.addToAllowList(collectionId, {Ethereum: userEth});263      const events = await submitTransactionAsync(owner, tx);264      const result = getCreateCollectionResult(events);265      expect(result.success).to.be.true;266    }267    {268      const tx = api.tx.unique.setMintPermission(collectionId, true);269      const events = await submitTransactionAsync(owner, tx);270      const result = getCreateCollectionResult(events);271      expect(result.success).to.be.true;272    }273274    const [alicesBalanceBefore] = await getBalance(api, [alicesPublicKey]);275276    {277      const nextTokenId = await contract.methods.nextTokenId().call();278      expect(nextTokenId).to.be.equal('1');279      const result = await contract.methods.mintWithTokenURI(280        userEth,281        nextTokenId,282        'Test URI',283      ).send({from: userEth});284      const events = normalizeEvents(result.events);285286      expect(events).to.be.deep.equal([287        {288          address,289          event: 'Transfer',290          args: {291            from: '0x0000000000000000000000000000000000000000',292            to: userEth,293            tokenId: nextTokenId,294          },295        },296      ]);297298      expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('Test URI');299    }300301    const [alicesBalanceAfter] = await getBalance(api, [alicesPublicKey]);302    expect(alicesBalanceAfter < alicesBalanceBefore).to.be.true;303  });304305306  itWeb3('Check that transaction via EVM spend money from substrate address', async ({api, web3}) => {307    const owner = privateKey('//Alice');308    const user = privateKey(`//User/${Date.now()}`);309    const userEth = subToEth(user.address);310    const collectionId = await createCollectionExpectSuccess();311    await addCollectionAdminExpectSuccess(owner, collectionId, {Ethereum: userEth});312    await transferBalanceTo(api, owner, user.address);313314    const address = collectionIdToAddress(collectionId);315    const contract = new web3.eth.Contract(nonFungibleAbi as any, address, {from: userEth, ...GAS_ARGS});316317    const [userBalanceBefore] = await getBalance(api, [user.address]);318319    {320      const nextTokenId = await contract.methods.nextTokenId().call();321      expect(nextTokenId).to.be.equal('1');322      await executeEthTxOnSub(web3, api, user, contract, m => m.mintWithTokenURI(323        userEth,324        nextTokenId,325        'Test URI',326      ));327328      expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('Test URI');329    }330331    const [userBalanceAfter] = await getBalance(api, [user.address]);332    expect(userBalanceAfter < userBalanceBefore).to.be.true;333  });334});
modifiedtests/src/eth/createCollection.test.tsdiffbeforeafterboth
--- a/tests/src/eth/createCollection.test.ts
+++ b/tests/src/eth/createCollection.test.ts
@@ -14,30 +14,18 @@
 // 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 nonFungibleAbi from './nonFungibleAbi.json';
-import {ApiPromise} from '@polkadot/api';
 import {evmToAddress} from '@polkadot/util-crypto';
 import {expect} from 'chai';
 import {getCreatedCollectionCount, getDetailedCollectionInfo} from '../util/helpers';
 import {
   evmCollectionHelper,
-  collectionIdFromAddress,
   collectionIdToAddress,
   createEthAccount,
   createEthAccountWithBalance,
   evmCollection,
-  GAS_ARGS,
   itWeb3,
-  normalizeAddress,
-  normalizeEvents,
+  getCollectionAddressFromResult,
 } from './util/helpers';
-
-async function getCollectionAddressFromResult(api: ApiPromise, result: any) {
-  const collectionIdAddress = normalizeAddress(result.events[0].raw.topics[2]);
-  const collectionId = collectionIdFromAddress(collectionIdAddress);  
-  const collection = (await getDetailedCollectionInfo(api, collectionId))!;
-  return {collectionIdAddress, collectionId, collection};
-}
 
 describe('Create collection from EVM', () => {
   itWeb3('Create collection', async ({api, web3}) => {
@@ -138,45 +126,6 @@
     expect(collectionSub.limits.ownerCanTransfer.toHuman()).to.be.eq(limits.ownerCanTransfer);
     expect(collectionSub.limits.ownerCanDestroy.toHuman()).to.be.eq(limits.ownerCanDestroy);
     expect(collectionSub.limits.transfersEnabled.toHuman()).to.be.eq(limits.transfersEnabled);
-  });
-
-  itWeb3('Check tokenURI', async ({web3, api}) => {
-    const owner = await createEthAccountWithBalance(api, web3);
-    const helper = evmCollectionHelper(web3, owner);
-    let result = await helper.methods.create721Collection('Mint collection', '6', '6').send();
-    const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);
-    const receiver = createEthAccount(web3);
-    const contract = new web3.eth.Contract(nonFungibleAbi as any, collectionIdAddress, {from: owner, ...GAS_ARGS});
-    const nextTokenId = await contract.methods.nextTokenId().call();
-
-    expect(nextTokenId).to.be.equal('1');
-    result = await contract.methods.mintWithTokenURI(
-      receiver,
-      nextTokenId,
-      'Test URI',
-    ).send();
-
-    const events = normalizeEvents(result.events);
-    const address = collectionIdToAddress(collectionId);
-
-    expect(events).to.be.deep.equal([
-      {
-        address,
-        event: 'Transfer',
-        args: {
-          from: '0x0000000000000000000000000000000000000000',
-          to: receiver,
-          tokenId: nextTokenId,
-        },
-      },
-    ]);
-
-    expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('Test URI');
-
-    // TODO: this wont work right now, need release 919000 first
-    // await helper.methods.setOffchainSchema(collectionIdAddress, 'https://offchain-service.local/token-info/{id}').send();
-    // const tokenUri = await contract.methods.tokenURI(nextTokenId).call();
-    // expect(tokenUri).to.be.equal(`https://offchain-service.local/token-info/${nextTokenId}`);
   });
 
   itWeb3('Collection address exist', async ({api, web3}) => {
modifiedtests/src/eth/nonFungible.test.tsdiffbeforeafterboth
--- a/tests/src/eth/nonFungible.test.ts
+++ b/tests/src/eth/nonFungible.test.ts
@@ -16,7 +16,7 @@
 
 import privateKey from '../substrate/privateKey';
 import {approveExpectSuccess, burnItemExpectSuccess, createCollectionExpectSuccess, createItemExpectSuccess, transferExpectSuccess, transferFromExpectSuccess, UNIQUE} from '../util/helpers';
-import {collectionIdToAddress, createEthAccount, createEthAccountWithBalance, GAS_ARGS, itWeb3, normalizeEvents, recordEthFee, recordEvents, subToEth, transferBalanceToEth} from './util/helpers';
+import {collectionIdToAddress, createEthAccount, createEthAccountWithBalance, evmCollection, evmCollectionHelper, GAS_ARGS, getCollectionAddressFromResult, itWeb3, normalizeEvents, recordEthFee, recordEvents, subToEth, transferBalanceToEth} from './util/helpers';
 import nonFungibleAbi from './nonFungibleAbi.json';
 import {expect} from 'chai';
 import {submitTransactionAsync} from '../substrate/substrate-api';
@@ -75,43 +75,42 @@
 
 describe('NFT: Plain calls', () => {
   itWeb3('Can perform mint()', async ({web3, api}) => {
-    const collection = await createCollectionExpectSuccess({
-      mode: {type: 'NFT'},
-    });
-    const alice = privateKey('//Alice');
-
-    const caller = await createEthAccountWithBalance(api, web3);
-    const changeAdminTx = api.tx.unique.addCollectionAdmin(collection, {Ethereum: caller});
-    await submitTransactionAsync(alice, changeAdminTx);
+    const owner = await createEthAccountWithBalance(api, web3);
+    const helper = evmCollectionHelper(web3, owner);
+    let result = await helper.methods.create721Collection('Mint collection', '6', '6').send();
+    const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);
     const receiver = createEthAccount(web3);
+    const contract = evmCollection(web3, owner, collectionIdAddress);
+    const nextTokenId = await contract.methods.nextTokenId().call();
 
-    const address = collectionIdToAddress(collection);
-    const contract = new web3.eth.Contract(nonFungibleAbi as any, address, {from: caller, ...GAS_ARGS});
+    expect(nextTokenId).to.be.equal('1');
+    result = await contract.methods.mintWithTokenURI(
+      receiver,
+      nextTokenId,
+      'Test URI',
+    ).send();
 
-    {
-      const nextTokenId = await contract.methods.nextTokenId().call();
-      expect(nextTokenId).to.be.equal('1');
-      const result = await contract.methods.mintWithTokenURI(
-        receiver,
-        nextTokenId,
-        'Test URI',
-      ).send({from: caller});
-      const events = normalizeEvents(result.events);
+    const events = normalizeEvents(result.events);
+    const address = collectionIdToAddress(collectionId);
 
-      expect(events).to.be.deep.equal([
-        {
-          address,
-          event: 'Transfer',
-          args: {
-            from: '0x0000000000000000000000000000000000000000',
-            to: receiver,
-            tokenId: nextTokenId,
-          },
+    expect(events).to.be.deep.equal([
+      {
+        address,
+        event: 'Transfer',
+        args: {
+          from: '0x0000000000000000000000000000000000000000',
+          to: receiver,
+          tokenId: nextTokenId,
         },
-      ]);
+      },
+    ]);
+
+    expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('Test URI');
 
-      expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('Test URI');
-    }
+    // TODO: this wont work right now, need release 919000 first
+    // await helper.methods.setOffchainSchema(collectionIdAddress, 'https://offchain-service.local/token-info/{id}').send();
+    // const tokenUri = await contract.methods.tokenURI(nextTokenId).call();
+    // expect(tokenUri).to.be.equal(`https://offchain-service.local/token-info/${nextTokenId}`);
   });
   itWeb3('Can perform mintBulk()', async ({web3, api}) => {
     const collection = await createCollectionExpectSuccess({
modifiedtests/src/eth/proxy/nonFungibleProxy.test.tsdiffbeforeafterboth
--- a/tests/src/eth/proxy/nonFungibleProxy.test.ts
+++ b/tests/src/eth/proxy/nonFungibleProxy.test.ts
@@ -127,6 +127,7 @@
       expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('Test URI');
     }
   });
+  
   itWeb3('Can perform mintBulk()', async ({web3, api}) => {
     const collection = await createCollectionExpectSuccess({
       mode: {type: 'NFT'},
modifiedtests/src/eth/util/helpers.tsdiffbeforeafterboth
--- a/tests/src/eth/util/helpers.ts
+++ b/tests/src/eth/util/helpers.ts
@@ -23,12 +23,12 @@
 import usingApi, {submitTransactionAsync} from '../../substrate/substrate-api';
 import {IKeyringPair} from '@polkadot/types/types';
 import {expect} from 'chai';
-import {CrossAccountId, getGenericResult, UNIQUE} from '../../util/helpers';
+import {CrossAccountId, getDetailedCollectionInfo, getGenericResult, UNIQUE} from '../../util/helpers';
 import * as solc from 'solc';
 import config from '../../config';
 import privateKey from '../../substrate/privateKey';
 import contractHelpersAbi from './contractHelpersAbi.json';
-import collectionAbi from '../nonFungibleAbi.json';
+import nonFungibleAbi from '../nonFungibleAbi.json';
 import collectionHelperAbi from '../collectionHelperAbi.json';
 import getBalance from '../../substrate/get-balance';
 import waitNewBlocks from '../../substrate/wait-new-blocks';
@@ -68,6 +68,13 @@
   ];
 }
 
+export async function getCollectionAddressFromResult(api: ApiPromise, result: any) {
+  const collectionIdAddress = normalizeAddress(result.events[0].raw.topics[2]);
+  const collectionId = collectionIdFromAddress(collectionIdAddress);  
+  const collection = (await getDetailedCollectionInfo(api, collectionId))!;
+  return {collectionIdAddress, collectionId, collection};
+}
+
 export function collectionIdToAddress(collection: number): string {
   const buf = Buffer.from([0x17, 0xc4, 0xe6, 0x45, 0x3c, 0xc4, 0x9a, 0xaa, 0xae, 0xac, 0xa8, 0x94, 0xe6, 0xd9, 0x68, 0x3e,
     ...encodeIntBE(collection),
@@ -301,7 +308,7 @@
  * @returns 
  */
 export function evmCollection(web3: Web3, caller: string, collection: string) {
-  return new web3.eth.Contract(collectionAbi as any, collection, {from: caller, ...GAS_ARGS});
+  return new web3.eth.Contract(nonFungibleAbi as any, collection, {from: caller, ...GAS_ARGS});
 }
 
 /**