thirdweb 5.29.6 → 5.30.0-nightly-991cb72bdb1b94fcf0f9a3de36b2ec8ee07ae5ec-20240619000538

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 (139) hide show
  1. package/dist/cjs/exports/extensions/erc1155.js +3 -1
  2. package/dist/cjs/exports/extensions/erc1155.js.map +1 -1
  3. package/dist/cjs/extensions/erc1155/__generated__/BatchMintMetadata/events/BatchMetadataUpdate.js +28 -0
  4. package/dist/cjs/extensions/erc1155/__generated__/BatchMintMetadata/events/BatchMetadataUpdate.js.map +1 -0
  5. package/dist/cjs/extensions/erc1155/__generated__/BatchMintMetadata/read/getBaseURICount.js +71 -0
  6. package/dist/cjs/extensions/erc1155/__generated__/BatchMintMetadata/read/getBaseURICount.js.map +1 -0
  7. package/dist/cjs/extensions/erc1155/__generated__/BatchMintMetadata/read/getBatchIdAtIndex.js +115 -0
  8. package/dist/cjs/extensions/erc1155/__generated__/BatchMintMetadata/read/getBatchIdAtIndex.js.map +1 -0
  9. package/dist/cjs/extensions/erc1155/__generated__/DropERC1155/write/freezeBatchBaseURI.js +116 -0
  10. package/dist/cjs/extensions/erc1155/__generated__/DropERC1155/write/freezeBatchBaseURI.js.map +1 -0
  11. package/dist/cjs/extensions/erc1155/__generated__/DropERC1155/write/setMaxTotalSupply.js +126 -0
  12. package/dist/cjs/extensions/erc1155/__generated__/DropERC1155/write/setMaxTotalSupply.js.map +1 -0
  13. package/dist/cjs/extensions/erc1155/__generated__/DropERC1155/write/setSaleRecipientForToken.js +126 -0
  14. package/dist/cjs/extensions/erc1155/__generated__/DropERC1155/write/setSaleRecipientForToken.js.map +1 -0
  15. package/dist/cjs/extensions/erc1155/__generated__/DropERC1155/write/updateBatchBaseURI.js +123 -0
  16. package/dist/cjs/extensions/erc1155/__generated__/DropERC1155/write/updateBatchBaseURI.js.map +1 -0
  17. package/dist/cjs/extensions/erc1155/drops/write/updateMetadata.js +89 -0
  18. package/dist/cjs/extensions/erc1155/drops/write/updateMetadata.js.map +1 -0
  19. package/dist/cjs/pay/buyWithCrypto/getQuote.js +19 -21
  20. package/dist/cjs/pay/buyWithCrypto/getQuote.js.map +1 -1
  21. package/dist/cjs/pay/buyWithCrypto/getStatus.js.map +1 -1
  22. package/dist/cjs/pay/buyWithFiat/getQuote.js +19 -20
  23. package/dist/cjs/pay/buyWithFiat/getQuote.js.map +1 -1
  24. package/dist/cjs/pay/buyWithFiat/getStatus.js.map +1 -1
  25. package/dist/cjs/react/core/hooks/transaction/useSendTransaction.js.map +1 -1
  26. package/dist/cjs/react/native/hooks/wallets/useActiveWalletChain.js +1 -1
  27. package/dist/cjs/react/web/hooks/transaction/useSendTransaction.js +1 -0
  28. package/dist/cjs/react/web/hooks/transaction/useSendTransaction.js.map +1 -1
  29. package/dist/cjs/react/web/hooks/wallets/useActiveWalletChain.js +1 -1
  30. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js +3 -0
  31. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js.map +1 -1
  32. package/dist/cjs/react/web/ui/ConnectWallet/useConnectModal.js.map +1 -1
  33. package/dist/cjs/react/web/ui/components/CopyIcon.js +2 -1
  34. package/dist/cjs/react/web/ui/components/CopyIcon.js.map +1 -1
  35. package/dist/cjs/version.js +1 -1
  36. package/dist/cjs/version.js.map +1 -1
  37. package/dist/cjs/wallets/wallet-connect/controller.js +6 -6
  38. package/dist/cjs/wallets/wallet-connect/controller.js.map +1 -1
  39. package/dist/esm/exports/extensions/erc1155.js +1 -0
  40. package/dist/esm/exports/extensions/erc1155.js.map +1 -1
  41. package/dist/esm/extensions/erc1155/__generated__/BatchMintMetadata/events/BatchMetadataUpdate.js +24 -0
  42. package/dist/esm/extensions/erc1155/__generated__/BatchMintMetadata/events/BatchMetadataUpdate.js.map +1 -0
  43. package/dist/esm/extensions/erc1155/__generated__/BatchMintMetadata/read/getBaseURICount.js +65 -0
  44. package/dist/esm/extensions/erc1155/__generated__/BatchMintMetadata/read/getBaseURICount.js.map +1 -0
  45. package/dist/esm/extensions/erc1155/__generated__/BatchMintMetadata/read/getBatchIdAtIndex.js +107 -0
  46. package/dist/esm/extensions/erc1155/__generated__/BatchMintMetadata/read/getBatchIdAtIndex.js.map +1 -0
  47. package/dist/esm/extensions/erc1155/__generated__/DropERC1155/write/freezeBatchBaseURI.js +109 -0
  48. package/dist/esm/extensions/erc1155/__generated__/DropERC1155/write/freezeBatchBaseURI.js.map +1 -0
  49. package/dist/esm/extensions/erc1155/__generated__/DropERC1155/write/setMaxTotalSupply.js +119 -0
  50. package/dist/esm/extensions/erc1155/__generated__/DropERC1155/write/setMaxTotalSupply.js.map +1 -0
  51. package/dist/esm/extensions/erc1155/__generated__/DropERC1155/write/setSaleRecipientForToken.js +119 -0
  52. package/dist/esm/extensions/erc1155/__generated__/DropERC1155/write/setSaleRecipientForToken.js.map +1 -0
  53. package/dist/esm/extensions/erc1155/__generated__/DropERC1155/write/updateBatchBaseURI.js +116 -0
  54. package/dist/esm/extensions/erc1155/__generated__/DropERC1155/write/updateBatchBaseURI.js.map +1 -0
  55. package/dist/esm/extensions/erc1155/drops/write/updateMetadata.js +84 -0
  56. package/dist/esm/extensions/erc1155/drops/write/updateMetadata.js.map +1 -0
  57. package/dist/esm/pay/buyWithCrypto/getQuote.js +19 -21
  58. package/dist/esm/pay/buyWithCrypto/getQuote.js.map +1 -1
  59. package/dist/esm/pay/buyWithCrypto/getStatus.js.map +1 -1
  60. package/dist/esm/pay/buyWithFiat/getQuote.js +19 -20
  61. package/dist/esm/pay/buyWithFiat/getQuote.js.map +1 -1
  62. package/dist/esm/pay/buyWithFiat/getStatus.js.map +1 -1
  63. package/dist/esm/react/core/hooks/transaction/useSendTransaction.js.map +1 -1
  64. package/dist/esm/react/native/hooks/wallets/useActiveWalletChain.js +1 -1
  65. package/dist/esm/react/web/hooks/transaction/useSendTransaction.js +1 -0
  66. package/dist/esm/react/web/hooks/transaction/useSendTransaction.js.map +1 -1
  67. package/dist/esm/react/web/hooks/wallets/useActiveWalletChain.js +1 -1
  68. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js +3 -0
  69. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js.map +1 -1
  70. package/dist/esm/react/web/ui/ConnectWallet/useConnectModal.js.map +1 -1
  71. package/dist/esm/react/web/ui/components/CopyIcon.js +2 -1
  72. package/dist/esm/react/web/ui/components/CopyIcon.js.map +1 -1
  73. package/dist/esm/version.js +1 -1
  74. package/dist/esm/version.js.map +1 -1
  75. package/dist/esm/wallets/wallet-connect/controller.js +6 -6
  76. package/dist/esm/wallets/wallet-connect/controller.js.map +1 -1
  77. package/dist/types/exports/extensions/erc1155.d.ts +1 -0
  78. package/dist/types/exports/extensions/erc1155.d.ts.map +1 -1
  79. package/dist/types/extensions/erc1155/__generated__/BatchMintMetadata/events/BatchMetadataUpdate.d.ts +29 -0
  80. package/dist/types/extensions/erc1155/__generated__/BatchMintMetadata/events/BatchMetadataUpdate.d.ts.map +1 -0
  81. package/dist/types/extensions/erc1155/__generated__/BatchMintMetadata/read/getBaseURICount.d.ts +46 -0
  82. package/dist/types/extensions/erc1155/__generated__/BatchMintMetadata/read/getBaseURICount.d.ts.map +1 -0
  83. package/dist/types/extensions/erc1155/__generated__/BatchMintMetadata/read/getBatchIdAtIndex.d.ts +85 -0
  84. package/dist/types/extensions/erc1155/__generated__/BatchMintMetadata/read/getBatchIdAtIndex.d.ts.map +1 -0
  85. package/dist/types/extensions/erc1155/__generated__/DropERC1155/write/freezeBatchBaseURI.d.ts +80 -0
  86. package/dist/types/extensions/erc1155/__generated__/DropERC1155/write/freezeBatchBaseURI.d.ts.map +1 -0
  87. package/dist/types/extensions/erc1155/__generated__/DropERC1155/write/setMaxTotalSupply.d.ts +87 -0
  88. package/dist/types/extensions/erc1155/__generated__/DropERC1155/write/setMaxTotalSupply.d.ts.map +1 -0
  89. package/dist/types/extensions/erc1155/__generated__/DropERC1155/write/setSaleRecipientForToken.d.ts +87 -0
  90. package/dist/types/extensions/erc1155/__generated__/DropERC1155/write/setSaleRecipientForToken.d.ts.map +1 -0
  91. package/dist/types/extensions/erc1155/__generated__/DropERC1155/write/updateBatchBaseURI.d.ts +87 -0
  92. package/dist/types/extensions/erc1155/__generated__/DropERC1155/write/updateBatchBaseURI.d.ts.map +1 -0
  93. package/dist/types/extensions/erc1155/drops/write/updateMetadata.d.ts +37 -0
  94. package/dist/types/extensions/erc1155/drops/write/updateMetadata.d.ts.map +1 -0
  95. package/dist/types/pay/buyWithCrypto/getQuote.d.ts +6 -0
  96. package/dist/types/pay/buyWithCrypto/getQuote.d.ts.map +1 -1
  97. package/dist/types/pay/buyWithCrypto/getStatus.d.ts +1 -0
  98. package/dist/types/pay/buyWithCrypto/getStatus.d.ts.map +1 -1
  99. package/dist/types/pay/buyWithFiat/getQuote.d.ts +11 -1
  100. package/dist/types/pay/buyWithFiat/getQuote.d.ts.map +1 -1
  101. package/dist/types/pay/buyWithFiat/getStatus.d.ts +4 -0
  102. package/dist/types/pay/buyWithFiat/getStatus.d.ts.map +1 -1
  103. package/dist/types/react/core/hooks/transaction/useSendTransaction.d.ts +1 -0
  104. package/dist/types/react/core/hooks/transaction/useSendTransaction.d.ts.map +1 -1
  105. package/dist/types/react/native/hooks/wallets/useActiveWalletChain.d.ts +1 -1
  106. package/dist/types/react/web/hooks/transaction/useSendTransaction.d.ts.map +1 -1
  107. package/dist/types/react/web/hooks/wallets/useActiveWalletChain.d.ts +1 -1
  108. package/dist/types/react/web/ui/ConnectWallet/ConnectButtonProps.d.ts +44 -4
  109. package/dist/types/react/web/ui/ConnectWallet/ConnectButtonProps.d.ts.map +1 -1
  110. package/dist/types/react/web/ui/ConnectWallet/useConnectModal.d.ts +1 -1
  111. package/dist/types/react/web/ui/components/CopyIcon.d.ts.map +1 -1
  112. package/dist/types/version.d.ts +1 -1
  113. package/dist/types/version.d.ts.map +1 -1
  114. package/dist/types/wallets/wallet-connect/controller.d.ts.map +1 -1
  115. package/package.json +2 -2
  116. package/src/exports/extensions/erc1155.ts +5 -0
  117. package/src/extensions/erc1155/__generated__/BatchMintMetadata/events/BatchMetadataUpdate.ts +25 -0
  118. package/src/extensions/erc1155/__generated__/BatchMintMetadata/read/getBaseURICount.ts +74 -0
  119. package/src/extensions/erc1155/__generated__/BatchMintMetadata/read/getBatchIdAtIndex.ts +131 -0
  120. package/src/extensions/erc1155/__generated__/DropERC1155/write/freezeBatchBaseURI.ts +141 -0
  121. package/src/extensions/erc1155/__generated__/DropERC1155/write/setMaxTotalSupply.ts +155 -0
  122. package/src/extensions/erc1155/__generated__/DropERC1155/write/setSaleRecipientForToken.ts +157 -0
  123. package/src/extensions/erc1155/__generated__/DropERC1155/write/updateBatchBaseURI.ts +149 -0
  124. package/src/extensions/erc1155/drops/write/updateMetadata.test.ts +127 -0
  125. package/src/extensions/erc1155/drops/write/updateMetadata.ts +125 -0
  126. package/src/pay/buyWithCrypto/getQuote.ts +27 -27
  127. package/src/pay/buyWithCrypto/getStatus.ts +1 -0
  128. package/src/pay/buyWithFiat/getQuote.ts +33 -27
  129. package/src/pay/buyWithFiat/getStatus.ts +5 -0
  130. package/src/react/core/hooks/transaction/useSendTransaction.ts +1 -0
  131. package/src/react/native/hooks/wallets/useActiveWalletChain.ts +1 -1
  132. package/src/react/web/hooks/transaction/useSendTransaction.tsx +1 -0
  133. package/src/react/web/hooks/wallets/useActiveWalletChain.ts +1 -1
  134. package/src/react/web/ui/ConnectWallet/ConnectButtonProps.ts +45 -4
  135. package/src/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.tsx +3 -0
  136. package/src/react/web/ui/ConnectWallet/useConnectModal.tsx +1 -1
  137. package/src/react/web/ui/components/CopyIcon.tsx +5 -6
  138. package/src/version.ts +1 -1
  139. package/src/wallets/wallet-connect/controller.ts +6 -5
@@ -0,0 +1,74 @@
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 type { ThirdwebContract } from "../../../../../contract/contract.js";
7
+ import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
8
+
9
+ export const FN_SELECTOR = "0x63b45e2d" as const;
10
+ const FN_INPUTS = [] as const;
11
+ const FN_OUTPUTS = [
12
+ {
13
+ type: "uint256",
14
+ },
15
+ ] as const;
16
+
17
+ /**
18
+ * Checks if the `getBaseURICount` method is supported by the given contract.
19
+ * @param contract The ThirdwebContract.
20
+ * @returns A promise that resolves to a boolean indicating if the `getBaseURICount` method is supported.
21
+ * @extension ERC1155
22
+ * @example
23
+ * ```ts
24
+ * import { isGetBaseURICountSupported } from "thirdweb/extensions/erc1155";
25
+ *
26
+ * const supported = await isGetBaseURICountSupported(contract);
27
+ * ```
28
+ */
29
+ export async function isGetBaseURICountSupported(
30
+ contract: ThirdwebContract<any>,
31
+ ) {
32
+ return detectMethod({
33
+ contract,
34
+ method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
35
+ });
36
+ }
37
+
38
+ /**
39
+ * Decodes the result of the getBaseURICount function call.
40
+ * @param result - The hexadecimal result to decode.
41
+ * @returns The decoded result as per the FN_OUTPUTS definition.
42
+ * @extension ERC1155
43
+ * @example
44
+ * ```ts
45
+ * import { decodeGetBaseURICountResult } from "thirdweb/extensions/erc1155";
46
+ * const result = decodeGetBaseURICountResult("...");
47
+ * ```
48
+ */
49
+ export function decodeGetBaseURICountResult(result: Hex) {
50
+ return decodeAbiParameters(FN_OUTPUTS, result)[0];
51
+ }
52
+
53
+ /**
54
+ * Calls the "getBaseURICount" function on the contract.
55
+ * @param options - The options for the getBaseURICount function.
56
+ * @returns The parsed result of the function call.
57
+ * @extension ERC1155
58
+ * @example
59
+ * ```ts
60
+ * import { getBaseURICount } from "thirdweb/extensions/erc1155";
61
+ *
62
+ * const result = await getBaseURICount({
63
+ * contract,
64
+ * });
65
+ *
66
+ * ```
67
+ */
68
+ export async function getBaseURICount(options: BaseTransactionOptions) {
69
+ return readContract({
70
+ contract: options.contract,
71
+ method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
72
+ params: [],
73
+ });
74
+ }
@@ -0,0 +1,131 @@
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 type { ThirdwebContract } from "../../../../../contract/contract.js";
8
+ import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
9
+
10
+ /**
11
+ * Represents the parameters for the "getBatchIdAtIndex" function.
12
+ */
13
+ export type GetBatchIdAtIndexParams = {
14
+ index: AbiParameterToPrimitiveType<{ type: "uint256"; name: "_index" }>;
15
+ };
16
+
17
+ export const FN_SELECTOR = "0x2419f51b" as const;
18
+ const FN_INPUTS = [
19
+ {
20
+ type: "uint256",
21
+ name: "_index",
22
+ },
23
+ ] as const;
24
+ const FN_OUTPUTS = [
25
+ {
26
+ type: "uint256",
27
+ },
28
+ ] as const;
29
+
30
+ /**
31
+ * Checks if the `getBatchIdAtIndex` method is supported by the given contract.
32
+ * @param contract The ThirdwebContract.
33
+ * @returns A promise that resolves to a boolean indicating if the `getBatchIdAtIndex` method is supported.
34
+ * @extension ERC1155
35
+ * @example
36
+ * ```ts
37
+ * import { isGetBatchIdAtIndexSupported } from "thirdweb/extensions/erc1155";
38
+ *
39
+ * const supported = await isGetBatchIdAtIndexSupported(contract);
40
+ * ```
41
+ */
42
+ export async function isGetBatchIdAtIndexSupported(
43
+ contract: ThirdwebContract<any>,
44
+ ) {
45
+ return detectMethod({
46
+ contract,
47
+ method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
48
+ });
49
+ }
50
+
51
+ /**
52
+ * Encodes the parameters for the "getBatchIdAtIndex" function.
53
+ * @param options - The options for the getBatchIdAtIndex function.
54
+ * @returns The encoded ABI parameters.
55
+ * @extension ERC1155
56
+ * @example
57
+ * ```ts
58
+ * import { encodeGetBatchIdAtIndexParams } "thirdweb/extensions/erc1155";
59
+ * const result = encodeGetBatchIdAtIndexParams({
60
+ * index: ...,
61
+ * });
62
+ * ```
63
+ */
64
+ export function encodeGetBatchIdAtIndexParams(
65
+ options: GetBatchIdAtIndexParams,
66
+ ) {
67
+ return encodeAbiParameters(FN_INPUTS, [options.index]);
68
+ }
69
+
70
+ /**
71
+ * Encodes the "getBatchIdAtIndex" function into a Hex string with its parameters.
72
+ * @param options - The options for the getBatchIdAtIndex function.
73
+ * @returns The encoded hexadecimal string.
74
+ * @extension ERC1155
75
+ * @example
76
+ * ```ts
77
+ * import { encodeGetBatchIdAtIndex } "thirdweb/extensions/erc1155";
78
+ * const result = encodeGetBatchIdAtIndex({
79
+ * index: ...,
80
+ * });
81
+ * ```
82
+ */
83
+ export function encodeGetBatchIdAtIndex(options: GetBatchIdAtIndexParams) {
84
+ // we do a "manual" concat here to avoid the overhead of the "concatHex" function
85
+ // we can do this because we know the specific formats of the values
86
+ return (FN_SELECTOR +
87
+ encodeGetBatchIdAtIndexParams(options).slice(
88
+ 2,
89
+ )) as `${typeof FN_SELECTOR}${string}`;
90
+ }
91
+
92
+ /**
93
+ * Decodes the result of the getBatchIdAtIndex function call.
94
+ * @param result - The hexadecimal result to decode.
95
+ * @returns The decoded result as per the FN_OUTPUTS definition.
96
+ * @extension ERC1155
97
+ * @example
98
+ * ```ts
99
+ * import { decodeGetBatchIdAtIndexResult } from "thirdweb/extensions/erc1155";
100
+ * const result = decodeGetBatchIdAtIndexResult("...");
101
+ * ```
102
+ */
103
+ export function decodeGetBatchIdAtIndexResult(result: Hex) {
104
+ return decodeAbiParameters(FN_OUTPUTS, result)[0];
105
+ }
106
+
107
+ /**
108
+ * Calls the "getBatchIdAtIndex" function on the contract.
109
+ * @param options - The options for the getBatchIdAtIndex function.
110
+ * @returns The parsed result of the function call.
111
+ * @extension ERC1155
112
+ * @example
113
+ * ```ts
114
+ * import { getBatchIdAtIndex } from "thirdweb/extensions/erc1155";
115
+ *
116
+ * const result = await getBatchIdAtIndex({
117
+ * contract,
118
+ * index: ...,
119
+ * });
120
+ *
121
+ * ```
122
+ */
123
+ export async function getBatchIdAtIndex(
124
+ options: BaseTransactionOptions<GetBatchIdAtIndexParams>,
125
+ ) {
126
+ return readContract({
127
+ contract: options.contract,
128
+ method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
129
+ params: [options.index],
130
+ });
131
+ }
@@ -0,0 +1,141 @@
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 type { ThirdwebContract } from "../../../../../contract/contract.js";
10
+ import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
11
+
12
+ /**
13
+ * Represents the parameters for the "freezeBatchBaseURI" function.
14
+ */
15
+ export type FreezeBatchBaseURIParams = WithOverrides<{
16
+ index: AbiParameterToPrimitiveType<{ type: "uint256"; name: "_index" }>;
17
+ }>;
18
+
19
+ export const FN_SELECTOR = "0xa07ced9e" as const;
20
+ const FN_INPUTS = [
21
+ {
22
+ type: "uint256",
23
+ name: "_index",
24
+ },
25
+ ] as const;
26
+ const FN_OUTPUTS = [] as const;
27
+
28
+ /**
29
+ * Checks if the `freezeBatchBaseURI` method is supported by the given contract.
30
+ * @param contract The ThirdwebContract.
31
+ * @returns A promise that resolves to a boolean indicating if the `freezeBatchBaseURI` method is supported.
32
+ * @extension ERC1155
33
+ * @example
34
+ * ```ts
35
+ * import { isFreezeBatchBaseURISupported } from "thirdweb/extensions/erc1155";
36
+ *
37
+ * const supported = await isFreezeBatchBaseURISupported(contract);
38
+ * ```
39
+ */
40
+ export async function isFreezeBatchBaseURISupported(
41
+ contract: ThirdwebContract<any>,
42
+ ) {
43
+ return detectMethod({
44
+ contract,
45
+ method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
46
+ });
47
+ }
48
+
49
+ /**
50
+ * Encodes the parameters for the "freezeBatchBaseURI" function.
51
+ * @param options - The options for the freezeBatchBaseURI function.
52
+ * @returns The encoded ABI parameters.
53
+ * @extension ERC1155
54
+ * @example
55
+ * ```ts
56
+ * import { encodeFreezeBatchBaseURIParams } "thirdweb/extensions/erc1155";
57
+ * const result = encodeFreezeBatchBaseURIParams({
58
+ * index: ...,
59
+ * });
60
+ * ```
61
+ */
62
+ export function encodeFreezeBatchBaseURIParams(
63
+ options: FreezeBatchBaseURIParams,
64
+ ) {
65
+ return encodeAbiParameters(FN_INPUTS, [options.index]);
66
+ }
67
+
68
+ /**
69
+ * Encodes the "freezeBatchBaseURI" function into a Hex string with its parameters.
70
+ * @param options - The options for the freezeBatchBaseURI function.
71
+ * @returns The encoded hexadecimal string.
72
+ * @extension ERC1155
73
+ * @example
74
+ * ```ts
75
+ * import { encodeFreezeBatchBaseURI } "thirdweb/extensions/erc1155";
76
+ * const result = encodeFreezeBatchBaseURI({
77
+ * index: ...,
78
+ * });
79
+ * ```
80
+ */
81
+ export function encodeFreezeBatchBaseURI(options: FreezeBatchBaseURIParams) {
82
+ // we do a "manual" concat here to avoid the overhead of the "concatHex" function
83
+ // we can do this because we know the specific formats of the values
84
+ return (FN_SELECTOR +
85
+ encodeFreezeBatchBaseURIParams(options).slice(
86
+ 2,
87
+ )) as `${typeof FN_SELECTOR}${string}`;
88
+ }
89
+
90
+ /**
91
+ * Prepares a transaction to call the "freezeBatchBaseURI" function on the contract.
92
+ * @param options - The options for the "freezeBatchBaseURI" function.
93
+ * @returns A prepared transaction object.
94
+ * @extension ERC1155
95
+ * @example
96
+ * ```ts
97
+ * import { freezeBatchBaseURI } from "thirdweb/extensions/erc1155";
98
+ *
99
+ * const transaction = freezeBatchBaseURI({
100
+ * contract,
101
+ * index: ...,
102
+ * overrides: {
103
+ * ...
104
+ * }
105
+ * });
106
+ *
107
+ * // Send the transaction
108
+ * ...
109
+ *
110
+ * ```
111
+ */
112
+ export function freezeBatchBaseURI(
113
+ options: BaseTransactionOptions<
114
+ | FreezeBatchBaseURIParams
115
+ | {
116
+ asyncParams: () => Promise<FreezeBatchBaseURIParams>;
117
+ }
118
+ >,
119
+ ) {
120
+ const asyncOptions = once(async () => {
121
+ return "asyncParams" in options ? await options.asyncParams() : options;
122
+ });
123
+
124
+ return prepareContractCall({
125
+ contract: options.contract,
126
+ method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
127
+ params: async () => {
128
+ const resolvedOptions = await asyncOptions();
129
+ return [resolvedOptions.index] as const;
130
+ },
131
+ value: async () => (await asyncOptions()).overrides?.value,
132
+ accessList: async () => (await asyncOptions()).overrides?.accessList,
133
+ gas: async () => (await asyncOptions()).overrides?.gas,
134
+ gasPrice: async () => (await asyncOptions()).overrides?.gasPrice,
135
+ maxFeePerGas: async () => (await asyncOptions()).overrides?.maxFeePerGas,
136
+ maxPriorityFeePerGas: async () =>
137
+ (await asyncOptions()).overrides?.maxPriorityFeePerGas,
138
+ nonce: async () => (await asyncOptions()).overrides?.nonce,
139
+ extraGas: async () => (await asyncOptions()).overrides?.extraGas,
140
+ });
141
+ }
@@ -0,0 +1,155 @@
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 type { ThirdwebContract } from "../../../../../contract/contract.js";
10
+ import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
11
+
12
+ /**
13
+ * Represents the parameters for the "setMaxTotalSupply" function.
14
+ */
15
+ export type SetMaxTotalSupplyParams = WithOverrides<{
16
+ tokenId: AbiParameterToPrimitiveType<{ type: "uint256"; name: "_tokenId" }>;
17
+ maxTotalSupply: AbiParameterToPrimitiveType<{
18
+ type: "uint256";
19
+ name: "_maxTotalSupply";
20
+ }>;
21
+ }>;
22
+
23
+ export const FN_SELECTOR = "0x87198cf2" as const;
24
+ const FN_INPUTS = [
25
+ {
26
+ type: "uint256",
27
+ name: "_tokenId",
28
+ },
29
+ {
30
+ type: "uint256",
31
+ name: "_maxTotalSupply",
32
+ },
33
+ ] as const;
34
+ const FN_OUTPUTS = [] as const;
35
+
36
+ /**
37
+ * Checks if the `setMaxTotalSupply` method is supported by the given contract.
38
+ * @param contract The ThirdwebContract.
39
+ * @returns A promise that resolves to a boolean indicating if the `setMaxTotalSupply` method is supported.
40
+ * @extension ERC1155
41
+ * @example
42
+ * ```ts
43
+ * import { isSetMaxTotalSupplySupported } from "thirdweb/extensions/erc1155";
44
+ *
45
+ * const supported = await isSetMaxTotalSupplySupported(contract);
46
+ * ```
47
+ */
48
+ export async function isSetMaxTotalSupplySupported(
49
+ contract: ThirdwebContract<any>,
50
+ ) {
51
+ return detectMethod({
52
+ contract,
53
+ method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
54
+ });
55
+ }
56
+
57
+ /**
58
+ * Encodes the parameters for the "setMaxTotalSupply" function.
59
+ * @param options - The options for the setMaxTotalSupply function.
60
+ * @returns The encoded ABI parameters.
61
+ * @extension ERC1155
62
+ * @example
63
+ * ```ts
64
+ * import { encodeSetMaxTotalSupplyParams } "thirdweb/extensions/erc1155";
65
+ * const result = encodeSetMaxTotalSupplyParams({
66
+ * tokenId: ...,
67
+ * maxTotalSupply: ...,
68
+ * });
69
+ * ```
70
+ */
71
+ export function encodeSetMaxTotalSupplyParams(
72
+ options: SetMaxTotalSupplyParams,
73
+ ) {
74
+ return encodeAbiParameters(FN_INPUTS, [
75
+ options.tokenId,
76
+ options.maxTotalSupply,
77
+ ]);
78
+ }
79
+
80
+ /**
81
+ * Encodes the "setMaxTotalSupply" function into a Hex string with its parameters.
82
+ * @param options - The options for the setMaxTotalSupply function.
83
+ * @returns The encoded hexadecimal string.
84
+ * @extension ERC1155
85
+ * @example
86
+ * ```ts
87
+ * import { encodeSetMaxTotalSupply } "thirdweb/extensions/erc1155";
88
+ * const result = encodeSetMaxTotalSupply({
89
+ * tokenId: ...,
90
+ * maxTotalSupply: ...,
91
+ * });
92
+ * ```
93
+ */
94
+ export function encodeSetMaxTotalSupply(options: SetMaxTotalSupplyParams) {
95
+ // we do a "manual" concat here to avoid the overhead of the "concatHex" function
96
+ // we can do this because we know the specific formats of the values
97
+ return (FN_SELECTOR +
98
+ encodeSetMaxTotalSupplyParams(options).slice(
99
+ 2,
100
+ )) as `${typeof FN_SELECTOR}${string}`;
101
+ }
102
+
103
+ /**
104
+ * Prepares a transaction to call the "setMaxTotalSupply" function on the contract.
105
+ * @param options - The options for the "setMaxTotalSupply" function.
106
+ * @returns A prepared transaction object.
107
+ * @extension ERC1155
108
+ * @example
109
+ * ```ts
110
+ * import { setMaxTotalSupply } from "thirdweb/extensions/erc1155";
111
+ *
112
+ * const transaction = setMaxTotalSupply({
113
+ * contract,
114
+ * tokenId: ...,
115
+ * maxTotalSupply: ...,
116
+ * overrides: {
117
+ * ...
118
+ * }
119
+ * });
120
+ *
121
+ * // Send the transaction
122
+ * ...
123
+ *
124
+ * ```
125
+ */
126
+ export function setMaxTotalSupply(
127
+ options: BaseTransactionOptions<
128
+ | SetMaxTotalSupplyParams
129
+ | {
130
+ asyncParams: () => Promise<SetMaxTotalSupplyParams>;
131
+ }
132
+ >,
133
+ ) {
134
+ const asyncOptions = once(async () => {
135
+ return "asyncParams" in options ? await options.asyncParams() : options;
136
+ });
137
+
138
+ return prepareContractCall({
139
+ contract: options.contract,
140
+ method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
141
+ params: async () => {
142
+ const resolvedOptions = await asyncOptions();
143
+ return [resolvedOptions.tokenId, resolvedOptions.maxTotalSupply] as const;
144
+ },
145
+ value: async () => (await asyncOptions()).overrides?.value,
146
+ accessList: async () => (await asyncOptions()).overrides?.accessList,
147
+ gas: async () => (await asyncOptions()).overrides?.gas,
148
+ gasPrice: async () => (await asyncOptions()).overrides?.gasPrice,
149
+ maxFeePerGas: async () => (await asyncOptions()).overrides?.maxFeePerGas,
150
+ maxPriorityFeePerGas: async () =>
151
+ (await asyncOptions()).overrides?.maxPriorityFeePerGas,
152
+ nonce: async () => (await asyncOptions()).overrides?.nonce,
153
+ extraGas: async () => (await asyncOptions()).overrides?.extraGas,
154
+ });
155
+ }
@@ -0,0 +1,157 @@
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 type { ThirdwebContract } from "../../../../../contract/contract.js";
10
+ import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
11
+
12
+ /**
13
+ * Represents the parameters for the "setSaleRecipientForToken" function.
14
+ */
15
+ export type SetSaleRecipientForTokenParams = WithOverrides<{
16
+ tokenId: AbiParameterToPrimitiveType<{ type: "uint256"; name: "_tokenId" }>;
17
+ saleRecipient: AbiParameterToPrimitiveType<{
18
+ type: "address";
19
+ name: "_saleRecipient";
20
+ }>;
21
+ }>;
22
+
23
+ export const FN_SELECTOR = "0x29c49b9b" as const;
24
+ const FN_INPUTS = [
25
+ {
26
+ type: "uint256",
27
+ name: "_tokenId",
28
+ },
29
+ {
30
+ type: "address",
31
+ name: "_saleRecipient",
32
+ },
33
+ ] as const;
34
+ const FN_OUTPUTS = [] as const;
35
+
36
+ /**
37
+ * Checks if the `setSaleRecipientForToken` method is supported by the given contract.
38
+ * @param contract The ThirdwebContract.
39
+ * @returns A promise that resolves to a boolean indicating if the `setSaleRecipientForToken` method is supported.
40
+ * @extension ERC1155
41
+ * @example
42
+ * ```ts
43
+ * import { isSetSaleRecipientForTokenSupported } from "thirdweb/extensions/erc1155";
44
+ *
45
+ * const supported = await isSetSaleRecipientForTokenSupported(contract);
46
+ * ```
47
+ */
48
+ export async function isSetSaleRecipientForTokenSupported(
49
+ contract: ThirdwebContract<any>,
50
+ ) {
51
+ return detectMethod({
52
+ contract,
53
+ method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
54
+ });
55
+ }
56
+
57
+ /**
58
+ * Encodes the parameters for the "setSaleRecipientForToken" function.
59
+ * @param options - The options for the setSaleRecipientForToken function.
60
+ * @returns The encoded ABI parameters.
61
+ * @extension ERC1155
62
+ * @example
63
+ * ```ts
64
+ * import { encodeSetSaleRecipientForTokenParams } "thirdweb/extensions/erc1155";
65
+ * const result = encodeSetSaleRecipientForTokenParams({
66
+ * tokenId: ...,
67
+ * saleRecipient: ...,
68
+ * });
69
+ * ```
70
+ */
71
+ export function encodeSetSaleRecipientForTokenParams(
72
+ options: SetSaleRecipientForTokenParams,
73
+ ) {
74
+ return encodeAbiParameters(FN_INPUTS, [
75
+ options.tokenId,
76
+ options.saleRecipient,
77
+ ]);
78
+ }
79
+
80
+ /**
81
+ * Encodes the "setSaleRecipientForToken" function into a Hex string with its parameters.
82
+ * @param options - The options for the setSaleRecipientForToken function.
83
+ * @returns The encoded hexadecimal string.
84
+ * @extension ERC1155
85
+ * @example
86
+ * ```ts
87
+ * import { encodeSetSaleRecipientForToken } "thirdweb/extensions/erc1155";
88
+ * const result = encodeSetSaleRecipientForToken({
89
+ * tokenId: ...,
90
+ * saleRecipient: ...,
91
+ * });
92
+ * ```
93
+ */
94
+ export function encodeSetSaleRecipientForToken(
95
+ options: SetSaleRecipientForTokenParams,
96
+ ) {
97
+ // we do a "manual" concat here to avoid the overhead of the "concatHex" function
98
+ // we can do this because we know the specific formats of the values
99
+ return (FN_SELECTOR +
100
+ encodeSetSaleRecipientForTokenParams(options).slice(
101
+ 2,
102
+ )) as `${typeof FN_SELECTOR}${string}`;
103
+ }
104
+
105
+ /**
106
+ * Prepares a transaction to call the "setSaleRecipientForToken" function on the contract.
107
+ * @param options - The options for the "setSaleRecipientForToken" function.
108
+ * @returns A prepared transaction object.
109
+ * @extension ERC1155
110
+ * @example
111
+ * ```ts
112
+ * import { setSaleRecipientForToken } from "thirdweb/extensions/erc1155";
113
+ *
114
+ * const transaction = setSaleRecipientForToken({
115
+ * contract,
116
+ * tokenId: ...,
117
+ * saleRecipient: ...,
118
+ * overrides: {
119
+ * ...
120
+ * }
121
+ * });
122
+ *
123
+ * // Send the transaction
124
+ * ...
125
+ *
126
+ * ```
127
+ */
128
+ export function setSaleRecipientForToken(
129
+ options: BaseTransactionOptions<
130
+ | SetSaleRecipientForTokenParams
131
+ | {
132
+ asyncParams: () => Promise<SetSaleRecipientForTokenParams>;
133
+ }
134
+ >,
135
+ ) {
136
+ const asyncOptions = once(async () => {
137
+ return "asyncParams" in options ? await options.asyncParams() : options;
138
+ });
139
+
140
+ return prepareContractCall({
141
+ contract: options.contract,
142
+ method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
143
+ params: async () => {
144
+ const resolvedOptions = await asyncOptions();
145
+ return [resolvedOptions.tokenId, resolvedOptions.saleRecipient] as const;
146
+ },
147
+ value: async () => (await asyncOptions()).overrides?.value,
148
+ accessList: async () => (await asyncOptions()).overrides?.accessList,
149
+ gas: async () => (await asyncOptions()).overrides?.gas,
150
+ gasPrice: async () => (await asyncOptions()).overrides?.gasPrice,
151
+ maxFeePerGas: async () => (await asyncOptions()).overrides?.maxFeePerGas,
152
+ maxPriorityFeePerGas: async () =>
153
+ (await asyncOptions()).overrides?.maxPriorityFeePerGas,
154
+ nonce: async () => (await asyncOptions()).overrides?.nonce,
155
+ extraGas: async () => (await asyncOptions()).overrides?.extraGas,
156
+ });
157
+ }