--- 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'); --- a/tests/src/eth/collectionProperties.test.ts +++ b/tests/src/eth/collectionProperties.test.ts @@ -14,10 +14,11 @@ // You should have received a copy of the GNU General Public License // along with Unique Network. If not, see . -import {itEth, usingEthPlaygrounds, expect, EthUniqueHelper} from './util'; +import {itEth, usingEthPlaygrounds, expect, EthUniqueHelper, EthUniqueHelper} from './util'; import {Pallets} from '../util'; import {IProperty, ITokenPropertyPermission, TCollectionMode} from '../util/playgrounds/types'; import {IKeyringPair} from '@polkadot/types/types'; +import {TCollectionMode} from '../util/playgrounds/types'; describe('EVM collection properties', () => { let donor: IKeyringPair; --- 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 {