From 13545a29687e42d837119e719bdd15d4e955a95b Mon Sep 17 00:00:00 2001 From: Julink Date: Tue, 30 Jul 2024 18:20:44 +0200 Subject: [PATCH 1/2] fix: unwrapping and wrapping names to use correct functions --- .../TransactionDialogManager/stage/Intro.tsx | 3 +- .../src/ensJsOverrides/contracts/erc1155.ts | 30 ++ .../src/ensJsOverrides/contracts/erc721.ts | 69 ++++ .../ensJsOverrides/contracts/nameWrapper.ts | 387 ++++++++++++++++++ .../src/ensJsOverrides/unwrapName.ts | 170 ++++++++ .../utils/makeLabelNodeAndParent.ts | 14 + .../src/ensJsOverrides/wrapName.ts | 190 +++++++++ .../src/transaction-flow/intro/WrapName.tsx | 3 +- .../transaction/unwrapName.ts | 7 +- .../transaction-flow/transaction/wrapName.ts | 3 +- 10 files changed, 867 insertions(+), 9 deletions(-) create mode 100644 packages/linea-ens-app/src/ensJsOverrides/contracts/erc1155.ts create mode 100644 packages/linea-ens-app/src/ensJsOverrides/contracts/erc721.ts create mode 100644 packages/linea-ens-app/src/ensJsOverrides/contracts/nameWrapper.ts create mode 100644 packages/linea-ens-app/src/ensJsOverrides/unwrapName.ts create mode 100644 packages/linea-ens-app/src/ensJsOverrides/utils/makeLabelNodeAndParent.ts create mode 100644 packages/linea-ens-app/src/ensJsOverrides/wrapName.ts diff --git a/packages/linea-ens-app/src/components/@molecules/TransactionDialogManager/stage/Intro.tsx b/packages/linea-ens-app/src/components/@molecules/TransactionDialogManager/stage/Intro.tsx index 48a4f0e75..91f0a4721 100644 --- a/packages/linea-ens-app/src/components/@molecules/TransactionDialogManager/stage/Intro.tsx +++ b/packages/linea-ens-app/src/components/@molecules/TransactionDialogManager/stage/Intro.tsx @@ -4,6 +4,7 @@ import { useTheme } from 'styled-components' import { Button, Dialog } from '@ensdomains/thorin' import { InnerDialog } from '@app/components/@atoms/InnerDialog' +import { DialogHeading } from '@app/components/styled/Dialog' import { intros } from '@app/transaction-flow/intro' import { TransactionIntro } from '@app/transaction-flow/types' import { TransactionDisplayItemSingle } from '@app/types' @@ -63,7 +64,7 @@ export const IntroStageModal = ({ return ( <> - + {t(...title)} {txCount > 1 && ( diff --git a/packages/linea-ens-app/src/ensJsOverrides/contracts/erc1155.ts b/packages/linea-ens-app/src/ensJsOverrides/contracts/erc1155.ts new file mode 100644 index 000000000..45c5ba71d --- /dev/null +++ b/packages/linea-ens-app/src/ensJsOverrides/contracts/erc1155.ts @@ -0,0 +1,30 @@ +export const erc1155SafeTransferFromSnippet = [ + { + inputs: [ + { + name: 'from', + type: 'address', + }, + { + name: 'to', + type: 'address', + }, + { + name: 'id', + type: 'uint256', + }, + { + name: 'amount', + type: 'uint256', + }, + { + name: 'data', + type: 'bytes', + }, + ], + name: 'safeTransferFrom', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, +] as const diff --git a/packages/linea-ens-app/src/ensJsOverrides/contracts/erc721.ts b/packages/linea-ens-app/src/ensJsOverrides/contracts/erc721.ts new file mode 100644 index 000000000..43ad8ab11 --- /dev/null +++ b/packages/linea-ens-app/src/ensJsOverrides/contracts/erc721.ts @@ -0,0 +1,69 @@ +export const erc721OwnerOfSnippet = [ + { + inputs: [ + { + name: 'id', + type: 'uint256', + }, + ], + name: 'ownerOf', + outputs: [ + { + name: 'owner', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, +] as const + +export const erc721SafeTransferFromSnippet = [ + { + inputs: [ + { + name: 'from', + type: 'address', + }, + { + name: 'to', + type: 'address', + }, + { + name: 'tokenId', + type: 'uint256', + }, + ], + name: 'safeTransferFrom', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, +] as const + +export const erc721SafeTransferFromWithDataSnippet = [ + { + inputs: [ + { + name: 'from', + type: 'address', + }, + { + name: 'to', + type: 'address', + }, + { + name: 'tokenId', + type: 'uint256', + }, + { + name: '_data', + type: 'bytes', + }, + ], + name: 'safeTransferFrom', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, +] as const diff --git a/packages/linea-ens-app/src/ensJsOverrides/contracts/nameWrapper.ts b/packages/linea-ens-app/src/ensJsOverrides/contracts/nameWrapper.ts new file mode 100644 index 000000000..f521c7b27 --- /dev/null +++ b/packages/linea-ens-app/src/ensJsOverrides/contracts/nameWrapper.ts @@ -0,0 +1,387 @@ +import { registrySetResolverSnippet } from '@ensdomains/ensjs/contracts' + +import { erc721OwnerOfSnippet } from './erc721' +import { erc1155SafeTransferFromSnippet } from './erc1155' + +export const nameWrapperErrors = [ + { + inputs: [], + name: 'CannotUpgrade', + type: 'error', + }, + { + inputs: [], + name: 'IncompatibleParent', + type: 'error', + }, + { + inputs: [ + { + name: 'owner', + type: 'address', + }, + ], + name: 'IncorrectTargetOwner', + type: 'error', + }, + { + inputs: [], + name: 'IncorrectTokenType', + type: 'error', + }, + { + inputs: [ + { + name: 'labelHash', + type: 'bytes32', + }, + { + name: 'expectedLabelhash', + type: 'bytes32', + }, + ], + name: 'LabelMismatch', + type: 'error', + }, + { + inputs: [ + { + name: 'label', + type: 'string', + }, + ], + name: 'LabelTooLong', + type: 'error', + }, + { + inputs: [], + name: 'LabelTooShort', + type: 'error', + }, + { + inputs: [], + name: 'NameIsNotWrapped', + type: 'error', + }, + { + inputs: [ + { + name: 'node', + type: 'bytes32', + }, + ], + name: 'OperationProhibited', + type: 'error', + }, + { + inputs: [ + { + name: 'node', + type: 'bytes32', + }, + { + name: 'addr', + type: 'address', + }, + ], + name: 'Unauthorised', + type: 'error', + }, +] as const + +export const nameWrapperGetDataSnippet = [ + ...nameWrapperErrors, + { + inputs: [ + { + name: 'id', + type: 'uint256', + }, + ], + name: 'getData', + outputs: [ + { + name: 'owner', + type: 'address', + }, + { + name: 'fuses', + type: 'uint32', + }, + { + name: 'expiry', + type: 'uint64', + }, + ], + stateMutability: 'view', + type: 'function', + }, +] as const + +export const nameWrapperSetFusesSnippet = [ + ...nameWrapperErrors, + { + inputs: [ + { + name: 'node', + type: 'bytes32', + }, + { + name: 'ownerControlledFuses', + type: 'uint16', + }, + ], + name: 'setFuses', + outputs: [ + { + name: '', + type: 'uint32', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, +] as const + +export const nameWrapperSetChildFusesSnippet = [ + ...nameWrapperErrors, + { + inputs: [ + { + name: 'parentNode', + type: 'bytes32', + }, + { + name: 'labelhash', + type: 'bytes32', + }, + { + name: 'fuses', + type: 'uint32', + }, + { + name: 'expiry', + type: 'uint64', + }, + ], + name: 'setChildFuses', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, +] as const + +export const nameWrapperSetSubnodeRecordSnippet = [ + ...nameWrapperErrors, + { + inputs: [ + { + name: 'parentNode', + type: 'bytes32', + }, + { + name: 'label', + type: 'string', + }, + { + name: 'owner', + type: 'address', + }, + { + name: 'resolver', + type: 'address', + }, + { + name: 'ttl', + type: 'uint64', + }, + { + name: 'fuses', + type: 'uint32', + }, + { + name: 'expiry', + type: 'uint64', + }, + ], + name: 'setSubnodeRecord', + outputs: [ + { + name: 'node', + type: 'bytes32', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, +] as const + +export const nameWrapperSetRecordSnippet = [ + ...nameWrapperErrors, + { + inputs: [ + { + name: 'node', + type: 'bytes32', + }, + { + name: 'owner', + type: 'address', + }, + { + name: 'resolver', + type: 'address', + }, + { + name: 'ttl', + type: 'uint64', + }, + ], + name: 'setRecord', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, +] as const + +export const nameWrapperSetSubnodeOwnerSnippet = [ + ...nameWrapperErrors, + { + inputs: [ + { + name: 'parentNode', + type: 'bytes32', + }, + { + name: 'label', + type: 'string', + }, + { + name: 'owner', + type: 'address', + }, + { + name: 'fuses', + type: 'uint32', + }, + { + name: 'expiry', + type: 'uint64', + }, + ], + name: 'setSubnodeOwner', + outputs: [ + { + name: 'node', + type: 'bytes32', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, +] as const + +export const nameWrapperWrapSnippet = [ + ...nameWrapperErrors, + { + inputs: [ + { + name: 'name', + type: 'bytes', + }, + { + name: 'wrappedOwner', + type: 'address', + }, + { + name: 'resolver', + type: 'address', + }, + ], + name: 'wrap', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, +] as const + +export const nameWrapperUnwrapSnippet = [ + ...nameWrapperErrors, + { + inputs: [ + { + name: 'parentNode', + type: 'bytes32', + }, + { + name: 'labelhash', + type: 'bytes32', + }, + { + name: 'controller', + type: 'address', + }, + ], + name: 'unwrap', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, +] as const + +export const nameWrapperUnwrapAnyldSnippet = [ + ...nameWrapperErrors, + { + inputs: [ + { + name: 'labelhash', + type: 'bytes32', + }, + { + name: 'registrant', + type: 'address', + }, + { + name: 'controller', + type: 'address', + }, + ], + name: 'unwrapAnyLD', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, +] as const + +export const nameWrapperNamesSnippet = [ + ...nameWrapperErrors, + { + inputs: [ + { + name: '', + type: 'bytes32', + }, + ], + name: 'names', + outputs: [ + { + name: '', + type: 'bytes', + }, + ], + stateMutability: 'view', + type: 'function', + }, +] as const + +export const nameWrapperSafeTransferFromSnippet = [ + ...nameWrapperErrors, + ...erc1155SafeTransferFromSnippet, +] as const + +export const nameWrapperOwnerOfSnippet = [...nameWrapperErrors, ...erc721OwnerOfSnippet] as const + +export const nameWrapperSetResolverSnippet = [ + ...nameWrapperErrors, + ...registrySetResolverSnippet, +] as const diff --git a/packages/linea-ens-app/src/ensJsOverrides/unwrapName.ts b/packages/linea-ens-app/src/ensJsOverrides/unwrapName.ts new file mode 100644 index 000000000..50272154c --- /dev/null +++ b/packages/linea-ens-app/src/ensJsOverrides/unwrapName.ts @@ -0,0 +1,170 @@ +import { + encodeFunctionData, + type Account, + type Address, + type Hash, + type SendTransactionParameters, + type Transport, +} from 'viem' +import { sendTransaction } from 'viem/actions' + +import { + AdditionalParameterSpecifiedError, + RequiredParameterNotSpecifiedError, +} from '@ensdomains/ensjs' +import { + ChainWithEns, + ClientWithAccount, + getChainContractAddress, +} from '@ensdomains/ensjs/contracts' +import { + Eth2ldName, + Eth2ldNameSpecifier, + GetNameType, + SimpleTransactionRequest, + WriteTransactionParameters, +} from '@ensdomains/ensjs/dist/types/types' + +import { nameWrapperUnwrapAnyldSnippet, nameWrapperUnwrapSnippet } from './contracts/nameWrapper' +import { getNameType } from './utils/getNameType' +import { makeLabelNodeAndParent } from './utils/makeLabelNodeAndParent' + +type BaseUnwrapNameDataParameters = { + /** The name to unwrap */ + name: TName + /** The recipient of the unwrapped name */ + newOwnerAddress: Address + /** The registrant of the unwrapped name (eth-2ld only) */ + newRegistrantAddress?: Address +} + +type Eth2ldUnwrapNameDataParameters = { + name: Eth2ldName + newRegistrantAddress: Address +} + +type OtherUnwrapNameDataParameters = { + name: string + newRegistrantAddress?: never +} + +export type UnwrapNameDataParameters< + TName extends string, + TNameType extends GetNameType = GetNameType, +> = BaseUnwrapNameDataParameters & + (TNameType extends Eth2ldNameSpecifier + ? Eth2ldUnwrapNameDataParameters + : OtherUnwrapNameDataParameters) + +export type UnwrapNameDataReturnType = SimpleTransactionRequest + +export type UnwrapNameParameters< + TName extends string, + TChain extends ChainWithEns, + TAccount extends Account | undefined, + TChainOverride extends ChainWithEns | undefined, +> = UnwrapNameDataParameters & WriteTransactionParameters + +export type UnwrapNameReturnType = Hash + +export const makeFunctionData = < + TName extends string, + TChain extends ChainWithEns, + TAccount extends Account | undefined, +>( + wallet: ClientWithAccount, + { name, newOwnerAddress, newRegistrantAddress }: UnwrapNameDataParameters, +): UnwrapNameDataReturnType => { + const { labelhash, parentNode } = makeLabelNodeAndParent(name) + const nameWrapperAddress = getChainContractAddress({ + client: wallet, + contract: 'ensNameWrapper', + }) + const nameType = getNameType(name) + + if (nameType === 'eth-3ld') { + if (!newRegistrantAddress) + throw new RequiredParameterNotSpecifiedError({ + parameter: 'newRegistrantAddress', + details: 'Must provide newRegistrantAddress for eth-2ld names', + }) + + return { + to: nameWrapperAddress, + data: encodeFunctionData({ + abi: nameWrapperUnwrapAnyldSnippet, + functionName: 'unwrapAnyLD', + args: [labelhash, newRegistrantAddress, newOwnerAddress], + }), + } + } + + if (newRegistrantAddress) + throw new AdditionalParameterSpecifiedError({ + parameter: 'newRegistrantAddress', + allowedParameters: ['name', 'newOwnerAddress'], + details: 'newRegistrantAddress can only be specified for eth-2ld names', + }) + + return { + to: nameWrapperAddress, + data: encodeFunctionData({ + abi: nameWrapperUnwrapSnippet, + functionName: 'unwrap', + args: [parentNode, labelhash, newOwnerAddress], + }), + } +} + +/** + * Unwraps a name. + * @param wallet - {@link ClientWithAccount} + * @param parameters - {@link UnwrapNameParameters} + * @returns Transaction hash. {@link UnwrapNameReturnType} + * + * @example + * import { createWalletClient, custom } from 'viem' + * import { mainnet } from 'viem/chains' + * import { addEnsContracts } from '@ensdomains/ensjs' + * import { unwrapName } from '@ensdomains/ensjs/wallet' + * + * const wallet = createWalletClient({ + * chain: addEnsContracts(mainnet), + * transport: custom(window.ethereum), + * }) + * const hash = await unwrapName(wallet, { + * name: 'example.eth', + * newOwnerAddress: '0xFe89cc7aBB2C4183683ab71653C4cdc9B02D44b7', + * newRegistrantAddress: '0xFe89cc7aBB2C4183683ab71653C4cdc9B02D44b7', + * }) + * // 0x... + */ +async function unwrapName< + TName extends string, + TChain extends ChainWithEns, + TAccount extends Account | undefined, + TChainOverride extends ChainWithEns | undefined = ChainWithEns, +>( + wallet: ClientWithAccount, + { + name, + newOwnerAddress, + newRegistrantAddress, + ...txArgs + }: UnwrapNameParameters, +): Promise { + const data = makeFunctionData(wallet, { + name, + newOwnerAddress, + newRegistrantAddress, + } as UnwrapNameDataParameters) + const writeArgs = { + ...data, + ...(txArgs as WriteTransactionParameters), + } as SendTransactionParameters + return sendTransaction(wallet, writeArgs) +} + +unwrapName.makeFunctionData = makeFunctionData + +export default unwrapName diff --git a/packages/linea-ens-app/src/ensJsOverrides/utils/makeLabelNodeAndParent.ts b/packages/linea-ens-app/src/ensJsOverrides/utils/makeLabelNodeAndParent.ts new file mode 100644 index 000000000..efa332e22 --- /dev/null +++ b/packages/linea-ens-app/src/ensJsOverrides/utils/makeLabelNodeAndParent.ts @@ -0,0 +1,14 @@ +import { labelhash } from 'viem' + +import { namehash } from '@ensdomains/ensjs/utils' + +export const makeLabelNodeAndParent = (name: string) => { + const labels = name.split('.') + const label = labels.shift() as string + const parentNode = namehash(labels.join('.')) + return { + label, + labelhash: labelhash(label), + parentNode, + } +} diff --git a/packages/linea-ens-app/src/ensJsOverrides/wrapName.ts b/packages/linea-ens-app/src/ensJsOverrides/wrapName.ts new file mode 100644 index 000000000..5c03a9059 --- /dev/null +++ b/packages/linea-ens-app/src/ensJsOverrides/wrapName.ts @@ -0,0 +1,190 @@ +import { + encodeAbiParameters, + encodeFunctionData, + labelhash, + toHex, + type Account, + type Address, + type Hash, + type SendTransactionParameters, + type Transport, +} from 'viem' +import { sendTransaction } from 'viem/actions' +import { parseAccount } from 'viem/utils' + +import { AdditionalParameterSpecifiedError } from '@ensdomains/ensjs' +import { + baseRegistrarSafeTransferFromWithDataSnippet, + ChainWithEns, + ClientWithAccount, + getChainContractAddress, + nameWrapperWrapSnippet, +} from '@ensdomains/ensjs/contracts' +import { + Eth2ldNameSpecifier, + GetNameType, + SimpleTransactionRequest, + WriteTransactionParameters, +} from '@ensdomains/ensjs/dist/types/types' +import { + EncodeChildFusesInputObject, + encodeFuses, + packetToBytes, + wrappedLabelLengthCheck, +} from '@ensdomains/ensjs/utils' + +import { Prettify } from '@app/types' + +import { checkIs3LDEth, checkIsDotEth } from './utils/validation' + +export type WrapNameDataParameters< + TName extends string, + TNameOption extends GetNameType = GetNameType, +> = { + /** The name to wrap */ + name: TName + /** The recipient of the wrapped name */ + newOwnerAddress: Address + /** Fuses to set on wrap (eth-2ld only) */ + fuses?: TNameOption extends Eth2ldNameSpecifier ? EncodeChildFusesInputObject : never + /** The resolver address to set on wrap */ + resolverAddress?: Address +} + +export type WrapNameDataReturnType = SimpleTransactionRequest + +export type WrapNameParameters< + TName extends string, + TChain extends ChainWithEns, + TAccount extends Account | undefined, + TChainOverride extends ChainWithEns | undefined, +> = Prettify< + WrapNameDataParameters & WriteTransactionParameters +> + +export type WrapNameReturnType = Hash + +export const makeFunctionData = < + TName extends string, + TChain extends ChainWithEns, + TAccount extends Account, +>( + wallet: ClientWithAccount, + { + name, + newOwnerAddress, + fuses, + resolverAddress = getChainContractAddress({ + client: wallet, + contract: 'ensPublicResolver', + }), + }: WrapNameDataParameters, +): WrapNameDataReturnType => { + const labels = name.split('.') + const isEth3ld = checkIs3LDEth(labels) + + const nameWrapperAddress = getChainContractAddress({ + client: wallet, + contract: 'ensNameWrapper', + }) + + if (isEth3ld) { + wrappedLabelLengthCheck(labels[0]) + const encodedFuses = fuses ? encodeFuses({ restriction: 'child', input: fuses }) : 0 + const tokenId = BigInt(labelhash(labels[0])) + + const data = encodeAbiParameters( + [ + { name: 'label', type: 'string' }, + { name: 'wrappedOwner', type: 'address' }, + { name: 'ownerControlledFuses', type: 'uint16' }, + { name: 'resolverAddress', type: 'address' }, + ], + [labels[0], newOwnerAddress, encodedFuses, resolverAddress], + ) + + return { + to: getChainContractAddress({ + client: wallet, + contract: 'ensBaseRegistrarImplementation', + }), + data: encodeFunctionData({ + abi: baseRegistrarSafeTransferFromWithDataSnippet, + functionName: 'safeTransferFrom', + args: [wallet.account.address, nameWrapperAddress, tokenId, data], + }), + } + } + + if (fuses) + throw new AdditionalParameterSpecifiedError({ + parameter: 'fuses', + allowedParameters: ['name', 'wrappedOwner', 'resolverAddress'], + details: 'Fuses cannot be initially set when wrapping non eth-2ld names', + }) + + labels.forEach((label) => wrappedLabelLengthCheck(label)) + return { + to: nameWrapperAddress, + data: encodeFunctionData({ + abi: nameWrapperWrapSnippet, + functionName: 'wrap', + args: [toHex(packetToBytes(name)), newOwnerAddress, resolverAddress], + }), + } +} + +/** + * Wraps a name. + * @param wallet - {@link ClientWithAccount} + * @param parameters - {@link WrapNameParameters} + * @returns Transaction hash. {@link WrapNameReturnType} + * + * @example + * import { createWalletClient, custom } from 'viem' + * import { mainnet } from 'viem/chains' + * import { addEnsContracts } from '@ensdomains/ensjs' + * import { wrapName } from '@ensdomains/ensjs/wallet' + * + * const wallet = createWalletClient({ + * chain: addEnsContracts(mainnet), + * transport: custom(window.ethereum), + * }) + * const hash = await wrapName(wallet, { + * name: 'ens.eth', + * newOwnerAddress: '0xFe89cc7aBB2C4183683ab71653C4cdc9B02D44b7', + * }) + * // 0x... + */ +async function wrapName< + TName extends string, + TChain extends ChainWithEns, + TAccount extends Account | undefined, + TChainOverride extends ChainWithEns | undefined = ChainWithEns, +>( + wallet: ClientWithAccount, + { + name, + newOwnerAddress, + fuses, + resolverAddress, + ...txArgs + }: WrapNameParameters, +): Promise { + const data = makeFunctionData( + { + ...wallet, + account: parseAccount((txArgs.account || wallet.account)!), + } as ClientWithAccount, + { name, newOwnerAddress, fuses, resolverAddress }, + ) + const writeArgs = { + ...data, + ...txArgs, + } as SendTransactionParameters + return sendTransaction(wallet, writeArgs) +} + +wrapName.makeFunctionData = makeFunctionData + +export default wrapName diff --git a/packages/linea-ens-app/src/transaction-flow/intro/WrapName.tsx b/packages/linea-ens-app/src/transaction-flow/intro/WrapName.tsx index e92c63c5b..b9606db22 100644 --- a/packages/linea-ens-app/src/transaction-flow/intro/WrapName.tsx +++ b/packages/linea-ens-app/src/transaction-flow/intro/WrapName.tsx @@ -2,10 +2,9 @@ import { useTranslation } from 'react-i18next' import styled, { css } from 'styled-components' import { useEnsAvatar } from 'wagmi' -import { Typography } from '@ensdomains/thorin' - import { WrapNameGift } from '@app/assets/WrapNameGift' import { Outlink } from '@app/components/Outlink' +import { Typography } from '@app/components/styled/Typography' import { ensAvatarConfig } from '@app/utils/query/ipfsGateway' import { getSupportLink } from '@app/utils/supportLinks' diff --git a/packages/linea-ens-app/src/transaction-flow/transaction/unwrapName.ts b/packages/linea-ens-app/src/transaction-flow/transaction/unwrapName.ts index 2db7f80c7..50545ffc5 100644 --- a/packages/linea-ens-app/src/transaction-flow/transaction/unwrapName.ts +++ b/packages/linea-ens-app/src/transaction-flow/transaction/unwrapName.ts @@ -1,9 +1,8 @@ import type { TFunction } from 'react-i18next' -import { unwrapName } from '@ensdomains/ensjs/wallet' - +import unwrapName from '@app/ensJsOverrides/unwrapName' import type { Transaction, TransactionDisplayItem, TransactionFunctionParameters } from '@app/types' -import { checkETH2LDFromName } from '@app/utils/utils' +import { checkETH3LDFromName } from '@app/utils/utils' type Data = { name: string @@ -27,7 +26,7 @@ const displayItems = ( const transaction = async ({ connectorClient, data }: TransactionFunctionParameters) => { const { address } = connectorClient.account - if (checkETH2LDFromName(data.name)) + if (checkETH3LDFromName(data.name)) return unwrapName.makeFunctionData(connectorClient, { name: data.name, newOwnerAddress: address, diff --git a/packages/linea-ens-app/src/transaction-flow/transaction/wrapName.ts b/packages/linea-ens-app/src/transaction-flow/transaction/wrapName.ts index 735343527..2a6cd54df 100644 --- a/packages/linea-ens-app/src/transaction-flow/transaction/wrapName.ts +++ b/packages/linea-ens-app/src/transaction-flow/transaction/wrapName.ts @@ -1,7 +1,6 @@ import type { TFunction } from 'react-i18next' -import { wrapName } from '@ensdomains/ensjs/wallet' - +import wrapName from '@app/ensJsOverrides/wrapName' import { Transaction, TransactionDisplayItem, TransactionFunctionParameters } from '@app/types' type Data = { From a562c3d6c39485b03bc351be822df08a17558f60 Mon Sep 17 00:00:00 2001 From: Julink Date: Tue, 30 Jul 2024 18:25:39 +0200 Subject: [PATCH 2/2] fix: unused var --- packages/linea-ens-app/src/ensJsOverrides/wrapName.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/linea-ens-app/src/ensJsOverrides/wrapName.ts b/packages/linea-ens-app/src/ensJsOverrides/wrapName.ts index 5c03a9059..7417d6747 100644 --- a/packages/linea-ens-app/src/ensJsOverrides/wrapName.ts +++ b/packages/linea-ens-app/src/ensJsOverrides/wrapName.ts @@ -35,7 +35,7 @@ import { import { Prettify } from '@app/types' -import { checkIs3LDEth, checkIsDotEth } from './utils/validation' +import { checkIs3LDEth } from './utils/validation' export type WrapNameDataParameters< TName extends string,