git.delta.rocks / unique-network / refs/commits / 0a9460cebd2b

difftreelog

source

tests/src/eth/collectionSponsoring.test.ts1.8 KiBsourcehistory
1import privateKey from '../substrate/privateKey';2import {addToAllowListExpectSuccess, confirmSponsorshipExpectSuccess, createCollectionExpectSuccess, enablePublicMintingExpectSuccess, setCollectionSponsorExpectSuccess} from '../util/helpers';3import {itWeb3, transferBalanceToEth, subToEth, createEthAccount, collectionIdToAddress, GAS_ARGS, normalizeEvents} from './util/helpers';4import nonFungibleAbi from './nonFungibleAbi.json';5import {expect} from 'chai';67describe('evm collection sponsoring', () => {8  itWeb3('sponsors mint transactions', async ({api, web3}) => {9    const alice = privateKey('//Alice');1011    const collection = await createCollectionExpectSuccess();12    await setCollectionSponsorExpectSuccess(collection, alice.address);13    await confirmSponsorshipExpectSuccess(collection);1415    // Wouldn't be needed after CORE-30016    await transferBalanceToEth(api, alice, subToEth(alice.address));1718    const minter = createEthAccount(web3);19    expect(await web3.eth.getBalance(minter)).to.equal('0');2021    const address = collectionIdToAddress(collection);22    const contract = new web3.eth.Contract(nonFungibleAbi as any, collectionIdToAddress(collection), {from: minter, ...GAS_ARGS});2324    await enablePublicMintingExpectSuccess(alice, collection);25    await addToAllowListExpectSuccess(alice, collection, {Ethereum: minter});2627    const nextTokenId = await contract.methods.nextTokenId().call();28    expect(nextTokenId).to.equal('1');29    const result = await contract.methods.mint(minter, nextTokenId).send();30    const events = normalizeEvents(result.events);31    expect(events).to.be.deep.equal([32      {33        address,34        event: 'Transfer',35        args: {36          from: '0x0000000000000000000000000000000000000000',37          to: minter,38          tokenId: nextTokenId,39        },40      },41    ]);42  });43});