-
Notifications
You must be signed in to change notification settings - Fork 414
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'staging' into fix/refactor-wrapped-callback
- Loading branch information
Showing
9 changed files
with
426 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
//SPDX-License-Identifier: MIT | ||
pragma solidity >=0.8.4; | ||
|
||
import {IBaseRegistrar} from "../ethregistrar/IBaseRegistrar.sol"; | ||
import {INameWrapper} from "../wrapper/INameWrapper.sol"; | ||
import {Controllable} from "../wrapper/Controllable.sol"; | ||
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; | ||
|
||
contract MigrationHelper is Ownable, Controllable { | ||
IBaseRegistrar public immutable registrar; | ||
INameWrapper public immutable wrapper; | ||
address public migrationTarget; | ||
|
||
error MigrationTargetNotSet(); | ||
|
||
event MigrationTargetUpdated(address indexed target); | ||
|
||
constructor(IBaseRegistrar _registrar, INameWrapper _wrapper) { | ||
registrar = _registrar; | ||
wrapper = _wrapper; | ||
} | ||
|
||
function setMigrationTarget(address target) external onlyOwner { | ||
migrationTarget = target; | ||
emit MigrationTargetUpdated(target); | ||
} | ||
|
||
function migrateNames( | ||
address nameOwner, | ||
uint256[] memory tokenIds, | ||
bytes memory data | ||
) external onlyController { | ||
if (migrationTarget == address(0)) { | ||
revert MigrationTargetNotSet(); | ||
} | ||
|
||
for (uint256 i = 0; i < tokenIds.length; i++) { | ||
registrar.safeTransferFrom( | ||
nameOwner, | ||
migrationTarget, | ||
tokenIds[i], | ||
data | ||
); | ||
} | ||
} | ||
|
||
function migrateWrappedNames( | ||
address nameOwner, | ||
uint256[] memory tokenIds, | ||
bytes memory data | ||
) external onlyController { | ||
if (migrationTarget == address(0)) { | ||
revert MigrationTargetNotSet(); | ||
} | ||
|
||
uint256[] memory amounts = new uint256[](tokenIds.length); | ||
for (uint256 i = 0; i < amounts.length; i++) { | ||
amounts[i] = 1; | ||
} | ||
wrapper.safeBatchTransferFrom( | ||
nameOwner, | ||
migrationTarget, | ||
tokenIds, | ||
amounts, | ||
data | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import type { DeployFunction } from 'hardhat-deploy/types.js' | ||
|
||
const func: DeployFunction = async function (hre) { | ||
const { deployments, viem } = hre | ||
const { deploy } = deployments | ||
|
||
const { deployer, owner } = await viem.getNamedClients() | ||
|
||
const registrar = await viem.getContract('BaseRegistrarImplementation') | ||
const wrapper = await viem.getContract('NameWrapper') | ||
|
||
await viem.deploy('MigrationHelper', [registrar.address, wrapper.address]) | ||
|
||
if (owner !== undefined && owner.address !== deployer.address) { | ||
const migrationHelper = await viem.getContract('MigrationHelper') | ||
const hash = await migrationHelper.write.transferOwnership([owner.address]) | ||
console.log(`Transfer ownership to ${owner.address} (tx: ${hash})...`) | ||
await viem.waitForTransactionSuccess(hash) | ||
} | ||
} | ||
|
||
func.id = 'migration-helper' | ||
func.tags = ['utils', 'MigrationHelper'] | ||
func.dependencies = ['BaseRegistrarImplementation', 'NameWrapper'] | ||
|
||
export default func |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.