git.delta.rocks / unique-network / refs/commits / 6d40fa6f157c

difftreelog

fix after rebase

Trubnikov Sergey2022-10-24parent: #36fc5ab.patch.diff
in: master

3 files changed

modifiedtests/src/eth/collectionAdmin.test.tsdiffbeforeafterboth
--- a/tests/src/eth/collectionAdmin.test.ts
+++ b/tests/src/eth/collectionAdmin.test.ts
@@ -64,6 +64,25 @@
     expect(adminList).to.be.like([{Substrate: newAdmin.address}]);
   });
 
+  itEth('Check adminlist', async ({helper, privateKey}) => {
+    const owner = await helper.eth.createAccountWithBalance(donor);
+        
+    const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
+    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
+
+    const admin1 = helper.eth.createAccount();
+    const admin2 = await privateKey('admin');
+    await collectionEvm.methods.addCollectionAdmin(admin1).send();
+    await collectionEvm.methods.addCollectionAdminSubstrate(admin2.addressRaw).send();
+
+    const adminListRpc = await helper.collection.getAdmins(collectionId);
+    let adminListEth = await collectionEvm.methods.collectionAdmins().call();
+    adminListEth = adminListEth.map((element: IEthCrossAccountId) => {
+      return helper.address.convertCrossAccountFromEthCrossAcoount(element);
+    });
+    expect(adminListRpc).to.be.like(adminListEth);
+  });
+
   itEth('Verify owner or admin', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor);
     const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
modifiedtests/src/eth/collectionProperties.test.tsdiffbeforeafterboth
14// You should have received a copy of the GNU General Public License14// You should have received a copy of the GNU General Public License
15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
1616
17import {itEth, usingEthPlaygrounds, expect, EthUniqueHelper} from './util';17import {itEth, usingEthPlaygrounds, expect, EthUniqueHelper, EthUniqueHelper} from './util';
18import {Pallets} from '../util';18import {Pallets} from '../util';
19import {IProperty, ITokenPropertyPermission, TCollectionMode} from '../util/playgrounds/types';19import {IProperty, ITokenPropertyPermission, TCollectionMode} from '../util/playgrounds/types';
20import {IKeyringPair} from '@polkadot/types/types';20import {IKeyringPair} from '@polkadot/types/types';
21import {TCollectionMode} from '../util/playgrounds/types';
2122
22describe('EVM collection properties', () => {23describe('EVM collection properties', () => {
23 let donor: IKeyringPair;24 let donor: IKeyringPair;
modifiedtests/src/util/playgrounds/unique.tsdiffbeforeafterboth
--- a/tests/src/util/playgrounds/unique.ts
+++ b/tests/src/util/playgrounds/unique.ts
@@ -2341,73 +2341,6 @@
 
     return siblingPrefix + encodedParaId + suffix;
   }
-
-  /**
-   * Encode key to substrate address
-   * @param key key for encoding address
-   * @param ss58Format prefix for encoding to the address of the corresponding network
-   * @returns encoded substrate address
-   */
-  encodeSubstrateAddress (key: Uint8Array | string | bigint, ss58Format = 42): string {
-    const u8a :Uint8Array = typeof key === 'string'
-      ? hexToU8a(key)
-      : typeof key === 'bigint'
-        ? hexToU8a(key.toString(16))
-        : key;
-  
-    if (ss58Format < 0 || ss58Format > 16383 || [46, 47].includes(ss58Format)) {
-      throw new Error(`ss58Format is not valid, received ${typeof ss58Format} "${ss58Format}"`);
-    }
-  
-    const allowedDecodedLengths = [1, 2, 4, 8, 32, 33];
-    if (!allowedDecodedLengths.includes(u8a.length)) {
-      throw new Error(`key length is not valid, received ${u8a.length}, valid values are ${allowedDecodedLengths.join(', ')}`);
-    }
-  
-    const u8aPrefix = ss58Format < 64
-      ? new Uint8Array([ss58Format])
-      : new Uint8Array([
-        ((ss58Format & 0xfc) >> 2) | 0x40,
-        (ss58Format >> 8) | ((ss58Format & 0x03) << 6),
-      ]);
-
-    const input = u8aConcat(u8aPrefix, u8a);
-  
-    return base58Encode(u8aConcat(
-      input,
-      blake2AsU8a(input).subarray(0, [32, 33].includes(u8a.length) ? 2 : 1),
-    ));
-  }
-
-  /**
-   * Restore substrate address from bigint representation
-   * @param number decimal representation of substrate address
-   * @returns substrate address
-   */
-  restoreCrossAccountFromBigInt(number: bigint): TSubstrateAccount {
-    if (this.helper.api === null) {
-      throw 'Not connected';
-    }
-    const res = this.helper.api.registry.createType('AccountId', '0x' + number.toString(16).padStart(64, '0')).toJSON();
-    if (res === undefined || res === null) {
-      throw 'Restore address error';
-    }
-    return res.toString();
-  }
-
-  /**
-   * Convert etherium cross account id to substrate cross account id
-   * @param ethCrossAccount etherium cross account
-   * @returns substrate cross account id
-   */
-  convertCrossAccountFromEthCrossAcoount(ethCrossAccount: IEthCrossAccountId): ICrossAccountId {
-    if (ethCrossAccount.field_1 === '0') {
-      return {Ethereum: ethCrossAccount.field_0.toLocaleLowerCase()};
-    }
-    
-    const ss58 = this.restoreCrossAccountFromBigInt(BigInt(ethCrossAccount.field_1));
-    return {Substrate: ss58};
-  }
 }
 
 class StakingGroup extends HelperGroup<UniqueHelper> {