Skip to content

Commit

Permalink
Ens custody migration
Browse files Browse the repository at this point in the history
  • Loading branch information
DancingAxolotl committed Oct 7, 2024
1 parent 4667db2 commit 41bbbc7
Show file tree
Hide file tree
Showing 12 changed files with 340 additions and 125 deletions.
85 changes: 57 additions & 28 deletions artifacts/ENSCustody.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion artifacts/abi/ENSCustody.json

Large diffs are not rendered by default.

41 changes: 24 additions & 17 deletions contracts/custody/ENSCustody.sol
Original file line number Diff line number Diff line change
Expand Up @@ -217,31 +217,38 @@ contract ENSCustody is
}

function safeTransfer(address to, uint256 tokenId) external onlyTokenOwner(tokenId) {
this.safeTransfer(to, tokenId, false);
_protectTokenOperation(tokenId);
StorageSlotUpgradeable.getAddressSlot(keccak256(abi.encodePacked(_OWNER_PREFIX_SLOT, tokenId))).value = address(0);
INameWrapper _wrapper = INameWrapper(StorageSlotUpgradeable.getAddressSlot(_ENS_WRAPPER_SLOT).value);
_wrapper.safeTransferFrom(address(this), to, tokenId, 1, '');
}

function safeTransfer(address to, uint256 tokenId, bool internalTransfer) external onlyTokenOwner(tokenId) {
receive() external payable {}

function parkingTransfer(address to, uint256 tokenId) external onlyTokenOwner(tokenId) {
_protectTokenOperation(tokenId);
if (internalTransfer) {
_park(tokenId, to);
} else {
StorageSlotUpgradeable.getAddressSlot(keccak256(abi.encodePacked(_OWNER_PREFIX_SLOT, tokenId))).value = address(0);
_park(tokenId, to);
}

INameWrapper _wrapper = INameWrapper(StorageSlotUpgradeable.getAddressSlot(_ENS_WRAPPER_SLOT).value);
_wrapper.safeTransferFrom(address(this), to, tokenId, 1, '');
}
struct ExecuteData {
ForwardRequest req;
bytes signature;
}

receive() external payable {}
function multicallExecute(ExecuteData[] calldata data) public returns (bytes[] memory results) {
require(!isTrustedForwarder(msg.sender), 'meta transactions are not allowed');

function multicall(bytes[] calldata data) public returns (bytes[] memory results) {
bytes[] memory _data = data;
if (isTrustedForwarder(msg.sender)) {
for (uint256 i = 0; i < data.length; i++) {
_data[i] = _buildData(_msgSender(), _msgToken(), data[i], '');
}
for (uint256 i = 0; i < data.length; i++) {
ExecuteData calldata d = data[i];
bytes4 sig = abi.decode(d.req.data[:4], (bytes4));
require(sig == this.parkingTransfer.selector, 'only parkingTransfer is allowed');
}

results = new bytes[](data.length);
for (uint256 i = 0; i < data.length; i++) {
results[i] = execute(data[i].req, data[i].signature);
}
return _multicall(_data);
return results;
}

function _register(
Expand Down
1 change: 0 additions & 1 deletion contracts/utils/Multicall.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import '@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol';
abstract contract Multicall {
/**
* @dev Receives and executes a batch of function calls on this contract.
* @custom:oz-upgrades-unsafe-allow-reachable delegatecall
*/
function _multicall(bytes[] memory data) internal returns (bytes[] memory results) {
results = new bytes[](data.length);
Expand Down
2 changes: 1 addition & 1 deletion dist/sandbox/state.json

Large diffs are not rendered by default.

69 changes: 44 additions & 25 deletions dist/types/contracts/custody/ENSCustody.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,21 @@ export declare namespace IForwarder {
data: string;
};
}
export declare namespace ENSCustody {
type ExecuteDataStruct = {
req: IForwarder.ForwardRequestStruct;
signature: BytesLike;
};
type ExecuteDataStructOutput = [
req: IForwarder.ForwardRequestStructOutput,
signature: string
] & {
req: IForwarder.ForwardRequestStructOutput;
signature: string;
};
}
export interface ENSCustodyInterface extends Interface {
getFunction(nameOrSignature: "DEFAULT_ADMIN_ROLE" | "MINTER_ROLE" | "NAME" | "VERSION" | "addMinter" | "addMinters" | "closeMinter" | "commit" | "execute" | "getRoleAdmin" | "grantRole" | "hasRole" | "initialize" | "isMinter" | "isTrustedForwarder" | "makeCommitment" | "multicall" | "nonceOf" | "onERC1155BatchReceived" | "onERC1155Received" | "onERC721Received" | "owner" | "ownerOf" | "register" | "removeMinter" | "removeMinters" | "renew" | "renounceMinter" | "renounceOwnership" | "renounceRole" | "rentPrice" | "revokeRole" | "rotateMinter" | "safeTransfer(address,uint256,bool)" | "safeTransfer(address,uint256)" | "setBaseRegistrar" | "supportsInterface" | "transferOwnership" | "verify"): FunctionFragment;
getFunction(nameOrSignature: "DEFAULT_ADMIN_ROLE" | "MINTER_ROLE" | "NAME" | "VERSION" | "addMinter" | "addMinters" | "closeMinter" | "commit" | "execute" | "getRoleAdmin" | "grantRole" | "hasRole" | "initialize" | "isMinter" | "isTrustedForwarder" | "makeCommitment" | "multicallExecute" | "nonceOf" | "onERC1155BatchReceived" | "onERC1155Received" | "onERC721Received" | "owner" | "ownerOf" | "parkingTransfer" | "register" | "removeMinter" | "removeMinters" | "renew" | "renounceMinter" | "renounceOwnership" | "renounceRole" | "rentPrice" | "revokeRole" | "rotateMinter" | "safeTransfer" | "setBaseRegistrar" | "supportsInterface" | "transferOwnership" | "verify"): FunctionFragment;
getEvent(nameOrSignatureOrTopic: "Initialized" | "OwnershipTransferred" | "Parked" | "RoleAdminChanged" | "RoleGranted" | "RoleRevoked"): EventFragment;
encodeFunctionData(functionFragment: "DEFAULT_ADMIN_ROLE", values?: undefined): string;
encodeFunctionData(functionFragment: "MINTER_ROLE", values?: undefined): string;
Expand Down Expand Up @@ -48,7 +61,7 @@ export interface ENSCustodyInterface extends Interface {
BigNumberish,
boolean
]): string;
encodeFunctionData(functionFragment: "multicall", values: [BytesLike[]]): string;
encodeFunctionData(functionFragment: "multicallExecute", values: [ENSCustody.ExecuteDataStruct[]]): string;
encodeFunctionData(functionFragment: "nonceOf", values: [BigNumberish]): string;
encodeFunctionData(functionFragment: "onERC1155BatchReceived", values: [
AddressLike,
Expand All @@ -61,6 +74,7 @@ export interface ENSCustodyInterface extends Interface {
encodeFunctionData(functionFragment: "onERC721Received", values: [AddressLike, AddressLike, BigNumberish, BytesLike]): string;
encodeFunctionData(functionFragment: "owner", values?: undefined): string;
encodeFunctionData(functionFragment: "ownerOf", values: [BigNumberish]): string;
encodeFunctionData(functionFragment: "parkingTransfer", values: [AddressLike, BigNumberish]): string;
encodeFunctionData(functionFragment: "register", values: [
string,
AddressLike,
Expand All @@ -81,8 +95,7 @@ export interface ENSCustodyInterface extends Interface {
encodeFunctionData(functionFragment: "rentPrice", values: [string, BigNumberish]): string;
encodeFunctionData(functionFragment: "revokeRole", values: [BytesLike, AddressLike]): string;
encodeFunctionData(functionFragment: "rotateMinter", values: [AddressLike]): string;
encodeFunctionData(functionFragment: "safeTransfer(address,uint256,bool)", values: [AddressLike, BigNumberish, boolean]): string;
encodeFunctionData(functionFragment: "safeTransfer(address,uint256)", values: [AddressLike, BigNumberish]): string;
encodeFunctionData(functionFragment: "safeTransfer", values: [AddressLike, BigNumberish]): string;
encodeFunctionData(functionFragment: "setBaseRegistrar", values: [AddressLike]): string;
encodeFunctionData(functionFragment: "supportsInterface", values: [BytesLike]): string;
encodeFunctionData(functionFragment: "transferOwnership", values: [AddressLike]): string;
Expand All @@ -103,13 +116,14 @@ export interface ENSCustodyInterface extends Interface {
decodeFunctionResult(functionFragment: "isMinter", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "isTrustedForwarder", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "makeCommitment", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "multicall", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "multicallExecute", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "nonceOf", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "onERC1155BatchReceived", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "onERC1155Received", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "onERC721Received", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "owner", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "ownerOf", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "parkingTransfer", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "register", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "removeMinter", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "removeMinters", data: BytesLike): Result;
Expand All @@ -120,8 +134,7 @@ export interface ENSCustodyInterface extends Interface {
decodeFunctionResult(functionFragment: "rentPrice", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "revokeRole", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "rotateMinter", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "safeTransfer(address,uint256,bool)", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "safeTransfer(address,uint256)", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "safeTransfer", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "setBaseRegistrar", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "supportsInterface", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "transferOwnership", data: BytesLike): Result;
Expand Down Expand Up @@ -287,7 +300,11 @@ export interface ENSCustody extends BaseContract {
], [
string
], "view">;
multicall: TypedContractMethod<[data: BytesLike[]], [string[]], "nonpayable">;
multicallExecute: TypedContractMethod<[
data: ENSCustody.ExecuteDataStruct[]
], [
string[]
], "nonpayable">;
nonceOf: TypedContractMethod<[tokenId: BigNumberish], [bigint], "view">;
onERC1155BatchReceived: TypedContractMethod<[
arg0: AddressLike,
Expand Down Expand Up @@ -317,6 +334,12 @@ export interface ENSCustody extends BaseContract {
], "nonpayable">;
owner: TypedContractMethod<[], [string], "view">;
ownerOf: TypedContractMethod<[tokenId: BigNumberish], [string], "view">;
parkingTransfer: TypedContractMethod<[
to: AddressLike,
tokenId: BigNumberish
], [
void
], "nonpayable">;
register: TypedContractMethod<[
name: string,
owner: AddressLike,
Expand Down Expand Up @@ -367,14 +390,7 @@ export interface ENSCustody extends BaseContract {
void
], "nonpayable">;
rotateMinter: TypedContractMethod<[receiver: AddressLike], [void], "payable">;
"safeTransfer(address,uint256,bool)": TypedContractMethod<[
to: AddressLike,
tokenId: BigNumberish,
internalTransfer: boolean
], [
void
], "nonpayable">;
"safeTransfer(address,uint256)": TypedContractMethod<[
safeTransfer: TypedContractMethod<[
to: AddressLike,
tokenId: BigNumberish
], [
Expand Down Expand Up @@ -451,7 +467,11 @@ export interface ENSCustody extends BaseContract {
], [
string
], "view">;
getFunction(nameOrSignature: "multicall"): TypedContractMethod<[data: BytesLike[]], [string[]], "nonpayable">;
getFunction(nameOrSignature: "multicallExecute"): TypedContractMethod<[
data: ENSCustody.ExecuteDataStruct[]
], [
string[]
], "nonpayable">;
getFunction(nameOrSignature: "nonceOf"): TypedContractMethod<[tokenId: BigNumberish], [bigint], "view">;
getFunction(nameOrSignature: "onERC1155BatchReceived"): TypedContractMethod<[
arg0: AddressLike,
Expand Down Expand Up @@ -481,6 +501,12 @@ export interface ENSCustody extends BaseContract {
], "nonpayable">;
getFunction(nameOrSignature: "owner"): TypedContractMethod<[], [string], "view">;
getFunction(nameOrSignature: "ownerOf"): TypedContractMethod<[tokenId: BigNumberish], [string], "view">;
getFunction(nameOrSignature: "parkingTransfer"): TypedContractMethod<[
to: AddressLike,
tokenId: BigNumberish
], [
void
], "nonpayable">;
getFunction(nameOrSignature: "register"): TypedContractMethod<[
name: string,
owner: AddressLike,
Expand Down Expand Up @@ -523,14 +549,7 @@ export interface ENSCustody extends BaseContract {
void
], "nonpayable">;
getFunction(nameOrSignature: "rotateMinter"): TypedContractMethod<[receiver: AddressLike], [void], "payable">;
getFunction(nameOrSignature: "safeTransfer(address,uint256,bool)"): TypedContractMethod<[
to: AddressLike,
tokenId: BigNumberish,
internalTransfer: boolean
], [
void
], "nonpayable">;
getFunction(nameOrSignature: "safeTransfer(address,uint256)"): TypedContractMethod<[
getFunction(nameOrSignature: "safeTransfer"): TypedContractMethod<[
to: AddressLike,
tokenId: BigNumberish
], [
Expand Down
2 changes: 1 addition & 1 deletion dist/types/contracts/custody/ENSCustody.d.ts.map

Large diffs are not rendered by default.

66 changes: 44 additions & 22 deletions dist/types/factories/contracts/custody/ENSCustody__factory.d.ts

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

83 changes: 56 additions & 27 deletions dist/types/factories/contracts/custody/ENSCustody__factory.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion sandbox/state.json

Large diffs are not rendered by default.

Loading

0 comments on commit 41bbbc7

Please sign in to comment.