@ensdomains/ensjs 4.1.2 → 4.2.2

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 (122) hide show
  1. package/README.md +1 -1
  2. package/dist/clients/decorators/subgraph.d.ts +1 -1
  3. package/dist/clients/decorators/wallet.d.ts +3 -3
  4. package/dist/contracts/addEnsContracts.d.ts +6 -1
  5. package/dist/contracts/addEnsContracts.js +20 -1
  6. package/dist/contracts/addEnsContracts.js.map +1 -1
  7. package/dist/contracts/bulkRenewal.d.ts +6 -0
  8. package/dist/contracts/bulkRenewal.js +7 -0
  9. package/dist/contracts/bulkRenewal.js.map +1 -1
  10. package/dist/contracts/consts.d.ts +35 -59
  11. package/dist/contracts/consts.js +35 -60
  12. package/dist/contracts/consts.js.map +1 -1
  13. package/dist/contracts/ethRegistrarController.d.ts +394 -27
  14. package/dist/contracts/ethRegistrarController.js +180 -34
  15. package/dist/contracts/ethRegistrarController.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/getDecodedName.d.ts +5 -1
  28. package/dist/functions/subgraph/getDecodedName.js +5 -1
  29. package/dist/functions/subgraph/getDecodedName.js.map +1 -1
  30. package/dist/functions/subgraph/getNameHistory.d.ts +3 -0
  31. package/dist/functions/subgraph/getNameHistory.js +3 -0
  32. package/dist/functions/subgraph/getNameHistory.js.map +1 -1
  33. package/dist/functions/subgraph/getNamesForAddress.d.ts +3 -0
  34. package/dist/functions/subgraph/getNamesForAddress.js +4 -0
  35. package/dist/functions/subgraph/getNamesForAddress.js.map +1 -1
  36. package/dist/functions/subgraph/getSubgraphRecords.d.ts +4 -1
  37. package/dist/functions/subgraph/getSubgraphRecords.js +4 -1
  38. package/dist/functions/subgraph/getSubgraphRecords.js.map +1 -1
  39. package/dist/functions/subgraph/getSubgraphRegistrant.d.ts +3 -0
  40. package/dist/functions/subgraph/getSubgraphRegistrant.js +3 -0
  41. package/dist/functions/subgraph/getSubgraphRegistrant.js.map +1 -1
  42. package/dist/functions/subgraph/getSubnames.d.ts +3 -0
  43. package/dist/functions/subgraph/getSubnames.js +3 -0
  44. package/dist/functions/subgraph/getSubnames.js.map +1 -1
  45. package/dist/functions/wallet/commitName.d.ts +1 -1
  46. package/dist/functions/wallet/commitName.js +2 -2
  47. package/dist/functions/wallet/commitName.js.map +1 -1
  48. package/dist/functions/wallet/registerName.d.ts +1 -1
  49. package/dist/functions/wallet/registerName.js +4 -7
  50. package/dist/functions/wallet/registerName.js.map +1 -1
  51. package/dist/functions/wallet/renewNames.d.ts +5 -3
  52. package/dist/functions/wallet/renewNames.js +4 -3
  53. package/dist/functions/wallet/renewNames.js.map +1 -1
  54. package/dist/functions/wallet/setContentHashRecord.d.ts +1 -1
  55. package/dist/functions/wallet/setContentHashRecord.js +1 -1
  56. package/dist/subgraph.d.ts +11 -0
  57. package/dist/subgraph.js +11 -0
  58. package/dist/subgraph.js.map +1 -1
  59. package/dist/utils/checkSafeUniversalResolverData.js.map +1 -1
  60. package/dist/utils/consts.d.ts +1 -0
  61. package/dist/utils/consts.js +1 -0
  62. package/dist/utils/consts.js.map +1 -1
  63. package/dist/utils/encoders/encodeAbi.js.map +1 -1
  64. package/dist/utils/generateFunction.js.map +1 -1
  65. package/dist/utils/index.d.ts +2 -3
  66. package/dist/utils/index.js +2 -3
  67. package/dist/utils/index.js.map +1 -1
  68. package/dist/utils/labels.js +4 -2
  69. package/dist/utils/labels.js.map +1 -1
  70. package/dist/utils/registerHelpers.d.ts +20 -27
  71. package/dist/utils/registerHelpers.js +19 -33
  72. package/dist/utils/registerHelpers.js.map +1 -1
  73. package/dist/wallet.d.ts +0 -2
  74. package/dist/wallet.js +0 -2
  75. package/dist/wallet.js.map +1 -1
  76. package/package.json +6 -7
  77. package/src/@types/dns-packet/index.d.ts +1 -0
  78. package/src/@types/pako.d.ts +4 -1
  79. package/src/clients/decorators/subgraph.ts +1 -1
  80. package/src/clients/decorators/wallet.ts +3 -3
  81. package/src/contracts/addEnsContracts.ts +32 -1
  82. package/src/contracts/bulkRenewal.ts +7 -0
  83. package/src/contracts/consts.ts +39 -60
  84. package/src/contracts/ethRegistrarController.ts +181 -34
  85. package/src/errors/utils.ts +1 -0
  86. package/src/errors/version.ts +1 -1
  87. package/src/functions/public/batch.ts +1 -0
  88. package/src/functions/public/getName.ts +1 -0
  89. package/src/functions/public/getRecords.ts +8 -2
  90. package/src/functions/subgraph/client.ts +1 -0
  91. package/src/functions/subgraph/getDecodedName.ts +5 -1
  92. package/src/functions/subgraph/getNameHistory.ts +3 -0
  93. package/src/functions/subgraph/getNamesForAddress.ts +4 -0
  94. package/src/functions/subgraph/getSubgraphRecords.ts +4 -1
  95. package/src/functions/subgraph/getSubgraphRegistrant.ts +3 -0
  96. package/src/functions/subgraph/getSubnames.ts +3 -0
  97. package/src/functions/wallet/commitName.ts +2 -2
  98. package/src/functions/wallet/registerName.ts +4 -8
  99. package/src/functions/wallet/renewNames.ts +12 -3
  100. package/src/functions/wallet/setContentHashRecord.ts +1 -1
  101. package/src/subgraph.ts +11 -0
  102. package/src/types.ts +2 -0
  103. package/src/utils/checkSafeUniversalResolverData.ts +1 -0
  104. package/src/utils/consts.ts +2 -0
  105. package/src/utils/encoders/encodeAbi.ts +1 -0
  106. package/src/utils/generateFunction.ts +6 -0
  107. package/src/utils/index.ts +5 -20
  108. package/src/utils/labels.ts +8 -4
  109. package/src/utils/registerHelpers.ts +40 -64
  110. package/src/wallet.ts +0 -14
  111. package/dist/functions/wallet/legacyCommitName.d.ts +0 -40
  112. package/dist/functions/wallet/legacyCommitName.js +0 -72
  113. package/dist/functions/wallet/legacyCommitName.js.map +0 -1
  114. package/dist/functions/wallet/legacyRegisterName.d.ts +0 -59
  115. package/dist/functions/wallet/legacyRegisterName.js +0 -93
  116. package/dist/functions/wallet/legacyRegisterName.js.map +0 -1
  117. package/dist/utils/legacyRegisterHelpers.d.ts +0 -48
  118. package/dist/utils/legacyRegisterHelpers.js +0 -45
  119. package/dist/utils/legacyRegisterHelpers.js.map +0 -1
  120. package/src/functions/wallet/legacyCommitName.ts +0 -127
  121. package/src/functions/wallet/legacyRegisterName.ts +0 -159
  122. package/src/utils/legacyRegisterHelpers.ts +0 -147
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"}
@@ -1,59 +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 LegacyRegisterNameDataParameters = LegacyRegistrationParameters & {
6
- /** Value of registration */
7
- value: bigint;
8
- };
9
- export type LegacyRegisterNameDataReturnType = SimpleTransactionRequest & {
10
- value: bigint;
11
- };
12
- export type LegacyRegisterNameParameters<TChain extends ChainWithEns, TAccount extends Account | undefined, TChainOverride extends ChainWithEns | undefined> = Prettify<LegacyRegisterNameDataParameters & WriteTransactionParameters<TChain, TAccount, TChainOverride>>;
13
- export type LegacyRegisterNameReturnType = Hash;
14
- export declare const makeFunctionData: <TChain extends ChainWithEns, TAccount extends Account | undefined>(wallet: ClientWithAccount<Transport, TChain, TAccount>, { value, ...args }: LegacyRegisterNameDataParameters) => LegacyRegisterNameDataReturnType;
15
- /**
16
- * Registers a name on ENS
17
- * @param wallet - {@link ClientWithAccount}
18
- * @param parameters - {@link RegisterNameParameters}
19
- * @returns Transaction hash. {@link LegacyRegisterNameReturnType}
20
- *
21
- * @example
22
- * import { createPublicClient, createWalletClient, http, custom } from 'viem'
23
- * import { mainnet } from 'viem/chains'
24
- * import { addEnsContracts } from '@ensdomains/ensjs'
25
- * import { getPrice } from '@ensdomains/ensjs/public'
26
- * import { randomSecret } from '@ensdomains/ensjs/utils'
27
- * import { commitName, registerName } from '@ensdomains/ensjs/wallet'
28
- *
29
- * const mainnetWithEns = addEnsContracts(mainnet)
30
- * const client = createPublicClient({
31
- * chain: mainnetWithEns,
32
- * transport: http(),
33
- * })
34
- * const wallet = createWalletClient({
35
- * chain: mainnetWithEns,
36
- * transport: custom(window.ethereum),
37
- * })
38
- * const secret = randomSecret()
39
- * const params = {
40
- * name: 'example.eth',
41
- * owner: '0xFe89cc7aBB2C4183683ab71653C4cdc9B02D44b7',
42
- * duration: 31536000, // 1 year
43
- * secret,
44
- * }
45
- *
46
- * const commitmentHash = await commitName(wallet, params)
47
- * await client.waitForTransactionReceipt({ hash: commitmentHash }) // wait for commitment to finalise
48
- * await new Promise((resolve) => setTimeout(resolve, 60 * 1_000)) // wait for commitment to be valid
49
- *
50
- * const { base, premium } = await getPrice(client, { nameOrNames: params.name, duration: params.duration })
51
- * const value = (base + premium) * 110n / 100n // add 10% to the price for buffer
52
- * const hash = await registerName(wallet, { ...params, value })
53
- * // 0x...
54
- */
55
- declare function legacyRegisterName<TChain extends ChainWithEns, TAccount extends Account | undefined, TChainOverride extends ChainWithEns | undefined = ChainWithEns>(wallet: ClientWithAccount<Transport, TChain, TAccount>, { name, owner, duration, secret, resolverAddress, address, value, ...txArgs }: LegacyRegisterNameParameters<TChain, TAccount, TChainOverride>): Promise<LegacyRegisterNameReturnType>;
56
- declare namespace legacyRegisterName {
57
- var makeFunctionData: <TChain extends ChainWithEns, TAccount extends Account | undefined>(wallet: ClientWithAccount<Transport, TChain, TAccount>, { value, ...args }: LegacyRegisterNameDataParameters) => LegacyRegisterNameDataReturnType;
58
- }
59
- export default legacyRegisterName;
@@ -1,93 +0,0 @@
1
- import { encodeFunctionData, } from 'viem';
2
- import { sendTransaction } from 'viem/actions';
3
- import { getChainContractAddress } from '../../contracts/getChainContractAddress.js';
4
- import { legacyEthRegistrarControllerRegisterSnippet, legacyEthRegistrarControllerRegisterWithConfigSnippet, } from '../../contracts/legacyEthRegistrarController.js';
5
- import { UnsupportedNameTypeError } from '../../errors/general.js';
6
- import { getNameType } from '../../utils/getNameType.js';
7
- import { isLegacyRegistrationWithConfigParameters, makeLegacyRegistrationTuple, makeLegacyRegistrationWithConfigTuple, } from '../../utils/legacyRegisterHelpers.js';
8
- export const makeFunctionData = (wallet, { value, ...args }) => {
9
- const nameType = getNameType(args.name);
10
- if (nameType !== 'eth-2ld')
11
- throw new UnsupportedNameTypeError({
12
- nameType,
13
- supportedNameTypes: ['eth-2ld'],
14
- details: 'Only 2ld-eth name registration is supported',
15
- });
16
- return {
17
- to: getChainContractAddress({
18
- client: wallet,
19
- contract: 'legacyEthRegistrarController',
20
- }),
21
- data: isLegacyRegistrationWithConfigParameters(args)
22
- ? encodeFunctionData({
23
- abi: legacyEthRegistrarControllerRegisterWithConfigSnippet,
24
- functionName: 'registerWithConfig',
25
- args: makeLegacyRegistrationWithConfigTuple(args),
26
- })
27
- : encodeFunctionData({
28
- abi: legacyEthRegistrarControllerRegisterSnippet,
29
- functionName: 'register',
30
- args: makeLegacyRegistrationTuple(args),
31
- }),
32
- value,
33
- };
34
- };
35
- /**
36
- * Registers a name on ENS
37
- * @param wallet - {@link ClientWithAccount}
38
- * @param parameters - {@link RegisterNameParameters}
39
- * @returns Transaction hash. {@link LegacyRegisterNameReturnType}
40
- *
41
- * @example
42
- * import { createPublicClient, createWalletClient, http, custom } from 'viem'
43
- * import { mainnet } from 'viem/chains'
44
- * import { addEnsContracts } from '@ensdomains/ensjs'
45
- * import { getPrice } from '@ensdomains/ensjs/public'
46
- * import { randomSecret } from '@ensdomains/ensjs/utils'
47
- * import { commitName, registerName } from '@ensdomains/ensjs/wallet'
48
- *
49
- * const mainnetWithEns = addEnsContracts(mainnet)
50
- * const client = createPublicClient({
51
- * chain: mainnetWithEns,
52
- * transport: http(),
53
- * })
54
- * const wallet = createWalletClient({
55
- * chain: mainnetWithEns,
56
- * transport: custom(window.ethereum),
57
- * })
58
- * const secret = randomSecret()
59
- * const params = {
60
- * name: 'example.eth',
61
- * owner: '0xFe89cc7aBB2C4183683ab71653C4cdc9B02D44b7',
62
- * duration: 31536000, // 1 year
63
- * secret,
64
- * }
65
- *
66
- * const commitmentHash = await commitName(wallet, params)
67
- * await client.waitForTransactionReceipt({ hash: commitmentHash }) // wait for commitment to finalise
68
- * await new Promise((resolve) => setTimeout(resolve, 60 * 1_000)) // wait for commitment to be valid
69
- *
70
- * const { base, premium } = await getPrice(client, { nameOrNames: params.name, duration: params.duration })
71
- * const value = (base + premium) * 110n / 100n // add 10% to the price for buffer
72
- * const hash = await registerName(wallet, { ...params, value })
73
- * // 0x...
74
- */
75
- async function legacyRegisterName(wallet, { name, owner, duration, secret, resolverAddress, address, value, ...txArgs }) {
76
- const data = makeFunctionData(wallet, {
77
- name,
78
- owner,
79
- duration,
80
- secret,
81
- resolverAddress,
82
- address,
83
- value,
84
- });
85
- const writeArgs = {
86
- ...data,
87
- ...txArgs,
88
- };
89
- return sendTransaction(wallet, writeArgs);
90
- }
91
- legacyRegisterName.makeFunctionData = makeFunctionData;
92
- export default legacyRegisterName;
93
- //# sourceMappingURL=legacyRegisterName.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"legacyRegisterName.js","sourceRoot":"","sources":["../../../src/functions/wallet/legacyRegisterName.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,EACL,2CAA2C,EAC3C,qDAAqD,GACtD,MAAM,iDAAiD,CAAA;AACxD,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAA;AAMlE,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AACxD,OAAO,EAEL,wCAAwC,EACxC,2BAA2B,EAC3B,qCAAqC,GACtC,MAAM,sCAAsC,CAAA;AAsB7C,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAI9B,MAAsD,EACtD,EAAE,KAAK,EAAE,GAAG,IAAI,EAAoC,EAClB,EAAE;IACpC,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,wCAAwC,CAAC,IAAI,CAAC;YAClD,CAAC,CAAC,kBAAkB,CAAC;gBACjB,GAAG,EAAE,qDAAqD;gBAC1D,YAAY,EAAE,oBAAoB;gBAClC,IAAI,EAAE,qCAAqC,CAAC,IAAI,CAAC;aAClD,CAAC;YACJ,CAAC,CAAC,kBAAkB,CAAC;gBACjB,GAAG,EAAE,2CAA2C;gBAChD,YAAY,EAAE,UAAU;gBACxB,IAAI,EAAE,2BAA2B,CAAC,IAAI,CAAC;aACxC,CAAC;QACN,KAAK;KACN,CAAA;AACH,CAAC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,KAAK,UAAU,kBAAkB,CAK/B,MAAsD,EACtD,EACE,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,MAAM,EACN,eAAe,EACf,OAAO,EACP,KAAK,EACL,GAAG,MAAM,EACsD;IAEjE,MAAM,IAAI,GAAG,gBAAgB,CAAC,MAAM,EAAE;QACpC,IAAI;QACJ,KAAK;QACL,QAAQ;QACR,MAAM;QACN,eAAe;QACf,OAAO;QACP,KAAK;KACN,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,kBAAkB,CAAC,gBAAgB,GAAG,gBAAgB,CAAA;AAEtD,eAAe,kBAAkB,CAAA"}
@@ -1,48 +0,0 @@
1
- import { type Address, type Hex } from 'viem';
2
- export type LegacyRegistrationParameters = {
3
- /** Name to register */
4
- name: string;
5
- /** Address to set owner to */
6
- owner: Address;
7
- /** Duration of registration */
8
- duration: number;
9
- /** Random 32 bytes to use for registration */
10
- secret: Hex;
11
- /** Custom resolver address, defaults to empty address */
12
- resolverAddress?: Address;
13
- /** Address to set upon registration, defaults to empty address */
14
- address?: Address;
15
- };
16
- export type LegacyRegistrationWithConfigParameters = LegacyRegistrationParameters & {
17
- resolverAddress: Address;
18
- address?: Address;
19
- };
20
- export declare const isLegacyRegistrationWithConfigParameters: (params: LegacyRegistrationParameters) => params is LegacyRegistrationWithConfigParameters;
21
- export type LegacyCommitmentTuple = [label: string, owner: Address, secret: Hex];
22
- export type LegacyCommitmentWithConfigTuple = [
23
- label: string,
24
- owner: Address,
25
- resolverAddress: Address,
26
- address: Address,
27
- secret: Hex
28
- ];
29
- export type LegacyRegistrationTuple = [
30
- label: string,
31
- owner: Address,
32
- duration: bigint,
33
- secret: Hex
34
- ];
35
- export type LegacyRegistrationWithConfigTuple = [
36
- label: string,
37
- owner: Address,
38
- duration: bigint,
39
- secret: Hex,
40
- resolverAddress: Address,
41
- address: Address
42
- ];
43
- export declare const makeLegacyCommitmentTuple: (params: LegacyRegistrationParameters) => LegacyCommitmentTuple;
44
- export declare const makeLegacyCommitmentWithConfigTuple: (params: LegacyRegistrationWithConfigParameters) => LegacyCommitmentWithConfigTuple;
45
- export declare const makeLegacyRegistrationTuple: ({ name, owner, secret, duration, }: LegacyRegistrationParameters) => LegacyRegistrationTuple;
46
- export declare const makeLegacyRegistrationWithConfigTuple: ({ name, owner, secret, duration, resolverAddress, address, }: LegacyRegistrationWithConfigParameters) => LegacyRegistrationWithConfigTuple;
47
- export declare const makeLegacyCommitmentFromTuple: ([label, ...others]: LegacyCommitmentTuple | LegacyCommitmentWithConfigTuple) => Hex;
48
- export declare const makeLegacyCommitment: (params: LegacyRegistrationParameters | LegacyRegistrationWithConfigParameters) => Hex;