diff --git a/src/pages/ClaimPage/SuccessClaim.tsx b/src/pages/ClaimPage/SuccessClaim.tsx
index 75d67096..300e116d 100644
--- a/src/pages/ClaimPage/SuccessClaim.tsx
+++ b/src/pages/ClaimPage/SuccessClaim.tsx
@@ -1,22 +1,31 @@
import { Tooltip, formatAmount } from '@massalabs/react-ui-kit';
import { SuccessCheck } from '@/components';
import { LinkExplorer } from '@/components/LinkExplorer';
+import { CHAIN_ID_TO_SERVICE_FEE } from '@/const';
import Intl from '@/i18n/i18n';
import { BurnRedeemOperation } from '@/store/operationStore';
+import { getAmountToReceive } from '@/utils/utils';
interface SuccessClaimProps {
operation: BurnRedeemOperation;
- symbol?: string;
- decimals?: number;
+ symbol: string;
+ decimals: number;
}
-export function SuccessClaim(args: SuccessClaimProps) {
- const { operation, symbol, decimals } = args;
- let { amountFormattedFull, amountFormattedPreview } = formatAmount(
- operation.amount,
- decimals,
+export function SuccessClaim(props: SuccessClaimProps) {
+ const { operation, symbol, decimals } = props;
+
+ const serviceFee = CHAIN_ID_TO_SERVICE_FEE[operation.evmChainId];
+
+ // calculates amount received
+ const receivedAmount = getAmountToReceive(
+ BigInt(operation.amount),
+ serviceFee,
);
+ // format amount received
+ const { preview, full } = formatAmount(receivedAmount, decimals);
+
return (
diff --git a/src/pages/HistoryPage/Amount.tsx b/src/pages/HistoryPage/Amount.tsx
deleted file mode 100644
index e1201b01..00000000
--- a/src/pages/HistoryPage/Amount.tsx
+++ /dev/null
@@ -1,27 +0,0 @@
-import { formatAmount, Tooltip } from '@massalabs/react-ui-kit';
-
-interface AmountProps {
- amount?: string;
- symbol?: string;
- decimals?: number;
-}
-
-export function Amount(props: AmountProps) {
- const { amount, symbol = '', decimals = 9 } = props;
-
- let amountFormattedPreview = '-';
- let amountFormattedFull = '-';
-
- if (amount !== undefined) {
- const formattedResult = formatAmount(amount, decimals);
- amountFormattedPreview = formattedResult.amountFormattedPreview;
- amountFormattedFull = formattedResult.amountFormattedFull;
- }
-
- return (
-
- {amountFormattedPreview} {symbol}
-
-
- );
-}
diff --git a/src/pages/HistoryPage/Operation.tsx b/src/pages/HistoryPage/Operation.tsx
index f1768133..c2f18e31 100644
--- a/src/pages/HistoryPage/Operation.tsx
+++ b/src/pages/HistoryPage/Operation.tsx
@@ -1,15 +1,14 @@
import { useMemo } from 'react';
-import { Amount } from './Amount';
import { Emitter } from './Emitter';
+import { Received } from './Received';
import { Recipient } from './Recipient';
+import { Sent } from './Sent';
import { ShowStatus } from './ShowStatus';
import { wmasDecimals, wmasSymbol } from '../DaoPage';
import { LinkExplorer } from '@/components/LinkExplorer';
-import { ServiceFeeTooltip } from '@/components/ServiceFeeTooltip/ServiceFeeTooltip';
import { MASSA_TOKEN } from '@/const';
import { useTokenStore } from '@/store/tokenStore';
import { Entities, OperationHistoryItem } from '@/utils/lambdaApi';
-import { retrievePercent } from '@/utils/utils';
function formatApiCreationTime(inputTimestamp: string) {
const dateObject = new Date(inputTimestamp);
@@ -20,23 +19,23 @@ interface OperationProps {
}
export function Operation(props: OperationProps) {
- const { operation: op } = props;
+ const { operation } = props;
const { tokens } = useTokenStore();
const memoizedStatusComponent = useMemo(() => {
- return
;
- }, [op.historyStatus]);
+ return
;
+ }, [operation.historyStatus]);
function getTokenInfo() {
- const token = tokens.find((t) => t.evmToken === op.evmToken);
- if (op.entity === Entities.ReleaseMAS) {
+ const token = tokens.find((t) => t.evmToken === operation.evmToken);
+ if (operation.entity === Entities.ReleaseMAS) {
return {
sentSymbol: wmasSymbol,
receivedSymbol: MASSA_TOKEN,
tokenDecimals: wmasDecimals,
};
- } else if (op.entity === Entities.Lock) {
+ } else if (operation.entity === Entities.Lock) {
return {
sentSymbol: token?.symbolEVM,
receivedSymbol: token?.symbol,
@@ -54,31 +53,28 @@ export function Operation(props: OperationProps) {
return (
-
-
+
+
- {formatApiCreationTime(op.createdAt)}
+ {formatApiCreationTime(operation.createdAt)}
{/* sent */}
-
+
{/* received */}
-
+
{memoizedStatusComponent}
diff --git a/src/pages/HistoryPage/Received.tsx b/src/pages/HistoryPage/Received.tsx
new file mode 100644
index 00000000..b5526475
--- /dev/null
+++ b/src/pages/HistoryPage/Received.tsx
@@ -0,0 +1,35 @@
+import { formatAmount } from '@massalabs/react-ui-kit';
+import { ServiceFeeTooltip } from '@/components/ServiceFeeTooltip/ServiceFeeTooltip';
+import { retrievePercent } from '@/utils/utils';
+
+interface AmountProps {
+ inputAmount: string;
+ outputAmount?: string;
+ symbol?: string;
+ decimals?: number;
+}
+
+export function Received(props: AmountProps) {
+ const { inputAmount, outputAmount, symbol = '', decimals = 9 } = props;
+
+ let outputPreview = '-';
+ let outputFull = '-';
+
+ if (outputAmount !== undefined && outputAmount !== null) {
+ const formattedResult = formatAmount(outputAmount, decimals);
+ outputPreview = formattedResult.preview;
+ outputFull = formattedResult.full;
+ }
+
+ return (
+
+ {outputPreview} {symbol}
+
+
+ );
+}
diff --git a/src/pages/HistoryPage/Sent.tsx b/src/pages/HistoryPage/Sent.tsx
new file mode 100644
index 00000000..3c0342c8
--- /dev/null
+++ b/src/pages/HistoryPage/Sent.tsx
@@ -0,0 +1,27 @@
+import { formatAmount, Tooltip } from '@massalabs/react-ui-kit';
+
+interface AmountProps {
+ amount?: string;
+ symbol?: string;
+ decimals?: number;
+}
+
+export function Sent(props: AmountProps) {
+ const { amount, symbol = '', decimals = 9 } = props;
+
+ let preview = '-';
+ let full = '-';
+
+ if (amount !== undefined && amount !== null) {
+ const formattedResult = formatAmount(amount, decimals);
+ preview = formattedResult.preview;
+ full = formattedResult.full;
+ }
+
+ return (
+
+ {preview} {symbol}
+
+
+ );
+}
diff --git a/src/pages/HistoryPage/index.ts b/src/pages/HistoryPage/index.ts
index 8a7c4f15..a6f219f1 100644
--- a/src/pages/HistoryPage/index.ts
+++ b/src/pages/HistoryPage/index.ts
@@ -5,3 +5,5 @@ export * from './Operation';
export * from './ShowStatus';
export * from './Operation';
export * from './Recipient';
+export * from './Sent';
+export * from './Received';
diff --git a/src/pages/IndexPage/Layouts/BridgeRedeemLayout/BoxLayoutComponents/EvmBoxComponents.tsx b/src/pages/IndexPage/Layouts/BridgeRedeemLayout/BoxLayoutComponents/EvmBoxComponents.tsx
index a23116da..d99541c7 100644
--- a/src/pages/IndexPage/Layouts/BridgeRedeemLayout/BoxLayoutComponents/EvmBoxComponents.tsx
+++ b/src/pages/IndexPage/Layouts/BridgeRedeemLayout/BoxLayoutComponents/EvmBoxComponents.tsx
@@ -29,8 +29,8 @@ export function EVMHeader() {
const isMainnet = getIsMainnet();
function handleChangeEvmNetwork(selectedEvm: SupportedEvmBlockchain) {
- setInputAmount('');
- setOutputAmount('');
+ setInputAmount(undefined);
+ setOutputAmount(undefined);
setSelectedEvm(selectedEvm);
resetSelectedToken();
}
diff --git a/src/pages/IndexPage/Layouts/BridgeRedeemLayout/BoxLayoutComponents/TokenBalance.tsx b/src/pages/IndexPage/Layouts/BridgeRedeemLayout/BoxLayoutComponents/TokenBalance.tsx
index b3ab18aa..fb53f8a4 100644
--- a/src/pages/IndexPage/Layouts/BridgeRedeemLayout/BoxLayoutComponents/TokenBalance.tsx
+++ b/src/pages/IndexPage/Layouts/BridgeRedeemLayout/BoxLayoutComponents/TokenBalance.tsx
@@ -21,7 +21,7 @@ export function TokenBalance() {
symbol = selectedToken?.symbolEVM;
}
- let { amountFormattedPreview, amountFormattedFull } = formatAmount(
+ let { preview, full } = formatAmount(
amount ? amount.toString() : '0',
decimals,
);
@@ -36,8 +36,8 @@ export function TokenBalance() {
) : (
- {amountFormattedPreview}
-
+ {preview}
+
)}
diff --git a/src/pages/IndexPage/Layouts/BridgeRedeemLayout/BridgeRedeemLayout.tsx b/src/pages/IndexPage/Layouts/BridgeRedeemLayout/BridgeRedeemLayout.tsx
index 81fd29e7..49f1755c 100644
--- a/src/pages/IndexPage/Layouts/BridgeRedeemLayout/BridgeRedeemLayout.tsx
+++ b/src/pages/IndexPage/Layouts/BridgeRedeemLayout/BridgeRedeemLayout.tsx
@@ -1,14 +1,8 @@
import { useState } from 'react';
-
-import {
- Button,
- Money,
- formatAmount,
- formatAmountToDisplay,
- removeTrailingZeros,
-} from '@massalabs/react-ui-kit';
+import { Button, Money, formatAmount } from '@massalabs/react-ui-kit';
import Big from 'big.js';
import { FiRepeat } from 'react-icons/fi';
+import { parseUnits } from 'viem';
import { useAccount } from 'wagmi';
import { boxLayout } from './BoxLayout';
import { FeesEstimation } from './FeesEstimation';
@@ -57,7 +51,11 @@ export function BridgeRedeemLayout(props: BridgeRedeemProps) {
setInputAmount,
setOutputAmount,
} = useOperationStore();
+
+ const [inputField, setInputField] = useState