Skip to content

Commit c67b502

Browse files
committed
works with EOA for regular registration and set-primary
1 parent b604e1a commit c67b502

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

apps/web/src/hooks/useRegisterNameCallback.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,8 @@ export function useRegisterNameCallback(
103103
if (!address) throw new Error('No address');
104104
if (!publicClient) throw new Error('No public client');
105105

106-
const reverseRegistrar = await publicClient.readContract({
107-
abi: UpgradeableRegistrarControllerAbi,
108-
address: REGISTER_CONTRACT_ADDRESSES[basenameChain.id],
109-
functionName: 'reverseRegistrar',
110-
});
106+
// Use the L2 Reverse Registrar address configured for this chain.
107+
const reverseRegistrar = USERNAME_L2_REVERSE_REGISTRAR_ADDRESSES[basenameChain.id];
111108

112109
const functionAbi = L2ReverseRegistrarAbi.find(
113110
(f) => f.type === 'function' && f.name === 'setNameForAddrWithSignature',
@@ -116,10 +113,11 @@ export function useRegisterNameCallback(
116113

117114
const signatureExpiry = BigInt(Math.floor(Date.now() / 1000) + 5 * 60);
118115
const coinTypes = [BigInt(convertChainIdToCoinTypeUint(basenameChain.id))] as const;
116+
const fullName = formatBaseEthDomain(name, basenameChain.id);
119117

120118
const preimage = encodePacked(
121119
['address', 'bytes4', 'address', 'uint256', 'string', 'uint256[]'],
122-
[reverseRegistrar, selector, address, signatureExpiry, normalizedName, coinTypes],
120+
[reverseRegistrar, selector, address, signatureExpiry, fullName, coinTypes],
123121
);
124122

125123
const digest = keccak256(preimage);
@@ -128,7 +126,7 @@ export function useRegisterNameCallback(
128126
const payload = { coinTypes, signatureExpiry, signature } as const;
129127
setReverseSigPayload(payload);
130128
return payload;
131-
}, [address, basenameChain.id, normalizedName, publicClient, signMessageAsync]);
129+
}, [address, basenameChain.id, name, publicClient, signMessageAsync]);
132130

133131
// Callback
134132
const registerName = useCallback(async () => {
@@ -176,13 +174,15 @@ export function useRegisterNameCallback(
176174
signatureForRequest = payload.signature;
177175
}
178176

177+
const reverseRecordForRequest = paymasterServiceEnabled ? false : reverseRecord;
178+
179179
const registerRequest = {
180180
name: normalizedName, // The name being registered.
181181
owner: address, // The address of the owner for the name.
182182
duration: secondsInYears(years), // The duration of the registration in seconds.
183183
resolver: UPGRADEABLE_L2_RESOLVER_ADDRESSES[basenameChain.id], // The address of the resolver to set for this name.
184184
data: [addressData, baseCointypeData, nameData], // Multicallable data bytes for setting records in the associated resolver upon registration.
185-
reverseRecord, // Bool to decide whether to set this name as the "primary" name for the `owner`.
185+
reverseRecord: reverseRecordForRequest, // When using paymaster (atomic batch), set via separate call instead of signature flow.
186186
coinTypes: coinTypesForRequest,
187187
signatureExpiry: signatureExpiryForRequest,
188188
signature: signatureForRequest,

0 commit comments

Comments
 (0)