Skip to content

Commit

Permalink
[REG-983] - Add gas estimations for multicall domain transfer
Browse files Browse the repository at this point in the history
  • Loading branch information
DeRain committed May 24, 2023
1 parent bc79cc1 commit 68d1d72
Showing 1 changed file with 36 additions and 2 deletions.
38 changes: 36 additions & 2 deletions test/consumption/UNSRegistry.multicall.gas.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@ import { UNSRegistry } from '../../types/contracts';
import { UNSRegistry__factory } from '../../types/factories/contracts';
import { TLD, ZERO_ADDRESS } from '../helpers/constants';
import { percDiff } from '../helpers/consumption';
import { mintDomain } from '../helpers/registry';
import { buildExecuteFunc, ExecuteFunc } from '../helpers/metatx';

describe('UNSRegistry Multicall (consumption)', () => {
let unsRegistry: UNSRegistry;
let signers: SignerWithAddress[], coinbase: SignerWithAddress, receiver: SignerWithAddress;
let signers: SignerWithAddress[],
coinbase: SignerWithAddress,
receiver: SignerWithAddress,
owner: SignerWithAddress;
let buildExecuteParams: ExecuteFunc;

async function prepParams (params: unknown[][], labels: string[]) {
const _params: unknown[][] = [];
Expand Down Expand Up @@ -37,12 +43,13 @@ describe('UNSRegistry Multicall (consumption)', () => {

before(async () => {
signers = await ethers.getSigners();
[coinbase, receiver] = signers;
[coinbase, receiver, owner] = signers;

unsRegistry = await new UNSRegistry__factory(coinbase).deploy();
await unsRegistry.initialize(coinbase.address, ZERO_ADDRESS, ZERO_ADDRESS, ZERO_ADDRESS);
await unsRegistry.mintTLD(TLD.CRYPTO, 'crypto');
await unsRegistry.setTokenURIPrefix('/');
buildExecuteParams = buildExecuteFunc(unsRegistry.interface, unsRegistry.address, unsRegistry);
});

it('Consumption', async () => {
Expand Down Expand Up @@ -161,4 +168,31 @@ describe('UNSRegistry Multicall (consumption)', () => {
}
console.table(result);
});

it('Multiple transfers consumption (MetaTX) - 50 domains', async () => {
const domainsAmount = 50;
const mintedTokenIds: string[] = [];
for (let i = 0; i < domainsAmount; i++) {
const tokenId = await mintDomain(unsRegistry, owner, ['tm1-' + i, 'crypto']);
mintedTokenIds.push(tokenId.toString());
}

const muticallData: string[] = [];
const domainsReceiver = await ethers.Wallet.createRandom();
for (const tokenId of mintedTokenIds) {
const { req, signature } = await buildExecuteParams(
'transferFrom(address,address,uint256)',
[owner.address, domainsReceiver.address, tokenId],
owner,
tokenId,
);
muticallData.push(unsRegistry.interface.encodeFunctionData('execute', [req, signature]));
}
const tx = await unsRegistry.multicall(muticallData);
const receipt = await tx.wait();
console.table({
name: 'Transfer ' + domainsAmount + ' domains',
gasUsed: receipt.gasUsed.toString(),
});
});
});

0 comments on commit 68d1d72

Please sign in to comment.