@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
@@ -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;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ACE,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;
@@ -1,45 +0,0 @@
1
- import { encodePacked, keccak256, labelhash, } from 'viem';
2
- import { LegacyRegistrationInvalidConfigError } from '../errors/register.js';
3
- import { EMPTY_ADDRESS } from './consts.js';
4
- export const isLegacyRegistrationWithConfigParameters = (params) => {
5
- const { resolverAddress = EMPTY_ADDRESS, address = EMPTY_ADDRESS } = params;
6
- if (resolverAddress === EMPTY_ADDRESS && address !== EMPTY_ADDRESS)
7
- throw new LegacyRegistrationInvalidConfigError({
8
- resolverAddress,
9
- address,
10
- });
11
- return resolverAddress !== EMPTY_ADDRESS || address !== EMPTY_ADDRESS;
12
- };
13
- export const makeLegacyCommitmentTuple = (params) => {
14
- const { name, owner, secret } = params;
15
- const label = name.split('.')[0];
16
- return [label, owner, secret];
17
- };
18
- export const makeLegacyCommitmentWithConfigTuple = (params) => {
19
- const { name, owner, secret, resolverAddress = EMPTY_ADDRESS, address = EMPTY_ADDRESS, } = params;
20
- const label = name.split('.')[0];
21
- return [label, owner, secret, resolverAddress, address];
22
- };
23
- export const makeLegacyRegistrationTuple = ({ name, owner, secret, duration, }) => {
24
- const label = name.split('.')[0];
25
- return [label, owner, BigInt(duration), secret];
26
- };
27
- export const makeLegacyRegistrationWithConfigTuple = ({ name, owner, secret, duration, resolverAddress, address = EMPTY_ADDRESS, }) => {
28
- const label = name.split('.')[0];
29
- return [label, owner, BigInt(duration), secret, resolverAddress, address];
30
- };
31
- export const makeLegacyCommitmentFromTuple = ([label, ...others]) => {
32
- const labelHash = labelhash(label);
33
- const params = [labelHash, ...others];
34
- if (params.length === 3)
35
- return keccak256(encodePacked(['bytes32', 'address', 'bytes32'], params));
36
- const [owner, secret, resolverAddress = EMPTY_ADDRESS, address = EMPTY_ADDRESS,] = others;
37
- return keccak256(encodePacked(['bytes32', 'address', 'address', 'address', 'bytes32'], [labelHash, owner, resolverAddress, address, secret]));
38
- };
39
- export const makeLegacyCommitment = (params) => {
40
- const touple = isLegacyRegistrationWithConfigParameters(params)
41
- ? makeLegacyCommitmentWithConfigTuple(params)
42
- : makeLegacyCommitmentTuple(params);
43
- return makeLegacyCommitmentFromTuple(touple);
44
- };
45
- //# sourceMappingURL=legacyRegisterHelpers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"legacyRegisterHelpers.js","sourceRoot":"","sources":["../../src/utils/legacyRegisterHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,YAAY,EACZ,SAAS,EACT,SAAS,GACV,MAAM,MAAM,CAAA;AACb,OAAO,EAAE,oCAAoC,EAAE,MAAM,uBAAuB,CAAA;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAuB3C,MAAM,CAAC,MAAM,wCAAwC,GAAG,CACtD,MAAoC,EACc,EAAE;IACpD,MAAM,EAAE,eAAe,GAAG,aAAa,EAAE,OAAO,GAAG,aAAa,EAAE,GAChE,MAAgD,CAAA;IAElD,IAAI,eAAe,KAAK,aAAa,IAAI,OAAO,KAAK,aAAa;QAChE,MAAM,IAAI,oCAAoC,CAAC;YAC7C,eAAe;YACf,OAAO;SACR,CAAC,CAAA;IACJ,OAAO,eAAe,KAAK,aAAa,IAAI,OAAO,KAAK,aAAa,CAAA;AACvE,CAAC,CAAA;A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AAK,EAAE,MAAM,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,eAAe,EAAE,OAAO,CAAC,CAAA;AAC3E,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,CAAC,KAAK,EAAE,GAAG,MAAM,CAE5B,EAAO,EAAE;IAC1C,MAAM,SAAS,GAAG,SAAS,CAAC,KAAK,CAAC,CAAA;IAClC,MAAM,MAAM,GAAG,CAAC,SAAS,EAAE,GAAG,MAAM,CAAU,CAAA;IAE9C,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QACrB,OAAO,SAAS,CAAC,YAAY,CAAC,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC,EAAE,MAAM,CAAC,CAAC,CAAA;IAE3E,MAAM,CACJ,KAAK,EACL,MAAM,EACN,eAAe,GAAG,aAAa,EAC/B,OAAO,GAAG,aAAa,EACxB,GAAG,MAAM,CAAA;IAEV,OAAO,SAAS,CACd,YAAY,CACV,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC,EACvD,CAAC,SAAS,EAAE,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,CAAC,CACrD,CACF,CAAA;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,MAA6E,EACxE,EAAE;IACP,MAAM,MAAM,GAAG,wCAAwC,CAAC,MAAM,CAAC;QAC7D,CAAC,CAAC,mCAAmC,CAAC,MAAM,CAAC;QAC7C,CAAC,CAAC,yBAAyB,CAAC,MAAM,CAAC,CAAA;IACrC,OAAO,6BAA6B,CAAC,MAAM,CAAC,CAAA;AAC9C,CAAC,CAAA"}
@@ -1,127 +0,0 @@
1
- import {
2
- type Account,
3
- type Hash,
4
- type SendTransactionParameters,
5
- type Transport,
6
- encodeFunctionData,
7
- } from 'viem'
8
- import { sendTransaction } from 'viem/actions'
9
- import type { ChainWithEns, ClientWithAccount } from '../../contracts/consts.js'
10
- import { getChainContractAddress } from '../../contracts/getChainContractAddress.js'
11
- import { legacyEthRegistrarControllerCommitSnippet } from '../../contracts/legacyEthRegistrarController.js'
12
- import { UnsupportedNameTypeError } from '../../errors/general.js'
13
- import type {
14
- Prettify,
15
- SimpleTransactionRequest,
16
- WriteTransactionParameters,
17
- } from '../../types.js'
18
- import { EMPTY_ADDRESS } from '../../utils/consts.js'
19
- import { getNameType } from '../../utils/getNameType.js'
20
- import {
21
- type LegacyRegistrationParameters,
22
- makeLegacyCommitment,
23
- } from '../../utils/legacyRegisterHelpers.js'
24
-
25
- export type LegacyCommitNameDataParameters = LegacyRegistrationParameters
26
-
27
- export type LegacyCommitNameDataReturnType = SimpleTransactionRequest
28
-
29
- export type LegacyCommitNameParameters<
30
- TChain extends ChainWithEns,
31
- TAccount extends Account | undefined,
32
- TChainOverride extends ChainWithEns | undefined,
33
- > = Prettify<
34
- LegacyCommitNameDataParameters &
35
- WriteTransactionParameters<TChain, TAccount, TChainOverride>
36
- >
37
-
38
- export type LegacyCommitNameReturnType = Hash
39
-
40
- export const makeFunctionData = <
41
- TChain extends ChainWithEns,
42
- TAccount extends Account | undefined,
43
- >(
44
- wallet: ClientWithAccount<Transport, TChain, TAccount>,
45
- args: LegacyCommitNameDataParameters,
46
- ): LegacyCommitNameDataReturnType => {
47
- const nameType = getNameType(args.name)
48
- if (nameType !== 'eth-2ld')
49
- throw new UnsupportedNameTypeError({
50
- nameType,
51
- supportedNameTypes: ['eth-2ld'],
52
- details: 'Only 2ld-eth name registration is supported',
53
- })
54
-
55
- return {
56
- to: getChainContractAddress({
57
- client: wallet,
58
- contract: 'legacyEthRegistrarController',
59
- }),
60
- data: encodeFunctionData({
61
- abi: legacyEthRegistrarControllerCommitSnippet,
62
- functionName: 'commit',
63
- args: [makeLegacyCommitment(args)],
64
- }),
65
- }
66
- }
67
-
68
- /**
69
- * Commits a name to be registered
70
- * @param wallet - {@link ClientWithAccount}
71
- * @param parameters - {@link LegacyCommitNameParameters}
72
- * @returns Transaction hash. {@link LegacyCommitNameReturnType}
73
- *
74
- * @example
75
- * import { createWalletClient, custom } from 'viem'
76
- * import { mainnet } from 'viem/chains'
77
- * import { addEnsContracts } from '@ensdomains/ensjs'
78
- * import { commitName } from '@ensdomains/ensjs/wallet'
79
- * import { randomSecret } from '@ensdomains/ensjs/utils'
80
- *
81
- * const wallet = createWalletClient({
82
- * chain: addEnsContracts(mainnet),
83
- * transport: custom(window.ethereum),
84
- * })
85
- * const secret = randomSecret()
86
- * const hash = await commitName(wallet, {
87
- * name: 'example.eth',
88
- * owner: '0xFe89cc7aBB2C4183683ab71653C4cdc9B02D44b7',
89
- * duration: 31536000, // 1 year
90
- * secret,
91
- * })
92
- * // 0x...
93
- */
94
- async function legacyCommitName<
95
- TChain extends ChainWithEns,
96
- TAccount extends Account | undefined,
97
- TChainOverride extends ChainWithEns | undefined = ChainWithEns,
98
- >(
99
- wallet: ClientWithAccount<Transport, TChain, TAccount>,
100
- {
101
- name,
102
- owner,
103
- duration,
104
- secret,
105
- resolverAddress = EMPTY_ADDRESS,
106
- address = EMPTY_ADDRESS,
107
- ...txArgs
108
- }: LegacyCommitNameParameters<TChain, TAccount, TChainOverride>,
109
- ): Promise<LegacyCommitNameReturnType> {
110
- const data = makeFunctionData(wallet, {
111
- name,
112
- owner,
113
- duration,
114
- secret,
115
- resolverAddress,
116
- address,
117
- })
118
- const writeArgs = {
119
- ...data,
120
- ...txArgs,
121
- } as SendTransactionParameters<TChain, TAccount, TChainOverride>
122
- return sendTransaction(wallet, writeArgs)
123
- }
124
-
125
- legacyCommitName.makeFunctionData = makeFunctionData
126
-
127
- export default legacyCommitName
@@ -1,159 +0,0 @@
1
- import {
2
- type Account,
3
- type Hash,
4
- type SendTransactionParameters,
5
- type Transport,
6
- encodeFunctionData,
7
- } from 'viem'
8
- import { sendTransaction } from 'viem/actions'
9
- import type { ChainWithEns, ClientWithAccount } from '../../contracts/consts.js'
10
- import { getChainContractAddress } from '../../contracts/getChainContractAddress.js'
11
- import {
12
- legacyEthRegistrarControllerRegisterSnippet,
13
- legacyEthRegistrarControllerRegisterWithConfigSnippet,
14
- } from '../../contracts/legacyEthRegistrarController.js'
15
- import { UnsupportedNameTypeError } from '../../errors/general.js'
16
- import type {
17
- Prettify,
18
- SimpleTransactionRequest,
19
- WriteTransactionParameters,
20
- } from '../../types.js'
21
- import { getNameType } from '../../utils/getNameType.js'
22
- import {
23
- type LegacyRegistrationParameters,
24
- isLegacyRegistrationWithConfigParameters,
25
- makeLegacyRegistrationTuple,
26
- makeLegacyRegistrationWithConfigTuple,
27
- } from '../../utils/legacyRegisterHelpers.js'
28
-
29
- export type LegacyRegisterNameDataParameters = LegacyRegistrationParameters & {
30
- /** Value of registration */
31
- value: bigint
32
- }
33
-
34
- export type LegacyRegisterNameDataReturnType = SimpleTransactionRequest & {
35
- value: bigint
36
- }
37
-
38
- export type LegacyRegisterNameParameters<
39
- TChain extends ChainWithEns,
40
- TAccount extends Account | undefined,
41
- TChainOverride extends ChainWithEns | undefined,
42
- > = Prettify<
43
- LegacyRegisterNameDataParameters &
44
- WriteTransactionParameters<TChain, TAccount, TChainOverride>
45
- >
46
-
47
- export type LegacyRegisterNameReturnType = Hash
48
-
49
- export const makeFunctionData = <
50
- TChain extends ChainWithEns,
51
- TAccount extends Account | undefined,
52
- >(
53
- wallet: ClientWithAccount<Transport, TChain, TAccount>,
54
- { value, ...args }: LegacyRegisterNameDataParameters,
55
- ): LegacyRegisterNameDataReturnType => {
56
- const nameType = getNameType(args.name)
57
- if (nameType !== 'eth-2ld')
58
- throw new UnsupportedNameTypeError({
59
- nameType,
60
- supportedNameTypes: ['eth-2ld'],
61
- details: 'Only 2ld-eth name registration is supported',
62
- })
63
-
64
- return {
65
- to: getChainContractAddress({
66
- client: wallet,
67
- contract: 'legacyEthRegistrarController',
68
- }),
69
- data: isLegacyRegistrationWithConfigParameters(args)
70
- ? encodeFunctionData({
71
- abi: legacyEthRegistrarControllerRegisterWithConfigSnippet,
72
- functionName: 'registerWithConfig',
73
- args: makeLegacyRegistrationWithConfigTuple(args),
74
- })
75
- : encodeFunctionData({
76
- abi: legacyEthRegistrarControllerRegisterSnippet,
77
- functionName: 'register',
78
- args: makeLegacyRegistrationTuple(args),
79
- }),
80
- value,
81
- }
82
- }
83
-
84
- /**
85
- * Registers a name on ENS
86
- * @param wallet - {@link ClientWithAccount}
87
- * @param parameters - {@link RegisterNameParameters}
88
- * @returns Transaction hash. {@link LegacyRegisterNameReturnType}
89
- *
90
- * @example
91
- * import { createPublicClient, createWalletClient, http, custom } from 'viem'
92
- * import { mainnet } from 'viem/chains'
93
- * import { addEnsContracts } from '@ensdomains/ensjs'
94
- * import { getPrice } from '@ensdomains/ensjs/public'
95
- * import { randomSecret } from '@ensdomains/ensjs/utils'
96
- * import { commitName, registerName } from '@ensdomains/ensjs/wallet'
97
- *
98
- * const mainnetWithEns = addEnsContracts(mainnet)
99
- * const client = createPublicClient({
100
- * chain: mainnetWithEns,
101
- * transport: http(),
102
- * })
103
- * const wallet = createWalletClient({
104
- * chain: mainnetWithEns,
105
- * transport: custom(window.ethereum),
106
- * })
107
- * const secret = randomSecret()
108
- * const params = {
109
- * name: 'example.eth',
110
- * owner: '0xFe89cc7aBB2C4183683ab71653C4cdc9B02D44b7',
111
- * duration: 31536000, // 1 year
112
- * secret,
113
- * }
114
- *
115
- * const commitmentHash = await commitName(wallet, params)
116
- * await client.waitForTransactionReceipt({ hash: commitmentHash }) // wait for commitment to finalise
117
- * await new Promise((resolve) => setTimeout(resolve, 60 * 1_000)) // wait for commitment to be valid
118
- *
119
- * const { base, premium } = await getPrice(client, { nameOrNames: params.name, duration: params.duration })
120
- * const value = (base + premium) * 110n / 100n // add 10% to the price for buffer
121
- * const hash = await registerName(wallet, { ...params, value })
122
- * // 0x...
123
- */
124
- async function legacyRegisterName<
125
- TChain extends ChainWithEns,
126
- TAccount extends Account | undefined,
127
- TChainOverride extends ChainWithEns | undefined = ChainWithEns,
128
- >(
129
- wallet: ClientWithAccount<Transport, TChain, TAccount>,
130
- {
131
- name,
132
- owner,
133
- duration,
134
- secret,
135
- resolverAddress,
136
- address,
137
- value,
138
- ...txArgs
139
- }: LegacyRegisterNameParameters<TChain, TAccount, TChainOverride>,
140
- ): Promise<LegacyRegisterNameReturnType> {
141
- const data = makeFunctionData(wallet, {
142
- name,
143
- owner,
144
- duration,
145
- secret,
146
- resolverAddress,
147
- address,
148
- value,
149
- })
150
- const writeArgs = {
151
- ...data,
152
- ...txArgs,
153
- } as SendTransactionParameters<TChain, TAccount, TChainOverride>
154
- return sendTransaction(wallet, writeArgs)
155
- }
156
-
157
- legacyRegisterName.makeFunctionData = makeFunctionData
158
-
159
- export default legacyRegisterName