git.delta.rocks / unique-network / refs/commits / 5811ea85a5fa

difftreelog

fmt

Trubnikov Sergey2022-12-09parent: #1a0647e.patch.diff
in: master

5 files changed

modifiedtests/src/eth/collectionSponsoring.test.tsdiffbeforeafterboth
--- a/tests/src/eth/collectionSponsoring.test.ts
+++ b/tests/src/eth/collectionSponsoring.test.ts
@@ -161,19 +161,17 @@
       {
         const result = await collectionEvm.methods.mintWithTokenURI(user, 'Test URI').send({from: user});
         const event = helper.eth.normalizeEvents(result.events)
-        .find(event => event.event === 'Transfer');;
+          .find(event => event.event === 'Transfer');
   
-        expect(event).to.be.deep.equal(
-          {
-            address: collectionAddress,
-            event: 'Transfer',
-            args: {
-              from: '0x0000000000000000000000000000000000000000',
-              to: user,
-              tokenId: '1',
-            },
+        expect(event).to.be.deep.equal({
+          address: collectionAddress,
+          event: 'Transfer',
+          args: {
+            from: '0x0000000000000000000000000000000000000000',
+            to: user,
+            tokenId: '1',
           },
-        );
+        });
   
         const ownerBalanceAfter = await helper.balance.getSubstrate(helper.address.ethToSubstrate(owner));
         const sponsorBalanceAfter = await helper.balance.getSubstrate(helper.address.ethToSubstrate(sponsorEth));
@@ -276,20 +274,18 @@
       const tokenId = mintingResult.events.Transfer.returnValues.tokenId;
   
       const event = helper.eth.normalizeEvents(mintingResult.events)
-      .find(event => event.event === 'Transfer');
+        .find(event => event.event === 'Transfer');
       const address = helper.ethAddress.fromCollectionId(collectionId);
   
-      expect(event).to.be.deep.equal(
-        {
-          address,
-          event: 'Transfer',
-          args: {
-            from: '0x0000000000000000000000000000000000000000',
-            to: user,
-            tokenId: '1',
-          },
+      expect(event).to.be.deep.equal({
+        address,
+        event: 'Transfer',
+        args: {
+          from: '0x0000000000000000000000000000000000000000',
+          to: user,
+          tokenId: '1',
         },
-      );
+      });
       expect(await collectionEvm.methods.tokenURI(tokenId).call({from: user})).to.be.equal('Test URI');
   
       const ownerBalanceAfter = await helper.balance.getSubstrate(helper.address.ethToSubstrate(owner));
modifiedtests/src/eth/events.test.tsdiffbeforeafterboth
--- a/tests/src/eth/events.test.ts
+++ b/tests/src/eth/events.test.ts
@@ -14,510 +14,510 @@
 // 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 { expect } from 'chai';
+import {expect} from 'chai';
 import {IKeyringPair} from '@polkadot/types/types';
-import { EthUniqueHelper, itEth, usingEthPlaygrounds } from './util';
-import { TCollectionMode } from '../util/playgrounds/types';
+import {EthUniqueHelper, itEth, usingEthPlaygrounds} from './util';
+import {TCollectionMode} from '../util/playgrounds/types';
 
 let donor: IKeyringPair;
   
 before(async function () {
-    await usingEthPlaygrounds(async (_helper, privateKey) => {
+  await usingEthPlaygrounds(async (_helper, privateKey) => {
     donor = await privateKey({filename: __filename});
-    });
+  });
 });
 
 async function testCollectionCreatedAndDestroy(helper: EthUniqueHelper, mode: TCollectionMode) {
-    const owner = await helper.eth.createAccountWithBalance(donor);
-        const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['CollectionCreated', 'CollectionDestroyed']}]);
-        const {collectionAddress, events: ethEvents} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');
-        {
-            expect(ethEvents).to.be.like([
-                {
-                    event: 'CollectionCreated',
-                    args: {
-                        owner: owner,
-                        collectionId: collectionAddress
-                    }
-                }
-            ]);
-            expect(subEvents).to.be.like([{method: 'CollectionCreated'}]);
-            ethEvents.pop();
-            subEvents.pop();
-        }
-        {
-            const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
-            let result = await collectionHelper.methods.destroyCollection(collectionAddress).send({from:owner});
-            expect(result.events).to.be.like({
-                CollectionDestroyed: {
-                    returnValues: {
-                        collectionId: collectionAddress
-                    }
-                }
-            });
-            expect(subEvents).to.be.like([{method: 'CollectionDestroyed'}]);
-        }
-        unsubscribe();
+  const owner = await helper.eth.createAccountWithBalance(donor);
+  const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['CollectionCreated', 'CollectionDestroyed']}]);
+  const {collectionAddress, events: ethEvents} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');
+  {
+    expect(ethEvents).to.be.like([
+      {
+        event: 'CollectionCreated',
+        args: {
+          owner: owner,
+          collectionId: collectionAddress,
+        },
+      },
+    ]);
+    expect(subEvents).to.be.like([{method: 'CollectionCreated'}]);
+    ethEvents.pop();
+    subEvents.pop();
+  }
+  {
+    const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
+    const result = await collectionHelper.methods.destroyCollection(collectionAddress).send({from:owner});
+    expect(result.events).to.be.like({
+      CollectionDestroyed: {
+        returnValues: {
+          collectionId: collectionAddress,
+        },
+      },
+    });
+    expect(subEvents).to.be.like([{method: 'CollectionDestroyed'}]);
+  }
+  unsubscribe();
 }
 
 async function testCollectionPropertySetAndCollectionPropertyDeleted(helper: EthUniqueHelper, mode: TCollectionMode) {
-    const owner = await helper.eth.createAccountWithBalance(donor);
-    const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');
-    const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);
-    const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
+  const owner = await helper.eth.createAccountWithBalance(donor);
+  const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');
+  const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);
+  const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
     
-    let {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['CollectionPropertySet', 'CollectionPropertyDeleted']}]);
-    {
-        const ethEvents: any = [];
-        collectionHelper.events.allEvents((_: any, event: any) => {
-            ethEvents.push(event);
-        });
-        await collection.methods.setCollectionProperties([{key: 'A', value: [0,1,2,3]}]).send({from:owner});
-        expect(ethEvents).to.be.like([
-            {
-                event: 'CollectionChanged',
-                returnValues: {
-                    collectionId: collectionAddress
-                }
-            }
-        ]);
-        expect(subEvents).to.be.like([{method: 'CollectionPropertySet'}]);
-        subEvents.pop();
-    }
-    {
-        const ethEvents: any = [];
-        collectionHelper.events.allEvents((_: any, event: any) => {
-            ethEvents.push(event);
-        });
-        await collection.methods.deleteCollectionProperties(['A']).send({from:owner});
-        expect(ethEvents).to.be.like([
-            {
-                event: 'CollectionChanged',
-                returnValues: {
-                    collectionId: collectionAddress
-                }
-            }
-        ]);
-        expect(subEvents).to.be.like([{method: 'CollectionPropertyDeleted'}]);
-    }
-    unsubscribe();
-}
-
-async function testPropertyPermissionSet(helper: EthUniqueHelper, mode: TCollectionMode) {
-    const owner = await helper.eth.createAccountWithBalance(donor);
-    const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');
-    const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);
-    const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
-    const eethEvents: any = [];
+  const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['CollectionPropertySet', 'CollectionPropertyDeleted']}]);
+  {
+    const ethEvents: any = [];
+    collectionHelper.events.allEvents((_: any, event: any) => {
+      ethEvents.push(event);
+    });
+    await collection.methods.setCollectionProperties([{key: 'A', value: [0,1,2,3]}]).send({from:owner});
+    expect(ethEvents).to.be.like([
+      {
+        event: 'CollectionChanged',
+        returnValues: {
+          collectionId: collectionAddress,
+        },
+      },
+    ]);
+    expect(subEvents).to.be.like([{method: 'CollectionPropertySet'}]);
+    subEvents.pop();
+  }
+  {
+    const ethEvents: any = [];
     collectionHelper.events.allEvents((_: any, event: any) => {
-        eethEvents.push(event);
+      ethEvents.push(event);
     });
-    const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['PropertyPermissionSet']}]);
-    await collection.methods.setTokenPropertyPermission('testKey', true, true, true).send({from: owner});
-    expect(eethEvents).to.be.like([
-        {
-            event: 'CollectionChanged',
-            returnValues: {
-                collectionId: collectionAddress
-            }
-        }
+    await collection.methods.deleteCollectionProperties(['A']).send({from:owner});
+    expect(ethEvents).to.be.like([
+      {
+        event: 'CollectionChanged',
+        returnValues: {
+          collectionId: collectionAddress,
+        },
+      },
     ]);
-    expect(subEvents).to.be.like([{method: 'PropertyPermissionSet'}]);
-    unsubscribe();
+    expect(subEvents).to.be.like([{method: 'CollectionPropertyDeleted'}]);
+  }
+  unsubscribe();
 }
 
+async function testPropertyPermissionSet(helper: EthUniqueHelper, mode: TCollectionMode) {
+  const owner = await helper.eth.createAccountWithBalance(donor);
+  const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');
+  const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);
+  const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
+  const eethEvents: any = [];
+  collectionHelper.events.allEvents((_: any, event: any) => {
+    eethEvents.push(event);
+  });
+  const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['PropertyPermissionSet']}]);
+  await collection.methods.setTokenPropertyPermission('testKey', true, true, true).send({from: owner});
+  expect(eethEvents).to.be.like([
+    {
+      event: 'CollectionChanged',
+      returnValues: {
+        collectionId: collectionAddress,
+      },
+    },
+  ]);
+  expect(subEvents).to.be.like([{method: 'PropertyPermissionSet'}]);
+  unsubscribe();
+}
+
 async function testAllowListAddressAddedAndAllowListAddressRemoved(helper: EthUniqueHelper, mode: TCollectionMode) {
-    const owner = await helper.eth.createAccountWithBalance(donor);
-        const user = helper.ethCrossAccount.createAccount();
-        const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');
-        const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);
-        const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
-        const ethEvents: any[] = [];
-        collectionHelper.events.allEvents((_: any, event: any) => {
-            ethEvents.push(event);
-        });
+  const owner = await helper.eth.createAccountWithBalance(donor);
+  const user = helper.ethCrossAccount.createAccount();
+  const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');
+  const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);
+  const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
+  const ethEvents: any[] = [];
+  collectionHelper.events.allEvents((_: any, event: any) => {
+    ethEvents.push(event);
+  });
 
-        const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['AllowListAddressAdded', 'AllowListAddressRemoved']}]);
-        {
-            await collection.methods.addToCollectionAllowListCross(user).send({from: owner});
-            expect(ethEvents).to.be.like([
-                {
-                    event: 'CollectionChanged',
-                    returnValues: {
-                        collectionId: collectionAddress
-                    }
-                }
-            ]);
-            expect(subEvents).to.be.like([{method: 'AllowListAddressAdded'}]);
-            ethEvents.pop();
-            subEvents.pop();
-        }
-        {
-            await collection.methods.removeFromCollectionAllowListCross(user).send({from: owner});
-            expect(ethEvents.length).to.be.eq(1);
-            expect(ethEvents).to.be.like([
-                {
-                    event: 'CollectionChanged',
-                    returnValues: {
-                        collectionId: collectionAddress
-                    }
-                }
-            ]);
-            expect(subEvents).to.be.like([{method: 'AllowListAddressRemoved'}]);
-        }
-        unsubscribe();
+  const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['AllowListAddressAdded', 'AllowListAddressRemoved']}]);
+  {
+    await collection.methods.addToCollectionAllowListCross(user).send({from: owner});
+    expect(ethEvents).to.be.like([
+      {
+        event: 'CollectionChanged',
+        returnValues: {
+          collectionId: collectionAddress,
+        },
+      },
+    ]);
+    expect(subEvents).to.be.like([{method: 'AllowListAddressAdded'}]);
+    ethEvents.pop();
+    subEvents.pop();
+  }
+  {
+    await collection.methods.removeFromCollectionAllowListCross(user).send({from: owner});
+    expect(ethEvents.length).to.be.eq(1);
+    expect(ethEvents).to.be.like([
+      {
+        event: 'CollectionChanged',
+        returnValues: {
+          collectionId: collectionAddress,
+        },
+      },
+    ]);
+    expect(subEvents).to.be.like([{method: 'AllowListAddressRemoved'}]);
+  }
+  unsubscribe();
 }
 
 async function testCollectionAdminAddedAndCollectionAdminRemoved(helper: EthUniqueHelper, mode: TCollectionMode) {
-    const owner = await helper.eth.createAccountWithBalance(donor);
-    const user = helper.ethCrossAccount.createAccount();
-    const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');
-    const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);
-    const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
-    const ethEvents: any = [];
-    collectionHelper.events.allEvents((_: any, event: any) => {
-        ethEvents.push(event);
-    });
-    const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['CollectionAdminAdded', 'CollectionAdminRemoved']}]);
-    {
-        await collection.methods.addCollectionAdminCross(user).send({from: owner});
-        expect(ethEvents).to.be.like([
-            {
-                event: 'CollectionChanged',
-                returnValues: {
-                    collectionId: collectionAddress
-                }
-            }
-        ]);
-        expect(subEvents).to.be.like([{method: 'CollectionAdminAdded'}]);
-        ethEvents.pop();
-        subEvents.pop();
-    }
-    {
-        await collection.methods.removeCollectionAdminCross(user).send({from: owner});
-        expect(ethEvents).to.be.like([
-            {
-                event: 'CollectionChanged',
-                returnValues: {
-                    collectionId: collectionAddress
-                }
-            }
-        ]);
-        expect(subEvents).to.be.like([{method: 'CollectionAdminRemoved'}]);
-    }
-    unsubscribe();
+  const owner = await helper.eth.createAccountWithBalance(donor);
+  const user = helper.ethCrossAccount.createAccount();
+  const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');
+  const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);
+  const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
+  const ethEvents: any = [];
+  collectionHelper.events.allEvents((_: any, event: any) => {
+    ethEvents.push(event);
+  });
+  const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['CollectionAdminAdded', 'CollectionAdminRemoved']}]);
+  {
+    await collection.methods.addCollectionAdminCross(user).send({from: owner});
+    expect(ethEvents).to.be.like([
+      {
+        event: 'CollectionChanged',
+        returnValues: {
+          collectionId: collectionAddress,
+        },
+      },
+    ]);
+    expect(subEvents).to.be.like([{method: 'CollectionAdminAdded'}]);
+    ethEvents.pop();
+    subEvents.pop();
+  }
+  {
+    await collection.methods.removeCollectionAdminCross(user).send({from: owner});
+    expect(ethEvents).to.be.like([
+      {
+        event: 'CollectionChanged',
+        returnValues: {
+          collectionId: collectionAddress,
+        },
+      },
+    ]);
+    expect(subEvents).to.be.like([{method: 'CollectionAdminRemoved'}]);
+  }
+  unsubscribe();
 }
 
 async function testCollectionLimitSet(helper: EthUniqueHelper, mode: TCollectionMode) {
-    const owner = await helper.eth.createAccountWithBalance(donor);
-    const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');
-    const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);
-    const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
-    const ethEvents: any = [];
-    collectionHelper.events.allEvents((_: any, event: any) => {
-        ethEvents.push(event);
-    });
-    const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['CollectionLimitSet']}]);
-    {
-        await collection.methods.setCollectionLimit('ownerCanTransfer', 0n).send({from: owner});
-        expect(ethEvents).to.be.like([
-            {
-                event: 'CollectionChanged',
-                returnValues: {
-                    collectionId: collectionAddress
-                }
-            }
-        ]);
-        expect(subEvents).to.be.like([{method: 'CollectionLimitSet'}]);
-    }
-    unsubscribe();
+  const owner = await helper.eth.createAccountWithBalance(donor);
+  const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');
+  const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);
+  const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
+  const ethEvents: any = [];
+  collectionHelper.events.allEvents((_: any, event: any) => {
+    ethEvents.push(event);
+  });
+  const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['CollectionLimitSet']}]);
+  {
+    await collection.methods.setCollectionLimit('ownerCanTransfer', 0n).send({from: owner});
+    expect(ethEvents).to.be.like([
+      {
+        event: 'CollectionChanged',
+        returnValues: {
+          collectionId: collectionAddress,
+        },
+      },
+    ]);
+    expect(subEvents).to.be.like([{method: 'CollectionLimitSet'}]);
+  }
+  unsubscribe();
 }
 
 async function testCollectionOwnedChanged(helper: EthUniqueHelper, mode: TCollectionMode) {
-    const owner = await helper.eth.createAccountWithBalance(donor);
-    const new_owner = helper.ethCrossAccount.createAccount();
-    const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');
-    const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);
-    const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
-    const ethEvents: any = [];
-    collectionHelper.events.allEvents((_: any, event: any) => {
-        ethEvents.push(event);
-    });
-    const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['CollectionOwnedChanged']}]);
-    {
-        await collection.methods.changeCollectionOwnerCross(new_owner).send({from: owner});
-        expect(ethEvents).to.be.like([
-            {
-                event: 'CollectionChanged',
-                returnValues: {
-                    collectionId: collectionAddress
-                }
-            }
-        ]);
-        expect(subEvents).to.be.like([{method: 'CollectionOwnedChanged'}]);
-    }
-    unsubscribe();
+  const owner = await helper.eth.createAccountWithBalance(donor);
+  const new_owner = helper.ethCrossAccount.createAccount();
+  const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');
+  const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);
+  const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
+  const ethEvents: any = [];
+  collectionHelper.events.allEvents((_: any, event: any) => {
+    ethEvents.push(event);
+  });
+  const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['CollectionOwnedChanged']}]);
+  {
+    await collection.methods.changeCollectionOwnerCross(new_owner).send({from: owner});
+    expect(ethEvents).to.be.like([
+      {
+        event: 'CollectionChanged',
+        returnValues: {
+          collectionId: collectionAddress,
+        },
+      },
+    ]);
+    expect(subEvents).to.be.like([{method: 'CollectionOwnedChanged'}]);
+  }
+  unsubscribe();
 }
 
 async function testCollectionPermissionSet(helper: EthUniqueHelper, mode: TCollectionMode) {
-    const owner = await helper.eth.createAccountWithBalance(donor);
-    const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');
-    const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);
-    const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
-    const ethEvents: any = [];
-    collectionHelper.events.allEvents((_: any, event: any) => {
-        ethEvents.push(event);
-    });
-    const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['CollectionPermissionSet']}]);
-    {
-        await collection.methods.setCollectionMintMode(true).send({from: owner});
-        expect(ethEvents).to.be.like([
-            {
-                event: 'CollectionChanged',
-                returnValues: {
-                    collectionId: collectionAddress
-                }
-            }
-        ]);
-        expect(subEvents).to.be.like([{method: 'CollectionPermissionSet'}]);
-        ethEvents.pop();
-        subEvents.pop();
-    }
-    {
-        await collection.methods.setCollectionAccess(1).send({from: owner});
-        expect(ethEvents).to.be.like([
-            {
-                event: 'CollectionChanged',
-                returnValues: {
-                    collectionId: collectionAddress
-                }
-            }
-        ]);
-        expect(subEvents).to.be.like([{method: 'CollectionPermissionSet'}]);
-    }
-    unsubscribe();
+  const owner = await helper.eth.createAccountWithBalance(donor);
+  const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');
+  const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);
+  const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
+  const ethEvents: any = [];
+  collectionHelper.events.allEvents((_: any, event: any) => {
+    ethEvents.push(event);
+  });
+  const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['CollectionPermissionSet']}]);
+  {
+    await collection.methods.setCollectionMintMode(true).send({from: owner});
+    expect(ethEvents).to.be.like([
+      {
+        event: 'CollectionChanged',
+        returnValues: {
+          collectionId: collectionAddress,
+        },
+      },
+    ]);
+    expect(subEvents).to.be.like([{method: 'CollectionPermissionSet'}]);
+    ethEvents.pop();
+    subEvents.pop();
+  }
+  {
+    await collection.methods.setCollectionAccess(1).send({from: owner});
+    expect(ethEvents).to.be.like([
+      {
+        event: 'CollectionChanged',
+        returnValues: {
+          collectionId: collectionAddress,
+        },
+      },
+    ]);
+    expect(subEvents).to.be.like([{method: 'CollectionPermissionSet'}]);
+  }
+  unsubscribe();
 }
 
 async function testCollectionSponsorSetAndSponsorshipConfirmedAndCollectionSponsorRemoved(helper: EthUniqueHelper, mode: TCollectionMode) {
-    const owner = await helper.eth.createAccountWithBalance(donor);
-        const sponsor = await helper.ethCrossAccount.createAccountWithBalance(donor);
-        const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');
-        const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);
-        const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
-        const ethEvents: any = [];
-        collectionHelper.events.allEvents((_: any, event: any) => {
-            ethEvents.push(event);
-        });
-        const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{
-            section: 'common', names: ['CollectionSponsorSet', 'SponsorshipConfirmed', 'CollectionSponsorRemoved'
-        ]}]);
-        {
-            await collection.methods.setCollectionSponsorCross(sponsor).send({from: owner});
-            expect(ethEvents).to.be.like([
-                {
-                    event: 'CollectionChanged',
-                    returnValues: {
-                        collectionId: collectionAddress
-                    }
-                }
-            ]);
-            expect(subEvents).to.be.like([{method: 'CollectionSponsorSet'}]);
-            ethEvents.pop();
-            subEvents.pop();
-        }
-        {
-            await collection.methods.confirmCollectionSponsorship().send({from: sponsor.eth});
-            expect(ethEvents).to.be.like([
-                {
-                    event: 'CollectionChanged',
-                    returnValues: {
-                        collectionId: collectionAddress
-                    }
-                }
-            ]);
-            expect(subEvents).to.be.like([{method: 'SponsorshipConfirmed'}]);
-            ethEvents.pop();
-            subEvents.pop();
-        }
-        {
-            await collection.methods.removeCollectionSponsor().send({from: owner});
-            expect(ethEvents).to.be.like([
-                {
-                    event: 'CollectionChanged',
-                    returnValues: {
-                        collectionId: collectionAddress
-                    }
-                }
-            ]);
-            expect(subEvents).to.be.like([{method: 'CollectionSponsorRemoved'}]);
-        }
-        unsubscribe();
+  const owner = await helper.eth.createAccountWithBalance(donor);
+  const sponsor = await helper.ethCrossAccount.createAccountWithBalance(donor);
+  const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');
+  const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);
+  const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
+  const ethEvents: any = [];
+  collectionHelper.events.allEvents((_: any, event: any) => {
+    ethEvents.push(event);
+  });
+  const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{
+    section: 'common', names: ['CollectionSponsorSet', 'SponsorshipConfirmed', 'CollectionSponsorRemoved',
+    ]}]);
+  {
+    await collection.methods.setCollectionSponsorCross(sponsor).send({from: owner});
+    expect(ethEvents).to.be.like([
+      {
+        event: 'CollectionChanged',
+        returnValues: {
+          collectionId: collectionAddress,
+        },
+      },
+    ]);
+    expect(subEvents).to.be.like([{method: 'CollectionSponsorSet'}]);
+    ethEvents.pop();
+    subEvents.pop();
+  }
+  {
+    await collection.methods.confirmCollectionSponsorship().send({from: sponsor.eth});
+    expect(ethEvents).to.be.like([
+      {
+        event: 'CollectionChanged',
+        returnValues: {
+          collectionId: collectionAddress,
+        },
+      },
+    ]);
+    expect(subEvents).to.be.like([{method: 'SponsorshipConfirmed'}]);
+    ethEvents.pop();
+    subEvents.pop();
+  }
+  {
+    await collection.methods.removeCollectionSponsor().send({from: owner});
+    expect(ethEvents).to.be.like([
+      {
+        event: 'CollectionChanged',
+        returnValues: {
+          collectionId: collectionAddress,
+        },
+      },
+    ]);
+    expect(subEvents).to.be.like([{method: 'CollectionSponsorRemoved'}]);
+  }
+  unsubscribe();
 }
 
 async function testTokenPropertySetAndTokenPropertyDeleted(helper: EthUniqueHelper, mode: TCollectionMode) {
-    const owner = await helper.eth.createAccountWithBalance(donor);
-    const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');
-    const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);
-    const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
-    const result = await collection.methods.mint(owner).send({from: owner});
-    const tokenId = result.events.Transfer.returnValues.tokenId;
-    await collection.methods.setTokenPropertyPermission('A', true, true, true).send({from: owner});
+  const owner = await helper.eth.createAccountWithBalance(donor);
+  const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');
+  const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);
+  const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
+  const result = await collection.methods.mint(owner).send({from: owner});
+  const tokenId = result.events.Transfer.returnValues.tokenId;
+  await collection.methods.setTokenPropertyPermission('A', true, true, true).send({from: owner});
 
 
-    const ethEvents: any = [];
-    collectionHelper.events.allEvents((_: any, event: any) => {
-        ethEvents.push(event);
-    });
-    const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['TokenPropertySet', 'TokenPropertyDeleted']}]);
-    {
-        await collection.methods.setProperties(tokenId, [{key: 'A', value: [1,2,3]}]).send({from: owner});
-        expect(ethEvents).to.be.like([
-            {
-                event: 'TokenChanged',
-                returnValues: {
-                    collectionId: collectionAddress
-                }
-            }
-        ]);
-        expect(subEvents).to.be.like([{method: 'TokenPropertySet'}]);
-        ethEvents.pop();
-        subEvents.pop();
-    }
-    {
-        await collection.methods.deleteProperties(tokenId, ['A']).send({from: owner});
-        expect(ethEvents).to.be.like([
-            {
-                event: 'TokenChanged',
-                returnValues: {
-                    collectionId: collectionAddress
-                }
-            }
-        ]);
-        expect(subEvents).to.be.like([{method: 'TokenPropertyDeleted'}]);
-    }
-    unsubscribe();
+  const ethEvents: any = [];
+  collectionHelper.events.allEvents((_: any, event: any) => {
+    ethEvents.push(event);
+  });
+  const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['TokenPropertySet', 'TokenPropertyDeleted']}]);
+  {
+    await collection.methods.setProperties(tokenId, [{key: 'A', value: [1,2,3]}]).send({from: owner});
+    expect(ethEvents).to.be.like([
+      {
+        event: 'TokenChanged',
+        returnValues: {
+          collectionId: collectionAddress,
+        },
+      },
+    ]);
+    expect(subEvents).to.be.like([{method: 'TokenPropertySet'}]);
+    ethEvents.pop();
+    subEvents.pop();
+  }
+  {
+    await collection.methods.deleteProperties(tokenId, ['A']).send({from: owner});
+    expect(ethEvents).to.be.like([
+      {
+        event: 'TokenChanged',
+        returnValues: {
+          collectionId: collectionAddress,
+        },
+      },
+    ]);
+    expect(subEvents).to.be.like([{method: 'TokenPropertyDeleted'}]);
+  }
+  unsubscribe();
 }
 
 describe('[FT] Sync sub & eth events', () => {
-    const mode: TCollectionMode = 'ft';
+  const mode: TCollectionMode = 'ft';
 
-    itEth('CollectionCreated and CollectionDestroyed events', async ({helper}) => {
-        await testCollectionCreatedAndDestroy(helper, mode);
-    });
+  itEth('CollectionCreated and CollectionDestroyed events', async ({helper}) => {
+    await testCollectionCreatedAndDestroy(helper, mode);
+  });
 
-    itEth('CollectionChanged event for CollectionPropertySet and CollectionPropertyDeleted', async ({helper}) => {
-        await testCollectionPropertySetAndCollectionPropertyDeleted(helper, mode);
-    });
+  itEth('CollectionChanged event for CollectionPropertySet and CollectionPropertyDeleted', async ({helper}) => {
+    await testCollectionPropertySetAndCollectionPropertyDeleted(helper, mode);
+  });
     
-    itEth('CollectionChanged event for AllowListAddressAdded, AllowListAddressRemoved', async ({helper}) => {
-        await testAllowListAddressAddedAndAllowListAddressRemoved(helper, mode);
-    });
+  itEth('CollectionChanged event for AllowListAddressAdded, AllowListAddressRemoved', async ({helper}) => {
+    await testAllowListAddressAddedAndAllowListAddressRemoved(helper, mode);
+  });
     
-    itEth('CollectionChanged event for CollectionAdminAdded, CollectionAdminRemoved', async ({helper}) => {
-        await testCollectionAdminAddedAndCollectionAdminRemoved(helper, mode);
-    });
+  itEth('CollectionChanged event for CollectionAdminAdded, CollectionAdminRemoved', async ({helper}) => {
+    await testCollectionAdminAddedAndCollectionAdminRemoved(helper, mode);
+  });
     
-    itEth('CollectionChanged event for CollectionLimitSet', async ({helper}) => {
-        await testCollectionLimitSet(helper, mode);
-    });
+  itEth('CollectionChanged event for CollectionLimitSet', async ({helper}) => {
+    await testCollectionLimitSet(helper, mode);
+  });
     
-    itEth('CollectionChanged event for CollectionOwnedChanged', async ({helper}) => {
-        await testCollectionOwnedChanged(helper, mode);
-    });
+  itEth('CollectionChanged event for CollectionOwnedChanged', async ({helper}) => {
+    await testCollectionOwnedChanged(helper, mode);
+  });
     
-    itEth('CollectionChanged event for CollectionPermissionSet', async ({helper}) => {
-        await testCollectionPermissionSet(helper, mode);
-    });
+  itEth('CollectionChanged event for CollectionPermissionSet', async ({helper}) => {
+    await testCollectionPermissionSet(helper, mode);
+  });
 
-    itEth('CollectionChanged event for CollectionSponsorSet, SponsorshipConfirmed, CollectionSponsorRemoved', async ({helper}) => {
-        await testCollectionSponsorSetAndSponsorshipConfirmedAndCollectionSponsorRemoved(helper, mode);
-    });
+  itEth('CollectionChanged event for CollectionSponsorSet, SponsorshipConfirmed, CollectionSponsorRemoved', async ({helper}) => {
+    await testCollectionSponsorSetAndSponsorshipConfirmedAndCollectionSponsorRemoved(helper, mode);
+  });
 });
 
 describe('[NFT] Sync sub & eth events', () => {
-    const mode: TCollectionMode = 'nft';
+  const mode: TCollectionMode = 'nft';
 
-    itEth('CollectionCreated and CollectionDestroyed events', async ({helper}) => {
-        await testCollectionCreatedAndDestroy(helper, mode);
-    });
+  itEth('CollectionCreated and CollectionDestroyed events', async ({helper}) => {
+    await testCollectionCreatedAndDestroy(helper, mode);
+  });
 
-    itEth('CollectionChanged event for CollectionPropertySet and CollectionPropertyDeleted', async ({helper}) => {
-        await testCollectionPropertySetAndCollectionPropertyDeleted(helper, mode);
-    });
+  itEth('CollectionChanged event for CollectionPropertySet and CollectionPropertyDeleted', async ({helper}) => {
+    await testCollectionPropertySetAndCollectionPropertyDeleted(helper, mode);
+  });
     
-    itEth('CollectionChanged event for PropertyPermissionSet', async ({helper}) => {
-        await testPropertyPermissionSet(helper, mode);
-    });
+  itEth('CollectionChanged event for PropertyPermissionSet', async ({helper}) => {
+    await testPropertyPermissionSet(helper, mode);
+  });
     
-    itEth('CollectionChanged event for AllowListAddressAdded, AllowListAddressRemoved', async ({helper}) => {
-        await testAllowListAddressAddedAndAllowListAddressRemoved(helper, mode);
-    });
+  itEth('CollectionChanged event for AllowListAddressAdded, AllowListAddressRemoved', async ({helper}) => {
+    await testAllowListAddressAddedAndAllowListAddressRemoved(helper, mode);
+  });
     
-    itEth('CollectionChanged event for CollectionAdminAdded, CollectionAdminRemoved', async ({helper}) => {
-        await testCollectionAdminAddedAndCollectionAdminRemoved(helper, mode);
-    });
+  itEth('CollectionChanged event for CollectionAdminAdded, CollectionAdminRemoved', async ({helper}) => {
+    await testCollectionAdminAddedAndCollectionAdminRemoved(helper, mode);
+  });
     
-    itEth('CollectionChanged event for CollectionLimitSet', async ({helper}) => {
-        await testCollectionLimitSet(helper, mode);
-    });
+  itEth('CollectionChanged event for CollectionLimitSet', async ({helper}) => {
+    await testCollectionLimitSet(helper, mode);
+  });
     
-    itEth('CollectionChanged event for CollectionOwnedChanged', async ({helper}) => {
-        await testCollectionOwnedChanged(helper, mode);
-    });
+  itEth('CollectionChanged event for CollectionOwnedChanged', async ({helper}) => {
+    await testCollectionOwnedChanged(helper, mode);
+  });
     
-    itEth('CollectionChanged event for CollectionPermissionSet', async ({helper}) => {
-        await testCollectionPermissionSet(helper, mode);
-    });
+  itEth('CollectionChanged event for CollectionPermissionSet', async ({helper}) => {
+    await testCollectionPermissionSet(helper, mode);
+  });
 
-    itEth('CollectionChanged event for CollectionSponsorSet, SponsorshipConfirmed, CollectionSponsorRemoved', async ({helper}) => {
-        await testCollectionSponsorSetAndSponsorshipConfirmedAndCollectionSponsorRemoved(helper, mode);
-    });
+  itEth('CollectionChanged event for CollectionSponsorSet, SponsorshipConfirmed, CollectionSponsorRemoved', async ({helper}) => {
+    await testCollectionSponsorSetAndSponsorshipConfirmedAndCollectionSponsorRemoved(helper, mode);
+  });
      
-    itEth('CollectionChanged event for TokenPropertySet, TokenPropertyDeleted', async ({helper}) => {
-        await testTokenPropertySetAndTokenPropertyDeleted(helper, mode);
-    });
+  itEth('CollectionChanged event for TokenPropertySet, TokenPropertyDeleted', async ({helper}) => {
+    await testTokenPropertySetAndTokenPropertyDeleted(helper, mode);
+  });
 });
 
 describe('[RFT] Sync sub & eth events', () => {
-    const mode: TCollectionMode = 'rft';
+  const mode: TCollectionMode = 'rft';
 
-    itEth('CollectionCreated and CollectionDestroyed events', async ({helper}) => {
-        await testCollectionCreatedAndDestroy(helper, mode);
-    });
+  itEth('CollectionCreated and CollectionDestroyed events', async ({helper}) => {
+    await testCollectionCreatedAndDestroy(helper, mode);
+  });
 
-    itEth('CollectionChanged event for CollectionPropertySet and CollectionPropertyDeleted', async ({helper}) => {
-        await testCollectionPropertySetAndCollectionPropertyDeleted(helper, mode);
-    });
+  itEth('CollectionChanged event for CollectionPropertySet and CollectionPropertyDeleted', async ({helper}) => {
+    await testCollectionPropertySetAndCollectionPropertyDeleted(helper, mode);
+  });
     
-    itEth('CollectionChanged event for PropertyPermissionSet', async ({helper}) => {
-        await testPropertyPermissionSet(helper, mode);
-    });
+  itEth('CollectionChanged event for PropertyPermissionSet', async ({helper}) => {
+    await testPropertyPermissionSet(helper, mode);
+  });
     
-    itEth('CollectionChanged event for AllowListAddressAdded, AllowListAddressRemoved', async ({helper}) => {
-        await testAllowListAddressAddedAndAllowListAddressRemoved(helper, mode);
-    });
+  itEth('CollectionChanged event for AllowListAddressAdded, AllowListAddressRemoved', async ({helper}) => {
+    await testAllowListAddressAddedAndAllowListAddressRemoved(helper, mode);
+  });
     
-    itEth('CollectionChanged event for CollectionAdminAdded, CollectionAdminRemoved', async ({helper}) => {
-        await testCollectionAdminAddedAndCollectionAdminRemoved(helper, mode);
-    });
+  itEth('CollectionChanged event for CollectionAdminAdded, CollectionAdminRemoved', async ({helper}) => {
+    await testCollectionAdminAddedAndCollectionAdminRemoved(helper, mode);
+  });
     
-    itEth('CollectionChanged event for CollectionLimitSet', async ({helper}) => {
-        await testCollectionLimitSet(helper, mode);
-    });
+  itEth('CollectionChanged event for CollectionLimitSet', async ({helper}) => {
+    await testCollectionLimitSet(helper, mode);
+  });
     
-    itEth('CollectionChanged event for CollectionOwnedChanged', async ({helper}) => {
-        await testCollectionOwnedChanged(helper, mode);
-    });
+  itEth('CollectionChanged event for CollectionOwnedChanged', async ({helper}) => {
+    await testCollectionOwnedChanged(helper, mode);
+  });
     
-    itEth('CollectionChanged event for CollectionPermissionSet', async ({helper}) => {
-        await testCollectionPermissionSet(helper, mode);
-    });
+  itEth('CollectionChanged event for CollectionPermissionSet', async ({helper}) => {
+    await testCollectionPermissionSet(helper, mode);
+  });
 
-    itEth('CollectionChanged event for CollectionSponsorSet, SponsorshipConfirmed, CollectionSponsorRemoved', async ({helper}) => {
-        await testCollectionSponsorSetAndSponsorshipConfirmedAndCollectionSponsorRemoved(helper, mode);
-    });
+  itEth('CollectionChanged event for CollectionSponsorSet, SponsorshipConfirmed, CollectionSponsorRemoved', async ({helper}) => {
+    await testCollectionSponsorSetAndSponsorshipConfirmedAndCollectionSponsorRemoved(helper, mode);
+  });
      
-    itEth('CollectionChanged event for TokenPropertySet, TokenPropertyDeleted', async ({helper}) => {
-        await testTokenPropertySetAndTokenPropertyDeleted(helper, mode);
-    });
+  itEth('CollectionChanged event for TokenPropertySet, TokenPropertyDeleted', async ({helper}) => {
+    await testTokenPropertySetAndTokenPropertyDeleted(helper, mode);
+  });
 });
modifiedtests/src/eth/proxy/nonFungibleProxy.test.tsdiffbeforeafterboth
before · tests/src/eth/proxy/nonFungibleProxy.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 {readFile} from 'fs/promises';18import {IKeyringPair} from '@polkadot/types/types';19import {EthUniqueHelper, itEth, usingEthPlaygrounds, expect} from '../util';202122async function proxyWrap(helper: EthUniqueHelper, wrapped: any, donor: IKeyringPair) {23  // Proxy owner has no special privilegies, we don't need to reuse them24  const owner = await helper.eth.createAccountWithBalance(donor);25  const web3 = helper.getWeb3();26  const proxyContract = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/UniqueNFTProxy.abi`)).toString()), undefined, {27    from: owner,28    gas: helper.eth.DEFAULT_GAS,29  });30  const proxy = await proxyContract.deploy({data: (await readFile(`${__dirname}/UniqueNFTProxy.bin`)).toString(), arguments: [wrapped.options.address]}).send({from: owner});31  return proxy;32}3334describe('NFT (Via EVM proxy): Information getting', () => {35  let alice: IKeyringPair;36  let donor: IKeyringPair;3738  before(async function() {39    await usingEthPlaygrounds(async (helper, privateKey) => {40      donor = await privateKey({filename: __filename});41      [alice] = await helper.arrange.createAccounts([10n], donor);42    });43  });4445  itEth('totalSupply', async ({helper}) => {46    const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});47    const caller = await helper.eth.createAccountWithBalance(donor);48    await collection.mintToken(alice, {Substrate: alice.address});4950    const address = helper.ethAddress.fromCollectionId(collection.collectionId);51    const evmCollection = helper.ethNativeContract.collection(address, 'nft', caller);52    const contract = await proxyWrap(helper, evmCollection, donor);53    const totalSupply = await contract.methods.totalSupply().call();5455    expect(totalSupply).to.equal('1');56  });5758  itEth('balanceOf', async ({helper}) => {59    const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});6061    const caller = await helper.eth.createAccountWithBalance(donor);62    await collection.mintMultipleTokens(alice, [63      {owner: {Ethereum: caller}},64      {owner: {Ethereum: caller}},65      {owner: {Ethereum: caller}},66    ]);6768    const address = helper.ethAddress.fromCollectionId(collection.collectionId);69    const evmCollection = helper.ethNativeContract.collection(address, 'nft', caller);70    const contract = await proxyWrap(helper, evmCollection, donor);71    const balance = await contract.methods.balanceOf(caller).call();7273    expect(balance).to.equal('3');74  });7576  itEth('ownerOf', async ({helper}) => {77    const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});7879    const caller = await helper.eth.createAccountWithBalance(donor);80    const {tokenId} = await collection.mintToken(alice, {Ethereum: caller});8182    const address = helper.ethAddress.fromCollectionId(collection.collectionId);83    const evmCollection = helper.ethNativeContract.collection(address, 'nft', caller);84    const contract = await proxyWrap(helper, evmCollection, donor);85    const owner = await contract.methods.ownerOf(tokenId).call();8687    expect(owner).to.equal(caller);88  });89});9091describe('NFT (Via EVM proxy): Plain calls', () => {92  let alice: IKeyringPair;93  let donor: IKeyringPair;9495  before(async function() {96    await usingEthPlaygrounds(async (helper, privateKey) => {97      donor = await privateKey({filename: __filename});98      [alice] = await helper.arrange.createAccounts([10n], donor);99    });100  });101102  // Soft-deprecated103  itEth('[eth] Can perform mint()', async ({helper}) => {104    const owner = await helper.eth.createAccountWithBalance(donor);105    const {collectionAddress} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner, 'A', 'A', 'A', '');106    const caller = await helper.eth.createAccountWithBalance(donor);107    const receiver = helper.eth.createAccount();108109    const collectionEvmOwned = helper.ethNativeContract.collection(collectionAddress, 'nft', owner, true);110    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', caller, true);111    const contract = await proxyWrap(helper, collectionEvm, donor);112    await collectionEvmOwned.methods.addCollectionAdmin(contract.options.address).send();113114    {115      const nextTokenId = await contract.methods.nextTokenId().call();116      const result = await contract.methods.mintWithTokenURI(receiver, nextTokenId, 'Test URI').send({from: caller});117      const tokenId = result.events.Transfer.returnValues.tokenId;118      expect(tokenId).to.be.equal('1');119120      const event = helper.eth.normalizeEvents(result.events)121        .find(event => event.event === 'Transfer')!;122      event.address = event.address.toLocaleLowerCase();123124      expect(event).to.be.deep.equal(125        {126          address: collectionAddress.toLocaleLowerCase(),127          event: 'Transfer',128          args: {129            from: '0x0000000000000000000000000000000000000000',130            to: receiver,131            tokenId,132          },133        },134      );135136      expect(await contract.methods.tokenURI(tokenId).call()).to.be.equal('Test URI');137    }138  });139140  itEth('[cross] Can perform mint()', async ({helper}) => {141    const owner = await helper.eth.createAccountWithBalance(donor);142    const {collectionAddress} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner, 'A', 'A', 'A', '');143    const caller = await helper.eth.createAccountWithBalance(donor);144    const receiver = helper.eth.createAccount();145146    const collectionEvmOwned = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);147    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', caller);148    const contract = await proxyWrap(helper, collectionEvm, donor);149    const contractAddressCross = helper.ethCrossAccount.fromAddress(contract.options.address);150    await collectionEvmOwned.methods.addCollectionAdminCross(contractAddressCross).send();151152    {153      const nextTokenId = await contract.methods.nextTokenId().call();154      const result = await contract.methods.mintWithTokenURI(receiver, nextTokenId, 'Test URI').send({from: caller});155      const tokenId = result.events.Transfer.returnValues.tokenId;156      expect(tokenId).to.be.equal('1');157158      const event = helper.eth.normalizeEvents(result.events)159        .find(event => event.event === 'Transfer')!;160      event.address = event.address.toLocaleLowerCase();161162      expect(event).to.be.deep.equal(163        {164          address: collectionAddress.toLocaleLowerCase(),165          event: 'Transfer',166          args: {167            from: '0x0000000000000000000000000000000000000000',168            to: receiver,169            tokenId,170          },171        },172      );173174      expect(await contract.methods.tokenURI(tokenId).call()).to.be.equal('Test URI');175    }176  });177178  //TODO: CORE-302 add eth methods179  itEth.skip('Can perform mintBulk()', async ({helper}) => {180    const collection = await helper.nft.mintCollection(donor, {name: 'New', description: 'New collection', tokenPrefix: 'NEW'});181182    const caller = await helper.eth.createAccountWithBalance(donor, 30n);183    const receiver = helper.eth.createAccount();184185    const address = helper.ethAddress.fromCollectionId(collection.collectionId);186    const evmCollection = helper.ethNativeContract.collection(address, 'nft', caller);187    const contract = await proxyWrap(helper, evmCollection, donor);188    await collection.addAdmin(donor, {Ethereum: contract.options.address});189190    {191      const nextTokenId = await contract.methods.nextTokenId().call();192      expect(nextTokenId).to.be.equal('1');193      const result = await contract.methods.mintBulkWithTokenURI(194        receiver,195        [196          [nextTokenId, 'Test URI 0'],197          [+nextTokenId + 1, 'Test URI 1'],198          [+nextTokenId + 2, 'Test URI 2'],199        ],200      ).send({from: caller});201      const events = helper.eth.normalizeEvents(result.events);202203      expect(events).to.be.deep.equal([204        {205          address,206          event: 'Transfer',207          args: {208            from: '0x0000000000000000000000000000000000000000',209            to: receiver,210            tokenId: nextTokenId,211          },212        },213        {214          address,215          event: 'Transfer',216          args: {217            from: '0x0000000000000000000000000000000000000000',218            to: receiver,219            tokenId: String(+nextTokenId + 1),220          },221        },222        {223          address,224          event: 'Transfer',225          args: {226            from: '0x0000000000000000000000000000000000000000',227            to: receiver,228            tokenId: String(+nextTokenId + 2),229          },230        },231      ]);232233      expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('Test URI 0');234      expect(await contract.methods.tokenURI(+nextTokenId + 1).call()).to.be.equal('Test URI 1');235      expect(await contract.methods.tokenURI(+nextTokenId + 2).call()).to.be.equal('Test URI 2');236    }237  });238239  itEth('Can perform burn()', async ({helper}) => {240    const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});241    const caller = await helper.eth.createAccountWithBalance(donor);242243    const address = helper.ethAddress.fromCollectionId(collection.collectionId);244    const evmCollection = helper.ethNativeContract.collection(address, 'nft', caller);245    const contract = await proxyWrap(helper, evmCollection, donor);246    const {tokenId} = await collection.mintToken(alice, {Ethereum: contract.options.address});247    await collection.addAdmin(alice, {Ethereum: contract.options.address});248249    {250      const result = await contract.methods.burn(tokenId).send({from: caller});251      const events = helper.eth.normalizeEvents(result.events);252253      expect(events).to.be.deep.equal([254        {255          address,256          event: 'Transfer',257          args: {258            from: contract.options.address,259            to: '0x0000000000000000000000000000000000000000',260            tokenId: tokenId.toString(),261          },262        },263      ]);264    }265  });266267  itEth('Can perform approve()', async ({helper}) => {268    const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});269    const caller = await helper.eth.createAccountWithBalance(donor);270    const spender = helper.eth.createAccount();271272    const address = helper.ethAddress.fromCollectionId(collection.collectionId);273    const evmCollection = helper.ethNativeContract.collection(address, 'nft', caller);274    const contract = await proxyWrap(helper, evmCollection, donor);275    const {tokenId} = await collection.mintToken(alice, {Ethereum: contract.options.address});276277    {278      const result = await contract.methods.approve(spender, tokenId).send({from: caller, gas: helper.eth.DEFAULT_GAS});279      const events = helper.eth.normalizeEvents(result.events);280281      expect(events).to.be.deep.equal([282        {283          address,284          event: 'Approval',285          args: {286            owner: contract.options.address,287            approved: spender,288            tokenId: tokenId.toString(),289          },290        },291      ]);292    }293  });294295  itEth('Can perform transferFrom()', async ({helper}) => {296    const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});297    const caller = await helper.eth.createAccountWithBalance(donor);298    const owner = await helper.eth.createAccountWithBalance(donor);299300    const receiver = helper.eth.createAccount();301302    const address = helper.ethAddress.fromCollectionId(collection.collectionId);303    const evmCollection = helper.ethNativeContract.collection(address, 'nft', caller);304    const contract = await proxyWrap(helper, evmCollection, donor);305    const {tokenId} = await collection.mintToken(alice, {Ethereum: owner});306307    await evmCollection.methods.approve(contract.options.address, tokenId).send({from: owner});308309    {310      const result = await contract.methods.transferFrom(owner, receiver, tokenId).send({from: caller});311      const events = helper.eth.normalizeEvents(result.events);312      expect(events).to.be.deep.equal([313        {314          address,315          event: 'Transfer',316          args: {317            from: owner,318            to: receiver,319            tokenId: tokenId.toString(),320          },321        },322      ]);323    }324325    {326      const balance = await contract.methods.balanceOf(receiver).call();327      expect(+balance).to.equal(1);328    }329330    {331      const balance = await contract.methods.balanceOf(contract.options.address).call();332      expect(+balance).to.equal(0);333    }334  });335336  itEth('Can perform transfer()', async ({helper}) => {337    const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});338    const caller = await helper.eth.createAccountWithBalance(donor);339    const receiver = helper.eth.createAccount();340341    const address = helper.ethAddress.fromCollectionId(collection.collectionId);342    const evmCollection = helper.ethNativeContract.collection(address, 'nft', caller);343    const contract = await proxyWrap(helper, evmCollection, donor);344    const {tokenId} = await collection.mintToken(alice, {Ethereum: contract.options.address});345346    {347      const result = await contract.methods.transfer(receiver, tokenId).send({from: caller});348      const events = helper.eth.normalizeEvents(result.events);349      expect(events).to.be.deep.equal([350        {351          address,352          event: 'Transfer',353          args: {354            from: contract.options.address,355            to: receiver,356            tokenId: tokenId.toString(),357          },358        },359      ]);360    }361362    {363      const balance = await contract.methods.balanceOf(contract.options.address).call();364      expect(+balance).to.equal(0);365    }366367    {368      const balance = await contract.methods.balanceOf(receiver).call();369      expect(+balance).to.equal(1);370    }371  });372});
after · tests/src/eth/proxy/nonFungibleProxy.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 {readFile} from 'fs/promises';18import {IKeyringPair} from '@polkadot/types/types';19import {EthUniqueHelper, itEth, usingEthPlaygrounds, expect} from '../util';202122async function proxyWrap(helper: EthUniqueHelper, wrapped: any, donor: IKeyringPair) {23  // Proxy owner has no special privilegies, we don't need to reuse them24  const owner = await helper.eth.createAccountWithBalance(donor);25  const web3 = helper.getWeb3();26  const proxyContract = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/UniqueNFTProxy.abi`)).toString()), undefined, {27    from: owner,28    gas: helper.eth.DEFAULT_GAS,29  });30  const proxy = await proxyContract.deploy({data: (await readFile(`${__dirname}/UniqueNFTProxy.bin`)).toString(), arguments: [wrapped.options.address]}).send({from: owner});31  return proxy;32}3334describe('NFT (Via EVM proxy): Information getting', () => {35  let alice: IKeyringPair;36  let donor: IKeyringPair;3738  before(async function() {39    await usingEthPlaygrounds(async (helper, privateKey) => {40      donor = await privateKey({filename: __filename});41      [alice] = await helper.arrange.createAccounts([10n], donor);42    });43  });4445  itEth('totalSupply', async ({helper}) => {46    const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});47    const caller = await helper.eth.createAccountWithBalance(donor);48    await collection.mintToken(alice, {Substrate: alice.address});4950    const address = helper.ethAddress.fromCollectionId(collection.collectionId);51    const evmCollection = helper.ethNativeContract.collection(address, 'nft', caller);52    const contract = await proxyWrap(helper, evmCollection, donor);53    const totalSupply = await contract.methods.totalSupply().call();5455    expect(totalSupply).to.equal('1');56  });5758  itEth('balanceOf', async ({helper}) => {59    const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});6061    const caller = await helper.eth.createAccountWithBalance(donor);62    await collection.mintMultipleTokens(alice, [63      {owner: {Ethereum: caller}},64      {owner: {Ethereum: caller}},65      {owner: {Ethereum: caller}},66    ]);6768    const address = helper.ethAddress.fromCollectionId(collection.collectionId);69    const evmCollection = helper.ethNativeContract.collection(address, 'nft', caller);70    const contract = await proxyWrap(helper, evmCollection, donor);71    const balance = await contract.methods.balanceOf(caller).call();7273    expect(balance).to.equal('3');74  });7576  itEth('ownerOf', async ({helper}) => {77    const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});7879    const caller = await helper.eth.createAccountWithBalance(donor);80    const {tokenId} = await collection.mintToken(alice, {Ethereum: caller});8182    const address = helper.ethAddress.fromCollectionId(collection.collectionId);83    const evmCollection = helper.ethNativeContract.collection(address, 'nft', caller);84    const contract = await proxyWrap(helper, evmCollection, donor);85    const owner = await contract.methods.ownerOf(tokenId).call();8687    expect(owner).to.equal(caller);88  });89});9091describe('NFT (Via EVM proxy): Plain calls', () => {92  let alice: IKeyringPair;93  let donor: IKeyringPair;9495  before(async function() {96    await usingEthPlaygrounds(async (helper, privateKey) => {97      donor = await privateKey({filename: __filename});98      [alice] = await helper.arrange.createAccounts([10n], donor);99    });100  });101102  // Soft-deprecated103  itEth('[eth] Can perform mint()', async ({helper}) => {104    const owner = await helper.eth.createAccountWithBalance(donor);105    const {collectionAddress} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner, 'A', 'A', 'A', '');106    const caller = await helper.eth.createAccountWithBalance(donor);107    const receiver = helper.eth.createAccount();108109    const collectionEvmOwned = helper.ethNativeContract.collection(collectionAddress, 'nft', owner, true);110    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', caller, true);111    const contract = await proxyWrap(helper, collectionEvm, donor);112    await collectionEvmOwned.methods.addCollectionAdmin(contract.options.address).send();113114    {115      const nextTokenId = await contract.methods.nextTokenId().call();116      const result = await contract.methods.mintWithTokenURI(receiver, nextTokenId, 'Test URI').send({from: caller});117      const tokenId = result.events.Transfer.returnValues.tokenId;118      expect(tokenId).to.be.equal('1');119120      const event = helper.eth.normalizeEvents(result.events)121        .find(event => event.event === 'Transfer')!;122      event.address = event.address.toLocaleLowerCase();123124      expect(event).to.be.deep.equal({125        address: collectionAddress.toLocaleLowerCase(),126        event: 'Transfer',127        args: {128          from: '0x0000000000000000000000000000000000000000',129          to: receiver,130          tokenId,131        },132      });133134      expect(await contract.methods.tokenURI(tokenId).call()).to.be.equal('Test URI');135    }136  });137138  itEth('[cross] Can perform mint()', async ({helper}) => {139    const owner = await helper.eth.createAccountWithBalance(donor);140    const {collectionAddress} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner, 'A', 'A', 'A', '');141    const caller = await helper.eth.createAccountWithBalance(donor);142    const receiver = helper.eth.createAccount();143144    const collectionEvmOwned = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);145    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', caller);146    const contract = await proxyWrap(helper, collectionEvm, donor);147    const contractAddressCross = helper.ethCrossAccount.fromAddress(contract.options.address);148    await collectionEvmOwned.methods.addCollectionAdminCross(contractAddressCross).send();149150    {151      const nextTokenId = await contract.methods.nextTokenId().call();152      const result = await contract.methods.mintWithTokenURI(receiver, nextTokenId, 'Test URI').send({from: caller});153      const tokenId = result.events.Transfer.returnValues.tokenId;154      expect(tokenId).to.be.equal('1');155156      const event = helper.eth.normalizeEvents(result.events)157        .find(event => event.event === 'Transfer')!;158      event.address = event.address.toLocaleLowerCase();159160      expect(event).to.be.deep.equal({161        address: collectionAddress.toLocaleLowerCase(),162        event: 'Transfer',163        args: {164          from: '0x0000000000000000000000000000000000000000',165          to: receiver,166          tokenId,167        },168      });169170      expect(await contract.methods.tokenURI(tokenId).call()).to.be.equal('Test URI');171    }172  });173174  //TODO: CORE-302 add eth methods175  itEth.skip('Can perform mintBulk()', async ({helper}) => {176    const collection = await helper.nft.mintCollection(donor, {name: 'New', description: 'New collection', tokenPrefix: 'NEW'});177178    const caller = await helper.eth.createAccountWithBalance(donor, 30n);179    const receiver = helper.eth.createAccount();180181    const address = helper.ethAddress.fromCollectionId(collection.collectionId);182    const evmCollection = helper.ethNativeContract.collection(address, 'nft', caller);183    const contract = await proxyWrap(helper, evmCollection, donor);184    await collection.addAdmin(donor, {Ethereum: contract.options.address});185186    {187      const nextTokenId = await contract.methods.nextTokenId().call();188      expect(nextTokenId).to.be.equal('1');189      const result = await contract.methods.mintBulkWithTokenURI(190        receiver,191        [192          [nextTokenId, 'Test URI 0'],193          [+nextTokenId + 1, 'Test URI 1'],194          [+nextTokenId + 2, 'Test URI 2'],195        ],196      ).send({from: caller});197      const events = helper.eth.normalizeEvents(result.events);198199      expect(events).to.be.deep.equal([200        {201          address,202          event: 'Transfer',203          args: {204            from: '0x0000000000000000000000000000000000000000',205            to: receiver,206            tokenId: nextTokenId,207          },208        },209        {210          address,211          event: 'Transfer',212          args: {213            from: '0x0000000000000000000000000000000000000000',214            to: receiver,215            tokenId: String(+nextTokenId + 1),216          },217        },218        {219          address,220          event: 'Transfer',221          args: {222            from: '0x0000000000000000000000000000000000000000',223            to: receiver,224            tokenId: String(+nextTokenId + 2),225          },226        },227      ]);228229      expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('Test URI 0');230      expect(await contract.methods.tokenURI(+nextTokenId + 1).call()).to.be.equal('Test URI 1');231      expect(await contract.methods.tokenURI(+nextTokenId + 2).call()).to.be.equal('Test URI 2');232    }233  });234235  itEth('Can perform burn()', async ({helper}) => {236    const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});237    const caller = await helper.eth.createAccountWithBalance(donor);238239    const address = helper.ethAddress.fromCollectionId(collection.collectionId);240    const evmCollection = helper.ethNativeContract.collection(address, 'nft', caller);241    const contract = await proxyWrap(helper, evmCollection, donor);242    const {tokenId} = await collection.mintToken(alice, {Ethereum: contract.options.address});243    await collection.addAdmin(alice, {Ethereum: contract.options.address});244245    {246      const result = await contract.methods.burn(tokenId).send({from: caller});247      const events = helper.eth.normalizeEvents(result.events);248249      expect(events).to.be.deep.equal([250        {251          address,252          event: 'Transfer',253          args: {254            from: contract.options.address,255            to: '0x0000000000000000000000000000000000000000',256            tokenId: tokenId.toString(),257          },258        },259      ]);260    }261  });262263  itEth('Can perform approve()', async ({helper}) => {264    const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});265    const caller = await helper.eth.createAccountWithBalance(donor);266    const spender = helper.eth.createAccount();267268    const address = helper.ethAddress.fromCollectionId(collection.collectionId);269    const evmCollection = helper.ethNativeContract.collection(address, 'nft', caller);270    const contract = await proxyWrap(helper, evmCollection, donor);271    const {tokenId} = await collection.mintToken(alice, {Ethereum: contract.options.address});272273    {274      const result = await contract.methods.approve(spender, tokenId).send({from: caller, gas: helper.eth.DEFAULT_GAS});275      const events = helper.eth.normalizeEvents(result.events);276277      expect(events).to.be.deep.equal([278        {279          address,280          event: 'Approval',281          args: {282            owner: contract.options.address,283            approved: spender,284            tokenId: tokenId.toString(),285          },286        },287      ]);288    }289  });290291  itEth('Can perform transferFrom()', async ({helper}) => {292    const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});293    const caller = await helper.eth.createAccountWithBalance(donor);294    const owner = await helper.eth.createAccountWithBalance(donor);295296    const receiver = helper.eth.createAccount();297298    const address = helper.ethAddress.fromCollectionId(collection.collectionId);299    const evmCollection = helper.ethNativeContract.collection(address, 'nft', caller);300    const contract = await proxyWrap(helper, evmCollection, donor);301    const {tokenId} = await collection.mintToken(alice, {Ethereum: owner});302303    await evmCollection.methods.approve(contract.options.address, tokenId).send({from: owner});304305    {306      const result = await contract.methods.transferFrom(owner, receiver, tokenId).send({from: caller});307      const events = helper.eth.normalizeEvents(result.events);308      expect(events).to.be.deep.equal([309        {310          address,311          event: 'Transfer',312          args: {313            from: owner,314            to: receiver,315            tokenId: tokenId.toString(),316          },317        },318      ]);319    }320321    {322      const balance = await contract.methods.balanceOf(receiver).call();323      expect(+balance).to.equal(1);324    }325326    {327      const balance = await contract.methods.balanceOf(contract.options.address).call();328      expect(+balance).to.equal(0);329    }330  });331332  itEth('Can perform transfer()', async ({helper}) => {333    const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});334    const caller = await helper.eth.createAccountWithBalance(donor);335    const receiver = helper.eth.createAccount();336337    const address = helper.ethAddress.fromCollectionId(collection.collectionId);338    const evmCollection = helper.ethNativeContract.collection(address, 'nft', caller);339    const contract = await proxyWrap(helper, evmCollection, donor);340    const {tokenId} = await collection.mintToken(alice, {Ethereum: contract.options.address});341342    {343      const result = await contract.methods.transfer(receiver, tokenId).send({from: caller});344      const events = helper.eth.normalizeEvents(result.events);345      expect(events).to.be.deep.equal([346        {347          address,348          event: 'Transfer',349          args: {350            from: contract.options.address,351            to: receiver,352            tokenId: tokenId.toString(),353          },354        },355      ]);356    }357358    {359      const balance = await contract.methods.balanceOf(contract.options.address).call();360      expect(+balance).to.equal(0);361    }362363    {364      const balance = await contract.methods.balanceOf(receiver).call();365      expect(+balance).to.equal(1);366    }367  });368});
modifiedtests/src/eth/util/playgrounds/unique.dev.tsdiffbeforeafterboth
--- a/tests/src/eth/util/playgrounds/unique.dev.ts
+++ b/tests/src/eth/util/playgrounds/unique.dev.ts
@@ -188,16 +188,16 @@
 
   createCollectionMethodName(mode: TCollectionMode) {
     switch (mode) {
-        case 'ft':
-            return 'createFTCollection';
-        case 'nft':
-            return 'createNFTCollection';
-        case 'rft':
-            return 'createRFTCollection';
+      case 'ft':
+        return 'createFTCollection';
+      case 'nft':
+        return 'createNFTCollection';
+      case 'rft':
+        return 'createRFTCollection';
     }
   }
 
-  async createCollection(mode: TCollectionMode, signer: string, name: string, description: string, tokenPrefix: string, decimals: number = 18): Promise<{ collectionId: number, collectionAddress: string, events: NormalizedEvent[] }> {
+  async createCollection(mode: TCollectionMode, signer: string, name: string, description: string, tokenPrefix: string, decimals = 18): Promise<{ collectionId: number, collectionAddress: string, events: NormalizedEvent[] }> {
     const collectionCreationPrice = this.helper.balance.getCollectionCreationPrice();
     const collectionHelper = this.helper.ethNativeContract.collectionHelpers(signer);
     const functionName: string = this.createCollectionMethodName(mode);
modifiedtests/src/util/playgrounds/unique.tsdiffbeforeafterboth
--- a/tests/src/util/playgrounds/unique.ts
+++ b/tests/src/util/playgrounds/unique.ts
@@ -44,7 +44,7 @@
 } from './types';
 import {RuntimeDispatchInfo} from '@polkadot/types/interfaces';
 import type {Vec} from '@polkadot/types-codec';
-import { FrameSystemEventRecord } from '@polkadot/types/lookup';
+import {FrameSystemEventRecord} from '@polkadot/types/lookup';
 
 export class CrossAccountId implements ICrossAccountId {
   Substrate?: TSubstrateAccount;
@@ -409,17 +409,17 @@
   async subscribeEvents(expectedEvents: {section: string, names: string[]}[]) {
     const collectedEvents: IEvent[] = [];
     const unsubscribe = await this.getApi().query.system.events((events: Vec<FrameSystemEventRecord>) => {
-        const ievents = this.eventHelper.extractEvents(events);
-        ievents.forEach((event) => {
-            expectedEvents.forEach((e => {
-                if (event.section === e.section && e.names.includes(event.method)) {
-                    collectedEvents.push(event);
-                }
-            }))
-        });
+      const ievents = this.eventHelper.extractEvents(events);
+      ievents.forEach((event) => {
+        expectedEvents.forEach((e => {
+          if (event.section === e.section && e.names.includes(event.method)) {
+            collectedEvents.push(event);
+          }
+        }));
+      });
     });
     return {unsubscribe: unsubscribe as any, collectedEvents};
-}
+  }
 
   clearChainLog(): void {
     this.chainLog = [];