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

Initial revision of MigrationHelper #387

Open
wants to merge 3 commits into
base: staging
Choose a base branch
from
Open
Changes from 1 commit
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
58 changes: 58 additions & 0 deletions contracts/utils/MigrationHelper.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
//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;

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 owner,
uint256[] memory tokenIds,
bytes memory data
) external onlyController {
for (uint256 i = 0; i < tokenIds.length; i++) {
registrar.safeTransferFrom(
owner,
Copy link
Member

Choose a reason for hiding this comment

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

Is the owner the owner of this contract (aka DAO) or the actual name owner? If the latter, you may want to change to nameowner or something as onlyOwner at setMigrationTarget and owner here have different semantics.

Copy link
Member

Choose a reason for hiding this comment

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

Looks like it's the actual name owner, because the owner of the name is what you need to transfer it

Copy link
Member Author

Choose a reason for hiding this comment

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

owner in this context is the owner of the name, yes. It's passed in as a function parameter.

migrationTarget,
tokenIds[i],
data
);
}
}

function migrateWrappedNames(
address owner,
uint256[] memory tokenIds,
bytes memory data
) external onlyController {
uint256[] memory amounts = new uint256[](tokenIds.length);
for (uint256 i = 0; i < amounts.length; i++) {
amounts[i] = 1;
}
wrapper.safeBatchTransferFrom(
owner,
migrationTarget,
tokenIds,
amounts,
data
);
}
}
Loading