Skip to content

Commit 545bdf5

Browse files
committed
scripts: benchmarks: fix permissions errors in mintFee
1 parent e61785c commit 545bdf5

File tree

1 file changed

+16
-12
lines changed
  • js-packages/scripts/benchmarks/mintFee

1 file changed

+16
-12
lines changed

js-packages/scripts/benchmarks/mintFee/index.ts

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {readFile} from 'fs/promises';
44
import type {ICrossAccountId} from '@unique-nft/playgrounds/types.js';
55
import type {IKeyringPair} from '@polkadot/types/types';
66
import {UniqueNFTCollection} from '@unique-nft/playgrounds/unique.js';
7-
import {Contract} from 'ethers';
7+
import {Contract, hexlify} from 'ethers';
88
import {createObjectCsvWriter} from 'csv-writer';
99
import {convertToTokens, createCollectionForBenchmarks, PERMISSIONS, PROPERTIES} from '../utils/common.js';
1010
import {makeNames} from '@unique/test-utils/util.js';
@@ -124,7 +124,7 @@ main()
124124
async function benchMintFee(
125125
helper: EthUniqueHelper,
126126
privateKey: (seed: string) => Promise<IKeyringPair>,
127-
proxyContract: Contract,
127+
contract: Contract,
128128
): Promise<{
129129
substrateFee: number;
130130
ethFee: number;
@@ -134,6 +134,8 @@ async function benchMintFee(
134134
const substrateReceiver = await privateKey('//Bob');
135135
const ethSigner = await helper.eth.createAccountWithBalance(donor);
136136

137+
const proxyContract = helper.eth.changeContractCaller(contract, ethSigner);
138+
137139
const nominal = helper.balance.getOneTokenNominal();
138140

139141
await helper.eth.transferBalanceFromSubstrate(
@@ -184,7 +186,7 @@ async function benchMintFee(
184186
async () => {
185187
await (await proxyContract.mintToSubstrate.send(
186188
helper.ethAddress.fromCollectionId(collection.collectionId),
187-
substrateReceiver.addressRaw,
189+
hexlify(substrateReceiver.addressRaw),
188190
)).wait(...waitParams);
189191
},
190192
);
@@ -199,14 +201,16 @@ async function benchMintFee(
199201
async function benchMintWithProperties(
200202
helper: EthUniqueHelper,
201203
privateKey: (seed: string) => Promise<IKeyringPair>,
202-
proxyContract: Contract,
204+
contract: Contract,
203205
setup: { propertiesNumber: number },
204206
): Promise<IBenchmarkResultForProp> {
205207
const donor = await privateKey('//Alice'); // Seed from account with balance on this network
206208
const ethSigner = await helper.eth.createAccountWithBalance(donor);
207209

208-
const susbstrateReceiver = await privateKey('//Bob');
209-
const receiverEthAddress = helper.address.substrateToEth(susbstrateReceiver.address);
210+
const proxyContract = helper.eth.changeContractCaller(contract, ethSigner);
211+
212+
const substrateReceiver = await privateKey('//Bob');
213+
const receiverEthAddress = helper.address.substrateToEth(substrateReceiver.address);
210214

211215
const nominal = helper.balance.getOneTokenNominal();
212216

@@ -219,7 +223,7 @@ async function benchMintWithProperties(
219223
async (collection) => {
220224
await collection.mintToken(
221225
donor,
222-
{Substrate: susbstrateReceiver.address},
226+
{Substrate: substrateReceiver.address},
223227
PROPERTIES.slice(0, setup.propertiesNumber).map((p) => ({key: p.key, value: Buffer.from(p.value).toString()})),
224228
);
225229
},
@@ -235,7 +239,7 @@ async function benchMintWithProperties(
235239
const evmContract = await helper.ethNativeContract.collection(
236240
helper.ethAddress.fromCollectionId(collection.collectionId),
237241
'nft',
238-
undefined as any,
242+
ethSigner,
239243
true,
240244
);
241245

@@ -273,7 +277,7 @@ async function benchMintWithProperties(
273277
const evmContract = await helper.ethNativeContract.collection(
274278
helper.ethAddress.fromCollectionId(collection.collectionId),
275279
'nft',
276-
undefined as any,
280+
ethSigner,
277281
);
278282

279283
const subTokenId = await evmContract.nextTokenId.staticCall();
@@ -308,7 +312,7 @@ async function benchMintWithProperties(
308312
const evmContract = await helper.ethNativeContract.collection(
309313
helper.ethAddress.fromCollectionId(collection.collectionId),
310314
'nft',
311-
undefined as any,
315+
ethSigner,
312316
);
313317

314318
await (await evmContract.mintCross.send(
@@ -327,7 +331,7 @@ async function benchMintWithProperties(
327331
async (collection) => {
328332
await (await proxyContract.mintToSubstrateWithProperty(
329333
helper.ethAddress.fromCollectionId(collection.collectionId),
330-
susbstrateReceiver.addressRaw,
334+
hexlify(substrateReceiver.addressRaw),
331335
PROPERTIES.slice(0, setup.propertiesNumber),
332336
)).wait(...waitParams);
333337
},
@@ -342,7 +346,7 @@ async function benchMintWithProperties(
342346
async (collection) => {
343347
await (await proxyContract.mintToSubstrateBulkProperty.send(
344348
helper.ethAddress.fromCollectionId(collection.collectionId),
345-
susbstrateReceiver.addressRaw,
349+
hexlify(substrateReceiver.addressRaw),
346350
PROPERTIES.slice(0, setup.propertiesNumber),
347351
)).wait(...waitParams);
348352
},

0 commit comments

Comments
 (0)