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-1332] feat: move uns tlds minting config outside of minting manager #351

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## v0.9.23

- Tld config removed from the Minting manager
- Tld config introduced in the uns repo, constants.ts
- Added a deployment task that mints all TLDs from the TLD config

## v0.9.22

- Add `.raiin` TLD
Expand Down
4 changes: 2 additions & 2 deletions artifacts/MintingManager.json

Large diffs are not rendered by default.

42 changes: 0 additions & 42 deletions contracts/MintingManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -103,48 +103,6 @@ contract MintingManager is ERC2771Context, MinterRole, Blocklist, Pausable, IMin
__MinterRole_init_unchained();
__ERC2771Context_init_unchained(forwarder);
__Pausable_init_unchained();

string[31] memory tlds = [
'crypto',
'wallet',
'x',
'nft',
'blockchain',
'bitcoin',
'888',
'dao',
'zil',
'polygon',
'unstoppable',
'klever',
'hi',
'kresus',
'anime',
'manga',
'binanceus',
'realm',
'go',
'altimist',
'pudgy',
'austin',
'bitget',
'pog',
'clay',
'witg',
'metropolis',
'wrkx',
'secret',
'raiin',
'stepn'
];
for (uint256 i = 0; i < tlds.length; i++) {
_addTld(tlds[i], false);
}

string[2] memory expirableTlds = ['com', 'ca'];
for (uint256 i = 0; i < expirableTlds.length; i++) {
_addTld(expirableTlds[i], true);
}
}

function addTld(string calldata tld, bool isExpirable) external override onlyOwner {
Expand Down
66 changes: 35 additions & 31 deletions ens-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,45 +73,45 @@
"1337": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please increase version of ens-config

"contracts": {
"ENSRegistry": {
"address": "0xc965345EDaC823D56812cD20A10316233916a605",
"deploymentBlock": "0x33",
"address": "0x6265cc8D1b28eDfd4D76C80bf774c0D446FFfbde",
"deploymentBlock": "0x55",
"legacyAddresses": []
},
"BaseRegistrarImplementation": {
"address": "0xf670681605eFc4efC804F5a9b97ee89520473d56",
"deploymentBlock": "0x34",
"address": "0xE4fDf45C2F8D198854f8823809C7a988eeAAA493",
"deploymentBlock": "0x56",
"legacyAddresses": []
},
"ReverseRegistrar": {
"address": "0x72FA6D0C2F56b802D762a14F1a71f9A56221cabe",
"deploymentBlock": "0x35",
"address": "0x5202cFE910C2D066e2A40f5Ca410c8eb26b92614",
"deploymentBlock": "0x57",
"legacyAddresses": []
},
"NameWrapper": {
"address": "0xF97b1F8b7c2598AA59f404F65E32DfA68de16dcC",
"deploymentBlock": "0x38",
"address": "0xc2110388dd54228aE0A834119457edE938BF0B57",
"deploymentBlock": "0x5a",
"legacyAddresses": []
},
"DummyOracle": {
"address": "0xeC71E4E674fe0f432693DC2b935C34bd2774C003",
"deploymentBlock": "0x3a",
"address": "0x951c830a0471C04DCB60Ce244DEe38eE4b0609ec",
"deploymentBlock": "0x5c",
"legacyAddresses": []
},
"StablePriceOracle": {
"address": "0x4fbf7B2f171336958BE5D15FF762a5CfF5363568",
"deploymentBlock": "0x3b",
"address": "0x5831f0664Ee58C88DE672946678Fed9a228Eb83B",
"deploymentBlock": "0x5d",
"legacyAddresses": []
},
"ETHRegistrarController": {
"address": "0xB17aAe5B3A7815433fC82Cfd67Ea245767894f03",
"deploymentBlock": "0x3c",
"address": "0x50eBEc0b0EAfc732324C1A28963C1FcB7889DA39",
"deploymentBlock": "0x5e",
"legacyAddresses": []
},
"PublicResolver": {
"address": "0xF1Ad43dc647f27c2366Ab4742d68d21282F7d50e",
"deploymentBlock": "0x45",
"address": "0x51A944e573DdcA58500583A997F2E46616A15770",
"deploymentBlock": "0x67",
"legacyAddresses": [
"0x0F242B0A26Fe26eA32929E05DfDbE1640e61FBA2"
"0x942518378eb0f32aAaB57B9c8176432AcCCdA331"
]
},
"ProxyAdmin": {
Expand All @@ -120,33 +120,37 @@
"legacyAddresses": []
},
"ENSCustody": {
"address": "0x951c830a0471C04DCB60Ce244DEe38eE4b0609ec",
"deploymentBlock": "0x5c",
"implementation": "0x3198fc981626687F4B5BDf0fbEABB0a5E0489C03",
"forwarder": "0x951c830a0471C04DCB60Ce244DEe38eE4b0609ec",
"address": "0xD16B320155789DB85e80e1ba25bf3123CB9bC8BD",
"deploymentBlock": "0x7e",
"implementation": "0x2f8cCe2f451D0F71708dC28ecafb0CFf0C2a8d39",
"forwarder": "0xD16B320155789DB85e80e1ba25bf3123CB9bC8BD",
"legacyAddresses": []
},
"LegacyENSRegistry": {
"address": "0xDAe1eD2709D22d03C1B0FEe45817EC59Bdb5B20F",
"deploymentBlock": "0x48",
"address": "0x0E2b61C5F7BCA3d8Fb1CBf5710B4157efCE36349",
"deploymentBlock": "0x6a",
"legacyAddresses": []
},
"LegacyETHRegistrarController": {
"address": "0x653F5A2aF800684EcF2aAeAcE8dBE86afEaaEBC0",
"deploymentBlock": "0x3d",
"address": "0xc86965b7720a64c86263030f7B2902c752084F46",
"deploymentBlock": "0x5f",
"legacyAddresses": []
},
"DNSSECImpl": {
"address": "0xFb82C655715B43b07863e9c2fd42f60bbd9838B0",
"deploymentBlock": "0x4f"
"address": "0xb9025e16A304BA1604e4b93e0A5d6cc4C699a772",
"deploymentBlock": "0x71"
},
"DNSRegistrar": {
"address": "0xE4fDf45C2F8D198854f8823809C7a988eeAAA493",
"deploymentBlock": "0x56"
"address": "0xE22d997f9f86801B0405a691B28CF74285fBbC79",
"deploymentBlock": "0x78"
},
"Root": {
"address": "0x5202cFE910C2D066e2A40f5Ca410c8eb26b92614",
"deploymentBlock": "0x57"
"address": "0x6EACD6613004f5B029fe62DC800CB22172be286A",
"deploymentBlock": "0x79"
},
"LegacyPublicResolver": {
"address": "0x4fbf7B2f171336958BE5D15FF762a5CfF5363568",
"deploymentBlock": "0x3b"
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "uns",
"version": "0.9.22",
"version": "0.9.23",
"description": "UNS contracts and tools",
"repository": "https://github.com/unstoppabledomains/uns.git",
"main": "./dist/index.js",
Expand Down
26 changes: 20 additions & 6 deletions sandbox/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ import { AbiCoder } from 'ethers';
import { NameService, getNetworkConfig } from '../src/config';
import { MintingManager, UNSRegistry } from '../types';
import { unwrap } from '../src/utils';
import { BUFFERED_REGISTRATION_COST, REGISTRATION_TIME, TLD, ZERO_ADDRESS } from '../test/helpers/constants';
import {
BUFFERED_REGISTRATION_COST,
REGISTRATION_TIME,
TLD,
ZERO_ADDRESS,
} from '../test/helpers/constants';
import {
CNSRegistry,
CNSRegistry__factory,
Expand Down Expand Up @@ -74,6 +79,15 @@ describe('Sandbox', async () => {
});

describe('UNS', () => {
it('should mint all TLDs', async () => {
const unsTlds = Object.entries(TLD)
.filter(([, tldConfig]) => tldConfig.nameServices.includes(NameService.UNS));

for (const [, config] of unsTlds) {
expect(await unsRegistry.exists(config.hash)).to.be.true;
}
});

it('should mint a token', async () => {
const labels = [`${domainPrefix}-wallet-0`, 'wallet'];

Expand All @@ -100,13 +114,13 @@ describe('Sandbox', async () => {
const tx = await mintingManager.connect(minter).issueWithRecords(owner.address, labels, [], [], false);
await tx.wait();

const tokenId = await cnsRegistry.childIdOf(TLD.CRYPTO, domainPrefix);
const tokenId = await cnsRegistry.childIdOf(TLD.crypto.hash, domainPrefix);
expect(await cnsRegistry.ownerOf(tokenId)).to.be.eq(owner.address);
});

it('should migrate token from CNS to UNS', async () => {
const labels = [domainPrefix, 'crypto'];
const tokenId = await cnsRegistry.childIdOf(TLD.CRYPTO, domainPrefix);
const tokenId = await cnsRegistry.childIdOf(TLD.crypto.hash, domainPrefix);

const tx = await mintingManager.connect(minter).issueWithRecords(owner.address, labels, [], [], false);
await tx.wait();
Expand All @@ -128,7 +142,7 @@ describe('Sandbox', async () => {

it('should migrate token from CNS to UNS L2', async () => {
const labels = [domainPrefix, 'crypto'];
const tokenId = await cnsRegistry.childIdOf(TLD.CRYPTO, domainPrefix);
const tokenId = await cnsRegistry.childIdOf(TLD.crypto.hash, domainPrefix);

const tx = await mintingManager.connect(minter).issueWithRecords(owner.address, labels, [], [], false);
await tx.wait();
Expand All @@ -144,15 +158,15 @@ describe('Sandbox', async () => {
// Somehow error cannot be decoded automatically here, used try...catch
try {
await cnsRegistry.ownerOf.staticCall(tokenId);
assert.fail('Error is ecpected');
assert.fail('Error is expected');
} catch (error) {}
});

it('mints .zil token to ZilliqaRecover custody', async () => {
const tx = await zilliqaRecover.connect(minter).mint(domainPrefix, owner.address);
await tx.wait();

const tokenId = await cnsRegistry.childIdOf(TLD.ZIL, domainPrefix);
const tokenId = await cnsRegistry.childIdOf(TLD.zil.hash, domainPrefix);
expect(await unsRegistry.ownerOf(tokenId)).to.be.eq(await zilliqaRecover.getAddress());
expect(await zilliqaRecover.znsOwnerOf(tokenId)).to.be.eq(owner.address);
});
Expand Down
2 changes: 1 addition & 1 deletion sandbox/state.json

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions scripts/deploy_mint_tlds.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { network } from 'hardhat';

import { mergeNetworkConfig, getNetworkConfig } from '../src/config';
import { Deployer } from '../src/deployer';
import { unwrap } from '../src/utils';

async function main () {
console.log('Network:', network.name);

const chainId: number = unwrap(network.config, 'chainId');
const config = getNetworkConfig(chainId);
if (!config) {
throw new Error(`Config not found for network ${network.config.chainId}`);
}

const deployer = await Deployer.create();
const deployConfig = await deployer.execute(['min_uns_tlds'], config);
mergeNetworkConfig(deployConfig);

console.log('Deployed!');
}

main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});
45 changes: 43 additions & 2 deletions src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,17 @@
DeployProxyOptions,
UpgradeProxyOptions,
} from '@openzeppelin/hardhat-upgrades/dist/utils';
import type { BaseContract, ContractFactory } from 'ethers';
import { BaseContract, ContractFactory, ethers } from 'ethers';
import { network, upgrades } from 'hardhat';
import { DependenciesMap, ContractName, NsNetworkConfig } from './types';
import { MintingManager } from '../types';
import { NetworkChainIds, TLD, TLDConfig } from '../test/helpers/constants';
import { ContractName, DependenciesMap, NsNetworkConfig } from './types';
import { NameService } from './config';

export const isSandbox = network.config.chainId === 1337 || network.config.chainId === 31337;
roman-gnativ marked this conversation as resolved.
Show resolved Hide resolved
export const isTestnet = network.config.chainId === 80002 ||
network.config.chainId === 11155111 ||
network.config.chainId === 84532;

export const ensureDeployed = (config: NsNetworkConfig, ...contracts: ContractName[]): DependenciesMap => {
return contracts
Expand Down Expand Up @@ -55,3 +63,36 @@
export const getContractAddress = async (contract: BaseContract): Promise<string> => {
return contract.getAddress();
};

export const mintUnsTlds = async (mintingManager: MintingManager, owner: ethers.Signer) => {
const tlds = Object.entries(TLD)
.filter(([, config]) => config.nameServices.includes(NameService.UNS))
.filter(([, tldConfig]) => applyfilterTldsByChainId(tldConfig));

for (const [tldName, tldConfig] of tlds) {
const correctTldName = tldName.toLowerCase();
const mintTx = await mintingManager.connect(owner).addTld(correctTldName, tldConfig.expirable ?? false);
await mintTx.wait();
}
};

export function getExpirableTlds (): string[] {
return Object.entries(TLD)
.filter(([, tldConfig]) => tldConfig.expirable)
.filter(([, tldConfig]) => applyfilterTldsByChainId(tldConfig))
.map(([tld]) => tld);
}

function applyfilterTldsByChainId (tldConfig: TLDConfig): boolean {
roman-gnativ marked this conversation as resolved.
Show resolved Hide resolved
const chainId = network.config.chainId!;

Check warning on line 87 in src/helpers.ts

View workflow job for this annotation

GitHub Actions / lint

Forbidden non-null assertion
if (tldConfig.chainIds.length === 0) {
return false;
}
if (isSandbox) {
return true;
}

return tldConfig.chainIds
.flatMap((n) => NetworkChainIds[n])
.includes(chainId);
}
28 changes: 25 additions & 3 deletions src/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import { ArtifactName, DependenciesMap, EnsContractName, NsNetworkConfig, UnsContractName } from './types';
import verify from './verify';
import { notNullSha, unwrap, unwrapDependencies } from './utils';
import { deployProxy, ensureDeployed, ensureUpgradable } from './helpers';
import { deployProxy, ensureDeployed, ensureUpgradable, isSandbox, isTestnet, mintUnsTlds } from './helpers';

export type Task = {
tags: string[];
Expand All @@ -25,8 +25,6 @@
ensureDependencies: (ctx: Deployer, config?: NsNetworkConfig) => DependenciesMap;
};

const isSandbox = network.config.chainId === 1337;
const isTestnet = network.config.chainId === 80002 || network.config.chainId === 11155111;

export const deployCNSTask: Task = {
tags: ['cns', 'full'],
Expand Down Expand Up @@ -559,6 +557,29 @@
},
};

const mintUnsTldsTask: Task = {
tags: ['min_uns_tlds', 'uns', 'full'],
priority: 110,
run: async (ctx: Deployer, dependencies: DependenciesMap, params?: Record<string, string>) => {

Check warning on line 563 in src/tasks.ts

View workflow job for this annotation

GitHub Actions / lint

'dependencies' is defined but never used

Check warning on line 563 in src/tasks.ts

View workflow job for this annotation

GitHub Actions / lint

'params' is defined but never used
const { owner } = ctx.accounts;
if(!isSandbox){
throw new Error('This task is only available for sandbox');
}

const mintingManagerAddr = ctx.getNetworkConfig()
.networks[network.config.chainId!]

Check warning on line 570 in src/tasks.ts

View workflow job for this annotation

GitHub Actions / lint

Forbidden non-null assertion
.contracts[UnsContractName.MintingManager].address;

const mintingManager = await ethers.getContractAt(ArtifactName.MintingManager, mintingManagerAddr, owner);
await mintUnsTlds(mintingManager, owner);
},
ensureDependencies: (ctx: Deployer, config?: NsNetworkConfig) => {
config = merge(ctx.getDeployConfig(), config);

return ensureDeployed(config, UnsContractName.MintingManager);
},
};

const proposeUNSRegistryTask: Task = {
tags: ['propose_registry'],
priority: 110,
Expand Down Expand Up @@ -1205,4 +1226,5 @@
deploySeaportProxyBuyerTask,
deployUsdcMockTask,
fundSeaportProxyBuyerTask,
mintUnsTldsTask,
];
Loading
Loading