Skip to content

Commit 59be4ea

Browse files
committed
[SDK/Dashboard] fix: ERC1155 single phase claim conditions (#6655)
<!-- ## title your PR with this format: "[SDK/Dashboard/Portal] Feature/Fix: Concise title for the changes" If you did not copy the branch name from Linear, paste the issue tag here (format is TEAM-0000): ## Notes for the reviewer Anything important to call out? Be sure to also clarify these in your comments. ## How to test Unit tests, playground, etc. --> <!-- start pr-codex --> --- ## PR-Codex overview This PR focuses on adding single phase functionality for `erc1155` claim conditions in the `thirdweb` dashboard and related utilities, enhancing the ability to manage claim eligibility and conditions for tokens. ### Detailed summary - Introduced `isMultiphase` and `isSinglePhase` properties in various components. - Updated `setClaimPhasesTx` to handle single phase options. - Modified `getClaimConditions` to support both multi-phase and single-phase claims. - Enhanced `resetClaimEligibility` to work with single phase drops. - Updated tests to validate new single phase functionality. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent 9c737a1 commit 59be4ea

File tree

16 files changed

+290
-81
lines changed

16 files changed

+290
-81
lines changed

.changeset/blue-geese-refuse.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"thirdweb": patch
3+
---
4+
5+
Single phase functionality for erc1155

apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/_components/claim-conditions/claim-conditions-form/hooks.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ export async function getClaimPhasesInLegacyFormat(
126126
type PhaseInput = z.input<typeof LegacyClaimConditionInputSchema>;
127127

128128
export function setClaimPhasesTx(
129-
baseOptions: BaseTransactionOptions<Options>,
129+
baseOptions: BaseTransactionOptions<Options> & { isSinglePhase?: boolean },
130130
rawPhases: PhaseInput[],
131131
) {
132132
const phases = rawPhases.map((phase) => {
@@ -172,6 +172,7 @@ export function setClaimPhasesTx(
172172
contract: baseOptions.contract,
173173
phases,
174174
tokenId: baseOptions.tokenId,
175+
singlePhaseDrop: baseOptions.isSinglePhase,
175176
});
176177
}
177178
}

apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/_components/claim-conditions/claim-conditions-form/index.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,10 @@ export const ClaimConditionsForm: React.FC<ClaimConditionsFormProps> = ({
226226
? { type: "erc20", decimals: tokenDecimals.data }
227227
: isErc721
228228
? { type: "erc721" }
229-
: { type: "erc1155", tokenId: BigInt(tokenId || 0) }),
229+
: {
230+
type: "erc1155",
231+
tokenId: BigInt(tokenId || 0),
232+
}),
230233
});
231234

232235
const transformedQueryData = useMemo(() => {
@@ -370,6 +373,7 @@ export const ClaimConditionsForm: React.FC<ClaimConditionsFormProps> = ({
370373
const tx = setClaimPhasesTx(
371374
{
372375
contract,
376+
isSinglePhase: !isMultiPhase,
373377
...(isErc20
374378
? { type: "erc20", decimals: tokenDecimals.data }
375379
: isErc721
@@ -635,6 +639,7 @@ export const ClaimConditionsForm: React.FC<ClaimConditionsFormProps> = ({
635639
isErc20={isErc20}
636640
contract={contract}
637641
tokenId={tokenId}
642+
isMultiphase={isMultiPhase}
638643
/>
639644
)}
640645
</div>

apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/_components/claim-conditions/claim-conditions.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@ interface ClaimConditionsProps {
1010
isColumn?: true;
1111
isERC20: boolean;
1212
twAccount: Account | undefined;
13+
isMultiphase: boolean;
1314
}
1415
export const ClaimConditions: React.FC<ClaimConditionsProps> = ({
1516
contract,
1617
tokenId,
1718
isColumn,
1819
isERC20,
1920
twAccount,
21+
isMultiphase,
2022
}) => {
2123
return (
2224
<div className="flex w-full flex-col gap-6">
@@ -37,8 +39,7 @@ export const ClaimConditions: React.FC<ClaimConditionsProps> = ({
3739
contract={contract}
3840
tokenId={tokenId}
3941
isColumn={isColumn}
40-
// always multi phase!
41-
isMultiPhase={true}
42+
isMultiPhase={isMultiphase}
4243
/>
4344
</div>
4445
);

apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/_components/claim-conditions/reset-claim-eligibility.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@ interface ResetClaimEligibilityProps {
1818
contract: ThirdwebContract;
1919
tokenId?: string;
2020
twAccount: Account | undefined;
21+
isMultiphase: boolean;
2122
}
2223

2324
export const ResetClaimEligibility: React.FC<ResetClaimEligibilityProps> = ({
2425
contract,
2526
tokenId,
2627
isErc20,
2728
twAccount,
29+
isMultiphase,
2830
}) => {
2931
const trackEvent = useTrack();
3032

@@ -55,6 +57,7 @@ export const ResetClaimEligibility: React.FC<ResetClaimEligibilityProps> = ({
5557
return ERC1155Ext.resetClaimEligibility({
5658
contract,
5759
tokenId: BigInt(tokenId),
60+
singlePhaseDrop: !isMultiphase,
5861
});
5962
}
6063
// assume erc 721

apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/claim-conditions/ClaimConditions.client.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export function ClaimConditionsClient(props: {
3636
contract={props.contract}
3737
isERC20={supportedERCs.isERC20}
3838
twAccount={props.twAccount}
39+
isMultiphase={true}
3940
/>
4041
);
4142
}

apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/claim-conditions/page.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export default async function Page(props: {
4141
contract={contract}
4242
isERC20={supportedERCs.isERC20}
4343
twAccount={account}
44+
isMultiphase={true}
4445
/>
4546
);
4647
}

apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/nfts/[tokenId]/useNftDrawerTabs.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ export function useNFTDrawerTabs({
6868
const hasERC1155ClaimConditions = (() => {
6969
return [
7070
// reads
71-
ERC1155Ext.isGetClaimConditionByIdSupported(functionSelectors),
7271
ERC1155Ext.isGetClaimConditionsSupported(functionSelectors),
7372
ERC1155Ext.isGetActiveClaimConditionSupported(functionSelectors),
7473
// writes
@@ -77,6 +76,10 @@ export function useNFTDrawerTabs({
7776
].every(Boolean);
7877
})();
7978

79+
const isERC1155Multiphase = (() => {
80+
return ERC1155Ext.isGetClaimConditionByIdSupported(functionSelectors);
81+
})();
82+
8083
const isBurnable = (() => {
8184
if (isERC721) {
8285
return ERC721Ext.isBurnSupported(functionSelectors);
@@ -130,6 +133,7 @@ export function useNFTDrawerTabs({
130133
tokenId={tokenId}
131134
isColumn
132135
twAccount={twAccount}
136+
isMultiphase={isERC1155Multiphase}
133137
/>
134138
),
135139
},
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[
22
"function claim(address receiver, uint256 tokenId, uint256 quantity, address currency, uint256 pricePerToken, (bytes32[] proof, uint256 quantityLimitPerWallet, uint256 pricePerToken, address currency) allowlistProof, bytes data) payable",
33
"function setClaimConditions(uint256 tokenId, (uint256 startTimestamp, uint256 maxClaimableSupply, uint256 supplyClaimed, uint256 quantityLimitPerWallet, bytes32 merkleRoot, uint256 pricePerToken, address currency, string metadata) phase, bool resetClaimEligibility)",
4-
"function claimCondition(uint256 tokenId) view returns ((uint256 startTimestamp, uint256 maxClaimableSupply, uint256 supplyClaimed, uint256 quantityLimitPerWallet, bytes32 merkleRoot, uint256 pricePerToken, address currency, string metadata) condition)",
4+
"function claimCondition(uint256 tokenId) view returns (uint256 startTimestamp, uint256 maxClaimableSupply, uint256 supplyClaimed, uint256 quantityLimitPerWallet, bytes32 merkleRoot, uint256 pricePerToken, address currency, string metadata)",
55
"event ClaimConditionUpdated(uint256 indexed tokenId, (uint256 startTimestamp, uint256 maxClaimableSupply, uint256 supplyClaimed, uint256 quantityLimitPerWallet, bytes32 merkleRoot, uint256 pricePerToken, address currency, string metadata) condition, bool resetEligibility)",
66
"event TokensClaimed(address indexed claimer, address indexed receiver, uint256 indexed tokenId, uint256 quantityClaimed)"
77
]

packages/thirdweb/src/exports/extensions/erc1155.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ export {
112112
type CanClaimParams,
113113
type CanClaimResult,
114114
} from "../../extensions/erc1155/drops/read/canClaim.js";
115+
export { claimCondition } from "../../extensions/erc1155/__generated__/IDropSinglePhase1155/read/claimCondition.js";
115116

116117
// WRITE
117118
export {

0 commit comments

Comments
 (0)