thirdweb 5.59.2 → 5.60.0-nightly-8b681729a105bf0ba13be166937bae7914813a2e-20240930000338

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 (191) hide show
  1. package/dist/cjs/exports/deploys.js +3 -1
  2. package/dist/cjs/exports/deploys.js.map +1 -1
  3. package/dist/cjs/exports/extensions/pack.js +24 -0
  4. package/dist/cjs/exports/extensions/pack.js.map +1 -0
  5. package/dist/cjs/extensions/pack/__generated__/IPack/events/PackCreated.js +31 -0
  6. package/dist/cjs/extensions/pack/__generated__/IPack/events/PackCreated.js.map +1 -0
  7. package/dist/cjs/extensions/pack/__generated__/IPack/events/PackOpened.js +32 -0
  8. package/dist/cjs/extensions/pack/__generated__/IPack/events/PackOpened.js.map +1 -0
  9. package/dist/cjs/extensions/pack/__generated__/IPack/events/PackUpdated.js +31 -0
  10. package/dist/cjs/extensions/pack/__generated__/IPack/events/PackUpdated.js.map +1 -0
  11. package/dist/cjs/extensions/pack/__generated__/IPack/read/canUpdatePack.js +114 -0
  12. package/dist/cjs/extensions/pack/__generated__/IPack/read/canUpdatePack.js.map +1 -0
  13. package/dist/cjs/extensions/pack/__generated__/IPack/read/getPackContents.js +137 -0
  14. package/dist/cjs/extensions/pack/__generated__/IPack/read/getPackContents.js.map +1 -0
  15. package/dist/cjs/extensions/pack/__generated__/IPack/read/getTokenCountOfBundle.js +114 -0
  16. package/dist/cjs/extensions/pack/__generated__/IPack/read/getTokenCountOfBundle.js.map +1 -0
  17. package/dist/cjs/extensions/pack/__generated__/IPack/read/getTokenOfBundle.js +139 -0
  18. package/dist/cjs/extensions/pack/__generated__/IPack/read/getTokenOfBundle.js.map +1 -0
  19. package/dist/cjs/extensions/pack/__generated__/IPack/read/getUriOfBundle.js +114 -0
  20. package/dist/cjs/extensions/pack/__generated__/IPack/read/getUriOfBundle.js.map +1 -0
  21. package/dist/cjs/extensions/pack/__generated__/IPack/write/addPackContents.js +175 -0
  22. package/dist/cjs/extensions/pack/__generated__/IPack/write/addPackContents.js.map +1 -0
  23. package/dist/cjs/extensions/pack/__generated__/IPack/write/createPack.js +193 -0
  24. package/dist/cjs/extensions/pack/__generated__/IPack/write/createPack.js.map +1 -0
  25. package/dist/cjs/extensions/pack/__generated__/IPack/write/openPack.js +146 -0
  26. package/dist/cjs/extensions/pack/__generated__/IPack/write/openPack.js.map +1 -0
  27. package/dist/cjs/extensions/pack/__generated__/IPackVRFDirect/events/PackOpenRequested.js +32 -0
  28. package/dist/cjs/extensions/pack/__generated__/IPackVRFDirect/events/PackOpenRequested.js.map +1 -0
  29. package/dist/cjs/extensions/pack/__generated__/IPackVRFDirect/events/PackRandomnessFulfilled.js +32 -0
  30. package/dist/cjs/extensions/pack/__generated__/IPackVRFDirect/events/PackRandomnessFulfilled.js.map +1 -0
  31. package/dist/cjs/extensions/pack/__generated__/IPackVRFDirect/read/canClaimRewards.js +114 -0
  32. package/dist/cjs/extensions/pack/__generated__/IPackVRFDirect/read/canClaimRewards.js.map +1 -0
  33. package/dist/cjs/extensions/pack/__generated__/IPackVRFDirect/write/claimRewards.js +74 -0
  34. package/dist/cjs/extensions/pack/__generated__/IPackVRFDirect/write/claimRewards.js.map +1 -0
  35. package/dist/cjs/extensions/pack/__generated__/IPackVRFDirect/write/openPackAndClaimRewards.js +143 -0
  36. package/dist/cjs/extensions/pack/__generated__/IPackVRFDirect/write/openPackAndClaimRewards.js.map +1 -0
  37. package/dist/cjs/extensions/pack/createNewPack.js +285 -0
  38. package/dist/cjs/extensions/pack/createNewPack.js.map +1 -0
  39. package/dist/cjs/extensions/prebuilts/__generated__/Pack/write/initialize.js +175 -0
  40. package/dist/cjs/extensions/prebuilts/__generated__/Pack/write/initialize.js.map +1 -0
  41. package/dist/cjs/extensions/prebuilts/deploy-pack.js +115 -0
  42. package/dist/cjs/extensions/prebuilts/deploy-pack.js.map +1 -0
  43. package/dist/cjs/rpc/watchBlockNumber.js +2 -8
  44. package/dist/cjs/rpc/watchBlockNumber.js.map +1 -1
  45. package/dist/cjs/utils/sleep.js +12 -0
  46. package/dist/cjs/utils/sleep.js.map +1 -0
  47. package/dist/cjs/version.js +1 -1
  48. package/dist/cjs/version.js.map +1 -1
  49. package/dist/cjs/wallets/in-app/web/utils/iFrameCommunication/IframeCommunicator.js +4 -8
  50. package/dist/cjs/wallets/in-app/web/utils/iFrameCommunication/IframeCommunicator.js.map +1 -1
  51. package/dist/esm/exports/deploys.js +1 -0
  52. package/dist/esm/exports/deploys.js.map +1 -1
  53. package/dist/esm/exports/extensions/pack.js +12 -0
  54. package/dist/esm/exports/extensions/pack.js.map +1 -0
  55. package/dist/esm/extensions/pack/__generated__/IPack/events/PackCreated.js +28 -0
  56. package/dist/esm/extensions/pack/__generated__/IPack/events/PackCreated.js.map +1 -0
  57. package/dist/esm/extensions/pack/__generated__/IPack/events/PackOpened.js +29 -0
  58. package/dist/esm/extensions/pack/__generated__/IPack/events/PackOpened.js.map +1 -0
  59. package/dist/esm/extensions/pack/__generated__/IPack/events/PackUpdated.js +28 -0
  60. package/dist/esm/extensions/pack/__generated__/IPack/events/PackUpdated.js.map +1 -0
  61. package/dist/esm/extensions/pack/__generated__/IPack/read/canUpdatePack.js +106 -0
  62. package/dist/esm/extensions/pack/__generated__/IPack/read/canUpdatePack.js.map +1 -0
  63. package/dist/esm/extensions/pack/__generated__/IPack/read/getPackContents.js +129 -0
  64. package/dist/esm/extensions/pack/__generated__/IPack/read/getPackContents.js.map +1 -0
  65. package/dist/esm/extensions/pack/__generated__/IPack/read/getTokenCountOfBundle.js +106 -0
  66. package/dist/esm/extensions/pack/__generated__/IPack/read/getTokenCountOfBundle.js.map +1 -0
  67. package/dist/esm/extensions/pack/__generated__/IPack/read/getTokenOfBundle.js +131 -0
  68. package/dist/esm/extensions/pack/__generated__/IPack/read/getTokenOfBundle.js.map +1 -0
  69. package/dist/esm/extensions/pack/__generated__/IPack/read/getUriOfBundle.js +106 -0
  70. package/dist/esm/extensions/pack/__generated__/IPack/read/getUriOfBundle.js.map +1 -0
  71. package/dist/esm/extensions/pack/__generated__/IPack/write/addPackContents.js +168 -0
  72. package/dist/esm/extensions/pack/__generated__/IPack/write/addPackContents.js.map +1 -0
  73. package/dist/esm/extensions/pack/__generated__/IPack/write/createPack.js +186 -0
  74. package/dist/esm/extensions/pack/__generated__/IPack/write/createPack.js.map +1 -0
  75. package/dist/esm/extensions/pack/__generated__/IPack/write/openPack.js +139 -0
  76. package/dist/esm/extensions/pack/__generated__/IPack/write/openPack.js.map +1 -0
  77. package/dist/esm/extensions/pack/__generated__/IPackVRFDirect/events/PackOpenRequested.js +29 -0
  78. package/dist/esm/extensions/pack/__generated__/IPackVRFDirect/events/PackOpenRequested.js.map +1 -0
  79. package/dist/esm/extensions/pack/__generated__/IPackVRFDirect/events/PackRandomnessFulfilled.js +29 -0
  80. package/dist/esm/extensions/pack/__generated__/IPackVRFDirect/events/PackRandomnessFulfilled.js.map +1 -0
  81. package/dist/esm/extensions/pack/__generated__/IPackVRFDirect/read/canClaimRewards.js +106 -0
  82. package/dist/esm/extensions/pack/__generated__/IPackVRFDirect/read/canClaimRewards.js.map +1 -0
  83. package/dist/esm/extensions/pack/__generated__/IPackVRFDirect/write/claimRewards.js +69 -0
  84. package/dist/esm/extensions/pack/__generated__/IPackVRFDirect/write/claimRewards.js.map +1 -0
  85. package/dist/esm/extensions/pack/__generated__/IPackVRFDirect/write/openPackAndClaimRewards.js +136 -0
  86. package/dist/esm/extensions/pack/__generated__/IPackVRFDirect/write/openPackAndClaimRewards.js.map +1 -0
  87. package/dist/esm/extensions/pack/createNewPack.js +281 -0
  88. package/dist/esm/extensions/pack/createNewPack.js.map +1 -0
  89. package/dist/esm/extensions/prebuilts/__generated__/Pack/write/initialize.js +168 -0
  90. package/dist/esm/extensions/prebuilts/__generated__/Pack/write/initialize.js.map +1 -0
  91. package/dist/esm/extensions/prebuilts/deploy-pack.js +112 -0
  92. package/dist/esm/extensions/prebuilts/deploy-pack.js.map +1 -0
  93. package/dist/esm/rpc/watchBlockNumber.js +1 -7
  94. package/dist/esm/rpc/watchBlockNumber.js.map +1 -1
  95. package/dist/esm/utils/sleep.js +9 -0
  96. package/dist/esm/utils/sleep.js.map +1 -0
  97. package/dist/esm/version.js +1 -1
  98. package/dist/esm/version.js.map +1 -1
  99. package/dist/esm/wallets/in-app/web/utils/iFrameCommunication/IframeCommunicator.js +4 -8
  100. package/dist/esm/wallets/in-app/web/utils/iFrameCommunication/IframeCommunicator.js.map +1 -1
  101. package/dist/types/exports/deploys.d.ts +1 -0
  102. package/dist/types/exports/deploys.d.ts.map +1 -1
  103. package/dist/types/exports/extensions/pack.d.ts +9 -0
  104. package/dist/types/exports/extensions/pack.d.ts.map +1 -0
  105. package/dist/types/extensions/pack/__generated__/IPack/events/PackCreated.d.ts +47 -0
  106. package/dist/types/extensions/pack/__generated__/IPack/events/PackCreated.d.ts.map +1 -0
  107. package/dist/types/extensions/pack/__generated__/IPack/events/PackOpened.d.ts +70 -0
  108. package/dist/types/extensions/pack/__generated__/IPack/events/PackOpened.d.ts.map +1 -0
  109. package/dist/types/extensions/pack/__generated__/IPack/events/PackUpdated.d.ts +47 -0
  110. package/dist/types/extensions/pack/__generated__/IPack/events/PackUpdated.d.ts.map +1 -0
  111. package/dist/types/extensions/pack/__generated__/IPack/read/canUpdatePack.d.ts +83 -0
  112. package/dist/types/extensions/pack/__generated__/IPack/read/canUpdatePack.d.ts.map +1 -0
  113. package/dist/types/extensions/pack/__generated__/IPack/read/getPackContents.d.ts +93 -0
  114. package/dist/types/extensions/pack/__generated__/IPack/read/getPackContents.d.ts.map +1 -0
  115. package/dist/types/extensions/pack/__generated__/IPack/read/getTokenCountOfBundle.d.ts +83 -0
  116. package/dist/types/extensions/pack/__generated__/IPack/read/getTokenCountOfBundle.d.ts.map +1 -0
  117. package/dist/types/extensions/pack/__generated__/IPack/read/getTokenOfBundle.d.ts +100 -0
  118. package/dist/types/extensions/pack/__generated__/IPack/read/getTokenOfBundle.d.ts.map +1 -0
  119. package/dist/types/extensions/pack/__generated__/IPack/read/getUriOfBundle.d.ts +83 -0
  120. package/dist/types/extensions/pack/__generated__/IPack/read/getUriOfBundle.d.ts.map +1 -0
  121. package/dist/types/extensions/pack/__generated__/IPack/write/addPackContents.d.ts +118 -0
  122. package/dist/types/extensions/pack/__generated__/IPack/write/addPackContents.d.ts.map +1 -0
  123. package/dist/types/extensions/pack/__generated__/IPack/write/createPack.d.ts +132 -0
  124. package/dist/types/extensions/pack/__generated__/IPack/write/createPack.d.ts.map +1 -0
  125. package/dist/types/extensions/pack/__generated__/IPack/write/openPack.d.ts +86 -0
  126. package/dist/types/extensions/pack/__generated__/IPack/write/openPack.d.ts.map +1 -0
  127. package/dist/types/extensions/pack/__generated__/IPackVRFDirect/events/PackOpenRequested.d.ts +57 -0
  128. package/dist/types/extensions/pack/__generated__/IPackVRFDirect/events/PackOpenRequested.d.ts.map +1 -0
  129. package/dist/types/extensions/pack/__generated__/IPackVRFDirect/events/PackRandomnessFulfilled.d.ts +51 -0
  130. package/dist/types/extensions/pack/__generated__/IPackVRFDirect/events/PackRandomnessFulfilled.d.ts.map +1 -0
  131. package/dist/types/extensions/pack/__generated__/IPackVRFDirect/read/canClaimRewards.d.ts +83 -0
  132. package/dist/types/extensions/pack/__generated__/IPackVRFDirect/read/canClaimRewards.d.ts.map +1 -0
  133. package/dist/types/extensions/pack/__generated__/IPackVRFDirect/write/claimRewards.d.ts +33 -0
  134. package/dist/types/extensions/pack/__generated__/IPackVRFDirect/write/claimRewards.d.ts.map +1 -0
  135. package/dist/types/extensions/pack/__generated__/IPackVRFDirect/write/openPackAndClaimRewards.d.ts +93 -0
  136. package/dist/types/extensions/pack/__generated__/IPackVRFDirect/write/openPackAndClaimRewards.d.ts.map +1 -0
  137. package/dist/types/extensions/pack/createNewPack.d.ts +104 -0
  138. package/dist/types/extensions/pack/createNewPack.d.ts.map +1 -0
  139. package/dist/types/extensions/prebuilts/__generated__/Pack/write/initialize.d.ts +121 -0
  140. package/dist/types/extensions/prebuilts/__generated__/Pack/write/initialize.d.ts.map +1 -0
  141. package/dist/types/extensions/prebuilts/deploy-pack.d.ts +62 -0
  142. package/dist/types/extensions/prebuilts/deploy-pack.d.ts.map +1 -0
  143. package/dist/types/rpc/watchBlockNumber.d.ts.map +1 -1
  144. package/dist/types/utils/sleep.d.ts +7 -0
  145. package/dist/types/utils/sleep.d.ts.map +1 -0
  146. package/dist/types/version.d.ts +1 -1
  147. package/dist/types/version.d.ts.map +1 -1
  148. package/dist/types/wallets/in-app/web/utils/iFrameCommunication/IframeCommunicator.d.ts.map +1 -1
  149. package/package.json +1 -1
  150. package/src/exports/deploys.ts +6 -0
  151. package/src/exports/extensions/pack.ts +42 -0
  152. package/src/extensions/erc1155/drops/read/getActiveClaimCondition.test.ts +6 -4
  153. package/src/extensions/erc721/drops/write/updateMetadata.test.ts +2 -2
  154. package/src/extensions/erc721/read/getTotalClaimedSupply.test.ts +2 -2
  155. package/src/extensions/erc721/read/getTotalUnclaimedSupply.test.ts +2 -2
  156. package/src/extensions/erc721/write/updateTokenURI.test.ts +2 -2
  157. package/src/extensions/pack/__generated__/IPack/events/PackCreated.ts +41 -0
  158. package/src/extensions/pack/__generated__/IPack/events/PackOpened.ts +47 -0
  159. package/src/extensions/pack/__generated__/IPack/events/PackUpdated.ts +41 -0
  160. package/src/extensions/pack/__generated__/IPack/read/canUpdatePack.ts +125 -0
  161. package/src/extensions/pack/__generated__/IPack/read/getPackContents.ts +148 -0
  162. package/src/extensions/pack/__generated__/IPack/read/getTokenCountOfBundle.ts +129 -0
  163. package/src/extensions/pack/__generated__/IPack/read/getTokenOfBundle.ts +151 -0
  164. package/src/extensions/pack/__generated__/IPack/read/getUriOfBundle.ts +125 -0
  165. package/src/extensions/pack/__generated__/IPack/write/addPackContents.ts +213 -0
  166. package/src/extensions/pack/__generated__/IPack/write/createPack.ts +239 -0
  167. package/src/extensions/pack/__generated__/IPack/write/openPack.ts +168 -0
  168. package/src/extensions/pack/__generated__/IPackVRFDirect/events/PackOpenRequested.ts +49 -0
  169. package/src/extensions/pack/__generated__/IPackVRFDirect/events/PackRandomnessFulfilled.ts +49 -0
  170. package/src/extensions/pack/__generated__/IPackVRFDirect/read/canClaimRewards.ts +125 -0
  171. package/src/extensions/pack/__generated__/IPackVRFDirect/write/claimRewards.ts +73 -0
  172. package/src/extensions/pack/__generated__/IPackVRFDirect/write/openPackAndClaimRewards.ts +177 -0
  173. package/src/extensions/pack/createNewPack.test.ts +207 -0
  174. package/src/extensions/pack/createNewPack.ts +433 -0
  175. package/src/extensions/prebuilts/__generated__/Pack/write/initialize.ts +216 -0
  176. package/src/extensions/prebuilts/deploy-erc20.test.ts +5 -3
  177. package/src/extensions/prebuilts/deploy-erc721.test.ts +6 -4
  178. package/src/extensions/prebuilts/deploy-pack.test.ts +23 -0
  179. package/src/extensions/prebuilts/deploy-pack.ts +173 -0
  180. package/src/extensions/prebuilts/deploy-split.test.ts +2 -2
  181. package/src/extensions/prebuilts/deploy-vote.test.ts +7 -5
  182. package/src/extensions/split/read/getAllRecipientsAddresses.test.ts +2 -2
  183. package/src/extensions/split/read/getAllRecipientsPercentages.test.ts +2 -2
  184. package/src/extensions/split/read/getRecipientSplitPercentage.test.ts +4 -2
  185. package/src/extensions/vote/read/proposalExists.test.ts +6 -6
  186. package/src/rpc/watchBlockNumber.ts +1 -8
  187. package/src/utils/sleep.ts +8 -0
  188. package/src/version.ts +1 -1
  189. package/src/wallets/in-app/web/utils/iFrameCommunication/IframeCommunicator.ts +5 -9
  190. package/src/wallets/smart/smart-wallet-integration-v07.test.ts +11 -8
  191. package/src/wallets/utils/getTokenBalance.test.ts +8 -6
@@ -0,0 +1,41 @@
1
+ import { prepareEvent } from "../../../../../event/prepare-event.js";
2
+ import type { AbiParameterToPrimitiveType } from "abitype";
3
+
4
+ /**
5
+ * Represents the filters for the "PackCreated" event.
6
+ */
7
+ export type PackCreatedEventFilters = Partial<{
8
+ packId: AbiParameterToPrimitiveType<{
9
+ type: "uint256";
10
+ name: "packId";
11
+ indexed: true;
12
+ }>;
13
+ }>;
14
+
15
+ /**
16
+ * Creates an event object for the PackCreated event.
17
+ * @param filters - Optional filters to apply to the event.
18
+ * @returns The prepared event object.
19
+ * @extension PACK
20
+ * @example
21
+ * ```ts
22
+ * import { getContractEvents } from "thirdweb";
23
+ * import { packCreatedEvent } from "thirdweb/extensions/pack";
24
+ *
25
+ * const events = await getContractEvents({
26
+ * contract,
27
+ * events: [
28
+ * packCreatedEvent({
29
+ * packId: ...,
30
+ * })
31
+ * ],
32
+ * });
33
+ * ```
34
+ */
35
+ export function packCreatedEvent(filters: PackCreatedEventFilters = {}) {
36
+ return prepareEvent({
37
+ signature:
38
+ "event PackCreated(uint256 indexed packId, address recipient, uint256 totalPacksCreated)",
39
+ filters,
40
+ });
41
+ }
@@ -0,0 +1,47 @@
1
+ import { prepareEvent } from "../../../../../event/prepare-event.js";
2
+ import type { AbiParameterToPrimitiveType } from "abitype";
3
+
4
+ /**
5
+ * Represents the filters for the "PackOpened" event.
6
+ */
7
+ export type PackOpenedEventFilters = Partial<{
8
+ packId: AbiParameterToPrimitiveType<{
9
+ type: "uint256";
10
+ name: "packId";
11
+ indexed: true;
12
+ }>;
13
+ opener: AbiParameterToPrimitiveType<{
14
+ type: "address";
15
+ name: "opener";
16
+ indexed: true;
17
+ }>;
18
+ }>;
19
+
20
+ /**
21
+ * Creates an event object for the PackOpened event.
22
+ * @param filters - Optional filters to apply to the event.
23
+ * @returns The prepared event object.
24
+ * @extension PACK
25
+ * @example
26
+ * ```ts
27
+ * import { getContractEvents } from "thirdweb";
28
+ * import { packOpenedEvent } from "thirdweb/extensions/pack";
29
+ *
30
+ * const events = await getContractEvents({
31
+ * contract,
32
+ * events: [
33
+ * packOpenedEvent({
34
+ * packId: ...,
35
+ * opener: ...,
36
+ * })
37
+ * ],
38
+ * });
39
+ * ```
40
+ */
41
+ export function packOpenedEvent(filters: PackOpenedEventFilters = {}) {
42
+ return prepareEvent({
43
+ signature:
44
+ "event PackOpened(uint256 indexed packId, address indexed opener, uint256 numOfPacksOpened, (address assetContract, uint8 tokenType, uint256 tokenId, uint256 totalAmount)[] rewardUnitsDistributed)",
45
+ filters,
46
+ });
47
+ }
@@ -0,0 +1,41 @@
1
+ import { prepareEvent } from "../../../../../event/prepare-event.js";
2
+ import type { AbiParameterToPrimitiveType } from "abitype";
3
+
4
+ /**
5
+ * Represents the filters for the "PackUpdated" event.
6
+ */
7
+ export type PackUpdatedEventFilters = Partial<{
8
+ packId: AbiParameterToPrimitiveType<{
9
+ type: "uint256";
10
+ name: "packId";
11
+ indexed: true;
12
+ }>;
13
+ }>;
14
+
15
+ /**
16
+ * Creates an event object for the PackUpdated event.
17
+ * @param filters - Optional filters to apply to the event.
18
+ * @returns The prepared event object.
19
+ * @extension PACK
20
+ * @example
21
+ * ```ts
22
+ * import { getContractEvents } from "thirdweb";
23
+ * import { packUpdatedEvent } from "thirdweb/extensions/pack";
24
+ *
25
+ * const events = await getContractEvents({
26
+ * contract,
27
+ * events: [
28
+ * packUpdatedEvent({
29
+ * packId: ...,
30
+ * })
31
+ * ],
32
+ * });
33
+ * ```
34
+ */
35
+ export function packUpdatedEvent(filters: PackUpdatedEventFilters = {}) {
36
+ return prepareEvent({
37
+ signature:
38
+ "event PackUpdated(uint256 indexed packId, address recipient, uint256 totalPacksCreated)",
39
+ filters,
40
+ });
41
+ }
@@ -0,0 +1,125 @@
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 "canUpdatePack" function.
11
+ */
12
+ export type CanUpdatePackParams = {
13
+ key: AbiParameterToPrimitiveType<{ type: "uint256"; name: "_key" }>;
14
+ };
15
+
16
+ export const FN_SELECTOR = "0xb0381b08" as const;
17
+ const FN_INPUTS = [
18
+ {
19
+ type: "uint256",
20
+ name: "_key",
21
+ },
22
+ ] as const;
23
+ const FN_OUTPUTS = [
24
+ {
25
+ type: "bool",
26
+ },
27
+ ] as const;
28
+
29
+ /**
30
+ * Checks if the `canUpdatePack` 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 `canUpdatePack` method is supported.
33
+ * @extension PACK
34
+ * @example
35
+ * ```ts
36
+ * import { isCanUpdatePackSupported } from "thirdweb/extensions/pack";
37
+ * const supported = isCanUpdatePackSupported(["0x..."]);
38
+ * ```
39
+ */
40
+ export function isCanUpdatePackSupported(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 "canUpdatePack" function.
49
+ * @param options - The options for the canUpdatePack function.
50
+ * @returns The encoded ABI parameters.
51
+ * @extension PACK
52
+ * @example
53
+ * ```ts
54
+ * import { encodeCanUpdatePackParams } from "thirdweb/extensions/pack";
55
+ * const result = encodeCanUpdatePackParams({
56
+ * key: ...,
57
+ * });
58
+ * ```
59
+ */
60
+ export function encodeCanUpdatePackParams(options: CanUpdatePackParams) {
61
+ return encodeAbiParameters(FN_INPUTS, [options.key]);
62
+ }
63
+
64
+ /**
65
+ * Encodes the "canUpdatePack" function into a Hex string with its parameters.
66
+ * @param options - The options for the canUpdatePack function.
67
+ * @returns The encoded hexadecimal string.
68
+ * @extension PACK
69
+ * @example
70
+ * ```ts
71
+ * import { encodeCanUpdatePack } from "thirdweb/extensions/pack";
72
+ * const result = encodeCanUpdatePack({
73
+ * key: ...,
74
+ * });
75
+ * ```
76
+ */
77
+ export function encodeCanUpdatePack(options: CanUpdatePackParams) {
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
+ encodeCanUpdatePackParams(options).slice(
82
+ 2,
83
+ )) as `${typeof FN_SELECTOR}${string}`;
84
+ }
85
+
86
+ /**
87
+ * Decodes the result of the canUpdatePack function call.
88
+ * @param result - The hexadecimal result to decode.
89
+ * @returns The decoded result as per the FN_OUTPUTS definition.
90
+ * @extension PACK
91
+ * @example
92
+ * ```ts
93
+ * import { decodeCanUpdatePackResult } from "thirdweb/extensions/pack";
94
+ * const result = decodeCanUpdatePackResultResult("...");
95
+ * ```
96
+ */
97
+ export function decodeCanUpdatePackResult(result: Hex) {
98
+ return decodeAbiParameters(FN_OUTPUTS, result)[0];
99
+ }
100
+
101
+ /**
102
+ * Calls the "canUpdatePack" function on the contract.
103
+ * @param options - The options for the canUpdatePack function.
104
+ * @returns The parsed result of the function call.
105
+ * @extension PACK
106
+ * @example
107
+ * ```ts
108
+ * import { canUpdatePack } from "thirdweb/extensions/pack";
109
+ *
110
+ * const result = await canUpdatePack({
111
+ * contract,
112
+ * key: ...,
113
+ * });
114
+ *
115
+ * ```
116
+ */
117
+ export async function canUpdatePack(
118
+ options: BaseTransactionOptions<CanUpdatePackParams>,
119
+ ) {
120
+ return readContract({
121
+ contract: options.contract,
122
+ method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
123
+ params: [options.key],
124
+ });
125
+ }
@@ -0,0 +1,148 @@
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 "getPackContents" function.
11
+ */
12
+ export type GetPackContentsParams = {
13
+ packId: AbiParameterToPrimitiveType<{ type: "uint256"; name: "_packId" }>;
14
+ };
15
+
16
+ export const FN_SELECTOR = "0x8d4c446a" as const;
17
+ const FN_INPUTS = [
18
+ {
19
+ type: "uint256",
20
+ name: "_packId",
21
+ },
22
+ ] as const;
23
+ const FN_OUTPUTS = [
24
+ {
25
+ type: "tuple[]",
26
+ name: "contents",
27
+ components: [
28
+ {
29
+ type: "address",
30
+ name: "assetContract",
31
+ },
32
+ {
33
+ type: "uint8",
34
+ name: "tokenType",
35
+ },
36
+ {
37
+ type: "uint256",
38
+ name: "tokenId",
39
+ },
40
+ {
41
+ type: "uint256",
42
+ name: "totalAmount",
43
+ },
44
+ ],
45
+ },
46
+ {
47
+ type: "uint256[]",
48
+ name: "perUnitAmounts",
49
+ },
50
+ ] as const;
51
+
52
+ /**
53
+ * Checks if the `getPackContents` method is supported by the given contract.
54
+ * @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.
55
+ * @returns A boolean indicating if the `getPackContents` method is supported.
56
+ * @extension PACK
57
+ * @example
58
+ * ```ts
59
+ * import { isGetPackContentsSupported } from "thirdweb/extensions/pack";
60
+ * const supported = isGetPackContentsSupported(["0x..."]);
61
+ * ```
62
+ */
63
+ export function isGetPackContentsSupported(availableSelectors: string[]) {
64
+ return detectMethod({
65
+ availableSelectors,
66
+ method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
67
+ });
68
+ }
69
+
70
+ /**
71
+ * Encodes the parameters for the "getPackContents" function.
72
+ * @param options - The options for the getPackContents function.
73
+ * @returns The encoded ABI parameters.
74
+ * @extension PACK
75
+ * @example
76
+ * ```ts
77
+ * import { encodeGetPackContentsParams } from "thirdweb/extensions/pack";
78
+ * const result = encodeGetPackContentsParams({
79
+ * packId: ...,
80
+ * });
81
+ * ```
82
+ */
83
+ export function encodeGetPackContentsParams(options: GetPackContentsParams) {
84
+ return encodeAbiParameters(FN_INPUTS, [options.packId]);
85
+ }
86
+
87
+ /**
88
+ * Encodes the "getPackContents" function into a Hex string with its parameters.
89
+ * @param options - The options for the getPackContents function.
90
+ * @returns The encoded hexadecimal string.
91
+ * @extension PACK
92
+ * @example
93
+ * ```ts
94
+ * import { encodeGetPackContents } from "thirdweb/extensions/pack";
95
+ * const result = encodeGetPackContents({
96
+ * packId: ...,
97
+ * });
98
+ * ```
99
+ */
100
+ export function encodeGetPackContents(options: GetPackContentsParams) {
101
+ // we do a "manual" concat here to avoid the overhead of the "concatHex" function
102
+ // we can do this because we know the specific formats of the values
103
+ return (FN_SELECTOR +
104
+ encodeGetPackContentsParams(options).slice(
105
+ 2,
106
+ )) as `${typeof FN_SELECTOR}${string}`;
107
+ }
108
+
109
+ /**
110
+ * Decodes the result of the getPackContents function call.
111
+ * @param result - The hexadecimal result to decode.
112
+ * @returns The decoded result as per the FN_OUTPUTS definition.
113
+ * @extension PACK
114
+ * @example
115
+ * ```ts
116
+ * import { decodeGetPackContentsResult } from "thirdweb/extensions/pack";
117
+ * const result = decodeGetPackContentsResultResult("...");
118
+ * ```
119
+ */
120
+ export function decodeGetPackContentsResult(result: Hex) {
121
+ return decodeAbiParameters(FN_OUTPUTS, result);
122
+ }
123
+
124
+ /**
125
+ * Calls the "getPackContents" function on the contract.
126
+ * @param options - The options for the getPackContents function.
127
+ * @returns The parsed result of the function call.
128
+ * @extension PACK
129
+ * @example
130
+ * ```ts
131
+ * import { getPackContents } from "thirdweb/extensions/pack";
132
+ *
133
+ * const result = await getPackContents({
134
+ * contract,
135
+ * packId: ...,
136
+ * });
137
+ *
138
+ * ```
139
+ */
140
+ export async function getPackContents(
141
+ options: BaseTransactionOptions<GetPackContentsParams>,
142
+ ) {
143
+ return readContract({
144
+ contract: options.contract,
145
+ method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
146
+ params: [options.packId],
147
+ });
148
+ }
@@ -0,0 +1,129 @@
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 "getTokenCountOfBundle" function.
11
+ */
12
+ export type GetTokenCountOfBundleParams = {
13
+ bundleId: AbiParameterToPrimitiveType<{ type: "uint256"; name: "_bundleId" }>;
14
+ };
15
+
16
+ export const FN_SELECTOR = "0xd0d2fe25" as const;
17
+ const FN_INPUTS = [
18
+ {
19
+ type: "uint256",
20
+ name: "_bundleId",
21
+ },
22
+ ] as const;
23
+ const FN_OUTPUTS = [
24
+ {
25
+ type: "uint256",
26
+ },
27
+ ] as const;
28
+
29
+ /**
30
+ * Checks if the `getTokenCountOfBundle` 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 `getTokenCountOfBundle` method is supported.
33
+ * @extension PACK
34
+ * @example
35
+ * ```ts
36
+ * import { isGetTokenCountOfBundleSupported } from "thirdweb/extensions/pack";
37
+ * const supported = isGetTokenCountOfBundleSupported(["0x..."]);
38
+ * ```
39
+ */
40
+ export function isGetTokenCountOfBundleSupported(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 "getTokenCountOfBundle" function.
49
+ * @param options - The options for the getTokenCountOfBundle function.
50
+ * @returns The encoded ABI parameters.
51
+ * @extension PACK
52
+ * @example
53
+ * ```ts
54
+ * import { encodeGetTokenCountOfBundleParams } from "thirdweb/extensions/pack";
55
+ * const result = encodeGetTokenCountOfBundleParams({
56
+ * bundleId: ...,
57
+ * });
58
+ * ```
59
+ */
60
+ export function encodeGetTokenCountOfBundleParams(
61
+ options: GetTokenCountOfBundleParams,
62
+ ) {
63
+ return encodeAbiParameters(FN_INPUTS, [options.bundleId]);
64
+ }
65
+
66
+ /**
67
+ * Encodes the "getTokenCountOfBundle" function into a Hex string with its parameters.
68
+ * @param options - The options for the getTokenCountOfBundle function.
69
+ * @returns The encoded hexadecimal string.
70
+ * @extension PACK
71
+ * @example
72
+ * ```ts
73
+ * import { encodeGetTokenCountOfBundle } from "thirdweb/extensions/pack";
74
+ * const result = encodeGetTokenCountOfBundle({
75
+ * bundleId: ...,
76
+ * });
77
+ * ```
78
+ */
79
+ export function encodeGetTokenCountOfBundle(
80
+ options: GetTokenCountOfBundleParams,
81
+ ) {
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
+ encodeGetTokenCountOfBundleParams(options).slice(
86
+ 2,
87
+ )) as `${typeof FN_SELECTOR}${string}`;
88
+ }
89
+
90
+ /**
91
+ * Decodes the result of the getTokenCountOfBundle function call.
92
+ * @param result - The hexadecimal result to decode.
93
+ * @returns The decoded result as per the FN_OUTPUTS definition.
94
+ * @extension PACK
95
+ * @example
96
+ * ```ts
97
+ * import { decodeGetTokenCountOfBundleResult } from "thirdweb/extensions/pack";
98
+ * const result = decodeGetTokenCountOfBundleResultResult("...");
99
+ * ```
100
+ */
101
+ export function decodeGetTokenCountOfBundleResult(result: Hex) {
102
+ return decodeAbiParameters(FN_OUTPUTS, result)[0];
103
+ }
104
+
105
+ /**
106
+ * Calls the "getTokenCountOfBundle" function on the contract.
107
+ * @param options - The options for the getTokenCountOfBundle function.
108
+ * @returns The parsed result of the function call.
109
+ * @extension PACK
110
+ * @example
111
+ * ```ts
112
+ * import { getTokenCountOfBundle } from "thirdweb/extensions/pack";
113
+ *
114
+ * const result = await getTokenCountOfBundle({
115
+ * contract,
116
+ * bundleId: ...,
117
+ * });
118
+ *
119
+ * ```
120
+ */
121
+ export async function getTokenCountOfBundle(
122
+ options: BaseTransactionOptions<GetTokenCountOfBundleParams>,
123
+ ) {
124
+ return readContract({
125
+ contract: options.contract,
126
+ method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
127
+ params: [options.bundleId],
128
+ });
129
+ }
@@ -0,0 +1,151 @@
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 "getTokenOfBundle" function.
11
+ */
12
+ export type GetTokenOfBundleParams = {
13
+ bundleId: AbiParameterToPrimitiveType<{ type: "uint256"; name: "_bundleId" }>;
14
+ index: AbiParameterToPrimitiveType<{ type: "uint256"; name: "index" }>;
15
+ };
16
+
17
+ export const FN_SELECTOR = "0x1da799c9" as const;
18
+ const FN_INPUTS = [
19
+ {
20
+ type: "uint256",
21
+ name: "_bundleId",
22
+ },
23
+ {
24
+ type: "uint256",
25
+ name: "index",
26
+ },
27
+ ] as const;
28
+ const FN_OUTPUTS = [
29
+ {
30
+ type: "tuple",
31
+ components: [
32
+ {
33
+ type: "address",
34
+ name: "assetContract",
35
+ },
36
+ {
37
+ type: "uint8",
38
+ name: "tokenType",
39
+ },
40
+ {
41
+ type: "uint256",
42
+ name: "tokenId",
43
+ },
44
+ {
45
+ type: "uint256",
46
+ name: "totalAmount",
47
+ },
48
+ ],
49
+ },
50
+ ] as const;
51
+
52
+ /**
53
+ * Checks if the `getTokenOfBundle` method is supported by the given contract.
54
+ * @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.
55
+ * @returns A boolean indicating if the `getTokenOfBundle` method is supported.
56
+ * @extension PACK
57
+ * @example
58
+ * ```ts
59
+ * import { isGetTokenOfBundleSupported } from "thirdweb/extensions/pack";
60
+ * const supported = isGetTokenOfBundleSupported(["0x..."]);
61
+ * ```
62
+ */
63
+ export function isGetTokenOfBundleSupported(availableSelectors: string[]) {
64
+ return detectMethod({
65
+ availableSelectors,
66
+ method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
67
+ });
68
+ }
69
+
70
+ /**
71
+ * Encodes the parameters for the "getTokenOfBundle" function.
72
+ * @param options - The options for the getTokenOfBundle function.
73
+ * @returns The encoded ABI parameters.
74
+ * @extension PACK
75
+ * @example
76
+ * ```ts
77
+ * import { encodeGetTokenOfBundleParams } from "thirdweb/extensions/pack";
78
+ * const result = encodeGetTokenOfBundleParams({
79
+ * bundleId: ...,
80
+ * index: ...,
81
+ * });
82
+ * ```
83
+ */
84
+ export function encodeGetTokenOfBundleParams(options: GetTokenOfBundleParams) {
85
+ return encodeAbiParameters(FN_INPUTS, [options.bundleId, options.index]);
86
+ }
87
+
88
+ /**
89
+ * Encodes the "getTokenOfBundle" function into a Hex string with its parameters.
90
+ * @param options - The options for the getTokenOfBundle function.
91
+ * @returns The encoded hexadecimal string.
92
+ * @extension PACK
93
+ * @example
94
+ * ```ts
95
+ * import { encodeGetTokenOfBundle } from "thirdweb/extensions/pack";
96
+ * const result = encodeGetTokenOfBundle({
97
+ * bundleId: ...,
98
+ * index: ...,
99
+ * });
100
+ * ```
101
+ */
102
+ export function encodeGetTokenOfBundle(options: GetTokenOfBundleParams) {
103
+ // we do a "manual" concat here to avoid the overhead of the "concatHex" function
104
+ // we can do this because we know the specific formats of the values
105
+ return (FN_SELECTOR +
106
+ encodeGetTokenOfBundleParams(options).slice(
107
+ 2,
108
+ )) as `${typeof FN_SELECTOR}${string}`;
109
+ }
110
+
111
+ /**
112
+ * Decodes the result of the getTokenOfBundle function call.
113
+ * @param result - The hexadecimal result to decode.
114
+ * @returns The decoded result as per the FN_OUTPUTS definition.
115
+ * @extension PACK
116
+ * @example
117
+ * ```ts
118
+ * import { decodeGetTokenOfBundleResult } from "thirdweb/extensions/pack";
119
+ * const result = decodeGetTokenOfBundleResultResult("...");
120
+ * ```
121
+ */
122
+ export function decodeGetTokenOfBundleResult(result: Hex) {
123
+ return decodeAbiParameters(FN_OUTPUTS, result)[0];
124
+ }
125
+
126
+ /**
127
+ * Calls the "getTokenOfBundle" function on the contract.
128
+ * @param options - The options for the getTokenOfBundle function.
129
+ * @returns The parsed result of the function call.
130
+ * @extension PACK
131
+ * @example
132
+ * ```ts
133
+ * import { getTokenOfBundle } from "thirdweb/extensions/pack";
134
+ *
135
+ * const result = await getTokenOfBundle({
136
+ * contract,
137
+ * bundleId: ...,
138
+ * index: ...,
139
+ * });
140
+ *
141
+ * ```
142
+ */
143
+ export async function getTokenOfBundle(
144
+ options: BaseTransactionOptions<GetTokenOfBundleParams>,
145
+ ) {
146
+ return readContract({
147
+ contract: options.contract,
148
+ method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
149
+ params: [options.bundleId, options.index],
150
+ });
151
+ }