Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REG-983] - Add gas estimations for multicall domain transfer #272

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(),
});
});
});