-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #183 from VerusCoin/dev
v1.0.18
- Loading branch information
Showing
52 changed files
with
2,082 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 111 additions & 0 deletions
111
src/components/SendModal/RecoverIdentity/RecoverIdentityConfirm/RecoverIdentityConfirm.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
import React, {useState, useCallback} from 'react'; | ||
import {useDispatch, useSelector} from 'react-redux'; | ||
import {Alert} from 'react-native'; | ||
import { | ||
SEND_MODAL_ENCRYPTED_IDENTITY_SEED, | ||
SEND_MODAL_FORM_STEP_FORM, | ||
SEND_MODAL_FORM_STEP_RESULT, | ||
SEND_MODAL_SYSTEM_ID, | ||
} from '../../../../utils/constants/sendModal'; | ||
import {RecoverIdentityConfirmRender} from './RecoverIdentityConfirm.render'; | ||
import { pushUpdateIdentityTx } from '../../../../utils/api/channels/verusid/requests/updateIdentity'; | ||
import { decryptkey } from '../../../../utils/seedCrypt'; | ||
import { deriveKeyPair } from '../../../../utils/keys'; | ||
import { ELECTRUM } from '../../../../utils/constants/intervalConstants'; | ||
import { coinsList } from '../../../../utils/CoinData/CoinsList'; | ||
|
||
const RecoverIdentityConfirm = props => { | ||
const [targetId, setTargetId] = useState(props.route.params.targetId); | ||
const [recoveryId, setRecoveryId] = useState(props.route.params.recoveryId); | ||
const [ownedAddress, setOwnedAddress] = useState(props.route.params.ownedAddress); | ||
const [recoverableByUser, setRecoverableByUser] = useState(props.route.params.recoverableByUser); | ||
const [recoveryResult, setRecoveryResult] = useState(props.route.params.recoveryResult); | ||
const [revocationAddr, setRevocationAddr] = useState(props.route.params.revocationAddr); | ||
const [recoveryAddr, setRecoveryAddr] = useState(props.route.params.recoveryAddr); | ||
const [primaryAddr, setPrimaryAddr] = useState(props.route.params.primaryAddr); | ||
const [privateAddr, setPrivateAddr] = useState(props.route.params.privateAddr); | ||
|
||
const [friendlyNames, setFriendlyNames] = useState( | ||
props.route.params.friendlyNames, | ||
); | ||
const instanceKey = useSelector(state => state.authentication.instanceKey); | ||
|
||
const dispatch = useDispatch(); | ||
const sendModal = useSelector(state => state.sendModal); | ||
const activeAccount = useSelector( | ||
state => state.authentication.activeAccount, | ||
); | ||
const activeCoinList = useSelector(state => state.coins.activeCoinList); | ||
|
||
const goBack = useCallback(() => { | ||
props.setModalHeight(); | ||
props.navigation.navigate(SEND_MODAL_FORM_STEP_FORM); | ||
}, [props]); | ||
|
||
const getSpendingKey = useCallback(async () => { | ||
const encryptedSeed = sendModal.data[SEND_MODAL_ENCRYPTED_IDENTITY_SEED]; | ||
const seed = decryptkey(instanceKey, encryptedSeed); | ||
|
||
if (!seed) throw new Error("Unable to decrypt seed"); | ||
|
||
const keyObj = await deriveKeyPair(seed, coinsList.VRSC, ELECTRUM); | ||
|
||
return keyObj.privKey; | ||
}, []); | ||
|
||
const submitData = useCallback(async () => { | ||
await props.setLoading(true); | ||
await props.setPreventExit(true); | ||
const { data } = sendModal; | ||
|
||
try { | ||
const spendingKey = await getSpendingKey(); | ||
|
||
const keys = []; | ||
for (let i = 0; i < recoveryResult.utxos.length; i++) { | ||
keys.push([spendingKey]) | ||
} | ||
|
||
const result = await pushUpdateIdentityTx(data[SEND_MODAL_SYSTEM_ID], recoveryResult.hex, recoveryResult.utxos, keys); | ||
|
||
if (result.error) { | ||
throw new Error(result.error.message); | ||
} | ||
|
||
props.navigation.navigate(SEND_MODAL_FORM_STEP_RESULT, { | ||
targetId, | ||
recoveryId, | ||
txid: result.result | ||
}); | ||
} catch (e) { | ||
Alert.alert('Error', e.message); | ||
} | ||
|
||
props.setPreventExit(false); | ||
props.setLoading(false); | ||
}, [ | ||
targetId, | ||
friendlyNames, | ||
sendModal, | ||
activeAccount, | ||
activeCoinList, | ||
dispatch, | ||
props, | ||
]); | ||
|
||
return RecoverIdentityConfirmRender({ | ||
targetId, | ||
friendlyNames, | ||
goBack, | ||
submitData, | ||
recoverableByUser: !!props.route.params.recoverableByUser, | ||
ownedAddress: props.route.params.ownedAddress || '', | ||
sendModal, | ||
revocationAddr, | ||
recoveryAddr, | ||
primaryAddr, | ||
privateAddr | ||
}); | ||
}; | ||
|
||
export default RecoverIdentityConfirm; |
61 changes: 61 additions & 0 deletions
61
...ponents/SendModal/RecoverIdentity/RecoverIdentityConfirm/RecoverIdentityConfirm.render.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import React from 'react'; | ||
import { ScrollView, View, SafeAreaView } from 'react-native'; | ||
import { Button } from 'react-native-paper'; | ||
import Colors from '../../../../globals/colors'; | ||
import Styles from '../../../../styles'; | ||
import VerusIdObjectData from '../../../VerusIdObjectData'; | ||
|
||
export const RecoverIdentityConfirmRender = ({ targetId, friendlyNames, goBack, submitData, ownedByUser, ownedAddress, sendModal, revocationAddr, recoveryAddr, primaryAddr, privateAddr }) => { | ||
return ( | ||
<SafeAreaView style={{ ...Styles.fullWidth, ...Styles.backgroundColorWhite }}> | ||
<VerusIdObjectData | ||
verusId={targetId} | ||
friendlyNames={friendlyNames} | ||
ownedByUser={false} | ||
ownedAddress={ownedAddress} | ||
updates={{ | ||
['Recovery Authority']: recoveryAddr ? { | ||
data: recoveryAddr | ||
} : null, | ||
['Revocation Authority']: revocationAddr ? { | ||
data: revocationAddr | ||
} : null, | ||
['Private Address']: privateAddr ? { | ||
data: privateAddr | ||
} : null, | ||
['Primary Address #1']: primaryAddr ? { | ||
data: primaryAddr | ||
} : null, | ||
["Status"]: { | ||
data: "Active" | ||
} | ||
}} | ||
StickyFooterComponent={ | ||
<View | ||
style={{ | ||
position: 'absolute', | ||
backgroundColor: 'white', | ||
width: '100%', | ||
flexDirection: 'row', | ||
justifyContent: 'space-evenly', | ||
paddingVertical: 20, | ||
bottom: 0, | ||
}}> | ||
<Button | ||
color={Colors.warningButtonColor} | ||
style={{ width: 148 }} | ||
onPress={goBack}> | ||
Back | ||
</Button> | ||
<Button | ||
color={Colors.verusGreenColor} | ||
style={{ width: 148 }} | ||
onPress={submitData}> | ||
Recover | ||
</Button> | ||
</View> | ||
} | ||
/> | ||
</SafeAreaView> | ||
); | ||
}; |
Oops, something went wrong.