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.
Files changed (167) hide show
  1. package/dist/cjs/extensions/erc721/__generated__/LoyaltyCard/events/TokensMinted.js +32 -0
  2. package/dist/cjs/extensions/erc721/__generated__/LoyaltyCard/events/TokensMinted.js.map +1 -0
  3. package/dist/cjs/extensions/erc721/__generated__/LoyaltyCard/events/TokensMintedWithSignature.js +33 -0
  4. package/dist/cjs/extensions/erc721/__generated__/LoyaltyCard/events/TokensMintedWithSignature.js.map +1 -0
  5. package/dist/cjs/extensions/erc721/__generated__/LoyaltyCard/read/nextTokenIdToMint.js +70 -0
  6. package/dist/cjs/extensions/erc721/__generated__/LoyaltyCard/read/nextTokenIdToMint.js.map +1 -0
  7. package/dist/cjs/extensions/erc721/__generated__/LoyaltyCard/read/supportsInterface.js +114 -0
  8. package/dist/cjs/extensions/erc721/__generated__/LoyaltyCard/read/supportsInterface.js.map +1 -0
  9. package/dist/cjs/extensions/erc721/__generated__/LoyaltyCard/read/tokenURI.js +114 -0
  10. package/dist/cjs/extensions/erc721/__generated__/LoyaltyCard/read/tokenURI.js.map +1 -0
  11. package/dist/cjs/extensions/erc721/__generated__/LoyaltyCard/read/totalMinted.js +70 -0
  12. package/dist/cjs/extensions/erc721/__generated__/LoyaltyCard/read/totalMinted.js.map +1 -0
  13. package/dist/cjs/extensions/erc721/__generated__/LoyaltyCard/write/cancel.js +117 -0
  14. package/dist/cjs/extensions/erc721/__generated__/LoyaltyCard/write/cancel.js.map +1 -0
  15. package/dist/cjs/extensions/erc721/__generated__/LoyaltyCard/write/initialize.js +202 -0
  16. package/dist/cjs/extensions/erc721/__generated__/LoyaltyCard/write/initialize.js.map +1 -0
  17. package/dist/cjs/extensions/erc721/__generated__/LoyaltyCard/write/mintTo.js +129 -0
  18. package/dist/cjs/extensions/erc721/__generated__/LoyaltyCard/write/mintTo.js.map +1 -0
  19. package/dist/cjs/extensions/erc721/__generated__/LoyaltyCard/write/mintWithSignature.js +171 -0
  20. package/dist/cjs/extensions/erc721/__generated__/LoyaltyCard/write/mintWithSignature.js.map +1 -0
  21. package/dist/cjs/extensions/erc721/__generated__/LoyaltyCard/write/revoke.js +117 -0
  22. package/dist/cjs/extensions/erc721/__generated__/LoyaltyCard/write/revoke.js.map +1 -0
  23. package/dist/cjs/extensions/erc721/__generated__/Multiwrap/events/TokensUnwrapped.js +33 -0
  24. package/dist/cjs/extensions/erc721/__generated__/Multiwrap/events/TokensUnwrapped.js.map +1 -0
  25. package/dist/cjs/extensions/erc721/__generated__/Multiwrap/events/TokensWrapped.js +33 -0
  26. package/dist/cjs/extensions/erc721/__generated__/Multiwrap/events/TokensWrapped.js.map +1 -0
  27. package/dist/cjs/extensions/erc721/__generated__/Multiwrap/read/contractType.js +70 -0
  28. package/dist/cjs/extensions/erc721/__generated__/Multiwrap/read/contractType.js.map +1 -0
  29. package/dist/cjs/extensions/erc721/__generated__/Multiwrap/read/contractVersion.js +70 -0
  30. package/dist/cjs/extensions/erc721/__generated__/Multiwrap/read/contractVersion.js.map +1 -0
  31. package/dist/cjs/extensions/erc721/__generated__/Multiwrap/read/getWrappedContents.js +133 -0
  32. package/dist/cjs/extensions/erc721/__generated__/Multiwrap/read/getWrappedContents.js.map +1 -0
  33. package/dist/cjs/extensions/erc721/__generated__/Multiwrap/read/nextTokenIdToMint.js +70 -0
  34. package/dist/cjs/extensions/erc721/__generated__/Multiwrap/read/nextTokenIdToMint.js.map +1 -0
  35. package/dist/cjs/extensions/erc721/__generated__/Multiwrap/read/supportsInterface.js +114 -0
  36. package/dist/cjs/extensions/erc721/__generated__/Multiwrap/read/supportsInterface.js.map +1 -0
  37. package/dist/cjs/extensions/erc721/__generated__/Multiwrap/read/tokenURI.js +114 -0
  38. package/dist/cjs/extensions/erc721/__generated__/Multiwrap/read/tokenURI.js.map +1 -0
  39. package/dist/cjs/extensions/erc721/__generated__/Multiwrap/write/initialize.js +175 -0
  40. package/dist/cjs/extensions/erc721/__generated__/Multiwrap/write/initialize.js.map +1 -0
  41. package/dist/cjs/extensions/erc721/__generated__/Multiwrap/write/unwrap.js +124 -0
  42. package/dist/cjs/extensions/erc721/__generated__/Multiwrap/write/unwrap.js.map +1 -0
  43. package/dist/cjs/extensions/erc721/__generated__/Multiwrap/write/wrap.js +162 -0
  44. package/dist/cjs/extensions/erc721/__generated__/Multiwrap/write/wrap.js.map +1 -0
  45. package/dist/cjs/extensions/prebuilts/deploy-erc721.js +21 -6
  46. package/dist/cjs/extensions/prebuilts/deploy-erc721.js.map +1 -1
  47. package/dist/cjs/version.js +1 -1
  48. package/dist/esm/extensions/erc721/__generated__/LoyaltyCard/events/TokensMinted.js +29 -0
  49. package/dist/esm/extensions/erc721/__generated__/LoyaltyCard/events/TokensMinted.js.map +1 -0
  50. package/dist/esm/extensions/erc721/__generated__/LoyaltyCard/events/TokensMintedWithSignature.js +30 -0
  51. package/dist/esm/extensions/erc721/__generated__/LoyaltyCard/events/TokensMintedWithSignature.js.map +1 -0
  52. package/dist/esm/extensions/erc721/__generated__/LoyaltyCard/read/nextTokenIdToMint.js +64 -0
  53. package/dist/esm/extensions/erc721/__generated__/LoyaltyCard/read/nextTokenIdToMint.js.map +1 -0
  54. package/dist/esm/extensions/erc721/__generated__/LoyaltyCard/read/supportsInterface.js +106 -0
  55. package/dist/esm/extensions/erc721/__generated__/LoyaltyCard/read/supportsInterface.js.map +1 -0
  56. package/dist/esm/extensions/erc721/__generated__/LoyaltyCard/read/tokenURI.js +106 -0
  57. package/dist/esm/extensions/erc721/__generated__/LoyaltyCard/read/tokenURI.js.map +1 -0
  58. package/dist/esm/extensions/erc721/__generated__/LoyaltyCard/read/totalMinted.js +64 -0
  59. package/dist/esm/extensions/erc721/__generated__/LoyaltyCard/read/totalMinted.js.map +1 -0
  60. package/dist/esm/extensions/erc721/__generated__/LoyaltyCard/write/cancel.js +110 -0
  61. package/dist/esm/extensions/erc721/__generated__/LoyaltyCard/write/cancel.js.map +1 -0
  62. package/dist/esm/extensions/erc721/__generated__/LoyaltyCard/write/initialize.js +195 -0
  63. package/dist/esm/extensions/erc721/__generated__/LoyaltyCard/write/initialize.js.map +1 -0
  64. package/dist/esm/extensions/erc721/__generated__/LoyaltyCard/write/mintTo.js +122 -0
  65. package/dist/esm/extensions/erc721/__generated__/LoyaltyCard/write/mintTo.js.map +1 -0
  66. package/dist/esm/extensions/erc721/__generated__/LoyaltyCard/write/mintWithSignature.js +164 -0
  67. package/dist/esm/extensions/erc721/__generated__/LoyaltyCard/write/mintWithSignature.js.map +1 -0
  68. package/dist/esm/extensions/erc721/__generated__/LoyaltyCard/write/revoke.js +110 -0
  69. package/dist/esm/extensions/erc721/__generated__/LoyaltyCard/write/revoke.js.map +1 -0
  70. package/dist/esm/extensions/erc721/__generated__/Multiwrap/events/TokensUnwrapped.js +30 -0
  71. package/dist/esm/extensions/erc721/__generated__/Multiwrap/events/TokensUnwrapped.js.map +1 -0
  72. package/dist/esm/extensions/erc721/__generated__/Multiwrap/events/TokensWrapped.js +30 -0
  73. package/dist/esm/extensions/erc721/__generated__/Multiwrap/events/TokensWrapped.js.map +1 -0
  74. package/dist/esm/extensions/erc721/__generated__/Multiwrap/read/contractType.js +64 -0
  75. package/dist/esm/extensions/erc721/__generated__/Multiwrap/read/contractType.js.map +1 -0
  76. package/dist/esm/extensions/erc721/__generated__/Multiwrap/read/contractVersion.js +64 -0
  77. package/dist/esm/extensions/erc721/__generated__/Multiwrap/read/contractVersion.js.map +1 -0
  78. package/dist/esm/extensions/erc721/__generated__/Multiwrap/read/getWrappedContents.js +125 -0
  79. package/dist/esm/extensions/erc721/__generated__/Multiwrap/read/getWrappedContents.js.map +1 -0
  80. package/dist/esm/extensions/erc721/__generated__/Multiwrap/read/nextTokenIdToMint.js +64 -0
  81. package/dist/esm/extensions/erc721/__generated__/Multiwrap/read/nextTokenIdToMint.js.map +1 -0
  82. package/dist/esm/extensions/erc721/__generated__/Multiwrap/read/supportsInterface.js +106 -0
  83. package/dist/esm/extensions/erc721/__generated__/Multiwrap/read/supportsInterface.js.map +1 -0
  84. package/dist/esm/extensions/erc721/__generated__/Multiwrap/read/tokenURI.js +106 -0
  85. package/dist/esm/extensions/erc721/__generated__/Multiwrap/read/tokenURI.js.map +1 -0
  86. package/dist/esm/extensions/erc721/__generated__/Multiwrap/write/initialize.js +168 -0
  87. package/dist/esm/extensions/erc721/__generated__/Multiwrap/write/initialize.js.map +1 -0
  88. package/dist/esm/extensions/erc721/__generated__/Multiwrap/write/unwrap.js +117 -0
  89. package/dist/esm/extensions/erc721/__generated__/Multiwrap/write/unwrap.js.map +1 -0
  90. package/dist/esm/extensions/erc721/__generated__/Multiwrap/write/wrap.js +155 -0
  91. package/dist/esm/extensions/erc721/__generated__/Multiwrap/write/wrap.js.map +1 -0
  92. package/dist/esm/extensions/prebuilts/deploy-erc721.js +15 -0
  93. package/dist/esm/extensions/prebuilts/deploy-erc721.js.map +1 -1
  94. package/dist/esm/version.js +1 -1
  95. package/dist/types/extensions/erc721/__generated__/LoyaltyCard/events/TokensMinted.d.ts +54 -0
  96. package/dist/types/extensions/erc721/__generated__/LoyaltyCard/events/TokensMinted.d.ts.map +1 -0
  97. package/dist/types/extensions/erc721/__generated__/LoyaltyCard/events/TokensMintedWithSignature.d.ts +95 -0
  98. package/dist/types/extensions/erc721/__generated__/LoyaltyCard/events/TokensMintedWithSignature.d.ts.map +1 -0
  99. package/dist/types/extensions/erc721/__generated__/LoyaltyCard/read/nextTokenIdToMint.d.ts +44 -0
  100. package/dist/types/extensions/erc721/__generated__/LoyaltyCard/read/nextTokenIdToMint.d.ts.map +1 -0
  101. package/dist/types/extensions/erc721/__generated__/LoyaltyCard/read/supportsInterface.d.ts +83 -0
  102. package/dist/types/extensions/erc721/__generated__/LoyaltyCard/read/supportsInterface.d.ts.map +1 -0
  103. package/dist/types/extensions/erc721/__generated__/LoyaltyCard/read/tokenURI.d.ts +83 -0
  104. package/dist/types/extensions/erc721/__generated__/LoyaltyCard/read/tokenURI.d.ts.map +1 -0
  105. package/dist/types/extensions/erc721/__generated__/LoyaltyCard/read/totalMinted.d.ts +44 -0
  106. package/dist/types/extensions/erc721/__generated__/LoyaltyCard/read/totalMinted.d.ts.map +1 -0
  107. package/dist/types/extensions/erc721/__generated__/LoyaltyCard/write/cancel.d.ts +79 -0
  108. package/dist/types/extensions/erc721/__generated__/LoyaltyCard/write/cancel.d.ts.map +1 -0
  109. package/dist/types/extensions/erc721/__generated__/LoyaltyCard/write/initialize.d.ts +142 -0
  110. package/dist/types/extensions/erc721/__generated__/LoyaltyCard/write/initialize.d.ts.map +1 -0
  111. package/dist/types/extensions/erc721/__generated__/LoyaltyCard/write/mintTo.d.ts +86 -0
  112. package/dist/types/extensions/erc721/__generated__/LoyaltyCard/write/mintTo.d.ts.map +1 -0
  113. package/dist/types/extensions/erc721/__generated__/LoyaltyCard/write/mintWithSignature.d.ts +128 -0
  114. package/dist/types/extensions/erc721/__generated__/LoyaltyCard/write/mintWithSignature.d.ts.map +1 -0
  115. package/dist/types/extensions/erc721/__generated__/LoyaltyCard/write/revoke.d.ts +79 -0
  116. package/dist/types/extensions/erc721/__generated__/LoyaltyCard/write/revoke.d.ts.map +1 -0
  117. package/dist/types/extensions/erc721/__generated__/Multiwrap/events/TokensUnwrapped.d.ts +61 -0
  118. package/dist/types/extensions/erc721/__generated__/Multiwrap/events/TokensUnwrapped.d.ts.map +1 -0
  119. package/dist/types/extensions/erc721/__generated__/Multiwrap/events/TokensWrapped.d.ts +77 -0
  120. package/dist/types/extensions/erc721/__generated__/Multiwrap/events/TokensWrapped.d.ts.map +1 -0
  121. package/dist/types/extensions/erc721/__generated__/Multiwrap/read/contractType.d.ts +44 -0
  122. package/dist/types/extensions/erc721/__generated__/Multiwrap/read/contractType.d.ts.map +1 -0
  123. package/dist/types/extensions/erc721/__generated__/Multiwrap/read/contractVersion.d.ts +44 -0
  124. package/dist/types/extensions/erc721/__generated__/Multiwrap/read/contractVersion.d.ts.map +1 -0
  125. package/dist/types/extensions/erc721/__generated__/Multiwrap/read/getWrappedContents.d.ts +93 -0
  126. package/dist/types/extensions/erc721/__generated__/Multiwrap/read/getWrappedContents.d.ts.map +1 -0
  127. package/dist/types/extensions/erc721/__generated__/Multiwrap/read/nextTokenIdToMint.d.ts +44 -0
  128. package/dist/types/extensions/erc721/__generated__/Multiwrap/read/nextTokenIdToMint.d.ts.map +1 -0
  129. package/dist/types/extensions/erc721/__generated__/Multiwrap/read/supportsInterface.d.ts +83 -0
  130. package/dist/types/extensions/erc721/__generated__/Multiwrap/read/supportsInterface.d.ts.map +1 -0
  131. package/dist/types/extensions/erc721/__generated__/Multiwrap/read/tokenURI.d.ts +83 -0
  132. package/dist/types/extensions/erc721/__generated__/Multiwrap/read/tokenURI.d.ts.map +1 -0
  133. package/dist/types/extensions/erc721/__generated__/Multiwrap/write/initialize.d.ts +121 -0
  134. package/dist/types/extensions/erc721/__generated__/Multiwrap/write/initialize.d.ts.map +1 -0
  135. package/dist/types/extensions/erc721/__generated__/Multiwrap/write/unwrap.d.ts +86 -0
  136. package/dist/types/extensions/erc721/__generated__/Multiwrap/write/unwrap.d.ts.map +1 -0
  137. package/dist/types/extensions/erc721/__generated__/Multiwrap/write/wrap.d.ts +111 -0
  138. package/dist/types/extensions/erc721/__generated__/Multiwrap/write/wrap.d.ts.map +1 -0
  139. package/dist/types/extensions/prebuilts/deploy-erc721.d.ts +1 -1
  140. package/dist/types/extensions/prebuilts/deploy-erc721.d.ts.map +1 -1
  141. package/dist/types/version.d.ts +1 -1
  142. package/package.json +1 -1
  143. package/src/extensions/erc721/__generated__/LoyaltyCard/events/TokensMinted.ts +47 -0
  144. package/src/extensions/erc721/__generated__/LoyaltyCard/events/TokensMintedWithSignature.ts +55 -0
  145. package/src/extensions/erc721/__generated__/LoyaltyCard/read/nextTokenIdToMint.ts +70 -0
  146. package/src/extensions/erc721/__generated__/LoyaltyCard/read/supportsInterface.ts +130 -0
  147. package/src/extensions/erc721/__generated__/LoyaltyCard/read/tokenURI.ts +123 -0
  148. package/src/extensions/erc721/__generated__/LoyaltyCard/read/totalMinted.ts +70 -0
  149. package/src/extensions/erc721/__generated__/LoyaltyCard/write/cancel.ts +135 -0
  150. package/src/extensions/erc721/__generated__/LoyaltyCard/write/initialize.ts +255 -0
  151. package/src/extensions/erc721/__generated__/LoyaltyCard/write/mintTo.ts +148 -0
  152. package/src/extensions/erc721/__generated__/LoyaltyCard/write/mintWithSignature.ts +209 -0
  153. package/src/extensions/erc721/__generated__/LoyaltyCard/write/revoke.ts +135 -0
  154. package/src/extensions/erc721/__generated__/Multiwrap/events/TokensUnwrapped.ts +55 -0
  155. package/src/extensions/erc721/__generated__/Multiwrap/events/TokensWrapped.ts +53 -0
  156. package/src/extensions/erc721/__generated__/Multiwrap/read/contractType.ts +70 -0
  157. package/src/extensions/erc721/__generated__/Multiwrap/read/contractVersion.ts +70 -0
  158. package/src/extensions/erc721/__generated__/Multiwrap/read/getWrappedContents.ts +146 -0
  159. package/src/extensions/erc721/__generated__/Multiwrap/read/nextTokenIdToMint.ts +70 -0
  160. package/src/extensions/erc721/__generated__/Multiwrap/read/supportsInterface.ts +130 -0
  161. package/src/extensions/erc721/__generated__/Multiwrap/read/tokenURI.ts +123 -0
  162. package/src/extensions/erc721/__generated__/Multiwrap/write/initialize.ts +216 -0
  163. package/src/extensions/erc721/__generated__/Multiwrap/write/unwrap.ts +146 -0
  164. package/src/extensions/erc721/__generated__/Multiwrap/write/wrap.ts +197 -0
  165. package/src/extensions/prebuilts/deploy-erc721.test.ts +70 -2
  166. package/src/extensions/prebuilts/deploy-erc721.ts +17 -1
  167. package/src/version.ts +1 -1
@@ -0,0 +1,148 @@
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 "mintTo" function.
13
+ */
14
+ export type MintToParams = WithOverrides<{
15
+ to: AbiParameterToPrimitiveType<{ type: "address"; name: "_to" }>;
16
+ uri: AbiParameterToPrimitiveType<{ type: "string"; name: "_uri" }>;
17
+ }>;
18
+
19
+ export const FN_SELECTOR = "0x0075a317" as const;
20
+ const FN_INPUTS = [
21
+ {
22
+ type: "address",
23
+ name: "_to",
24
+ },
25
+ {
26
+ type: "string",
27
+ name: "_uri",
28
+ },
29
+ ] as const;
30
+ const FN_OUTPUTS = [
31
+ {
32
+ type: "uint256",
33
+ name: "tokenIdMinted",
34
+ },
35
+ ] as const;
36
+
37
+ /**
38
+ * Checks if the `mintTo` method is supported by the given contract.
39
+ * @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.
40
+ * @returns A boolean indicating if the `mintTo` method is supported.
41
+ * @extension ERC721
42
+ * @example
43
+ * ```ts
44
+ * import { isMintToSupported } from "thirdweb/extensions/erc721";
45
+ *
46
+ * const supported = isMintToSupported(["0x..."]);
47
+ * ```
48
+ */
49
+ export function isMintToSupported(availableSelectors: string[]) {
50
+ return detectMethod({
51
+ availableSelectors,
52
+ method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
53
+ });
54
+ }
55
+
56
+ /**
57
+ * Encodes the parameters for the "mintTo" function.
58
+ * @param options - The options for the mintTo function.
59
+ * @returns The encoded ABI parameters.
60
+ * @extension ERC721
61
+ * @example
62
+ * ```ts
63
+ * import { encodeMintToParams } from "thirdweb/extensions/erc721";
64
+ * const result = encodeMintToParams({
65
+ * to: ...,
66
+ * uri: ...,
67
+ * });
68
+ * ```
69
+ */
70
+ export function encodeMintToParams(options: MintToParams) {
71
+ return encodeAbiParameters(FN_INPUTS, [options.to, options.uri]);
72
+ }
73
+
74
+ /**
75
+ * Encodes the "mintTo" function into a Hex string with its parameters.
76
+ * @param options - The options for the mintTo function.
77
+ * @returns The encoded hexadecimal string.
78
+ * @extension ERC721
79
+ * @example
80
+ * ```ts
81
+ * import { encodeMintTo } from "thirdweb/extensions/erc721";
82
+ * const result = encodeMintTo({
83
+ * to: ...,
84
+ * uri: ...,
85
+ * });
86
+ * ```
87
+ */
88
+ export function encodeMintTo(options: MintToParams) {
89
+ // we do a "manual" concat here to avoid the overhead of the "concatHex" function
90
+ // we can do this because we know the specific formats of the values
91
+ return (FN_SELECTOR +
92
+ encodeMintToParams(options).slice(2)) as `${typeof FN_SELECTOR}${string}`;
93
+ }
94
+
95
+ /**
96
+ * Prepares a transaction to call the "mintTo" function on the contract.
97
+ * @param options - The options for the "mintTo" function.
98
+ * @returns A prepared transaction object.
99
+ * @extension ERC721
100
+ * @example
101
+ * ```ts
102
+ * import { sendTransaction } from "thirdweb";
103
+ * import { mintTo } from "thirdweb/extensions/erc721";
104
+ *
105
+ * const transaction = mintTo({
106
+ * contract,
107
+ * to: ...,
108
+ * uri: ...,
109
+ * overrides: {
110
+ * ...
111
+ * }
112
+ * });
113
+ *
114
+ * // Send the transaction
115
+ * await sendTransaction({ transaction, account });
116
+ * ```
117
+ */
118
+ export function mintTo(
119
+ options: BaseTransactionOptions<
120
+ | MintToParams
121
+ | {
122
+ asyncParams: () => Promise<MintToParams>;
123
+ }
124
+ >,
125
+ ) {
126
+ const asyncOptions = once(async () => {
127
+ return "asyncParams" in options ? await options.asyncParams() : options;
128
+ });
129
+
130
+ return prepareContractCall({
131
+ contract: options.contract,
132
+ method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
133
+ params: async () => {
134
+ const resolvedOptions = await asyncOptions();
135
+ return [resolvedOptions.to, resolvedOptions.uri] as const;
136
+ },
137
+ value: async () => (await asyncOptions()).overrides?.value,
138
+ accessList: async () => (await asyncOptions()).overrides?.accessList,
139
+ gas: async () => (await asyncOptions()).overrides?.gas,
140
+ gasPrice: async () => (await asyncOptions()).overrides?.gasPrice,
141
+ maxFeePerGas: async () => (await asyncOptions()).overrides?.maxFeePerGas,
142
+ maxPriorityFeePerGas: async () =>
143
+ (await asyncOptions()).overrides?.maxPriorityFeePerGas,
144
+ nonce: async () => (await asyncOptions()).overrides?.nonce,
145
+ extraGas: async () => (await asyncOptions()).overrides?.extraGas,
146
+ erc20Value: async () => (await asyncOptions()).overrides?.erc20Value,
147
+ });
148
+ }
@@ -0,0 +1,209 @@
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 "mintWithSignature" function.
13
+ */
14
+ export type MintWithSignatureParams = WithOverrides<{
15
+ req: AbiParameterToPrimitiveType<{
16
+ type: "tuple";
17
+ name: "_req";
18
+ components: [
19
+ { type: "address"; name: "to" },
20
+ { type: "address"; name: "royaltyRecipient" },
21
+ { type: "uint256"; name: "royaltyBps" },
22
+ { type: "address"; name: "primarySaleRecipient" },
23
+ { type: "uint256"; name: "quantity" },
24
+ { type: "uint256"; name: "pricePerToken" },
25
+ { type: "address"; name: "currency" },
26
+ { type: "uint128"; name: "validityStartTimestamp" },
27
+ { type: "uint128"; name: "validityEndTimestamp" },
28
+ { type: "string"; name: "uri" },
29
+ ];
30
+ }>;
31
+ signature: AbiParameterToPrimitiveType<{ type: "bytes"; name: "_signature" }>;
32
+ }>;
33
+
34
+ export const FN_SELECTOR = "0x91c5ee92" as const;
35
+ const FN_INPUTS = [
36
+ {
37
+ type: "tuple",
38
+ name: "_req",
39
+ components: [
40
+ {
41
+ type: "address",
42
+ name: "to",
43
+ },
44
+ {
45
+ type: "address",
46
+ name: "royaltyRecipient",
47
+ },
48
+ {
49
+ type: "uint256",
50
+ name: "royaltyBps",
51
+ },
52
+ {
53
+ type: "address",
54
+ name: "primarySaleRecipient",
55
+ },
56
+ {
57
+ type: "uint256",
58
+ name: "quantity",
59
+ },
60
+ {
61
+ type: "uint256",
62
+ name: "pricePerToken",
63
+ },
64
+ {
65
+ type: "address",
66
+ name: "currency",
67
+ },
68
+ {
69
+ type: "uint128",
70
+ name: "validityStartTimestamp",
71
+ },
72
+ {
73
+ type: "uint128",
74
+ name: "validityEndTimestamp",
75
+ },
76
+ {
77
+ type: "string",
78
+ name: "uri",
79
+ },
80
+ ],
81
+ },
82
+ {
83
+ type: "bytes",
84
+ name: "_signature",
85
+ },
86
+ ] as const;
87
+ const FN_OUTPUTS = [
88
+ {
89
+ type: "address",
90
+ name: "signer",
91
+ },
92
+ ] as const;
93
+
94
+ /**
95
+ * Checks if the `mintWithSignature` method is supported by the given contract.
96
+ * @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.
97
+ * @returns A boolean indicating if the `mintWithSignature` method is supported.
98
+ * @extension ERC721
99
+ * @example
100
+ * ```ts
101
+ * import { isMintWithSignatureSupported } from "thirdweb/extensions/erc721";
102
+ *
103
+ * const supported = isMintWithSignatureSupported(["0x..."]);
104
+ * ```
105
+ */
106
+ export function isMintWithSignatureSupported(availableSelectors: string[]) {
107
+ return detectMethod({
108
+ availableSelectors,
109
+ method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
110
+ });
111
+ }
112
+
113
+ /**
114
+ * Encodes the parameters for the "mintWithSignature" function.
115
+ * @param options - The options for the mintWithSignature function.
116
+ * @returns The encoded ABI parameters.
117
+ * @extension ERC721
118
+ * @example
119
+ * ```ts
120
+ * import { encodeMintWithSignatureParams } from "thirdweb/extensions/erc721";
121
+ * const result = encodeMintWithSignatureParams({
122
+ * req: ...,
123
+ * signature: ...,
124
+ * });
125
+ * ```
126
+ */
127
+ export function encodeMintWithSignatureParams(
128
+ options: MintWithSignatureParams,
129
+ ) {
130
+ return encodeAbiParameters(FN_INPUTS, [options.req, options.signature]);
131
+ }
132
+
133
+ /**
134
+ * Encodes the "mintWithSignature" function into a Hex string with its parameters.
135
+ * @param options - The options for the mintWithSignature function.
136
+ * @returns The encoded hexadecimal string.
137
+ * @extension ERC721
138
+ * @example
139
+ * ```ts
140
+ * import { encodeMintWithSignature } from "thirdweb/extensions/erc721";
141
+ * const result = encodeMintWithSignature({
142
+ * req: ...,
143
+ * signature: ...,
144
+ * });
145
+ * ```
146
+ */
147
+ export function encodeMintWithSignature(options: MintWithSignatureParams) {
148
+ // we do a "manual" concat here to avoid the overhead of the "concatHex" function
149
+ // we can do this because we know the specific formats of the values
150
+ return (FN_SELECTOR +
151
+ encodeMintWithSignatureParams(options).slice(
152
+ 2,
153
+ )) as `${typeof FN_SELECTOR}${string}`;
154
+ }
155
+
156
+ /**
157
+ * Prepares a transaction to call the "mintWithSignature" function on the contract.
158
+ * @param options - The options for the "mintWithSignature" function.
159
+ * @returns A prepared transaction object.
160
+ * @extension ERC721
161
+ * @example
162
+ * ```ts
163
+ * import { sendTransaction } from "thirdweb";
164
+ * import { mintWithSignature } from "thirdweb/extensions/erc721";
165
+ *
166
+ * const transaction = mintWithSignature({
167
+ * contract,
168
+ * req: ...,
169
+ * signature: ...,
170
+ * overrides: {
171
+ * ...
172
+ * }
173
+ * });
174
+ *
175
+ * // Send the transaction
176
+ * await sendTransaction({ transaction, account });
177
+ * ```
178
+ */
179
+ export function mintWithSignature(
180
+ options: BaseTransactionOptions<
181
+ | MintWithSignatureParams
182
+ | {
183
+ asyncParams: () => Promise<MintWithSignatureParams>;
184
+ }
185
+ >,
186
+ ) {
187
+ const asyncOptions = once(async () => {
188
+ return "asyncParams" in options ? await options.asyncParams() : options;
189
+ });
190
+
191
+ return prepareContractCall({
192
+ contract: options.contract,
193
+ method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
194
+ params: async () => {
195
+ const resolvedOptions = await asyncOptions();
196
+ return [resolvedOptions.req, resolvedOptions.signature] as const;
197
+ },
198
+ value: async () => (await asyncOptions()).overrides?.value,
199
+ accessList: async () => (await asyncOptions()).overrides?.accessList,
200
+ gas: async () => (await asyncOptions()).overrides?.gas,
201
+ gasPrice: async () => (await asyncOptions()).overrides?.gasPrice,
202
+ maxFeePerGas: async () => (await asyncOptions()).overrides?.maxFeePerGas,
203
+ maxPriorityFeePerGas: async () =>
204
+ (await asyncOptions()).overrides?.maxPriorityFeePerGas,
205
+ nonce: async () => (await asyncOptions()).overrides?.nonce,
206
+ extraGas: async () => (await asyncOptions()).overrides?.extraGas,
207
+ erc20Value: async () => (await asyncOptions()).overrides?.erc20Value,
208
+ });
209
+ }
@@ -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 "revoke" function.
13
+ */
14
+ export type RevokeParams = WithOverrides<{
15
+ tokenId: AbiParameterToPrimitiveType<{ type: "uint256"; name: "tokenId" }>;
16
+ }>;
17
+
18
+ export const FN_SELECTOR = "0x20c5429b" 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 `revoke` 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 `revoke` method is supported.
31
+ * @extension ERC721
32
+ * @example
33
+ * ```ts
34
+ * import { isRevokeSupported } from "thirdweb/extensions/erc721";
35
+ *
36
+ * const supported = isRevokeSupported(["0x..."]);
37
+ * ```
38
+ */
39
+ export function isRevokeSupported(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 "revoke" function.
48
+ * @param options - The options for the revoke function.
49
+ * @returns The encoded ABI parameters.
50
+ * @extension ERC721
51
+ * @example
52
+ * ```ts
53
+ * import { encodeRevokeParams } from "thirdweb/extensions/erc721";
54
+ * const result = encodeRevokeParams({
55
+ * tokenId: ...,
56
+ * });
57
+ * ```
58
+ */
59
+ export function encodeRevokeParams(options: RevokeParams) {
60
+ return encodeAbiParameters(FN_INPUTS, [options.tokenId]);
61
+ }
62
+
63
+ /**
64
+ * Encodes the "revoke" function into a Hex string with its parameters.
65
+ * @param options - The options for the revoke function.
66
+ * @returns The encoded hexadecimal string.
67
+ * @extension ERC721
68
+ * @example
69
+ * ```ts
70
+ * import { encodeRevoke } from "thirdweb/extensions/erc721";
71
+ * const result = encodeRevoke({
72
+ * tokenId: ...,
73
+ * });
74
+ * ```
75
+ */
76
+ export function encodeRevoke(options: RevokeParams) {
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
+ encodeRevokeParams(options).slice(2)) as `${typeof FN_SELECTOR}${string}`;
81
+ }
82
+
83
+ /**
84
+ * Prepares a transaction to call the "revoke" function on the contract.
85
+ * @param options - The options for the "revoke" function.
86
+ * @returns A prepared transaction object.
87
+ * @extension ERC721
88
+ * @example
89
+ * ```ts
90
+ * import { sendTransaction } from "thirdweb";
91
+ * import { revoke } from "thirdweb/extensions/erc721";
92
+ *
93
+ * const transaction = revoke({
94
+ * contract,
95
+ * tokenId: ...,
96
+ * overrides: {
97
+ * ...
98
+ * }
99
+ * });
100
+ *
101
+ * // Send the transaction
102
+ * await sendTransaction({ transaction, account });
103
+ * ```
104
+ */
105
+ export function revoke(
106
+ options: BaseTransactionOptions<
107
+ | RevokeParams
108
+ | {
109
+ asyncParams: () => Promise<RevokeParams>;
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,55 @@
1
+ import { prepareEvent } from "../../../../../event/prepare-event.js";
2
+ import type { AbiParameterToPrimitiveType } from "abitype";
3
+
4
+ /**
5
+ * Represents the filters for the "TokensUnwrapped" event.
6
+ */
7
+ export type TokensUnwrappedEventFilters = Partial<{
8
+ unwrapper: AbiParameterToPrimitiveType<{
9
+ type: "address";
10
+ name: "unwrapper";
11
+ indexed: true;
12
+ }>;
13
+ recipientOfWrappedContents: AbiParameterToPrimitiveType<{
14
+ type: "address";
15
+ name: "recipientOfWrappedContents";
16
+ indexed: true;
17
+ }>;
18
+ tokenIdOfWrappedToken: AbiParameterToPrimitiveType<{
19
+ type: "uint256";
20
+ name: "tokenIdOfWrappedToken";
21
+ indexed: true;
22
+ }>;
23
+ }>;
24
+
25
+ /**
26
+ * Creates an event object for the TokensUnwrapped event.
27
+ * @param filters - Optional filters to apply to the event.
28
+ * @returns The prepared event object.
29
+ * @extension ERC721
30
+ * @example
31
+ * ```ts
32
+ * import { getContractEvents } from "thirdweb";
33
+ * import { tokensUnwrappedEvent } from "thirdweb/extensions/erc721";
34
+ *
35
+ * const events = await getContractEvents({
36
+ * contract,
37
+ * events: [
38
+ * tokensUnwrappedEvent({
39
+ * unwrapper: ...,
40
+ * recipientOfWrappedContents: ...,
41
+ * tokenIdOfWrappedToken: ...,
42
+ * })
43
+ * ],
44
+ * });
45
+ * ```
46
+ */
47
+ export function tokensUnwrappedEvent(
48
+ filters: TokensUnwrappedEventFilters = {},
49
+ ) {
50
+ return prepareEvent({
51
+ signature:
52
+ "event TokensUnwrapped(address indexed unwrapper, address indexed recipientOfWrappedContents, uint256 indexed tokenIdOfWrappedToken)",
53
+ filters,
54
+ });
55
+ }
@@ -0,0 +1,53 @@
1
+ import { prepareEvent } from "../../../../../event/prepare-event.js";
2
+ import type { AbiParameterToPrimitiveType } from "abitype";
3
+
4
+ /**
5
+ * Represents the filters for the "TokensWrapped" event.
6
+ */
7
+ export type TokensWrappedEventFilters = Partial<{
8
+ wrapper: AbiParameterToPrimitiveType<{
9
+ type: "address";
10
+ name: "wrapper";
11
+ indexed: true;
12
+ }>;
13
+ recipientOfWrappedToken: AbiParameterToPrimitiveType<{
14
+ type: "address";
15
+ name: "recipientOfWrappedToken";
16
+ indexed: true;
17
+ }>;
18
+ tokenIdOfWrappedToken: AbiParameterToPrimitiveType<{
19
+ type: "uint256";
20
+ name: "tokenIdOfWrappedToken";
21
+ indexed: true;
22
+ }>;
23
+ }>;
24
+
25
+ /**
26
+ * Creates an event object for the TokensWrapped event.
27
+ * @param filters - Optional filters to apply to the event.
28
+ * @returns The prepared event object.
29
+ * @extension ERC721
30
+ * @example
31
+ * ```ts
32
+ * import { getContractEvents } from "thirdweb";
33
+ * import { tokensWrappedEvent } from "thirdweb/extensions/erc721";
34
+ *
35
+ * const events = await getContractEvents({
36
+ * contract,
37
+ * events: [
38
+ * tokensWrappedEvent({
39
+ * wrapper: ...,
40
+ * recipientOfWrappedToken: ...,
41
+ * tokenIdOfWrappedToken: ...,
42
+ * })
43
+ * ],
44
+ * });
45
+ * ```
46
+ */
47
+ export function tokensWrappedEvent(filters: TokensWrappedEventFilters = {}) {
48
+ return prepareEvent({
49
+ signature:
50
+ "event TokensWrapped(address indexed wrapper, address indexed recipientOfWrappedToken, uint256 indexed tokenIdOfWrappedToken, (address assetContract, uint8 tokenType, uint256 tokenId, uint256 amount)[] wrappedContents)",
51
+ filters,
52
+ });
53
+ }
@@ -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 = "0xcb2ef6f7" as const;
9
+ const FN_INPUTS = [] as const;
10
+ const FN_OUTPUTS = [
11
+ {
12
+ type: "bytes32",
13
+ },
14
+ ] as const;
15
+
16
+ /**
17
+ * Checks if the `contractType` 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 `contractType` method is supported.
20
+ * @extension ERC721
21
+ * @example
22
+ * ```ts
23
+ * import { isContractTypeSupported } from "thirdweb/extensions/erc721";
24
+ * const supported = isContractTypeSupported(["0x..."]);
25
+ * ```
26
+ */
27
+ export function isContractTypeSupported(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 contractType 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 { decodeContractTypeResult } from "thirdweb/extensions/erc721";
42
+ * const result = decodeContractTypeResultResult("...");
43
+ * ```
44
+ */
45
+ export function decodeContractTypeResult(result: Hex) {
46
+ return decodeAbiParameters(FN_OUTPUTS, result)[0];
47
+ }
48
+
49
+ /**
50
+ * Calls the "contractType" function on the contract.
51
+ * @param options - The options for the contractType function.
52
+ * @returns The parsed result of the function call.
53
+ * @extension ERC721
54
+ * @example
55
+ * ```ts
56
+ * import { contractType } from "thirdweb/extensions/erc721";
57
+ *
58
+ * const result = await contractType({
59
+ * contract,
60
+ * });
61
+ *
62
+ * ```
63
+ */
64
+ export async function contractType(options: BaseTransactionOptions) {
65
+ return readContract({
66
+ contract: options.contract,
67
+ method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
68
+ params: [],
69
+ });
70
+ }