@ensforge/core 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -4
- package/dist/action/index.d.ts +1 -1
- package/dist/actions/batch/execute-write-plan.d.ts.map +1 -1
- package/dist/actions/batch/execute-write-plan.js +20 -2
- package/dist/actions/batch/execute-write-plan.js.map +1 -1
- package/dist/actions/capabilities/get-name-capabilities/index.d.ts +1 -1
- package/dist/actions/capabilities/get-operator-approval/index.d.ts +1 -1
- package/dist/actions/capabilities/get-record-permissions/index.d.ts.map +1 -1
- package/dist/actions/capabilities/get-record-permissions/index.js +13 -1
- package/dist/actions/capabilities/get-record-permissions/index.js.map +1 -1
- package/dist/actions/capabilities/get-required-authorization/index.d.ts +1 -1
- package/dist/actions/capabilities/get-resolver-capabilities/index.d.ts +1 -1
- package/dist/actions/capabilities/get-write-target/index.d.ts +1 -1
- package/dist/actions/dns/get-dns-claim-status/index.d.ts +1 -1
- package/dist/actions/dns/get-dns-import-plan/index.d.ts +1 -1
- package/dist/actions/dns/get-zone-hash/index.d.ts +1 -1
- package/dist/actions/dns/has-dns-records/index.d.ts +1 -1
- package/dist/actions/dns/types.d.ts +3 -3
- package/dist/actions/dns/types.d.ts.map +1 -1
- package/dist/actions/dns/types.js.map +1 -1
- package/dist/actions/events/get-ens-events/index.d.ts +4 -4
- package/dist/actions/events/get-name-history/index.d.ts +4 -4
- package/dist/actions/events/types.d.ts +1 -1
- package/dist/actions/index.d.ts +25 -25
- package/dist/actions/migration/get-migration-eligibility/index.d.ts +1 -1
- package/dist/actions/migration/get-migration-plan/index.d.ts +2 -2
- package/dist/actions/migration/mutation.js +1 -1
- package/dist/actions/name/get-expiry/types.d.ts +2 -2
- package/dist/actions/name/get-name-state/index.d.ts +6 -6
- package/dist/actions/name/get-name-state/types.d.ts +2 -2
- package/dist/actions/name/get-name-status/index.d.ts +1 -1
- package/dist/actions/name/get-owner/index.d.ts +1 -1
- package/dist/actions/name/get-owner/types.d.ts +2 -2
- package/dist/actions/records/get-abi/types.d.ts +2 -2
- package/dist/actions/records/get-address/types.d.ts +2 -2
- package/dist/actions/records/get-avatar/types.d.ts +2 -2
- package/dist/actions/records/get-content-hash/types.d.ts +2 -2
- package/dist/actions/records/get-data/types.d.ts +2 -2
- package/dist/actions/records/get-interface/types.d.ts +2 -2
- package/dist/actions/records/get-name/types.d.ts +2 -2
- package/dist/actions/records/get-pubkey/types.d.ts +2 -2
- package/dist/actions/records/get-records/types.d.ts +3 -3
- package/dist/actions/records/get-text/types.d.ts +2 -2
- package/dist/actions/records/set-records/index.js +1 -1
- package/dist/actions/registration/get-commitment-status/index.d.ts +1 -1
- package/dist/actions/registration/get-registration-parameters/index.d.ts +1 -1
- package/dist/actions/registration/get-registration-plan/index.d.ts +9 -9
- package/dist/actions/registration/get-registration-price/index.d.ts +9 -9
- package/dist/actions/registration/get-renewal-price/index.d.ts +9 -9
- package/dist/actions/registration/is-payment-token-supported/index.d.ts +1 -1
- package/dist/actions/registration/renew-names/index.js +2 -2
- package/dist/actions/registration/renew-names/index.js.map +1 -1
- package/dist/actions/registration/renewal-mutation.d.ts +0 -1
- package/dist/actions/registration/renewal-mutation.d.ts.map +1 -1
- package/dist/actions/registration/renewal-mutation.js +27 -71
- package/dist/actions/registration/renewal-mutation.js.map +1 -1
- package/dist/actions/registration/types.d.ts +3 -3
- package/dist/actions/registration/types.d.ts.map +1 -1
- package/dist/actions/registration/types.js.map +1 -1
- package/dist/actions/resolution/create-resolver/index.d.ts +2 -0
- package/dist/actions/resolution/create-resolver/index.d.ts.map +1 -1
- package/dist/actions/resolution/create-resolver/index.js +39 -21
- package/dist/actions/resolution/create-resolver/index.js.map +1 -1
- package/dist/actions/resolution/create-resolver/prepare.d.ts.map +1 -1
- package/dist/actions/resolution/create-resolver/prepare.js +7 -5
- package/dist/actions/resolution/create-resolver/prepare.js.map +1 -1
- package/dist/actions/resolution/get-alias/index.d.ts.map +1 -1
- package/dist/actions/resolution/get-alias/index.js.map +1 -1
- package/dist/actions/resolution/get-resolver/types.d.ts +2 -2
- package/dist/actions/resolution/get-resolver-version/index.d.ts +1 -1
- package/dist/actions/resolution/resolve/types.d.ts +2 -2
- package/dist/actions/resolution/resolve-batch/index.d.ts +1 -1
- package/dist/actions/resolution/set-resolver/index.js +1 -1
- package/dist/actions/resolution/upgrade-resolver/index.js +1 -1
- package/dist/actions/reverse/get-primary-name/types.d.ts +2 -2
- package/dist/actions/subnames/intents.js +4 -24
- package/dist/actions/subnames/intents.js.map +1 -1
- package/dist/actions/wrapping/intents.js +1 -1
- package/dist/batch.d.ts +10 -0
- package/dist/batch.js +11 -0
- package/dist/{actions/capabilities/index.d.ts → capabilities.d.ts} +15 -15
- package/dist/capabilities.js +17 -0
- package/dist/config/config.d.ts +3 -10
- package/dist/config/config.d.ts.map +1 -1
- package/dist/config/config.js.map +1 -1
- package/dist/config/create-config.d.ts.map +1 -1
- package/dist/config/create-config.js +4 -56
- package/dist/config/create-config.js.map +1 -1
- package/dist/config/index.d.ts +2 -2
- package/dist/dns.d.ts +14 -0
- package/dist/dns.js +13 -0
- package/dist/errors/index.d.ts +2 -2
- package/dist/{actions/events/index.d.ts → events.d.ts} +4 -4
- package/dist/events.js +6 -0
- package/dist/index.d.ts +16 -16
- package/dist/index.js +3 -2
- package/dist/internal/config/create-config.js +54 -0
- package/dist/internal/config/create-config.js.map +1 -0
- package/dist/internal/errors/viem-error.d.ts +1 -1
- package/dist/internal/errors/write-error.js +6 -2
- package/dist/internal/errors/write-error.js.map +1 -1
- package/dist/internal/gateway/ccip-request.js +5 -1
- package/dist/internal/gateway/ccip-request.js.map +1 -1
- package/dist/internal/read/execution-context.d.ts +1 -1
- package/dist/internal/write/execute-sequential.js +41 -13
- package/dist/internal/write/execute-sequential.js.map +1 -1
- package/dist/internal/write/prepare-write-intents.js +1 -1
- package/dist/internal/write/resolver-write-action.js +1 -1
- package/dist/internal/write/resume-sequential.js +62 -0
- package/dist/internal/write/resume-sequential.js.map +1 -0
- package/dist/internal/write/single-write-action.js +1 -1
- package/dist/{actions/migration/index.d.ts → migration.d.ts} +8 -8
- package/dist/migration.js +10 -0
- package/dist/{actions/name/index.d.ts → name.d.ts} +18 -18
- package/dist/name.js +20 -0
- package/dist/{actions/ownership/index.d.ts → ownership.d.ts} +8 -8
- package/dist/ownership.js +8 -0
- package/dist/{actions/permissions/index.d.ts → permissions.d.ts} +12 -12
- package/dist/permissions.js +8 -0
- package/dist/{actions/records/index.d.ts → records.d.ts} +46 -46
- package/dist/records.js +34 -0
- package/dist/{actions/registration/index.d.ts → registration.d.ts} +15 -15
- package/dist/registration.js +16 -0
- package/dist/{actions/resolution/index.d.ts → resolution.d.ts} +20 -20
- package/dist/resolution.js +15 -0
- package/dist/{actions/reverse/index.d.ts → reverse.d.ts} +7 -7
- package/dist/reverse.js +8 -0
- package/dist/{actions/subnames/index.d.ts → subnames.d.ts} +5 -5
- package/dist/subnames.js +6 -0
- package/dist/testing/create-test-config.js +2 -2
- package/dist/wagmi/config.d.ts +9 -0
- package/dist/wagmi/config.d.ts.map +1 -0
- package/dist/wagmi/create-config.d.ts +7 -0
- package/dist/wagmi/create-config.d.ts.map +1 -0
- package/dist/wagmi/create-config.js +20 -0
- package/dist/wagmi/create-config.js.map +1 -0
- package/dist/wagmi.d.ts +3 -0
- package/dist/wagmi.js +3 -0
- package/dist/{actions/wrapping/index.d.ts → wrapping.d.ts} +10 -10
- package/dist/wrapping.js +7 -0
- package/dist/write/types.d.ts +2 -2
- package/package.json +25 -3
- package/dist/actions/batch/index.d.ts +0 -10
- package/dist/actions/dns/index.d.ts +0 -14
|
@@ -3,6 +3,15 @@ import { RegistrationPriceParameters, RegistrationReadError, RenewalPriceResult
|
|
|
3
3
|
import "../../../index.js";
|
|
4
4
|
//#region src/actions/registration/get-renewal-price/index.d.ts
|
|
5
5
|
declare const getRenewalPrice: EnsReadAction<RegistrationPriceParameters, {
|
|
6
|
+
readonly status: "payment-token-required";
|
|
7
|
+
readonly name: string & import("effect/Brand").Brand<"NormalizedName">;
|
|
8
|
+
readonly protocol: "v1" | "v2";
|
|
9
|
+
} | {
|
|
10
|
+
readonly status: "unsupported-payment-token";
|
|
11
|
+
readonly name: string & import("effect/Brand").Brand<"NormalizedName">;
|
|
12
|
+
readonly protocol: "v1" | "v2";
|
|
13
|
+
readonly paymentToken: `0x${string}`;
|
|
14
|
+
} | {
|
|
6
15
|
readonly status: "renewable";
|
|
7
16
|
readonly name: string & import("effect/Brand").Brand<"NormalizedName">;
|
|
8
17
|
readonly protocol: "v1" | "v2";
|
|
@@ -25,15 +34,6 @@ declare const getRenewalPrice: EnsReadAction<RegistrationPriceParameters, {
|
|
|
25
34
|
readonly name: string & import("effect/Brand").Brand<"NormalizedName">;
|
|
26
35
|
readonly protocol: "v1" | "v2";
|
|
27
36
|
readonly reason: "NAME_NOT_RENEWABLE";
|
|
28
|
-
} | {
|
|
29
|
-
readonly status: "payment-token-required";
|
|
30
|
-
readonly name: string & import("effect/Brand").Brand<"NormalizedName">;
|
|
31
|
-
readonly protocol: "v1" | "v2";
|
|
32
|
-
} | {
|
|
33
|
-
readonly status: "unsupported-payment-token";
|
|
34
|
-
readonly name: string & import("effect/Brand").Brand<"NormalizedName">;
|
|
35
|
-
readonly protocol: "v1" | "v2";
|
|
36
|
-
readonly paymentToken: `0x${string}`;
|
|
37
37
|
}, RegistrationReadError>;
|
|
38
38
|
//#endregion
|
|
39
39
|
export { type RegistrationReadError as GetRenewalPriceError, type RegistrationPriceParameters as GetRenewalPriceParameters, getRenewalPrice };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BlockParameters } from "../../../action/block.js";
|
|
2
1
|
import { EnsReadAction } from "../../../action/read-request.js";
|
|
2
|
+
import { BlockParameters } from "../../../action/block.js";
|
|
3
3
|
import { EthereumAddress } from "../../../schemas/identity.js";
|
|
4
4
|
import { PaymentTokenSupport, RegistrationReadError } from "../types.js";
|
|
5
5
|
import "../../../index.js";
|
|
@@ -134,7 +134,7 @@ const renewNamesEffect = Effect.fn("ensforge.renewNames")(function* (config, par
|
|
|
134
134
|
atomicity: "none",
|
|
135
135
|
confirmation: confirmed
|
|
136
136
|
});
|
|
137
|
-
const contractBatch = supportsContractRenewalBatch(
|
|
137
|
+
const contractBatch = supportsContractRenewalBatch(first.quote.route);
|
|
138
138
|
stages.push({
|
|
139
139
|
type: "calls",
|
|
140
140
|
id: renewalStageId,
|
|
@@ -168,7 +168,7 @@ const renewNamesEffect = Effect.fn("ensforge.renewNames")(function* (config, par
|
|
|
168
168
|
const stage = write.completedStages.find((candidate) => candidate.id === stageId);
|
|
169
169
|
const entryCall = group?.findIndex((candidate) => candidate === entry) ?? -1;
|
|
170
170
|
const callResult = stage?.result.mode === "sequential" && entryCall >= 0 ? stage.result.calls[entryCall] : void 0;
|
|
171
|
-
if (!(completedIds.has(stageId) || group !== void 0 && !supportsContractRenewalBatch(
|
|
171
|
+
if (!(completedIds.has(stageId) || group !== void 0 && !supportsContractRenewalBatch(entry.quote.route) && callResult !== void 0 && callResult.status !== "not-started")) return {
|
|
172
172
|
name: entry.quote.name,
|
|
173
173
|
protocol: entry.quote.protocol,
|
|
174
174
|
route: entry.quote.route,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../../src/actions/registration/renew-names/index.ts"],"sourcesContent":["import { Effect } from \"effect\";\n\nimport { erc20AllowanceAbi } from \"@ensforge/contracts/shared\";\nimport { keccak256, stringToHex } from \"viem\";\n\nimport { defineAction } from \"../../../action/action.js\";\nimport type { EnsforgeConfig } from \"../../../config/config.js\";\nimport { RenewalError } from \"../../../errors/renewal-error.js\";\nimport { provideConfig } from \"../../../internal/config/context.js\";\nimport { viemErrorToEffectError } from \"../../../internal/errors/viem-error.js\";\nimport { resolveWalletContext } from \"../../../internal/services/wallet-client.js\";\nimport { normalizeName } from \"../../../names/normalize.js\";\nimport type { WriteError, WritePlan } from \"../../../write/types.js\";\nimport { executeWritePlan } from \"../../batch/execute-write-plan.js\";\nimport { getExpiry } from \"../../name/get-expiry/index.js\";\nimport { getNameState } from \"../../name/get-name-state/index.js\";\nimport { getRenewalPrice } from \"../get-renewal-price/index.js\";\nimport {\n approveRenewalPayment,\n makeRenewalBatchIntent,\n makeRenewalIntent,\n supportsContractRenewalBatch,\n} from \"../renewal-mutation.js\";\nimport type {\n RenewNamesParameters,\n RenewNamesResult,\n RenewalApproval,\n RenewalPriceResult,\n} from \"../types.js\";\n\nconst confirmed = { type: \"confirmed\" } as const;\n\ntype Quote = Extract<RenewalPriceResult, { status: \"renewable\" }>;\ntype Entry = {\n readonly index: number;\n readonly parameters: RenewNamesParameters[\"renewals\"][number];\n readonly name: string;\n readonly quote: Quote;\n readonly previousExpiry: bigint | null;\n};\n\nconst planId = (parameters: RenewNamesParameters, names: ReadonlyArray<string>) =>\n `renewNames:${keccak256(\n stringToHex(\n JSON.stringify(\n {\n renewals: parameters.renewals.map((renewal, index) => ({\n ...renewal,\n name: names[index] ?? renewal.name,\n })),\n maxTotalPrice: parameters.maxTotalPrice ?? null,\n },\n (_key, value: unknown) => (typeof value === \"bigint\" ? value.toString() : value),\n ),\n ),\n )}`;\n\nconst requireQuote = (quote: RenewalPriceResult): Effect.Effect<Quote, RenewalError> => {\n switch (quote.status) {\n case \"not-renewable\":\n return new RenewalError({\n code: \"NAME_NOT_RENEWABLE\",\n message: `${quote.name} is not renewable`,\n });\n case \"payment-token-required\":\n return new RenewalError({\n code: \"PAYMENT_TOKEN_REQUIRED\",\n message: `A payment token is required to renew ${quote.name}`,\n });\n case \"unsupported-payment-token\":\n return new RenewalError({\n code: \"PAYMENT_TOKEN_UNSUPPORTED\",\n message: `The selected payment token is not supported for ${quote.name}`,\n });\n default:\n return Effect.succeed(quote);\n }\n};\n\nconst renewNamesEffect = Effect.fn(\"ensforge.renewNames\")(function* (\n config: EnsforgeConfig,\n parameters: RenewNamesParameters,\n): Effect.fn.Return<RenewNamesResult, WriteError> {\n if (parameters.renewals.length === 0) {\n return yield* new RenewalError({\n code: \"RENEWAL_FAILED\",\n message: \"renewNames requires at least one renewal\",\n });\n }\n const names = yield* Effect.forEach(parameters.renewals, (renewal) =>\n normalizeName.effect(renewal.name),\n );\n if (new Set(names).size !== names.length) {\n return yield* new RenewalError({\n code: \"RENEWAL_FAILED\",\n message: \"renewNames cannot contain duplicate names\",\n });\n }\n const id = planId(parameters, names);\n if (parameters.resume?.write.status === \"completed\") {\n if (parameters.resume.write.planId !== id) {\n return yield* new RenewalError({\n code: \"ROUTE_CHANGED\",\n message: \"Renewal resume data does not match the supplied renewals\",\n });\n }\n const renewals = yield* Effect.forEach(parameters.resume.renewals, (renewal) =>\n Effect.all(\n [\n getExpiry.effect(config, { name: renewal.name }),\n getNameState.effect(config, { name: renewal.name }),\n ] as const,\n { concurrency: \"unbounded\" },\n ).pipe(\n Effect.map(([expiry, finalState]) => ({\n ...renewal,\n newExpiry: expiry?.expiry ?? null,\n finalState,\n })),\n ),\n );\n return { ...parameters.resume, renewals };\n }\n\n const entries = yield* Effect.forEach(\n parameters.renewals,\n (renewal, index) =>\n Effect.all(\n [\n getRenewalPrice\n .effect(config, {\n name: names[index] ?? renewal.name,\n duration: renewal.duration,\n ...(renewal.paymentToken === undefined ? {} : { paymentToken: renewal.paymentToken }),\n })\n .pipe(Effect.flatMap(requireQuote)),\n getExpiry.effect(config, { name: names[index] ?? renewal.name }),\n ] as const,\n { concurrency: \"unbounded\" },\n ).pipe(\n Effect.map(([quote, expiry]): Entry => ({\n index,\n parameters: renewal,\n name: names[index] ?? renewal.name,\n quote,\n previousExpiry:\n parameters.resume?.renewals[index]?.previousExpiry ?? expiry?.expiry ?? null,\n })),\n ),\n { concurrency: config.reads.concurrency },\n );\n for (const entry of entries) {\n if (entry.parameters.maxPrice !== undefined && entry.quote.price > entry.parameters.maxPrice) {\n return yield* new RenewalError({\n code: \"PRICE_EXCEEDS_MAXIMUM\",\n message: `The current renewal price for ${entry.name} exceeds maxPrice`,\n });\n }\n }\n const totalPrice = entries.reduce((sum, entry) => sum + entry.quote.price, 0n);\n if (parameters.maxTotalPrice !== undefined && totalPrice > parameters.maxTotalPrice) {\n return yield* new RenewalError({\n code: \"TOTAL_PRICE_EXCEEDS_MAXIMUM\",\n message: \"The current renewal price exceeds maxTotalPrice\",\n });\n }\n\n const grouped = new Map<string, Array<Entry>>();\n for (const entry of entries) {\n const token = entry.quote.currency.kind === \"erc20\" ? entry.quote.currency.address : \"native\";\n const v1Arguments =\n entry.quote.route === \"v1-controller\"\n ? `${entry.parameters.duration}:${entry.parameters.referrer ?? \"default\"}`\n : \"mixed\";\n const key = `${entry.quote.route}:${entry.quote.renewer}:${token}:${v1Arguments}`;\n grouped.set(key, [...(grouped.get(key) ?? []), entry]);\n }\n\n const { account } = yield* provideConfig(config, resolveWalletContext(parameters));\n const payer = typeof account === \"string\" ? account : account.address;\n const stages: Array<WritePlan[\"stages\"][number]> = [];\n const approvals: Array<RenewalApproval> = [];\n let groupIndex = 0;\n for (const group of grouped.values()) {\n const first = group[0];\n if (first === undefined) continue;\n const renewalStageId = `renew-group-${groupIndex}`;\n const groupCompleted = parameters.resume?.write.completedStages.some(\n (stage) => stage.id === renewalStageId,\n );\n let approval = parameters.resume?.approvals.find(\n (candidate) =>\n candidate.spender === first.quote.renewer &&\n candidate.token ===\n (first.quote.currency.kind === \"erc20\" ? first.quote.currency.address : null),\n );\n if (first.quote.currency.kind === \"erc20\" && approval === undefined && !groupCompleted) {\n const currency = first.quote.currency;\n const allowance = yield* Effect.tryPromise({\n try: () =>\n config.publicClient.readContract({\n address: currency.address,\n abi: erc20AllowanceAbi,\n functionName: \"allowance\",\n args: [payer, first.quote.renewer],\n }),\n catch: (cause) => viemErrorToEffectError(cause, \"readContract\"),\n });\n const groupPrice = group.reduce((sum, entry) => sum + entry.quote.price, 0n);\n approval = {\n required: allowance < groupPrice,\n spender: first.quote.renewer,\n token: currency.address,\n amount: group.reduce(\n (sum, entry) => sum + (entry.parameters.maxPrice ?? entry.quote.price),\n 0n,\n ),\n };\n }\n if (approval !== undefined) approvals.push(approval);\n if (approval?.required && approval.token !== null) {\n stages.push({\n type: \"calls\",\n id: `approve-group-${groupIndex}`,\n calls: [\n approveRenewalPayment.call({\n name: first.name,\n duration: first.parameters.duration,\n paymentToken: approval.token,\n amount: approval.amount,\n }),\n ],\n mode: \"sequential\",\n atomicity: \"none\",\n confirmation: confirmed,\n });\n }\n const contractBatch = supportsContractRenewalBatch(config, first.quote.route);\n stages.push({\n type: \"calls\",\n id: renewalStageId,\n calls: contractBatch\n ? [\n makeRenewalBatchIntent({\n renewals: group.map((entry) => entry.parameters),\n ...(parameters.maxTotalPrice === undefined\n ? {}\n : { maxTotalPrice: parameters.maxTotalPrice }),\n }),\n ]\n : group.map((entry) => makeRenewalIntent(entry.parameters)),\n mode: contractBatch ? \"sequential\" : (parameters.mode ?? \"auto\"),\n atomicity: contractBatch || group.length === 1 ? \"none\" : \"preferred\",\n confirmation: parameters.confirmation ?? confirmed,\n });\n groupIndex += 1;\n }\n\n const write = yield* executeWritePlan\n .effect(config, {\n plan: { id, stages },\n ...(parameters.resume === undefined ? {} : { resume: parameters.resume.write }),\n ...(parameters.walletClient === undefined ? {} : { walletClient: parameters.walletClient }),\n ...(parameters.account === undefined ? {} : { account: parameters.account }),\n })\n .pipe(\n Effect.mapError((error) =>\n error instanceof RenewalError\n ? error\n : new RenewalError({ code: \"RENEWAL_FAILED\", message: \"Unable to renew names\" }),\n ),\n );\n const completedIds = new Set(write.completedStages.map((stage) => stage.id));\n const renewals = yield* Effect.forEach(\n entries,\n Effect.fn(\"ensforge.renewNames.result\")(function* (entry) {\n const containingGroup = [...grouped.values()].findIndex((group) => group.includes(entry));\n const group = [...grouped.values()][containingGroup];\n const stageId = `renew-group-${containingGroup}`;\n const stage = write.completedStages.find((candidate) => candidate.id === stageId);\n const entryCall = group?.findIndex((candidate) => candidate === entry) ?? -1;\n const callResult =\n stage?.result.mode === \"sequential\" && entryCall >= 0\n ? stage.result.calls[entryCall]\n : undefined;\n const completed =\n completedIds.has(stageId) ||\n (group !== undefined &&\n !supportsContractRenewalBatch(config, entry.quote.route) &&\n callResult !== undefined &&\n callResult.status !== \"not-started\");\n if (!completed) {\n return {\n name: entry.quote.name,\n protocol: entry.quote.protocol,\n route: entry.quote.route,\n duration: entry.parameters.duration,\n previousExpiry: entry.previousExpiry,\n newExpiry: null,\n price: entry.quote.price,\n currency: entry.quote.currency,\n finalState: null,\n } satisfies RenewNamesResult[\"renewals\"][number];\n }\n const [expiry, finalState] = yield* Effect.all(\n [\n getExpiry.effect(config, { name: entry.name }),\n getNameState.effect(config, { name: entry.name }),\n ] as const,\n { concurrency: \"unbounded\" },\n );\n return {\n name: entry.quote.name,\n protocol: entry.quote.protocol,\n route: entry.quote.route,\n duration: entry.parameters.duration,\n previousExpiry: entry.previousExpiry,\n newExpiry: expiry?.expiry ?? null,\n price: entry.quote.price,\n currency: entry.quote.currency,\n finalState,\n } satisfies RenewNamesResult[\"renewals\"][number];\n }),\n );\n return {\n status: write.status === \"completed\" ? \"completed\" : \"partial\",\n renewals,\n approvals,\n totalPrice,\n write,\n };\n});\n\nexport const renewNames = defineAction<RenewNamesParameters, RenewNamesResult, WriteError>(\n renewNamesEffect,\n);\n\nexport type { RenewNamesParameters, RenewNamesResult } from \"../types.js\";\n"],"mappings":";;;;;;;;;;;;;;;;AA8BA,MAAM,YAAY,EAAE,MAAM,YAAY;AAWtC,MAAM,UAAU,YAAkC,UAChD,cAAc,UACZ,YACE,KAAK,UACH;CACE,UAAU,WAAW,SAAS,KAAK,SAAS,WAAW;EACrD,GAAG;EACH,MAAM,MAAM,UAAU,QAAQ;CAChC,EAAE;CACF,eAAe,WAAW,iBAAiB;AAC7C,IACC,MAAM,UAAoB,OAAO,UAAU,WAAW,MAAM,SAAS,IAAI,KAC5E,CACF,CACF;AAEF,MAAM,gBAAgB,UAAkE;CACtF,QAAQ,MAAM,QAAd;EACE,KAAK,iBACH,OAAO,IAAI,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;CACF;AACF,CAAC;AAED,MAAa,aAAa,aACxB,gBACF"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../src/actions/registration/renew-names/index.ts"],"sourcesContent":["import { Effect } from \"effect\";\n\nimport { erc20AllowanceAbi } from \"@ensforge/contracts/shared\";\nimport { keccak256, stringToHex } from \"viem\";\n\nimport { defineAction } from \"../../../action/action.js\";\nimport type { EnsforgeConfig } from \"../../../config/config.js\";\nimport { RenewalError } from \"../../../errors/renewal-error.js\";\nimport { provideConfig } from \"../../../internal/config/context.js\";\nimport { viemErrorToEffectError } from \"../../../internal/errors/viem-error.js\";\nimport { resolveWalletContext } from \"../../../internal/services/wallet-client.js\";\nimport { normalizeName } from \"../../../names/normalize.js\";\nimport type { WriteError, WritePlan } from \"../../../write/types.js\";\nimport { executeWritePlan } from \"../../batch/execute-write-plan.js\";\nimport { getExpiry } from \"../../name/get-expiry/index.js\";\nimport { getNameState } from \"../../name/get-name-state/index.js\";\nimport { getRenewalPrice } from \"../get-renewal-price/index.js\";\nimport {\n approveRenewalPayment,\n makeRenewalBatchIntent,\n makeRenewalIntent,\n supportsContractRenewalBatch,\n} from \"../renewal-mutation.js\";\nimport type {\n RenewNamesParameters,\n RenewNamesResult,\n RenewalApproval,\n RenewalPriceResult,\n} from \"../types.js\";\n\nconst confirmed = { type: \"confirmed\" } as const;\n\ntype Quote = Extract<RenewalPriceResult, { status: \"renewable\" }>;\ntype Entry = {\n readonly index: number;\n readonly parameters: RenewNamesParameters[\"renewals\"][number];\n readonly name: string;\n readonly quote: Quote;\n readonly previousExpiry: bigint | null;\n};\n\nconst planId = (parameters: RenewNamesParameters, names: ReadonlyArray<string>) =>\n `renewNames:${keccak256(\n stringToHex(\n JSON.stringify(\n {\n renewals: parameters.renewals.map((renewal, index) => ({\n ...renewal,\n name: names[index] ?? renewal.name,\n })),\n maxTotalPrice: parameters.maxTotalPrice ?? null,\n },\n (_key, value: unknown) => (typeof value === \"bigint\" ? value.toString() : value),\n ),\n ),\n )}`;\n\nconst requireQuote = (quote: RenewalPriceResult): Effect.Effect<Quote, RenewalError> => {\n switch (quote.status) {\n case \"not-renewable\":\n return new RenewalError({\n code: \"NAME_NOT_RENEWABLE\",\n message: `${quote.name} is not renewable`,\n });\n case \"payment-token-required\":\n return new RenewalError({\n code: \"PAYMENT_TOKEN_REQUIRED\",\n message: `A payment token is required to renew ${quote.name}`,\n });\n case \"unsupported-payment-token\":\n return new RenewalError({\n code: \"PAYMENT_TOKEN_UNSUPPORTED\",\n message: `The selected payment token is not supported for ${quote.name}`,\n });\n default:\n return Effect.succeed(quote);\n }\n};\n\nconst renewNamesEffect = Effect.fn(\"ensforge.renewNames\")(function* (\n config: EnsforgeConfig,\n parameters: RenewNamesParameters,\n): Effect.fn.Return<RenewNamesResult, WriteError> {\n if (parameters.renewals.length === 0) {\n return yield* new RenewalError({\n code: \"RENEWAL_FAILED\",\n message: \"renewNames requires at least one renewal\",\n });\n }\n const names = yield* Effect.forEach(parameters.renewals, (renewal) =>\n normalizeName.effect(renewal.name),\n );\n if (new Set(names).size !== names.length) {\n return yield* new RenewalError({\n code: \"RENEWAL_FAILED\",\n message: \"renewNames cannot contain duplicate names\",\n });\n }\n const id = planId(parameters, names);\n if (parameters.resume?.write.status === \"completed\") {\n if (parameters.resume.write.planId !== id) {\n return yield* new RenewalError({\n code: \"ROUTE_CHANGED\",\n message: \"Renewal resume data does not match the supplied renewals\",\n });\n }\n const renewals = yield* Effect.forEach(parameters.resume.renewals, (renewal) =>\n Effect.all(\n [\n getExpiry.effect(config, { name: renewal.name }),\n getNameState.effect(config, { name: renewal.name }),\n ] as const,\n { concurrency: \"unbounded\" },\n ).pipe(\n Effect.map(([expiry, finalState]) => ({\n ...renewal,\n newExpiry: expiry?.expiry ?? null,\n finalState,\n })),\n ),\n );\n return { ...parameters.resume, renewals };\n }\n\n const entries = yield* Effect.forEach(\n parameters.renewals,\n (renewal, index) =>\n Effect.all(\n [\n getRenewalPrice\n .effect(config, {\n name: names[index] ?? renewal.name,\n duration: renewal.duration,\n ...(renewal.paymentToken === undefined ? {} : { paymentToken: renewal.paymentToken }),\n })\n .pipe(Effect.flatMap(requireQuote)),\n getExpiry.effect(config, { name: names[index] ?? renewal.name }),\n ] as const,\n { concurrency: \"unbounded\" },\n ).pipe(\n Effect.map(([quote, expiry]): Entry => ({\n index,\n parameters: renewal,\n name: names[index] ?? renewal.name,\n quote,\n previousExpiry:\n parameters.resume?.renewals[index]?.previousExpiry ?? expiry?.expiry ?? null,\n })),\n ),\n { concurrency: config.reads.concurrency },\n );\n for (const entry of entries) {\n if (entry.parameters.maxPrice !== undefined && entry.quote.price > entry.parameters.maxPrice) {\n return yield* new RenewalError({\n code: \"PRICE_EXCEEDS_MAXIMUM\",\n message: `The current renewal price for ${entry.name} exceeds maxPrice`,\n });\n }\n }\n const totalPrice = entries.reduce((sum, entry) => sum + entry.quote.price, 0n);\n if (parameters.maxTotalPrice !== undefined && totalPrice > parameters.maxTotalPrice) {\n return yield* new RenewalError({\n code: \"TOTAL_PRICE_EXCEEDS_MAXIMUM\",\n message: \"The current renewal price exceeds maxTotalPrice\",\n });\n }\n\n const grouped = new Map<string, Array<Entry>>();\n for (const entry of entries) {\n const token = entry.quote.currency.kind === \"erc20\" ? entry.quote.currency.address : \"native\";\n const v1Arguments =\n entry.quote.route === \"v1-controller\"\n ? `${entry.parameters.duration}:${entry.parameters.referrer ?? \"default\"}`\n : \"mixed\";\n const key = `${entry.quote.route}:${entry.quote.renewer}:${token}:${v1Arguments}`;\n grouped.set(key, [...(grouped.get(key) ?? []), entry]);\n }\n\n const { account } = yield* provideConfig(config, resolveWalletContext(parameters));\n const payer = typeof account === \"string\" ? account : account.address;\n const stages: Array<WritePlan[\"stages\"][number]> = [];\n const approvals: Array<RenewalApproval> = [];\n let groupIndex = 0;\n for (const group of grouped.values()) {\n const first = group[0];\n if (first === undefined) continue;\n const renewalStageId = `renew-group-${groupIndex}`;\n const groupCompleted = parameters.resume?.write.completedStages.some(\n (stage) => stage.id === renewalStageId,\n );\n let approval = parameters.resume?.approvals.find(\n (candidate) =>\n candidate.spender === first.quote.renewer &&\n candidate.token ===\n (first.quote.currency.kind === \"erc20\" ? first.quote.currency.address : null),\n );\n if (first.quote.currency.kind === \"erc20\" && approval === undefined && !groupCompleted) {\n const currency = first.quote.currency;\n const allowance = yield* Effect.tryPromise({\n try: () =>\n config.publicClient.readContract({\n address: currency.address,\n abi: erc20AllowanceAbi,\n functionName: \"allowance\",\n args: [payer, first.quote.renewer],\n }),\n catch: (cause) => viemErrorToEffectError(cause, \"readContract\"),\n });\n const groupPrice = group.reduce((sum, entry) => sum + entry.quote.price, 0n);\n approval = {\n required: allowance < groupPrice,\n spender: first.quote.renewer,\n token: currency.address,\n amount: group.reduce(\n (sum, entry) => sum + (entry.parameters.maxPrice ?? entry.quote.price),\n 0n,\n ),\n };\n }\n if (approval !== undefined) approvals.push(approval);\n if (approval?.required && approval.token !== null) {\n stages.push({\n type: \"calls\",\n id: `approve-group-${groupIndex}`,\n calls: [\n approveRenewalPayment.call({\n name: first.name,\n duration: first.parameters.duration,\n paymentToken: approval.token,\n amount: approval.amount,\n }),\n ],\n mode: \"sequential\",\n atomicity: \"none\",\n confirmation: confirmed,\n });\n }\n const contractBatch = supportsContractRenewalBatch(first.quote.route);\n stages.push({\n type: \"calls\",\n id: renewalStageId,\n calls: contractBatch\n ? [\n makeRenewalBatchIntent({\n renewals: group.map((entry) => entry.parameters),\n ...(parameters.maxTotalPrice === undefined\n ? {}\n : { maxTotalPrice: parameters.maxTotalPrice }),\n }),\n ]\n : group.map((entry) => makeRenewalIntent(entry.parameters)),\n mode: contractBatch ? \"sequential\" : (parameters.mode ?? \"auto\"),\n atomicity: contractBatch || group.length === 1 ? \"none\" : \"preferred\",\n confirmation: parameters.confirmation ?? confirmed,\n });\n groupIndex += 1;\n }\n\n const write = yield* executeWritePlan\n .effect(config, {\n plan: { id, stages },\n ...(parameters.resume === undefined ? {} : { resume: parameters.resume.write }),\n ...(parameters.walletClient === undefined ? {} : { walletClient: parameters.walletClient }),\n ...(parameters.account === undefined ? {} : { account: parameters.account }),\n })\n .pipe(\n Effect.mapError((error) =>\n error instanceof RenewalError\n ? error\n : new RenewalError({ code: \"RENEWAL_FAILED\", message: \"Unable to renew names\" }),\n ),\n );\n const completedIds = new Set(write.completedStages.map((stage) => stage.id));\n const renewals = yield* Effect.forEach(\n entries,\n Effect.fn(\"ensforge.renewNames.result\")(function* (entry) {\n const containingGroup = [...grouped.values()].findIndex((group) => group.includes(entry));\n const group = [...grouped.values()][containingGroup];\n const stageId = `renew-group-${containingGroup}`;\n const stage = write.completedStages.find((candidate) => candidate.id === stageId);\n const entryCall = group?.findIndex((candidate) => candidate === entry) ?? -1;\n const callResult =\n stage?.result.mode === \"sequential\" && entryCall >= 0\n ? stage.result.calls[entryCall]\n : undefined;\n const completed =\n completedIds.has(stageId) ||\n (group !== undefined &&\n !supportsContractRenewalBatch(entry.quote.route) &&\n callResult !== undefined &&\n callResult.status !== \"not-started\");\n if (!completed) {\n return {\n name: entry.quote.name,\n protocol: entry.quote.protocol,\n route: entry.quote.route,\n duration: entry.parameters.duration,\n previousExpiry: entry.previousExpiry,\n newExpiry: null,\n price: entry.quote.price,\n currency: entry.quote.currency,\n finalState: null,\n } satisfies RenewNamesResult[\"renewals\"][number];\n }\n const [expiry, finalState] = yield* Effect.all(\n [\n getExpiry.effect(config, { name: entry.name }),\n getNameState.effect(config, { name: entry.name }),\n ] as const,\n { concurrency: \"unbounded\" },\n );\n return {\n name: entry.quote.name,\n protocol: entry.quote.protocol,\n route: entry.quote.route,\n duration: entry.parameters.duration,\n previousExpiry: entry.previousExpiry,\n newExpiry: expiry?.expiry ?? null,\n price: entry.quote.price,\n currency: entry.quote.currency,\n finalState,\n } satisfies RenewNamesResult[\"renewals\"][number];\n }),\n );\n return {\n status: write.status === \"completed\" ? \"completed\" : \"partial\",\n renewals,\n approvals,\n totalPrice,\n write,\n };\n});\n\nexport const renewNames = defineAction<RenewNamesParameters, RenewNamesResult, WriteError>(\n renewNamesEffect,\n);\n\nexport type { RenewNamesParameters, RenewNamesResult } from \"../types.js\";\n"],"mappings":";;;;;;;;;;;;;;;;AA8BA,MAAM,YAAY,EAAE,MAAM,YAAY;AAWtC,MAAM,UAAU,YAAkC,UAChD,cAAc,UACZ,YACE,KAAK,UACH;CACE,UAAU,WAAW,SAAS,KAAK,SAAS,WAAW;EACrD,GAAG;EACH,MAAM,MAAM,UAAU,QAAQ;CAChC,EAAE;CACF,eAAe,WAAW,iBAAiB;AAC7C,IACC,MAAM,UAAoB,OAAO,UAAU,WAAW,MAAM,SAAS,IAAI,KAC5E,CACF,CACF;AAEF,MAAM,gBAAgB,UAAkE;CACtF,QAAQ,MAAM,QAAd;EACE,KAAK,iBACH,OAAO,IAAI,aAAa;GACtB,MAAM;GACN,SAAS,GAAG,MAAM,KAAK;EACzB,CAAC;EACH,KAAK,0BACH,OAAO,IAAI,aAAa;GACtB,MAAM;GACN,SAAS,wCAAwC,MAAM;EACzD,CAAC;EACH,KAAK,6BACH,OAAO,IAAI,aAAa;GACtB,MAAM;GACN,SAAS,mDAAmD,MAAM;EACpE,CAAC;EACH,SACE,OAAO,OAAO,QAAQ,KAAK;CAC/B;AACF;AAEA,MAAM,mBAAmB,OAAO,GAAG,qBAAqB,CAAC,CAAC,WACxD,QACA,YACgD;CAChD,IAAI,WAAW,SAAS,WAAW,GACjC,OAAO,OAAO,IAAI,aAAa;EAC7B,MAAM;EACN,SAAS;CACX,CAAC;CAEH,MAAM,QAAQ,OAAO,OAAO,QAAQ,WAAW,WAAW,YACxD,cAAc,OAAO,QAAQ,IAAI,CACnC;CACA,IAAI,IAAI,IAAI,KAAK,CAAC,CAAC,SAAS,MAAM,QAChC,OAAO,OAAO,IAAI,aAAa;EAC7B,MAAM;EACN,SAAS;CACX,CAAC;CAEH,MAAM,KAAK,OAAO,YAAY,KAAK;CACnC,IAAI,WAAW,QAAQ,MAAM,WAAW,aAAa;EACnD,IA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MAAM,CAAC,QAAQ,cAAc,OAAO,OAAO,IACzC,CACE,UAAU,OAAO,QAAQ,EAAE,MAAM,MAAM,KAAK,CAAC,GAC7C,aAAa,OAAO,QAAQ,EAAE,MAAM,MAAM,KAAK,CAAC,CAClD,GACA,EAAE,aAAa,YAAY,CAC7B;EACA,OAAO;GACL,MAAM,MAAM,MAAM;GAClB,UAAU,MAAM,MAAM;GACtB,OAAO,MAAM,MAAM;GACnB,UAAU,MAAM,WAAW;GAC3B,gBAAgB,MAAM;GACtB,WAAW,QAAQ,UAAU;GAC7B,OAAO,MAAM,MAAM;GACnB,UAAU,MAAM,MAAM;GACtB;EACF;CACF,CAAC,CACH;CACA,OAAO;EACL,QAAQ,MAAM,WAAW,cAAc,cAAc;EACrD;EACA;EACA;EACA;CACF;AACF,CAAC;AAED,MAAa,aAAa,aACxB,gBACF"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { CallExecutionResult, WriteError } from "../../write/types.js";
|
|
2
2
|
import { EnsWriteAction } from "../../action/write-intent.js";
|
|
3
3
|
import { ApproveRenewalPaymentParameters } from "./types.js";
|
|
4
|
-
import "./get-renewal-price/index.js";
|
|
5
4
|
import "../../index.js";
|
|
6
5
|
//#region src/actions/registration/renewal-mutation.d.ts
|
|
7
6
|
declare const approveRenewalPayment: EnsWriteAction<ApproveRenewalPaymentParameters, CallExecutionResult, WriteError>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renewal-mutation.d.ts","names":[],"sources":["../../../src/actions/registration/renewal-mutation.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"renewal-mutation.d.ts","names":[],"sources":["../../../src/actions/registration/renewal-mutation.ts"],"mappings":";;;;;cAgOa,uBAAqB,eAAA,iCAAA,qBAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { makeWriteIntent } from "../../action/write-intent.js";
|
|
2
1
|
import { ContractError } from "../../errors/contract-error.js";
|
|
3
2
|
import { viemErrorToEffectError } from "../../internal/errors/viem-error.js";
|
|
3
|
+
import { makeWriteIntent } from "../../action/write-intent.js";
|
|
4
4
|
import { makeSingleWriteAction } from "../../internal/write/single-write-action.js";
|
|
5
5
|
import { decodeOwnershipAddress } from "../ownership/address.js";
|
|
6
6
|
import { getSecondLevelEthLabel } from "../../internal/registration/second-level-eth.js";
|
|
@@ -9,12 +9,11 @@ import { RenewalError } from "../../errors/renewal-error.js";
|
|
|
9
9
|
import { Effect } from "effect";
|
|
10
10
|
import { encodeFunctionData, zeroHash } from "viem";
|
|
11
11
|
import { bulkRenewalV1RenewAllAbi, ethRegistrarControllerV1RenewAbi } from "@ensforge/contracts/v1";
|
|
12
|
-
import {
|
|
12
|
+
import { ethRegistrarV2RenewAbi, ethRenewerV1RenewAbi } from "@ensforge/contracts/v2";
|
|
13
13
|
import { erc20AllowanceAbi, erc20ApproveAbi } from "@ensforge/contracts/shared";
|
|
14
14
|
|
|
15
15
|
//#region src/actions/registration/renewal-mutation.ts
|
|
16
|
-
const
|
|
17
|
-
const supportsContractRenewalBatch = (config, route) => route === "v1-controller" || !usesFlatRenewalAbi(config);
|
|
16
|
+
const supportsContractRenewalBatch = (route) => route === "v1-controller";
|
|
18
17
|
const encode = (operation, makeData) => Effect.try({
|
|
19
18
|
try: makeData,
|
|
20
19
|
catch: (cause) => new ContractError({
|
|
@@ -113,7 +112,7 @@ const renewalPreparer = Effect.fn("ensforge.renewName.prepare")(function* (confi
|
|
|
113
112
|
});
|
|
114
113
|
return {
|
|
115
114
|
to: quote.renewer,
|
|
116
|
-
data: yield* encode("renewName", () =>
|
|
115
|
+
data: yield* encode("renewName", () => encodeFunctionData({
|
|
117
116
|
abi: quote.route === "v1-renewer" ? ethRenewerV1RenewAbi : ethRegistrarV2RenewAbi,
|
|
118
117
|
functionName: "renew",
|
|
119
118
|
args: [
|
|
@@ -122,98 +121,55 @@ const renewalPreparer = Effect.fn("ensforge.renewName.prepare")(function* (confi
|
|
|
122
121
|
currency.address,
|
|
123
122
|
referrer
|
|
124
123
|
]
|
|
125
|
-
}) : encodeFunctionData({
|
|
126
|
-
abi: quote.route === "v1-renewer" ? ethRenewerV2InterfaceRenewAbi : ethRegistrarV2InterfaceRenewAbi,
|
|
127
|
-
functionName: "renew",
|
|
128
|
-
args: [{
|
|
129
|
-
label,
|
|
130
|
-
duration: parameters.duration,
|
|
131
|
-
referrer
|
|
132
|
-
}, currency.address]
|
|
133
124
|
})),
|
|
134
125
|
value: 0n,
|
|
135
126
|
protocol: quote.protocol
|
|
136
127
|
};
|
|
137
128
|
});
|
|
138
|
-
const
|
|
129
|
+
const v1BatchRenewalPreparer = Effect.fn("ensforge.renewNames.prepareV1Batch")(function* (config, parameters) {
|
|
139
130
|
if (parameters.renewals.length === 0) return yield* new RenewalError({
|
|
140
131
|
code: "RENEWAL_FAILED",
|
|
141
132
|
message: "Renewal batch is empty"
|
|
142
133
|
});
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
-
if (first === void 0) return yield* new RenewalError({
|
|
134
|
+
const duration = parameters.renewals[0]?.duration;
|
|
135
|
+
if (duration === void 0 || parameters.renewals.some((renewal) => renewal.duration !== duration)) return yield* new RenewalError({
|
|
146
136
|
code: "RENEWAL_FAILED",
|
|
147
|
-
message: "
|
|
137
|
+
message: "ENSv1 bulk renewal requires a shared duration"
|
|
148
138
|
});
|
|
149
|
-
|
|
139
|
+
const quotes = yield* Effect.forEach(parameters.renewals, (renewal) => requireQuote(config, renewal));
|
|
140
|
+
if (quotes.some((quote) => quote.route !== "v1-controller")) return yield* new RenewalError({
|
|
150
141
|
code: "ROUTE_CHANGED",
|
|
151
|
-
message: "
|
|
142
|
+
message: "ENSv1 bulk renewal only accepts names routed through the V1 controller"
|
|
152
143
|
});
|
|
153
144
|
const total = quotes.reduce((sum, quote) => sum + quote.price, 0n);
|
|
154
145
|
if (parameters.maxTotalPrice !== void 0 && total > parameters.maxTotalPrice) return yield* new RenewalError({
|
|
155
146
|
code: "TOTAL_PRICE_EXCEEDS_MAXIMUM",
|
|
156
147
|
message: "The current renewal batch price exceeds maxTotalPrice"
|
|
157
148
|
});
|
|
158
|
-
const
|
|
159
|
-
if (
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
code: "ROUTE_CHANGED",
|
|
163
|
-
message: "The ENSv1 bulk renewal deployment is unavailable"
|
|
164
|
-
});
|
|
165
|
-
const duration = parameters.renewals[0]?.duration;
|
|
166
|
-
if (duration === void 0 || parameters.renewals.some((renewal) => renewal.duration !== duration)) return yield* new RenewalError({
|
|
167
|
-
code: "RENEWAL_FAILED",
|
|
168
|
-
message: "ENSv1 bulk renewal requires a shared duration"
|
|
169
|
-
});
|
|
170
|
-
return {
|
|
171
|
-
to: v1.contracts.bulkRenewal,
|
|
172
|
-
data: yield* encode("renewNames", () => encodeFunctionData({
|
|
173
|
-
abi: bulkRenewalV1RenewAllAbi,
|
|
174
|
-
functionName: "renewAll",
|
|
175
|
-
args: [
|
|
176
|
-
labels,
|
|
177
|
-
duration,
|
|
178
|
-
parameters.renewals[0]?.referrer ?? zeroHash
|
|
179
|
-
]
|
|
180
|
-
})),
|
|
181
|
-
value: total,
|
|
182
|
-
protocol: "v1"
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
if (!supportsContractRenewalBatch(config, first.route)) return yield* new RenewalError({
|
|
186
|
-
code: "RENEWAL_FAILED",
|
|
187
|
-
message: "The selected renewal deployment does not support contract-native batching"
|
|
188
|
-
});
|
|
189
|
-
const currency = first.currency;
|
|
190
|
-
if (currency.kind !== "erc20" || quotes.some((quote) => quote.currency.kind !== "erc20" || quote.currency.address !== currency.address)) return yield* new RenewalError({
|
|
191
|
-
code: "PAYMENT_TOKEN_UNSUPPORTED",
|
|
192
|
-
message: "All names in an ENSv2 renewal batch must use the same payment token"
|
|
193
|
-
});
|
|
194
|
-
const account = typeof context.account === "string" ? context.account : context.account.address;
|
|
195
|
-
if ((yield* readAllowance(config, currency.address, first.renewer, account)) < total) return yield* new RenewalError({
|
|
196
|
-
code: "INSUFFICIENT_ALLOWANCE",
|
|
197
|
-
message: "Payment-token allowance is insufficient for the renewal batch"
|
|
149
|
+
const v1 = config.deployments.v1;
|
|
150
|
+
if (v1 === void 0) return yield* new RenewalError({
|
|
151
|
+
code: "ROUTE_CHANGED",
|
|
152
|
+
message: "The ENSv1 bulk renewal deployment is unavailable"
|
|
198
153
|
});
|
|
154
|
+
const labels = yield* Effect.forEach(quotes, (quote) => getSecondLevelEthLabel(quote.name));
|
|
199
155
|
return {
|
|
200
|
-
to:
|
|
156
|
+
to: v1.contracts.bulkRenewal,
|
|
201
157
|
data: yield* encode("renewNames", () => encodeFunctionData({
|
|
202
|
-
abi:
|
|
203
|
-
functionName: "
|
|
204
|
-
args: [
|
|
205
|
-
|
|
206
|
-
duration
|
|
207
|
-
|
|
208
|
-
|
|
158
|
+
abi: bulkRenewalV1RenewAllAbi,
|
|
159
|
+
functionName: "renewAll",
|
|
160
|
+
args: [
|
|
161
|
+
labels,
|
|
162
|
+
duration,
|
|
163
|
+
parameters.renewals[0]?.referrer ?? zeroHash
|
|
164
|
+
]
|
|
209
165
|
})),
|
|
210
|
-
value:
|
|
211
|
-
protocol:
|
|
166
|
+
value: total,
|
|
167
|
+
protocol: "v1"
|
|
212
168
|
};
|
|
213
169
|
});
|
|
214
170
|
const approveRenewalPayment = makeSingleWriteAction("approveRenewalPayment", approvalPreparer);
|
|
215
171
|
const makeRenewalIntent = (parameters) => makeWriteIntent("renewName", parameters, renewalPreparer);
|
|
216
|
-
const makeRenewalBatchIntent = (parameters) => makeWriteIntent("renewNames", parameters,
|
|
172
|
+
const makeRenewalBatchIntent = (parameters) => makeWriteIntent("renewNames", parameters, v1BatchRenewalPreparer);
|
|
217
173
|
|
|
218
174
|
//#endregion
|
|
219
175
|
export { approveRenewalPayment, makeRenewalBatchIntent, makeRenewalIntent, supportsContractRenewalBatch };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renewal-mutation.js","names":[],"sources":["../../../src/actions/registration/renewal-mutation.ts"],"sourcesContent":["import { Effect } from \"effect\";\n\nimport { erc20AllowanceAbi, erc20ApproveAbi } from \"@ensforge/contracts/shared\";\nimport { bulkRenewalV1RenewAllAbi, ethRegistrarControllerV1RenewAbi } from \"@ensforge/contracts/v1\";\nimport {\n ethRegistrarV2InterfaceRenewBatchAbi,\n ethRegistrarV2InterfaceRenewAbi,\n ethRegistrarV2RenewAbi,\n ethRenewerV1RenewAbi,\n ethRenewerV2InterfaceRenewBatchAbi,\n ethRenewerV2InterfaceRenewAbi,\n} from \"@ensforge/contracts/v2\";\nimport { encodeFunctionData, zeroHash } from \"viem\";\n\nimport {\n makeWriteIntent,\n type EnsWriteIntent,\n type EnsWriteIntentPreparer,\n} from \"../../action/write-intent.js\";\nimport { ContractError } from \"../../errors/contract-error.js\";\nimport { RenewalError } from \"../../errors/renewal-error.js\";\nimport { viemErrorToEffectError } from \"../../internal/errors/viem-error.js\";\nimport { getSecondLevelEthLabel } from \"../../internal/registration/second-level-eth.js\";\nimport { makeSingleWriteAction } from \"../../internal/write/single-write-action.js\";\nimport type { CallExecutionResult, WriteError } from \"../../write/types.js\";\nimport { decodeOwnershipAddress } from \"../ownership/address.js\";\nimport { getRenewalPrice } from \"./get-renewal-price/index.js\";\nimport type { ApproveRenewalPaymentParameters, RenewNameCallParameters } from \"./types.js\";\n\nexport interface RenewBatchCallParameters {\n readonly renewals: ReadonlyArray<RenewNameCallParameters>;\n readonly maxTotalPrice?: bigint;\n}\n\nconst usesFlatRenewalAbi = (config: Parameters<typeof getRenewalPrice.effect>[0]) =>\n // The July Sepolia beta predates the tuple-based renewals and registrar-level batch methods.\n config.deployments.protocol === \"v2\" && config.deployments.v2.id === \"sepolia-v2\";\n\nexport const supportsContractRenewalBatch = (\n config: Parameters<typeof getRenewalPrice.effect>[0],\n route: \"v1-controller\" | \"v1-renewer\" | \"v2-registrar\",\n) => route === \"v1-controller\" || !usesFlatRenewalAbi(config);\n\nconst encode = (operation: string, makeData: () => `0x${string}`) =>\n Effect.try({\n try: makeData,\n catch: (cause) =>\n new ContractError({ code: \"ENCODE_FAILED\", message: `Unable to encode ${operation}`, cause }),\n });\n\nconst requireQuote = Effect.fn(\"ensforge.renewal.requireQuote\")(function* (\n config: Parameters<typeof getRenewalPrice.effect>[0],\n parameters: RenewNameCallParameters,\n) {\n const quote = yield* getRenewalPrice.effect(config, parameters);\n switch (quote.status) {\n case \"not-renewable\":\n return yield* new RenewalError({\n code: \"NAME_NOT_RENEWABLE\",\n message: `${quote.name} is not renewable`,\n });\n case \"payment-token-required\":\n return yield* new RenewalError({\n code: \"PAYMENT_TOKEN_REQUIRED\",\n message: `A payment token is required to renew ${quote.name}`,\n });\n case \"unsupported-payment-token\":\n return yield* new RenewalError({\n code: \"PAYMENT_TOKEN_UNSUPPORTED\",\n message: `The selected payment token is not supported for ${quote.name}`,\n });\n default:\n if (parameters.maxPrice !== undefined && quote.price > parameters.maxPrice) {\n return yield* new RenewalError({\n code: \"PRICE_EXCEEDS_MAXIMUM\",\n message: `The current renewal price for ${quote.name} exceeds maxPrice`,\n });\n }\n return quote;\n }\n});\n\nconst readAllowance = Effect.fn(\"ensforge.renewal.readAllowance\")(function* (\n config: Parameters<typeof getRenewalPrice.effect>[0],\n token: `0x${string}`,\n spender: `0x${string}`,\n account: `0x${string}`,\n) {\n return yield* Effect.tryPromise({\n try: () =>\n config.publicClient.readContract({\n address: token,\n abi: erc20AllowanceAbi,\n functionName: \"allowance\",\n args: [account, spender],\n }),\n catch: (cause) => viemErrorToEffectError(cause, \"readContract\"),\n });\n});\n\nconst approvalPreparer: EnsWriteIntentPreparer<ApproveRenewalPaymentParameters, WriteError> =\n Effect.fn(\"ensforge.approveRenewalPayment.prepare\")(function* (config, parameters) {\n if (parameters.amount < 0n) {\n return yield* new RenewalError({\n code: \"RENEWAL_FAILED\",\n message: \"Renewal payment approval amount cannot be negative\",\n });\n }\n const paymentToken = yield* decodeOwnershipAddress(parameters.paymentToken, \"payment token\");\n const quote = yield* requireQuote(config, {\n name: parameters.name,\n duration: parameters.duration,\n paymentToken,\n });\n if (quote.currency.kind !== \"erc20\") {\n return yield* new RenewalError({\n code: \"PAYMENT_TOKEN_UNSUPPORTED\",\n message: \"ENSv1 renewal uses native ETH and does not accept payment tokens\",\n });\n }\n return {\n to: paymentToken,\n data: yield* encode(\"approveRenewalPayment\", () =>\n encodeFunctionData({\n abi: erc20ApproveAbi,\n functionName: \"approve\",\n args: [quote.renewer, parameters.amount],\n }),\n ),\n value: 0n,\n protocol: quote.protocol,\n };\n });\n\nconst renewalPreparer: EnsWriteIntentPreparer<RenewNameCallParameters, WriteError> = Effect.fn(\n \"ensforge.renewName.prepare\",\n)(function* (config, parameters, context) {\n const quote = yield* requireQuote(config, parameters);\n const label = yield* getSecondLevelEthLabel(quote.name);\n const referrer = parameters.referrer ?? zeroHash;\n if (quote.route === \"v1-controller\") {\n return {\n to: quote.renewer,\n data: yield* encode(\"renewName\", () =>\n encodeFunctionData({\n abi: ethRegistrarControllerV1RenewAbi,\n functionName: \"renew\",\n args: [label, parameters.duration, referrer],\n }),\n ),\n value: quote.price,\n protocol: \"v1\" as const,\n };\n }\n if (quote.currency.kind !== \"erc20\") {\n return yield* new RenewalError({\n code: \"PAYMENT_TOKEN_REQUIRED\",\n message: `An ERC-20 payment token is required to renew ${quote.name}`,\n });\n }\n const currency = quote.currency;\n const account = typeof context.account === \"string\" ? context.account : context.account.address;\n const allowance = yield* readAllowance(config, currency.address, quote.renewer, account);\n if (allowance < quote.price) {\n return yield* new RenewalError({\n code: \"INSUFFICIENT_ALLOWANCE\",\n message: `Payment-token allowance is insufficient to renew ${quote.name}`,\n });\n }\n return {\n to: quote.renewer,\n data: yield* encode(\"renewName\", () =>\n usesFlatRenewalAbi(config)\n ? encodeFunctionData({\n abi: quote.route === \"v1-renewer\" ? ethRenewerV1RenewAbi : ethRegistrarV2RenewAbi,\n functionName: \"renew\",\n args: [label, parameters.duration, currency.address, referrer],\n })\n : encodeFunctionData({\n abi:\n quote.route === \"v1-renewer\"\n ? ethRenewerV2InterfaceRenewAbi\n : ethRegistrarV2InterfaceRenewAbi,\n functionName: \"renew\",\n args: [{ label, duration: parameters.duration, referrer }, currency.address],\n }),\n ),\n value: 0n,\n protocol: quote.protocol,\n };\n});\n\nconst batchRenewalPreparer: EnsWriteIntentPreparer<RenewBatchCallParameters, WriteError> =\n Effect.fn(\"ensforge.renewNames.prepareBatch\")(function* (config, parameters, context) {\n if (parameters.renewals.length === 0) {\n return yield* new RenewalError({ code: \"RENEWAL_FAILED\", message: \"Renewal batch is empty\" });\n }\n const quotes = yield* Effect.forEach(parameters.renewals, (renewal) =>\n requireQuote(config, renewal),\n );\n const first = quotes[0];\n if (first === undefined) {\n return yield* new RenewalError({ code: \"RENEWAL_FAILED\", message: \"Renewal batch is empty\" });\n }\n if (quotes.some((quote) => quote.route !== first.route || quote.renewer !== first.renewer)) {\n return yield* new RenewalError({\n code: \"ROUTE_CHANGED\",\n message: \"All names in a renewal batch must use the same renewal contract\",\n });\n }\n const total = quotes.reduce((sum, quote) => sum + quote.price, 0n);\n if (parameters.maxTotalPrice !== undefined && total > parameters.maxTotalPrice) {\n return yield* new RenewalError({\n code: \"TOTAL_PRICE_EXCEEDS_MAXIMUM\",\n message: \"The current renewal batch price exceeds maxTotalPrice\",\n });\n }\n const labels = yield* Effect.forEach(quotes, (quote) => getSecondLevelEthLabel(quote.name));\n if (first.route === \"v1-controller\") {\n const v1 = config.deployments.v1;\n if (v1 === undefined) {\n return yield* new RenewalError({\n code: \"ROUTE_CHANGED\",\n message: \"The ENSv1 bulk renewal deployment is unavailable\",\n });\n }\n const duration = parameters.renewals[0]?.duration;\n if (\n duration === undefined ||\n parameters.renewals.some((renewal) => renewal.duration !== duration)\n ) {\n return yield* new RenewalError({\n code: \"RENEWAL_FAILED\",\n message: \"ENSv1 bulk renewal requires a shared duration\",\n });\n }\n return {\n to: v1.contracts.bulkRenewal,\n data: yield* encode(\"renewNames\", () =>\n encodeFunctionData({\n abi: bulkRenewalV1RenewAllAbi,\n functionName: \"renewAll\",\n args: [labels, duration, parameters.renewals[0]?.referrer ?? zeroHash],\n }),\n ),\n value: total,\n protocol: \"v1\" as const,\n };\n }\n if (!supportsContractRenewalBatch(config, first.route)) {\n return yield* new RenewalError({\n code: \"RENEWAL_FAILED\",\n message: \"The selected renewal deployment does not support contract-native batching\",\n });\n }\n const currency = first.currency;\n if (\n currency.kind !== \"erc20\" ||\n quotes.some(\n (quote) => quote.currency.kind !== \"erc20\" || quote.currency.address !== currency.address,\n )\n ) {\n return yield* new RenewalError({\n code: \"PAYMENT_TOKEN_UNSUPPORTED\",\n message: \"All names in an ENSv2 renewal batch must use the same payment token\",\n });\n }\n const account = typeof context.account === \"string\" ? context.account : context.account.address;\n const allowance = yield* readAllowance(config, currency.address, first.renewer, account);\n if (allowance < total) {\n return yield* new RenewalError({\n code: \"INSUFFICIENT_ALLOWANCE\",\n message: \"Payment-token allowance is insufficient for the renewal batch\",\n });\n }\n return {\n to: first.renewer,\n data: yield* encode(\"renewNames\", () =>\n encodeFunctionData({\n abi:\n first.route === \"v1-renewer\"\n ? ethRenewerV2InterfaceRenewBatchAbi\n : ethRegistrarV2InterfaceRenewBatchAbi,\n functionName: \"renewBatch\",\n args: [\n parameters.renewals.map((renewal, index) => ({\n label: labels[index] ?? \"\",\n duration: renewal.duration,\n referrer: renewal.referrer ?? zeroHash,\n })),\n currency.address,\n ],\n }),\n ),\n value: 0n,\n protocol: first.protocol,\n };\n });\n\nexport const approveRenewalPayment = makeSingleWriteAction(\n \"approveRenewalPayment\",\n approvalPreparer,\n);\n\nexport const makeRenewalIntent = (\n parameters: RenewNameCallParameters,\n): EnsWriteIntent<CallExecutionResult, WriteError> =>\n makeWriteIntent(\"renewName\", parameters, renewalPreparer);\n\nexport const makeRenewalBatchIntent = (\n parameters: RenewBatchCallParameters,\n): EnsWriteIntent<CallExecutionResult, WriteError> =>\n makeWriteIntent(\"renewNames\", parameters, batchRenewalPreparer);\n"],"mappings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QAAQ;IAClB,UAAU,QAAQ,YAAY;GAChC,EAAE,GACF,SAAS,OACX;EACF,CAAC,CACH;EACA,OAAO;EACP,UAAU,MAAM;CAClB;AACF,CAAC;AAEH,MAAa,wBAAwB,sBACnC,yBACA,gBACF;AAEA,MAAa,qBACX,eAEA,gBAAgB,aAAa,YAAY,eAAe;AAE1D,MAAa,0BACX,eAEA,gBAAgB,cAAc,YAAY,oBAAoB"}
|
|
1
|
+
{"version":3,"file":"renewal-mutation.js","names":[],"sources":["../../../src/actions/registration/renewal-mutation.ts"],"sourcesContent":["import { Effect } from \"effect\";\n\nimport { erc20AllowanceAbi, erc20ApproveAbi } from \"@ensforge/contracts/shared\";\nimport { bulkRenewalV1RenewAllAbi, ethRegistrarControllerV1RenewAbi } from \"@ensforge/contracts/v1\";\nimport { ethRegistrarV2RenewAbi, ethRenewerV1RenewAbi } from \"@ensforge/contracts/v2\";\nimport { encodeFunctionData, zeroHash } from \"viem\";\n\nimport {\n makeWriteIntent,\n type EnsWriteIntent,\n type EnsWriteIntentPreparer,\n} from \"../../action/write-intent.js\";\nimport { ContractError } from \"../../errors/contract-error.js\";\nimport { RenewalError } from \"../../errors/renewal-error.js\";\nimport { viemErrorToEffectError } from \"../../internal/errors/viem-error.js\";\nimport { getSecondLevelEthLabel } from \"../../internal/registration/second-level-eth.js\";\nimport { makeSingleWriteAction } from \"../../internal/write/single-write-action.js\";\nimport type { CallExecutionResult, WriteError } from \"../../write/types.js\";\nimport { decodeOwnershipAddress } from \"../ownership/address.js\";\nimport { getRenewalPrice } from \"./get-renewal-price/index.js\";\nimport type { ApproveRenewalPaymentParameters, RenewNameCallParameters } from \"./types.js\";\n\nexport const supportsContractRenewalBatch = (\n route: \"v1-controller\" | \"v1-renewer\" | \"v2-registrar\",\n) => route === \"v1-controller\";\n\nexport interface RenewBatchCallParameters {\n readonly renewals: ReadonlyArray<RenewNameCallParameters>;\n readonly maxTotalPrice?: bigint;\n}\n\nconst encode = (operation: string, makeData: () => `0x${string}`) =>\n Effect.try({\n try: makeData,\n catch: (cause) =>\n new ContractError({ code: \"ENCODE_FAILED\", message: `Unable to encode ${operation}`, cause }),\n });\n\nconst requireQuote = Effect.fn(\"ensforge.renewal.requireQuote\")(function* (\n config: Parameters<typeof getRenewalPrice.effect>[0],\n parameters: RenewNameCallParameters,\n) {\n const quote = yield* getRenewalPrice.effect(config, parameters);\n switch (quote.status) {\n case \"not-renewable\":\n return yield* new RenewalError({\n code: \"NAME_NOT_RENEWABLE\",\n message: `${quote.name} is not renewable`,\n });\n case \"payment-token-required\":\n return yield* new RenewalError({\n code: \"PAYMENT_TOKEN_REQUIRED\",\n message: `A payment token is required to renew ${quote.name}`,\n });\n case \"unsupported-payment-token\":\n return yield* new RenewalError({\n code: \"PAYMENT_TOKEN_UNSUPPORTED\",\n message: `The selected payment token is not supported for ${quote.name}`,\n });\n default:\n if (parameters.maxPrice !== undefined && quote.price > parameters.maxPrice) {\n return yield* new RenewalError({\n code: \"PRICE_EXCEEDS_MAXIMUM\",\n message: `The current renewal price for ${quote.name} exceeds maxPrice`,\n });\n }\n return quote;\n }\n});\n\nconst readAllowance = Effect.fn(\"ensforge.renewal.readAllowance\")(function* (\n config: Parameters<typeof getRenewalPrice.effect>[0],\n token: `0x${string}`,\n spender: `0x${string}`,\n account: `0x${string}`,\n) {\n return yield* Effect.tryPromise({\n try: () =>\n config.publicClient.readContract({\n address: token,\n abi: erc20AllowanceAbi,\n functionName: \"allowance\",\n args: [account, spender],\n }),\n catch: (cause) => viemErrorToEffectError(cause, \"readContract\"),\n });\n});\n\nconst approvalPreparer: EnsWriteIntentPreparer<ApproveRenewalPaymentParameters, WriteError> =\n Effect.fn(\"ensforge.approveRenewalPayment.prepare\")(function* (config, parameters) {\n if (parameters.amount < 0n) {\n return yield* new RenewalError({\n code: \"RENEWAL_FAILED\",\n message: \"Renewal payment approval amount cannot be negative\",\n });\n }\n const paymentToken = yield* decodeOwnershipAddress(parameters.paymentToken, \"payment token\");\n const quote = yield* requireQuote(config, {\n name: parameters.name,\n duration: parameters.duration,\n paymentToken,\n });\n if (quote.currency.kind !== \"erc20\") {\n return yield* new RenewalError({\n code: \"PAYMENT_TOKEN_UNSUPPORTED\",\n message: \"ENSv1 renewal uses native ETH and does not accept payment tokens\",\n });\n }\n return {\n to: paymentToken,\n data: yield* encode(\"approveRenewalPayment\", () =>\n encodeFunctionData({\n abi: erc20ApproveAbi,\n functionName: \"approve\",\n args: [quote.renewer, parameters.amount],\n }),\n ),\n value: 0n,\n protocol: quote.protocol,\n };\n });\n\nconst renewalPreparer: EnsWriteIntentPreparer<RenewNameCallParameters, WriteError> = Effect.fn(\n \"ensforge.renewName.prepare\",\n)(function* (config, parameters, context) {\n const quote = yield* requireQuote(config, parameters);\n const label = yield* getSecondLevelEthLabel(quote.name);\n const referrer = parameters.referrer ?? zeroHash;\n if (quote.route === \"v1-controller\") {\n return {\n to: quote.renewer,\n data: yield* encode(\"renewName\", () =>\n encodeFunctionData({\n abi: ethRegistrarControllerV1RenewAbi,\n functionName: \"renew\",\n args: [label, parameters.duration, referrer],\n }),\n ),\n value: quote.price,\n protocol: \"v1\" as const,\n };\n }\n if (quote.currency.kind !== \"erc20\") {\n return yield* new RenewalError({\n code: \"PAYMENT_TOKEN_REQUIRED\",\n message: `An ERC-20 payment token is required to renew ${quote.name}`,\n });\n }\n const currency = quote.currency;\n const account = typeof context.account === \"string\" ? context.account : context.account.address;\n const allowance = yield* readAllowance(config, currency.address, quote.renewer, account);\n if (allowance < quote.price) {\n return yield* new RenewalError({\n code: \"INSUFFICIENT_ALLOWANCE\",\n message: `Payment-token allowance is insufficient to renew ${quote.name}`,\n });\n }\n return {\n to: quote.renewer,\n data: yield* encode(\"renewName\", () =>\n encodeFunctionData({\n abi: quote.route === \"v1-renewer\" ? ethRenewerV1RenewAbi : ethRegistrarV2RenewAbi,\n functionName: \"renew\",\n args: [label, parameters.duration, currency.address, referrer],\n }),\n ),\n value: 0n,\n protocol: quote.protocol,\n };\n});\n\nconst v1BatchRenewalPreparer: EnsWriteIntentPreparer<RenewBatchCallParameters, WriteError> =\n Effect.fn(\"ensforge.renewNames.prepareV1Batch\")(function* (config, parameters) {\n if (parameters.renewals.length === 0) {\n return yield* new RenewalError({ code: \"RENEWAL_FAILED\", message: \"Renewal batch is empty\" });\n }\n const duration = parameters.renewals[0]?.duration;\n if (\n duration === undefined ||\n parameters.renewals.some((renewal) => renewal.duration !== duration)\n ) {\n return yield* new RenewalError({\n code: \"RENEWAL_FAILED\",\n message: \"ENSv1 bulk renewal requires a shared duration\",\n });\n }\n const quotes = yield* Effect.forEach(parameters.renewals, (renewal) =>\n requireQuote(config, renewal),\n );\n if (quotes.some((quote) => quote.route !== \"v1-controller\")) {\n return yield* new RenewalError({\n code: \"ROUTE_CHANGED\",\n message: \"ENSv1 bulk renewal only accepts names routed through the V1 controller\",\n });\n }\n const total = quotes.reduce((sum, quote) => sum + quote.price, 0n);\n if (parameters.maxTotalPrice !== undefined && total > parameters.maxTotalPrice) {\n return yield* new RenewalError({\n code: \"TOTAL_PRICE_EXCEEDS_MAXIMUM\",\n message: \"The current renewal batch price exceeds maxTotalPrice\",\n });\n }\n const v1 = config.deployments.v1;\n if (v1 === undefined) {\n return yield* new RenewalError({\n code: \"ROUTE_CHANGED\",\n message: \"The ENSv1 bulk renewal deployment is unavailable\",\n });\n }\n const labels = yield* Effect.forEach(quotes, (quote) => getSecondLevelEthLabel(quote.name));\n return {\n to: v1.contracts.bulkRenewal,\n data: yield* encode(\"renewNames\", () =>\n encodeFunctionData({\n abi: bulkRenewalV1RenewAllAbi,\n functionName: \"renewAll\",\n args: [labels, duration, parameters.renewals[0]?.referrer ?? zeroHash],\n }),\n ),\n value: total,\n protocol: \"v1\" as const,\n };\n });\n\nexport const approveRenewalPayment = makeSingleWriteAction(\n \"approveRenewalPayment\",\n approvalPreparer,\n);\n\nexport const makeRenewalIntent = (\n parameters: RenewNameCallParameters,\n): EnsWriteIntent<CallExecutionResult, WriteError> =>\n makeWriteIntent(\"renewName\", parameters, renewalPreparer);\n\nexport const makeRenewalBatchIntent = (\n parameters: RenewBatchCallParameters,\n): EnsWriteIntent<CallExecutionResult, WriteError> =>\n makeWriteIntent(\"renewNames\", parameters, v1BatchRenewalPreparer);\n"],"mappings":";;;;;;;;;;;;;;;AAsBA,MAAa,gCACX,UACG,UAAU;AAOf,MAAM,UAAU,WAAmB,aACjC,OAAO,IAAI;CACT,KAAK;CACL,QAAQ,UACN,IAAI,cAAc;EAAE,MAAM;EAAiB,SAAS,oBAAoB;EAAa;CAAM,CAAC;AAChG,CAAC;AAEH,MAAM,eAAe,OAAO,GAAG,+BAA+B,CAAC,CAAC,WAC9D,QACA,YACA;CACA,MAAM,QAAQ,OAAO,gBAAgB,OAAO,QAAQ,UAAU;CAC9D,QAAQ,MAAM,QAAd;EACE,KAAK,iBACH,OAAO,OAAO,IAAI,aAAa;GAC7B,MAAM;GACN,SAAS,GAAG,MAAM,KAAK;EACzB,CAAC;EACH,KAAK,0BACH,OAAO,OAAO,IAAI,aAAa;GAC7B,MAAM;GACN,SAAS,wCAAwC,MAAM;EACzD,CAAC;EACH,KAAK,6BACH,OAAO,OAAO,IAAI,aAAa;GAC7B,MAAM;GACN,SAAS,mDAAmD,MAAM;EACpE,CAAC;EACH;GACE,IAAI,WAAW,aAAa,UAAa,MAAM,QAAQ,WAAW,UAChE,OAAO,OAAO,IAAI,aAAa;IAC7B,MAAM;IACN,SAAS,iCAAiC,MAAM,KAAK;GACvD,CAAC;GAEH,OAAO;CACX;AACF,CAAC;AAED,MAAM,gBAAgB,OAAO,GAAG,gCAAgC,CAAC,CAAC,WAChE,QACA,OACA,SACA,SACA;CACA,OAAO,OAAO,OAAO,WAAW;EAC9B,WACE,OAAO,aAAa,aAAa;GAC/B,SAAS;GACT,KAAK;GACL,cAAc;GACd,MAAM,CAAC,SAAS,OAAO;EACzB,CAAC;EACH,QAAQ,UAAU,uBAAuB,OAAO,cAAc;CAChE,CAAC;AACH,CAAC;AAED,MAA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AAuB,MAAM,IAAI,CAAC;CAC1F,OAAO;EACL,IAAI,GAAG,UAAU;EACjB,MAAM,OAAO,OAAO,oBAClB,mBAAmB;GACjB,KAAK;GACL,cAAc;GACd,MAAM;IAAC;IAAQ;IAAU,WAAW,SAAS,EAAE,EAAE,YAAY;GAAQ;EACvE,CAAC,CACH;EACA,OAAO;EACP,UAAU;CACZ;AACF,CAAC;AAEH,MAAa,wBAAwB,sBACnC,yBACA,gBACF;AAEA,MAAa,qBACX,eAEA,gBAAgB,aAAa,YAAY,eAAe;AAE1D,MAAa,0BACX,eAEA,gBAAgB,cAAc,YAAY,sBAAsB"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { EnsProtocol } from "../../schemas/protocol.js";
|
|
2
2
|
import { ConfirmationPolicy } from "../../config/write-options.js";
|
|
3
3
|
import { EnsAction } from "../../action/action.js";
|
|
4
|
+
import { RpcError } from "../../errors/rpc-error.js";
|
|
4
5
|
import { BlockParameters } from "../../action/block.js";
|
|
5
|
-
import { CodecError } from "../../errors/codec-error.js";
|
|
6
6
|
import { ContractError } from "../../errors/contract-error.js";
|
|
7
|
+
import { CodecError } from "../../errors/codec-error.js";
|
|
7
8
|
import { NameError } from "../../errors/name-error.js";
|
|
8
|
-
import { RpcError } from "../../errors/rpc-error.js";
|
|
9
9
|
import { CallExecutionResult, WriteError, WriteMode, WritePlanProgress } from "../../write/types.js";
|
|
10
10
|
import { EnsWriteIntent } from "../../action/write-intent.js";
|
|
11
11
|
import { EthereumAddress } from "../../schemas/identity.js";
|
|
@@ -414,5 +414,5 @@ interface RenewNamesResult {
|
|
|
414
414
|
readonly write: WritePlanProgress;
|
|
415
415
|
}
|
|
416
416
|
//#endregion
|
|
417
|
-
export { ApprovePaymentTokenParameters, ApproveRenewalPaymentParameters, AvailableRegistrationPrice, CommitNameParameters, CommitmentStatus, CompleteRegistrationParameters, Erc20PaymentCurrency, NativePaymentCurrency, PaymentCurrency, PaymentTokenSupport, RegisterNameParameters, RegisterNameResult, RegisterNamesEntryParameters, RegisterNamesParameters, RegisterNamesResult, RegistrationCommitment, RegistrationCommitmentParameters, RegistrationNameParameters, RegistrationParameters, RegistrationPlan, RegistrationPriceParameters, RegistrationPriceResult, RegistrationReadError, RegistrationWriteError, RegistrationWriteIntent, RegistrationWriteResult, RenewNameAction, RenewNameCallParameters, RenewNameParameters, RenewNameResult, RenewNamesEntryParameters, RenewNamesParameters, RenewNamesResult, RenewalApproval, RenewalPriceResult, RenewalRoute };
|
|
417
|
+
export { ApprovePaymentTokenParameters, ApproveRenewalPaymentParameters, AvailableRegistrationPrice, CommitNameParameters, CommitmentStatus, CompleteRegistrationParameters, Erc20PaymentCurrency, NativePaymentCurrency, PaymentCurrency, PaymentTokenSupport, RegisterNameParameters, RegisterNameResult, RegisterNamesEntryParameters, RegisterNamesParameters, RegisterNamesResult, RegistrationCommitment, RegistrationCommitmentParameters, RegistrationNameParameters, RegistrationParameters, RegistrationPlan, RegistrationPriceParameters, RegistrationPriceResult, RegistrationReadError, RegistrationWalletParameters, RegistrationWriteError, RegistrationWriteIntent, RegistrationWriteResult, RenewNameAction, RenewNameCallParameters, RenewNameParameters, RenewNameResult, RenewNamesEntryParameters, RenewNamesParameters, RenewNamesResult, RenewalApproval, RenewalPriceResult, RenewalRoute };
|
|
418
418
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/actions/registration/types.ts"],"mappings":";;;;;;;;;;;;;;;;;;;KA0BY,wBAAwB,aAAa,gBAAgB,YAAY;KAEjE;WACD;WACA;IACP;KAEQ,8BAA8B;WAC/B,eAAe;;cAGb,uBAAqB,OAAA;;;;;cAMrB,sBAAoB,OAAA;;;;;;cAOpB,iBAAe,OAAA,gBAAA,OAAA;;;;;;;;;;KAChB,yBAAyB,gBAAgB;cAexC,yBAAuB,OAAA,gBAAA,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA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pC,yBACA;KAGU;WACD;WACA;WACA,eAAe;WACf;WACA,WAAW;;UAGL;WACN;WACA;WACA;WACA;;KAGC,sBAAsB,0BAChC;WACW,SAAS;;UAGL;WACN;WACA,SAAS;WACT,OAAO;WACP;;UAGM;WACN;WACA,MAAM;WACN,iBAAiB,YAAY;WAC7B,OAAO;WACP;WACA;WACA;WACA;WACA,UAAU;WACV,UAAU;WACV,OAAO;WACP,YAAY;;UAGN,wBAAwB,UACvC,qBACA,iBACA;WAES,OACP,YAAY,4BACT,eAAe,qBAAqB;;KAG/B,4BAA4B;UAEvB,6BAA6B;WACnC,UAAU,cAAc;WACxB;WACA,SAAS;;UAGH;WACN;WACA,UAAU,cACjB,KAAK;aACM;aACA,YAAY;;WAGhB,WAAW,cAAc;WACzB;WACA,OAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../src/actions/registration/types.ts"],"sourcesContent":["import { Schema } from \"effect\";\n\nimport type { Account, Address, WalletClient } from \"viem\";\n\nimport type { EnsAction } from \"../../action/action.js\";\nimport type { BlockParameters } from \"../../action/block.js\";\nimport type { EnsWriteIntent } from \"../../action/write-intent.js\";\nimport type { CodecError } from \"../../errors/codec-error.js\";\nimport type { ContractError } from \"../../errors/contract-error.js\";\nimport type { NameError } from \"../../errors/name-error.js\";\nimport type { RpcError } from \"../../errors/rpc-error.js\";\nimport { Bytes32 } from \"../../schemas/hash.js\";\nimport type { Hex } from \"../../schemas/hex.js\";\nimport { EthereumAddress } from \"../../schemas/identity.js\";\nimport { NormalizedName } from \"../../schemas/name.js\";\nimport { EnsProtocol } from \"../../schemas/protocol.js\";\nimport type {\n CallExecutionResult,\n ConfirmationPolicy,\n WriteError,\n WriteMode,\n WritePlanProgress,\n} from \"../../write/types.js\";\nimport type { NameState } from \"../name/get-name-state/types.js\";\nimport type { SetRecordInput } from \"../records/set-records/types.js\";\n\nexport type RegistrationReadError = CodecError | ContractError | NameError | RpcError;\n\nexport type RegistrationNameParameters = {\n readonly name: string;\n readonly duration: bigint;\n} & BlockParameters;\n\nexport type RegistrationPriceParameters = RegistrationNameParameters & {\n readonly paymentToken?: EthereumAddress;\n};\n\nexport const NativePaymentCurrency = Schema.Struct({\n kind: Schema.Literal(\"native\"),\n symbol: Schema.Literal(\"ETH\"),\n decimals: Schema.Literal(18),\n});\n\nexport const Erc20PaymentCurrency = Schema.Struct({\n kind: Schema.Literal(\"erc20\"),\n address: EthereumAddress,\n symbol: Schema.String,\n decimals: Schema.Int,\n});\n\nexport const PaymentCurrency = Schema.Union([NativePaymentCurrency, Erc20PaymentCurrency]);\nexport type PaymentCurrency = typeof PaymentCurrency.Type;\n\nconst PaymentTokenRequired = Schema.Struct({\n status: Schema.Literal(\"payment-token-required\"),\n name: NormalizedName,\n protocol: EnsProtocol,\n});\n\nconst UnsupportedPaymentToken = Schema.Struct({\n status: Schema.Literal(\"unsupported-payment-token\"),\n name: NormalizedName,\n protocol: EnsProtocol,\n paymentToken: EthereumAddress,\n});\n\nexport const RegistrationPriceResult = Schema.Union([\n Schema.Struct({\n status: Schema.Literal(\"available\"),\n name: NormalizedName,\n protocol: EnsProtocol,\n registrar: EthereumAddress,\n duration: Schema.BigInt,\n base: Schema.BigInt,\n premium: Schema.BigInt,\n total: Schema.BigInt,\n currency: PaymentCurrency,\n }),\n Schema.Struct({\n status: Schema.Literal(\"unavailable\"),\n name: NormalizedName,\n protocol: EnsProtocol,\n reason: Schema.Literal(\"NAME_UNAVAILABLE\"),\n }),\n PaymentTokenRequired,\n UnsupportedPaymentToken,\n]);\nexport type RegistrationPriceResult = typeof RegistrationPriceResult.Type;\n\nexport const RenewalRoute = Schema.Literals([\"v1-controller\", \"v2-registrar\", \"v1-renewer\"]);\nexport type RenewalRoute = typeof RenewalRoute.Type;\n\nexport const RenewalPriceResult = Schema.Union([\n Schema.Struct({\n status: Schema.Literal(\"renewable\"),\n name: NormalizedName,\n protocol: EnsProtocol,\n route: RenewalRoute,\n renewer: EthereumAddress,\n duration: Schema.BigInt,\n price: Schema.BigInt,\n currency: PaymentCurrency,\n }),\n Schema.Struct({\n status: Schema.Literal(\"not-renewable\"),\n name: NormalizedName,\n protocol: EnsProtocol,\n reason: Schema.Literal(\"NAME_NOT_RENEWABLE\"),\n }),\n PaymentTokenRequired,\n UnsupportedPaymentToken,\n]);\nexport type RenewalPriceResult = typeof RenewalPriceResult.Type;\n\nexport const RegistrationParameters = Schema.Union([\n Schema.Struct({\n protocol: Schema.Literal(\"v1\"),\n registrar: EthereumAddress,\n priceOracle: EthereumAddress,\n minimumRegistrationDuration: Schema.BigInt,\n minimumRenewalDuration: Schema.BigInt,\n minimumCommitmentAge: Schema.BigInt,\n maximumCommitmentAge: Schema.BigInt,\n payment: Schema.Struct({ kind: Schema.Literal(\"native\") }),\n }),\n Schema.Struct({\n protocol: Schema.Literal(\"v2\"),\n registrar: EthereumAddress,\n priceOracle: EthereumAddress,\n minimumRegistrationDuration: Schema.BigInt,\n minimumRenewalDuration: Schema.BigInt,\n minimumCommitmentAge: Schema.BigInt,\n maximumCommitmentAge: Schema.BigInt,\n payment: Schema.Struct({ kind: Schema.Literal(\"erc20\"), enumerable: Schema.Literal(false) }),\n }),\n]);\nexport type RegistrationParameters = typeof RegistrationParameters.Type;\n\nexport const PaymentTokenSupport = Schema.Union([\n Schema.Struct({\n protocol: Schema.Literal(\"v1\"),\n supported: Schema.Literal(false),\n reason: Schema.Literal(\"NATIVE_PAYMENT_ONLY\"),\n }),\n Schema.Struct({\n protocol: Schema.Literal(\"v2\"),\n supported: Schema.Literal(false),\n token: EthereumAddress,\n reason: Schema.Literal(\"PAYMENT_TOKEN_NOT_SUPPORTED\"),\n }),\n Schema.Struct({\n protocol: Schema.Literal(\"v2\"),\n supported: Schema.Literal(true),\n token: EthereumAddress,\n symbol: Schema.String,\n decimals: Schema.Int,\n }),\n]);\nexport type PaymentTokenSupport = typeof PaymentTokenSupport.Type;\n\nexport type RegistrationCommitmentParameters = RegistrationNameParameters & {\n readonly owner: EthereumAddress;\n readonly secret: Bytes32;\n readonly resolver?: EthereumAddress;\n readonly subregistry?: EthereumAddress;\n readonly records?: ReadonlyArray<Hex>;\n readonly reverseRecord?: 0 | 1 | 2;\n readonly referrer?: Bytes32;\n};\n\nexport const RegistrationCommitment = Schema.Struct({\n name: NormalizedName,\n protocol: EnsProtocol,\n registrar: EthereumAddress,\n commitment: Bytes32,\n});\nexport type RegistrationCommitment = typeof RegistrationCommitment.Type;\n\nexport const CommitmentStatus = Schema.Union([\n Schema.Struct({ status: Schema.Literal(\"not-found\"), protocol: EnsProtocol }),\n Schema.Struct({\n status: Schema.Literal(\"pending\"),\n protocol: EnsProtocol,\n submittedAt: Schema.BigInt,\n readyAt: Schema.BigInt,\n expiresAt: Schema.BigInt,\n remainingSeconds: Schema.BigInt,\n }),\n Schema.Struct({\n status: Schema.Literal(\"ready\"),\n protocol: EnsProtocol,\n submittedAt: Schema.BigInt,\n readyAt: Schema.BigInt,\n expiresAt: Schema.BigInt,\n remainingSeconds: Schema.BigInt,\n }),\n Schema.Struct({\n status: Schema.Literal(\"expired\"),\n protocol: EnsProtocol,\n submittedAt: Schema.BigInt,\n readyAt: Schema.BigInt,\n expiresAt: Schema.BigInt,\n }),\n]);\nexport type CommitmentStatus = typeof CommitmentStatus.Type;\n\nexport const RegistrationPlan = Schema.Union([\n Schema.Struct({ status: Schema.Literal(\"unavailable\"), name: NormalizedName }),\n Schema.Struct({ status: Schema.Literal(\"payment-token-required\"), name: NormalizedName }),\n Schema.Struct({\n status: Schema.Literal(\"unsupported-payment-token\"),\n name: NormalizedName,\n paymentToken: EthereumAddress,\n }),\n Schema.Struct({\n status: Schema.Literals([\n \"commitment-required\",\n \"commitment-pending\",\n \"ready\",\n \"commitment-expired\",\n ]),\n name: NormalizedName,\n parameters: RegistrationParameters,\n price: RegistrationPriceResult,\n commitment: RegistrationCommitment,\n commitmentStatus: CommitmentStatus,\n }),\n]);\nexport type RegistrationPlan = typeof RegistrationPlan.Type;\n\nexport interface CommitNameParameters {\n readonly commitment: Bytes32;\n}\n\nexport interface ApprovePaymentTokenParameters {\n readonly paymentToken: string;\n readonly amount: bigint;\n}\n\ntype RegistrationCommitmentWriteParameters = Omit<\n RegistrationCommitmentParameters,\n \"blockNumber\" | \"blockTag\"\n>;\n\nexport type CompleteRegistrationParameters = RegistrationCommitmentWriteParameters & {\n readonly paymentToken?: EthereumAddress;\n readonly maxPrice?: bigint;\n};\n\ninterface RegistrationWalletParameters {\n readonly walletClient?: WalletClient;\n readonly account?: Account | Address;\n readonly mode?: WriteMode;\n readonly confirmation?: ConfirmationPolicy;\n}\n\nexport type RegisterNameParameters = Omit<RegistrationCommitmentWriteParameters, \"records\"> &\n RegistrationWalletParameters & {\n readonly paymentToken?: EthereumAddress;\n readonly maxPrice?: bigint;\n readonly records?: ReadonlyArray<SetRecordInput>;\n readonly resume?: RegisterNameResult;\n };\n\nexport type AvailableRegistrationPrice = Extract<RegistrationPriceResult, { status: \"available\" }>;\n\nexport interface RegisterNameResult {\n readonly status: \"waiting\" | \"partial\" | \"submitted\" | \"completed\";\n readonly name: NormalizedName;\n readonly protocol: typeof EnsProtocol.Type;\n readonly commitment: Bytes32;\n readonly committedByWorkflow: boolean;\n readonly paymentApprovalIncluded: boolean;\n readonly readyAt: bigint | null;\n readonly expiresAt: bigint | null;\n readonly nextActionAt: bigint | null;\n readonly price: AvailableRegistrationPrice;\n readonly write: WritePlanProgress;\n readonly finalState: NameState | null;\n}\n\nexport type RegisterNamesEntryParameters = Omit<\n RegisterNameParameters,\n \"resume\" | \"walletClient\" | \"account\" | \"mode\" | \"confirmation\"\n>;\n\nexport interface RegisterNamesParameters extends RegistrationWalletParameters {\n readonly registrations: ReadonlyArray<RegisterNamesEntryParameters>;\n readonly resume?: RegisterNamesResult;\n}\n\nexport interface RegisterNamesResult {\n readonly status: \"waiting\" | \"partial\" | \"submitted\" | \"completed\";\n readonly registrations: ReadonlyArray<RegisterNameResult>;\n readonly nextActionAt: bigint | null;\n}\n\nexport type RegistrationWriteError = WriteError;\nexport type RegistrationWriteResult = CallExecutionResult;\nexport type RegistrationWriteIntent = EnsWriteIntent<\n RegistrationWriteResult,\n RegistrationWriteError\n>;\n\nexport type RenewNameCallParameters = {\n readonly name: string;\n readonly duration: bigint;\n readonly paymentToken?: EthereumAddress;\n readonly maxPrice?: bigint;\n readonly referrer?: Bytes32;\n};\n\nexport interface ApproveRenewalPaymentParameters {\n readonly name: string;\n readonly duration: bigint;\n readonly paymentToken: string;\n readonly amount: bigint;\n}\n\nexport type RenewNameParameters = RenewNameCallParameters &\n RegistrationWalletParameters & {\n readonly resume?: RenewNameResult;\n };\n\nexport interface RenewalApproval {\n readonly required: boolean;\n readonly spender: EthereumAddress | null;\n readonly token: EthereumAddress | null;\n readonly amount: bigint;\n}\n\nexport interface RenewNameResult {\n readonly status: \"completed\" | \"partial\";\n readonly name: NormalizedName;\n readonly protocol: typeof EnsProtocol.Type;\n readonly route: RenewalRoute;\n readonly duration: bigint;\n readonly previousExpiry: bigint | null;\n readonly newExpiry: bigint | null;\n readonly price: bigint;\n readonly currency: PaymentCurrency;\n readonly approval: RenewalApproval;\n readonly write: WritePlanProgress;\n readonly finalState: NameState | null;\n}\n\nexport interface RenewNameAction extends EnsAction<\n RenewNameParameters,\n RenewNameResult,\n WriteError\n> {\n readonly call: (\n parameters: RenewNameCallParameters,\n ) => EnsWriteIntent<CallExecutionResult, WriteError>;\n}\n\nexport type RenewNamesEntryParameters = RenewNameCallParameters;\n\nexport interface RenewNamesParameters extends RegistrationWalletParameters {\n readonly renewals: ReadonlyArray<RenewNamesEntryParameters>;\n readonly maxTotalPrice?: bigint;\n readonly resume?: RenewNamesResult;\n}\n\nexport interface RenewNamesResult {\n readonly status: \"completed\" | \"partial\";\n readonly renewals: ReadonlyArray<\n Omit<RenewNameResult, \"write\" | \"status\" | \"approval\" | \"finalState\"> & {\n readonly newExpiry: bigint | null;\n readonly finalState: NameState | null;\n }\n >;\n readonly approvals: ReadonlyArray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BAAmB,OAAO,MAAM;CAC3C,OAAO,OAAO;EAAE,QAAQ,OAAO,QAAQ,WAAW;EAAG,UAAU;CAAY,CAAC;CAC5E,OAAO,OAAO;EACZ,QAAQ,OAAO,QAAQ,SAAS;EAChC,UAAU;EACV,aAAa,OAAO;EACpB,SAAS,OAAO;EAChB,WAAW,OAAO;EAClB,kBAAkB,OAAO;CAC3B,CAAC;CACD,OAAO,OAAO;EACZ,QAAQ,OAAO,QAAQ,OAAO;EAC9B,UAAU;EACV,aAAa,OAAO;EACpB,SAAS,OAAO;EAChB,WAAW,OAAO;EAClB,kBAAkB,OAAO;CAC3B,CAAC;CACD,OAAO,OAAO;EACZ,QAAQ,OAAO,QAAQ,SAAS;EAChC,UAAU;EACV,aAAa,OAAO;EACpB,SAAS,OAAO;EAChB,WAAW,OAAO;CACpB,CAAC;AACH,CAAC;AAGD,MAAa,mBAAmB,OAAO,MAAM;CAC3C,OAAO,OAAO;EAAE,QAAQ,OAAO,QAAQ,aAAa;EAAG,MAAM;CAAe,CAAC;CAC7E,OAAO,OAAO;EAAE,QAAQ,OAAO,QAAQ,wBAAwB;EAAG,MAAM;CAAe,CAAC;CACxF,OAAO,OAAO;EACZ,QAAQ,OAAO,QAAQ,2BAA2B;EAClD,MAAM;EACN,cAAc;CAChB,CAAC;CACD,OAAO,OAAO;EACZ,QAAQ,OAAO,SAAS;GACtB;GACA;GACA;GACA;EACF,CAAC;EACD,MAAM;EACN,YAAY;EACZ,OAAO;EACP,YAAY;EACZ,kBAAkB;CACpB,CAAC;AACH,CAAC"}
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../src/actions/registration/types.ts"],"sourcesContent":["import { Schema } from \"effect\";\n\nimport type { Account, Address, WalletClient } from \"viem\";\n\nimport type { EnsAction } from \"../../action/action.js\";\nimport type { BlockParameters } from \"../../action/block.js\";\nimport type { EnsWriteIntent } from \"../../action/write-intent.js\";\nimport type { CodecError } from \"../../errors/codec-error.js\";\nimport type { ContractError } from \"../../errors/contract-error.js\";\nimport type { NameError } from \"../../errors/name-error.js\";\nimport type { RpcError } from \"../../errors/rpc-error.js\";\nimport { Bytes32 } from \"../../schemas/hash.js\";\nimport type { Hex } from \"../../schemas/hex.js\";\nimport { EthereumAddress } from \"../../schemas/identity.js\";\nimport { NormalizedName } from \"../../schemas/name.js\";\nimport { EnsProtocol } from \"../../schemas/protocol.js\";\nimport type {\n CallExecutionResult,\n ConfirmationPolicy,\n WriteError,\n WriteMode,\n WritePlanProgress,\n} from \"../../write/types.js\";\nimport type { NameState } from \"../name/get-name-state/types.js\";\nimport type { SetRecordInput } from \"../records/set-records/types.js\";\n\nexport type RegistrationReadError = CodecError | ContractError | NameError | RpcError;\n\nexport type RegistrationNameParameters = {\n readonly name: string;\n readonly duration: bigint;\n} & BlockParameters;\n\nexport type RegistrationPriceParameters = RegistrationNameParameters & {\n readonly paymentToken?: EthereumAddress;\n};\n\nexport const NativePaymentCurrency = Schema.Struct({\n kind: Schema.Literal(\"native\"),\n symbol: Schema.Literal(\"ETH\"),\n decimals: Schema.Literal(18),\n});\n\nexport const Erc20PaymentCurrency = Schema.Struct({\n kind: Schema.Literal(\"erc20\"),\n address: EthereumAddress,\n symbol: Schema.String,\n decimals: Schema.Int,\n});\n\nexport const PaymentCurrency = Schema.Union([NativePaymentCurrency, Erc20PaymentCurrency]);\nexport type PaymentCurrency = typeof PaymentCurrency.Type;\n\nconst PaymentTokenRequired = Schema.Struct({\n status: Schema.Literal(\"payment-token-required\"),\n name: NormalizedName,\n protocol: EnsProtocol,\n});\n\nconst UnsupportedPaymentToken = Schema.Struct({\n status: Schema.Literal(\"unsupported-payment-token\"),\n name: NormalizedName,\n protocol: EnsProtocol,\n paymentToken: EthereumAddress,\n});\n\nexport const RegistrationPriceResult = Schema.Union([\n Schema.Struct({\n status: Schema.Literal(\"available\"),\n name: NormalizedName,\n protocol: EnsProtocol,\n registrar: EthereumAddress,\n duration: Schema.BigInt,\n base: Schema.BigInt,\n premium: Schema.BigInt,\n total: Schema.BigInt,\n currency: PaymentCurrency,\n }),\n Schema.Struct({\n status: Schema.Literal(\"unavailable\"),\n name: NormalizedName,\n protocol: EnsProtocol,\n reason: Schema.Literal(\"NAME_UNAVAILABLE\"),\n }),\n PaymentTokenRequired,\n UnsupportedPaymentToken,\n]);\nexport type RegistrationPriceResult = typeof RegistrationPriceResult.Type;\n\nexport const RenewalRoute = Schema.Literals([\"v1-controller\", \"v2-registrar\", \"v1-renewer\"]);\nexport type RenewalRoute = typeof RenewalRoute.Type;\n\nexport const RenewalPriceResult = Schema.Union([\n Schema.Struct({\n status: Schema.Literal(\"renewable\"),\n name: NormalizedName,\n protocol: EnsProtocol,\n route: RenewalRoute,\n renewer: EthereumAddress,\n duration: Schema.BigInt,\n price: Schema.BigInt,\n currency: PaymentCurrency,\n }),\n Schema.Struct({\n status: Schema.Literal(\"not-renewable\"),\n name: NormalizedName,\n protocol: EnsProtocol,\n reason: Schema.Literal(\"NAME_NOT_RENEWABLE\"),\n }),\n PaymentTokenRequired,\n UnsupportedPaymentToken,\n]);\nexport type RenewalPriceResult = typeof RenewalPriceResult.Type;\n\nexport const RegistrationParameters = Schema.Union([\n Schema.Struct({\n protocol: Schema.Literal(\"v1\"),\n registrar: EthereumAddress,\n priceOracle: EthereumAddress,\n minimumRegistrationDuration: Schema.BigInt,\n minimumRenewalDuration: Schema.BigInt,\n minimumCommitmentAge: Schema.BigInt,\n maximumCommitmentAge: Schema.BigInt,\n payment: Schema.Struct({ kind: Schema.Literal(\"native\") }),\n }),\n Schema.Struct({\n protocol: Schema.Literal(\"v2\"),\n registrar: EthereumAddress,\n priceOracle: EthereumAddress,\n minimumRegistrationDuration: Schema.BigInt,\n minimumRenewalDuration: Schema.BigInt,\n minimumCommitmentAge: Schema.BigInt,\n maximumCommitmentAge: Schema.BigInt,\n payment: Schema.Struct({ kind: Schema.Literal(\"erc20\"), enumerable: Schema.Literal(false) }),\n }),\n]);\nexport type RegistrationParameters = typeof RegistrationParameters.Type;\n\nexport const PaymentTokenSupport = Schema.Union([\n Schema.Struct({\n protocol: Schema.Literal(\"v1\"),\n supported: Schema.Literal(false),\n reason: Schema.Literal(\"NATIVE_PAYMENT_ONLY\"),\n }),\n Schema.Struct({\n protocol: Schema.Literal(\"v2\"),\n supported: Schema.Literal(false),\n token: EthereumAddress,\n reason: Schema.Literal(\"PAYMENT_TOKEN_NOT_SUPPORTED\"),\n }),\n Schema.Struct({\n protocol: Schema.Literal(\"v2\"),\n supported: Schema.Literal(true),\n token: EthereumAddress,\n symbol: Schema.String,\n decimals: Schema.Int,\n }),\n]);\nexport type PaymentTokenSupport = typeof PaymentTokenSupport.Type;\n\nexport type RegistrationCommitmentParameters = RegistrationNameParameters & {\n readonly owner: EthereumAddress;\n readonly secret: Bytes32;\n readonly resolver?: EthereumAddress;\n readonly subregistry?: EthereumAddress;\n readonly records?: ReadonlyArray<Hex>;\n readonly reverseRecord?: 0 | 1 | 2;\n readonly referrer?: Bytes32;\n};\n\nexport const RegistrationCommitment = Schema.Struct({\n name: NormalizedName,\n protocol: EnsProtocol,\n registrar: EthereumAddress,\n commitment: Bytes32,\n});\nexport type RegistrationCommitment = typeof RegistrationCommitment.Type;\n\nexport const CommitmentStatus = Schema.Union([\n Schema.Struct({ status: Schema.Literal(\"not-found\"), protocol: EnsProtocol }),\n Schema.Struct({\n status: Schema.Literal(\"pending\"),\n protocol: EnsProtocol,\n submittedAt: Schema.BigInt,\n readyAt: Schema.BigInt,\n expiresAt: Schema.BigInt,\n remainingSeconds: Schema.BigInt,\n }),\n Schema.Struct({\n status: Schema.Literal(\"ready\"),\n protocol: EnsProtocol,\n submittedAt: Schema.BigInt,\n readyAt: Schema.BigInt,\n expiresAt: Schema.BigInt,\n remainingSeconds: Schema.BigInt,\n }),\n Schema.Struct({\n status: Schema.Literal(\"expired\"),\n protocol: EnsProtocol,\n submittedAt: Schema.BigInt,\n readyAt: Schema.BigInt,\n expiresAt: Schema.BigInt,\n }),\n]);\nexport type CommitmentStatus = typeof CommitmentStatus.Type;\n\nexport const RegistrationPlan = Schema.Union([\n Schema.Struct({ status: Schema.Literal(\"unavailable\"), name: NormalizedName }),\n Schema.Struct({ status: Schema.Literal(\"payment-token-required\"), name: NormalizedName }),\n Schema.Struct({\n status: Schema.Literal(\"unsupported-payment-token\"),\n name: NormalizedName,\n paymentToken: EthereumAddress,\n }),\n Schema.Struct({\n status: Schema.Literals([\n \"commitment-required\",\n \"commitment-pending\",\n \"ready\",\n \"commitment-expired\",\n ]),\n name: NormalizedName,\n parameters: RegistrationParameters,\n price: RegistrationPriceResult,\n commitment: RegistrationCommitment,\n commitmentStatus: CommitmentStatus,\n }),\n]);\nexport type RegistrationPlan = typeof RegistrationPlan.Type;\n\nexport interface CommitNameParameters {\n readonly commitment: Bytes32;\n}\n\nexport interface ApprovePaymentTokenParameters {\n readonly paymentToken: string;\n readonly amount: bigint;\n}\n\ntype RegistrationCommitmentWriteParameters = Omit<\n RegistrationCommitmentParameters,\n \"blockNumber\" | \"blockTag\"\n>;\n\nexport type CompleteRegistrationParameters = RegistrationCommitmentWriteParameters & {\n readonly paymentToken?: EthereumAddress;\n readonly maxPrice?: bigint;\n};\n\nexport interface RegistrationWalletParameters {\n readonly walletClient?: WalletClient;\n readonly account?: Account | Address;\n readonly mode?: WriteMode;\n readonly confirmation?: ConfirmationPolicy;\n}\n\nexport type RegisterNameParameters = Omit<RegistrationCommitmentWriteParameters, \"records\"> &\n RegistrationWalletParameters & {\n readonly paymentToken?: EthereumAddress;\n readonly maxPrice?: bigint;\n readonly records?: ReadonlyArray<SetRecordInput>;\n readonly resume?: RegisterNameResult;\n };\n\nexport type AvailableRegistrationPrice = Extract<RegistrationPriceResult, { status: \"available\" }>;\n\nexport interface RegisterNameResult {\n readonly status: \"waiting\" | \"partial\" | \"submitted\" | \"completed\";\n readonly name: NormalizedName;\n readonly protocol: typeof EnsProtocol.Type;\n readonly commitment: Bytes32;\n readonly committedByWorkflow: boolean;\n readonly paymentApprovalIncluded: boolean;\n readonly readyAt: bigint | null;\n readonly expiresAt: bigint | null;\n readonly nextActionAt: bigint | null;\n readonly price: AvailableRegistrationPrice;\n readonly write: WritePlanProgress;\n readonly finalState: NameState | null;\n}\n\nexport type RegisterNamesEntryParameters = Omit<\n RegisterNameParameters,\n \"resume\" | \"walletClient\" | \"account\" | \"mode\" | \"confirmation\"\n>;\n\nexport interface RegisterNamesParameters extends RegistrationWalletParameters {\n readonly registrations: ReadonlyArray<RegisterNamesEntryParameters>;\n readonly resume?: RegisterNamesResult;\n}\n\nexport interface RegisterNamesResult {\n readonly status: \"waiting\" | \"partial\" | \"submitted\" | \"completed\";\n readonly registrations: ReadonlyArray<RegisterNameResult>;\n readonly nextActionAt: bigint | null;\n}\n\nexport type RegistrationWriteError = WriteError;\nexport type RegistrationWriteResult = CallExecutionResult;\nexport type RegistrationWriteIntent = EnsWriteIntent<\n RegistrationWriteResult,\n RegistrationWriteError\n>;\n\nexport type RenewNameCallParameters = {\n readonly name: string;\n readonly duration: bigint;\n readonly paymentToken?: EthereumAddress;\n readonly maxPrice?: bigint;\n readonly referrer?: Bytes32;\n};\n\nexport interface ApproveRenewalPaymentParameters {\n readonly name: string;\n readonly duration: bigint;\n readonly paymentToken: string;\n readonly amount: bigint;\n}\n\nexport type RenewNameParameters = RenewNameCallParameters &\n RegistrationWalletParameters & {\n readonly resume?: RenewNameResult;\n };\n\nexport interface RenewalApproval {\n readonly required: boolean;\n readonly spender: EthereumAddress | null;\n readonly token: EthereumAddress | null;\n readonly amount: bigint;\n}\n\nexport interface RenewNameResult {\n readonly status: \"completed\" | \"partial\";\n readonly name: NormalizedName;\n readonly protocol: typeof EnsProtocol.Type;\n readonly route: RenewalRoute;\n readonly duration: bigint;\n readonly previousExpiry: bigint | null;\n readonly newExpiry: bigint | null;\n readonly price: bigint;\n readonly currency: PaymentCurrency;\n readonly approval: RenewalApproval;\n readonly write: WritePlanProgress;\n readonly finalState: NameState | null;\n}\n\nexport interface RenewNameAction extends EnsAction<\n RenewNameParameters,\n RenewNameResult,\n WriteError\n> {\n readonly call: (\n parameters: RenewNameCallParameters,\n ) => EnsWriteIntent<CallExecutionResult, WriteError>;\n}\n\nexport type RenewNamesEntryParameters = RenewNameCallParameters;\n\nexport interface RenewNamesParameters extends RegistrationWalletParameters {\n readonly renewals: ReadonlyArray<RenewNamesEntryParameters>;\n readonly maxTotalPrice?: bigint;\n readonly resume?: RenewNamesResult;\n}\n\nexport interface RenewNamesResult {\n readonly status: \"completed\" | \"partial\";\n readonly renewals: ReadonlyArray<\n Omit<RenewNameResult, \"write\" | \"status\" | \"approval\" | \"finalState\"> & {\n readonly newExpiry: bigint | null;\n readonly finalState: NameState | null;\n }\n >;\n readonly approvals: ReadonlyArray<RenewalApproval>;\n readonly totalPrice: bigint;\n readonly write: WritePlanProgress;\n}\n"],"mappings":";;;;;;;AAqCA,MAAa,wBAAwB,OAAO,OAAO;CACjD,MAAM,OAAO,QAAQ,QAAQ;CAC7B,QAAQ,OAAO,QAAQ,KAAK;CAC5B,UAAU,OAAO,QAAQ,EAAE;AAC7B,CAAC;AAED,MAAa,uBAAuB,OAAO,OAAO;CAChD,MAAM,OAAO,QAAQ,OAAO;CAC5B,SAAS;CACT,QAAQ,OAAO;CACf,UAAU,OAAO;AACnB,CAAC;AAED,MAAa,kBAAkB,OAAO,MAAM,CAAC,uBAAuB,oBAAoB,CAAC;AAGzF,MAAM,uBAAuB,OAAO,OAAO;CACzC,QAAQ,OAAO,QAAQ,wBAAwB;CAC/C,MAAM;CACN,UAAU;AACZ,CAAC;AAED,MAAM,0BAA0B,OAAO,OAAO;CAC5C,QAAQ,OAAO,QAAQ,2BAA2B;CAClD,MAAM;CACN,UAAU;CACV,cAAc;AAChB,CAAC;AAED,MAAa,0BAA0B,OAAO,MAAM;CAClD,OAAO,OAAO;EACZ,QAAQ,OAAO,QAAQ,WAAW;EAClC,MAAM;EACN,UAAU;EACV,WAAW;EACX,UAAU,OAAO;EACjB,MAAM,OAAO;EACb,SAAS,OAAO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ACN,cAAc;CAChB,CAAC;CACD,OAAO,OAAO;EACZ,QAAQ,OAAO,SAAS;GACtB;GACA;GACA;GACA;EACF,CAAC;EACD,MAAM;EACN,YAAY;EACZ,OAAO;EACP,YAAY;EACZ,kBAAkB;CACpB,CAAC;AACH,CAAC"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import "../../../config/config.js";
|
|
2
2
|
import { EnsAction } from "../../../action/action.js";
|
|
3
|
+
import "../../../internal/errors/viem-error.js";
|
|
4
|
+
import "../../../errors/write-plan-error.js";
|
|
3
5
|
import { WriteError } from "../../../write/types.js";
|
|
4
6
|
import { CreateResolverError, CreateResolverIntent, CreateResolverParameters, CreateResolverResult } from "./types.js";
|
|
5
7
|
import { createResolverIntent } from "./prepare.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../../src/actions/resolution/create-resolver/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../../src/actions/resolution/create-resolver/index.ts"],"mappings":";;;;;;;;;;cA4Ea,wBAAsB,UAAA,yCAAA;cA0C7B,QAAM,UAAA,0BAAA,sBAAA;cAMC,uBAOD;WAAoB,aAAa"}
|
|
@@ -1,36 +1,54 @@
|
|
|
1
1
|
import { defineAction, defineExtendedAction } from "../../../action/action.js";
|
|
2
|
+
import { provideConfig } from "../../../internal/config/context.js";
|
|
2
3
|
import { ContractError } from "../../../errors/contract-error.js";
|
|
3
4
|
import { WritePlanError } from "../../../errors/write-plan-error.js";
|
|
5
|
+
import { resolveWalletContext } from "../../../internal/services/wallet-client.js";
|
|
4
6
|
import { executeSequential } from "../../../internal/write/execute-sequential.js";
|
|
5
|
-
import {
|
|
6
|
-
import { EthereumAddress } from "../../../schemas/identity.js";
|
|
7
|
+
import { EthereumClient } from "../../../internal/client/ethereum-client.js";
|
|
7
8
|
import { createResolverIntent, prepareCreateResolver } from "./prepare.js";
|
|
8
|
-
import { Effect
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
9
|
+
import { Effect } from "effect";
|
|
10
|
+
import { concatHex, encodeAbiParameters, getCreate2Address, keccak256 } from "viem";
|
|
11
|
+
import { verifiableFactoryV2ProxyLogicAbi } from "@ensforge/contracts/v2";
|
|
11
12
|
|
|
12
13
|
//#region src/actions/resolution/create-resolver/index.ts
|
|
13
14
|
const predictResolverAddressEffect = Effect.fn("ensforge.predictResolverAddress")(function* (config, parameters) {
|
|
14
|
-
const
|
|
15
|
-
|
|
15
|
+
const deployment = config.deployments;
|
|
16
|
+
if (deployment.protocol !== "v2") return yield* new WritePlanError({
|
|
17
|
+
code: "INVALID_CALL_PLAN",
|
|
18
|
+
message: "Permissioned Resolver prediction requires an ENSv2 deployment",
|
|
19
|
+
cause: deployment
|
|
20
|
+
});
|
|
21
|
+
const wallet = yield* provideConfig(config, resolveWalletContext({
|
|
16
22
|
...parameters.walletClient === void 0 ? {} : { walletClient: parameters.walletClient },
|
|
17
23
|
...parameters.account === void 0 ? {} : { account: parameters.account }
|
|
18
|
-
});
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
}));
|
|
25
|
+
const sender = typeof wallet.account === "string" ? wallet.account : wallet.account.address;
|
|
26
|
+
const factory = deployment.v2.contracts.verifiableFactory;
|
|
27
|
+
const proxyLogic = yield* provideConfig(config, Effect.gen(function* () {
|
|
28
|
+
return yield* (yield* EthereumClient).readContractDirect({
|
|
29
|
+
address: factory,
|
|
30
|
+
abi: verifiableFactoryV2ProxyLogicAbi,
|
|
31
|
+
functionName: "proxyLogic"
|
|
32
|
+
});
|
|
33
|
+
}));
|
|
25
34
|
return yield* Effect.try({
|
|
26
|
-
try: () =>
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
35
|
+
try: () => {
|
|
36
|
+
const salt = keccak256(encodeAbiParameters([{ type: "address" }, { type: "uint256" }], [sender, parameters.salt]));
|
|
37
|
+
const bytecode = concatHex([
|
|
38
|
+
"0x3d604d80600a3d3981f3363d3d373d3d3d363d73",
|
|
39
|
+
proxyLogic,
|
|
40
|
+
"0x5af43d82803e903d91602b57fd5bf3",
|
|
41
|
+
salt
|
|
42
|
+
]);
|
|
43
|
+
return getCreate2Address({
|
|
44
|
+
from: factory,
|
|
45
|
+
salt,
|
|
46
|
+
bytecode
|
|
47
|
+
});
|
|
48
|
+
},
|
|
31
49
|
catch: (cause) => new ContractError({
|
|
32
|
-
code: "
|
|
33
|
-
message: "Unable to
|
|
50
|
+
code: "ENCODE_FAILED",
|
|
51
|
+
message: "Unable to derive the Permissioned Resolver proxy address",
|
|
34
52
|
cause
|
|
35
53
|
})
|
|
36
54
|
});
|