Skip to content

Commit 9b0f195

Browse files
joaquim-vergesMananTank
authored andcommitted
[Dashboard] Fix asset page link and improve token claim UX (#7193)
1 parent 51eda91 commit 9b0f195

File tree

6 files changed

+30
-20
lines changed

6 files changed

+30
-20
lines changed

apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/overview/ContractOverviewPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export const ContractOverviewPage: React.FC<ContractOverviewPageProps> = ({
5353
text: "View asset page",
5454
icon: <ExternalLinkIcon className="size-4" />,
5555
target: "_blank",
56-
link: `https://thirdweb.com/${chainSlug}/${contract.address}`,
56+
link: `/${chainSlug}/${contract.address}`,
5757
}}
5858
trackingCategory="erc20-contract"
5959
trackingLabel="view-asset-page"

apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/public-pages/erc20/_components/claim-tokens/claim-tokens-ui.tsx

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ export function ClaimTokenCardUI(props: {
122122
}
123123

124124
async function sendAndConfirm() {
125-
const receipt = await sendClaimTx.mutateAsync(transaction);
126-
await waitForReceipt(receipt);
125+
const result = await sendClaimTx.mutateAsync(transaction);
126+
await waitForReceipt(result);
127127
}
128128

129129
setStepsUI({
@@ -154,12 +154,7 @@ export function ClaimTokenCardUI(props: {
154154
});
155155

156156
const claimParamsQuery = useQuery({
157-
queryKey: [
158-
"claim-params",
159-
props.contract.address,
160-
quantity,
161-
account?.address,
162-
],
157+
queryKey: ["claim-params", props.contract.address, account?.address],
163158
queryFn: async () => {
164159
const defaultPricing = {
165160
pricePerTokenWei: props.claimCondition.pricePerToken,
@@ -180,7 +175,7 @@ export function ClaimTokenCardUI(props: {
180175
const claimParams = await getClaimParams({
181176
contract: props.contract,
182177
to: account.address,
183-
quantity: BigInt(quantity),
178+
quantity: 1n, // not relevant
184179
type: "erc20",
185180
tokenDecimals: props.decimals,
186181
from: account.address,
@@ -204,12 +199,6 @@ export function ClaimTokenCardUI(props: {
204199

205200
const claimParamsData = claimParamsQuery.data;
206201

207-
const totalPriceInTokens = claimParamsData
208-
? Number(
209-
toTokens(claimParamsData.pricePerTokenWei, claimParamsData.decimals),
210-
) * quantity
211-
: undefined;
212-
213202
return (
214203
<div className="rounded-xl border bg-card ">
215204
<div className="border-b px-4 py-5 lg:px-5">
@@ -269,8 +258,15 @@ export function ClaimTokenCardUI(props: {
269258
<SkeletonContainer
270259
skeletonData={"0.00 ETH"}
271260
loadedData={
272-
totalPriceInTokens && claimParamsData
273-
? `${totalPriceInTokens} ${claimParamsData.symbol}`
261+
claimParamsData
262+
? `${
263+
Number(
264+
toTokens(
265+
claimParamsData.pricePerTokenWei,
266+
claimParamsData.decimals,
267+
),
268+
) * quantity
269+
} ${claimParamsData.symbol}`
274270
: undefined
275271
}
276272
render={(v) => {
@@ -286,6 +282,7 @@ export function ClaimTokenCardUI(props: {
286282
{account ? (
287283
<TransactionButton
288284
transactionCount={undefined}
285+
checkBalance={false}
289286
isLoggedIn={true}
290287
isPending={approveAndClaim.isPending}
291288
onClick={async () => {

apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/public-pages/erc20/_hooks/useTokenPriceData.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,6 @@ export function useTokenPriceData(params: {
5151
}
5252
: { type: "no-data" as const };
5353
},
54+
refetchInterval: 5000,
5455
});
5556
}

apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/public-pages/erc20/_hooks/useTokenTransfers.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,6 @@ export function useTokenTransfers(params: {
4949
const data = json.data as TokenTransfersData[];
5050
return data;
5151
},
52+
refetchInterval: 5000,
5253
});
5354
}

apps/dashboard/src/components/buttons/MismatchButton.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,20 @@ type MistmatchButtonProps = React.ComponentProps<typeof Button> & {
8080
txChainId: number;
8181
isLoggedIn: boolean;
8282
isPending: boolean;
83+
checkBalance?: boolean;
8384
};
8485

8586
export const MismatchButton = forwardRef<
8687
HTMLButtonElement,
8788
MistmatchButtonProps
8889
>((props, ref) => {
89-
const { txChainId, isLoggedIn, isPending, ...buttonProps } = props;
90+
const {
91+
txChainId,
92+
isLoggedIn,
93+
isPending,
94+
checkBalance = true,
95+
...buttonProps
96+
} = props;
9097
const account = useActiveAccount();
9198
const wallet = useActiveWallet();
9299
const activeWalletChain = useActiveWalletChain();
@@ -150,7 +157,8 @@ export const MismatchButton = forwardRef<
150157
}
151158

152159
const isBalanceRequired =
153-
wallet.id === "smart" ? false : !GAS_FREE_CHAINS.includes(txChainId);
160+
checkBalance &&
161+
(wallet.id === "smart" ? false : !GAS_FREE_CHAINS.includes(txChainId));
154162

155163
const notEnoughBalance =
156164
(txChainBalance.data?.value || 0n) === 0n && isBalanceRequired;

apps/dashboard/src/components/buttons/TransactionButton.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ type TransactionButtonProps = Omit<ButtonProps, "variant"> & {
2929
txChainID: number;
3030
variant?: "destructive" | "primary" | "default";
3131
isLoggedIn: boolean;
32+
checkBalance?: boolean;
3233
};
3334

3435
export const TransactionButton: React.FC<TransactionButtonProps> = ({
@@ -38,6 +39,7 @@ export const TransactionButton: React.FC<TransactionButtonProps> = ({
3839
txChainID,
3940
variant,
4041
isLoggedIn,
42+
checkBalance,
4143
...restButtonProps
4244
}) => {
4345
const activeWallet = useActiveWallet();
@@ -68,6 +70,7 @@ export const TransactionButton: React.FC<TransactionButtonProps> = ({
6870
txChainId={txChainID}
6971
{...restButtonProps}
7072
disabled={disabled}
73+
checkBalance={checkBalance}
7174
className={cn("relative overflow-hidden", restButtonProps.className)}
7275
style={{
7376
paddingLeft: transactionCount

0 commit comments

Comments
 (0)