difftreelog
fix after rebase
in: master
3 files changed
tests/src/eth/collectionAdmin.test.tsdiffbeforeafterboth64 expect(adminList).to.be.like([{Substrate: newAdmin.address}]);64 expect(adminList).to.be.like([{Substrate: newAdmin.address}]);65 });65 });6667 itEth('Check adminlist', async ({helper, privateKey}) => {68 const owner = await helper.eth.createAccountWithBalance(donor);69 70 const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');71 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);7273 const admin1 = helper.eth.createAccount();74 const admin2 = await privateKey('admin');75 await collectionEvm.methods.addCollectionAdmin(admin1).send();76 await collectionEvm.methods.addCollectionAdminSubstrate(admin2.addressRaw).send();7778 const adminListRpc = await helper.collection.getAdmins(collectionId);79 let adminListEth = await collectionEvm.methods.collectionAdmins().call();80 adminListEth = adminListEth.map((element: IEthCrossAccountId) => {81 return helper.address.convertCrossAccountFromEthCrossAcoount(element);82 });83 expect(adminListRpc).to.be.like(adminListEth);84 });668567 itEth('Verify owner or admin', async ({helper}) => {86 itEth('Verify owner or admin', async ({helper}) => {68 const owner = await helper.eth.createAccountWithBalance(donor);87 const owner = await helper.eth.createAccountWithBalance(donor);tests/src/eth/collectionProperties.test.tsdiffbeforeafterboth14// You should have received a copy of the GNU General Public License14// You should have received a copy of the GNU General Public License15// 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/>.161617import {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';212222describe('EVM collection properties', () => {23describe('EVM collection properties', () => {23 let donor: IKeyringPair;24 let donor: IKeyringPair;tests/src/util/playgrounds/unique.tsdiffbeforeafterboth2342 return siblingPrefix + encodedParaId + suffix;2342 return siblingPrefix + encodedParaId + suffix;2343 }2343 }23442345 /**2346 * Encode key to substrate address2347 * @param key key for encoding address2348 * @param ss58Format prefix for encoding to the address of the corresponding network2349 * @returns encoded substrate address2350 */2351 encodeSubstrateAddress (key: Uint8Array | string | bigint, ss58Format = 42): string {2352 const u8a :Uint8Array = typeof key === 'string'2353 ? hexToU8a(key)2354 : typeof key === 'bigint'2355 ? hexToU8a(key.toString(16))2356 : key;2357 2358 if (ss58Format < 0 || ss58Format > 16383 || [46, 47].includes(ss58Format)) {2359 throw new Error(`ss58Format is not valid, received ${typeof ss58Format} "${ss58Format}"`);2360 }2361 2362 const allowedDecodedLengths = [1, 2, 4, 8, 32, 33];2363 if (!allowedDecodedLengths.includes(u8a.length)) {2364 throw new Error(`key length is not valid, received ${u8a.length}, valid values are ${allowedDecodedLengths.join(', ')}`);2365 }2366 2367 const u8aPrefix = ss58Format < 642368 ? new Uint8Array([ss58Format])2369 : new Uint8Array([2370 ((ss58Format & 0xfc) >> 2) | 0x40,2371 (ss58Format >> 8) | ((ss58Format & 0x03) << 6),2372 ]);23732374 const input = u8aConcat(u8aPrefix, u8a);2375 2376 return base58Encode(u8aConcat(2377 input,2378 blake2AsU8a(input).subarray(0, [32, 33].includes(u8a.length) ? 2 : 1),2379 ));2380 }23812382 /**2383 * Restore substrate address from bigint representation2384 * @param number decimal representation of substrate address2385 * @returns substrate address2386 */2387 restoreCrossAccountFromBigInt(number: bigint): TSubstrateAccount {2388 if (this.helper.api === null) {2389 throw 'Not connected';2390 }2391 const res = this.helper.api.registry.createType('AccountId', '0x' + number.toString(16).padStart(64, '0')).toJSON();2392 if (res === undefined || res === null) {2393 throw 'Restore address error';2394 }2395 return res.toString();2396 }23972398 /**2399 * Convert etherium cross account id to substrate cross account id2400 * @param ethCrossAccount etherium cross account2401 * @returns substrate cross account id2402 */2403 convertCrossAccountFromEthCrossAcoount(ethCrossAccount: IEthCrossAccountId): ICrossAccountId {2404 if (ethCrossAccount.field_1 === '0') {2405 return {Ethereum: ethCrossAccount.field_0.toLocaleLowerCase()};2406 }2407 2408 const ss58 = this.restoreCrossAccountFromBigInt(BigInt(ethCrossAccount.field_1));2409 return {Substrate: ss58};2410 }2411}2344}241223452413class StakingGroup extends HelperGroup<UniqueHelper> {2346class StakingGroup extends HelperGroup<UniqueHelper> {