@@ -13,13 +13,35 @@ import Icon from 'react-native-vector-icons/Feather';
1313import { blockchains } from '../../storage/blockchains' ;
1414import type { cryptos } from '../../types' ;
1515
16+ /**
17+ * Format a base-unit amount (satoshis/wei) to human-readable using chain decimals.
18+ */
19+ function formatAmount ( amount : string , decimals : number ) : string {
20+ try {
21+ const raw = BigInt ( amount ) ;
22+ const divisor = 10n ** BigInt ( decimals ) ;
23+ const wholePart = raw / divisor ;
24+ const fracPart = raw % divisor ;
25+ if ( fracPart === 0n ) {
26+ return wholePart . toString ( ) ;
27+ }
28+ const fracStr = fracPart . toString ( ) . padStart ( decimals , '0' ) ;
29+ const trimmed = fracStr . replace ( / 0 + $ / , '' ) ;
30+ return `${ wholePart . toString ( ) } .${ trimmed } ` ;
31+ } catch {
32+ return amount ;
33+ }
34+ }
35+
1636interface VaultSignRequestProps {
1737 activityStatus : boolean ;
1838 recipients : Array < { address : string ; amount : string ; label ?: string } > ;
1939 fee : string ;
2040 feeLabel : string ;
2141 memo ?: string ;
2242 chain : string ;
43+ vaultName ?: string ;
44+ orgName ?: string ;
2345 actionStatus : ( status : boolean ) => void ;
2446}
2547
@@ -30,6 +52,8 @@ const VaultSignRequest: React.FC<VaultSignRequestProps> = ({
3052 feeLabel,
3153 memo,
3254 chain,
55+ vaultName,
56+ orgName,
3357 actionStatus,
3458} ) => {
3559 const { t } = useTranslation ( [ 'home' , 'common' ] ) ;
@@ -39,6 +63,8 @@ const VaultSignRequest: React.FC<VaultSignRequestProps> = ({
3963 const chainDisplay = chainConfig
4064 ? `${ chainConfig . name } (${ chainConfig . symbol } )`
4165 : chain ;
66+ const chainDecimals = chainConfig ?. decimals ?? 8 ;
67+ const chainSymbol = chainConfig ?. symbol ?? chain . toUpperCase ( ) ;
4268
4369 const approve = ( ) => {
4470 console . log ( 'Approve vault signing request' ) ;
@@ -98,6 +124,46 @@ const VaultSignRequest: React.FC<VaultSignRequestProps> = ({
98124 { t ( 'home:vault_sign_request_info' ) }
99125 </ Text >
100126
127+ { /* Vault & Org Info */ }
128+ { ( vaultName || orgName ) && (
129+ < View
130+ style = { [
131+ Gutters . regularTMargin ,
132+ Gutters . regularLMargin ,
133+ Gutters . regularRMargin ,
134+ {
135+ backgroundColor : Colors . inputBackground ,
136+ borderRadius : 8 ,
137+ padding : 12 ,
138+ width : '90%' ,
139+ borderWidth : 1 ,
140+ borderColor : Colors . textGray200 ,
141+ } ,
142+ ] }
143+ >
144+ { vaultName && (
145+ < View style = { { marginBottom : orgName ? 4 : 0 } } >
146+ < Text style = { [ Fonts . textTiny , { color : Colors . textGray400 } ] } >
147+ { t ( 'home:vault' ) }
148+ </ Text >
149+ < Text style = { [ Fonts . textSmall , Fonts . textBold ] } >
150+ { vaultName }
151+ </ Text >
152+ </ View >
153+ ) }
154+ { orgName && (
155+ < View >
156+ < Text style = { [ Fonts . textTiny , { color : Colors . textGray400 } ] } >
157+ { t ( 'home:organization' ) }
158+ </ Text >
159+ < Text style = { [ Fonts . textSmall , Fonts . textBold ] } >
160+ { orgName }
161+ </ Text >
162+ </ View >
163+ ) }
164+ </ View >
165+ ) }
166+
101167 { /* Chain Info */ }
102168 < View
103169 style = { [
@@ -196,7 +262,7 @@ const VaultSignRequest: React.FC<VaultSignRequestProps> = ({
196262 { marginTop : 2 } ,
197263 ] }
198264 >
199- { recipient . amount }
265+ { formatAmount ( recipient . amount , chainDecimals ) } { chainSymbol }
200266 </ Text >
201267 </ View >
202268 ) ) }
@@ -211,7 +277,7 @@ const VaultSignRequest: React.FC<VaultSignRequestProps> = ({
211277 { color : Colors . textGray400 } ,
212278 ] }
213279 >
214- { t ( 'home:vault_sign_fee' ) } : { fee } ( { feeLabel } )
280+ { t ( 'home:vault_sign_fee' ) } : { formatAmount ( fee , chainDecimals ) } { chainSymbol }
215281 </ Text >
216282 </ View >
217283
0 commit comments