Skip to content

Commit

Permalink
Merge pull request #74 from DarkFlorist/rename-ENS_TOKEN_WRAPPER
Browse files Browse the repository at this point in the history
rename ENS_TOKEN_WRAPPER
  • Loading branch information
KillariDev authored Oct 24, 2024
2 parents aff6fe5 + 0500949 commit eb4c28c
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 65 deletions.
4 changes: 2 additions & 2 deletions app/ts/components/requirements.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { computed, Signal, useSignal } from '@preact/signals'
import { AccountAddress, CheckBoxes, EnsFuseName, FinalChildChecks, ParentChecks } from '../types/types.js'
import { ENS_TOKEN_WRAPPER } from '../utils/constants.js'
import { callPetalLock, deployPetalLockAndRenewalManager, getOpenRenewalManagerAddress, getRequiredFusesWithoutApproval, renewDomainByYear, renewDomainToMax } from '../utils/ensUtils.js'
import { isSameAddress } from '../utils/utilities.js'
import { OptionalSignal } from '../utils/OptionalSignal.js'
import { isValidContentHashString } from '../utils/contenthash.js'
import { Spinner } from './Spinner.js'
import { isAddress } from 'viem'
import { YearPicker } from './YearPicker.js'
import { ENS_NAME_WRAPPER } from '../utils/constants.js'

interface SwitchAddressProps {
maybeAccountAddress: OptionalSignal<AccountAddress>
Expand Down Expand Up @@ -220,7 +220,7 @@ export const Create = ( { contentHashInput, resolutionAddressInput, loadingInfos
const ownershipIssues = computed(() => {
const managerAndOwners = checkBoxes.deepValue?.filter((x) => x.exists && x.isWrapped).map((x) => [x.domainInfo.owner, x.domainInfo.manager])
if (managerAndOwners === undefined || managerAndOwners.length === 0) return undefined
const unique = Array.from(new Set(managerAndOwners.flat().flat().filter((address) => address !== ENS_TOKEN_WRAPPER)))
const unique = Array.from(new Set(managerAndOwners.flat().flat().filter((address) => address !== ENS_NAME_WRAPPER)))
if (unique.length <= 1) return undefined
return ` - The domain${ unique.length > 1 ? 's' : '' } need to be owned and managed by the same address. Currently they are managed by addresses: ${ unique.join(', ') }`
})
Expand Down
50 changes: 25 additions & 25 deletions app/ts/tests/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { extractENSFuses, getOpenRenewalManagerAddress, getPetalLockUseTransacti
import { petalLockContractArtifact } from '../VendoredPetalLock.js'
import { BlockCall, EthSimulateV1Result } from './ethSimulate-types.js'
import { jsonRpcRequest } from './ethSimulate.js'
import { ENS_ETH_REGISTRAR_CONTROLLER, ENS_PUBLIC_RESOLVER, ENS_TOKEN_WRAPPER, FINAL_CHILD_FUSES, MID_PARENT_FUSES, SINGLE_DOMAIN_FUSES, TOP_PARENT_FUSES } from '../utils/constants.js'
import { ENS_ETH_REGISTRAR_CONTROLLER, ENS_PUBLIC_RESOLVER, ENS_NAME_WRAPPER, FINAL_CHILD_FUSES, MID_PARENT_FUSES, SINGLE_DOMAIN_FUSES, TOP_PARENT_FUSES } from '../utils/constants.js'
import { ENS_WRAPPER_ABI } from '../abi/ens_wrapper_abi.js'
import { ENS_REGISTRAR_CONTROLLER_ABI } from '../abi/ens_registrar_controller_abi.js'
import { dataStringWith0xStart, splitDomainToSubDomainAndParent } from '../utils/utilities.js'
Expand Down Expand Up @@ -35,7 +35,7 @@ const makeImmutableDomain = (routenames: readonly string[], ownedTokens: readonl
)
return {
from: ownAddress,
to: BigInt(ENS_TOKEN_WRAPPER),
to: BigInt(ENS_NAME_WRAPPER),
input: stringToUint8Array(encodeFunctionData(tx))
}
}
Expand Down Expand Up @@ -73,7 +73,7 @@ const ethSimulateTransactions = async (rpc: string, transactions: readonly Block
const runTests = async () => {
console.log(`Reneval manager: ${ getOpenRenewalManagerAddress() }`)
const testOpenRenewalManagerAddressIsConstant = async () => {
const openRenewalManagerAddress = 0x2F2b2AA8E6Ba88A3E01eaCC031c8812E8Ea74718n
const openRenewalManagerAddress = 0x094f4b81679aaB4aD7538c2A4aB1343294864F6Fn
const calculatedAddress = BigInt(getOpenRenewalManagerAddress())
if (calculatedAddress !== openRenewalManagerAddress) throw new Error(`The Address of Open Renewal Manager has changed to ${ addressString(calculatedAddress) }.`)
}
Expand All @@ -88,7 +88,7 @@ const runTests = async () => {
makeImmutableDomain(subdomainRouteNames2, ownedTokens),
{
from: ownAddress,
to: BigInt(ENS_TOKEN_WRAPPER),
to: BigInt(ENS_NAME_WRAPPER),
input: stringToUint8Array(encodeFunctionData({
abi: ENS_WRAPPER_ABI,
functionName: 'balanceOf',
Expand Down Expand Up @@ -116,7 +116,7 @@ const runTests = async () => {
},
{
from: whale,
to: BigInt(ENS_TOKEN_WRAPPER),
to: BigInt(ENS_NAME_WRAPPER),
input: stringToUint8Array(encodeFunctionData({
abi: ENS_WRAPPER_ABI,
functionName: 'getData',
Expand All @@ -125,7 +125,7 @@ const runTests = async () => {
},
{
from: whale,
to: BigInt(ENS_TOKEN_WRAPPER),
to: BigInt(ENS_NAME_WRAPPER),
input: stringToUint8Array(encodeFunctionData({
abi: ENS_WRAPPER_ABI,
functionName: 'getData',
Expand All @@ -148,7 +148,7 @@ const runTests = async () => {
const ownedTokens = [BigInt(namehash(subdomainRouteNames2[0]))]
const result = await ethSimulateTransactions(rpc, [{
from: ownAddress,
to: BigInt(ENS_TOKEN_WRAPPER),
to: BigInt(ENS_NAME_WRAPPER),
input: stringToUint8Array(encodeFunctionData({
abi: ENS_WRAPPER_ABI,
functionName: 'safeBatchTransferFrom',
Expand All @@ -160,7 +160,7 @@ const runTests = async () => {
const testNoNonBatchTransfer = async () => {
const result = await ethSimulateTransactions(rpc, [{
from: ownAddress,
to: BigInt(ENS_TOKEN_WRAPPER),
to: BigInt(ENS_NAME_WRAPPER),
input: stringToUint8Array(encodeFunctionData({
abi: ENS_WRAPPER_ABI,
functionName: 'safeTransferFrom',
Expand All @@ -175,7 +175,7 @@ const runTests = async () => {
makeImmutableDomain(subdomainRouteNames3, ownedTokens),
{
from: whale,
to: BigInt(ENS_TOKEN_WRAPPER),
to: BigInt(ENS_NAME_WRAPPER),
input: stringToUint8Array(encodeFunctionData({
abi: ENS_WRAPPER_ABI,
functionName: 'getData',
Expand All @@ -184,7 +184,7 @@ const runTests = async () => {
},
{
from: whale,
to: BigInt(ENS_TOKEN_WRAPPER),
to: BigInt(ENS_NAME_WRAPPER),
input: stringToUint8Array(encodeFunctionData({
abi: ENS_WRAPPER_ABI,
functionName: 'getData',
Expand All @@ -193,7 +193,7 @@ const runTests = async () => {
},
{
from: whale,
to: BigInt(ENS_TOKEN_WRAPPER),
to: BigInt(ENS_NAME_WRAPPER),
input: stringToUint8Array(encodeFunctionData({
abi: ENS_WRAPPER_ABI,
functionName: 'getData',
Expand All @@ -202,7 +202,7 @@ const runTests = async () => {
},
{
from: ownAddress,
to: BigInt(ENS_TOKEN_WRAPPER),
to: BigInt(ENS_NAME_WRAPPER),
input: stringToUint8Array(encodeFunctionData({
abi: ENS_WRAPPER_ABI,
functionName: 'balanceOf',
Expand All @@ -211,7 +211,7 @@ const runTests = async () => {
},
{
from: ownAddress,
to: BigInt(ENS_TOKEN_WRAPPER),
to: BigInt(ENS_NAME_WRAPPER),
input: stringToUint8Array(encodeFunctionData({
abi: ENS_WRAPPER_ABI,
functionName: 'balanceOf',
Expand All @@ -220,7 +220,7 @@ const runTests = async () => {
},
{
from: ownAddress,
to: BigInt(ENS_TOKEN_WRAPPER),
to: BigInt(ENS_NAME_WRAPPER),
input: stringToUint8Array(encodeFunctionData({
abi: ENS_WRAPPER_ABI,
functionName: 'balanceOf',
Expand All @@ -229,7 +229,7 @@ const runTests = async () => {
},
{
from: ownAddress,
to: BigInt(ENS_TOKEN_WRAPPER),
to: BigInt(ENS_NAME_WRAPPER),
input: stringToUint8Array(encodeFunctionData({
abi: ENS_WRAPPER_ABI,
functionName: 'balanceOf',
Expand Down Expand Up @@ -339,7 +339,7 @@ const runTests = async () => {
makeImmutableDomain(subdomainRouteNames3_another, ownedTokens3_another),
{
from: whale,
to: BigInt(ENS_TOKEN_WRAPPER),
to: BigInt(ENS_NAME_WRAPPER),
input: stringToUint8Array(encodeFunctionData({
abi: ENS_WRAPPER_ABI,
functionName: 'getData',
Expand All @@ -348,7 +348,7 @@ const runTests = async () => {
},
{
from: ownAddress,
to: BigInt(ENS_TOKEN_WRAPPER),
to: BigInt(ENS_NAME_WRAPPER),
input: stringToUint8Array(encodeFunctionData({
abi: ENS_WRAPPER_ABI,
functionName: 'balanceOf',
Expand Down Expand Up @@ -396,7 +396,7 @@ const runTests = async () => {
makeImmutableDomain(subdomainRouteNames3, ownedTokens),
{
from: whale,
to: BigInt(ENS_TOKEN_WRAPPER),
to: BigInt(ENS_NAME_WRAPPER),
input: stringToUint8Array(encodeFunctionData({
abi: ENS_WRAPPER_ABI,
functionName: 'getApproved',
Expand All @@ -405,7 +405,7 @@ const runTests = async () => {
},
{
from: whale,
to: BigInt(ENS_TOKEN_WRAPPER),
to: BigInt(ENS_NAME_WRAPPER),
input: stringToUint8Array(encodeFunctionData({
abi: ENS_WRAPPER_ABI,
functionName: 'getApproved',
Expand All @@ -414,7 +414,7 @@ const runTests = async () => {
},
{
from: whale,
to: BigInt(ENS_TOKEN_WRAPPER),
to: BigInt(ENS_NAME_WRAPPER),
input: stringToUint8Array(encodeFunctionData({
abi: ENS_WRAPPER_ABI,
functionName: 'getApproved',
Expand Down Expand Up @@ -499,7 +499,7 @@ const runTests = async () => {
},
{
from: whale,
to: BigInt(ENS_TOKEN_WRAPPER),
to: BigInt(ENS_NAME_WRAPPER),
input: stringToUint8Array(encodeFunctionData({
abi: ENS_WRAPPER_ABI,
functionName: 'getData',
Expand All @@ -508,7 +508,7 @@ const runTests = async () => {
},
{
from: ownAddress,
to: BigInt(ENS_TOKEN_WRAPPER),
to: BigInt(ENS_NAME_WRAPPER),
input: stringToUint8Array(encodeFunctionData({
abi: ENS_WRAPPER_ABI,
functionName: 'balanceOf',
Expand Down Expand Up @@ -538,7 +538,7 @@ const runTests = async () => {
makeImmutableDomain([subdomainRouteNames3[0]], ownedTokens),
{
from: whale,
to: BigInt(ENS_TOKEN_WRAPPER),
to: BigInt(ENS_NAME_WRAPPER),
input: stringToUint8Array(encodeFunctionData({
abi: ENS_WRAPPER_ABI,
functionName: 'getData',
Expand All @@ -557,7 +557,7 @@ const runTests = async () => {
},
{
from: whale,
to: BigInt(ENS_TOKEN_WRAPPER),
to: BigInt(ENS_NAME_WRAPPER),
input: stringToUint8Array(encodeFunctionData({
abi: ENS_WRAPPER_ABI,
functionName: 'getData',
Expand Down Expand Up @@ -607,7 +607,7 @@ const runTests = async () => {
)
const result = await ethSimulateTransactions(rpc, [{
from: ownAddress,
to: BigInt(ENS_TOKEN_WRAPPER),
to: BigInt(ENS_NAME_WRAPPER),
input: stringToUint8Array(encodeFunctionData(tx))
}])
if (allSuccess(result)) throw new Error('transaction succeeded while it should fail')
Expand Down
2 changes: 1 addition & 1 deletion app/ts/utils/constants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const MOCK_ADDRESS = '0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef'
export const ENS_PUBLIC_RESOLVER = '0x231b0Ee14048e9dCcD1d247744d114a4EB5E8E63'
export const ENS_TOKEN_WRAPPER = '0xD4416b13d2b3a9aBae7AcD5D6C2BbDBE25686401'
export const ENS_NAME_WRAPPER = '0xD4416b13d2b3a9aBae7AcD5D6C2BbDBE25686401'
export const ENS_ETH_REGISTRAR_CONTROLLER = '0x253553366Da8546fC250F225fe3d25d0C782303b'
export const ENS_ETHEREUM_NAME_SERVICE = '0x57f1887a8BF19b14fC0dF6Fd9B2acc9Af147eA85'
export const ENS_PUBLIC_RESOLVER_2 = '0x4976fb03C32e5B8cfe2b6cCB31c09Ba78EBaBa41'
Expand Down
12 changes: 6 additions & 6 deletions app/ts/utils/ensUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'viem/window'
import { ENS_REGISTRY_ABI } from '../abi/ens_registry_abi.js'
import { bigIntToNumber, splitDomainToSubDomainAndParent, splitEnsStringToSubdomainPath } from './utilities.js'
import { ENS_PUBLIC_RESOLVER_ABI } from '../abi/ens_public_resolver_abi.js'
import { CAN_DO_EVERYTHING, ENS_ETH_REGISTRAR_CONTROLLER, ENS_ETHEREUM_NAME_SERVICE, ENS_FLAGS, ENS_PUBLIC_RESOLVER, ENS_REGISTRY_WITH_FALLBACK, ENS_TOKEN_WRAPPER, FINAL_CHILD_FUSES, MID_PARENT_FUSES, SINGLE_DOMAIN_FUSES, TOP_PARENT_FUSES } from './constants.js'
import { CAN_DO_EVERYTHING, ENS_ETH_REGISTRAR_CONTROLLER, ENS_ETHEREUM_NAME_SERVICE, ENS_FLAGS, ENS_PUBLIC_RESOLVER, ENS_REGISTRY_WITH_FALLBACK, ENS_NAME_WRAPPER, FINAL_CHILD_FUSES, MID_PARENT_FUSES, SINGLE_DOMAIN_FUSES, TOP_PARENT_FUSES } from './constants.js'
import { AccountAddress, DomainInfo, EnsFuseName } from '../types/types.js'
import { ENS_ETHEREUM_NAME_SERVICE_ABI } from '../abi/ens_ethereum_name_service_abi.js'
import { tryEncodeContentHash } from './contenthash.js'
Expand Down Expand Up @@ -67,21 +67,21 @@ export const getChainId = async (accountAddress: AccountAddress) => {
const getDomainInfo = async (accountAddress: AccountAddress | undefined, nameHash: `0x${ string }`, label: string, parentDomain: string, token: `0x${ string }`, subDomain: string): Promise<DomainInfo> => {
const client = createReadClient(accountAddress)
const isWrappedPromise = client.readContract({
address: ENS_TOKEN_WRAPPER,
address: ENS_NAME_WRAPPER,
abi: ENS_WRAPPER_ABI,
functionName: 'isWrapped',
args: [nameHash]
})

const ownerPromise = client.readContract({
address: ENS_TOKEN_WRAPPER,
address: ENS_NAME_WRAPPER,
abi: ENS_WRAPPER_ABI,
functionName: 'ownerOf',
args: [BigInt(nameHash)]
})

const dataPromise = client.readContract({
address: ENS_TOKEN_WRAPPER,
address: ENS_NAME_WRAPPER,
abi: ENS_WRAPPER_ABI,
functionName: 'getData',
args: [BigInt(nameHash)]
Expand Down Expand Up @@ -132,7 +132,7 @@ const getDomainInfo = async (accountAddress: AccountAddress | undefined, nameHas
})

const approvedPromise = client.readContract({
address: ENS_TOKEN_WRAPPER,
address: ENS_NAME_WRAPPER,
abi: ENS_WRAPPER_ABI,
functionName: 'getApproved',
args: [BigInt(nameHash)]
Expand Down Expand Up @@ -302,7 +302,7 @@ export const getPetalLockUseTransaction = (petalLockAddress: AccountAddress, acc
return {
chain: mainnet,
account: accountAddress,
address: ENS_TOKEN_WRAPPER,
address: ENS_NAME_WRAPPER,
abi: ENS_WRAPPER_ABI,
functionName: 'safeBatchTransferFrom',
args: [accountAddress, petalLockAddress, ownedTokens, ownedTokens.map(() => 1n), data]
Expand Down
8 changes: 4 additions & 4 deletions solidity/contracts/OpenRenewalManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ interface IENS {
function owner(bytes32 node) external view returns (address);
}

address constant ENS_TOKEN_WRAPPER = 0xD4416b13d2b3a9aBae7AcD5D6C2BbDBE25686401;
address constant ENS_NAME_WRAPPER = 0xD4416b13d2b3a9aBae7AcD5D6C2BbDBE25686401;

contract OpenRenewalManager {
function extendExpiry(bytes32 parentNode, bytes32 labelhash, uint64 expiry) external returns (uint64) {
return INameWrapper(ENS_TOKEN_WRAPPER).extendExpiry(parentNode, labelhash, expiry);
return INameWrapper(ENS_NAME_WRAPPER).extendExpiry(parentNode, labelhash, expiry);
}
function onERC1155Received(address, address, uint256, uint256, bytes memory) external view returns (bytes4) {
require(msg.sender == ENS_TOKEN_WRAPPER, 'OpenRenewalManager: Only Wrapped ENS tokens are supported');
require(msg.sender == ENS_NAME_WRAPPER, 'OpenRenewalManager: Only Wrapped ENS names are supported');
return this.onERC1155Received.selector;
}

// when receiving wrapped ens tokens, make the last child immutable
function onERC1155BatchReceived(address, address, uint256[] memory, uint256[] memory, bytes memory) external view returns (bytes4) {
require(msg.sender == ENS_TOKEN_WRAPPER, 'OpenRenewalManager: Only Wrapped ENS tokens are supported');
require(msg.sender == ENS_NAME_WRAPPER, 'OpenRenewalManager: Only Wrapped ENS names are supported');
return this.onERC1155BatchReceived.selector;
}
}
Loading

0 comments on commit eb4c28c

Please sign in to comment.