@ensdomains/ensjs 4.2.0 → 4.2.3

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.
Files changed (94) hide show
  1. package/dist/clients/decorators/wallet.d.ts +2 -2
  2. package/dist/contracts/addEnsContracts.js +0 -2
  3. package/dist/contracts/addEnsContracts.js.map +1 -1
  4. package/dist/contracts/bulkRenewal.d.ts +6 -0
  5. package/dist/contracts/bulkRenewal.js +7 -0
  6. package/dist/contracts/bulkRenewal.js.map +1 -1
  7. package/dist/contracts/consts.d.ts +35 -59
  8. package/dist/contracts/consts.js +35 -60
  9. package/dist/contracts/consts.js.map +1 -1
  10. package/dist/contracts/ethRegistrarController.d.ts +394 -27
  11. package/dist/contracts/ethRegistrarController.js +180 -34
  12. package/dist/contracts/ethRegistrarController.js.map +1 -1
  13. package/dist/contracts/universalResolver.d.ts +234 -8
  14. package/dist/contracts/universalResolver.js +53 -4
  15. package/dist/contracts/universalResolver.js.map +1 -1
  16. package/dist/errors/utils.js +1 -0
  17. package/dist/errors/utils.js.map +1 -1
  18. package/dist/errors/version.d.ts +1 -1
  19. package/dist/errors/version.js +1 -1
  20. package/dist/errors/version.js.map +1 -1
  21. package/dist/functions/public/batch.js.map +1 -1
  22. package/dist/functions/public/getName.js.map +1 -1
  23. package/dist/functions/public/getRecords.js +2 -2
  24. package/dist/functions/public/getRecords.js.map +1 -1
  25. package/dist/functions/subgraph/client.js +1 -0
  26. package/dist/functions/subgraph/client.js.map +1 -1
  27. package/dist/functions/subgraph/getNamesForAddress.js +1 -0
  28. package/dist/functions/subgraph/getNamesForAddress.js.map +1 -1
  29. package/dist/functions/wallet/commitName.d.ts +1 -1
  30. package/dist/functions/wallet/commitName.js +2 -2
  31. package/dist/functions/wallet/commitName.js.map +1 -1
  32. package/dist/functions/wallet/registerName.d.ts +1 -1
  33. package/dist/functions/wallet/registerName.js +4 -7
  34. package/dist/functions/wallet/registerName.js.map +1 -1
  35. package/dist/functions/wallet/renewNames.d.ts +5 -3
  36. package/dist/functions/wallet/renewNames.js +4 -3
  37. package/dist/functions/wallet/renewNames.js.map +1 -1
  38. package/dist/utils/checkSafeUniversalResolverData.js.map +1 -1
  39. package/dist/utils/consts.d.ts +1 -0
  40. package/dist/utils/consts.js +1 -0
  41. package/dist/utils/consts.js.map +1 -1
  42. package/dist/utils/encoders/encodeAbi.js.map +1 -1
  43. package/dist/utils/generateFunction.js.map +1 -1
  44. package/dist/utils/index.d.ts +2 -3
  45. package/dist/utils/index.js +2 -3
  46. package/dist/utils/index.js.map +1 -1
  47. package/dist/utils/labels.js +4 -2
  48. package/dist/utils/labels.js.map +1 -1
  49. package/dist/utils/registerHelpers.d.ts +20 -27
  50. package/dist/utils/registerHelpers.js +19 -33
  51. package/dist/utils/registerHelpers.js.map +1 -1
  52. package/dist/wallet.d.ts +0 -2
  53. package/dist/wallet.js +0 -2
  54. package/dist/wallet.js.map +1 -1
  55. package/package.json +8 -9
  56. package/src/@types/dns-packet/index.d.ts +1 -0
  57. package/src/@types/pako.d.ts +4 -1
  58. package/src/clients/decorators/wallet.ts +2 -2
  59. package/src/contracts/addEnsContracts.ts +0 -2
  60. package/src/contracts/bulkRenewal.ts +7 -0
  61. package/src/contracts/consts.ts +39 -60
  62. package/src/contracts/ethRegistrarController.ts +181 -34
  63. package/src/contracts/universalResolver.ts +53 -4
  64. package/src/errors/utils.ts +1 -0
  65. package/src/errors/version.ts +1 -1
  66. package/src/functions/public/batch.ts +1 -0
  67. package/src/functions/public/getName.ts +1 -0
  68. package/src/functions/public/getRecords.ts +8 -2
  69. package/src/functions/subgraph/client.ts +1 -0
  70. package/src/functions/subgraph/getNamesForAddress.ts +1 -0
  71. package/src/functions/wallet/commitName.ts +2 -2
  72. package/src/functions/wallet/registerName.ts +4 -8
  73. package/src/functions/wallet/renewNames.ts +12 -3
  74. package/src/types.ts +2 -0
  75. package/src/utils/checkSafeUniversalResolverData.ts +1 -0
  76. package/src/utils/consts.ts +2 -0
  77. package/src/utils/encoders/encodeAbi.ts +1 -0
  78. package/src/utils/generateFunction.ts +6 -0
  79. package/src/utils/index.ts +5 -20
  80. package/src/utils/labels.ts +8 -4
  81. package/src/utils/registerHelpers.ts +40 -64
  82. package/src/wallet.ts +0 -14
  83. package/dist/functions/wallet/legacyCommitName.d.ts +0 -40
  84. package/dist/functions/wallet/legacyCommitName.js +0 -72
  85. package/dist/functions/wallet/legacyCommitName.js.map +0 -1
  86. package/dist/functions/wallet/legacyRegisterName.d.ts +0 -59
  87. package/dist/functions/wallet/legacyRegisterName.js +0 -93
  88. package/dist/functions/wallet/legacyRegisterName.js.map +0 -1
  89. package/dist/utils/legacyRegisterHelpers.d.ts +0 -48
  90. package/dist/utils/legacyRegisterHelpers.js +0 -45
  91. package/dist/utils/legacyRegisterHelpers.js.map +0 -1
  92. package/src/functions/wallet/legacyCommitName.ts +0 -127
  93. package/src/functions/wallet/legacyRegisterName.ts +0 -159
  94. package/src/utils/legacyRegisterHelpers.ts +0 -147
@@ -94,9 +94,13 @@ export type GetRecordsReturnType<
94
94
  TContentHash extends boolean | undefined = true,
95
95
  TAbi extends boolean | undefined = true,
96
96
  > = Prettify<
97
+ // biome-ignore lint/complexity/noBannedTypes: empty object represents no data when feature is disabled
97
98
  (TContentHash extends true ? WithContentHashResult : {}) &
99
+ // biome-ignore lint/complexity/noBannedTypes: empty object represents no data when feature is disabled
98
100
  (TAbi extends true ? WithAbiResult : {}) &
101
+ // biome-ignore lint/complexity/noBannedTypes: empty object represents no data when feature is disabled
99
102
  (TTexts extends readonly string[] ? WithTextsResult : {}) &
103
+ // biome-ignore lint/complexity/noBannedTypes: empty object represents no data when feature is disabled
100
104
  (TCoins extends readonly (string | number)[] ? WithCoinsResult : {}) & {
101
105
  /** Resolver address used for fetch */
102
106
  resolverAddress: Address
@@ -129,6 +133,7 @@ type EncodeReturnType = Required<
129
133
  TransactionRequestWithPassthrough<{
130
134
  calls: (CallObj | null)[]
131
135
  address?: Address
136
+ // biome-ignore lint/suspicious/noExplicitAny: passthrough args can be various types depending on resolver method
132
137
  args?: any
133
138
  }>
134
139
  >
@@ -414,11 +419,11 @@ const decode = async <
414
419
  abi: multicallSnippet,
415
420
  data: result[0],
416
421
  }).map((r, i) => {
417
- if (r === '0x') {
422
+ if (r === '0x' || (r.length - 2) % 64 !== 0) {
418
423
  calls[i] = null
419
424
  return null
420
425
  }
421
- return (r.length - 2) % 64 === 0 ? r : null
426
+ return r
422
427
  })
423
428
  }
424
429
 
@@ -440,6 +445,7 @@ const decode = async <
440
445
  }
441
446
 
442
447
  type EncoderFunction = typeof encode
448
+ // biome-ignore lint/suspicious/noExplicitAny: generic placeholder for batch function type inference
443
449
  type DecoderFunction = typeof decode<any>
444
450
 
445
451
  type BatchableFunctionObject = {
@@ -55,6 +55,7 @@ export const requestMiddleware: RequestMiddleware = (request) => {
55
55
  }
56
56
 
57
57
  export const responseMiddleware: ResponseMiddleware = (response) => {
58
+ // biome-ignore lint/suspicious/noExplicitAny: recursively traverses unknown GraphQL response structure
58
59
  const traverse = (obj: Record<string, any>) => {
59
60
  if (obj && typeof obj === 'object') {
60
61
  for (const key in obj) {
@@ -182,6 +182,7 @@ const getNamesForAddress = async (
182
182
  const ownerWhereFilters: DomainFilter[] = Object.entries(filters).reduce(
183
183
  (prev, [key, value]) => {
184
184
  if (value) {
185
+ // biome-ignore lint/suspicious/noExplicitAny: runtime validation of filter key against supported filters
185
186
  if (!supportedOwnerFilters.includes(key as any))
186
187
  throw new InvalidFilterKeyError({
187
188
  filterKey: key,
@@ -106,7 +106,7 @@ async function commitName<
106
106
  resolverAddress,
107
107
  records,
108
108
  reverseRecord,
109
- fuses,
109
+ referrer,
110
110
  ...txArgs
111
111
  }: CommitNameParameters<TChain, TAccount, TChainOverride>,
112
112
  ): Promise<CommitNameReturnType> {
@@ -118,7 +118,7 @@ async function commitName<
118
118
  resolverAddress,
119
119
  records,
120
120
  reverseRecord,
121
- fuses,
121
+ referrer,
122
122
  })
123
123
  const writeArgs = {
124
124
  ...data,
@@ -18,9 +18,8 @@ import type {
18
18
  import { getNameType } from '../../utils/getNameType.js'
19
19
  import {
20
20
  type RegistrationParameters,
21
- makeRegistrationTuple,
21
+ makeRegistrationCallData,
22
22
  } from '../../utils/registerHelpers.js'
23
- import { wrappedLabelLengthCheck } from '../../utils/wrapper.js'
24
23
 
25
24
  export type RegisterNameDataParameters = RegistrationParameters & {
26
25
  /** Value of registration */
@@ -57,9 +56,6 @@ export const makeFunctionData = <
57
56
  details: 'Only 2ld-eth name registration is supported',
58
57
  })
59
58
 
60
- const labels = args.name.split('.')
61
- wrappedLabelLengthCheck(labels[0])
62
-
63
59
  return {
64
60
  to: getChainContractAddress({
65
61
  client: wallet,
@@ -68,7 +64,7 @@ export const makeFunctionData = <
68
64
  data: encodeFunctionData({
69
65
  abi: ethRegistrarControllerRegisterSnippet,
70
66
  functionName: 'register',
71
- args: makeRegistrationTuple(args),
67
+ args: [makeRegistrationCallData(args)],
72
68
  }),
73
69
  value,
74
70
  }
@@ -128,7 +124,7 @@ async function registerName<
128
124
  resolverAddress,
129
125
  records,
130
126
  reverseRecord,
131
- fuses,
127
+ referrer,
132
128
  value,
133
129
  ...txArgs
134
130
  }: RegisterNameParameters<TChain, TAccount, TChainOverride>,
@@ -141,7 +137,7 @@ async function registerName<
141
137
  resolverAddress,
142
138
  records,
143
139
  reverseRecord,
144
- fuses,
140
+ referrer,
145
141
  value,
146
142
  })
147
143
  const writeArgs = {
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  type Account,
3
3
  type Hash,
4
+ type Hex,
4
5
  type SendTransactionParameters,
5
6
  type Transport,
6
7
  encodeFunctionData,
@@ -16,6 +17,7 @@ import type {
16
17
  SimpleTransactionRequest,
17
18
  WriteTransactionParameters,
18
19
  } from '../../types.js'
20
+ import { EMPTY_BYTES32 } from '../../utils/consts.js'
19
21
  import { getNameType } from '../../utils/getNameType.js'
20
22
 
21
23
  export type RenewNamesDataParameters = {
@@ -23,6 +25,8 @@ export type RenewNamesDataParameters = {
23
25
  nameOrNames: string | string[]
24
26
  /** Duration to renew name(s) for */
25
27
  duration: bigint | number
28
+ /** Referrer data */
29
+ referrer?: Hex
26
30
  /** Value of all renewals */
27
31
  value: bigint
28
32
  }
@@ -47,7 +51,12 @@ export const makeFunctionData = <
47
51
  TAccount extends Account | undefined,
48
52
  >(
49
53
  wallet: ClientWithAccount<Transport, TChain, TAccount>,
50
- { nameOrNames, duration, value }: RenewNamesDataParameters,
54
+ {
55
+ nameOrNames,
56
+ duration,
57
+ referrer = EMPTY_BYTES32,
58
+ value,
59
+ }: RenewNamesDataParameters,
51
60
  ): RenewNamesDataReturnType => {
52
61
  const names = Array.isArray(nameOrNames) ? nameOrNames : [nameOrNames]
53
62
  const labels = names.map((name) => {
@@ -71,7 +80,7 @@ export const makeFunctionData = <
71
80
  data: encodeFunctionData({
72
81
  abi: ethRegistrarControllerRenewSnippet,
73
82
  functionName: 'renew',
74
- args: [labels[0], BigInt(duration)],
83
+ args: [labels[0], BigInt(duration), referrer],
75
84
  }),
76
85
  value,
77
86
  }
@@ -85,7 +94,7 @@ export const makeFunctionData = <
85
94
  data: encodeFunctionData({
86
95
  abi: bulkRenewalRenewAllSnippet,
87
96
  functionName: 'renewAll',
88
- args: [labels, BigInt(duration)],
97
+ args: [labels, BigInt(duration), referrer],
89
98
  }),
90
99
  value,
91
100
  }
package/src/types.ts CHANGED
@@ -28,11 +28,13 @@ export type SimpleTransactionRequest = {
28
28
  >
29
29
  }
30
30
 
31
+ // biome-ignore lint/suspicious/noExplicitAny: generic default for passthrough data of various types
31
32
  export type TransactionRequestWithPassthrough<TPassthrough = any> =
32
33
  SimpleTransactionRequest & {
33
34
  passthrough?: TPassthrough
34
35
  }
35
36
 
37
+ // biome-ignore lint/suspicious/noExplicitAny: args can be various types depending on the function being called
36
38
  export type GenericPassthrough = { args: any; address: Address }
37
39
 
38
40
  export type Extended = { [K in keyof Client]?: undefined } & {
@@ -11,6 +11,7 @@ import { getRevertErrorData } from './getRevertErrorData.js'
11
11
  type CheckSafeUniversalResolverDataParameters = Prettify<
12
12
  {
13
13
  strict: boolean | undefined
14
+ // biome-ignore lint/suspicious/noExplicitAny: contract function args can be various types depending on the ABI function
14
15
  args: any[] | (() => any[])
15
16
  } & Omit<Parameters<typeof getContractError>[1], 'args'>
16
17
  >
@@ -1,4 +1,6 @@
1
1
  export const EMPTY_ADDRESS = '0x0000000000000000000000000000000000000000'
2
+ export const EMPTY_BYTES32 =
3
+ '0x0000000000000000000000000000000000000000000000000000000000000000'
2
4
  export const MAX_INT_64 = BigInt('18446744073709551615')
3
5
  export const MAX_DATE_INT = 8640000000000000
4
6
  export const MINIMUM_DOT_ETH_CHARS = 3
@@ -24,6 +24,7 @@ export type EncodeAbiParameters<TEncodeAs extends AbiEncodeAs = AbiEncodeAs> =
24
24
  }
25
25
  : {
26
26
  encodeAs: TEncodeAs
27
+ // biome-ignore lint/suspicious/noExplicitAny: ABI data structure can have various key-value types depending on the schema
27
28
  data: Record<any, any> | null
28
29
  }
29
30
 
@@ -4,10 +4,13 @@ import type { ClientWithEns } from '../contracts/consts.js'
4
4
  import type { TransactionRequestWithPassthrough } from '../types.js'
5
5
 
6
6
  export type EncoderFunction = (
7
+ // biome-ignore lint/suspicious/noExplicitAny: generic encoder function accepts various argument types
7
8
  ...args: any[]
8
9
  ) => TransactionRequestWithPassthrough
10
+ // biome-ignore lint/suspicious/noExplicitAny: generic decoder function accepts various argument types and returns various types
9
11
  export type DecoderFunction = (...args: any[]) => Promise<any>
10
12
 
13
+ // biome-ignore lint/suspicious/noExplicitAny: conditional type matches first argument of any type for extraction
11
14
  type OmitFirstArg<F> = F extends (x: any, ...args: infer P) => infer R
12
15
  ? (...args: P) => R
13
16
  : never
@@ -27,7 +30,9 @@ export type BatchFunctionResult<
27
30
  args: Parameters<OmitFirstArg<TEncoderFn>>
28
31
  } & CoderObject<TEncoderFn, TDecoderFn>
29
32
 
33
+ // biome-ignore lint/complexity/noBannedTypes: Function constraint required for generic type matching any function signature
30
34
  export type ExtractResult<TFunction extends Function> = TFunction extends (
35
+ // biome-ignore lint/suspicious/noExplicitAny: conditional type matches promise-returning function with any arguments for result extraction
31
36
  ...args: any[]
32
37
  ) => Promise<infer U>
33
38
  ? U
@@ -36,6 +41,7 @@ export type ExtractResult<TFunction extends Function> = TFunction extends (
36
41
  export interface GeneratedFunction<
37
42
  TEncoderFn extends EncoderFunction,
38
43
  TDecoderFn extends DecoderFunction,
44
+ // biome-ignore lint/complexity/noBannedTypes: Function type required for extending base function interface with additional properties
39
45
  > extends Function,
40
46
  CoderObject<TEncoderFn, TDecoderFn> {
41
47
  (
@@ -43,6 +43,7 @@ export {
43
43
 
44
44
  export {
45
45
  EMPTY_ADDRESS,
46
+ EMPTY_BYTES32,
46
47
  GRACE_PERIOD_SECONDS,
47
48
  MAX_DATE_INT,
48
49
  MAX_INT_64,
@@ -104,21 +105,6 @@ export {
104
105
  saveLabel,
105
106
  saveName,
106
107
  } from './labels.js'
107
- export {
108
- makeLegacyCommitment,
109
- makeLegacyCommitmentFromTuple,
110
- makeLegacyCommitmentTuple,
111
- makeLegacyCommitmentWithConfigTuple,
112
- makeLegacyRegistrationTuple,
113
- makeLegacyRegistrationWithConfigTuple,
114
- isLegacyRegistrationWithConfigParameters,
115
- type LegacyCommitmentTuple,
116
- type LegacyCommitmentWithConfigTuple,
117
- type LegacyRegistrationParameters,
118
- type LegacyRegistrationWithConfigParameters,
119
- type LegacyRegistrationTuple,
120
- type LegacyRegistrationWithConfigTuple,
121
- } from './legacyRegisterHelpers.js'
122
108
  export { makeSafeSecondsDate } from './makeSafeSecondsDate.js'
123
109
  export {
124
110
  beautify,
@@ -143,13 +129,12 @@ export {
143
129
  } from './normalise.js'
144
130
  export {
145
131
  makeCommitment,
146
- makeCommitmentFromTuple,
147
- makeCommitmentTuple,
148
- makeRegistrationTuple,
132
+ makeCommitmentFromCallData,
133
+ makeRegistrationCallData,
149
134
  randomSecret,
150
- type CommitmentTuple,
135
+ type RegistrationCallData,
136
+ type ReverseRecordParameter,
151
137
  type RegistrationParameters,
152
- type RegistrationTuple,
153
138
  } from './registerHelpers.js'
154
139
  export {
155
140
  checkIsDotEth,
@@ -49,6 +49,7 @@ function getLabels() {
49
49
  : {}
50
50
  }
51
51
 
52
+ // biome-ignore lint/suspicious/noExplicitAny: label data stored in localStorage can be various types
52
53
  function _saveLabel(hash: string, label: any) {
53
54
  if (!hasLocalStorage) return hash
54
55
  const labels = getLabels()
@@ -89,8 +90,11 @@ export function checkIsDecrypted(string: string | string[]) {
89
90
  }
90
91
 
91
92
  export function decryptName(name: string) {
92
- return name
93
- .split('.')
94
- .map((label: any) => checkLabel(label))
95
- .join('.')
93
+ return (
94
+ name
95
+ .split('.')
96
+ // biome-ignore lint/suspicious/noExplicitAny: label is a string from split but type inference needs explicit annotation
97
+ .map((label: any) => checkLabel(label))
98
+ .join('.')
99
+ )
96
100
  }
@@ -3,8 +3,8 @@ import {
3
3
  type Hex,
4
4
  encodeAbiParameters,
5
5
  keccak256,
6
- labelhash,
7
6
  pad,
7
+ parseAbiParameters,
8
8
  toBytes,
9
9
  toHex,
10
10
  } from 'viem'
@@ -13,13 +13,18 @@ import {
13
13
  ResolverAddressRequiredError,
14
14
  } from '../errors/utils.js'
15
15
  import { EMPTY_ADDRESS } from './consts.js'
16
- import { type EncodeChildFusesInputObject, encodeFuses } from './fuses.js'
17
16
  import {
18
17
  type RecordOptions,
19
18
  generateRecordCallArray,
20
19
  } from './generateRecordCallArray.js'
21
20
  import { namehash } from './normalise.js'
22
21
 
22
+ export enum ReverseRecordParameter {
23
+ None = 0,
24
+ Ethereum = 1,
25
+ Default = 2,
26
+ }
27
+
23
28
  export type RegistrationParameters = {
24
29
  /** Name to register */
25
30
  name: string
@@ -34,32 +39,21 @@ export type RegistrationParameters = {
34
39
  /** Records to set upon registration */
35
40
  records?: RecordOptions
36
41
  /** Sets primary name upon registration */
37
- reverseRecord?: boolean
38
- /** Fuses to set upon registration */
39
- fuses?: EncodeChildFusesInputObject
42
+ reverseRecord?: ReverseRecordParameter
43
+ /** Referrer for registration */
44
+ referrer?: Hex
40
45
  }
41
46
 
42
- export type CommitmentTuple = [
43
- labelHash: Hex,
44
- owner: Address,
45
- duration: bigint,
46
- secret: Hex,
47
- resolver: Address,
48
- data: Hex[],
49
- reverseRecord: boolean,
50
- ownerControlledFuses: number,
51
- ]
52
-
53
- export type RegistrationTuple = [
54
- label: string,
55
- owner: Address,
56
- duration: bigint,
57
- secret: Hex,
58
- resolver: Address,
59
- data: Hex[],
60
- reverseRecord: boolean,
61
- ownerControlledFuses: number,
62
- ]
47
+ export type RegistrationCallData = {
48
+ label: string
49
+ owner: Address
50
+ duration: bigint
51
+ secret: Hex
52
+ resolver: Address
53
+ data: Hex[]
54
+ reverseRecord: ReverseRecordParameter
55
+ referrer: Hex
56
+ }
63
57
 
64
58
  const cryptoRef =
65
59
  (typeof crypto !== 'undefined' && crypto) ||
@@ -93,21 +87,18 @@ export const randomSecret = ({
93
87
  return toHex(bytes)
94
88
  }
95
89
 
96
- export const makeCommitmentTuple = ({
90
+ export const makeRegistrationCallData = ({
97
91
  name,
98
92
  owner,
99
93
  duration,
100
94
  resolverAddress = EMPTY_ADDRESS,
101
- records: { coins = [], ...records } = { texts: [], coins: [] },
95
+ records: { coins = [], ...records } = { coins: [], texts: [] },
102
96
  reverseRecord,
103
- fuses,
104
97
  secret,
105
- }: RegistrationParameters): CommitmentTuple => {
106
- const labelHash = labelhash(name.split('.')[0])
98
+ referrer = '0x0000000000000000000000000000000000000000000000000000000000000000',
99
+ }: RegistrationParameters): RegistrationCallData => {
100
+ const label = name.split('.')[0]
107
101
  const hash = namehash(name)
108
- const fuseData = fuses
109
- ? encodeFuses({ restriction: 'child', input: fuses })
110
- : 0
111
102
 
112
103
  if (
113
104
  reverseRecord &&
@@ -135,48 +126,33 @@ export const makeCommitmentTuple = ({
135
126
  resolverAddress,
136
127
  records,
137
128
  reverseRecord,
138
- fuses,
139
129
  },
140
130
  })
141
131
 
142
- return [
143
- labelHash,
132
+ return {
133
+ label,
144
134
  owner,
145
- BigInt(duration),
135
+ duration: BigInt(duration),
146
136
  secret,
147
- resolverAddress,
137
+ resolver: resolverAddress,
148
138
  data,
149
- !!reverseRecord,
150
- fuseData,
151
- ]
152
- }
153
-
154
- export const makeRegistrationTuple = (
155
- params: RegistrationParameters,
156
- ): RegistrationTuple => {
157
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
158
- const [_labelhash, ...commitmentData] = makeCommitmentTuple(params)
159
- const label = params.name.split('.')[0]
160
- return [label, ...commitmentData]
139
+ reverseRecord: reverseRecord ?? 0,
140
+ referrer: referrer,
141
+ }
161
142
  }
162
143
 
163
- export const makeCommitmentFromTuple = (params: CommitmentTuple): Hex => {
144
+ export const makeCommitmentFromCallData = (
145
+ callData: RegistrationCallData,
146
+ ): Hex => {
164
147
  return keccak256(
165
148
  encodeAbiParameters(
166
- [
167
- { name: 'name', type: 'bytes32' },
168
- { name: 'owner', type: 'address' },
169
- { name: 'duration', type: 'uint256' },
170
- { name: 'secret', type: 'bytes32' },
171
- { name: 'resolver', type: 'address' },
172
- { name: 'data', type: 'bytes[]' },
173
- { name: 'reverseRecord', type: 'bool' },
174
- { name: 'ownerControlledFuses', type: 'uint16' },
175
- ],
176
- params,
149
+ parseAbiParameters(
150
+ '(string label,address owner,uint256 duration,bytes32 secret,address resolver,bytes[] data,uint8 reverseRecord,bytes32 referrer)',
151
+ ),
152
+ [callData],
177
153
  ),
178
154
  )
179
155
  }
180
156
 
181
157
  export const makeCommitment = (params: RegistrationParameters): Hex =>
182
- makeCommitmentFromTuple(makeCommitmentTuple(params))
158
+ makeCommitmentFromCallData(makeRegistrationCallData(params))
package/src/wallet.ts CHANGED
@@ -26,20 +26,6 @@ export {
26
26
  type DeleteSubnameParameters,
27
27
  type DeleteSubnameReturnType,
28
28
  } from './functions/wallet/deleteSubname.js'
29
- export {
30
- default as legacyCommitName,
31
- type LegacyCommitNameDataParameters,
32
- type LegacyCommitNameDataReturnType,
33
- type LegacyCommitNameParameters,
34
- type LegacyCommitNameReturnType,
35
- } from './functions/wallet/legacyCommitName.js'
36
- export {
37
- default as legacyRegisterName,
38
- type LegacyRegisterNameDataParameters,
39
- type LegacyRegisterNameDataReturnType,
40
- type LegacyRegisterNameParameters,
41
- type LegacyRegisterNameReturnType,
42
- } from './functions/wallet/legacyRegisterName.js'
43
29
  export {
44
30
  default as registerName,
45
31
  type RegisterNameDataParameters,
@@ -1,40 +0,0 @@
1
- import { type Account, type Hash, type Transport } from 'viem';
2
- import type { ChainWithEns, ClientWithAccount } from '../../contracts/consts.js';
3
- import type { Prettify, SimpleTransactionRequest, WriteTransactionParameters } from '../../types.js';
4
- import { type LegacyRegistrationParameters } from '../../utils/legacyRegisterHelpers.js';
5
- export type LegacyCommitNameDataParameters = LegacyRegistrationParameters;
6
- export type LegacyCommitNameDataReturnType = SimpleTransactionRequest;
7
- export type LegacyCommitNameParameters<TChain extends ChainWithEns, TAccount extends Account | undefined, TChainOverride extends ChainWithEns | undefined> = Prettify<LegacyCommitNameDataParameters & WriteTransactionParameters<TChain, TAccount, TChainOverride>>;
8
- export type LegacyCommitNameReturnType = Hash;
9
- export declare const makeFunctionData: <TChain extends ChainWithEns, TAccount extends Account | undefined>(wallet: ClientWithAccount<Transport, TChain, TAccount>, args: LegacyCommitNameDataParameters) => LegacyCommitNameDataReturnType;
10
- /**
11
- * Commits a name to be registered
12
- * @param wallet - {@link ClientWithAccount}
13
- * @param parameters - {@link LegacyCommitNameParameters}
14
- * @returns Transaction hash. {@link LegacyCommitNameReturnType}
15
- *
16
- * @example
17
- * import { createWalletClient, custom } from 'viem'
18
- * import { mainnet } from 'viem/chains'
19
- * import { addEnsContracts } from '@ensdomains/ensjs'
20
- * import { commitName } from '@ensdomains/ensjs/wallet'
21
- * import { randomSecret } from '@ensdomains/ensjs/utils'
22
- *
23
- * const wallet = createWalletClient({
24
- * chain: addEnsContracts(mainnet),
25
- * transport: custom(window.ethereum),
26
- * })
27
- * const secret = randomSecret()
28
- * const hash = await commitName(wallet, {
29
- * name: 'example.eth',
30
- * owner: '0xFe89cc7aBB2C4183683ab71653C4cdc9B02D44b7',
31
- * duration: 31536000, // 1 year
32
- * secret,
33
- * })
34
- * // 0x...
35
- */
36
- declare function legacyCommitName<TChain extends ChainWithEns, TAccount extends Account | undefined, TChainOverride extends ChainWithEns | undefined = ChainWithEns>(wallet: ClientWithAccount<Transport, TChain, TAccount>, { name, owner, duration, secret, resolverAddress, address, ...txArgs }: LegacyCommitNameParameters<TChain, TAccount, TChainOverride>): Promise<LegacyCommitNameReturnType>;
37
- declare namespace legacyCommitName {
38
- var makeFunctionData: <TChain extends ChainWithEns, TAccount extends Account | undefined>(wallet: ClientWithAccount<Transport, TChain, TAccount>, args: LegacyCommitNameDataParameters) => LegacyCommitNameDataReturnType;
39
- }
40
- export default legacyCommitName;
@@ -1,72 +0,0 @@
1
- import { encodeFunctionData, } from 'viem';
2
- import { sendTransaction } from 'viem/actions';
3
- import { getChainContractAddress } from '../../contracts/getChainContractAddress.js';
4
- import { legacyEthRegistrarControllerCommitSnippet } from '../../contracts/legacyEthRegistrarController.js';
5
- import { UnsupportedNameTypeError } from '../../errors/general.js';
6
- import { EMPTY_ADDRESS } from '../../utils/consts.js';
7
- import { getNameType } from '../../utils/getNameType.js';
8
- import { makeLegacyCommitment, } from '../../utils/legacyRegisterHelpers.js';
9
- export const makeFunctionData = (wallet, args) => {
10
- const nameType = getNameType(args.name);
11
- if (nameType !== 'eth-2ld')
12
- throw new UnsupportedNameTypeError({
13
- nameType,
14
- supportedNameTypes: ['eth-2ld'],
15
- details: 'Only 2ld-eth name registration is supported',
16
- });
17
- return {
18
- to: getChainContractAddress({
19
- client: wallet,
20
- contract: 'legacyEthRegistrarController',
21
- }),
22
- data: encodeFunctionData({
23
- abi: legacyEthRegistrarControllerCommitSnippet,
24
- functionName: 'commit',
25
- args: [makeLegacyCommitment(args)],
26
- }),
27
- };
28
- };
29
- /**
30
- * Commits a name to be registered
31
- * @param wallet - {@link ClientWithAccount}
32
- * @param parameters - {@link LegacyCommitNameParameters}
33
- * @returns Transaction hash. {@link LegacyCommitNameReturnType}
34
- *
35
- * @example
36
- * import { createWalletClient, custom } from 'viem'
37
- * import { mainnet } from 'viem/chains'
38
- * import { addEnsContracts } from '@ensdomains/ensjs'
39
- * import { commitName } from '@ensdomains/ensjs/wallet'
40
- * import { randomSecret } from '@ensdomains/ensjs/utils'
41
- *
42
- * const wallet = createWalletClient({
43
- * chain: addEnsContracts(mainnet),
44
- * transport: custom(window.ethereum),
45
- * })
46
- * const secret = randomSecret()
47
- * const hash = await commitName(wallet, {
48
- * name: 'example.eth',
49
- * owner: '0xFe89cc7aBB2C4183683ab71653C4cdc9B02D44b7',
50
- * duration: 31536000, // 1 year
51
- * secret,
52
- * })
53
- * // 0x...
54
- */
55
- async function legacyCommitName(wallet, { name, owner, duration, secret, resolverAddress = EMPTY_ADDRESS, address = EMPTY_ADDRESS, ...txArgs }) {
56
- const data = makeFunctionData(wallet, {
57
- name,
58
- owner,
59
- duration,
60
- secret,
61
- resolverAddress,
62
- address,
63
- });
64
- const writeArgs = {
65
- ...data,
66
- ...txArgs,
67
- };
68
- return sendTransaction(wallet, writeArgs);
69
- }
70
- legacyCommitName.makeFunctionData = makeFunctionData;
71
- export default legacyCommitName;
72
- //# sourceMappingURL=legacyCommitName.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"legacyCommitName.js","sourceRoot":"","sources":["../../../src/functions/wallet/legacyCommitName.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,kBAAkB,GACnB,MAAM,MAAM,CAAA;AACb,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAE9C,OAAO,EAAE,uBAAuB,EAAE,MAAM,4CAA4C,CAAA;AACpF,OAAO,EAAE,yCAAyC,EAAE,MAAM,iDAAiD,CAAA;AAC3G,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAA;AAMlE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AACxD,OAAO,EAEL,oBAAoB,GACrB,MAAM,sCAAsC,CAAA;AAiB7C,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAI9B,MAAsD,EACtD,IAAoC,EACJ,EAAE;IAClC,MAAM,QAAQ,GAAG,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACvC,IAAI,QAAQ,KAAK,SAAS;QACxB,MAAM,IAAI,wBAAwB,CAAC;YACjC,QAAQ;YACR,kBAAkB,EAAE,CAAC,SAAS,CAAC;YAC/B,OAAO,EAAE,6CAA6C;SACvD,CAAC,CAAA;IAEJ,OAAO;QACL,EAAE,EAAE,uBAAuB,CAAC;YAC1B,MAAM,EAAE,MAAM;YACd,QAAQ,EAAE,8BAA8B;SACzC,CAAC;QACF,IAAI,EAAE,kBAAkB,CAAC;YACvB,GAAG,EAAE,yCAAyC;YAC9C,YAAY,EAAE,QAAQ;YACtB,IAAI,EAAE,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;SACnC,CAAC;KACH,CAAA;AACH,CAAC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,KAAK,UAAU,gBAAgB,CAK7B,MAAsD,EACtD,EACE,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,MAAM,EACN,eAAe,GAAG,aAAa,EAC/B,OAAO,GAAG,aAAa,EACvB,GAAG,MAAM,EACoD;IAE/D,MAAM,IAAI,GAAG,gBAAgB,CAAC,MAAM,EAAE;QACpC,IAAI;QACJ,KAAK;QACL,QAAQ;QACR,MAAM;QACN,eAAe;QACf,OAAO;KACR,CAAC,CAAA;IACF,MAAM,SAAS,GAAG;QAChB,GAAG,IAAI;QACP,GAAG,MAAM;KACqD,CAAA;IAChE,OAAO,eAAe,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;AAC3C,CAAC;AAED,gBAAgB,CAAC,gBAAgB,GAAG,gBAAgB,CAAA;AAEpD,eAAe,gBAAgB,CAAA"}