difftreelog
CORE-346 Some changes for broken tests
in: master
5 files changed
tests/src/eth/contractSponsoring.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 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 evmCollectionHelper,33 getCollectionAddressFromResult,34 evmCollection,35} from './util/helpers';36import {37 addCollectionAdminExpectSuccess,38 createCollectionExpectSuccess,39 getCreateCollectionResult,40 getDetailedCollectionInfo,41 transferBalanceTo,42} from '../util/helpers';43import nonFungibleAbi from './nonFungibleAbi.json';44import {45 submitTransactionAsync,46} from '../substrate/substrate-api';47import getBalance from '../substrate/get-balance';48import {alicesPublicKey} from '../accounts';49import { evmToAddress } from '@polkadot/util-crypto';5051describe('Sponsoring EVM contracts', () => {52 itWeb3('Sponsoring can be set by the address that has deployed the contract', async ({api, web3}) => {53 const owner = await createEthAccountWithBalance(api, web3);54 const flipper = await deployFlipper(web3, owner);55 const helpers = contractHelpers(web3, owner);56 expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.false;57 await helpers.methods.setSponsoringMode(flipper.options.address, SponsoringMode.Allowlisted).send({from: owner});58 expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.true;59 });6061 itWeb3('Sponsoring cannot be set by the address that did not deployed the contract', async ({api, web3}) => {62 const owner = await createEthAccountWithBalance(api, web3);63 const notOwner = await createEthAccountWithBalance(api, web3);64 const flipper = await deployFlipper(web3, owner);65 const helpers = contractHelpers(web3, owner);66 expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.false;67 await expect(helpers.methods.setSponsoringMode(notOwner, SponsoringMode.Allowlisted).send({from: notOwner})).to.rejected;68 expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.false;69 });7071 itWeb3('In generous mode, non-allowlisted user transaction will be sponsored', async ({api, web3}) => {72 const alice = privateKey('//Alice');7374 const owner = await createEthAccountWithBalance(api, web3);75 const caller = await createEthAccountWithBalance(api, web3);7677 const flipper = await deployFlipper(web3, owner);7879 const helpers = contractHelpers(web3, owner);8081 expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.false;82 await helpers.methods.setSponsoringMode(flipper.options.address, SponsoringMode.Generous).send({from: owner});83 await helpers.methods.setSponsoringRateLimit(flipper.options.address, 0).send({from: owner});84 expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.true;8586 await transferBalanceToEth(api, alice, flipper.options.address);8788 const originalFlipperBalance = await web3.eth.getBalance(flipper.options.address);89 expect(originalFlipperBalance).to.be.not.equal('0');9091 await flipper.methods.flip().send({from: caller});92 expect(await flipper.methods.getValue().call()).to.be.true;9394 // Balance should be taken from flipper instead of caller95 const balanceAfter = await web3.eth.getBalance(flipper.options.address);96 expect(+balanceAfter).to.be.lessThan(+originalFlipperBalance);97 });9899 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}) => {100 const alice = privateKey('//Alice');101102 const owner = await createEthAccountWithBalance(api, web3);103 const caller = createEthAccount(web3);104105 const flipper = await deployFlipper(web3, owner);106107 const helpers = contractHelpers(web3, owner);108 await helpers.methods.toggleAllowlist(flipper.options.address, true).send({from: owner});109 await helpers.methods.toggleAllowed(flipper.options.address, caller, true).send({from: owner});110111 expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.false;112 await helpers.methods.setSponsoringMode(flipper.options.address, SponsoringMode.Allowlisted).send({from: owner});113 await helpers.methods.setSponsoringRateLimit(flipper.options.address, 0).send({from: owner});114 expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.true;115116 await transferBalanceToEth(api, alice, flipper.options.address);117118 const originalFlipperBalance = await web3.eth.getBalance(flipper.options.address);119 expect(originalFlipperBalance).to.be.not.equal('0');120121 await flipper.methods.flip().send({from: caller});122 expect(await flipper.methods.getValue().call()).to.be.true;123124 // Balance should be taken from flipper instead of caller125 const balanceAfter = await web3.eth.getBalance(flipper.options.address);126 expect(+balanceAfter).to.be.lessThan(+originalFlipperBalance);127 });128129 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}) => {130 const alice = privateKey('//Alice');131132 const owner = await createEthAccountWithBalance(api, web3);133 const caller = createEthAccount(web3);134135 const flipper = await deployFlipper(web3, owner);136137 const helpers = contractHelpers(web3, owner);138139 expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.false;140 await helpers.methods.setSponsoringMode(flipper.options.address, SponsoringMode.Allowlisted).send({from: owner});141 await helpers.methods.setSponsoringRateLimit(flipper.options.address, 0).send({from: owner});142 expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.true;143144 await transferBalanceToEth(api, alice, flipper.options.address);145146 const originalFlipperBalance = await web3.eth.getBalance(flipper.options.address);147 expect(originalFlipperBalance).to.be.not.equal('0');148149 await expect(flipper.methods.flip().send({from: caller})).to.be.rejectedWith(/InvalidTransaction::Payment/);150 expect(await flipper.methods.getValue().call()).to.be.false;151152 // Balance should be taken from flipper instead of caller153 const balanceAfter = await web3.eth.getBalance(flipper.options.address);154 expect(+balanceAfter).to.be.equals(+originalFlipperBalance);155 });156157 itWeb3('Sponsoring is set, an address that has UNQ can send a transaction and it works. User balance should not change', async ({api, web3}) => {158 const alice = privateKey('//Alice');159160 const owner = await createEthAccountWithBalance(api, web3);161 const caller = await createEthAccountWithBalance(api, web3);162 const originalCallerBalance = await web3.eth.getBalance(caller);163164 const flipper = await deployFlipper(web3, owner);165166 const helpers = contractHelpers(web3, owner);167 await helpers.methods.toggleAllowlist(flipper.options.address, true).send({from: owner});168 await helpers.methods.toggleAllowed(flipper.options.address, caller, true).send({from: owner});169170 expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.false;171 await helpers.methods.setSponsoringMode(flipper.options.address, SponsoringMode.Allowlisted).send({from: owner});172 await helpers.methods.setSponsoringRateLimit(flipper.options.address, 0).send({from: owner});173 expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.true;174175 await transferBalanceToEth(api, alice, flipper.options.address);176177 const originalFlipperBalance = await web3.eth.getBalance(flipper.options.address);178 expect(originalFlipperBalance).to.be.not.equal('0');179180 await flipper.methods.flip().send({from: caller});181 expect(await flipper.methods.getValue().call()).to.be.true;182183 expect(await web3.eth.getBalance(caller)).to.be.equals(originalCallerBalance);184 });185186 itWeb3('Sponsoring is limited, with setContractRateLimit. The limitation is working if transactions are sent more often, the sender pays the commission.', async ({api, web3}) => {187 const alice = privateKey('//Alice');188189 const owner = await createEthAccountWithBalance(api, web3);190 const caller = await createEthAccountWithBalance(api, web3);191 const originalCallerBalance = await web3.eth.getBalance(caller);192193 const flipper = await deployFlipper(web3, owner);194195 const helpers = contractHelpers(web3, owner);196 await helpers.methods.toggleAllowlist(flipper.options.address, true).send({from: owner});197 await helpers.methods.toggleAllowed(flipper.options.address, caller, true).send({from: owner});198199 expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.false;200 await helpers.methods.setSponsoringMode(flipper.options.address, SponsoringMode.Allowlisted).send({from: owner});201 await helpers.methods.setSponsoringRateLimit(flipper.options.address, 10).send({from: owner});202 expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.true;203204 await transferBalanceToEth(api, alice, flipper.options.address);205206 const originalFlipperBalance = await web3.eth.getBalance(flipper.options.address);207 expect(originalFlipperBalance).to.be.not.equal('0');208209 await flipper.methods.flip().send({from: caller});210 expect(await flipper.methods.getValue().call()).to.be.true;211 expect(await web3.eth.getBalance(caller)).to.be.equals(originalCallerBalance);212213 const newFlipperBalance = await web3.eth.getBalance(flipper.options.address);214 expect(newFlipperBalance).to.be.not.equals(originalFlipperBalance);215216 await flipper.methods.flip().send({from: caller});217 expect(await web3.eth.getBalance(flipper.options.address)).to.be.equal(newFlipperBalance);218 expect(await web3.eth.getBalance(caller)).to.be.not.equals(originalCallerBalance);219 });220221 // TODO: Find a way to calculate default rate limit222 itWeb3('Default rate limit equals 7200', async ({api, web3}) => {223 const owner = await createEthAccountWithBalance(api, web3);224 const flipper = await deployFlipper(web3, owner);225 const helpers = contractHelpers(web3, owner);226 expect(await helpers.methods.getSponsoringRateLimit(flipper.options.address).call()).to.be.equals('7200');227 });228229 itWeb3('Sponsoring evm address from substrate collection', async ({api, web3}) => {230 const owner = await createEthAccountWithBalance(api, web3);231 const collectionHelper = evmCollectionHelper(web3, owner);232 let result = await collectionHelper.methods.create721Collection('Sponsor collection', '1', '1').send();233 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);234 const sponsor = await createEthAccountWithBalance(api, web3);235 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);236 result = await collectionEvm.methods.ethSetSponsor(sponsor).send();237 let collectionSub = (await getDetailedCollectionInfo(api, collectionId))!;238 expect(collectionSub.sponsorship.isUnconfirmed).to.be.true;239 expect(collectionSub.sponsorship.asUnconfirmed.toHuman()).to.be.eq(evmToAddress(sponsor));240 await expect(collectionEvm.methods.ethConfirmSponsorship().call()).to.be.rejectedWith('Caller is not set as sponsor');241242 const sponsorCollection = evmCollection(web3, sponsor, collectionIdAddress);243 await sponsorCollection.methods.ethConfirmSponsorship().send();244 collectionSub = (await getDetailedCollectionInfo(api, collectionId))!;245 expect(collectionSub.sponsorship.isConfirmed).to.be.true;246 expect(collectionSub.sponsorship.asConfirmed.toHuman()).to.be.eq(evmToAddress(sponsor));247248 const user = createEthAccount(web3);249 const userContract = evmCollection(web3, user, collectionIdAddress);250 const nextTokenId = await userContract.methods.nextTokenId().call();251252 expect(nextTokenId).to.be.equal('1');253 await expect(userContract.methods.mintWithTokenURI(254 user,255 nextTokenId,256 'Test URI',257 ).call()).to.be.rejectedWith('PublicMintingNotAllowed');258 259 // TODO: add this methods to eth260 // {261 // const tx = api.tx.unique.setPublicAccessMode(collectionId, 'AllowList');262 // const events = await submitTransactionAsync(owner, tx);263 // const result = getCreateCollectionResult(events);264 // expect(result.success).to.be.true;265 // }266 // {267 // const tx = api.tx.unique.addToAllowList(collectionId, {Ethereum: userEth});268 // const events = await submitTransactionAsync(owner, tx);269 // const result = getCreateCollectionResult(events);270 // expect(result.success).to.be.true;271 // }272 // {273 // const tx = api.tx.unique.setMintPermission(collectionId, true);274 // const events = await submitTransactionAsync(owner, tx);275 // const result = getCreateCollectionResult(events);276 // expect(result.success).to.be.true;277 // }278279 // const [alicesBalanceBefore] = await getBalance(api, [alicesPublicKey]);280281 {282 const nextTokenId = await userContract.methods.nextTokenId().call();283 expect(nextTokenId).to.be.equal('1');284 const result = await userContract.methods.mintWithTokenURI(285 user,286 nextTokenId,287 'Test URI',288 ).send();289 const events = normalizeEvents(result.events);290291 expect(events).to.be.deep.equal([292 {293 collectionIdAddress,294 event: 'Transfer',295 args: {296 from: '0x0000000000000000000000000000000000000000',297 to: user,298 tokenId: nextTokenId,299 },300 },301 ]);302303 expect(await userContract.methods.tokenURI(nextTokenId).call()).to.be.equal('Test URI');304 }305 });306307308 itWeb3('Check that transaction via EVM spend money from substrate address', async ({api, web3}) => {309 const owner = privateKey('//Alice');310 const user = privateKey(`//User/${Date.now()}`);311 const userEth = subToEth(user.address);312 const collectionId = await createCollectionExpectSuccess();313 await addCollectionAdminExpectSuccess(owner, collectionId, {Ethereum: userEth});314 await transferBalanceTo(api, owner, user.address);315316 const address = collectionIdToAddress(collectionId);317 const contract = new web3.eth.Contract(nonFungibleAbi as any, address, {from: userEth, ...GAS_ARGS});318319 const [userBalanceBefore] = await getBalance(api, [user.address]);320321 {322 const nextTokenId = await contract.methods.nextTokenId().call();323 expect(nextTokenId).to.be.equal('1');324 await executeEthTxOnSub(web3, api, user, contract, m => m.mintWithTokenURI(325 userEth,326 nextTokenId,327 'Test URI',328 ));329330 expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('Test URI');331 }332333 const [userBalanceAfter] = await getBalance(api, [user.address]);334 expect(userBalanceAfter < userBalanceBefore).to.be.true;335 });336});tests/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}) => {
tests/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({
tests/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'},
tests/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});
}
/**