1import {EthUniqueHelper} from '../../eth/util';2import {ITokenPropertyPermission, TCollectionMode} from '../../util/playgrounds/types';3import {UniqueNFTCollection, UniqueRFTCollection} from '../../util/playgrounds/unique';4import {IKeyringPair} from '@polkadot/types/types';5import {ContractImports} from '../../eth/util/playgrounds/types';67export const CONTRACT_IMPORT: ContractImports[] = [8 {9 fsPath: `${__dirname}/../../eth/api/CollectionHelpers.sol`,10 solPath: 'eth/api/CollectionHelpers.sol',11 },12 {13 fsPath: `${__dirname}/../../eth/api/ContractHelpers.sol`,14 solPath: 'eth/api/ContractHelpers.sol',15 },16 {17 fsPath: `${__dirname}/../../eth/api/UniqueRefungibleToken.sol`,18 solPath: 'eth/api/UniqueRefungibleToken.sol',19 },20 {21 fsPath: `${__dirname}/../../eth/api/UniqueRefungible.sol`,22 solPath: 'eth/api/UniqueRefungible.sol',23 },24 {25 fsPath: `${__dirname}/../../eth/api/UniqueNFT.sol`,26 solPath: 'eth/api/UniqueNFT.sol',27 },28];2930export const PROPERTIES = Array(40)31 .fill(0)32 .map((_, i) => {33 return {34 key: `key_${i}`,35 value: Uint8Array.from(Buffer.from(`value_${i}`)),36 };37 });3839export const SUBS_PROPERTIES = Array(40)40 .fill(0)41 .map((_, i) => {42 return {43 key: `key_${i}`,44 value: `value_${i}`,45 };46 });4748export const PERMISSIONS: ITokenPropertyPermission[] = PROPERTIES.map((p) => {49 return {50 key: p.key,51 permission: {52 tokenOwner: true,53 collectionAdmin: true,54 mutable: true,55 },56 };57});5859export function convertToTokens(value: bigint, nominal = 1000_000_000_000_000_000n): number {60 return Number((value * 1000n) / nominal) / 1000;61}6263export async function createCollectionForBenchmarks(64 mode : TCollectionMode,65 helper: EthUniqueHelper,66 privateKey: (seed: string) => Promise<IKeyringPair>,67 ethSigner: string,68 proxyContract: string | null,69 permissions: ITokenPropertyPermission[],70) {71 const donor = await privateKey('//Alice');7273 const collection = await helper[mode].mintCollection(donor, {74 name: 'test mintToSubstrate',75 description: 'EVMHelpers',76 tokenPrefix: mode,77 ...(mode != 'ft' ? {78 tokenPropertyPermissions: [79 {80 key: 'url',81 permission: {82 tokenOwner: true,83 collectionAdmin: true,84 mutable: true,85 },86 },87 {88 key: 'URI',89 permission: {90 tokenOwner: true,91 collectionAdmin: true,92 mutable: true,93 },94 },95 ],96 } : {}),97 limits: {sponsorTransferTimeout: 0, sponsorApproveTimeout: 0},98 permissions: {mintMode: true},99 });100101 await collection.addToAllowList(donor, {102 Ethereum: helper.address.substrateToEth(donor.address),103 });104 await collection.addToAllowList(donor, {Substrate: donor.address});105 await collection.addAdmin(donor, {Ethereum: ethSigner});106 await collection.addAdmin(donor, {107 Ethereum: helper.address.substrateToEth(donor.address),108 });109110 if (proxyContract) {111 await collection.addToAllowList(donor, {Ethereum: proxyContract});112 await collection.addAdmin(donor, {Ethereum: proxyContract});113 }114 if (collection instanceof UniqueNFTCollection || collection instanceof UniqueRFTCollection)115 await collection.setTokenPropertyPermissions(donor, permissions);116117 return collection;118}