thirdweb 5.60.1 → 5.61.0-nightly-27375af91b86eb21d251a99dec57e0a6470511ca-20241004000320
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/exports/extensions/unstoppable-domains.js +10 -0
- package/dist/cjs/exports/extensions/unstoppable-domains.js.map +1 -0
- package/dist/cjs/extensions/unstoppable-domains/__generated__/UnstoppableDomains/read/getMany.js +122 -0
- package/dist/cjs/extensions/unstoppable-domains/__generated__/UnstoppableDomains/read/getMany.js.map +1 -0
- package/dist/cjs/extensions/unstoppable-domains/__generated__/UnstoppableDomains/read/namehash.js +115 -0
- package/dist/cjs/extensions/unstoppable-domains/__generated__/UnstoppableDomains/read/namehash.js.map +1 -0
- package/dist/cjs/extensions/unstoppable-domains/__generated__/UnstoppableDomains/read/reverseNameOf.js +115 -0
- package/dist/cjs/extensions/unstoppable-domains/__generated__/UnstoppableDomains/read/reverseNameOf.js.map +1 -0
- package/dist/cjs/extensions/unstoppable-domains/consts.js +5 -0
- package/dist/cjs/extensions/unstoppable-domains/consts.js.map +1 -0
- package/dist/cjs/extensions/unstoppable-domains/read/resolveAddress.js +77 -0
- package/dist/cjs/extensions/unstoppable-domains/read/resolveAddress.js.map +1 -0
- package/dist/cjs/extensions/unstoppable-domains/read/resolveName.js +60 -0
- package/dist/cjs/extensions/unstoppable-domains/read/resolveName.js.map +1 -0
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/esm/exports/extensions/unstoppable-domains.js +4 -0
- package/dist/esm/exports/extensions/unstoppable-domains.js.map +1 -0
- package/dist/esm/extensions/unstoppable-domains/__generated__/UnstoppableDomains/read/getMany.js +114 -0
- package/dist/esm/extensions/unstoppable-domains/__generated__/UnstoppableDomains/read/getMany.js.map +1 -0
- package/dist/esm/extensions/unstoppable-domains/__generated__/UnstoppableDomains/read/namehash.js +107 -0
- package/dist/esm/extensions/unstoppable-domains/__generated__/UnstoppableDomains/read/namehash.js.map +1 -0
- package/dist/esm/extensions/unstoppable-domains/__generated__/UnstoppableDomains/read/reverseNameOf.js +107 -0
- package/dist/esm/extensions/unstoppable-domains/__generated__/UnstoppableDomains/read/reverseNameOf.js.map +1 -0
- package/dist/esm/extensions/unstoppable-domains/consts.js +2 -0
- package/dist/esm/extensions/unstoppable-domains/consts.js.map +1 -0
- package/dist/esm/extensions/unstoppable-domains/read/resolveAddress.js +74 -0
- package/dist/esm/extensions/unstoppable-domains/read/resolveAddress.js.map +1 -0
- package/dist/esm/extensions/unstoppable-domains/read/resolveName.js +57 -0
- package/dist/esm/extensions/unstoppable-domains/read/resolveName.js.map +1 -0
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/types/exports/extensions/unstoppable-domains.d.ts +4 -0
- package/dist/types/exports/extensions/unstoppable-domains.d.ts.map +1 -0
- package/dist/types/extensions/unstoppable-domains/__generated__/UnstoppableDomains/read/getMany.d.ts +90 -0
- package/dist/types/extensions/unstoppable-domains/__generated__/UnstoppableDomains/read/getMany.d.ts.map +1 -0
- package/dist/types/extensions/unstoppable-domains/__generated__/UnstoppableDomains/read/namehash.d.ts +83 -0
- package/dist/types/extensions/unstoppable-domains/__generated__/UnstoppableDomains/read/namehash.d.ts.map +1 -0
- package/dist/types/extensions/unstoppable-domains/__generated__/UnstoppableDomains/read/reverseNameOf.d.ts +83 -0
- package/dist/types/extensions/unstoppable-domains/__generated__/UnstoppableDomains/read/reverseNameOf.d.ts.map +1 -0
- package/dist/types/extensions/unstoppable-domains/consts.d.ts +2 -0
- package/dist/types/extensions/unstoppable-domains/consts.d.ts.map +1 -0
- package/dist/types/extensions/unstoppable-domains/read/resolveAddress.d.ts +45 -0
- package/dist/types/extensions/unstoppable-domains/read/resolveAddress.d.ts.map +1 -0
- package/dist/types/extensions/unstoppable-domains/read/resolveName.d.ts +43 -0
- package/dist/types/extensions/unstoppable-domains/read/resolveName.d.ts.map +1 -0
- package/dist/types/version.d.ts +1 -1
- package/dist/types/version.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/exports/extensions/unstoppable-domains.ts +9 -0
- package/src/extensions/unstoppable-domains/__generated__/UnstoppableDomains/read/getMany.ts +130 -0
- package/src/extensions/unstoppable-domains/__generated__/UnstoppableDomains/read/namehash.ts +124 -0
- package/src/extensions/unstoppable-domains/__generated__/UnstoppableDomains/read/reverseNameOf.ts +126 -0
- package/src/extensions/unstoppable-domains/consts.ts +1 -0
- package/src/extensions/unstoppable-domains/read/resolveAddress.test.ts +18 -0
- package/src/extensions/unstoppable-domains/read/resolveAddress.ts +96 -0
- package/src/extensions/unstoppable-domains/read/resolveName.test.ts +16 -0
- package/src/extensions/unstoppable-domains/read/resolveName.ts +77 -0
- package/src/version.ts +1 -1
@@ -0,0 +1,83 @@
|
|
1
|
+
import type { AbiParameterToPrimitiveType } from "abitype";
|
2
|
+
import type { BaseTransactionOptions } from "../../../../../transaction/types.js";
|
3
|
+
import type { Hex } from "../../../../../utils/encoding/hex.js";
|
4
|
+
/**
|
5
|
+
* Represents the parameters for the "namehash" function.
|
6
|
+
*/
|
7
|
+
export type NamehashParams = {
|
8
|
+
labels: AbiParameterToPrimitiveType<{
|
9
|
+
type: "string[]";
|
10
|
+
name: "labels";
|
11
|
+
}>;
|
12
|
+
};
|
13
|
+
export declare const FN_SELECTOR: "0x276fabb1";
|
14
|
+
/**
|
15
|
+
* Checks if the `namehash` method is supported by the given contract.
|
16
|
+
* @param availableSelectors An array of 4byte function selectors of the contract. You can get this in various ways, such as using "whatsabi" or if you have the ABI of the contract available you can use it to generate the selectors.
|
17
|
+
* @returns A boolean indicating if the `namehash` method is supported.
|
18
|
+
* @extension UNSTOPPABLE-DOMAINS
|
19
|
+
* @example
|
20
|
+
* ```ts
|
21
|
+
* import { isNamehashSupported } from "thirdweb/extensions/unstoppable-domains";
|
22
|
+
* const supported = isNamehashSupported(["0x..."]);
|
23
|
+
* ```
|
24
|
+
*/
|
25
|
+
export declare function isNamehashSupported(availableSelectors: string[]): boolean;
|
26
|
+
/**
|
27
|
+
* Encodes the parameters for the "namehash" function.
|
28
|
+
* @param options - The options for the namehash function.
|
29
|
+
* @returns The encoded ABI parameters.
|
30
|
+
* @extension UNSTOPPABLE-DOMAINS
|
31
|
+
* @example
|
32
|
+
* ```ts
|
33
|
+
* import { encodeNamehashParams } from "thirdweb/extensions/unstoppable-domains";
|
34
|
+
* const result = encodeNamehashParams({
|
35
|
+
* labels: ...,
|
36
|
+
* });
|
37
|
+
* ```
|
38
|
+
*/
|
39
|
+
export declare function encodeNamehashParams(options: NamehashParams): `0x${string}`;
|
40
|
+
/**
|
41
|
+
* Encodes the "namehash" function into a Hex string with its parameters.
|
42
|
+
* @param options - The options for the namehash function.
|
43
|
+
* @returns The encoded hexadecimal string.
|
44
|
+
* @extension UNSTOPPABLE-DOMAINS
|
45
|
+
* @example
|
46
|
+
* ```ts
|
47
|
+
* import { encodeNamehash } from "thirdweb/extensions/unstoppable-domains";
|
48
|
+
* const result = encodeNamehash({
|
49
|
+
* labels: ...,
|
50
|
+
* });
|
51
|
+
* ```
|
52
|
+
*/
|
53
|
+
export declare function encodeNamehash(options: NamehashParams): `${typeof FN_SELECTOR}${string}`;
|
54
|
+
/**
|
55
|
+
* Decodes the result of the namehash function call.
|
56
|
+
* @param result - The hexadecimal result to decode.
|
57
|
+
* @returns The decoded result as per the FN_OUTPUTS definition.
|
58
|
+
* @extension UNSTOPPABLE-DOMAINS
|
59
|
+
* @example
|
60
|
+
* ```ts
|
61
|
+
* import { decodeNamehashResult } from "thirdweb/extensions/unstoppable-domains";
|
62
|
+
* const result = decodeNamehashResultResult("...");
|
63
|
+
* ```
|
64
|
+
*/
|
65
|
+
export declare function decodeNamehashResult(result: Hex): bigint;
|
66
|
+
/**
|
67
|
+
* Calls the "namehash" function on the contract.
|
68
|
+
* @param options - The options for the namehash function.
|
69
|
+
* @returns The parsed result of the function call.
|
70
|
+
* @extension UNSTOPPABLE-DOMAINS
|
71
|
+
* @example
|
72
|
+
* ```ts
|
73
|
+
* import { namehash } from "thirdweb/extensions/unstoppable-domains";
|
74
|
+
*
|
75
|
+
* const result = await namehash({
|
76
|
+
* contract,
|
77
|
+
* labels: ...,
|
78
|
+
* });
|
79
|
+
*
|
80
|
+
* ```
|
81
|
+
*/
|
82
|
+
export declare function namehash(options: BaseTransactionOptions<NamehashParams>): Promise<bigint>;
|
83
|
+
//# sourceMappingURL=namehash.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"namehash.d.ts","sourceRoot":"","sources":["../../../../../../../src/extensions/unstoppable-domains/__generated__/UnstoppableDomains/read/namehash.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAC;AAE3D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAGlF,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,sCAAsC,CAAC;AAGhE;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,2BAA2B,CAAC;QAAE,IAAI,EAAE,UAAU,CAAC;QAAC,IAAI,EAAE,QAAQ,CAAA;KAAE,CAAC,CAAC;CAC3E,CAAC;AAEF,eAAO,MAAM,WAAW,cAAwB,CAAC;AAcjD;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,kBAAkB,EAAE,MAAM,EAAE,WAK/D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,cAAc,iBAE3D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,cAAc,GAIP,GAAG,OAAO,WAAW,GAAG,MAAM,EAAE,CAC9E;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,GAAG,UAE/C;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,QAAQ,CAC5B,OAAO,EAAE,sBAAsB,CAAC,cAAc,CAAC,mBAOhD"}
|
@@ -0,0 +1,83 @@
|
|
1
|
+
import type { AbiParameterToPrimitiveType } from "abitype";
|
2
|
+
import type { BaseTransactionOptions } from "../../../../../transaction/types.js";
|
3
|
+
import type { Hex } from "../../../../../utils/encoding/hex.js";
|
4
|
+
/**
|
5
|
+
* Represents the parameters for the "reverseNameOf" function.
|
6
|
+
*/
|
7
|
+
export type ReverseNameOfParams = {
|
8
|
+
addr: AbiParameterToPrimitiveType<{
|
9
|
+
type: "address";
|
10
|
+
name: "addr";
|
11
|
+
}>;
|
12
|
+
};
|
13
|
+
export declare const FN_SELECTOR: "0xbebec6b4";
|
14
|
+
/**
|
15
|
+
* Checks if the `reverseNameOf` method is supported by the given contract.
|
16
|
+
* @param availableSelectors An array of 4byte function selectors of the contract. You can get this in various ways, such as using "whatsabi" or if you have the ABI of the contract available you can use it to generate the selectors.
|
17
|
+
* @returns A boolean indicating if the `reverseNameOf` method is supported.
|
18
|
+
* @extension UNSTOPPABLE-DOMAINS
|
19
|
+
* @example
|
20
|
+
* ```ts
|
21
|
+
* import { isReverseNameOfSupported } from "thirdweb/extensions/unstoppable-domains";
|
22
|
+
* const supported = isReverseNameOfSupported(["0x..."]);
|
23
|
+
* ```
|
24
|
+
*/
|
25
|
+
export declare function isReverseNameOfSupported(availableSelectors: string[]): boolean;
|
26
|
+
/**
|
27
|
+
* Encodes the parameters for the "reverseNameOf" function.
|
28
|
+
* @param options - The options for the reverseNameOf function.
|
29
|
+
* @returns The encoded ABI parameters.
|
30
|
+
* @extension UNSTOPPABLE-DOMAINS
|
31
|
+
* @example
|
32
|
+
* ```ts
|
33
|
+
* import { encodeReverseNameOfParams } from "thirdweb/extensions/unstoppable-domains";
|
34
|
+
* const result = encodeReverseNameOfParams({
|
35
|
+
* addr: ...,
|
36
|
+
* });
|
37
|
+
* ```
|
38
|
+
*/
|
39
|
+
export declare function encodeReverseNameOfParams(options: ReverseNameOfParams): `0x${string}`;
|
40
|
+
/**
|
41
|
+
* Encodes the "reverseNameOf" function into a Hex string with its parameters.
|
42
|
+
* @param options - The options for the reverseNameOf function.
|
43
|
+
* @returns The encoded hexadecimal string.
|
44
|
+
* @extension UNSTOPPABLE-DOMAINS
|
45
|
+
* @example
|
46
|
+
* ```ts
|
47
|
+
* import { encodeReverseNameOf } from "thirdweb/extensions/unstoppable-domains";
|
48
|
+
* const result = encodeReverseNameOf({
|
49
|
+
* addr: ...,
|
50
|
+
* });
|
51
|
+
* ```
|
52
|
+
*/
|
53
|
+
export declare function encodeReverseNameOf(options: ReverseNameOfParams): `${typeof FN_SELECTOR}${string}`;
|
54
|
+
/**
|
55
|
+
* Decodes the result of the reverseNameOf function call.
|
56
|
+
* @param result - The hexadecimal result to decode.
|
57
|
+
* @returns The decoded result as per the FN_OUTPUTS definition.
|
58
|
+
* @extension UNSTOPPABLE-DOMAINS
|
59
|
+
* @example
|
60
|
+
* ```ts
|
61
|
+
* import { decodeReverseNameOfResult } from "thirdweb/extensions/unstoppable-domains";
|
62
|
+
* const result = decodeReverseNameOfResultResult("...");
|
63
|
+
* ```
|
64
|
+
*/
|
65
|
+
export declare function decodeReverseNameOfResult(result: Hex): string;
|
66
|
+
/**
|
67
|
+
* Calls the "reverseNameOf" function on the contract.
|
68
|
+
* @param options - The options for the reverseNameOf function.
|
69
|
+
* @returns The parsed result of the function call.
|
70
|
+
* @extension UNSTOPPABLE-DOMAINS
|
71
|
+
* @example
|
72
|
+
* ```ts
|
73
|
+
* import { reverseNameOf } from "thirdweb/extensions/unstoppable-domains";
|
74
|
+
*
|
75
|
+
* const result = await reverseNameOf({
|
76
|
+
* contract,
|
77
|
+
* addr: ...,
|
78
|
+
* });
|
79
|
+
*
|
80
|
+
* ```
|
81
|
+
*/
|
82
|
+
export declare function reverseNameOf(options: BaseTransactionOptions<ReverseNameOfParams>): Promise<string>;
|
83
|
+
//# sourceMappingURL=reverseNameOf.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"reverseNameOf.d.ts","sourceRoot":"","sources":["../../../../../../../src/extensions/unstoppable-domains/__generated__/UnstoppableDomains/read/reverseNameOf.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAC;AAE3D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAGlF,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,sCAAsC,CAAC;AAGhE;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,2BAA2B,CAAC;QAAE,IAAI,EAAE,SAAS,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACtE,CAAC;AAEF,eAAO,MAAM,WAAW,cAAwB,CAAC;AAcjD;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CAAC,kBAAkB,EAAE,MAAM,EAAE,WAKpE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,mBAAmB,iBAErE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,mBAAmB,GAMtD,GAAG,OAAO,WAAW,GAAG,MAAM,EAAE,CACzC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,GAAG,UAEpD;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,aAAa,CACjC,OAAO,EAAE,sBAAsB,CAAC,mBAAmB,CAAC,mBAOrD"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../../../../src/extensions/unstoppable-domains/consts.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,+CAA+C,CAAC"}
|
@@ -0,0 +1,45 @@
|
|
1
|
+
import type { Chain } from "../../../chains/types.js";
|
2
|
+
import type { ThirdwebClient } from "../../../client/client.js";
|
3
|
+
/**
|
4
|
+
* @extension UNSTOPPABLE-DOMAINS
|
5
|
+
*/
|
6
|
+
export type ResolveAddressOptions = {
|
7
|
+
client: ThirdwebClient;
|
8
|
+
name: string;
|
9
|
+
resolverAddress?: string;
|
10
|
+
resolverChain?: Chain;
|
11
|
+
};
|
12
|
+
/**
|
13
|
+
* Resolve an Unstoppable-Domain domain to an Ethereum address
|
14
|
+
* @param options - The options for resolving an UD domain
|
15
|
+
* @returns The Ethereum address associated with the domain name. [Learn more](https://docs.unstoppabledomains.com/reverse-resolution/)
|
16
|
+
* @example
|
17
|
+
*
|
18
|
+
* ### Basic usage
|
19
|
+
* ```ts
|
20
|
+
* import { resolveAddress } from "thirdweb/extension/unstoppable-domains";
|
21
|
+
*
|
22
|
+
* const address = await resolveAddress({
|
23
|
+
* client,
|
24
|
+
* name: "thirdweb.crypto",
|
25
|
+
* });
|
26
|
+
* ```
|
27
|
+
*
|
28
|
+
* ### Custom resolver
|
29
|
+
* By default this extension will try to resolve the name on Polygon mainnet,
|
30
|
+
* you can decide to customize the resolver contract by specifying `resolverAddress` and `resolverChain`
|
31
|
+
* ```ts
|
32
|
+
* import { ethereum } from "thirdweb/chains";
|
33
|
+
*
|
34
|
+
* const address = await resolveAddress({
|
35
|
+
* client,
|
36
|
+
* name: "thirdweb.crypto",
|
37
|
+
* resolverAddress: "0x...",
|
38
|
+
* resolverChain: ethereum,
|
39
|
+
* });
|
40
|
+
* ```
|
41
|
+
*
|
42
|
+
* @extension UNSTOPPABLE-DOMAINS
|
43
|
+
*/
|
44
|
+
export declare function resolveAddress(options: ResolveAddressOptions): Promise<string>;
|
45
|
+
//# sourceMappingURL=resolveAddress.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"resolveAddress.d.ts","sourceRoot":"","sources":["../../../../../src/extensions/unstoppable-domains/read/resolveAddress.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAQhE;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,MAAM,EAAE,cAAc,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,KAAK,CAAC;CACvB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,MAAM,CAAC,CAyCjB"}
|
@@ -0,0 +1,43 @@
|
|
1
|
+
import type { Chain } from "../../../chains/types.js";
|
2
|
+
import type { ThirdwebClient } from "../../../client/client.js";
|
3
|
+
/**
|
4
|
+
* @extension UNSTOPPABLE-DOMAINS
|
5
|
+
*/
|
6
|
+
export type ResolveUDNameOptions = {
|
7
|
+
client: ThirdwebClient;
|
8
|
+
address: string;
|
9
|
+
resolverAddress?: string;
|
10
|
+
resolverChain?: Chain;
|
11
|
+
};
|
12
|
+
/**
|
13
|
+
* Resolves the primary Untoppable-Domains name for a specified address.
|
14
|
+
* @param options - The options for resolving an UD domain
|
15
|
+
* @example
|
16
|
+
*
|
17
|
+
* ### Basic usage
|
18
|
+
* ```ts
|
19
|
+
* import { resolveName } from "thirdweb/extension/unstoppable-domains";
|
20
|
+
*
|
21
|
+
* const name = await resolveName({
|
22
|
+
* client,
|
23
|
+
* address: "0x...",
|
24
|
+
* });
|
25
|
+
* ```
|
26
|
+
*
|
27
|
+
* ### Custom resolver
|
28
|
+
* By default this extension will try to resolve the address on Polygon mainnet,
|
29
|
+
* you can decide to customize the resolver contract by specifying `resolverAddress` and `resolverChain`
|
30
|
+
* ```ts
|
31
|
+
* import { ethereum } from "thirdweb/chains";
|
32
|
+
*
|
33
|
+
* const address = await resolveName({
|
34
|
+
* client,
|
35
|
+
* address: "0x...",
|
36
|
+
* resolverAddress: "0x...",
|
37
|
+
* resolverChain: ethereum,
|
38
|
+
* });
|
39
|
+
* ```
|
40
|
+
* @extension UNSTOPPABLE-DOMAINS
|
41
|
+
*/
|
42
|
+
export declare function resolveName(options: ResolveUDNameOptions): Promise<string>;
|
43
|
+
//# sourceMappingURL=resolveName.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"resolveName.d.ts","sourceRoot":"","sources":["../../../../../src/extensions/unstoppable-domains/read/resolveName.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAMhE;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC,MAAM,EAAE,cAAc,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,KAAK,CAAC;CACvB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAsB,WAAW,CAC/B,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,MAAM,CAAC,CA0BjB"}
|
package/dist/types/version.d.ts
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
export declare const version = "5.
|
1
|
+
export declare const version = "5.61.0-nightly-27375af91b86eb21d251a99dec57e0a6470511ca-20241004000320";
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,2EAA2E,CAAC"}
|
package/package.json
CHANGED
@@ -0,0 +1,9 @@
|
|
1
|
+
export { UD_POLYGON_MAINNET } from "../../extensions/unstoppable-domains/consts.js";
|
2
|
+
export {
|
3
|
+
type ResolveUDNameOptions,
|
4
|
+
resolveName,
|
5
|
+
} from "../../extensions/unstoppable-domains/read/resolveName.js";
|
6
|
+
export {
|
7
|
+
type ResolveAddressOptions,
|
8
|
+
resolveAddress,
|
9
|
+
} from "../../extensions/unstoppable-domains/read/resolveAddress.js";
|
@@ -0,0 +1,130 @@
|
|
1
|
+
import type { AbiParameterToPrimitiveType } from "abitype";
|
2
|
+
import { readContract } from "../../../../../transaction/read-contract.js";
|
3
|
+
import type { BaseTransactionOptions } from "../../../../../transaction/types.js";
|
4
|
+
import { encodeAbiParameters } from "../../../../../utils/abi/encodeAbiParameters.js";
|
5
|
+
import { decodeAbiParameters } from "viem";
|
6
|
+
import type { Hex } from "../../../../../utils/encoding/hex.js";
|
7
|
+
import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
|
8
|
+
|
9
|
+
/**
|
10
|
+
* Represents the parameters for the "getMany" function.
|
11
|
+
*/
|
12
|
+
export type GetManyParams = {
|
13
|
+
keys: AbiParameterToPrimitiveType<{ type: "string[]"; name: "keys" }>;
|
14
|
+
tokenId: AbiParameterToPrimitiveType<{ type: "uint256"; name: "tokenId" }>;
|
15
|
+
};
|
16
|
+
|
17
|
+
export const FN_SELECTOR = "0x1bd8cc1a" as const;
|
18
|
+
const FN_INPUTS = [
|
19
|
+
{
|
20
|
+
type: "string[]",
|
21
|
+
name: "keys",
|
22
|
+
},
|
23
|
+
{
|
24
|
+
type: "uint256",
|
25
|
+
name: "tokenId",
|
26
|
+
},
|
27
|
+
] as const;
|
28
|
+
const FN_OUTPUTS = [
|
29
|
+
{
|
30
|
+
type: "string[]",
|
31
|
+
name: "values",
|
32
|
+
},
|
33
|
+
] as const;
|
34
|
+
|
35
|
+
/**
|
36
|
+
* Checks if the `getMany` method is supported by the given contract.
|
37
|
+
* @param availableSelectors An array of 4byte function selectors of the contract. You can get this in various ways, such as using "whatsabi" or if you have the ABI of the contract available you can use it to generate the selectors.
|
38
|
+
* @returns A boolean indicating if the `getMany` method is supported.
|
39
|
+
* @extension UNSTOPPABLE-DOMAINS
|
40
|
+
* @example
|
41
|
+
* ```ts
|
42
|
+
* import { isGetManySupported } from "thirdweb/extensions/unstoppable-domains";
|
43
|
+
* const supported = isGetManySupported(["0x..."]);
|
44
|
+
* ```
|
45
|
+
*/
|
46
|
+
export function isGetManySupported(availableSelectors: string[]) {
|
47
|
+
return detectMethod({
|
48
|
+
availableSelectors,
|
49
|
+
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
50
|
+
});
|
51
|
+
}
|
52
|
+
|
53
|
+
/**
|
54
|
+
* Encodes the parameters for the "getMany" function.
|
55
|
+
* @param options - The options for the getMany function.
|
56
|
+
* @returns The encoded ABI parameters.
|
57
|
+
* @extension UNSTOPPABLE-DOMAINS
|
58
|
+
* @example
|
59
|
+
* ```ts
|
60
|
+
* import { encodeGetManyParams } from "thirdweb/extensions/unstoppable-domains";
|
61
|
+
* const result = encodeGetManyParams({
|
62
|
+
* keys: ...,
|
63
|
+
* tokenId: ...,
|
64
|
+
* });
|
65
|
+
* ```
|
66
|
+
*/
|
67
|
+
export function encodeGetManyParams(options: GetManyParams) {
|
68
|
+
return encodeAbiParameters(FN_INPUTS, [options.keys, options.tokenId]);
|
69
|
+
}
|
70
|
+
|
71
|
+
/**
|
72
|
+
* Encodes the "getMany" function into a Hex string with its parameters.
|
73
|
+
* @param options - The options for the getMany function.
|
74
|
+
* @returns The encoded hexadecimal string.
|
75
|
+
* @extension UNSTOPPABLE-DOMAINS
|
76
|
+
* @example
|
77
|
+
* ```ts
|
78
|
+
* import { encodeGetMany } from "thirdweb/extensions/unstoppable-domains";
|
79
|
+
* const result = encodeGetMany({
|
80
|
+
* keys: ...,
|
81
|
+
* tokenId: ...,
|
82
|
+
* });
|
83
|
+
* ```
|
84
|
+
*/
|
85
|
+
export function encodeGetMany(options: GetManyParams) {
|
86
|
+
// we do a "manual" concat here to avoid the overhead of the "concatHex" function
|
87
|
+
// we can do this because we know the specific formats of the values
|
88
|
+
return (FN_SELECTOR +
|
89
|
+
encodeGetManyParams(options).slice(2)) as `${typeof FN_SELECTOR}${string}`;
|
90
|
+
}
|
91
|
+
|
92
|
+
/**
|
93
|
+
* Decodes the result of the getMany function call.
|
94
|
+
* @param result - The hexadecimal result to decode.
|
95
|
+
* @returns The decoded result as per the FN_OUTPUTS definition.
|
96
|
+
* @extension UNSTOPPABLE-DOMAINS
|
97
|
+
* @example
|
98
|
+
* ```ts
|
99
|
+
* import { decodeGetManyResult } from "thirdweb/extensions/unstoppable-domains";
|
100
|
+
* const result = decodeGetManyResultResult("...");
|
101
|
+
* ```
|
102
|
+
*/
|
103
|
+
export function decodeGetManyResult(result: Hex) {
|
104
|
+
return decodeAbiParameters(FN_OUTPUTS, result)[0];
|
105
|
+
}
|
106
|
+
|
107
|
+
/**
|
108
|
+
* Calls the "getMany" function on the contract.
|
109
|
+
* @param options - The options for the getMany function.
|
110
|
+
* @returns The parsed result of the function call.
|
111
|
+
* @extension UNSTOPPABLE-DOMAINS
|
112
|
+
* @example
|
113
|
+
* ```ts
|
114
|
+
* import { getMany } from "thirdweb/extensions/unstoppable-domains";
|
115
|
+
*
|
116
|
+
* const result = await getMany({
|
117
|
+
* contract,
|
118
|
+
* keys: ...,
|
119
|
+
* tokenId: ...,
|
120
|
+
* });
|
121
|
+
*
|
122
|
+
* ```
|
123
|
+
*/
|
124
|
+
export async function getMany(options: BaseTransactionOptions<GetManyParams>) {
|
125
|
+
return readContract({
|
126
|
+
contract: options.contract,
|
127
|
+
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
128
|
+
params: [options.keys, options.tokenId],
|
129
|
+
});
|
130
|
+
}
|
@@ -0,0 +1,124 @@
|
|
1
|
+
import type { AbiParameterToPrimitiveType } from "abitype";
|
2
|
+
import { readContract } from "../../../../../transaction/read-contract.js";
|
3
|
+
import type { BaseTransactionOptions } from "../../../../../transaction/types.js";
|
4
|
+
import { encodeAbiParameters } from "../../../../../utils/abi/encodeAbiParameters.js";
|
5
|
+
import { decodeAbiParameters } from "viem";
|
6
|
+
import type { Hex } from "../../../../../utils/encoding/hex.js";
|
7
|
+
import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
|
8
|
+
|
9
|
+
/**
|
10
|
+
* Represents the parameters for the "namehash" function.
|
11
|
+
*/
|
12
|
+
export type NamehashParams = {
|
13
|
+
labels: AbiParameterToPrimitiveType<{ type: "string[]"; name: "labels" }>;
|
14
|
+
};
|
15
|
+
|
16
|
+
export const FN_SELECTOR = "0x276fabb1" as const;
|
17
|
+
const FN_INPUTS = [
|
18
|
+
{
|
19
|
+
type: "string[]",
|
20
|
+
name: "labels",
|
21
|
+
},
|
22
|
+
] as const;
|
23
|
+
const FN_OUTPUTS = [
|
24
|
+
{
|
25
|
+
type: "uint256",
|
26
|
+
name: "hash",
|
27
|
+
},
|
28
|
+
] as const;
|
29
|
+
|
30
|
+
/**
|
31
|
+
* Checks if the `namehash` method is supported by the given contract.
|
32
|
+
* @param availableSelectors An array of 4byte function selectors of the contract. You can get this in various ways, such as using "whatsabi" or if you have the ABI of the contract available you can use it to generate the selectors.
|
33
|
+
* @returns A boolean indicating if the `namehash` method is supported.
|
34
|
+
* @extension UNSTOPPABLE-DOMAINS
|
35
|
+
* @example
|
36
|
+
* ```ts
|
37
|
+
* import { isNamehashSupported } from "thirdweb/extensions/unstoppable-domains";
|
38
|
+
* const supported = isNamehashSupported(["0x..."]);
|
39
|
+
* ```
|
40
|
+
*/
|
41
|
+
export function isNamehashSupported(availableSelectors: string[]) {
|
42
|
+
return detectMethod({
|
43
|
+
availableSelectors,
|
44
|
+
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
45
|
+
});
|
46
|
+
}
|
47
|
+
|
48
|
+
/**
|
49
|
+
* Encodes the parameters for the "namehash" function.
|
50
|
+
* @param options - The options for the namehash function.
|
51
|
+
* @returns The encoded ABI parameters.
|
52
|
+
* @extension UNSTOPPABLE-DOMAINS
|
53
|
+
* @example
|
54
|
+
* ```ts
|
55
|
+
* import { encodeNamehashParams } from "thirdweb/extensions/unstoppable-domains";
|
56
|
+
* const result = encodeNamehashParams({
|
57
|
+
* labels: ...,
|
58
|
+
* });
|
59
|
+
* ```
|
60
|
+
*/
|
61
|
+
export function encodeNamehashParams(options: NamehashParams) {
|
62
|
+
return encodeAbiParameters(FN_INPUTS, [options.labels]);
|
63
|
+
}
|
64
|
+
|
65
|
+
/**
|
66
|
+
* Encodes the "namehash" function into a Hex string with its parameters.
|
67
|
+
* @param options - The options for the namehash function.
|
68
|
+
* @returns The encoded hexadecimal string.
|
69
|
+
* @extension UNSTOPPABLE-DOMAINS
|
70
|
+
* @example
|
71
|
+
* ```ts
|
72
|
+
* import { encodeNamehash } from "thirdweb/extensions/unstoppable-domains";
|
73
|
+
* const result = encodeNamehash({
|
74
|
+
* labels: ...,
|
75
|
+
* });
|
76
|
+
* ```
|
77
|
+
*/
|
78
|
+
export function encodeNamehash(options: NamehashParams) {
|
79
|
+
// we do a "manual" concat here to avoid the overhead of the "concatHex" function
|
80
|
+
// we can do this because we know the specific formats of the values
|
81
|
+
return (FN_SELECTOR +
|
82
|
+
encodeNamehashParams(options).slice(2)) as `${typeof FN_SELECTOR}${string}`;
|
83
|
+
}
|
84
|
+
|
85
|
+
/**
|
86
|
+
* Decodes the result of the namehash function call.
|
87
|
+
* @param result - The hexadecimal result to decode.
|
88
|
+
* @returns The decoded result as per the FN_OUTPUTS definition.
|
89
|
+
* @extension UNSTOPPABLE-DOMAINS
|
90
|
+
* @example
|
91
|
+
* ```ts
|
92
|
+
* import { decodeNamehashResult } from "thirdweb/extensions/unstoppable-domains";
|
93
|
+
* const result = decodeNamehashResultResult("...");
|
94
|
+
* ```
|
95
|
+
*/
|
96
|
+
export function decodeNamehashResult(result: Hex) {
|
97
|
+
return decodeAbiParameters(FN_OUTPUTS, result)[0];
|
98
|
+
}
|
99
|
+
|
100
|
+
/**
|
101
|
+
* Calls the "namehash" function on the contract.
|
102
|
+
* @param options - The options for the namehash function.
|
103
|
+
* @returns The parsed result of the function call.
|
104
|
+
* @extension UNSTOPPABLE-DOMAINS
|
105
|
+
* @example
|
106
|
+
* ```ts
|
107
|
+
* import { namehash } from "thirdweb/extensions/unstoppable-domains";
|
108
|
+
*
|
109
|
+
* const result = await namehash({
|
110
|
+
* contract,
|
111
|
+
* labels: ...,
|
112
|
+
* });
|
113
|
+
*
|
114
|
+
* ```
|
115
|
+
*/
|
116
|
+
export async function namehash(
|
117
|
+
options: BaseTransactionOptions<NamehashParams>,
|
118
|
+
) {
|
119
|
+
return readContract({
|
120
|
+
contract: options.contract,
|
121
|
+
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
122
|
+
params: [options.labels],
|
123
|
+
});
|
124
|
+
}
|