From e6d331f116ab7f2fcbe9400e733f74be86dc9eac Mon Sep 17 00:00:00 2001 From: Pavlo Syrotyna Date: Thu, 27 Feb 2025 14:44:19 +0200 Subject: [PATCH 1/2] fix(suite): hide solana unstake amount --- .../suite/src/components/suite/UnstakingTxAmount.tsx | 9 +++++++-- .../Detail/AdvancedTxDetails/AmountDetails.tsx | 3 ++- .../TransactionTarget/TransactionTarget.tsx | 6 +++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/packages/suite/src/components/suite/UnstakingTxAmount.tsx b/packages/suite/src/components/suite/UnstakingTxAmount.tsx index 84836814d3b..34101b094be 100644 --- a/packages/suite/src/components/suite/UnstakingTxAmount.tsx +++ b/packages/suite/src/components/suite/UnstakingTxAmount.tsx @@ -14,14 +14,19 @@ interface UnstakingTxAmountProps { } export const UnstakingTxAmount = ({ transaction }: UnstakingTxAmountProps) => { - const { ethereumSpecific, solanaSpecific, symbol, amount } = transaction; + const { ethereumSpecific, solanaSpecific, symbol } = transaction; const solanaStakeType = solanaSpecific?.stakeType; // Handle Solana unstake transaction if (solanaStakeType === 'unstake') { + const unstakeAmount = solanaSpecific?.unstakeAmount ?? '0'; + return ( - + ); } diff --git a/packages/suite/src/components/suite/modals/ReduxModal/UserContextModal/TxDetailModal/Detail/AdvancedTxDetails/AmountDetails.tsx b/packages/suite/src/components/suite/modals/ReduxModal/UserContextModal/TxDetailModal/Detail/AdvancedTxDetails/AmountDetails.tsx index b4893be354e..e306003e426 100644 --- a/packages/suite/src/components/suite/modals/ReduxModal/UserContextModal/TxDetailModal/Detail/AdvancedTxDetails/AmountDetails.tsx +++ b/packages/suite/src/components/suite/modals/ReduxModal/UserContextModal/TxDetailModal/Detail/AdvancedTxDetails/AmountDetails.tsx @@ -46,7 +46,8 @@ export const AmountDetails = ({ tx, isTestnet }: AmountDetailsProps) => { const selectedAccount = useSelector(state => state.wallet.selectedAccount); const txSignature = tx.ethereumSpecific?.parsedData?.methodId; - const isStakeTypeTxNoAmount = isStakeTypeTx(txSignature) && amount.eq(0); + const isStakeType = isStakeTypeTx(txSignature) || tx?.solanaSpecific?.stakeType; // ethereum or solana staking tx + const isStakeTypeTxNoAmount = isStakeType && amount.eq(0); return ( diff --git a/packages/suite/src/components/wallet/TransactionItem/TransactionTarget/TransactionTarget.tsx b/packages/suite/src/components/wallet/TransactionItem/TransactionTarget/TransactionTarget.tsx index 2f4ec85056a..3303cff579e 100644 --- a/packages/suite/src/components/wallet/TransactionItem/TransactionTarget/TransactionTarget.tsx +++ b/packages/suite/src/components/wallet/TransactionItem/TransactionTarget/TransactionTarget.tsx @@ -66,8 +66,12 @@ export const TransactionTarget = ({ selectHistoricFiatRatesByTimestamp(state, fiatRateKey, transaction.blockTime as Timestamp), ); const labelingValueBeingEdited = useSelector(selectLabelingValueBeingEdited); + const isSolanaUnstakeTx = transaction?.solanaSpecific?.stakeType === 'unstake'; const amount = useMemo(() => { + // hide amount for solana unstake transactions + if (isSolanaUnstakeTx) return null; + switch (type) { case 'target': return getTargetAmount(payload, transaction); @@ -76,7 +80,7 @@ export const TransactionTarget = ({ case 'token': return formatAmount(payload.amount, payload.decimals); } - }, [type, payload, transaction]); + }, [type, payload, transaction, isSolanaUnstakeTx]); const operation = getTxOperation(type === 'target' ? transaction.type : payload.type); From f0894160ba2dce01f70b3c1e56715179e6c0ab0c Mon Sep 17 00:00:00 2001 From: Pavlo Syrotyna Date: Thu, 27 Feb 2025 14:46:33 +0200 Subject: [PATCH 2/2] fix(blockchain-link): handle solana unstake transactions amount correctly --- packages/blockchain-link-types/src/common.ts | 1 + packages/blockchain-link-utils/src/solana.ts | 18 +++++++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/packages/blockchain-link-types/src/common.ts b/packages/blockchain-link-types/src/common.ts index f4eedb3290d..c19d4825d16 100644 --- a/packages/blockchain-link-types/src/common.ts +++ b/packages/blockchain-link-types/src/common.ts @@ -154,6 +154,7 @@ export interface Transaction { solanaSpecific?: { status: 'confirmed'; stakeType?: StakeType; + unstakeAmount?: string; }; details: TransactionDetail; vsize?: number; diff --git a/packages/blockchain-link-utils/src/solana.ts b/packages/blockchain-link-utils/src/solana.ts index f2151e14480..7934a9d94a6 100644 --- a/packages/blockchain-link-utils/src/solana.ts +++ b/packages/blockchain-link-utils/src/solana.ts @@ -737,13 +737,16 @@ export const transformTransaction = ( const targets = getTargets(nativeEffects, txType, accountAddress); - const amount = - stakeType === 'unstake' - ? getUnstakeAmount(tx) - : getAmount( - nativeEffects.find(({ address }) => address === accountAddress), - type, - ); + const isUnstakeTx = stakeType === 'unstake'; + + const amount = isUnstakeTx + ? '0' // amount for unstake transactions should be hidden + : getAmount( + nativeEffects.find(({ address }) => address === accountAddress), + type, + ); + + const unstakeAmount = isUnstakeTx ? getUnstakeAmount(tx) : undefined; const details = getDetails(tx, nativeEffects, accountAddress, type); @@ -763,6 +766,7 @@ export const transformTransaction = ( solanaSpecific: { status: 'confirmed', stakeType, + unstakeAmount, }, }; };