git.delta.rocks / unique-network / refs/commits / 71e7d44249c5

difftreelog

Add ethereum allowlist checks

Max Andreev2022-11-30parent: #8f5889c.patch.diff
in: master

1 file changed

modifiedtests/src/eth/allowlist.test.tsdiffbeforeafterboth
91 expect(await collectionEvm.methods.allowlistedCross(crossUser).call({from: owner})).to.be.false;91 expect(await collectionEvm.methods.allowlistedCross(crossUser).call({from: owner})).to.be.false;
92 });92 });
9393
94 itEth('Collection allowlist can be added and removed by [cross] address', async ({helper}) => {94 itEth.only('Collection allowlist can be added and removed by [cross] address', async ({helper}) => {
95 const owner = await helper.eth.createAccountWithBalance(donor);95 const owner = (await helper.eth.createAccountWithBalance(donor)).toLowerCase();
96 const user = donor;96 const [userSub] = await helper.arrange.createAccounts([10n], donor);
97 97 const userEth = await helper.eth.createAccountWithBalance(donor);
98
98 const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');99 const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
99 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);100 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
100 const userCross = helper.ethCrossAccount.fromKeyringPair(user);101 const userCrossSub = helper.ethCrossAccount.fromKeyringPair(userSub);
101 102 const userCrossEth = helper.ethCrossAccount.fromAddress(userEth);
103
104 // Can addToCollectionAllowListCross:
102 expect(await helper.collection.allowed(collectionId, {Substrate: user.address})).to.be.false;105 expect(await helper.collection.allowed(collectionId, {Substrate: userSub.address})).to.be.false;
103 await collectionEvm.methods.addToCollectionAllowListCross(userCross).send({from: owner});106 await collectionEvm.methods.addToCollectionAllowListCross(userCrossSub).send({from: owner});
107 await collectionEvm.methods.addToCollectionAllowListCross(userCrossEth).send({from: owner});
104 expect(await helper.collection.allowed(collectionId, {Substrate: user.address})).to.be.true;108 expect(await helper.collection.allowed(collectionId, {Substrate: userSub.address})).to.be.true;
109 expect(await helper.collection.allowed(collectionId, {Ethereum: userEth})).to.be.true;
105 expect(await collectionEvm.methods.allowlistedCross(userCross).call({from: owner})).to.be.true;110 expect(await collectionEvm.methods.allowlistedCross(userCrossSub).call({from: owner})).to.be.true;
106 111 expect(await collectionEvm.methods.allowlistedCross(userCrossEth).call({from: owner})).to.be.true;
112
113 // allowlisted account can transfer tokens:
114 await collectionEvm.methods.mint(userEth).send();
115 await collectionEvm.methods.setCollectionAccess(1).send();
116 await collectionEvm.methods.transfer(owner, 1).send({from: userEth}); // FIXME: why not?
117 expect(await helper.nft.getTokenOwner(collectionId, 1)).to.eq({Ethereum: owner});
118
119 // can removeFromCollectionAllowListCross
107 await collectionEvm.methods.removeFromCollectionAllowListCross(userCross).send({from: owner});120 await collectionEvm.methods.removeFromCollectionAllowListCross(userCrossSub).send({from: owner});
121 await collectionEvm.methods.removeFromCollectionAllowListCross(userCrossEth).send({from: owner});
108 expect(await helper.collection.allowed(collectionId, {Substrate: user.address})).to.be.false;122 expect(await helper.collection.allowed(collectionId, {Substrate: userSub.address})).to.be.false;
123 expect(await helper.collection.allowed(collectionId, {Substrate: userEth})).to.be.false;
109 expect(await collectionEvm.methods.allowlistedCross(userCross).call({from: owner})).to.be.false;124 expect(await collectionEvm.methods.allowlistedCross(userCrossEth).call({from: owner})).to.be.false;
125
126 // cannot transfer anymore
127 await collectionEvm.methods.mint(userEth).send();
128 await expect(collectionEvm.methods.transfer(owner, 2).send({from: userEth})).to.be.rejected;
110 });129 });
111130
112 // Soft-deprecated131 // Soft-deprecated