1
1
import { CopyToClipboardControl , Tooltip } from "@namada/components" ;
2
2
import { shortenAddress } from "@namada/utils" ;
3
+ import { FiatCurrency } from "App/Common/FiatCurrency" ;
3
4
import { TokenCurrency } from "App/Common/TokenCurrency" ;
4
5
import { AssetImage } from "App/Transfer/AssetImage" ;
5
6
import { isShieldedAddress , isTransparentAddress } from "App/Transfer/common" ;
7
+ import { namadaRegistryChainAssetsMapAtom } from "atoms/integrations" ;
8
+
9
+ import { tokenPricesFamily } from "atoms/prices/atoms" ;
10
+ import BigNumber from "bignumber.js" ;
6
11
import clsx from "clsx" ;
12
+ import { useAtomValue } from "jotai" ;
7
13
import { FaLock } from "react-icons/fa" ;
8
14
import {
9
15
IoCheckmarkCircleOutline ,
@@ -27,6 +33,25 @@ const getTitle = (transferTransaction: TransferTransactionData): string => {
27
33
export const LocalStorageTransactionCard = ( {
28
34
transaction,
29
35
} : TransactionCardProps ) : JSX . Element => {
36
+ const namadaAssetsMap = useAtomValue ( namadaRegistryChainAssetsMapAtom ) ;
37
+ const namadaAsset =
38
+ namadaAssetsMap . data &&
39
+ Object . values ( namadaAssetsMap . data ) . find (
40
+ ( namadaAsset ) => namadaAsset . symbol === transaction . asset . symbol
41
+ ) ;
42
+
43
+ // Use the Namada asset address if available, otherwise try the original asset address
44
+ const assetAddress = namadaAsset ?. address || transaction . asset . address ;
45
+
46
+ const tokenPrices = useAtomValue (
47
+ tokenPricesFamily ( assetAddress ? [ assetAddress ] : [ ] )
48
+ ) ;
49
+ const tokenPrice = assetAddress && tokenPrices . data ?. [ assetAddress ] ;
50
+
51
+ // Ensure displayAmount is a BigNumber before performing calculations
52
+ const displayAmount = BigNumber ( transaction . displayAmount ) ;
53
+ const dollarAmount = tokenPrice && displayAmount . multipliedBy ( tokenPrice ) ;
54
+
30
55
const renderKeplrIcon = ( address : string ) : JSX . Element | null => {
31
56
if ( isShieldedAddress ( address ) ) return null ;
32
57
if ( isTransparentAddress ( address ) ) return null ;
@@ -94,25 +119,22 @@ export const LocalStorageTransactionCard = ({
94
119
< div className = "aspect-square w-10 h-10" >
95
120
< AssetImage asset = { transaction . asset } />
96
121
</ div >
97
- < TokenCurrency
98
- className = "text-white mt-1 ml-2"
99
- amount = { transaction . displayAmount }
100
- symbol = { transaction . asset . symbol }
101
- />
122
+ < div className = "ml-2 flex flex-col" >
123
+ < TokenCurrency
124
+ className = "text-white"
125
+ amount = { displayAmount }
126
+ symbol = { transaction . asset . symbol }
127
+ />
128
+ { dollarAmount && (
129
+ < FiatCurrency
130
+ className = "text-neutral-400 text-sm"
131
+ amount = { dollarAmount }
132
+ />
133
+ ) }
134
+ </ div >
102
135
</ div >
103
136
< div className = "flex flex-col" >
104
- < h4
105
- className = {
106
- (
107
- isShieldedAddress ( sender ?? "" ) ||
108
- transaction . type === "ShieldedToIbc"
109
- ) ?
110
- "text-yellow"
111
- : ""
112
- }
113
- >
114
- From
115
- </ h4 >
137
+ < h4 className = "text-neutral-400" > From</ h4 >
116
138
< h4
117
139
className = {
118
140
(
@@ -139,9 +161,7 @@ export const LocalStorageTransactionCard = ({
139
161
</ div >
140
162
141
163
< div className = "flex flex-col relative" >
142
- < h4 className = { isShieldedAddress ( receiver ?? "" ) ? "text-yellow" : "" } >
143
- To
144
- </ h4 >
164
+ < h4 className = "text-neutral-400" > To</ h4 >
145
165
< div className = "flex items-center justify-between" >
146
166
< h4
147
167
className = { isShieldedAddress ( receiver ?? "" ) ? "text-yellow" : "" }
0 commit comments