Skip to content

Commit

Permalink
fix: pass failed description, styles
Browse files Browse the repository at this point in the history
  • Loading branch information
jurevans committed Sep 10, 2024
1 parent b40a331 commit dbe729e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
19 changes: 14 additions & 5 deletions apps/namadillo/src/App/Common/Toast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { useAtomValue, useSetAtom } from "jotai";
import { useCallback, useEffect, useRef, useState } from "react";
import { FaCheck, FaTimes } from "react-icons/fa";
import { FaRegHourglassHalf, FaXmark } from "react-icons/fa6";
import { GoAlert } from "react-icons/go";
import { ToastNotification } from "types";

export const Toasts = (): JSX.Element => {
Expand Down Expand Up @@ -113,6 +114,11 @@ const Toast = ({
<FaRegHourglassHalf />
</i>
)}
{notification.type === "partialSuccess" && (
<i className="text-2xl">
<GoAlert />
</i>
)}
</span>
<Stack
gap={0.5}
Expand All @@ -137,11 +143,14 @@ const Toast = ({
</div>
)}
{notification.failedDetails && (viewDetails || forceDetailsOpen) && (
<div className="w-full text-xs text-red block">
<br />
<div>The following Tx were not applied:</div>
{notification.failedDetails}
</div>
<>
<div className="w-full text-xs text-white block my-4">
<span className="font-bold">
{notification.failedDescription}
</span>
{notification.failedDetails}
</div>
</>
)}
</Stack>
<i
Expand Down
9 changes: 8 additions & 1 deletion apps/namadillo/src/hooks/useTransactionNotifications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ export const useTransactionNotifications = (): void => {
succeeded
</>
),
failedDescription: (
<>The following staking transactions were not applied:</>
),
details: getAmountByValidatorList(e.detail.data),
failedDetails: getAmountByValidatorList(e.detail.failedData || []),
type: "partialSuccess",
Expand Down Expand Up @@ -149,9 +152,12 @@ export const useTransactionNotifications = (): void => {
title: "Some Unstake transactions failed",
description: (
<>
Your unbonding of <NamCurrency amount={total} /> has succeeded
Your unstaking of <NamCurrency amount={total} /> has succeeded
</>
),
failedDescription: (
<>The following unstaking transactions were not applied:</>
),
details: getAmountByValidatorList(e.detail.data),
failedDetails:
e.detail.failedData ?
Expand Down Expand Up @@ -246,6 +252,7 @@ export const useTransactionNotifications = (): void => {
has succeeded
</>
),
failedDescription: <>The following redelegations were not applied:</>,
details: getReDelegateDetailList(e.detail.data),
failedDetails:
e.detail.failedData ?
Expand Down
3 changes: 1 addition & 2 deletions apps/namadillo/src/lib/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
} from "@namada/types";
import { getIndexerApi } from "atoms/api";
import { chainParametersAtom } from "atoms/chain";
import BigNumber from "bignumber.js";
import { getSdkInstance } from "hooks";
import invariant from "invariant";
import { getDefaultStore } from "jotai";
Expand Down Expand Up @@ -59,7 +58,7 @@ const getTxProps = (
return {
token: chain.nativeTokenAddress,
feeAmount: gasConfig.gasPrice,
gasLimit: BigNumber(200),
gasLimit: gasConfig.gasLimit,
chainId: chain.chainId,
publicKey: account.publicKey!,
memo: "",
Expand Down
1 change: 1 addition & 0 deletions apps/namadillo/src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ export type ToastNotification = {
type: "pending" | "success" | "partialSuccess" | "error";
title: React.ReactNode;
description: React.ReactNode;
failedDescription?: React.ReactNode;
details?: React.ReactNode;
failedDetails?: React.ReactNode;
timeout?: number;
Expand Down

0 comments on commit dbe729e

Please sign in to comment.