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,433 @@
|
|
1
|
+
import type { ThirdwebClient } from "../../client/client.js";
|
2
|
+
import { type ThirdwebContract, getContract } from "../../contract/contract.js";
|
3
|
+
import { upload } from "../../storage/upload.js";
|
4
|
+
import type { BaseTransactionOptions } from "../../transaction/types.js";
|
5
|
+
import type { NFTInput } from "../../utils/nft/parseNft.js";
|
6
|
+
import { toUnits } from "../../utils/units.js";
|
7
|
+
import type { AddPackContentsParams } from "./__generated__/IPack/write/addPackContents.js";
|
8
|
+
import {
|
9
|
+
type CreatePackParams,
|
10
|
+
createPack,
|
11
|
+
} from "./__generated__/IPack/write/createPack.js";
|
12
|
+
|
13
|
+
export enum PACK_TOKEN_TYPE {
|
14
|
+
ERC20 = 0,
|
15
|
+
ERC721 = 1,
|
16
|
+
ERC1155 = 2,
|
17
|
+
}
|
18
|
+
|
19
|
+
export type ERC20Reward = {
|
20
|
+
contractAddress: string;
|
21
|
+
quantityPerReward: number | string;
|
22
|
+
totalRewards: number | string;
|
23
|
+
};
|
24
|
+
|
25
|
+
export type ERC721Reward = {
|
26
|
+
contractAddress: string;
|
27
|
+
tokenId: bigint;
|
28
|
+
};
|
29
|
+
|
30
|
+
export type ERC1155Reward = {
|
31
|
+
contractAddress: string;
|
32
|
+
tokenId: bigint;
|
33
|
+
quantityPerReward: number | string;
|
34
|
+
totalRewards: number | string;
|
35
|
+
};
|
36
|
+
|
37
|
+
/**
|
38
|
+
* @extension PACK
|
39
|
+
*/
|
40
|
+
export type CreateNewPackParams = {
|
41
|
+
client: ThirdwebClient;
|
42
|
+
contract: ThirdwebContract;
|
43
|
+
/**
|
44
|
+
* The address of the reward recipient
|
45
|
+
*/
|
46
|
+
recipient: string;
|
47
|
+
/**
|
48
|
+
* The address of the entity who owns the tokens that are used as rewards.
|
49
|
+
* This is only used for checking token approval
|
50
|
+
*/
|
51
|
+
tokenOwner: string;
|
52
|
+
/**
|
53
|
+
* The metadata (image, description, etc.) of the Pack.
|
54
|
+
* This is similar to an NFT's metadata
|
55
|
+
*/
|
56
|
+
packMetadata: NFTInput | string;
|
57
|
+
amountDistributedPerOpen: bigint;
|
58
|
+
/**
|
59
|
+
* JavaScript Date object
|
60
|
+
*/
|
61
|
+
openStartTimestamp: Date;
|
62
|
+
/**
|
63
|
+
* An array of ERC20 rewards, see type `ERC20Reward` for more info
|
64
|
+
*/
|
65
|
+
erc20Rewards?: ERC20Reward[];
|
66
|
+
/**
|
67
|
+
* An array of ERC721 rewards, see type `ERC721Reward` for more info
|
68
|
+
*/
|
69
|
+
erc721Rewards?: ERC721Reward[];
|
70
|
+
/**
|
71
|
+
* An array of ERC1155 rewards, see type `ERC1155Reward` for more info
|
72
|
+
*/
|
73
|
+
erc1155Rewards?: ERC1155Reward[];
|
74
|
+
};
|
75
|
+
|
76
|
+
/**
|
77
|
+
* @extension PACK
|
78
|
+
* @example
|
79
|
+
* ```ts
|
80
|
+
* import { createNewPack } from "thirdweb/extensions/pack";
|
81
|
+
*
|
82
|
+
* const transaction = createNewPack({
|
83
|
+
* contract: packContract,
|
84
|
+
* client,
|
85
|
+
* recipient: "0x...",
|
86
|
+
* tokenOwner: "0x...",
|
87
|
+
* packMetadata: {
|
88
|
+
* name: "Pack #1",
|
89
|
+
* image: "image-of-pack-1",
|
90
|
+
* },
|
91
|
+
* openStartTimestamp: new Date(),
|
92
|
+
* erc20Rewards: [
|
93
|
+
* {
|
94
|
+
* contractAddress: "0x...",
|
95
|
+
* quantityPerReward: 1,
|
96
|
+
* totalRewards: 1,
|
97
|
+
* },
|
98
|
+
* ],
|
99
|
+
* erc721Rewards: [
|
100
|
+
* {
|
101
|
+
* contractAddress: "0x...",
|
102
|
+
* tokenId: 0n,
|
103
|
+
* },
|
104
|
+
* ],
|
105
|
+
* erc1155Rewards: [
|
106
|
+
* {
|
107
|
+
* contractAddress: "0x...",
|
108
|
+
* tokenId: 0n,
|
109
|
+
* quantityPerReward: 1,
|
110
|
+
* totalRewards: 1,
|
111
|
+
* },
|
112
|
+
* ],
|
113
|
+
* });
|
114
|
+
* ```
|
115
|
+
*/
|
116
|
+
export function createNewPack(
|
117
|
+
options: BaseTransactionOptions<CreateNewPackParams>,
|
118
|
+
) {
|
119
|
+
return createPack({
|
120
|
+
contract: options.contract,
|
121
|
+
asyncParams: async () => getCreatePackParams(options),
|
122
|
+
});
|
123
|
+
}
|
124
|
+
|
125
|
+
/**
|
126
|
+
* @internal
|
127
|
+
*/
|
128
|
+
async function getCreatePackParams(
|
129
|
+
options: BaseTransactionOptions<CreateNewPackParams>,
|
130
|
+
): Promise<CreatePackParams> {
|
131
|
+
const {
|
132
|
+
contract,
|
133
|
+
recipient,
|
134
|
+
packMetadata,
|
135
|
+
amountDistributedPerOpen,
|
136
|
+
openStartTimestamp,
|
137
|
+
erc20Rewards,
|
138
|
+
erc721Rewards,
|
139
|
+
erc1155Rewards,
|
140
|
+
tokenOwner,
|
141
|
+
} = options;
|
142
|
+
const [erc20Content, erc721Content, erc1155Content, packUri] =
|
143
|
+
await Promise.all([
|
144
|
+
processErc20Rewards({
|
145
|
+
packContract: contract,
|
146
|
+
content: erc20Rewards,
|
147
|
+
tokenOwner,
|
148
|
+
}),
|
149
|
+
processErc721Rewards({
|
150
|
+
packContract: contract,
|
151
|
+
content: erc721Rewards,
|
152
|
+
tokenOwner,
|
153
|
+
}),
|
154
|
+
processErc1155Rewards({
|
155
|
+
packContract: contract,
|
156
|
+
content: erc1155Rewards,
|
157
|
+
tokenOwner,
|
158
|
+
}),
|
159
|
+
typeof packMetadata === "string"
|
160
|
+
? packMetadata
|
161
|
+
: upload({
|
162
|
+
client: options.contract.client,
|
163
|
+
files: [packMetadata],
|
164
|
+
}),
|
165
|
+
]);
|
166
|
+
const contents = erc20Content.content
|
167
|
+
.concat(erc721Content.content)
|
168
|
+
.concat(erc1155Content.content);
|
169
|
+
|
170
|
+
const numOfRewardUnits = erc20Content.numOfRewardUnits
|
171
|
+
.concat(erc721Content.numOfRewardUnits)
|
172
|
+
.concat(erc1155Content.numOfRewardUnits);
|
173
|
+
|
174
|
+
return {
|
175
|
+
packUri,
|
176
|
+
recipient,
|
177
|
+
contents,
|
178
|
+
numOfRewardUnits,
|
179
|
+
// openStartTimestamp should be in seconds and not millisecond
|
180
|
+
openStartTimestamp: BigInt(Math.ceil(openStartTimestamp.getTime() / 1000)),
|
181
|
+
amountDistributedPerOpen,
|
182
|
+
};
|
183
|
+
}
|
184
|
+
|
185
|
+
/**
|
186
|
+
* @internal
|
187
|
+
*/
|
188
|
+
async function processErc20Rewards(options: {
|
189
|
+
content?: ERC20Reward[];
|
190
|
+
packContract: ThirdwebContract;
|
191
|
+
tokenOwner: string;
|
192
|
+
}): Promise<{
|
193
|
+
content: AddPackContentsParams["contents"];
|
194
|
+
numOfRewardUnits: bigint[];
|
195
|
+
}> {
|
196
|
+
const { content, packContract, tokenOwner } = options;
|
197
|
+
if (!content?.length) {
|
198
|
+
return {
|
199
|
+
content: [],
|
200
|
+
numOfRewardUnits: [],
|
201
|
+
};
|
202
|
+
}
|
203
|
+
const [{ allowance }, { decimals }] = await Promise.all([
|
204
|
+
import("../erc20/__generated__/IERC20/read/allowance.js"),
|
205
|
+
import("../erc20/__generated__/IERC20/read/decimals.js"),
|
206
|
+
]);
|
207
|
+
|
208
|
+
const uniqueERC20Contracts = [
|
209
|
+
...new Set(
|
210
|
+
content.map((o) =>
|
211
|
+
getContract({
|
212
|
+
address: o.contractAddress,
|
213
|
+
chain: packContract.chain,
|
214
|
+
client: packContract.client,
|
215
|
+
}),
|
216
|
+
),
|
217
|
+
),
|
218
|
+
];
|
219
|
+
|
220
|
+
const data: Array<{
|
221
|
+
_allowance: bigint;
|
222
|
+
_decimals: number;
|
223
|
+
address: string;
|
224
|
+
}> = (
|
225
|
+
await Promise.all(
|
226
|
+
uniqueERC20Contracts.map((contract) => {
|
227
|
+
return Promise.all([
|
228
|
+
allowance({
|
229
|
+
contract,
|
230
|
+
spender: packContract.address,
|
231
|
+
owner: tokenOwner,
|
232
|
+
}),
|
233
|
+
decimals({ contract }).catch(() => undefined),
|
234
|
+
contract.address,
|
235
|
+
]);
|
236
|
+
}),
|
237
|
+
)
|
238
|
+
).map((item) => {
|
239
|
+
const [_allowance, _decimals, address] = item;
|
240
|
+
if (_decimals === undefined) {
|
241
|
+
throw new Error(
|
242
|
+
`Failed to get the decimals of contract: ${address}. Make sure it is a valid ERC20 contract`,
|
243
|
+
);
|
244
|
+
}
|
245
|
+
return {
|
246
|
+
_allowance,
|
247
|
+
_decimals,
|
248
|
+
address,
|
249
|
+
};
|
250
|
+
});
|
251
|
+
const numOfRewardUnits: bigint[] = [];
|
252
|
+
const result = content.map((item, index) => {
|
253
|
+
const { contractAddress, quantityPerReward, totalRewards } = item;
|
254
|
+
if (!totalRewards) {
|
255
|
+
throw new Error(
|
256
|
+
`Invalid totalRewards for contract: ${contractAddress} at index: ${index}`,
|
257
|
+
);
|
258
|
+
}
|
259
|
+
const _data = data.find((o) => o.address === contractAddress);
|
260
|
+
if (!_data) {
|
261
|
+
// This should never happen
|
262
|
+
throw new Error(`contractAddress not found: ${contractAddress}`);
|
263
|
+
}
|
264
|
+
const quantityInWei = toUnits(String(quantityPerReward), _data._decimals);
|
265
|
+
const totalRequired = quantityInWei * BigInt(totalRewards);
|
266
|
+
if (totalRequired > _data._allowance) {
|
267
|
+
throw new Error(
|
268
|
+
`The following ERC20 contract address do not have enough allowance for the Pack contract: ${contractAddress}`,
|
269
|
+
);
|
270
|
+
}
|
271
|
+
numOfRewardUnits.push(BigInt(item.totalRewards));
|
272
|
+
return {
|
273
|
+
assetContract: contractAddress,
|
274
|
+
tokenType: PACK_TOKEN_TYPE.ERC20,
|
275
|
+
tokenId: 0n, // hard-coded to `0n` for ERC20
|
276
|
+
totalAmount: totalRequired,
|
277
|
+
};
|
278
|
+
});
|
279
|
+
|
280
|
+
return {
|
281
|
+
content: result,
|
282
|
+
numOfRewardUnits,
|
283
|
+
};
|
284
|
+
}
|
285
|
+
|
286
|
+
/**
|
287
|
+
* @internal
|
288
|
+
*/
|
289
|
+
async function processErc721Rewards(options: {
|
290
|
+
content?: ERC721Reward[];
|
291
|
+
packContract: ThirdwebContract;
|
292
|
+
tokenOwner: string;
|
293
|
+
}): Promise<{
|
294
|
+
content: AddPackContentsParams["contents"];
|
295
|
+
numOfRewardUnits: bigint[];
|
296
|
+
}> {
|
297
|
+
const { content, packContract, tokenOwner } = options;
|
298
|
+
if (!content?.length) {
|
299
|
+
return {
|
300
|
+
content: [],
|
301
|
+
numOfRewardUnits: [],
|
302
|
+
};
|
303
|
+
}
|
304
|
+
const uniqueERC721Contracts = [
|
305
|
+
...new Set(
|
306
|
+
content.map((o) => ({
|
307
|
+
contract: getContract({
|
308
|
+
address: o.contractAddress,
|
309
|
+
chain: packContract.chain,
|
310
|
+
client: packContract.client,
|
311
|
+
}),
|
312
|
+
tokenId: o.tokenId,
|
313
|
+
})),
|
314
|
+
),
|
315
|
+
];
|
316
|
+
const [{ isApprovedForAll }, { getApproved }] = await Promise.all([
|
317
|
+
import("../erc721/__generated__/IERC721A/read/isApprovedForAll.js"),
|
318
|
+
import("../erc721/__generated__/IERC721A/read/getApproved.js"),
|
319
|
+
]);
|
320
|
+
const numOfRewardUnits: bigint[] = [];
|
321
|
+
const result = (
|
322
|
+
await Promise.all(
|
323
|
+
uniqueERC721Contracts.map(({ contract, tokenId }) => {
|
324
|
+
return Promise.all([
|
325
|
+
isApprovedForAll({
|
326
|
+
contract,
|
327
|
+
operator: packContract.address,
|
328
|
+
owner: tokenOwner,
|
329
|
+
}).catch(() => false),
|
330
|
+
getApproved({ contract, tokenId }).catch(() => ""),
|
331
|
+
contract.address,
|
332
|
+
tokenId,
|
333
|
+
]);
|
334
|
+
}),
|
335
|
+
)
|
336
|
+
).map((item) => {
|
337
|
+
const [_allApproved, _tokenApprove, address, tokenId] = item;
|
338
|
+
if (
|
339
|
+
!_allApproved &&
|
340
|
+
_tokenApprove.toLowerCase() !== packContract.address.toLowerCase()
|
341
|
+
) {
|
342
|
+
throw new Error(
|
343
|
+
`TokenID: ${tokenId} from contract address ${address} is not approved to be used by this Pack contract.`,
|
344
|
+
);
|
345
|
+
}
|
346
|
+
numOfRewardUnits.push(1n);
|
347
|
+
return {
|
348
|
+
assetContract: address,
|
349
|
+
tokenType: PACK_TOKEN_TYPE.ERC721,
|
350
|
+
tokenId,
|
351
|
+
totalAmount: 1n,
|
352
|
+
};
|
353
|
+
});
|
354
|
+
|
355
|
+
return {
|
356
|
+
content: result,
|
357
|
+
numOfRewardUnits,
|
358
|
+
};
|
359
|
+
}
|
360
|
+
|
361
|
+
async function processErc1155Rewards(options: {
|
362
|
+
content?: ERC1155Reward[];
|
363
|
+
packContract: ThirdwebContract;
|
364
|
+
tokenOwner: string;
|
365
|
+
}): Promise<{
|
366
|
+
content: AddPackContentsParams["contents"];
|
367
|
+
numOfRewardUnits: bigint[];
|
368
|
+
}> {
|
369
|
+
const { content, packContract, tokenOwner } = options;
|
370
|
+
if (!content?.length) {
|
371
|
+
return {
|
372
|
+
content: [],
|
373
|
+
numOfRewardUnits: [],
|
374
|
+
};
|
375
|
+
}
|
376
|
+
const uniqueERC1155Contracts = [
|
377
|
+
...new Set(
|
378
|
+
content.map((o) => ({
|
379
|
+
contract: getContract({
|
380
|
+
address: o.contractAddress,
|
381
|
+
chain: packContract.chain,
|
382
|
+
client: packContract.client,
|
383
|
+
}),
|
384
|
+
tokenId: o.tokenId,
|
385
|
+
quantityPerReward: o.quantityPerReward,
|
386
|
+
totalRewards: o.totalRewards,
|
387
|
+
})),
|
388
|
+
),
|
389
|
+
];
|
390
|
+
const { isApprovedForAll } = await import(
|
391
|
+
"../erc1155/__generated__/IERC1155/read/isApprovedForAll.js"
|
392
|
+
);
|
393
|
+
const numOfRewardUnits: bigint[] = [];
|
394
|
+
const result = (
|
395
|
+
await Promise.all(
|
396
|
+
uniqueERC1155Contracts.map(
|
397
|
+
({ contract, tokenId, quantityPerReward, totalRewards }) => {
|
398
|
+
return Promise.all([
|
399
|
+
isApprovedForAll({
|
400
|
+
contract,
|
401
|
+
operator: packContract.address,
|
402
|
+
owner: tokenOwner,
|
403
|
+
}).catch(() => false),
|
404
|
+
contract.address,
|
405
|
+
tokenId,
|
406
|
+
quantityPerReward,
|
407
|
+
totalRewards,
|
408
|
+
]);
|
409
|
+
},
|
410
|
+
),
|
411
|
+
)
|
412
|
+
).map((item) => {
|
413
|
+
const [_allApproved, address, tokenId, quantityPerReward, totalRewards] =
|
414
|
+
item;
|
415
|
+
if (!_allApproved) {
|
416
|
+
throw new Error(
|
417
|
+
`ERC1155 contract address ${address} is not approved to be used by this Pack contract.`,
|
418
|
+
);
|
419
|
+
}
|
420
|
+
numOfRewardUnits.push(BigInt(totalRewards));
|
421
|
+
return {
|
422
|
+
assetContract: address,
|
423
|
+
tokenType: PACK_TOKEN_TYPE.ERC1155,
|
424
|
+
tokenId,
|
425
|
+
totalAmount: BigInt(quantityPerReward) * BigInt(totalRewards),
|
426
|
+
};
|
427
|
+
});
|
428
|
+
|
429
|
+
return {
|
430
|
+
content: result,
|
431
|
+
numOfRewardUnits,
|
432
|
+
};
|
433
|
+
}
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { beforeAll, describe, expect, it } from "vitest";
|
2
|
+
import { TEST_CONTRACT_URI } from "~test/ipfs-uris.js";
|
2
3
|
import { ANVIL_CHAIN } from "../../../test/src/chains.js";
|
3
4
|
import { TEST_CLIENT } from "../../../test/src/test-clients.js";
|
4
5
|
import {
|
@@ -22,6 +23,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("Permissions", () => {
|
|
22
23
|
client: TEST_CLIENT,
|
23
24
|
params: {
|
24
25
|
name: "PermissionsErc20",
|
26
|
+
contractURI: TEST_CONTRACT_URI,
|
25
27
|
},
|
26
28
|
type: "TokenERC20",
|
27
29
|
});
|
@@ -196,6 +198,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("PermissionsEnumerable", () => {
|
|
196
198
|
client: TEST_CLIENT,
|
197
199
|
params: {
|
198
200
|
name: "PermissionsErc20",
|
201
|
+
contractURI: TEST_CONTRACT_URI,
|
199
202
|
},
|
200
203
|
type: "TokenERC20",
|
201
204
|
});
|
@@ -0,0 +1,216 @@
|
|
1
|
+
import type { AbiParameterToPrimitiveType } from "abitype";
|
2
|
+
import type {
|
3
|
+
BaseTransactionOptions,
|
4
|
+
WithOverrides,
|
5
|
+
} from "../../../../../transaction/types.js";
|
6
|
+
import { prepareContractCall } from "../../../../../transaction/prepare-contract-call.js";
|
7
|
+
import { encodeAbiParameters } from "../../../../../utils/abi/encodeAbiParameters.js";
|
8
|
+
import { once } from "../../../../../utils/promise/once.js";
|
9
|
+
import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
|
10
|
+
|
11
|
+
/**
|
12
|
+
* Represents the parameters for the "initialize" function.
|
13
|
+
*/
|
14
|
+
export type InitializeParams = WithOverrides<{
|
15
|
+
defaultAdmin: AbiParameterToPrimitiveType<{
|
16
|
+
type: "address";
|
17
|
+
name: "_defaultAdmin";
|
18
|
+
}>;
|
19
|
+
name: AbiParameterToPrimitiveType<{ type: "string"; name: "_name" }>;
|
20
|
+
symbol: AbiParameterToPrimitiveType<{ type: "string"; name: "_symbol" }>;
|
21
|
+
contractURI: AbiParameterToPrimitiveType<{
|
22
|
+
type: "string";
|
23
|
+
name: "_contractURI";
|
24
|
+
}>;
|
25
|
+
trustedForwarders: AbiParameterToPrimitiveType<{
|
26
|
+
type: "address[]";
|
27
|
+
name: "_trustedForwarders";
|
28
|
+
}>;
|
29
|
+
royaltyRecipient: AbiParameterToPrimitiveType<{
|
30
|
+
type: "address";
|
31
|
+
name: "_royaltyRecipient";
|
32
|
+
}>;
|
33
|
+
royaltyBps: AbiParameterToPrimitiveType<{
|
34
|
+
type: "uint256";
|
35
|
+
name: "_royaltyBps";
|
36
|
+
}>;
|
37
|
+
}>;
|
38
|
+
|
39
|
+
export const FN_SELECTOR = "0x754b8fe7" as const;
|
40
|
+
const FN_INPUTS = [
|
41
|
+
{
|
42
|
+
type: "address",
|
43
|
+
name: "_defaultAdmin",
|
44
|
+
},
|
45
|
+
{
|
46
|
+
type: "string",
|
47
|
+
name: "_name",
|
48
|
+
},
|
49
|
+
{
|
50
|
+
type: "string",
|
51
|
+
name: "_symbol",
|
52
|
+
},
|
53
|
+
{
|
54
|
+
type: "string",
|
55
|
+
name: "_contractURI",
|
56
|
+
},
|
57
|
+
{
|
58
|
+
type: "address[]",
|
59
|
+
name: "_trustedForwarders",
|
60
|
+
},
|
61
|
+
{
|
62
|
+
type: "address",
|
63
|
+
name: "_royaltyRecipient",
|
64
|
+
},
|
65
|
+
{
|
66
|
+
type: "uint256",
|
67
|
+
name: "_royaltyBps",
|
68
|
+
},
|
69
|
+
] as const;
|
70
|
+
const FN_OUTPUTS = [] as const;
|
71
|
+
|
72
|
+
/**
|
73
|
+
* Checks if the `initialize` method is supported by the given contract.
|
74
|
+
* @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.
|
75
|
+
* @returns A boolean indicating if the `initialize` method is supported.
|
76
|
+
* @extension PREBUILTS
|
77
|
+
* @example
|
78
|
+
* ```ts
|
79
|
+
* import { isInitializeSupported } from "thirdweb/extensions/prebuilts";
|
80
|
+
*
|
81
|
+
* const supported = isInitializeSupported(["0x..."]);
|
82
|
+
* ```
|
83
|
+
*/
|
84
|
+
export function isInitializeSupported(availableSelectors: string[]) {
|
85
|
+
return detectMethod({
|
86
|
+
availableSelectors,
|
87
|
+
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
88
|
+
});
|
89
|
+
}
|
90
|
+
|
91
|
+
/**
|
92
|
+
* Encodes the parameters for the "initialize" function.
|
93
|
+
* @param options - The options for the initialize function.
|
94
|
+
* @returns The encoded ABI parameters.
|
95
|
+
* @extension PREBUILTS
|
96
|
+
* @example
|
97
|
+
* ```ts
|
98
|
+
* import { encodeInitializeParams } from "thirdweb/extensions/prebuilts";
|
99
|
+
* const result = encodeInitializeParams({
|
100
|
+
* defaultAdmin: ...,
|
101
|
+
* name: ...,
|
102
|
+
* symbol: ...,
|
103
|
+
* contractURI: ...,
|
104
|
+
* trustedForwarders: ...,
|
105
|
+
* royaltyRecipient: ...,
|
106
|
+
* royaltyBps: ...,
|
107
|
+
* });
|
108
|
+
* ```
|
109
|
+
*/
|
110
|
+
export function encodeInitializeParams(options: InitializeParams) {
|
111
|
+
return encodeAbiParameters(FN_INPUTS, [
|
112
|
+
options.defaultAdmin,
|
113
|
+
options.name,
|
114
|
+
options.symbol,
|
115
|
+
options.contractURI,
|
116
|
+
options.trustedForwarders,
|
117
|
+
options.royaltyRecipient,
|
118
|
+
options.royaltyBps,
|
119
|
+
]);
|
120
|
+
}
|
121
|
+
|
122
|
+
/**
|
123
|
+
* Encodes the "initialize" function into a Hex string with its parameters.
|
124
|
+
* @param options - The options for the initialize function.
|
125
|
+
* @returns The encoded hexadecimal string.
|
126
|
+
* @extension PREBUILTS
|
127
|
+
* @example
|
128
|
+
* ```ts
|
129
|
+
* import { encodeInitialize } from "thirdweb/extensions/prebuilts";
|
130
|
+
* const result = encodeInitialize({
|
131
|
+
* defaultAdmin: ...,
|
132
|
+
* name: ...,
|
133
|
+
* symbol: ...,
|
134
|
+
* contractURI: ...,
|
135
|
+
* trustedForwarders: ...,
|
136
|
+
* royaltyRecipient: ...,
|
137
|
+
* royaltyBps: ...,
|
138
|
+
* });
|
139
|
+
* ```
|
140
|
+
*/
|
141
|
+
export function encodeInitialize(options: InitializeParams) {
|
142
|
+
// we do a "manual" concat here to avoid the overhead of the "concatHex" function
|
143
|
+
// we can do this because we know the specific formats of the values
|
144
|
+
return (FN_SELECTOR +
|
145
|
+
encodeInitializeParams(options).slice(
|
146
|
+
2,
|
147
|
+
)) as `${typeof FN_SELECTOR}${string}`;
|
148
|
+
}
|
149
|
+
|
150
|
+
/**
|
151
|
+
* Prepares a transaction to call the "initialize" function on the contract.
|
152
|
+
* @param options - The options for the "initialize" function.
|
153
|
+
* @returns A prepared transaction object.
|
154
|
+
* @extension PREBUILTS
|
155
|
+
* @example
|
156
|
+
* ```ts
|
157
|
+
* import { sendTransaction } from "thirdweb";
|
158
|
+
* import { initialize } from "thirdweb/extensions/prebuilts";
|
159
|
+
*
|
160
|
+
* const transaction = initialize({
|
161
|
+
* contract,
|
162
|
+
* defaultAdmin: ...,
|
163
|
+
* name: ...,
|
164
|
+
* symbol: ...,
|
165
|
+
* contractURI: ...,
|
166
|
+
* trustedForwarders: ...,
|
167
|
+
* royaltyRecipient: ...,
|
168
|
+
* royaltyBps: ...,
|
169
|
+
* overrides: {
|
170
|
+
* ...
|
171
|
+
* }
|
172
|
+
* });
|
173
|
+
*
|
174
|
+
* // Send the transaction
|
175
|
+
* await sendTransaction({ transaction, account });
|
176
|
+
* ```
|
177
|
+
*/
|
178
|
+
export function initialize(
|
179
|
+
options: BaseTransactionOptions<
|
180
|
+
| InitializeParams
|
181
|
+
| {
|
182
|
+
asyncParams: () => Promise<InitializeParams>;
|
183
|
+
}
|
184
|
+
>,
|
185
|
+
) {
|
186
|
+
const asyncOptions = once(async () => {
|
187
|
+
return "asyncParams" in options ? await options.asyncParams() : options;
|
188
|
+
});
|
189
|
+
|
190
|
+
return prepareContractCall({
|
191
|
+
contract: options.contract,
|
192
|
+
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
193
|
+
params: async () => {
|
194
|
+
const resolvedOptions = await asyncOptions();
|
195
|
+
return [
|
196
|
+
resolvedOptions.defaultAdmin,
|
197
|
+
resolvedOptions.name,
|
198
|
+
resolvedOptions.symbol,
|
199
|
+
resolvedOptions.contractURI,
|
200
|
+
resolvedOptions.trustedForwarders,
|
201
|
+
resolvedOptions.royaltyRecipient,
|
202
|
+
resolvedOptions.royaltyBps,
|
203
|
+
] as const;
|
204
|
+
},
|
205
|
+
value: async () => (await asyncOptions()).overrides?.value,
|
206
|
+
accessList: async () => (await asyncOptions()).overrides?.accessList,
|
207
|
+
gas: async () => (await asyncOptions()).overrides?.gas,
|
208
|
+
gasPrice: async () => (await asyncOptions()).overrides?.gasPrice,
|
209
|
+
maxFeePerGas: async () => (await asyncOptions()).overrides?.maxFeePerGas,
|
210
|
+
maxPriorityFeePerGas: async () =>
|
211
|
+
(await asyncOptions()).overrides?.maxPriorityFeePerGas,
|
212
|
+
nonce: async () => (await asyncOptions()).overrides?.nonce,
|
213
|
+
extraGas: async () => (await asyncOptions()).overrides?.extraGas,
|
214
|
+
erc20Value: async () => (await asyncOptions()).overrides?.erc20Value,
|
215
|
+
});
|
216
|
+
}
|
@@ -1,11 +1,13 @@
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
2
2
|
import { ANVIL_CHAIN } from "../../../test/src/chains.js";
|
3
3
|
import { TEST_CLIENT } from "../../../test/src/test-clients.js";
|
4
|
-
import {
|
4
|
+
import { TEST_ACCOUNT_D } from "../../../test/src/test-wallets.js";
|
5
5
|
import { getContract } from "../../contract/contract.js";
|
6
6
|
import { name } from "../common/read/name.js";
|
7
7
|
import { deployERC20Contract } from "./deploy-erc20.js";
|
8
8
|
|
9
|
+
const account = TEST_ACCOUNT_D;
|
10
|
+
|
9
11
|
// skip this test suite if there is no secret key available to test with
|
10
12
|
// TODO: remove reliance on secret key during unit tests entirely
|
11
13
|
describe.runIf(process.env.TW_SECRET_KEY)("deployERC20", () => {
|
@@ -13,7 +15,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("deployERC20", () => {
|
|
13
15
|
const address = await deployERC20Contract({
|
14
16
|
client: TEST_CLIENT,
|
15
17
|
chain: ANVIL_CHAIN,
|
16
|
-
account
|
18
|
+
account,
|
17
19
|
type: "DropERC20",
|
18
20
|
params: {
|
19
21
|
name: "TokenDrop",
|
@@ -35,7 +37,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("deployERC20", () => {
|
|
35
37
|
const address = await deployERC20Contract({
|
36
38
|
client: TEST_CLIENT,
|
37
39
|
chain: ANVIL_CHAIN,
|
38
|
-
account
|
40
|
+
account,
|
39
41
|
type: "TokenERC20",
|
40
42
|
params: {
|
41
43
|
name: "Token",
|