@ensdomains/ensjs 3.0.0-beta.1 → 3.0.0-beta.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.
- package/dist/cjs/clients/decorators/subgraph.js.map +1 -1
- package/dist/cjs/contracts/consts.js +52 -1
- package/dist/cjs/contracts/consts.js.map +1 -1
- package/dist/cjs/dns.js +3 -3
- package/dist/cjs/dns.js.map +1 -1
- package/dist/cjs/errors/subgraph.js.map +1 -1
- package/dist/cjs/errors/utils.js +15 -18
- package/dist/cjs/errors/utils.js.map +1 -1
- package/dist/cjs/errors/version.js +1 -1
- package/dist/cjs/functions/dns/{prepareDnsImport.js → getDnsImportData.js} +3 -3
- package/dist/cjs/functions/dns/{prepareDnsImport.js.map → getDnsImportData.js.map} +1 -1
- package/dist/cjs/functions/dns/importDnsName.js +7 -7
- package/dist/cjs/functions/dns/importDnsName.js.map +1 -1
- package/dist/cjs/functions/public/_getContentHash.js +1 -1
- package/dist/cjs/functions/public/getSupportedInterfaces.js +1 -1
- package/dist/cjs/functions/public/getSupportedInterfaces.js.map +1 -1
- package/dist/cjs/functions/public/getWrapperData.js.map +1 -1
- package/dist/cjs/functions/subgraph/filters.js +3 -0
- package/dist/cjs/functions/subgraph/filters.js.map +1 -0
- package/dist/cjs/functions/subgraph/getNameHistory.js +1 -1
- package/dist/cjs/functions/subgraph/getNamesForAddress.js +140 -182
- package/dist/cjs/functions/subgraph/getNamesForAddress.js.map +1 -1
- package/dist/cjs/functions/subgraph/getSubnames.js +95 -108
- package/dist/cjs/functions/subgraph/getSubnames.js.map +1 -1
- package/dist/cjs/functions/subgraph/types.js +3 -0
- package/dist/cjs/functions/subgraph/types.js.map +1 -0
- package/dist/cjs/functions/subgraph/utils.js.map +1 -1
- package/dist/cjs/functions/wallet/createSubname.js +1 -1
- package/dist/cjs/functions/wallet/createSubname.js.map +1 -1
- package/dist/cjs/functions/wallet/setChildFuses.js +1 -1
- package/dist/cjs/functions/wallet/setChildFuses.js.map +1 -1
- package/dist/cjs/functions/wallet/setFuses.js +1 -1
- package/dist/cjs/functions/wallet/setFuses.js.map +1 -1
- package/dist/cjs/functions/wallet/wrapName.js +3 -1
- package/dist/cjs/functions/wallet/wrapName.js.map +1 -1
- package/dist/cjs/index.js +1 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/utils/contentHash.js +54 -131
- package/dist/cjs/utils/contentHash.js.map +1 -1
- package/dist/cjs/utils/encoders/encodeSetContentHash.js +1 -4
- package/dist/cjs/utils/encoders/encodeSetContentHash.js.map +1 -1
- package/dist/cjs/utils/format.js +1 -5
- package/dist/cjs/utils/format.js.map +1 -1
- package/dist/cjs/utils/fuses.js +181 -200
- package/dist/cjs/utils/fuses.js.map +1 -1
- package/dist/cjs/utils/index.js +4 -7
- package/dist/cjs/utils/index.js.map +1 -1
- package/dist/cjs/utils/registerHelpers.js +3 -1
- package/dist/cjs/utils/registerHelpers.js.map +1 -1
- package/dist/esm/clients/decorators/subgraph.js.map +1 -1
- package/dist/esm/contracts/consts.js +52 -1
- package/dist/esm/contracts/consts.js.map +1 -1
- package/dist/esm/dns.js +1 -1
- package/dist/esm/dns.js.map +1 -1
- package/dist/esm/errors/subgraph.js.map +1 -1
- package/dist/esm/errors/utils.js +13 -16
- package/dist/esm/errors/utils.js.map +1 -1
- package/dist/esm/errors/version.js +1 -1
- package/dist/esm/functions/dns/{prepareDnsImport.js → getDnsImportData.js} +9 -10
- package/dist/esm/functions/dns/getDnsImportData.js.map +1 -0
- package/dist/esm/functions/dns/importDnsName.js +12 -12
- package/dist/esm/functions/dns/importDnsName.js.map +1 -1
- package/dist/esm/functions/public/_getContentHash.js +2 -2
- package/dist/esm/functions/public/getSupportedInterfaces.js +2 -2
- package/dist/esm/functions/public/getSupportedInterfaces.js.map +1 -1
- package/dist/esm/functions/public/getWrapperData.js.map +1 -1
- package/dist/esm/functions/subgraph/filters.js +2 -0
- package/dist/esm/functions/subgraph/filters.js.map +1 -0
- package/dist/esm/functions/subgraph/getNameHistory.js +2 -2
- package/dist/esm/functions/subgraph/getNamesForAddress.js +144 -183
- package/dist/esm/functions/subgraph/getNamesForAddress.js.map +1 -1
- package/dist/esm/functions/subgraph/getSubnames.js +101 -111
- package/dist/esm/functions/subgraph/getSubnames.js.map +1 -1
- package/dist/esm/functions/subgraph/types.js +2 -0
- package/dist/esm/functions/subgraph/types.js.map +1 -0
- package/dist/esm/functions/subgraph/utils.js.map +1 -1
- package/dist/esm/functions/wallet/createSubname.js +1 -1
- package/dist/esm/functions/wallet/createSubname.js.map +1 -1
- package/dist/esm/functions/wallet/setChildFuses.js +1 -1
- package/dist/esm/functions/wallet/setChildFuses.js.map +1 -1
- package/dist/esm/functions/wallet/setFuses.js +2 -2
- package/dist/esm/functions/wallet/setFuses.js.map +1 -1
- package/dist/esm/functions/wallet/wrapName.js +4 -2
- package/dist/esm/functions/wallet/wrapName.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/utils/contentHash.js +51 -128
- package/dist/esm/utils/contentHash.js.map +1 -1
- package/dist/esm/utils/encoders/encodeSetContentHash.js +2 -5
- package/dist/esm/utils/encoders/encodeSetContentHash.js.map +1 -1
- package/dist/esm/utils/format.js +0 -2
- package/dist/esm/utils/format.js.map +1 -1
- package/dist/esm/utils/fuses.js +180 -201
- package/dist/esm/utils/fuses.js.map +1 -1
- package/dist/esm/utils/index.js +2 -2
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/esm/utils/registerHelpers.js +4 -2
- package/dist/esm/utils/registerHelpers.js.map +1 -1
- package/dist/types/clients/decorators/subgraph.d.ts +1 -1
- package/dist/types/clients/decorators/subgraph.d.ts.map +1 -1
- package/dist/types/clients/decorators/wallet.d.ts +12 -12
- package/dist/types/clients/public.d.ts +1 -1
- package/dist/types/clients/subgraph.d.ts +1 -1
- package/dist/types/clients/wallet.d.ts +43 -79
- package/dist/types/clients/wallet.d.ts.map +1 -1
- package/dist/types/contracts/consts.d.ts +51 -2
- package/dist/types/contracts/consts.d.ts.map +1 -1
- package/dist/types/dns.d.ts +1 -1
- package/dist/types/dns.d.ts.map +1 -1
- package/dist/types/errors/subgraph.d.ts +4 -4
- package/dist/types/errors/subgraph.d.ts.map +1 -1
- package/dist/types/errors/utils.d.ts +10 -13
- package/dist/types/errors/utils.d.ts.map +1 -1
- package/dist/types/errors/version.d.ts +1 -1
- package/dist/types/functions/dns/{prepareDnsImport.d.ts → getDnsImportData.d.ts} +11 -12
- package/dist/types/functions/dns/{prepareDnsImport.d.ts.map → getDnsImportData.d.ts.map} +1 -1
- package/dist/types/functions/dns/importDnsName.d.ts +36 -36
- package/dist/types/functions/dns/importDnsName.d.ts.map +1 -1
- package/dist/types/functions/public/getSupportedInterfaces.d.ts +19 -4
- package/dist/types/functions/public/getSupportedInterfaces.d.ts.map +1 -1
- package/dist/types/functions/public/getWrapperData.d.ts +2 -2
- package/dist/types/functions/public/getWrapperData.d.ts.map +1 -1
- package/dist/types/functions/subgraph/filters.d.ts +693 -0
- package/dist/types/functions/subgraph/filters.d.ts.map +1 -0
- package/dist/types/functions/subgraph/getNamesForAddress.d.ts +2 -0
- package/dist/types/functions/subgraph/getNamesForAddress.d.ts.map +1 -1
- package/dist/types/functions/subgraph/getSubnames.d.ts +3 -1
- package/dist/types/functions/subgraph/getSubnames.d.ts.map +1 -1
- package/dist/types/functions/subgraph/types.d.ts +13 -0
- package/dist/types/functions/subgraph/types.d.ts.map +1 -0
- package/dist/types/functions/subgraph/utils.d.ts +2 -2
- package/dist/types/functions/subgraph/utils.d.ts.map +1 -1
- package/dist/types/functions/wallet/commitName.d.ts +25 -25
- package/dist/types/functions/wallet/createSubname.d.ts +28 -28
- package/dist/types/functions/wallet/createSubname.d.ts.map +1 -1
- package/dist/types/functions/wallet/deleteSubname.d.ts +25 -25
- package/dist/types/functions/wallet/registerName.d.ts +24 -24
- package/dist/types/functions/wallet/renewNames.d.ts +24 -24
- package/dist/types/functions/wallet/setAbiRecord.d.ts +25 -25
- package/dist/types/functions/wallet/setAddressRecord.d.ts +25 -25
- package/dist/types/functions/wallet/setChildFuses.d.ts +27 -27
- package/dist/types/functions/wallet/setChildFuses.d.ts.map +1 -1
- package/dist/types/functions/wallet/setContentHashRecord.d.ts +25 -25
- package/dist/types/functions/wallet/setFuses.d.ts +27 -27
- package/dist/types/functions/wallet/setFuses.d.ts.map +1 -1
- package/dist/types/functions/wallet/setPrimaryName.d.ts +25 -25
- package/dist/types/functions/wallet/setRecords.d.ts +25 -25
- package/dist/types/functions/wallet/setResolver.d.ts +25 -25
- package/dist/types/functions/wallet/setTextRecord.d.ts +25 -25
- package/dist/types/functions/wallet/transferName.d.ts +25 -25
- package/dist/types/functions/wallet/unwrapName.d.ts +25 -25
- package/dist/types/functions/wallet/wrapName.d.ts +27 -27
- package/dist/types/functions/wallet/wrapName.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/utils/contentHash.d.ts +7 -11
- package/dist/types/utils/contentHash.d.ts.map +1 -1
- package/dist/types/utils/encoders/encodeSetContentHash.d.ts.map +1 -1
- package/dist/types/utils/format.d.ts +0 -2
- package/dist/types/utils/format.d.ts.map +1 -1
- package/dist/types/utils/fuses.d.ts +164 -125
- package/dist/types/utils/fuses.d.ts.map +1 -1
- package/dist/types/utils/index.d.ts +2 -2
- package/dist/types/utils/index.d.ts.map +1 -1
- package/dist/types/utils/registerHelpers.d.ts +2 -2
- package/dist/types/utils/registerHelpers.d.ts.map +1 -1
- package/package.json +4 -3
- package/src/clients/decorators/subgraph.ts +1 -0
- package/src/contracts/consts.ts +57 -12
- package/src/dns.ts +5 -5
- package/src/errors/subgraph.ts +4 -4
- package/src/errors/utils.ts +21 -18
- package/src/errors/version.ts +1 -1
- package/src/functions/dns/{prepareDnsImport.ts → getDnsImportData.ts} +12 -13
- package/src/functions/dns/importDnsName.ts +20 -15
- package/src/functions/public/_getContentHash.ts +2 -2
- package/src/functions/public/getSupportedInterfaces.ts +48 -10
- package/src/functions/public/getWrapperData.ts +2 -2
- package/src/functions/subgraph/filters.ts +702 -0
- package/src/functions/subgraph/getNameHistory.ts +2 -2
- package/src/functions/subgraph/getNamesForAddress.ts +170 -186
- package/src/functions/subgraph/getSubnames.ts +121 -113
- package/src/functions/subgraph/types.ts +13 -0
- package/src/functions/subgraph/utils.ts +2 -2
- package/src/functions/wallet/createSubname.ts +4 -4
- package/src/functions/wallet/setChildFuses.ts +3 -3
- package/src/functions/wallet/setFuses.ts +6 -3
- package/src/functions/wallet/wrapName.ts +8 -3
- package/src/index.ts +0 -1
- package/src/utils/contentHash.ts +59 -113
- package/src/utils/encoders/encodeSetContentHash.ts +2 -4
- package/src/utils/format.ts +0 -6
- package/src/utils/fuses.ts +308 -308
- package/src/utils/index.ts +4 -5
- package/src/utils/registerHelpers.ts +5 -3
- package/dist/esm/functions/dns/prepareDnsImport.js.map +0 -1
- package/src/@types/@ensdomains/content-hash.d.ts +0 -1
- package/src/functions/dns/getDnsOwner.test.ts +0 -195
- package/src/functions/dns/importDnsName.test.ts +0 -117
- package/src/functions/dns/prepareDnsImport.test.ts +0 -115
- package/src/functions/public/batch.test.ts +0 -67
- package/src/functions/public/ccip.test.ts +0 -78
- package/src/functions/public/getAbiRecord.test.ts +0 -174
- package/src/functions/public/getAddressRecord.test.ts +0 -83
- package/src/functions/public/getAvailable.test.ts +0 -17
- package/src/functions/public/getContentHashRecord.test.ts +0 -28
- package/src/functions/public/getExpiry.test.ts +0 -48
- package/src/functions/public/getName.test.ts +0 -66
- package/src/functions/public/getOwner.test.ts +0 -87
- package/src/functions/public/getPrice.test.ts +0 -45
- package/src/functions/public/getRecords.test.ts +0 -49
- package/src/functions/public/getResolver.test.ts +0 -12
- package/src/functions/public/getTextRecord.test.ts +0 -20
- package/src/functions/public/getWrapperData.test.ts +0 -79
- package/src/functions/public/getWrapperName.test.ts +0 -19
- package/src/functions/subgraph/client.test.ts +0 -170
- package/src/functions/subgraph/getDecodedName.test.ts +0 -31
- package/src/functions/subgraph/getNameHistory.test.ts +0 -39
- package/src/functions/subgraph/getNamesForAddress.test.ts +0 -244
- package/src/functions/subgraph/getSubgraphRecords.test.ts +0 -74
- package/src/functions/subgraph/getSubgraphRegistrant.test.ts +0 -34
- package/src/functions/subgraph/getSubnames.test.ts +0 -202
- package/src/functions/wallet/commitName.test.ts +0 -58
- package/src/functions/wallet/createSubname.test.ts +0 -73
- package/src/functions/wallet/deleteSubname.test.ts +0 -150
- package/src/functions/wallet/registerName.test.ts +0 -81
- package/src/functions/wallet/renewNames.test.ts +0 -92
- package/src/functions/wallet/setAbiRecord.test.ts +0 -156
- package/src/functions/wallet/setAddressRecord.test.ts +0 -121
- package/src/functions/wallet/setChildFuses.test.ts +0 -97
- package/src/functions/wallet/setContentHashRecord.test.ts +0 -69
- package/src/functions/wallet/setFuses.test.ts +0 -287
- package/src/functions/wallet/setPrimaryName.test.ts +0 -71
- package/src/functions/wallet/setRecords.test.ts +0 -127
- package/src/functions/wallet/setResolver.test.ts +0 -114
- package/src/functions/wallet/setTextRecord.test.ts +0 -67
- package/src/functions/wallet/transferName.test.ts +0 -201
- package/src/functions/wallet/unwrapName.test.ts +0 -93
- package/src/functions/wallet/wrapName.test.ts +0 -195
- package/src/utils/generateRecordCallArray.test.ts +0 -84
- package/src/utils/labels.test.ts +0 -163
- package/src/utils/makeLabelNodeAndParent.test.ts +0 -11
- package/src/utils/makeSafeSecondsDate.test.ts +0 -14
- package/src/utils/normalise.test.ts +0 -35
- package/src/utils/ownerFromContract.test.ts +0 -52
- package/src/utils/registerHelpers.test.ts +0 -159
- package/src/utils/validation.test.ts +0 -170
- package/src/utils/wrapper.test.ts +0 -46
package/src/errors/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = 'v3.0.0-beta.
|
|
1
|
+
export const version = 'v3.0.0-beta.3'
|
|
@@ -13,7 +13,7 @@ import { DnsNewerRecordTypeAvailableError } from '../../errors/dns.js'
|
|
|
13
13
|
import { packetToBytes } from '../../utils/hexEncodedName.js'
|
|
14
14
|
import type { Endpoint } from './types.js'
|
|
15
15
|
|
|
16
|
-
export type
|
|
16
|
+
export type GetDnsImportDataParameters = {
|
|
17
17
|
/** Name to prepare for DNS import */
|
|
18
18
|
name: string
|
|
19
19
|
/** An RFC-1035 compatible DNS endpoint to use (default: `https://cloudflare-dns.com/dns-query`) */
|
|
@@ -25,7 +25,7 @@ export type RrSetWithSig = {
|
|
|
25
25
|
sig: Uint8Array
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
export type
|
|
28
|
+
export type GetDnsImportDataReturnType = {
|
|
29
29
|
rrsets: RrSetWithSig[]
|
|
30
30
|
proof: Uint8Array
|
|
31
31
|
}
|
|
@@ -43,32 +43,31 @@ const encodeProofs = (
|
|
|
43
43
|
}))
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
|
-
*
|
|
46
|
+
* Gets DNS import data, used for `importDnsName()`
|
|
47
47
|
* @param client - {@link ClientWithEns}
|
|
48
|
-
* @param parameters - {@link
|
|
49
|
-
* @returns
|
|
48
|
+
* @param parameters - {@link GetDnsImportDataParameters}
|
|
49
|
+
* @returns DNS import data object, used for proving the value of the `_ens` TXT record
|
|
50
50
|
*
|
|
51
51
|
* @example
|
|
52
52
|
* import { createPublicClient, http } from 'viem'
|
|
53
53
|
* import { mainnet } from 'viem/chains'
|
|
54
|
-
* import {
|
|
54
|
+
* import { addEnsContracts, getDnsImportData } from '@ensdomains/ensjs'
|
|
55
55
|
*
|
|
56
|
-
* const mainnetWithEns = addContracts([mainnet])
|
|
57
56
|
* const client = createPublicClient({
|
|
58
|
-
* chain:
|
|
57
|
+
* chain: addEnsContracts(mainnet),
|
|
59
58
|
* transport: http(),
|
|
60
59
|
* })
|
|
61
|
-
* const
|
|
60
|
+
* const data = await getDnsImportData(client, {
|
|
62
61
|
* name: 'example.eth',
|
|
63
62
|
* })
|
|
64
63
|
*/
|
|
65
|
-
const
|
|
64
|
+
const getDnsImportData = async (
|
|
66
65
|
client: ClientWithEns,
|
|
67
66
|
{
|
|
68
67
|
name,
|
|
69
68
|
endpoint = 'https://cloudflare-dns.com/dns-query',
|
|
70
|
-
}:
|
|
71
|
-
): Promise<
|
|
69
|
+
}: GetDnsImportDataParameters,
|
|
70
|
+
): Promise<GetDnsImportDataReturnType> => {
|
|
72
71
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
73
72
|
const { DNSProver } = await import('@ensdomains/dnsprovejs')
|
|
74
73
|
const prover = DNSProver.create(endpoint)
|
|
@@ -130,4 +129,4 @@ const prepareDnsImport = async (
|
|
|
130
129
|
}
|
|
131
130
|
}
|
|
132
131
|
|
|
133
|
-
export default
|
|
132
|
+
export default getDnsImportData
|
|
@@ -21,13 +21,13 @@ import type {
|
|
|
21
21
|
WriteTransactionParameters,
|
|
22
22
|
} from '../../types.js'
|
|
23
23
|
import { packetToBytes } from '../../utils/hexEncodedName.js'
|
|
24
|
-
import type {
|
|
24
|
+
import type { GetDnsImportDataReturnType } from './getDnsImportData.js'
|
|
25
25
|
|
|
26
26
|
type BaseImportDnsNameDataParameters = {
|
|
27
27
|
/** Name to import */
|
|
28
28
|
name: string
|
|
29
|
-
/** Data returned from `
|
|
30
|
-
|
|
29
|
+
/** Data returned from `getDnsImportData()` */
|
|
30
|
+
dnsImportData: GetDnsImportDataReturnType
|
|
31
31
|
/** Address to claim the name for */
|
|
32
32
|
address?: Address
|
|
33
33
|
/** Address of the resolver to use (default: `ensPublicResolver`) */
|
|
@@ -65,9 +65,14 @@ export const makeFunctionData = <
|
|
|
65
65
|
TAccount extends Account | undefined,
|
|
66
66
|
>(
|
|
67
67
|
wallet: WalletWithEns<Transport, TChain, TAccount>,
|
|
68
|
-
{
|
|
68
|
+
{
|
|
69
|
+
name,
|
|
70
|
+
dnsImportData,
|
|
71
|
+
address,
|
|
72
|
+
resolverAddress,
|
|
73
|
+
}: ImportDnsNameDataParameters,
|
|
69
74
|
): ImportDnsNameDataReturnType => {
|
|
70
|
-
const data =
|
|
75
|
+
const data = dnsImportData.rrsets.map((rrset) => ({
|
|
71
76
|
rrset: bytesToHex(rrset.rrset),
|
|
72
77
|
sig: bytesToHex(rrset.sig),
|
|
73
78
|
}))
|
|
@@ -81,7 +86,7 @@ export const makeFunctionData = <
|
|
|
81
86
|
if (resolverAddress)
|
|
82
87
|
throw new AdditionalParameterSpecifiedError({
|
|
83
88
|
parameter: 'resolverAddress',
|
|
84
|
-
allowedParameters: ['name', '
|
|
89
|
+
allowedParameters: ['name', 'dnsImportData'],
|
|
85
90
|
details:
|
|
86
91
|
'resolverAddress cannot be specified when claiming without an address',
|
|
87
92
|
})
|
|
@@ -90,7 +95,7 @@ export const makeFunctionData = <
|
|
|
90
95
|
data: encodeFunctionData({
|
|
91
96
|
abi: dnsRegistrarProveAndClaimSnippet,
|
|
92
97
|
functionName: 'proveAndClaim',
|
|
93
|
-
args: [hexEncodedName, data, bytesToHex(
|
|
98
|
+
args: [hexEncodedName, data, bytesToHex(dnsImportData.proof)],
|
|
94
99
|
}),
|
|
95
100
|
}
|
|
96
101
|
}
|
|
@@ -107,7 +112,7 @@ export const makeFunctionData = <
|
|
|
107
112
|
args: [
|
|
108
113
|
hexEncodedName,
|
|
109
114
|
data,
|
|
110
|
-
bytesToHex(
|
|
115
|
+
bytesToHex(dnsImportData.proof),
|
|
111
116
|
resolverAddress_,
|
|
112
117
|
address,
|
|
113
118
|
],
|
|
@@ -124,9 +129,9 @@ export const makeFunctionData = <
|
|
|
124
129
|
* @example
|
|
125
130
|
* import { createPublicClient, createWalletClient, http, custom } from 'viem'
|
|
126
131
|
* import { mainnet } from 'viem/chains'
|
|
127
|
-
* import {
|
|
132
|
+
* import { addEnsContracts, getDnsImportData, importDnsName } from '@ensdomains/ensjs'
|
|
128
133
|
*
|
|
129
|
-
* const
|
|
134
|
+
* const mainnetWithEns = addEnsContracts(mainnet)
|
|
130
135
|
* const client = createPublicClient({
|
|
131
136
|
* chain: mainnetWithEns,
|
|
132
137
|
* transport: http(),
|
|
@@ -135,12 +140,12 @@ export const makeFunctionData = <
|
|
|
135
140
|
* chain: mainnetWithEns,
|
|
136
141
|
* transport: custom(window.ethereum),
|
|
137
142
|
* })
|
|
138
|
-
* const
|
|
143
|
+
* const dnsImportData = await getDnsImportData(client, {
|
|
139
144
|
* name: 'example.com',
|
|
140
145
|
* })
|
|
141
|
-
* const hash = await importDnsName(
|
|
146
|
+
* const hash = await importDnsName(wallet, {
|
|
142
147
|
* name: 'example.com',
|
|
143
|
-
*
|
|
148
|
+
* dnsImportData,
|
|
144
149
|
* })
|
|
145
150
|
*/
|
|
146
151
|
async function importDnsName<
|
|
@@ -152,7 +157,7 @@ async function importDnsName<
|
|
|
152
157
|
{
|
|
153
158
|
name,
|
|
154
159
|
address,
|
|
155
|
-
|
|
160
|
+
dnsImportData,
|
|
156
161
|
resolverAddress,
|
|
157
162
|
...txArgs
|
|
158
163
|
}: ImportDnsNameParameters<TChain, TAccount, TChainOverride>,
|
|
@@ -160,7 +165,7 @@ async function importDnsName<
|
|
|
160
165
|
const data = makeFunctionData(wallet, {
|
|
161
166
|
name,
|
|
162
167
|
address,
|
|
163
|
-
|
|
168
|
+
dnsImportData,
|
|
164
169
|
resolverAddress,
|
|
165
170
|
} as ImportDnsNameDataParameters)
|
|
166
171
|
const writeArgs = {
|
|
@@ -4,7 +4,7 @@ import { publicResolverContenthashSnippet } from '../../contracts/publicResolver
|
|
|
4
4
|
import type { Prettify, SimpleTransactionRequest } from '../../types.js'
|
|
5
5
|
import { EMPTY_ADDRESS } from '../../utils/consts.js'
|
|
6
6
|
import {
|
|
7
|
-
|
|
7
|
+
decodeContentHash,
|
|
8
8
|
type DecodedContentHash,
|
|
9
9
|
} from '../../utils/contentHash.js'
|
|
10
10
|
import { generateFunction } from '../../utils/generateFunction.js'
|
|
@@ -44,7 +44,7 @@ const decode = async (
|
|
|
44
44
|
data,
|
|
45
45
|
})
|
|
46
46
|
|
|
47
|
-
return
|
|
47
|
+
return decodeContentHash(response)
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
const _getContentHash = generateFunction({ encode, decode })
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
BaseError,
|
|
3
|
+
encodeFunctionData,
|
|
4
|
+
padHex,
|
|
5
|
+
type Address,
|
|
6
|
+
type Hex,
|
|
7
|
+
} from 'viem'
|
|
2
8
|
import type { ClientWithEns } from '../../contracts/consts.js'
|
|
3
9
|
import { erc165SupportsInterfaceSnippet } from '../../contracts/erc165.js'
|
|
4
10
|
import type {
|
|
@@ -8,12 +14,18 @@ import type {
|
|
|
8
14
|
import { generateFunction } from '../../utils/generateFunction.js'
|
|
9
15
|
import multicallWrapper from './multicallWrapper.js'
|
|
10
16
|
|
|
11
|
-
export type GetSupportedInterfacesParameters
|
|
17
|
+
export type GetSupportedInterfacesParameters<
|
|
18
|
+
TInterfaces extends readonly Hex[],
|
|
19
|
+
> = {
|
|
12
20
|
address: Address
|
|
13
|
-
interfaces:
|
|
21
|
+
interfaces: TInterfaces
|
|
14
22
|
}
|
|
15
23
|
|
|
16
|
-
export type GetSupportedInterfacesReturnType
|
|
24
|
+
export type GetSupportedInterfacesReturnType<
|
|
25
|
+
TInterfaces extends readonly Hex[],
|
|
26
|
+
> = {
|
|
27
|
+
-readonly [K in keyof TInterfaces]: boolean
|
|
28
|
+
}
|
|
17
29
|
|
|
18
30
|
const encodeInterface = (interfaceId: Hex): Hex =>
|
|
19
31
|
encodeFunctionData({
|
|
@@ -22,9 +34,9 @@ const encodeInterface = (interfaceId: Hex): Hex =>
|
|
|
22
34
|
args: [interfaceId],
|
|
23
35
|
})
|
|
24
36
|
|
|
25
|
-
const encode = (
|
|
37
|
+
const encode = <TInterfaces extends Hex[]>(
|
|
26
38
|
client: ClientWithEns,
|
|
27
|
-
{ address, interfaces }: GetSupportedInterfacesParameters
|
|
39
|
+
{ address, interfaces }: GetSupportedInterfacesParameters<TInterfaces>,
|
|
28
40
|
): TransactionRequestWithPassthrough => {
|
|
29
41
|
const calls = interfaces.map((interfaceId) => ({
|
|
30
42
|
to: address,
|
|
@@ -39,16 +51,42 @@ const encode = (
|
|
|
39
51
|
}
|
|
40
52
|
}
|
|
41
53
|
|
|
42
|
-
const decode = async (
|
|
54
|
+
const decode = async <const TInterfaces extends readonly Hex[]>(
|
|
43
55
|
client: ClientWithEns,
|
|
44
56
|
data: Hex | BaseError,
|
|
45
57
|
passthrough: SimpleTransactionRequest[],
|
|
46
|
-
): Promise<GetSupportedInterfacesReturnType
|
|
58
|
+
): Promise<GetSupportedInterfacesReturnType<TInterfaces>> => {
|
|
47
59
|
if (typeof data === 'object') throw data
|
|
48
60
|
const result = await multicallWrapper.decode(client, data, passthrough)
|
|
49
|
-
return result.map(
|
|
61
|
+
return result.map(
|
|
62
|
+
(r) => r.success && r.returnData === padHex('0x01'),
|
|
63
|
+
) as GetSupportedInterfacesReturnType<TInterfaces>
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
type EncoderFunction = typeof encode
|
|
67
|
+
type DecoderFunction = typeof decode
|
|
68
|
+
|
|
69
|
+
type BatchableFunctionObject = {
|
|
70
|
+
encode: EncoderFunction
|
|
71
|
+
decode: DecoderFunction
|
|
72
|
+
batch: <
|
|
73
|
+
const TInterfaces extends readonly Hex[],
|
|
74
|
+
TParams extends GetSupportedInterfacesParameters<TInterfaces>,
|
|
75
|
+
>(
|
|
76
|
+
args: TParams,
|
|
77
|
+
) => {
|
|
78
|
+
args: [TParams]
|
|
79
|
+
encode: EncoderFunction
|
|
80
|
+
decode: typeof decode<TInterfaces>
|
|
81
|
+
}
|
|
50
82
|
}
|
|
51
83
|
|
|
52
|
-
const getSupportedInterfaces = generateFunction({ encode, decode })
|
|
84
|
+
const getSupportedInterfaces = generateFunction({ encode, decode }) as (<
|
|
85
|
+
const TInterfaces extends readonly Hex[],
|
|
86
|
+
>(
|
|
87
|
+
client: ClientWithEns,
|
|
88
|
+
{ address, interfaces }: GetSupportedInterfacesParameters<TInterfaces>,
|
|
89
|
+
) => Promise<GetSupportedInterfacesReturnType<TInterfaces>>) &
|
|
90
|
+
BatchableFunctionObject
|
|
53
91
|
|
|
54
92
|
export default getSupportedInterfaces
|
|
@@ -16,7 +16,7 @@ import type {
|
|
|
16
16
|
TransactionRequestWithPassthrough,
|
|
17
17
|
} from '../../types.js'
|
|
18
18
|
import { EMPTY_ADDRESS } from '../../utils/consts.js'
|
|
19
|
-
import { decodeFuses } from '../../utils/fuses.js'
|
|
19
|
+
import { decodeFuses, type DecodedFuses } from '../../utils/fuses.js'
|
|
20
20
|
import {
|
|
21
21
|
generateFunction,
|
|
22
22
|
type GeneratedFunction,
|
|
@@ -31,7 +31,7 @@ export type GetWrapperDataParameters = {
|
|
|
31
31
|
|
|
32
32
|
export type GetWrapperDataReturnType = Prettify<{
|
|
33
33
|
/** Fuse object */
|
|
34
|
-
fuses:
|
|
34
|
+
fuses: DecodedFuses & {
|
|
35
35
|
value: number
|
|
36
36
|
}
|
|
37
37
|
/** Expiry of the name */
|