Skip to content

Commit e40d733

Browse files
committed
adde Private Key filed under account
1 parent 15daacd commit e40d733

File tree

2 files changed

+44
-2
lines changed

2 files changed

+44
-2
lines changed

app/screens/account/account-screen.tsx

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export const AccountScreen: React.FC<Props> = ({ navigation }) => {
5858
const [did, setDID] = useState(null)
5959
const [poolOptions, setPoolOptions] = useState([])
6060
const [cid, setCid] = useState<string | null>(null);
61+
const [pk, setPk] = useState<string | null>(null);
6162
const getCid = async () => {
6263
try {
6364
const cid_ = await AsyncStorage.getItem('@lastUploadedCid');
@@ -69,6 +70,18 @@ export const AccountScreen: React.FC<Props> = ({ navigation }) => {
6970
}
7071
};
7172

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+
7285
useEffect(() => {
7386
if (!fulaPeerId) {
7487
loadPeerId()
@@ -407,6 +420,32 @@ export const AccountScreen: React.FC<Props> = ({ navigation }) => {
407420
</ListItem.Content>
408421
</ListItem>
409422
);
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+
);
410449
return (
411450
<Screen preset="scroll" style={styles.screen}>
412451
{renderHeader()}
@@ -464,6 +503,7 @@ export const AccountScreen: React.FC<Props> = ({ navigation }) => {
464503
</ListItem.Content>
465504
</ListItem>
466505
{renderCIDListItem()}
506+
{renderPrivateKeyListItem()}
467507
<ListItem
468508
onPress={() =>
469509
fulaAccount

app/services/sync-service.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,12 @@ const uploadAssetBackgroundTask = async (taskParameters?: TaskParams) => {
7979
if (!api) {
8080
api = await chainApi.init()
8181
fulaAccount = await chainApi.getAccountIdFromSeed(fulaAccountSeed)
82-
while (gasBalance <= 1000000) {
82+
while (gasBalance <= 10000000) {
8383
let gasBalanceStr = await chainApi.checkAccountBalance(api, fulaAccount)
8484
if (gasBalanceStr) {
8585
gasBalance = parseInt(gasBalanceStr)
8686
}
87-
if (gasBalance <= 1000000){
87+
if (gasBalance <= 10000000){
8888
await BackgroundJob.updateNotification({
8989
taskTitle: `Waiting for enough gas balance in ${fulaAccount}`,
9090
taskDesc: `Uploads are resumed as soon as gas balance is enough ...`,
@@ -521,6 +521,8 @@ export const initFula = async (
521521
}
522522
console.log('blox Address created: '+ bloxAddr)
523523
}
524+
console.log('identity:')
525+
console.log(identity)
524526
const fulaInit = await fula.init(
525527
identity, //bytes of the privateKey of did identity in string format
526528
storePath, // leave empty to use the default temp one

0 commit comments

Comments
 (0)