Skip to content

Commit 0a02499

Browse files
committed
undid some work, root registration and transfer works but transfer through registry still breaks subdomain registration
1 parent a7f3bb5 commit 0a02499

File tree

5 files changed

+36
-2
lines changed

5 files changed

+36
-2
lines changed

contracts/registrar/ZNSRootRegistrar.sol

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ contract ZNSRootRegistrar is
7373
}
7474

7575
function registerRootDomainBulk(
76+
address[] calldata owners, // for post registration, we transfer to actual owner
7677
string[] calldata names,
7778
address[] calldata domainAddresses,
7879
string [] calldata tokenURIs,
@@ -84,14 +85,20 @@ contract ZNSRootRegistrar is
8485
for (uint256 i = 0; i < names.length;) {
8586
// DistributionConfig memory distrConfig = DistributionConfig(IZNSPricer(address(0)), PaymentType.DIRECT, AccessType.OPEN);
8687
// PaymentConfig memory paymentConfig = PaymentConfig(IERC20(address(0)), address(0));
87-
registerRootDomain(
88+
bytes32 domainHash = registerRootDomain(
8889
names[i],
8990
domainAddresses[i],
9091
tokenURIs[i],
9192
emptyDistrConfig,
9293
emptyPaymentConfig
9394
);
9495

96+
// Transfer ERC721 to actual owner
97+
domainToken.transferFrom(msg.sender, owners[i], uint256(domainHash));
98+
99+
// This call breaks subdomain registration right now
100+
// registry.updateDomainOwnerForMigration(domainHash, owners[i]);
101+
95102
unchecked {
96103
++i;
97104
}

contracts/registry/IZNSRegistry.sol

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,11 @@ interface IZNSRegistry {
142142

143143
function updateDomainOwner(bytes32 domainHash, address owner) external;
144144

145+
function updateDomainOwnerForMigration(
146+
bytes32 domainHash,
147+
address owner
148+
) external;
149+
145150
function updateDomainResolver(
146151
bytes32 domainHash,
147152
string calldata resolverType

contracts/registry/ZNSRegistry.sol

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,14 @@ contract ZNSRegistry is AAccessControlled, UUPSUpgradeable, IZNSRegistry {
239239
_setDomainOwner(domainHash, owner);
240240
}
241241

242+
// TODO for remove after migration. This is to allow a no contact airdrop to users in migration
243+
function updateDomainOwnerForMigration(
244+
bytes32 domainHash,
245+
address owner
246+
) external override {
247+
_setDomainOwner(domainHash, owner);
248+
}
249+
242250
/**
243251
* @notice Updates the resolver of an existing domain in `records`.
244252
* Can be called by either the owner of the Name or an allowed operator.

src/utils/migration/02_register.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ const main = async () => {
6464
await zns.meowToken.connect(migrationAdmin).approve(await zns.treasury.getAddress(), hre.ethers.MaxUint256);
6565
}
6666

67+
await zns.domainToken.connect(migrationAdmin).setApprovalForAll(await zns.rootRegistrar.getAddress(), true);
68+
6769
// TODO fix, On real chain we wont use the mock that can simply mint tokens
6870
await zns.meowToken.connect(migrationAdmin).mint(migrationAdmin.address, hre.ethers.parseEther("99999999999999999999"));
6971

@@ -94,6 +96,9 @@ const main = async () => {
9496
start
9597
);
9698

99+
const tid = rootDomains[0].tokenId;
100+
const ownerBefore = await zns.domainToken.ownerOf(tid);
101+
97102
// ms -> s -> min
98103
const totalTime = (Date.now() - startTime) / 1000 / 60;
99104
console.log(`Registered ${registeredDomains.length + registeredSubdomains.length} groups of domains in ${totalTime} minutes`);

src/utils/migration/registration.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ export const registerBase = async ({
9393

9494
// console.log("DEBUG");
9595

96+
const owners = domains.map((domain) => { return domain.owner.id });
9697
const parentHashes = domains.map((domain) => { return domain.parentHash });
9798
const labels = domains.map((domain) => { return domain.label });
9899
const domainAddresses = domains.map((domain) => {return domain.address });
@@ -108,10 +109,16 @@ export const registerBase = async ({
108109
// We aren't setting configs intentionally.
109110
// console.log(`Registering ${domains.length} root domains...`);
110111
tx = await zns.rootRegistrar.connect(regAdmin).registerRootDomainBulk(
112+
owners,
111113
labels,
112114
domainAddresses,
113115
tokenURIs,
114-
distrConfigEmpty, // TODO what should this be? stake vs, direct should be upheld maybe?
116+
{
117+
pricerContract: hre.ethers.ZeroAddress,
118+
paymentType: 0n, // Direct
119+
accessType: 1n, // Open
120+
121+
}, // TODO what should this be? stake vs, direct should be upheld maybe?
115122
paymentConfigEmpty,
116123
// {
117124
// // TODO Debug, force the TX
@@ -171,6 +178,8 @@ export const registerBase = async ({
171178

172179
// console.log(`DOMAINHASHES: ${domainHashes.length}`);
173180

181+
// console.log(txReceipt.hash);
182+
174183
return { domainHashes, txHash: txReceipt.hash, retryData: undefined };
175184
};
176185

0 commit comments

Comments
 (0)