From ensforge 1.1
Upgrade an app from ensforge 1.1 to 1.2, with every default that changed to match the ENS app and the code that keeps the old behaviour.
ensforge 1.2 brings ensforge in line with the ENS app. Some defaults changed to match it. Most apps need no code changes. This guide lists every change that can affect 1.1 code, and how to keep the old behaviour where that is still possible.
Code blocks that mark lines with [!code --] and [!code ++] are diffs: they show the old and the new line together, so the docs build does not compile them.
What changed
| Area | 1.1 | 1.2 |
|---|---|---|
| Registration resolver | A new PermissionedResolver per name | The signer's shared resolver (resolver: "owned"), as the ENS app does |
name.transfer | Safe transfer only, refused when the registry disallows it | unsafe: "auto": an unsafe transfer when needed, with the warning TRANSFER_UNSAFE |
record.set({ resolver }) | Merged new records into what the resolver held | Starts a fresh record on a resolver that already holds the name's records |
| Migration records | Copied what it could read | Fails with RECORDS_UNKNOWN when a record cannot be copied |
| Renewal step ids | One renew step | One step per renewBatch call: renew:v2:0, renew:v1:0, … |
wrapper.unwrap | Sent the name to the signer | Leaves the name with its current holder |
| Role names | Any role name, read by bit position | Names from the target's own table (Role.RegistryName, Role.ResolverName) |
rhinestone() | Requested sponsored gas | The HCA pays its fees; sponsored: true asks for sponsorship |
via: hca() | Failed when the HCA held too little | Funds the HCA from the owner's wallet |
1. Update the packages
pnpm add @ensforge/sdk@latest @ensforge/contracts@latestAlso update @ensforge/react and @ensforge/hca if you use them. The public packages version together.
2. Registration uses one resolver per wallet
A name registered for the signer goes on the signer's shared PermissionedResolver, at the address the ENS app uses. It is deployed with the first registration and reused after that. A name registered for another owner keeps a resolver of its own.
To keep one resolver per name, pass resolver: "new":
await ens.registration.registerSync({
names: "alice.eth",
duration: Duration.years(1),
resolver: "new",
});A commitment made by ensforge 1.1 with the default resolver must be revealed with resolver: "new". Without it, the commitment no longer matches, and register commits again.
See Resolvers and shared records.
3. Transfers move the name when the registry allows only an unsafe transfer
Some ENSv2 registries, such as those of names made with subname.create, allow only unsafeTransfer. In 1.1 such transfers failed. In 1.2 name.transfer sends them, and the plan carries a TRANSFER_UNSAFE warning saying why. The receiver is still checked.
To refuse instead, pass unsafe: false:
await ens.name.transfer({
name: "pay.alice.eth",
to: recipient,
unsafe: false,
});4. Switching resolvers starts a fresh record
record.set({ resolver }) moves a name to another resolver. When that resolver already holds records for the name, 1.2 starts a fresh record there, as clear: true would, so records shared with other names are not changed. Pass clear: false to merge as before:
await ens.record.set({
name: "alice.eth",
resolver: newResolver,
texts: { url: "https://alice.example" },
clear: false,
});5. Migration refuses to leave records behind
A record that migration.migrate cannot copy, such as a public key, or an incomplete list from the indexer, now fails with RECORDS_UNKNOWN. Pass the name's records, keep its resolver with resolver: "keep", or pass allowIncompleteRecords to copy the others.
A migration that stopped after its transfer can now be finished with resume: true. See Finish a migration that stopped.
6. Role names follow the target
Registry and resolver roles share bit positions. In 1.1, roles: ["setAddr"] with target: "registry" granted the registry's registrar role. In 1.2 a name that is not in the target's table fails with INVALID_ROLES, and the option types accept only that table's names.
Code that passes a Role.Name[] variable must narrow it:
import type { Role } from "@ensforge/sdk";
const roles: Role.Name[] = ["setResolver"];
const roles: Role.RegistryName[] = ["setResolver"];
await ens.role.grant({ name: "alice.eth", target: "registry", grantee, roles });7. Check the smaller changes
registration.renewmakes one plan step perrenewBatchcall. Code that looks up a step by id readsrenew:v2:0,renew:v1:0, and so on, orrenewwhen there is one call. A resumed renewal skips the calls already mined.wrapper.unwrapleaves the name with its current holder. Passownerto send it to the signer or elsewhere.register,commit,record.setandresolver.setrefuse a resolver address without a contract withRESOLVER_NOT_DEPLOYED.resolver.set({ allowNonContract: true })still allows one.- Registration and renewal durations must be at most 100 years (
INVALID_DURATION). - PermissionedResolvers that ensforge deploys give their writers every role. A shared resolver created by ensforge 1.0 or 1.1 still works, with the warning
RESOLVER_ROLES_PARTIAL.
8. HCA writes
These apply only to @ensforge/hca:
rhinestone()no longer requests sponsored gas. Executions pay their fee from the HCA. If your Rhinestone project sponsors gas, passsponsored: true.- When the HCA holds less than its calls and fees need,
hca()moves the shortfall from the owner's wallet, and the plan warnsHCA_FUNDING. Passhca({ funding: "none" })to fail withINSUFFICIENT_TOKEN_BALANCEinstead. - The orchestrator's route is checked before signing. A route that does more than the requested calls, or refunds more than
maxRefund, fails withHCA_ROUTE_REJECTED. - Session-signed intents need the ENS-patched
@rhinestone/sdk@1.22.0.
const via = hca({
executors: [rhinestone({ sdk, sponsored: true })],
});See Use smart accounts.
Was this page helpful?