@@ -58,6 +58,7 @@ export const AccountScreen: React.FC<Props> = ({ navigation }) => {
58
58
const [ did , setDID ] = useState ( null )
59
59
const [ poolOptions , setPoolOptions ] = useState ( [ ] )
60
60
const [ cid , setCid ] = useState < string | null > ( null ) ;
61
+ const [ pk , setPk ] = useState < string | null > ( null ) ;
61
62
const getCid = async ( ) => {
62
63
try {
63
64
const cid_ = await AsyncStorage . getItem ( '@lastUploadedCid' ) ;
@@ -69,6 +70,18 @@ export const AccountScreen: React.FC<Props> = ({ navigation }) => {
69
70
}
70
71
} ;
71
72
73
+ const getPk = async ( ) => {
74
+ try {
75
+ const _pk = await helper . getMyDIDKeyPair ( dIDCredentials . username , dIDCredentials . password ) ;
76
+ const identity = _pk . secretKey . toString ( ) ;
77
+ if ( identity ) {
78
+ setPk ( identity )
79
+ }
80
+ } catch ( e ) {
81
+ // error reading value
82
+ }
83
+ } ;
84
+
72
85
useEffect ( ( ) => {
73
86
if ( ! fulaPeerId ) {
74
87
loadPeerId ( )
@@ -407,6 +420,32 @@ export const AccountScreen: React.FC<Props> = ({ navigation }) => {
407
420
</ ListItem . Content >
408
421
</ ListItem >
409
422
) ;
423
+
424
+ const copyToClipboardPrivateKey = ( pkValue : string ) => {
425
+ Clipboard . setString ( pkValue ) ;
426
+ Toast . show ( {
427
+ type : 'success' ,
428
+ text1 : 'Your Private Key copied to the clipboard!' ,
429
+ position : 'bottom' ,
430
+ bottomOffset : 0 ,
431
+ } ) ;
432
+ } ;
433
+ const renderPrivateKeyListItem = ( ) => (
434
+ < ListItem onPress = { ( ) => cid && copyToClipboardPrivateKey ( pk ) } containerStyle = { { width : '100%' } } >
435
+ < ListItem . Content >
436
+ < View style = { { flexDirection : 'row' , justifyContent : 'space-between' , alignItems : 'center' } } >
437
+ < View style = { { flexDirection : 'row' , alignItems : 'center' } } >
438
+ < Card . Title style = { { textAlign : 'left' , paddingRight : 10 } } >
439
+ Private Key
440
+ </ Card . Title >
441
+ < Icon name = "content-copy" type = "material-community" onPress = { ( ) => pk && copyToClipboardPrivateKey ( pk ) } />
442
+ </ View >
443
+ < Icon name = "refresh" type = "material-community" onPress = { getPk } />
444
+ </ View >
445
+ < ListItem . Subtitle > { pk || 'No Private Key Available' } </ ListItem . Subtitle >
446
+ </ ListItem . Content >
447
+ </ ListItem >
448
+ ) ;
410
449
return (
411
450
< Screen preset = "scroll" style = { styles . screen } >
412
451
{ renderHeader ( ) }
@@ -464,6 +503,7 @@ export const AccountScreen: React.FC<Props> = ({ navigation }) => {
464
503
</ ListItem . Content >
465
504
</ ListItem >
466
505
{ renderCIDListItem ( ) }
506
+ { renderPrivateKeyListItem ( ) }
467
507
< ListItem
468
508
onPress = { ( ) =>
469
509
fulaAccount
0 commit comments