Skip to content

Commit 164b70b

Browse files
committed
[Dashboard] Fix falsy logic when updating Royalties and PlatformFees (#5342)
## Problem solved Short description of the bug fixed or feature added <!-- start pr-codex --> --- ## PR-Codex overview This PR focuses on refining the validation logic for platform fees and royalties in the settings components by removing default values and error handling that were previously in place. This aims to enhance clarity and enforce valid user input. ### Detailed summary - Removed default values for `platform_fee_basis_points` and `platform_fee_recipient` in `platform-fees.tsx`. - Removed error handling for invalid `platform_fee_basis_points` and `platform_fee_recipient` in `platform-fees.tsx`. - Removed default values for `seller_fee_basis_points` and `fee_recipient` in `royalties.tsx`. - Removed error handling for invalid `seller_fee_basis_points` and `fee_recipient` in `royalties.tsx`. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent b2adc8d commit 164b70b

File tree

2 files changed

+6
-24
lines changed

2 files changed

+6
-24
lines changed

apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/settings/components/platform-fees.tsx

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ import { SolidityInput } from "contract-ui/components/solidity-inputs";
1010
import { useTrack } from "hooks/analytics/useTrack";
1111
import { useTxNotifications } from "hooks/useTxNotifications";
1212
import { useForm } from "react-hook-form";
13-
import { toast } from "sonner";
14-
import { type ThirdwebContract, ZERO_ADDRESS } from "thirdweb";
13+
import type { ThirdwebContract } from "thirdweb";
1514
import {
1615
getPlatformFeeInfo,
1716
setPlatformFeeInfo,
@@ -36,11 +35,11 @@ const CommonPlatformFeeSchema = z.object({
3635
/**
3736
* platform fee basis points
3837
*/
39-
platform_fee_basis_points: BasisPointsSchema.default(0),
38+
platform_fee_basis_points: BasisPointsSchema,
4039
/**
4140
* platform fee recipient address
4241
*/
43-
platform_fee_recipient: AddressOrEnsSchema.default(ZERO_ADDRESS),
42+
platform_fee_recipient: AddressOrEnsSchema,
4443
});
4544

4645
export const SettingsPlatformFees = ({
@@ -84,14 +83,6 @@ export const SettingsPlatformFees = ({
8483
action: "set-platform-fees",
8584
label: "attempt",
8685
});
87-
// In the v4 hook we defaulted recipient to address_zero and bps to `0`
88-
// but let's actually throw an error here for better transparency
89-
if (!data.platform_fee_basis_points) {
90-
return toast.error("Please enter valid basis points.");
91-
}
92-
if (!data.platform_fee_recipient) {
93-
return toast.error("Please enter a valid platform fee recipient.");
94-
}
9586
const transaction = setPlatformFeeInfo({
9687
contract,
9788
platformFeeRecipient: data.platform_fee_recipient,

apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/settings/components/royalties.tsx

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ import { SolidityInput } from "contract-ui/components/solidity-inputs";
1010
import { useTrack } from "hooks/analytics/useTrack";
1111
import { useTxNotifications } from "hooks/useTxNotifications";
1212
import { useForm } from "react-hook-form";
13-
import { toast } from "sonner";
14-
import { type ThirdwebContract, ZERO_ADDRESS } from "thirdweb";
13+
import type { ThirdwebContract } from "thirdweb";
1514
import {
1615
getDefaultRoyaltyInfo,
1716
setDefaultRoyaltyInfo,
@@ -46,15 +45,15 @@ const CommonRoyaltySchema = z.object({
4645
* @internal
4746
* @remarks used by OpenSea "seller_fee_basis_points"
4847
*/
49-
seller_fee_basis_points: BasisPointsSchema.default(0),
48+
seller_fee_basis_points: BasisPointsSchema,
5049

5150
/**
5251
* The address of the royalty recipient. All royalties will be sent
5352
* to this address.
5453
* @internal
5554
* @remarks used by OpenSea "fee_recipient"
5655
*/
57-
fee_recipient: AddressOrEnsSchema.default(ZERO_ADDRESS),
56+
fee_recipient: AddressOrEnsSchema,
5857
});
5958

6059
export const SettingsRoyalties = ({
@@ -97,14 +96,6 @@ export const SettingsRoyalties = ({
9796
action: "set-royalty",
9897
label: "attempt",
9998
});
100-
// In the v4 hook we defaulted recipient to address_zero and bps to `0`
101-
// but let's actually throw an error here for better transparency
102-
if (!d.seller_fee_basis_points) {
103-
return toast.error("Please enter valid basis points.");
104-
}
105-
if (!d.fee_recipient) {
106-
return toast.error("Please enter a valid royalty fee recipient.");
107-
}
10899
const transaction = setDefaultRoyaltyInfo({
109100
contract,
110101
royaltyRecipient: d.fee_recipient,

0 commit comments

Comments
 (0)