thirdweb 5.59.1 → 5.60.0-nightly-6c26012a71d884f99dd5d8c914b3879037b36d56-20240929000339
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/exports/deploys.js +3 -1
- package/dist/cjs/exports/deploys.js.map +1 -1
- package/dist/cjs/exports/extensions/pack.js +24 -0
- package/dist/cjs/exports/extensions/pack.js.map +1 -0
- package/dist/cjs/extensions/pack/__generated__/IPack/events/PackCreated.js +31 -0
- package/dist/cjs/extensions/pack/__generated__/IPack/events/PackCreated.js.map +1 -0
- package/dist/cjs/extensions/pack/__generated__/IPack/events/PackOpened.js +32 -0
- package/dist/cjs/extensions/pack/__generated__/IPack/events/PackOpened.js.map +1 -0
- package/dist/cjs/extensions/pack/__generated__/IPack/events/PackUpdated.js +31 -0
- package/dist/cjs/extensions/pack/__generated__/IPack/events/PackUpdated.js.map +1 -0
- package/dist/cjs/extensions/pack/__generated__/IPack/read/canUpdatePack.js +114 -0
- package/dist/cjs/extensions/pack/__generated__/IPack/read/canUpdatePack.js.map +1 -0
- package/dist/cjs/extensions/pack/__generated__/IPack/read/getPackContents.js +137 -0
- package/dist/cjs/extensions/pack/__generated__/IPack/read/getPackContents.js.map +1 -0
- package/dist/cjs/extensions/pack/__generated__/IPack/read/getTokenCountOfBundle.js +114 -0
- package/dist/cjs/extensions/pack/__generated__/IPack/read/getTokenCountOfBundle.js.map +1 -0
- package/dist/cjs/extensions/pack/__generated__/IPack/read/getTokenOfBundle.js +139 -0
- package/dist/cjs/extensions/pack/__generated__/IPack/read/getTokenOfBundle.js.map +1 -0
- package/dist/cjs/extensions/pack/__generated__/IPack/read/getUriOfBundle.js +114 -0
- package/dist/cjs/extensions/pack/__generated__/IPack/read/getUriOfBundle.js.map +1 -0
- package/dist/cjs/extensions/pack/__generated__/IPack/write/addPackContents.js +175 -0
- package/dist/cjs/extensions/pack/__generated__/IPack/write/addPackContents.js.map +1 -0
- package/dist/cjs/extensions/pack/__generated__/IPack/write/createPack.js +193 -0
- package/dist/cjs/extensions/pack/__generated__/IPack/write/createPack.js.map +1 -0
- package/dist/cjs/extensions/pack/__generated__/IPack/write/openPack.js +146 -0
- package/dist/cjs/extensions/pack/__generated__/IPack/write/openPack.js.map +1 -0
- package/dist/cjs/extensions/pack/__generated__/IPackVRFDirect/events/PackOpenRequested.js +32 -0
- package/dist/cjs/extensions/pack/__generated__/IPackVRFDirect/events/PackOpenRequested.js.map +1 -0
- package/dist/cjs/extensions/pack/__generated__/IPackVRFDirect/events/PackRandomnessFulfilled.js +32 -0
- package/dist/cjs/extensions/pack/__generated__/IPackVRFDirect/events/PackRandomnessFulfilled.js.map +1 -0
- package/dist/cjs/extensions/pack/__generated__/IPackVRFDirect/read/canClaimRewards.js +114 -0
- package/dist/cjs/extensions/pack/__generated__/IPackVRFDirect/read/canClaimRewards.js.map +1 -0
- package/dist/cjs/extensions/pack/__generated__/IPackVRFDirect/write/claimRewards.js +74 -0
- package/dist/cjs/extensions/pack/__generated__/IPackVRFDirect/write/claimRewards.js.map +1 -0
- package/dist/cjs/extensions/pack/__generated__/IPackVRFDirect/write/openPackAndClaimRewards.js +143 -0
- package/dist/cjs/extensions/pack/__generated__/IPackVRFDirect/write/openPackAndClaimRewards.js.map +1 -0
- package/dist/cjs/extensions/pack/createNewPack.js +285 -0
- package/dist/cjs/extensions/pack/createNewPack.js.map +1 -0
- package/dist/cjs/extensions/prebuilts/__generated__/Pack/write/initialize.js +175 -0
- package/dist/cjs/extensions/prebuilts/__generated__/Pack/write/initialize.js.map +1 -0
- package/dist/cjs/extensions/prebuilts/deploy-pack.js +115 -0
- package/dist/cjs/extensions/prebuilts/deploy-pack.js.map +1 -0
- package/dist/cjs/rpc/watchBlockNumber.js +2 -8
- package/dist/cjs/rpc/watchBlockNumber.js.map +1 -1
- package/dist/cjs/utils/sleep.js +12 -0
- package/dist/cjs/utils/sleep.js.map +1 -0
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/cjs/wallets/in-app/web/utils/iFrameCommunication/IframeCommunicator.js +4 -8
- package/dist/cjs/wallets/in-app/web/utils/iFrameCommunication/IframeCommunicator.js.map +1 -1
- package/dist/cjs/wallets/smart/lib/userop.js +2 -0
- package/dist/cjs/wallets/smart/lib/userop.js.map +1 -1
- package/dist/cjs/wallets/wallet-connect/controller.js +9 -9
- package/dist/cjs/wallets/wallet-connect/controller.js.map +1 -1
- package/dist/esm/exports/deploys.js +1 -0
- package/dist/esm/exports/deploys.js.map +1 -1
- package/dist/esm/exports/extensions/pack.js +12 -0
- package/dist/esm/exports/extensions/pack.js.map +1 -0
- package/dist/esm/extensions/pack/__generated__/IPack/events/PackCreated.js +28 -0
- package/dist/esm/extensions/pack/__generated__/IPack/events/PackCreated.js.map +1 -0
- package/dist/esm/extensions/pack/__generated__/IPack/events/PackOpened.js +29 -0
- package/dist/esm/extensions/pack/__generated__/IPack/events/PackOpened.js.map +1 -0
- package/dist/esm/extensions/pack/__generated__/IPack/events/PackUpdated.js +28 -0
- package/dist/esm/extensions/pack/__generated__/IPack/events/PackUpdated.js.map +1 -0
- package/dist/esm/extensions/pack/__generated__/IPack/read/canUpdatePack.js +106 -0
- package/dist/esm/extensions/pack/__generated__/IPack/read/canUpdatePack.js.map +1 -0
- package/dist/esm/extensions/pack/__generated__/IPack/read/getPackContents.js +129 -0
- package/dist/esm/extensions/pack/__generated__/IPack/read/getPackContents.js.map +1 -0
- package/dist/esm/extensions/pack/__generated__/IPack/read/getTokenCountOfBundle.js +106 -0
- package/dist/esm/extensions/pack/__generated__/IPack/read/getTokenCountOfBundle.js.map +1 -0
- package/dist/esm/extensions/pack/__generated__/IPack/read/getTokenOfBundle.js +131 -0
- package/dist/esm/extensions/pack/__generated__/IPack/read/getTokenOfBundle.js.map +1 -0
- package/dist/esm/extensions/pack/__generated__/IPack/read/getUriOfBundle.js +106 -0
- package/dist/esm/extensions/pack/__generated__/IPack/read/getUriOfBundle.js.map +1 -0
- package/dist/esm/extensions/pack/__generated__/IPack/write/addPackContents.js +168 -0
- package/dist/esm/extensions/pack/__generated__/IPack/write/addPackContents.js.map +1 -0
- package/dist/esm/extensions/pack/__generated__/IPack/write/createPack.js +186 -0
- package/dist/esm/extensions/pack/__generated__/IPack/write/createPack.js.map +1 -0
- package/dist/esm/extensions/pack/__generated__/IPack/write/openPack.js +139 -0
- package/dist/esm/extensions/pack/__generated__/IPack/write/openPack.js.map +1 -0
- package/dist/esm/extensions/pack/__generated__/IPackVRFDirect/events/PackOpenRequested.js +29 -0
- package/dist/esm/extensions/pack/__generated__/IPackVRFDirect/events/PackOpenRequested.js.map +1 -0
- package/dist/esm/extensions/pack/__generated__/IPackVRFDirect/events/PackRandomnessFulfilled.js +29 -0
- package/dist/esm/extensions/pack/__generated__/IPackVRFDirect/events/PackRandomnessFulfilled.js.map +1 -0
- package/dist/esm/extensions/pack/__generated__/IPackVRFDirect/read/canClaimRewards.js +106 -0
- package/dist/esm/extensions/pack/__generated__/IPackVRFDirect/read/canClaimRewards.js.map +1 -0
- package/dist/esm/extensions/pack/__generated__/IPackVRFDirect/write/claimRewards.js +69 -0
- package/dist/esm/extensions/pack/__generated__/IPackVRFDirect/write/claimRewards.js.map +1 -0
- package/dist/esm/extensions/pack/__generated__/IPackVRFDirect/write/openPackAndClaimRewards.js +136 -0
- package/dist/esm/extensions/pack/__generated__/IPackVRFDirect/write/openPackAndClaimRewards.js.map +1 -0
- package/dist/esm/extensions/pack/createNewPack.js +281 -0
- package/dist/esm/extensions/pack/createNewPack.js.map +1 -0
- package/dist/esm/extensions/prebuilts/__generated__/Pack/write/initialize.js +168 -0
- package/dist/esm/extensions/prebuilts/__generated__/Pack/write/initialize.js.map +1 -0
- package/dist/esm/extensions/prebuilts/deploy-pack.js +112 -0
- package/dist/esm/extensions/prebuilts/deploy-pack.js.map +1 -0
- package/dist/esm/rpc/watchBlockNumber.js +1 -7
- package/dist/esm/rpc/watchBlockNumber.js.map +1 -1
- package/dist/esm/utils/sleep.js +9 -0
- package/dist/esm/utils/sleep.js.map +1 -0
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/esm/wallets/in-app/web/utils/iFrameCommunication/IframeCommunicator.js +4 -8
- package/dist/esm/wallets/in-app/web/utils/iFrameCommunication/IframeCommunicator.js.map +1 -1
- package/dist/esm/wallets/smart/lib/userop.js +2 -0
- package/dist/esm/wallets/smart/lib/userop.js.map +1 -1
- package/dist/esm/wallets/wallet-connect/controller.js +9 -9
- package/dist/esm/wallets/wallet-connect/controller.js.map +1 -1
- package/dist/types/exports/deploys.d.ts +1 -0
- package/dist/types/exports/deploys.d.ts.map +1 -1
- package/dist/types/exports/extensions/pack.d.ts +9 -0
- package/dist/types/exports/extensions/pack.d.ts.map +1 -0
- package/dist/types/extensions/pack/__generated__/IPack/events/PackCreated.d.ts +47 -0
- package/dist/types/extensions/pack/__generated__/IPack/events/PackCreated.d.ts.map +1 -0
- package/dist/types/extensions/pack/__generated__/IPack/events/PackOpened.d.ts +70 -0
- package/dist/types/extensions/pack/__generated__/IPack/events/PackOpened.d.ts.map +1 -0
- package/dist/types/extensions/pack/__generated__/IPack/events/PackUpdated.d.ts +47 -0
- package/dist/types/extensions/pack/__generated__/IPack/events/PackUpdated.d.ts.map +1 -0
- package/dist/types/extensions/pack/__generated__/IPack/read/canUpdatePack.d.ts +83 -0
- package/dist/types/extensions/pack/__generated__/IPack/read/canUpdatePack.d.ts.map +1 -0
- package/dist/types/extensions/pack/__generated__/IPack/read/getPackContents.d.ts +93 -0
- package/dist/types/extensions/pack/__generated__/IPack/read/getPackContents.d.ts.map +1 -0
- package/dist/types/extensions/pack/__generated__/IPack/read/getTokenCountOfBundle.d.ts +83 -0
- package/dist/types/extensions/pack/__generated__/IPack/read/getTokenCountOfBundle.d.ts.map +1 -0
- package/dist/types/extensions/pack/__generated__/IPack/read/getTokenOfBundle.d.ts +100 -0
- package/dist/types/extensions/pack/__generated__/IPack/read/getTokenOfBundle.d.ts.map +1 -0
- package/dist/types/extensions/pack/__generated__/IPack/read/getUriOfBundle.d.ts +83 -0
- package/dist/types/extensions/pack/__generated__/IPack/read/getUriOfBundle.d.ts.map +1 -0
- package/dist/types/extensions/pack/__generated__/IPack/write/addPackContents.d.ts +118 -0
- package/dist/types/extensions/pack/__generated__/IPack/write/addPackContents.d.ts.map +1 -0
- package/dist/types/extensions/pack/__generated__/IPack/write/createPack.d.ts +132 -0
- package/dist/types/extensions/pack/__generated__/IPack/write/createPack.d.ts.map +1 -0
- package/dist/types/extensions/pack/__generated__/IPack/write/openPack.d.ts +86 -0
- package/dist/types/extensions/pack/__generated__/IPack/write/openPack.d.ts.map +1 -0
- package/dist/types/extensions/pack/__generated__/IPackVRFDirect/events/PackOpenRequested.d.ts +57 -0
- package/dist/types/extensions/pack/__generated__/IPackVRFDirect/events/PackOpenRequested.d.ts.map +1 -0
- package/dist/types/extensions/pack/__generated__/IPackVRFDirect/events/PackRandomnessFulfilled.d.ts +51 -0
- package/dist/types/extensions/pack/__generated__/IPackVRFDirect/events/PackRandomnessFulfilled.d.ts.map +1 -0
- package/dist/types/extensions/pack/__generated__/IPackVRFDirect/read/canClaimRewards.d.ts +83 -0
- package/dist/types/extensions/pack/__generated__/IPackVRFDirect/read/canClaimRewards.d.ts.map +1 -0
- package/dist/types/extensions/pack/__generated__/IPackVRFDirect/write/claimRewards.d.ts +33 -0
- package/dist/types/extensions/pack/__generated__/IPackVRFDirect/write/claimRewards.d.ts.map +1 -0
- package/dist/types/extensions/pack/__generated__/IPackVRFDirect/write/openPackAndClaimRewards.d.ts +93 -0
- package/dist/types/extensions/pack/__generated__/IPackVRFDirect/write/openPackAndClaimRewards.d.ts.map +1 -0
- package/dist/types/extensions/pack/createNewPack.d.ts +104 -0
- package/dist/types/extensions/pack/createNewPack.d.ts.map +1 -0
- package/dist/types/extensions/prebuilts/__generated__/Pack/write/initialize.d.ts +121 -0
- package/dist/types/extensions/prebuilts/__generated__/Pack/write/initialize.d.ts.map +1 -0
- package/dist/types/extensions/prebuilts/deploy-pack.d.ts +62 -0
- package/dist/types/extensions/prebuilts/deploy-pack.d.ts.map +1 -0
- package/dist/types/rpc/watchBlockNumber.d.ts.map +1 -1
- package/dist/types/utils/sleep.d.ts +7 -0
- package/dist/types/utils/sleep.d.ts.map +1 -0
- package/dist/types/version.d.ts +1 -1
- package/dist/types/version.d.ts.map +1 -1
- package/dist/types/wallets/in-app/web/utils/iFrameCommunication/IframeCommunicator.d.ts.map +1 -1
- package/dist/types/wallets/smart/lib/userop.d.ts.map +1 -1
- package/dist/types/wallets/wallet-connect/controller.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/exports/deploys.ts +6 -0
- package/src/exports/extensions/pack.ts +42 -0
- package/src/extensions/erc1155/drop1155.test.ts +2 -11
- package/src/extensions/erc1155/drops/read/getActiveClaimCondition.test.ts +6 -4
- package/src/extensions/erc1155/token1155.test.ts +2 -11
- package/src/extensions/erc20/drop20.test.ts +2 -11
- package/src/extensions/erc721/drop721.test.ts +3 -11
- package/src/extensions/erc721/drops/write/updateMetadata.test.ts +2 -2
- package/src/extensions/erc721/lazyMinting/write/createAndReveal.test.ts +2 -2
- package/src/extensions/erc721/read/getTotalClaimedSupply.test.ts +2 -2
- package/src/extensions/erc721/read/getTotalUnclaimedSupply.test.ts +2 -2
- package/src/extensions/erc721/write/mintTo.test.ts +2 -0
- package/src/extensions/erc721/write/updateTokenURI.test.ts +2 -2
- package/src/extensions/marketplace/english-auctions/english-auctions.test.ts +3 -0
- package/src/extensions/marketplace/offers/offers.test.ts +3 -0
- package/src/extensions/modules/ClaimableERC1155/claimableERC1155.test.ts +2 -1
- package/src/extensions/modules/ClaimableERC20/claimableERC20.test.ts +2 -1
- package/src/extensions/modules/ClaimableERC721/claimableERC721.test.ts +2 -1
- package/src/extensions/modules/MintableERC1155/mintableERC1155.test.ts +2 -0
- package/src/extensions/modules/MintableERC20/mintableERC20.test.ts +2 -0
- package/src/extensions/modules/MintableERC721/mintableERC721.test.ts +2 -0
- package/src/extensions/modules/OpenEditionMetadataERC721/openEditionERC721.test.ts +2 -0
- package/src/extensions/pack/__generated__/IPack/events/PackCreated.ts +41 -0
- package/src/extensions/pack/__generated__/IPack/events/PackOpened.ts +47 -0
- package/src/extensions/pack/__generated__/IPack/events/PackUpdated.ts +41 -0
- package/src/extensions/pack/__generated__/IPack/read/canUpdatePack.ts +125 -0
- package/src/extensions/pack/__generated__/IPack/read/getPackContents.ts +148 -0
- package/src/extensions/pack/__generated__/IPack/read/getTokenCountOfBundle.ts +129 -0
- package/src/extensions/pack/__generated__/IPack/read/getTokenOfBundle.ts +151 -0
- package/src/extensions/pack/__generated__/IPack/read/getUriOfBundle.ts +125 -0
- package/src/extensions/pack/__generated__/IPack/write/addPackContents.ts +213 -0
- package/src/extensions/pack/__generated__/IPack/write/createPack.ts +239 -0
- package/src/extensions/pack/__generated__/IPack/write/openPack.ts +168 -0
- package/src/extensions/pack/__generated__/IPackVRFDirect/events/PackOpenRequested.ts +49 -0
- package/src/extensions/pack/__generated__/IPackVRFDirect/events/PackRandomnessFulfilled.ts +49 -0
- package/src/extensions/pack/__generated__/IPackVRFDirect/read/canClaimRewards.ts +125 -0
- package/src/extensions/pack/__generated__/IPackVRFDirect/write/claimRewards.ts +73 -0
- package/src/extensions/pack/__generated__/IPackVRFDirect/write/openPackAndClaimRewards.ts +177 -0
- package/src/extensions/pack/createNewPack.test.ts +207 -0
- package/src/extensions/pack/createNewPack.ts +433 -0
- package/src/extensions/permissions/permissions.test.ts +3 -0
- package/src/extensions/prebuilts/__generated__/Pack/write/initialize.ts +216 -0
- package/src/extensions/prebuilts/deploy-erc20.test.ts +5 -3
- package/src/extensions/prebuilts/deploy-erc721.test.ts +6 -4
- package/src/extensions/prebuilts/deploy-pack.test.ts +23 -0
- package/src/extensions/prebuilts/deploy-pack.ts +173 -0
- package/src/extensions/prebuilts/deploy-split.test.ts +2 -2
- package/src/extensions/prebuilts/deploy-vote.test.ts +7 -5
- package/src/extensions/split/read/getAllRecipientsAddresses.test.ts +2 -2
- package/src/extensions/split/read/getAllRecipientsPercentages.test.ts +2 -2
- package/src/extensions/split/read/getRecipientSplitPercentage.test.ts +4 -2
- package/src/extensions/vote/read/proposalExists.test.ts +6 -6
- package/src/rpc/watchBlockNumber.ts +1 -8
- package/src/utils/sleep.ts +8 -0
- package/src/version.ts +1 -1
- package/src/wallets/in-app/web/utils/iFrameCommunication/IframeCommunicator.ts +5 -9
- package/src/wallets/smart/lib/userop.ts +2 -0
- package/src/wallets/smart/smart-wallet-integration-v07.test.ts +11 -8
- package/src/wallets/utils/getTokenBalance.test.ts +8 -6
- package/src/wallets/wallet-connect/controller.ts +23 -11
@@ -0,0 +1,239 @@
|
|
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 "createPack" function.
|
13
|
+
*/
|
14
|
+
export type CreatePackParams = WithOverrides<{
|
15
|
+
contents: AbiParameterToPrimitiveType<{
|
16
|
+
type: "tuple[]";
|
17
|
+
name: "contents";
|
18
|
+
components: [
|
19
|
+
{ type: "address"; name: "assetContract" },
|
20
|
+
{ type: "uint8"; name: "tokenType" },
|
21
|
+
{ type: "uint256"; name: "tokenId" },
|
22
|
+
{ type: "uint256"; name: "totalAmount" },
|
23
|
+
];
|
24
|
+
}>;
|
25
|
+
numOfRewardUnits: AbiParameterToPrimitiveType<{
|
26
|
+
type: "uint256[]";
|
27
|
+
name: "numOfRewardUnits";
|
28
|
+
}>;
|
29
|
+
packUri: AbiParameterToPrimitiveType<{ type: "string"; name: "packUri" }>;
|
30
|
+
openStartTimestamp: AbiParameterToPrimitiveType<{
|
31
|
+
type: "uint128";
|
32
|
+
name: "openStartTimestamp";
|
33
|
+
}>;
|
34
|
+
amountDistributedPerOpen: AbiParameterToPrimitiveType<{
|
35
|
+
type: "uint128";
|
36
|
+
name: "amountDistributedPerOpen";
|
37
|
+
}>;
|
38
|
+
recipient: AbiParameterToPrimitiveType<{
|
39
|
+
type: "address";
|
40
|
+
name: "recipient";
|
41
|
+
}>;
|
42
|
+
}>;
|
43
|
+
|
44
|
+
export const FN_SELECTOR = "0x092e6075" as const;
|
45
|
+
const FN_INPUTS = [
|
46
|
+
{
|
47
|
+
type: "tuple[]",
|
48
|
+
name: "contents",
|
49
|
+
components: [
|
50
|
+
{
|
51
|
+
type: "address",
|
52
|
+
name: "assetContract",
|
53
|
+
},
|
54
|
+
{
|
55
|
+
type: "uint8",
|
56
|
+
name: "tokenType",
|
57
|
+
},
|
58
|
+
{
|
59
|
+
type: "uint256",
|
60
|
+
name: "tokenId",
|
61
|
+
},
|
62
|
+
{
|
63
|
+
type: "uint256",
|
64
|
+
name: "totalAmount",
|
65
|
+
},
|
66
|
+
],
|
67
|
+
},
|
68
|
+
{
|
69
|
+
type: "uint256[]",
|
70
|
+
name: "numOfRewardUnits",
|
71
|
+
},
|
72
|
+
{
|
73
|
+
type: "string",
|
74
|
+
name: "packUri",
|
75
|
+
},
|
76
|
+
{
|
77
|
+
type: "uint128",
|
78
|
+
name: "openStartTimestamp",
|
79
|
+
},
|
80
|
+
{
|
81
|
+
type: "uint128",
|
82
|
+
name: "amountDistributedPerOpen",
|
83
|
+
},
|
84
|
+
{
|
85
|
+
type: "address",
|
86
|
+
name: "recipient",
|
87
|
+
},
|
88
|
+
] as const;
|
89
|
+
const FN_OUTPUTS = [
|
90
|
+
{
|
91
|
+
type: "uint256",
|
92
|
+
name: "packId",
|
93
|
+
},
|
94
|
+
{
|
95
|
+
type: "uint256",
|
96
|
+
name: "packTotalSupply",
|
97
|
+
},
|
98
|
+
] as const;
|
99
|
+
|
100
|
+
/**
|
101
|
+
* Checks if the `createPack` method is supported by the given contract.
|
102
|
+
* @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.
|
103
|
+
* @returns A boolean indicating if the `createPack` method is supported.
|
104
|
+
* @extension PACK
|
105
|
+
* @example
|
106
|
+
* ```ts
|
107
|
+
* import { isCreatePackSupported } from "thirdweb/extensions/pack";
|
108
|
+
*
|
109
|
+
* const supported = isCreatePackSupported(["0x..."]);
|
110
|
+
* ```
|
111
|
+
*/
|
112
|
+
export function isCreatePackSupported(availableSelectors: string[]) {
|
113
|
+
return detectMethod({
|
114
|
+
availableSelectors,
|
115
|
+
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
116
|
+
});
|
117
|
+
}
|
118
|
+
|
119
|
+
/**
|
120
|
+
* Encodes the parameters for the "createPack" function.
|
121
|
+
* @param options - The options for the createPack function.
|
122
|
+
* @returns The encoded ABI parameters.
|
123
|
+
* @extension PACK
|
124
|
+
* @example
|
125
|
+
* ```ts
|
126
|
+
* import { encodeCreatePackParams } from "thirdweb/extensions/pack";
|
127
|
+
* const result = encodeCreatePackParams({
|
128
|
+
* contents: ...,
|
129
|
+
* numOfRewardUnits: ...,
|
130
|
+
* packUri: ...,
|
131
|
+
* openStartTimestamp: ...,
|
132
|
+
* amountDistributedPerOpen: ...,
|
133
|
+
* recipient: ...,
|
134
|
+
* });
|
135
|
+
* ```
|
136
|
+
*/
|
137
|
+
export function encodeCreatePackParams(options: CreatePackParams) {
|
138
|
+
return encodeAbiParameters(FN_INPUTS, [
|
139
|
+
options.contents,
|
140
|
+
options.numOfRewardUnits,
|
141
|
+
options.packUri,
|
142
|
+
options.openStartTimestamp,
|
143
|
+
options.amountDistributedPerOpen,
|
144
|
+
options.recipient,
|
145
|
+
]);
|
146
|
+
}
|
147
|
+
|
148
|
+
/**
|
149
|
+
* Encodes the "createPack" function into a Hex string with its parameters.
|
150
|
+
* @param options - The options for the createPack function.
|
151
|
+
* @returns The encoded hexadecimal string.
|
152
|
+
* @extension PACK
|
153
|
+
* @example
|
154
|
+
* ```ts
|
155
|
+
* import { encodeCreatePack } from "thirdweb/extensions/pack";
|
156
|
+
* const result = encodeCreatePack({
|
157
|
+
* contents: ...,
|
158
|
+
* numOfRewardUnits: ...,
|
159
|
+
* packUri: ...,
|
160
|
+
* openStartTimestamp: ...,
|
161
|
+
* amountDistributedPerOpen: ...,
|
162
|
+
* recipient: ...,
|
163
|
+
* });
|
164
|
+
* ```
|
165
|
+
*/
|
166
|
+
export function encodeCreatePack(options: CreatePackParams) {
|
167
|
+
// we do a "manual" concat here to avoid the overhead of the "concatHex" function
|
168
|
+
// we can do this because we know the specific formats of the values
|
169
|
+
return (FN_SELECTOR +
|
170
|
+
encodeCreatePackParams(options).slice(
|
171
|
+
2,
|
172
|
+
)) as `${typeof FN_SELECTOR}${string}`;
|
173
|
+
}
|
174
|
+
|
175
|
+
/**
|
176
|
+
* Prepares a transaction to call the "createPack" function on the contract.
|
177
|
+
* @param options - The options for the "createPack" function.
|
178
|
+
* @returns A prepared transaction object.
|
179
|
+
* @extension PACK
|
180
|
+
* @example
|
181
|
+
* ```ts
|
182
|
+
* import { sendTransaction } from "thirdweb";
|
183
|
+
* import { createPack } from "thirdweb/extensions/pack";
|
184
|
+
*
|
185
|
+
* const transaction = createPack({
|
186
|
+
* contract,
|
187
|
+
* contents: ...,
|
188
|
+
* numOfRewardUnits: ...,
|
189
|
+
* packUri: ...,
|
190
|
+
* openStartTimestamp: ...,
|
191
|
+
* amountDistributedPerOpen: ...,
|
192
|
+
* recipient: ...,
|
193
|
+
* overrides: {
|
194
|
+
* ...
|
195
|
+
* }
|
196
|
+
* });
|
197
|
+
*
|
198
|
+
* // Send the transaction
|
199
|
+
* await sendTransaction({ transaction, account });
|
200
|
+
* ```
|
201
|
+
*/
|
202
|
+
export function createPack(
|
203
|
+
options: BaseTransactionOptions<
|
204
|
+
| CreatePackParams
|
205
|
+
| {
|
206
|
+
asyncParams: () => Promise<CreatePackParams>;
|
207
|
+
}
|
208
|
+
>,
|
209
|
+
) {
|
210
|
+
const asyncOptions = once(async () => {
|
211
|
+
return "asyncParams" in options ? await options.asyncParams() : options;
|
212
|
+
});
|
213
|
+
|
214
|
+
return prepareContractCall({
|
215
|
+
contract: options.contract,
|
216
|
+
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
217
|
+
params: async () => {
|
218
|
+
const resolvedOptions = await asyncOptions();
|
219
|
+
return [
|
220
|
+
resolvedOptions.contents,
|
221
|
+
resolvedOptions.numOfRewardUnits,
|
222
|
+
resolvedOptions.packUri,
|
223
|
+
resolvedOptions.openStartTimestamp,
|
224
|
+
resolvedOptions.amountDistributedPerOpen,
|
225
|
+
resolvedOptions.recipient,
|
226
|
+
] as const;
|
227
|
+
},
|
228
|
+
value: async () => (await asyncOptions()).overrides?.value,
|
229
|
+
accessList: async () => (await asyncOptions()).overrides?.accessList,
|
230
|
+
gas: async () => (await asyncOptions()).overrides?.gas,
|
231
|
+
gasPrice: async () => (await asyncOptions()).overrides?.gasPrice,
|
232
|
+
maxFeePerGas: async () => (await asyncOptions()).overrides?.maxFeePerGas,
|
233
|
+
maxPriorityFeePerGas: async () =>
|
234
|
+
(await asyncOptions()).overrides?.maxPriorityFeePerGas,
|
235
|
+
nonce: async () => (await asyncOptions()).overrides?.nonce,
|
236
|
+
extraGas: async () => (await asyncOptions()).overrides?.extraGas,
|
237
|
+
erc20Value: async () => (await asyncOptions()).overrides?.erc20Value,
|
238
|
+
});
|
239
|
+
}
|
@@ -0,0 +1,168 @@
|
|
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 "openPack" function.
|
13
|
+
*/
|
14
|
+
export type OpenPackParams = WithOverrides<{
|
15
|
+
packId: AbiParameterToPrimitiveType<{ type: "uint256"; name: "packId" }>;
|
16
|
+
amountToOpen: AbiParameterToPrimitiveType<{
|
17
|
+
type: "uint256";
|
18
|
+
name: "amountToOpen";
|
19
|
+
}>;
|
20
|
+
}>;
|
21
|
+
|
22
|
+
export const FN_SELECTOR = "0x914e126a" as const;
|
23
|
+
const FN_INPUTS = [
|
24
|
+
{
|
25
|
+
type: "uint256",
|
26
|
+
name: "packId",
|
27
|
+
},
|
28
|
+
{
|
29
|
+
type: "uint256",
|
30
|
+
name: "amountToOpen",
|
31
|
+
},
|
32
|
+
] as const;
|
33
|
+
const FN_OUTPUTS = [
|
34
|
+
{
|
35
|
+
type: "tuple[]",
|
36
|
+
components: [
|
37
|
+
{
|
38
|
+
type: "address",
|
39
|
+
name: "assetContract",
|
40
|
+
},
|
41
|
+
{
|
42
|
+
type: "uint8",
|
43
|
+
name: "tokenType",
|
44
|
+
},
|
45
|
+
{
|
46
|
+
type: "uint256",
|
47
|
+
name: "tokenId",
|
48
|
+
},
|
49
|
+
{
|
50
|
+
type: "uint256",
|
51
|
+
name: "totalAmount",
|
52
|
+
},
|
53
|
+
],
|
54
|
+
},
|
55
|
+
] as const;
|
56
|
+
|
57
|
+
/**
|
58
|
+
* Checks if the `openPack` method is supported by the given contract.
|
59
|
+
* @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.
|
60
|
+
* @returns A boolean indicating if the `openPack` method is supported.
|
61
|
+
* @extension PACK
|
62
|
+
* @example
|
63
|
+
* ```ts
|
64
|
+
* import { isOpenPackSupported } from "thirdweb/extensions/pack";
|
65
|
+
*
|
66
|
+
* const supported = isOpenPackSupported(["0x..."]);
|
67
|
+
* ```
|
68
|
+
*/
|
69
|
+
export function isOpenPackSupported(availableSelectors: string[]) {
|
70
|
+
return detectMethod({
|
71
|
+
availableSelectors,
|
72
|
+
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
73
|
+
});
|
74
|
+
}
|
75
|
+
|
76
|
+
/**
|
77
|
+
* Encodes the parameters for the "openPack" function.
|
78
|
+
* @param options - The options for the openPack function.
|
79
|
+
* @returns The encoded ABI parameters.
|
80
|
+
* @extension PACK
|
81
|
+
* @example
|
82
|
+
* ```ts
|
83
|
+
* import { encodeOpenPackParams } from "thirdweb/extensions/pack";
|
84
|
+
* const result = encodeOpenPackParams({
|
85
|
+
* packId: ...,
|
86
|
+
* amountToOpen: ...,
|
87
|
+
* });
|
88
|
+
* ```
|
89
|
+
*/
|
90
|
+
export function encodeOpenPackParams(options: OpenPackParams) {
|
91
|
+
return encodeAbiParameters(FN_INPUTS, [options.packId, options.amountToOpen]);
|
92
|
+
}
|
93
|
+
|
94
|
+
/**
|
95
|
+
* Encodes the "openPack" function into a Hex string with its parameters.
|
96
|
+
* @param options - The options for the openPack function.
|
97
|
+
* @returns The encoded hexadecimal string.
|
98
|
+
* @extension PACK
|
99
|
+
* @example
|
100
|
+
* ```ts
|
101
|
+
* import { encodeOpenPack } from "thirdweb/extensions/pack";
|
102
|
+
* const result = encodeOpenPack({
|
103
|
+
* packId: ...,
|
104
|
+
* amountToOpen: ...,
|
105
|
+
* });
|
106
|
+
* ```
|
107
|
+
*/
|
108
|
+
export function encodeOpenPack(options: OpenPackParams) {
|
109
|
+
// we do a "manual" concat here to avoid the overhead of the "concatHex" function
|
110
|
+
// we can do this because we know the specific formats of the values
|
111
|
+
return (FN_SELECTOR +
|
112
|
+
encodeOpenPackParams(options).slice(2)) as `${typeof FN_SELECTOR}${string}`;
|
113
|
+
}
|
114
|
+
|
115
|
+
/**
|
116
|
+
* Prepares a transaction to call the "openPack" function on the contract.
|
117
|
+
* @param options - The options for the "openPack" function.
|
118
|
+
* @returns A prepared transaction object.
|
119
|
+
* @extension PACK
|
120
|
+
* @example
|
121
|
+
* ```ts
|
122
|
+
* import { sendTransaction } from "thirdweb";
|
123
|
+
* import { openPack } from "thirdweb/extensions/pack";
|
124
|
+
*
|
125
|
+
* const transaction = openPack({
|
126
|
+
* contract,
|
127
|
+
* packId: ...,
|
128
|
+
* amountToOpen: ...,
|
129
|
+
* overrides: {
|
130
|
+
* ...
|
131
|
+
* }
|
132
|
+
* });
|
133
|
+
*
|
134
|
+
* // Send the transaction
|
135
|
+
* await sendTransaction({ transaction, account });
|
136
|
+
* ```
|
137
|
+
*/
|
138
|
+
export function openPack(
|
139
|
+
options: BaseTransactionOptions<
|
140
|
+
| OpenPackParams
|
141
|
+
| {
|
142
|
+
asyncParams: () => Promise<OpenPackParams>;
|
143
|
+
}
|
144
|
+
>,
|
145
|
+
) {
|
146
|
+
const asyncOptions = once(async () => {
|
147
|
+
return "asyncParams" in options ? await options.asyncParams() : options;
|
148
|
+
});
|
149
|
+
|
150
|
+
return prepareContractCall({
|
151
|
+
contract: options.contract,
|
152
|
+
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
153
|
+
params: async () => {
|
154
|
+
const resolvedOptions = await asyncOptions();
|
155
|
+
return [resolvedOptions.packId, resolvedOptions.amountToOpen] as const;
|
156
|
+
},
|
157
|
+
value: async () => (await asyncOptions()).overrides?.value,
|
158
|
+
accessList: async () => (await asyncOptions()).overrides?.accessList,
|
159
|
+
gas: async () => (await asyncOptions()).overrides?.gas,
|
160
|
+
gasPrice: async () => (await asyncOptions()).overrides?.gasPrice,
|
161
|
+
maxFeePerGas: async () => (await asyncOptions()).overrides?.maxFeePerGas,
|
162
|
+
maxPriorityFeePerGas: async () =>
|
163
|
+
(await asyncOptions()).overrides?.maxPriorityFeePerGas,
|
164
|
+
nonce: async () => (await asyncOptions()).overrides?.nonce,
|
165
|
+
extraGas: async () => (await asyncOptions()).overrides?.extraGas,
|
166
|
+
erc20Value: async () => (await asyncOptions()).overrides?.erc20Value,
|
167
|
+
});
|
168
|
+
}
|
@@ -0,0 +1,49 @@
|
|
1
|
+
import { prepareEvent } from "../../../../../event/prepare-event.js";
|
2
|
+
import type { AbiParameterToPrimitiveType } from "abitype";
|
3
|
+
|
4
|
+
/**
|
5
|
+
* Represents the filters for the "PackOpenRequested" event.
|
6
|
+
*/
|
7
|
+
export type PackOpenRequestedEventFilters = Partial<{
|
8
|
+
opener: AbiParameterToPrimitiveType<{
|
9
|
+
type: "address";
|
10
|
+
name: "opener";
|
11
|
+
indexed: true;
|
12
|
+
}>;
|
13
|
+
packId: AbiParameterToPrimitiveType<{
|
14
|
+
type: "uint256";
|
15
|
+
name: "packId";
|
16
|
+
indexed: true;
|
17
|
+
}>;
|
18
|
+
}>;
|
19
|
+
|
20
|
+
/**
|
21
|
+
* Creates an event object for the PackOpenRequested 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 { packOpenRequestedEvent } from "thirdweb/extensions/pack";
|
29
|
+
*
|
30
|
+
* const events = await getContractEvents({
|
31
|
+
* contract,
|
32
|
+
* events: [
|
33
|
+
* packOpenRequestedEvent({
|
34
|
+
* opener: ...,
|
35
|
+
* packId: ...,
|
36
|
+
* })
|
37
|
+
* ],
|
38
|
+
* });
|
39
|
+
* ```
|
40
|
+
*/
|
41
|
+
export function packOpenRequestedEvent(
|
42
|
+
filters: PackOpenRequestedEventFilters = {},
|
43
|
+
) {
|
44
|
+
return prepareEvent({
|
45
|
+
signature:
|
46
|
+
"event PackOpenRequested(address indexed opener, uint256 indexed packId, uint256 amountToOpen, uint256 requestId)",
|
47
|
+
filters,
|
48
|
+
});
|
49
|
+
}
|
@@ -0,0 +1,49 @@
|
|
1
|
+
import { prepareEvent } from "../../../../../event/prepare-event.js";
|
2
|
+
import type { AbiParameterToPrimitiveType } from "abitype";
|
3
|
+
|
4
|
+
/**
|
5
|
+
* Represents the filters for the "PackRandomnessFulfilled" event.
|
6
|
+
*/
|
7
|
+
export type PackRandomnessFulfilledEventFilters = Partial<{
|
8
|
+
packId: AbiParameterToPrimitiveType<{
|
9
|
+
type: "uint256";
|
10
|
+
name: "packId";
|
11
|
+
indexed: true;
|
12
|
+
}>;
|
13
|
+
requestId: AbiParameterToPrimitiveType<{
|
14
|
+
type: "uint256";
|
15
|
+
name: "requestId";
|
16
|
+
indexed: true;
|
17
|
+
}>;
|
18
|
+
}>;
|
19
|
+
|
20
|
+
/**
|
21
|
+
* Creates an event object for the PackRandomnessFulfilled 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 { packRandomnessFulfilledEvent } from "thirdweb/extensions/pack";
|
29
|
+
*
|
30
|
+
* const events = await getContractEvents({
|
31
|
+
* contract,
|
32
|
+
* events: [
|
33
|
+
* packRandomnessFulfilledEvent({
|
34
|
+
* packId: ...,
|
35
|
+
* requestId: ...,
|
36
|
+
* })
|
37
|
+
* ],
|
38
|
+
* });
|
39
|
+
* ```
|
40
|
+
*/
|
41
|
+
export function packRandomnessFulfilledEvent(
|
42
|
+
filters: PackRandomnessFulfilledEventFilters = {},
|
43
|
+
) {
|
44
|
+
return prepareEvent({
|
45
|
+
signature:
|
46
|
+
"event PackRandomnessFulfilled(uint256 indexed packId, uint256 indexed requestId)",
|
47
|
+
filters,
|
48
|
+
});
|
49
|
+
}
|
@@ -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 "canClaimRewards" function.
|
11
|
+
*/
|
12
|
+
export type CanClaimRewardsParams = {
|
13
|
+
opener: AbiParameterToPrimitiveType<{ type: "address"; name: "_opener" }>;
|
14
|
+
};
|
15
|
+
|
16
|
+
export const FN_SELECTOR = "0xa9b47a66" as const;
|
17
|
+
const FN_INPUTS = [
|
18
|
+
{
|
19
|
+
type: "address",
|
20
|
+
name: "_opener",
|
21
|
+
},
|
22
|
+
] as const;
|
23
|
+
const FN_OUTPUTS = [
|
24
|
+
{
|
25
|
+
type: "bool",
|
26
|
+
},
|
27
|
+
] as const;
|
28
|
+
|
29
|
+
/**
|
30
|
+
* Checks if the `canClaimRewards` 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 `canClaimRewards` method is supported.
|
33
|
+
* @extension PACK
|
34
|
+
* @example
|
35
|
+
* ```ts
|
36
|
+
* import { isCanClaimRewardsSupported } from "thirdweb/extensions/pack";
|
37
|
+
* const supported = isCanClaimRewardsSupported(["0x..."]);
|
38
|
+
* ```
|
39
|
+
*/
|
40
|
+
export function isCanClaimRewardsSupported(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 "canClaimRewards" function.
|
49
|
+
* @param options - The options for the canClaimRewards function.
|
50
|
+
* @returns The encoded ABI parameters.
|
51
|
+
* @extension PACK
|
52
|
+
* @example
|
53
|
+
* ```ts
|
54
|
+
* import { encodeCanClaimRewardsParams } from "thirdweb/extensions/pack";
|
55
|
+
* const result = encodeCanClaimRewardsParams({
|
56
|
+
* opener: ...,
|
57
|
+
* });
|
58
|
+
* ```
|
59
|
+
*/
|
60
|
+
export function encodeCanClaimRewardsParams(options: CanClaimRewardsParams) {
|
61
|
+
return encodeAbiParameters(FN_INPUTS, [options.opener]);
|
62
|
+
}
|
63
|
+
|
64
|
+
/**
|
65
|
+
* Encodes the "canClaimRewards" function into a Hex string with its parameters.
|
66
|
+
* @param options - The options for the canClaimRewards function.
|
67
|
+
* @returns The encoded hexadecimal string.
|
68
|
+
* @extension PACK
|
69
|
+
* @example
|
70
|
+
* ```ts
|
71
|
+
* import { encodeCanClaimRewards } from "thirdweb/extensions/pack";
|
72
|
+
* const result = encodeCanClaimRewards({
|
73
|
+
* opener: ...,
|
74
|
+
* });
|
75
|
+
* ```
|
76
|
+
*/
|
77
|
+
export function encodeCanClaimRewards(options: CanClaimRewardsParams) {
|
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
|
+
encodeCanClaimRewardsParams(options).slice(
|
82
|
+
2,
|
83
|
+
)) as `${typeof FN_SELECTOR}${string}`;
|
84
|
+
}
|
85
|
+
|
86
|
+
/**
|
87
|
+
* Decodes the result of the canClaimRewards 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 { decodeCanClaimRewardsResult } from "thirdweb/extensions/pack";
|
94
|
+
* const result = decodeCanClaimRewardsResultResult("...");
|
95
|
+
* ```
|
96
|
+
*/
|
97
|
+
export function decodeCanClaimRewardsResult(result: Hex) {
|
98
|
+
return decodeAbiParameters(FN_OUTPUTS, result)[0];
|
99
|
+
}
|
100
|
+
|
101
|
+
/**
|
102
|
+
* Calls the "canClaimRewards" function on the contract.
|
103
|
+
* @param options - The options for the canClaimRewards function.
|
104
|
+
* @returns The parsed result of the function call.
|
105
|
+
* @extension PACK
|
106
|
+
* @example
|
107
|
+
* ```ts
|
108
|
+
* import { canClaimRewards } from "thirdweb/extensions/pack";
|
109
|
+
*
|
110
|
+
* const result = await canClaimRewards({
|
111
|
+
* contract,
|
112
|
+
* opener: ...,
|
113
|
+
* });
|
114
|
+
*
|
115
|
+
* ```
|
116
|
+
*/
|
117
|
+
export async function canClaimRewards(
|
118
|
+
options: BaseTransactionOptions<CanClaimRewardsParams>,
|
119
|
+
) {
|
120
|
+
return readContract({
|
121
|
+
contract: options.contract,
|
122
|
+
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
123
|
+
params: [options.opener],
|
124
|
+
});
|
125
|
+
}
|
@@ -0,0 +1,73 @@
|
|
1
|
+
import type { BaseTransactionOptions } from "../../../../../transaction/types.js";
|
2
|
+
import { prepareContractCall } from "../../../../../transaction/prepare-contract-call.js";
|
3
|
+
|
4
|
+
import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
|
5
|
+
|
6
|
+
export const FN_SELECTOR = "0x372500ab" as const;
|
7
|
+
const FN_INPUTS = [] as const;
|
8
|
+
const FN_OUTPUTS = [
|
9
|
+
{
|
10
|
+
type: "tuple[]",
|
11
|
+
name: "rewardUnits",
|
12
|
+
components: [
|
13
|
+
{
|
14
|
+
type: "address",
|
15
|
+
name: "assetContract",
|
16
|
+
},
|
17
|
+
{
|
18
|
+
type: "uint8",
|
19
|
+
name: "tokenType",
|
20
|
+
},
|
21
|
+
{
|
22
|
+
type: "uint256",
|
23
|
+
name: "tokenId",
|
24
|
+
},
|
25
|
+
{
|
26
|
+
type: "uint256",
|
27
|
+
name: "totalAmount",
|
28
|
+
},
|
29
|
+
],
|
30
|
+
},
|
31
|
+
] as const;
|
32
|
+
|
33
|
+
/**
|
34
|
+
* Checks if the `claimRewards` method is supported by the given contract.
|
35
|
+
* @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.
|
36
|
+
* @returns A boolean indicating if the `claimRewards` method is supported.
|
37
|
+
* @extension PACK
|
38
|
+
* @example
|
39
|
+
* ```ts
|
40
|
+
* import { isClaimRewardsSupported } from "thirdweb/extensions/pack";
|
41
|
+
*
|
42
|
+
* const supported = isClaimRewardsSupported(["0x..."]);
|
43
|
+
* ```
|
44
|
+
*/
|
45
|
+
export function isClaimRewardsSupported(availableSelectors: string[]) {
|
46
|
+
return detectMethod({
|
47
|
+
availableSelectors,
|
48
|
+
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
49
|
+
});
|
50
|
+
}
|
51
|
+
|
52
|
+
/**
|
53
|
+
* Prepares a transaction to call the "claimRewards" function on the contract.
|
54
|
+
* @param options - The options for the "claimRewards" function.
|
55
|
+
* @returns A prepared transaction object.
|
56
|
+
* @extension PACK
|
57
|
+
* @example
|
58
|
+
* ```ts
|
59
|
+
* import { sendTransaction } from "thirdweb";
|
60
|
+
* import { claimRewards } from "thirdweb/extensions/pack";
|
61
|
+
*
|
62
|
+
* const transaction = claimRewards();
|
63
|
+
*
|
64
|
+
* // Send the transaction
|
65
|
+
* await sendTransaction({ transaction, account });
|
66
|
+
* ```
|
67
|
+
*/
|
68
|
+
export function claimRewards(options: BaseTransactionOptions) {
|
69
|
+
return prepareContractCall({
|
70
|
+
contract: options.contract,
|
71
|
+
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
72
|
+
});
|
73
|
+
}
|