git.delta.rocks / unique-network / refs/commits / fd6a419056e6

difftreelog

fix normalize addresses

rkv2022-09-22parent: #b45c52c.patch.diff
in: master

3 files changed

modifiedtests/src/change-collection-owner.test.tsdiffbeforeafterboth
31 itSub('Changing owner changes owner address', async ({helper}) => {31 itSub('Changing owner changes owner address', async ({helper}) => {
32 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});32 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
33 const beforeChanging = await helper.collection.getData(collection.collectionId);33 const beforeChanging = await helper.collection.getData(collection.collectionId);
34 expect(beforeChanging?.normalizedOwner).to.be.equal(alice.address);34 expect(beforeChanging?.normalizedOwner).to.be.equal(helper.util.normalizeSubstrateAddress(alice.address));
3535
36 await collection.changeOwner(alice, bob.address);36 await collection.changeOwner(alice, bob.address);
37 const afterChanging = await helper.collection.getData(collection.collectionId);37 const afterChanging = await helper.collection.getData(collection.collectionId);
38 expect(afterChanging?.normalizedOwner).to.be.equal(bob.address);38 expect(afterChanging?.normalizedOwner).to.be.equal(helper.util.normalizeSubstrateAddress(bob.address));
39 });39 });
40});40});
4141
60 await expect(changeOwnerTx()).to.be.rejectedWith(/common\.NoPermission/);60 await expect(changeOwnerTx()).to.be.rejectedWith(/common\.NoPermission/);
6161
62 const afterChanging = await helper.collection.getData(collection.collectionId);62 const afterChanging = await helper.collection.getData(collection.collectionId);
63 expect(afterChanging?.normalizedOwner).to.be.equal(bob.address);63 expect(afterChanging?.normalizedOwner).to.be.equal(helper.util.normalizeSubstrateAddress(bob.address));
64 });64 });
6565
66 itSub('New collectionOwner has access to sponsorship management operations in the collection', async ({helper}) => {66 itSub('New collectionOwner has access to sponsorship management operations in the collection', async ({helper}) => {
67 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});67 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
68 await collection.changeOwner(alice, bob.address);68 await collection.changeOwner(alice, bob.address);
6969
70 const afterChanging = await helper.collection.getData(collection.collectionId);70 const afterChanging = await helper.collection.getData(collection.collectionId);
71 expect(afterChanging?.normalizedOwner).to.be.equal(bob.address);71 expect(afterChanging?.normalizedOwner).to.be.equal(helper.util.normalizeSubstrateAddress(bob.address));
7272
73 await collection.setSponsor(bob, charlie.address);73 await collection.setSponsor(bob, charlie.address);
74 await collection.confirmSponsorship(charlie);74 await collection.confirmSponsorship(charlie);
97 await collection.changeOwner(alice, bob.address);97 await collection.changeOwner(alice, bob.address);
98 await collection.changeOwner(bob, charlie.address);98 await collection.changeOwner(bob, charlie.address);
99 const collectionData = await collection.getData();99 const collectionData = await collection.getData();
100 expect(collectionData?.normalizedOwner).to.be.equal(charlie.address);100 expect(collectionData?.normalizedOwner).to.be.equal(helper.util.normalizeSubstrateAddress(charlie.address));
101 });101 });
102});102});
103103
140 await expect(changeOwnerTx()).to.be.rejectedWith(/common\.NoPermission/);140 await expect(changeOwnerTx()).to.be.rejectedWith(/common\.NoPermission/);
141141
142 const afterChanging = await helper.collection.getData(collection.collectionId);142 const afterChanging = await helper.collection.getData(collection.collectionId);
143 expect(afterChanging?.normalizedOwner).to.be.equal(bob.address);143 expect(afterChanging?.normalizedOwner).to.be.equal(helper.util.normalizeSubstrateAddress(bob.address));
144144
145 const setSponsorTx = async () => collection.setSponsor(alice, charlie.address);145 const setSponsorTx = async () => collection.setSponsor(alice, charlie.address);
146 const confirmSponsorshipTx = async () => collection.confirmSponsorship(alice);146 const confirmSponsorshipTx = async () => collection.confirmSponsorship(alice);
modifiedtests/src/createCollection.test.tsdiffbeforeafterboth
--- a/tests/src/createCollection.test.ts
+++ b/tests/src/createCollection.test.ts
@@ -29,7 +29,7 @@
     collection = await helper.rft.mintCollection(signer, options);
   }
   const data = await collection.getData();
-  expect(data?.normalizedOwner).to.be.equal(signer.address);
+  expect(data?.normalizedOwner).to.be.equal(helper.util.normalizeSubstrateAddress(signer.address));
   expect(data?.name).to.be.equal(options.name);
   expect(data?.description).to.be.equal(options.description);
   expect(data?.raw.tokenPrefix).to.be.equal(options.tokenPrefix);
@@ -96,7 +96,7 @@
     const limits = await collection.getEffectiveLimits();
     const raw = data?.raw;
 
-    expect(data?.normalizedOwner).to.be.equal(alice.address);
+    expect(data?.normalizedOwner).to.be.equal(helper.util.normalizeSubstrateAddress(alice.address));
     expect(data?.name).to.be.equal('name');
     expect(data?.description).to.be.equal('descr');
     expect(raw.permissions.access).to.be.equal('AllowList');
modifiedtests/src/createMultipleItems.test.tsdiffbeforeafterboth
--- a/tests/src/createMultipleItems.test.ts
+++ b/tests/src/createMultipleItems.test.ts
@@ -48,7 +48,7 @@
     const tokens = await helper.nft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);
     for (const [i, token] of tokens.entries()) {
       const tokenData = await token.getData();
-      expect(tokenData?.normalizedOwner).to.be.deep.equal({Substrate: alice.address});
+      expect(tokenData?.normalizedOwner).to.be.deep.equal({Substrate: helper.util.normalizeSubstrateAddress(alice.address)});
       expect(tokenData?.properties[0].value).to.be.equal(args[i].properties[0].value);
     }
   });
@@ -116,7 +116,7 @@
     const tokens = await helper.nft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);
     for (const [i, token] of tokens.entries()) {
       const tokenData = await token.getData();
-      expect(tokenData?.normalizedOwner).to.be.deep.equal({Substrate: alice.address});
+      expect(tokenData?.normalizedOwner).to.be.deep.equal({Substrate: helper.util.normalizeSubstrateAddress(alice.address)});
       expect(tokenData?.properties[0].value).to.be.equal(args[i].properties[0].value);
     }
   });
@@ -138,7 +138,7 @@
     const tokens = await helper.nft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);
     for (const [i, token] of tokens.entries()) {
       const tokenData = await token.getData();
-      expect(tokenData?.normalizedOwner).to.be.deep.equal({Substrate: alice.address});
+      expect(tokenData?.normalizedOwner).to.be.deep.equal({Substrate: helper.util.normalizeSubstrateAddress(alice.address)});
       expect(tokenData?.properties[0].value).to.be.equal(args[i].properties[0].value);
     }
   });
@@ -160,7 +160,7 @@
     const tokens = await helper.nft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);
     for (const [i, token] of tokens.entries()) {
       const tokenData = await token.getData();
-      expect(tokenData?.normalizedOwner).to.be.deep.equal({Substrate: alice.address});
+      expect(tokenData?.normalizedOwner).to.be.deep.equal({Substrate: helper.util.normalizeSubstrateAddress(alice.address)});
       expect(tokenData?.properties[0].value).to.be.equal(args[i].properties[0].value);
     }
   });