thirdweb 5.72.0-nightly-f64e0253d7de6fdb6f56ab49315cc4cdcdd75b20-20241127000345 → 5.72.0-nightly-e87eb2ff35eea1b94ab7bdae3585d819879ec53c-20241128000350
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/extensions/erc721/__generated__/LoyaltyCard/events/TokensMinted.js +32 -0
- package/dist/cjs/extensions/erc721/__generated__/LoyaltyCard/events/TokensMinted.js.map +1 -0
- package/dist/cjs/extensions/erc721/__generated__/LoyaltyCard/events/TokensMintedWithSignature.js +33 -0
- package/dist/cjs/extensions/erc721/__generated__/LoyaltyCard/events/TokensMintedWithSignature.js.map +1 -0
- package/dist/cjs/extensions/erc721/__generated__/LoyaltyCard/read/nextTokenIdToMint.js +70 -0
- package/dist/cjs/extensions/erc721/__generated__/LoyaltyCard/read/nextTokenIdToMint.js.map +1 -0
- package/dist/cjs/extensions/erc721/__generated__/LoyaltyCard/read/supportsInterface.js +114 -0
- package/dist/cjs/extensions/erc721/__generated__/LoyaltyCard/read/supportsInterface.js.map +1 -0
- package/dist/cjs/extensions/erc721/__generated__/LoyaltyCard/read/tokenURI.js +114 -0
- package/dist/cjs/extensions/erc721/__generated__/LoyaltyCard/read/tokenURI.js.map +1 -0
- package/dist/cjs/extensions/erc721/__generated__/LoyaltyCard/read/totalMinted.js +70 -0
- package/dist/cjs/extensions/erc721/__generated__/LoyaltyCard/read/totalMinted.js.map +1 -0
- package/dist/cjs/extensions/erc721/__generated__/LoyaltyCard/write/cancel.js +117 -0
- package/dist/cjs/extensions/erc721/__generated__/LoyaltyCard/write/cancel.js.map +1 -0
- package/dist/cjs/extensions/erc721/__generated__/LoyaltyCard/write/initialize.js +202 -0
- package/dist/cjs/extensions/erc721/__generated__/LoyaltyCard/write/initialize.js.map +1 -0
- package/dist/cjs/extensions/erc721/__generated__/LoyaltyCard/write/mintTo.js +129 -0
- package/dist/cjs/extensions/erc721/__generated__/LoyaltyCard/write/mintTo.js.map +1 -0
- package/dist/cjs/extensions/erc721/__generated__/LoyaltyCard/write/mintWithSignature.js +171 -0
- package/dist/cjs/extensions/erc721/__generated__/LoyaltyCard/write/mintWithSignature.js.map +1 -0
- package/dist/cjs/extensions/erc721/__generated__/LoyaltyCard/write/revoke.js +117 -0
- package/dist/cjs/extensions/erc721/__generated__/LoyaltyCard/write/revoke.js.map +1 -0
- package/dist/cjs/extensions/erc721/__generated__/Multiwrap/events/TokensUnwrapped.js +33 -0
- package/dist/cjs/extensions/erc721/__generated__/Multiwrap/events/TokensUnwrapped.js.map +1 -0
- package/dist/cjs/extensions/erc721/__generated__/Multiwrap/events/TokensWrapped.js +33 -0
- package/dist/cjs/extensions/erc721/__generated__/Multiwrap/events/TokensWrapped.js.map +1 -0
- package/dist/cjs/extensions/erc721/__generated__/Multiwrap/read/contractType.js +70 -0
- package/dist/cjs/extensions/erc721/__generated__/Multiwrap/read/contractType.js.map +1 -0
- package/dist/cjs/extensions/erc721/__generated__/Multiwrap/read/contractVersion.js +70 -0
- package/dist/cjs/extensions/erc721/__generated__/Multiwrap/read/contractVersion.js.map +1 -0
- package/dist/cjs/extensions/erc721/__generated__/Multiwrap/read/getWrappedContents.js +133 -0
- package/dist/cjs/extensions/erc721/__generated__/Multiwrap/read/getWrappedContents.js.map +1 -0
- package/dist/cjs/extensions/erc721/__generated__/Multiwrap/read/nextTokenIdToMint.js +70 -0
- package/dist/cjs/extensions/erc721/__generated__/Multiwrap/read/nextTokenIdToMint.js.map +1 -0
- package/dist/cjs/extensions/erc721/__generated__/Multiwrap/read/supportsInterface.js +114 -0
- package/dist/cjs/extensions/erc721/__generated__/Multiwrap/read/supportsInterface.js.map +1 -0
- package/dist/cjs/extensions/erc721/__generated__/Multiwrap/read/tokenURI.js +114 -0
- package/dist/cjs/extensions/erc721/__generated__/Multiwrap/read/tokenURI.js.map +1 -0
- package/dist/cjs/extensions/erc721/__generated__/Multiwrap/write/initialize.js +175 -0
- package/dist/cjs/extensions/erc721/__generated__/Multiwrap/write/initialize.js.map +1 -0
- package/dist/cjs/extensions/erc721/__generated__/Multiwrap/write/unwrap.js +124 -0
- package/dist/cjs/extensions/erc721/__generated__/Multiwrap/write/unwrap.js.map +1 -0
- package/dist/cjs/extensions/erc721/__generated__/Multiwrap/write/wrap.js +162 -0
- package/dist/cjs/extensions/erc721/__generated__/Multiwrap/write/wrap.js.map +1 -0
- package/dist/cjs/extensions/prebuilts/deploy-erc721.js +21 -6
- package/dist/cjs/extensions/prebuilts/deploy-erc721.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/extensions/erc721/__generated__/LoyaltyCard/events/TokensMinted.js +29 -0
- package/dist/esm/extensions/erc721/__generated__/LoyaltyCard/events/TokensMinted.js.map +1 -0
- package/dist/esm/extensions/erc721/__generated__/LoyaltyCard/events/TokensMintedWithSignature.js +30 -0
- package/dist/esm/extensions/erc721/__generated__/LoyaltyCard/events/TokensMintedWithSignature.js.map +1 -0
- package/dist/esm/extensions/erc721/__generated__/LoyaltyCard/read/nextTokenIdToMint.js +64 -0
- package/dist/esm/extensions/erc721/__generated__/LoyaltyCard/read/nextTokenIdToMint.js.map +1 -0
- package/dist/esm/extensions/erc721/__generated__/LoyaltyCard/read/supportsInterface.js +106 -0
- package/dist/esm/extensions/erc721/__generated__/LoyaltyCard/read/supportsInterface.js.map +1 -0
- package/dist/esm/extensions/erc721/__generated__/LoyaltyCard/read/tokenURI.js +106 -0
- package/dist/esm/extensions/erc721/__generated__/LoyaltyCard/read/tokenURI.js.map +1 -0
- package/dist/esm/extensions/erc721/__generated__/LoyaltyCard/read/totalMinted.js +64 -0
- package/dist/esm/extensions/erc721/__generated__/LoyaltyCard/read/totalMinted.js.map +1 -0
- package/dist/esm/extensions/erc721/__generated__/LoyaltyCard/write/cancel.js +110 -0
- package/dist/esm/extensions/erc721/__generated__/LoyaltyCard/write/cancel.js.map +1 -0
- package/dist/esm/extensions/erc721/__generated__/LoyaltyCard/write/initialize.js +195 -0
- package/dist/esm/extensions/erc721/__generated__/LoyaltyCard/write/initialize.js.map +1 -0
- package/dist/esm/extensions/erc721/__generated__/LoyaltyCard/write/mintTo.js +122 -0
- package/dist/esm/extensions/erc721/__generated__/LoyaltyCard/write/mintTo.js.map +1 -0
- package/dist/esm/extensions/erc721/__generated__/LoyaltyCard/write/mintWithSignature.js +164 -0
- package/dist/esm/extensions/erc721/__generated__/LoyaltyCard/write/mintWithSignature.js.map +1 -0
- package/dist/esm/extensions/erc721/__generated__/LoyaltyCard/write/revoke.js +110 -0
- package/dist/esm/extensions/erc721/__generated__/LoyaltyCard/write/revoke.js.map +1 -0
- package/dist/esm/extensions/erc721/__generated__/Multiwrap/events/TokensUnwrapped.js +30 -0
- package/dist/esm/extensions/erc721/__generated__/Multiwrap/events/TokensUnwrapped.js.map +1 -0
- package/dist/esm/extensions/erc721/__generated__/Multiwrap/events/TokensWrapped.js +30 -0
- package/dist/esm/extensions/erc721/__generated__/Multiwrap/events/TokensWrapped.js.map +1 -0
- package/dist/esm/extensions/erc721/__generated__/Multiwrap/read/contractType.js +64 -0
- package/dist/esm/extensions/erc721/__generated__/Multiwrap/read/contractType.js.map +1 -0
- package/dist/esm/extensions/erc721/__generated__/Multiwrap/read/contractVersion.js +64 -0
- package/dist/esm/extensions/erc721/__generated__/Multiwrap/read/contractVersion.js.map +1 -0
- package/dist/esm/extensions/erc721/__generated__/Multiwrap/read/getWrappedContents.js +125 -0
- package/dist/esm/extensions/erc721/__generated__/Multiwrap/read/getWrappedContents.js.map +1 -0
- package/dist/esm/extensions/erc721/__generated__/Multiwrap/read/nextTokenIdToMint.js +64 -0
- package/dist/esm/extensions/erc721/__generated__/Multiwrap/read/nextTokenIdToMint.js.map +1 -0
- package/dist/esm/extensions/erc721/__generated__/Multiwrap/read/supportsInterface.js +106 -0
- package/dist/esm/extensions/erc721/__generated__/Multiwrap/read/supportsInterface.js.map +1 -0
- package/dist/esm/extensions/erc721/__generated__/Multiwrap/read/tokenURI.js +106 -0
- package/dist/esm/extensions/erc721/__generated__/Multiwrap/read/tokenURI.js.map +1 -0
- package/dist/esm/extensions/erc721/__generated__/Multiwrap/write/initialize.js +168 -0
- package/dist/esm/extensions/erc721/__generated__/Multiwrap/write/initialize.js.map +1 -0
- package/dist/esm/extensions/erc721/__generated__/Multiwrap/write/unwrap.js +117 -0
- package/dist/esm/extensions/erc721/__generated__/Multiwrap/write/unwrap.js.map +1 -0
- package/dist/esm/extensions/erc721/__generated__/Multiwrap/write/wrap.js +155 -0
- package/dist/esm/extensions/erc721/__generated__/Multiwrap/write/wrap.js.map +1 -0
- package/dist/esm/extensions/prebuilts/deploy-erc721.js +15 -0
- package/dist/esm/extensions/prebuilts/deploy-erc721.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/types/extensions/erc721/__generated__/LoyaltyCard/events/TokensMinted.d.ts +54 -0
- package/dist/types/extensions/erc721/__generated__/LoyaltyCard/events/TokensMinted.d.ts.map +1 -0
- package/dist/types/extensions/erc721/__generated__/LoyaltyCard/events/TokensMintedWithSignature.d.ts +95 -0
- package/dist/types/extensions/erc721/__generated__/LoyaltyCard/events/TokensMintedWithSignature.d.ts.map +1 -0
- package/dist/types/extensions/erc721/__generated__/LoyaltyCard/read/nextTokenIdToMint.d.ts +44 -0
- package/dist/types/extensions/erc721/__generated__/LoyaltyCard/read/nextTokenIdToMint.d.ts.map +1 -0
- package/dist/types/extensions/erc721/__generated__/LoyaltyCard/read/supportsInterface.d.ts +83 -0
- package/dist/types/extensions/erc721/__generated__/LoyaltyCard/read/supportsInterface.d.ts.map +1 -0
- package/dist/types/extensions/erc721/__generated__/LoyaltyCard/read/tokenURI.d.ts +83 -0
- package/dist/types/extensions/erc721/__generated__/LoyaltyCard/read/tokenURI.d.ts.map +1 -0
- package/dist/types/extensions/erc721/__generated__/LoyaltyCard/read/totalMinted.d.ts +44 -0
- package/dist/types/extensions/erc721/__generated__/LoyaltyCard/read/totalMinted.d.ts.map +1 -0
- package/dist/types/extensions/erc721/__generated__/LoyaltyCard/write/cancel.d.ts +79 -0
- package/dist/types/extensions/erc721/__generated__/LoyaltyCard/write/cancel.d.ts.map +1 -0
- package/dist/types/extensions/erc721/__generated__/LoyaltyCard/write/initialize.d.ts +142 -0
- package/dist/types/extensions/erc721/__generated__/LoyaltyCard/write/initialize.d.ts.map +1 -0
- package/dist/types/extensions/erc721/__generated__/LoyaltyCard/write/mintTo.d.ts +86 -0
- package/dist/types/extensions/erc721/__generated__/LoyaltyCard/write/mintTo.d.ts.map +1 -0
- package/dist/types/extensions/erc721/__generated__/LoyaltyCard/write/mintWithSignature.d.ts +128 -0
- package/dist/types/extensions/erc721/__generated__/LoyaltyCard/write/mintWithSignature.d.ts.map +1 -0
- package/dist/types/extensions/erc721/__generated__/LoyaltyCard/write/revoke.d.ts +79 -0
- package/dist/types/extensions/erc721/__generated__/LoyaltyCard/write/revoke.d.ts.map +1 -0
- package/dist/types/extensions/erc721/__generated__/Multiwrap/events/TokensUnwrapped.d.ts +61 -0
- package/dist/types/extensions/erc721/__generated__/Multiwrap/events/TokensUnwrapped.d.ts.map +1 -0
- package/dist/types/extensions/erc721/__generated__/Multiwrap/events/TokensWrapped.d.ts +77 -0
- package/dist/types/extensions/erc721/__generated__/Multiwrap/events/TokensWrapped.d.ts.map +1 -0
- package/dist/types/extensions/erc721/__generated__/Multiwrap/read/contractType.d.ts +44 -0
- package/dist/types/extensions/erc721/__generated__/Multiwrap/read/contractType.d.ts.map +1 -0
- package/dist/types/extensions/erc721/__generated__/Multiwrap/read/contractVersion.d.ts +44 -0
- package/dist/types/extensions/erc721/__generated__/Multiwrap/read/contractVersion.d.ts.map +1 -0
- package/dist/types/extensions/erc721/__generated__/Multiwrap/read/getWrappedContents.d.ts +93 -0
- package/dist/types/extensions/erc721/__generated__/Multiwrap/read/getWrappedContents.d.ts.map +1 -0
- package/dist/types/extensions/erc721/__generated__/Multiwrap/read/nextTokenIdToMint.d.ts +44 -0
- package/dist/types/extensions/erc721/__generated__/Multiwrap/read/nextTokenIdToMint.d.ts.map +1 -0
- package/dist/types/extensions/erc721/__generated__/Multiwrap/read/supportsInterface.d.ts +83 -0
- package/dist/types/extensions/erc721/__generated__/Multiwrap/read/supportsInterface.d.ts.map +1 -0
- package/dist/types/extensions/erc721/__generated__/Multiwrap/read/tokenURI.d.ts +83 -0
- package/dist/types/extensions/erc721/__generated__/Multiwrap/read/tokenURI.d.ts.map +1 -0
- package/dist/types/extensions/erc721/__generated__/Multiwrap/write/initialize.d.ts +121 -0
- package/dist/types/extensions/erc721/__generated__/Multiwrap/write/initialize.d.ts.map +1 -0
- package/dist/types/extensions/erc721/__generated__/Multiwrap/write/unwrap.d.ts +86 -0
- package/dist/types/extensions/erc721/__generated__/Multiwrap/write/unwrap.d.ts.map +1 -0
- package/dist/types/extensions/erc721/__generated__/Multiwrap/write/wrap.d.ts +111 -0
- package/dist/types/extensions/erc721/__generated__/Multiwrap/write/wrap.d.ts.map +1 -0
- package/dist/types/extensions/prebuilts/deploy-erc721.d.ts +1 -1
- package/dist/types/extensions/prebuilts/deploy-erc721.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/extensions/erc721/__generated__/LoyaltyCard/events/TokensMinted.ts +47 -0
- package/src/extensions/erc721/__generated__/LoyaltyCard/events/TokensMintedWithSignature.ts +55 -0
- package/src/extensions/erc721/__generated__/LoyaltyCard/read/nextTokenIdToMint.ts +70 -0
- package/src/extensions/erc721/__generated__/LoyaltyCard/read/supportsInterface.ts +130 -0
- package/src/extensions/erc721/__generated__/LoyaltyCard/read/tokenURI.ts +123 -0
- package/src/extensions/erc721/__generated__/LoyaltyCard/read/totalMinted.ts +70 -0
- package/src/extensions/erc721/__generated__/LoyaltyCard/write/cancel.ts +135 -0
- package/src/extensions/erc721/__generated__/LoyaltyCard/write/initialize.ts +255 -0
- package/src/extensions/erc721/__generated__/LoyaltyCard/write/mintTo.ts +148 -0
- package/src/extensions/erc721/__generated__/LoyaltyCard/write/mintWithSignature.ts +209 -0
- package/src/extensions/erc721/__generated__/LoyaltyCard/write/revoke.ts +135 -0
- package/src/extensions/erc721/__generated__/Multiwrap/events/TokensUnwrapped.ts +55 -0
- package/src/extensions/erc721/__generated__/Multiwrap/events/TokensWrapped.ts +53 -0
- package/src/extensions/erc721/__generated__/Multiwrap/read/contractType.ts +70 -0
- package/src/extensions/erc721/__generated__/Multiwrap/read/contractVersion.ts +70 -0
- package/src/extensions/erc721/__generated__/Multiwrap/read/getWrappedContents.ts +146 -0
- package/src/extensions/erc721/__generated__/Multiwrap/read/nextTokenIdToMint.ts +70 -0
- package/src/extensions/erc721/__generated__/Multiwrap/read/supportsInterface.ts +130 -0
- package/src/extensions/erc721/__generated__/Multiwrap/read/tokenURI.ts +123 -0
- package/src/extensions/erc721/__generated__/Multiwrap/write/initialize.ts +216 -0
- package/src/extensions/erc721/__generated__/Multiwrap/write/unwrap.ts +146 -0
- package/src/extensions/erc721/__generated__/Multiwrap/write/wrap.ts +197 -0
- package/src/extensions/prebuilts/deploy-erc721.test.ts +70 -2
- package/src/extensions/prebuilts/deploy-erc721.ts +17 -1
- package/src/version.ts +1 -1
@@ -0,0 +1,123 @@
|
|
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 "tokenURI" function.
|
11
|
+
*/
|
12
|
+
export type TokenURIParams = {
|
13
|
+
tokenId: AbiParameterToPrimitiveType<{ type: "uint256"; name: "_tokenId" }>;
|
14
|
+
};
|
15
|
+
|
16
|
+
export const FN_SELECTOR = "0xc87b56dd" as const;
|
17
|
+
const FN_INPUTS = [
|
18
|
+
{
|
19
|
+
type: "uint256",
|
20
|
+
name: "_tokenId",
|
21
|
+
},
|
22
|
+
] as const;
|
23
|
+
const FN_OUTPUTS = [
|
24
|
+
{
|
25
|
+
type: "string",
|
26
|
+
},
|
27
|
+
] as const;
|
28
|
+
|
29
|
+
/**
|
30
|
+
* Checks if the `tokenURI` method is supported by the given contract.
|
31
|
+
* @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.
|
32
|
+
* @returns A boolean indicating if the `tokenURI` method is supported.
|
33
|
+
* @extension ERC721
|
34
|
+
* @example
|
35
|
+
* ```ts
|
36
|
+
* import { isTokenURISupported } from "thirdweb/extensions/erc721";
|
37
|
+
* const supported = isTokenURISupported(["0x..."]);
|
38
|
+
* ```
|
39
|
+
*/
|
40
|
+
export function isTokenURISupported(availableSelectors: string[]) {
|
41
|
+
return detectMethod({
|
42
|
+
availableSelectors,
|
43
|
+
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
44
|
+
});
|
45
|
+
}
|
46
|
+
|
47
|
+
/**
|
48
|
+
* Encodes the parameters for the "tokenURI" function.
|
49
|
+
* @param options - The options for the tokenURI function.
|
50
|
+
* @returns The encoded ABI parameters.
|
51
|
+
* @extension ERC721
|
52
|
+
* @example
|
53
|
+
* ```ts
|
54
|
+
* import { encodeTokenURIParams } from "thirdweb/extensions/erc721";
|
55
|
+
* const result = encodeTokenURIParams({
|
56
|
+
* tokenId: ...,
|
57
|
+
* });
|
58
|
+
* ```
|
59
|
+
*/
|
60
|
+
export function encodeTokenURIParams(options: TokenURIParams) {
|
61
|
+
return encodeAbiParameters(FN_INPUTS, [options.tokenId]);
|
62
|
+
}
|
63
|
+
|
64
|
+
/**
|
65
|
+
* Encodes the "tokenURI" function into a Hex string with its parameters.
|
66
|
+
* @param options - The options for the tokenURI function.
|
67
|
+
* @returns The encoded hexadecimal string.
|
68
|
+
* @extension ERC721
|
69
|
+
* @example
|
70
|
+
* ```ts
|
71
|
+
* import { encodeTokenURI } from "thirdweb/extensions/erc721";
|
72
|
+
* const result = encodeTokenURI({
|
73
|
+
* tokenId: ...,
|
74
|
+
* });
|
75
|
+
* ```
|
76
|
+
*/
|
77
|
+
export function encodeTokenURI(options: TokenURIParams) {
|
78
|
+
// we do a "manual" concat here to avoid the overhead of the "concatHex" function
|
79
|
+
// we can do this because we know the specific formats of the values
|
80
|
+
return (FN_SELECTOR +
|
81
|
+
encodeTokenURIParams(options).slice(2)) as `${typeof FN_SELECTOR}${string}`;
|
82
|
+
}
|
83
|
+
|
84
|
+
/**
|
85
|
+
* Decodes the result of the tokenURI function call.
|
86
|
+
* @param result - The hexadecimal result to decode.
|
87
|
+
* @returns The decoded result as per the FN_OUTPUTS definition.
|
88
|
+
* @extension ERC721
|
89
|
+
* @example
|
90
|
+
* ```ts
|
91
|
+
* import { decodeTokenURIResult } from "thirdweb/extensions/erc721";
|
92
|
+
* const result = decodeTokenURIResultResult("...");
|
93
|
+
* ```
|
94
|
+
*/
|
95
|
+
export function decodeTokenURIResult(result: Hex) {
|
96
|
+
return decodeAbiParameters(FN_OUTPUTS, result)[0];
|
97
|
+
}
|
98
|
+
|
99
|
+
/**
|
100
|
+
* Calls the "tokenURI" function on the contract.
|
101
|
+
* @param options - The options for the tokenURI function.
|
102
|
+
* @returns The parsed result of the function call.
|
103
|
+
* @extension ERC721
|
104
|
+
* @example
|
105
|
+
* ```ts
|
106
|
+
* import { tokenURI } from "thirdweb/extensions/erc721";
|
107
|
+
*
|
108
|
+
* const result = await tokenURI({
|
109
|
+
* contract,
|
110
|
+
* tokenId: ...,
|
111
|
+
* });
|
112
|
+
*
|
113
|
+
* ```
|
114
|
+
*/
|
115
|
+
export async function tokenURI(
|
116
|
+
options: BaseTransactionOptions<TokenURIParams>,
|
117
|
+
) {
|
118
|
+
return readContract({
|
119
|
+
contract: options.contract,
|
120
|
+
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
121
|
+
params: [options.tokenId],
|
122
|
+
});
|
123
|
+
}
|
@@ -0,0 +1,70 @@
|
|
1
|
+
import { readContract } from "../../../../../transaction/read-contract.js";
|
2
|
+
import type { BaseTransactionOptions } from "../../../../../transaction/types.js";
|
3
|
+
|
4
|
+
import { decodeAbiParameters } from "viem";
|
5
|
+
import type { Hex } from "../../../../../utils/encoding/hex.js";
|
6
|
+
import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
|
7
|
+
|
8
|
+
export const FN_SELECTOR = "0xa2309ff8" as const;
|
9
|
+
const FN_INPUTS = [] as const;
|
10
|
+
const FN_OUTPUTS = [
|
11
|
+
{
|
12
|
+
type: "uint256",
|
13
|
+
},
|
14
|
+
] as const;
|
15
|
+
|
16
|
+
/**
|
17
|
+
* Checks if the `totalMinted` method is supported by the given contract.
|
18
|
+
* @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.
|
19
|
+
* @returns A boolean indicating if the `totalMinted` method is supported.
|
20
|
+
* @extension ERC721
|
21
|
+
* @example
|
22
|
+
* ```ts
|
23
|
+
* import { isTotalMintedSupported } from "thirdweb/extensions/erc721";
|
24
|
+
* const supported = isTotalMintedSupported(["0x..."]);
|
25
|
+
* ```
|
26
|
+
*/
|
27
|
+
export function isTotalMintedSupported(availableSelectors: string[]) {
|
28
|
+
return detectMethod({
|
29
|
+
availableSelectors,
|
30
|
+
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
31
|
+
});
|
32
|
+
}
|
33
|
+
|
34
|
+
/**
|
35
|
+
* Decodes the result of the totalMinted function call.
|
36
|
+
* @param result - The hexadecimal result to decode.
|
37
|
+
* @returns The decoded result as per the FN_OUTPUTS definition.
|
38
|
+
* @extension ERC721
|
39
|
+
* @example
|
40
|
+
* ```ts
|
41
|
+
* import { decodeTotalMintedResult } from "thirdweb/extensions/erc721";
|
42
|
+
* const result = decodeTotalMintedResultResult("...");
|
43
|
+
* ```
|
44
|
+
*/
|
45
|
+
export function decodeTotalMintedResult(result: Hex) {
|
46
|
+
return decodeAbiParameters(FN_OUTPUTS, result)[0];
|
47
|
+
}
|
48
|
+
|
49
|
+
/**
|
50
|
+
* Calls the "totalMinted" function on the contract.
|
51
|
+
* @param options - The options for the totalMinted function.
|
52
|
+
* @returns The parsed result of the function call.
|
53
|
+
* @extension ERC721
|
54
|
+
* @example
|
55
|
+
* ```ts
|
56
|
+
* import { totalMinted } from "thirdweb/extensions/erc721";
|
57
|
+
*
|
58
|
+
* const result = await totalMinted({
|
59
|
+
* contract,
|
60
|
+
* });
|
61
|
+
*
|
62
|
+
* ```
|
63
|
+
*/
|
64
|
+
export async function totalMinted(options: BaseTransactionOptions) {
|
65
|
+
return readContract({
|
66
|
+
contract: options.contract,
|
67
|
+
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
68
|
+
params: [],
|
69
|
+
});
|
70
|
+
}
|
@@ -0,0 +1,135 @@
|
|
1
|
+
import type { AbiParameterToPrimitiveType } from "abitype";
|
2
|
+
import type {
|
3
|
+
BaseTransactionOptions,
|
4
|
+
WithOverrides,
|
5
|
+
} from "../../../../../transaction/types.js";
|
6
|
+
import { prepareContractCall } from "../../../../../transaction/prepare-contract-call.js";
|
7
|
+
import { encodeAbiParameters } from "../../../../../utils/abi/encodeAbiParameters.js";
|
8
|
+
import { once } from "../../../../../utils/promise/once.js";
|
9
|
+
import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
|
10
|
+
|
11
|
+
/**
|
12
|
+
* Represents the parameters for the "cancel" function.
|
13
|
+
*/
|
14
|
+
export type CancelParams = WithOverrides<{
|
15
|
+
tokenId: AbiParameterToPrimitiveType<{ type: "uint256"; name: "tokenId" }>;
|
16
|
+
}>;
|
17
|
+
|
18
|
+
export const FN_SELECTOR = "0x40e58ee5" as const;
|
19
|
+
const FN_INPUTS = [
|
20
|
+
{
|
21
|
+
type: "uint256",
|
22
|
+
name: "tokenId",
|
23
|
+
},
|
24
|
+
] as const;
|
25
|
+
const FN_OUTPUTS = [] as const;
|
26
|
+
|
27
|
+
/**
|
28
|
+
* Checks if the `cancel` method is supported by the given contract.
|
29
|
+
* @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.
|
30
|
+
* @returns A boolean indicating if the `cancel` method is supported.
|
31
|
+
* @extension ERC721
|
32
|
+
* @example
|
33
|
+
* ```ts
|
34
|
+
* import { isCancelSupported } from "thirdweb/extensions/erc721";
|
35
|
+
*
|
36
|
+
* const supported = isCancelSupported(["0x..."]);
|
37
|
+
* ```
|
38
|
+
*/
|
39
|
+
export function isCancelSupported(availableSelectors: string[]) {
|
40
|
+
return detectMethod({
|
41
|
+
availableSelectors,
|
42
|
+
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
43
|
+
});
|
44
|
+
}
|
45
|
+
|
46
|
+
/**
|
47
|
+
* Encodes the parameters for the "cancel" function.
|
48
|
+
* @param options - The options for the cancel function.
|
49
|
+
* @returns The encoded ABI parameters.
|
50
|
+
* @extension ERC721
|
51
|
+
* @example
|
52
|
+
* ```ts
|
53
|
+
* import { encodeCancelParams } from "thirdweb/extensions/erc721";
|
54
|
+
* const result = encodeCancelParams({
|
55
|
+
* tokenId: ...,
|
56
|
+
* });
|
57
|
+
* ```
|
58
|
+
*/
|
59
|
+
export function encodeCancelParams(options: CancelParams) {
|
60
|
+
return encodeAbiParameters(FN_INPUTS, [options.tokenId]);
|
61
|
+
}
|
62
|
+
|
63
|
+
/**
|
64
|
+
* Encodes the "cancel" function into a Hex string with its parameters.
|
65
|
+
* @param options - The options for the cancel function.
|
66
|
+
* @returns The encoded hexadecimal string.
|
67
|
+
* @extension ERC721
|
68
|
+
* @example
|
69
|
+
* ```ts
|
70
|
+
* import { encodeCancel } from "thirdweb/extensions/erc721";
|
71
|
+
* const result = encodeCancel({
|
72
|
+
* tokenId: ...,
|
73
|
+
* });
|
74
|
+
* ```
|
75
|
+
*/
|
76
|
+
export function encodeCancel(options: CancelParams) {
|
77
|
+
// we do a "manual" concat here to avoid the overhead of the "concatHex" function
|
78
|
+
// we can do this because we know the specific formats of the values
|
79
|
+
return (FN_SELECTOR +
|
80
|
+
encodeCancelParams(options).slice(2)) as `${typeof FN_SELECTOR}${string}`;
|
81
|
+
}
|
82
|
+
|
83
|
+
/**
|
84
|
+
* Prepares a transaction to call the "cancel" function on the contract.
|
85
|
+
* @param options - The options for the "cancel" function.
|
86
|
+
* @returns A prepared transaction object.
|
87
|
+
* @extension ERC721
|
88
|
+
* @example
|
89
|
+
* ```ts
|
90
|
+
* import { sendTransaction } from "thirdweb";
|
91
|
+
* import { cancel } from "thirdweb/extensions/erc721";
|
92
|
+
*
|
93
|
+
* const transaction = cancel({
|
94
|
+
* contract,
|
95
|
+
* tokenId: ...,
|
96
|
+
* overrides: {
|
97
|
+
* ...
|
98
|
+
* }
|
99
|
+
* });
|
100
|
+
*
|
101
|
+
* // Send the transaction
|
102
|
+
* await sendTransaction({ transaction, account });
|
103
|
+
* ```
|
104
|
+
*/
|
105
|
+
export function cancel(
|
106
|
+
options: BaseTransactionOptions<
|
107
|
+
| CancelParams
|
108
|
+
| {
|
109
|
+
asyncParams: () => Promise<CancelParams>;
|
110
|
+
}
|
111
|
+
>,
|
112
|
+
) {
|
113
|
+
const asyncOptions = once(async () => {
|
114
|
+
return "asyncParams" in options ? await options.asyncParams() : options;
|
115
|
+
});
|
116
|
+
|
117
|
+
return prepareContractCall({
|
118
|
+
contract: options.contract,
|
119
|
+
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
120
|
+
params: async () => {
|
121
|
+
const resolvedOptions = await asyncOptions();
|
122
|
+
return [resolvedOptions.tokenId] as const;
|
123
|
+
},
|
124
|
+
value: async () => (await asyncOptions()).overrides?.value,
|
125
|
+
accessList: async () => (await asyncOptions()).overrides?.accessList,
|
126
|
+
gas: async () => (await asyncOptions()).overrides?.gas,
|
127
|
+
gasPrice: async () => (await asyncOptions()).overrides?.gasPrice,
|
128
|
+
maxFeePerGas: async () => (await asyncOptions()).overrides?.maxFeePerGas,
|
129
|
+
maxPriorityFeePerGas: async () =>
|
130
|
+
(await asyncOptions()).overrides?.maxPriorityFeePerGas,
|
131
|
+
nonce: async () => (await asyncOptions()).overrides?.nonce,
|
132
|
+
extraGas: async () => (await asyncOptions()).overrides?.extraGas,
|
133
|
+
erc20Value: async () => (await asyncOptions()).overrides?.erc20Value,
|
134
|
+
});
|
135
|
+
}
|
@@ -0,0 +1,255 @@
|
|
1
|
+
import type { AbiParameterToPrimitiveType } from "abitype";
|
2
|
+
import type {
|
3
|
+
BaseTransactionOptions,
|
4
|
+
WithOverrides,
|
5
|
+
} from "../../../../../transaction/types.js";
|
6
|
+
import { prepareContractCall } from "../../../../../transaction/prepare-contract-call.js";
|
7
|
+
import { encodeAbiParameters } from "../../../../../utils/abi/encodeAbiParameters.js";
|
8
|
+
import { once } from "../../../../../utils/promise/once.js";
|
9
|
+
import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
|
10
|
+
|
11
|
+
/**
|
12
|
+
* Represents the parameters for the "initialize" function.
|
13
|
+
*/
|
14
|
+
export type InitializeParams = WithOverrides<{
|
15
|
+
defaultAdmin: AbiParameterToPrimitiveType<{
|
16
|
+
type: "address";
|
17
|
+
name: "_defaultAdmin";
|
18
|
+
}>;
|
19
|
+
name: AbiParameterToPrimitiveType<{ type: "string"; name: "_name" }>;
|
20
|
+
symbol: AbiParameterToPrimitiveType<{ type: "string"; name: "_symbol" }>;
|
21
|
+
contractURI: AbiParameterToPrimitiveType<{
|
22
|
+
type: "string";
|
23
|
+
name: "_contractURI";
|
24
|
+
}>;
|
25
|
+
trustedForwarders: AbiParameterToPrimitiveType<{
|
26
|
+
type: "address[]";
|
27
|
+
name: "_trustedForwarders";
|
28
|
+
}>;
|
29
|
+
saleRecipient: AbiParameterToPrimitiveType<{
|
30
|
+
type: "address";
|
31
|
+
name: "_saleRecipient";
|
32
|
+
}>;
|
33
|
+
royaltyRecipient: AbiParameterToPrimitiveType<{
|
34
|
+
type: "address";
|
35
|
+
name: "_royaltyRecipient";
|
36
|
+
}>;
|
37
|
+
royaltyBps: AbiParameterToPrimitiveType<{
|
38
|
+
type: "uint128";
|
39
|
+
name: "_royaltyBps";
|
40
|
+
}>;
|
41
|
+
platformFeeBps: AbiParameterToPrimitiveType<{
|
42
|
+
type: "uint128";
|
43
|
+
name: "_platformFeeBps";
|
44
|
+
}>;
|
45
|
+
platformFeeRecipient: AbiParameterToPrimitiveType<{
|
46
|
+
type: "address";
|
47
|
+
name: "_platformFeeRecipient";
|
48
|
+
}>;
|
49
|
+
}>;
|
50
|
+
|
51
|
+
export const FN_SELECTOR = "0xe1591634" as const;
|
52
|
+
const FN_INPUTS = [
|
53
|
+
{
|
54
|
+
type: "address",
|
55
|
+
name: "_defaultAdmin",
|
56
|
+
},
|
57
|
+
{
|
58
|
+
type: "string",
|
59
|
+
name: "_name",
|
60
|
+
},
|
61
|
+
{
|
62
|
+
type: "string",
|
63
|
+
name: "_symbol",
|
64
|
+
},
|
65
|
+
{
|
66
|
+
type: "string",
|
67
|
+
name: "_contractURI",
|
68
|
+
},
|
69
|
+
{
|
70
|
+
type: "address[]",
|
71
|
+
name: "_trustedForwarders",
|
72
|
+
},
|
73
|
+
{
|
74
|
+
type: "address",
|
75
|
+
name: "_saleRecipient",
|
76
|
+
},
|
77
|
+
{
|
78
|
+
type: "address",
|
79
|
+
name: "_royaltyRecipient",
|
80
|
+
},
|
81
|
+
{
|
82
|
+
type: "uint128",
|
83
|
+
name: "_royaltyBps",
|
84
|
+
},
|
85
|
+
{
|
86
|
+
type: "uint128",
|
87
|
+
name: "_platformFeeBps",
|
88
|
+
},
|
89
|
+
{
|
90
|
+
type: "address",
|
91
|
+
name: "_platformFeeRecipient",
|
92
|
+
},
|
93
|
+
] as const;
|
94
|
+
const FN_OUTPUTS = [] as const;
|
95
|
+
|
96
|
+
/**
|
97
|
+
* Checks if the `initialize` method is supported by the given contract.
|
98
|
+
* @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.
|
99
|
+
* @returns A boolean indicating if the `initialize` method is supported.
|
100
|
+
* @extension ERC721
|
101
|
+
* @example
|
102
|
+
* ```ts
|
103
|
+
* import { isInitializeSupported } from "thirdweb/extensions/erc721";
|
104
|
+
*
|
105
|
+
* const supported = isInitializeSupported(["0x..."]);
|
106
|
+
* ```
|
107
|
+
*/
|
108
|
+
export function isInitializeSupported(availableSelectors: string[]) {
|
109
|
+
return detectMethod({
|
110
|
+
availableSelectors,
|
111
|
+
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
112
|
+
});
|
113
|
+
}
|
114
|
+
|
115
|
+
/**
|
116
|
+
* Encodes the parameters for the "initialize" function.
|
117
|
+
* @param options - The options for the initialize function.
|
118
|
+
* @returns The encoded ABI parameters.
|
119
|
+
* @extension ERC721
|
120
|
+
* @example
|
121
|
+
* ```ts
|
122
|
+
* import { encodeInitializeParams } from "thirdweb/extensions/erc721";
|
123
|
+
* const result = encodeInitializeParams({
|
124
|
+
* defaultAdmin: ...,
|
125
|
+
* name: ...,
|
126
|
+
* symbol: ...,
|
127
|
+
* contractURI: ...,
|
128
|
+
* trustedForwarders: ...,
|
129
|
+
* saleRecipient: ...,
|
130
|
+
* royaltyRecipient: ...,
|
131
|
+
* royaltyBps: ...,
|
132
|
+
* platformFeeBps: ...,
|
133
|
+
* platformFeeRecipient: ...,
|
134
|
+
* });
|
135
|
+
* ```
|
136
|
+
*/
|
137
|
+
export function encodeInitializeParams(options: InitializeParams) {
|
138
|
+
return encodeAbiParameters(FN_INPUTS, [
|
139
|
+
options.defaultAdmin,
|
140
|
+
options.name,
|
141
|
+
options.symbol,
|
142
|
+
options.contractURI,
|
143
|
+
options.trustedForwarders,
|
144
|
+
options.saleRecipient,
|
145
|
+
options.royaltyRecipient,
|
146
|
+
options.royaltyBps,
|
147
|
+
options.platformFeeBps,
|
148
|
+
options.platformFeeRecipient,
|
149
|
+
]);
|
150
|
+
}
|
151
|
+
|
152
|
+
/**
|
153
|
+
* Encodes the "initialize" function into a Hex string with its parameters.
|
154
|
+
* @param options - The options for the initialize function.
|
155
|
+
* @returns The encoded hexadecimal string.
|
156
|
+
* @extension ERC721
|
157
|
+
* @example
|
158
|
+
* ```ts
|
159
|
+
* import { encodeInitialize } from "thirdweb/extensions/erc721";
|
160
|
+
* const result = encodeInitialize({
|
161
|
+
* defaultAdmin: ...,
|
162
|
+
* name: ...,
|
163
|
+
* symbol: ...,
|
164
|
+
* contractURI: ...,
|
165
|
+
* trustedForwarders: ...,
|
166
|
+
* saleRecipient: ...,
|
167
|
+
* royaltyRecipient: ...,
|
168
|
+
* royaltyBps: ...,
|
169
|
+
* platformFeeBps: ...,
|
170
|
+
* platformFeeRecipient: ...,
|
171
|
+
* });
|
172
|
+
* ```
|
173
|
+
*/
|
174
|
+
export function encodeInitialize(options: InitializeParams) {
|
175
|
+
// we do a "manual" concat here to avoid the overhead of the "concatHex" function
|
176
|
+
// we can do this because we know the specific formats of the values
|
177
|
+
return (FN_SELECTOR +
|
178
|
+
encodeInitializeParams(options).slice(
|
179
|
+
2,
|
180
|
+
)) as `${typeof FN_SELECTOR}${string}`;
|
181
|
+
}
|
182
|
+
|
183
|
+
/**
|
184
|
+
* Prepares a transaction to call the "initialize" function on the contract.
|
185
|
+
* @param options - The options for the "initialize" function.
|
186
|
+
* @returns A prepared transaction object.
|
187
|
+
* @extension ERC721
|
188
|
+
* @example
|
189
|
+
* ```ts
|
190
|
+
* import { sendTransaction } from "thirdweb";
|
191
|
+
* import { initialize } from "thirdweb/extensions/erc721";
|
192
|
+
*
|
193
|
+
* const transaction = initialize({
|
194
|
+
* contract,
|
195
|
+
* defaultAdmin: ...,
|
196
|
+
* name: ...,
|
197
|
+
* symbol: ...,
|
198
|
+
* contractURI: ...,
|
199
|
+
* trustedForwarders: ...,
|
200
|
+
* saleRecipient: ...,
|
201
|
+
* royaltyRecipient: ...,
|
202
|
+
* royaltyBps: ...,
|
203
|
+
* platformFeeBps: ...,
|
204
|
+
* platformFeeRecipient: ...,
|
205
|
+
* overrides: {
|
206
|
+
* ...
|
207
|
+
* }
|
208
|
+
* });
|
209
|
+
*
|
210
|
+
* // Send the transaction
|
211
|
+
* await sendTransaction({ transaction, account });
|
212
|
+
* ```
|
213
|
+
*/
|
214
|
+
export function initialize(
|
215
|
+
options: BaseTransactionOptions<
|
216
|
+
| InitializeParams
|
217
|
+
| {
|
218
|
+
asyncParams: () => Promise<InitializeParams>;
|
219
|
+
}
|
220
|
+
>,
|
221
|
+
) {
|
222
|
+
const asyncOptions = once(async () => {
|
223
|
+
return "asyncParams" in options ? await options.asyncParams() : options;
|
224
|
+
});
|
225
|
+
|
226
|
+
return prepareContractCall({
|
227
|
+
contract: options.contract,
|
228
|
+
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
229
|
+
params: async () => {
|
230
|
+
const resolvedOptions = await asyncOptions();
|
231
|
+
return [
|
232
|
+
resolvedOptions.defaultAdmin,
|
233
|
+
resolvedOptions.name,
|
234
|
+
resolvedOptions.symbol,
|
235
|
+
resolvedOptions.contractURI,
|
236
|
+
resolvedOptions.trustedForwarders,
|
237
|
+
resolvedOptions.saleRecipient,
|
238
|
+
resolvedOptions.royaltyRecipient,
|
239
|
+
resolvedOptions.royaltyBps,
|
240
|
+
resolvedOptions.platformFeeBps,
|
241
|
+
resolvedOptions.platformFeeRecipient,
|
242
|
+
] as const;
|
243
|
+
},
|
244
|
+
value: async () => (await asyncOptions()).overrides?.value,
|
245
|
+
accessList: async () => (await asyncOptions()).overrides?.accessList,
|
246
|
+
gas: async () => (await asyncOptions()).overrides?.gas,
|
247
|
+
gasPrice: async () => (await asyncOptions()).overrides?.gasPrice,
|
248
|
+
maxFeePerGas: async () => (await asyncOptions()).overrides?.maxFeePerGas,
|
249
|
+
maxPriorityFeePerGas: async () =>
|
250
|
+
(await asyncOptions()).overrides?.maxPriorityFeePerGas,
|
251
|
+
nonce: async () => (await asyncOptions()).overrides?.nonce,
|
252
|
+
extraGas: async () => (await asyncOptions()).overrides?.extraGas,
|
253
|
+
erc20Value: async () => (await asyncOptions()).overrides?.erc20Value,
|
254
|
+
});
|
255
|
+
}
|