Skip to content

Commit

Permalink
Merge pull request #183 from VerusCoin/dev
Browse files Browse the repository at this point in the history
v1.0.18
  • Loading branch information
Asherda authored Oct 18, 2024
2 parents 0f3251d + 2fa2207 commit 758398a
Show file tree
Hide file tree
Showing 52 changed files with 2,082 additions and 148 deletions.
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import com.android.build.OutputFile

def versionMajor = 1
def versionMinor = 0
def versionRevision = 17
def versionRevision = 18
def versionBuild = 0

def keystorePropertiesFile = rootProject.file("keystore.properties");
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ allprojects {
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
url 'https://www.jitpack.io'
}
google()
//maven { url 'https://www.jitpack.io' }
}
}

Expand Down
2 changes: 1 addition & 1 deletion env/main.android.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"APP_VERSION": "1.0.17",
"APP_VERSION": "1.0.18",
"ELECTRUM_PROTOCOL_CHANGE": 1.4,

"KEY_DERIVATION_VERSION": 1,
Expand Down
2 changes: 1 addition & 1 deletion env/main.ios.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"APP_VERSION": "1.0.17",
"APP_VERSION": "1.0.18",
"ELECTRUM_PROTOCOL_CHANGE": 1.4,

"KEY_DERIVATION_VERSION": 1,
Expand Down
2 changes: 1 addition & 1 deletion ios/assets/env/main.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"APP_VERSION": "1.0.17",
"APP_VERSION": "1.0.18",
"ELECTRUM_PROTOCOL_CHANGE": 1.4,

"KEY_DERIVATION_VERSION": 1,
Expand Down
4 changes: 2 additions & 2 deletions ios/verusMobile.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@
"\"${PODS_CONFIGURATION_BUILD_DIR}/react-native-webview\"",
"\"${PODS_CONFIGURATION_BUILD_DIR}/rn-fetch-blob\"",
);
MARKETING_VERSION = 1.0.17;
MARKETING_VERSION = 1.0.18;
PRODUCT_BUNDLE_IDENTIFIER = org.reactjs.native.verusmobile;
PRODUCT_NAME = verusmobile;
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -792,7 +792,7 @@
"\"${PODS_CONFIGURATION_BUILD_DIR}/react-native-webview\"",
"\"${PODS_CONFIGURATION_BUILD_DIR}/rn-fetch-blob\"",
);
MARKETING_VERSION = 1.0.17;
MARKETING_VERSION = 1.0.18;
PRODUCT_BUNDLE_IDENTIFIER = org.reactjs.native.verusmobile;
PRODUCT_NAME = verusmobile;
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "verusmobile",
"version": "1.0.17",
"version": "1.0.18",
"private": true,
"scripts": {
"postinstall": "./node_modules/.bin/rn-nodeify --hack --install --yarn && npx jetify",
Expand All @@ -11,7 +11,8 @@
"bundle-ios": "react-native bundle --dev false --entry-file index.js --bundle-output ios/main.jsbundle --platform ios --assets-dest='./ios'",
"dist-android": "cd android && ./gradlew assembleRelease && cd ..",
"test": "jest",
"lint": "eslint ."
"lint": "eslint .",
"update-verus-libs": "yarn remove verus-typescript-primitives && yarn add 'git+https://github.com/VerusCoin/verus-typescript-primitives.git' && yarn remove @bitgo/utxo-lib && yarn add 'git+https://github.com/VerusCoin/BitGoJS.git#utxo-lib-verus' && yarn remove verusd-rpc-ts-client && yarn add 'git+https://github.com/VerusCoin/verusd-rpc-ts-client.git' && yarn remove verusid-ts-client && yarn add 'git+https://github.com/VerusCoin/verusid-ts-client.git'"
},
"dependencies": {
"@bitgo/utxo-lib": "git+https://github.com/VerusCoin/BitGoJS.git#utxo-lib-verus",
Expand Down
6 changes: 5 additions & 1 deletion src/VerusMobile.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import {
initSettings,
fetchActiveCoins,
requestSeedData,
initNotifications
initNotifications,
initInstanceKey
} from './actions/actionCreators';
import {
initCache,
Expand All @@ -40,6 +41,7 @@ import LoadingModal from "./components/LoadingModal/LoadingModal";
import { CoinDirectory } from "./utils/CoinData/CoinDirectory";
import { removeInactiveCurrencyDefinitions } from "./utils/asyncStore/currencyDefinitionStorage";
import { removeInactiveContractDefinitions } from "./utils/asyncStore/contractDefinitionStorage";
import { initInstance } from "./utils/auth/authBox";

class VerusMobile extends React.Component {
constructor(props) {
Expand Down Expand Up @@ -112,6 +114,8 @@ class VerusMobile extends React.Component {
const settingsAction = await initSettings();
this.props.dispatch(settingsAction);

this.props.dispatch(initInstanceKey(await initInstance()));

CoinDirectory.setVrpcOverrides(settingsAction.settings.generalWalletSettings ? settingsAction.settings.generalWalletSettings.vrpcOverrides : {});

await clearCachedVrpcResponses()
Expand Down
13 changes: 12 additions & 1 deletion src/actions/actionCreators.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ import {
SET_SECURE_LOADING_SUCCESS_DATA,
SET_SECURE_LOADING_ERROR_DATA,
CLEAR_SECURE_LOADING_DATA,
UPDATE_SESSION_KEY
UPDATE_SESSION_KEY,
INIT_INSTANCE_KEY
} from "../utils/constants/storeType";

//Reducer Name: authentication
Expand Down Expand Up @@ -117,6 +118,16 @@ export const updateSessionKey = (sessionKey) => {
}
}

//Reducer Name: authentication
export const initInstanceKey = (instanceKey) => {
return {
type: INIT_INSTANCE_KEY,
payload: {
instanceKey
}
}
}

//Reducer Name: authentication
export const signOut = () => {
return {
Expand Down
6 changes: 5 additions & 1 deletion src/actions/actions/UserData.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,12 @@ export const authenticateAccount = async (account, password) => {

if (seeds[seedChannel] == null) throw new Error('No seed for channel ' + seedChannel);

const decryptedSeed = decryptkey(password, seeds[seedChannel]);

if (!decryptedSeed) throw new Error('Failed to decrypt seed for channel ' + seedChannel);

const keyObj = await deriveKeyPair(
decryptkey(password, seeds[seedChannel]),
decryptedSeed,
activeCoins[i],
channel,
account.keyDerivationVersion == null
Expand Down
42 changes: 41 additions & 1 deletion src/actions/actions/sendModal/dispatchers/sendModal.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import store from '../../../../store';
import { coinsList } from '../../../../utils/CoinData/CoinsList';
import {
CONVERSION_SEND_MODAL,
WITHDRAW_SEND_MODAL,
Expand Down Expand Up @@ -36,7 +37,12 @@ import {
SEND_MODAL_SHOW_MAPPING_FIELD,
SEND_MODAL_PBAAS_CURRENCY_PASSTHROUGH,
SEND_MODAL_SHOW_IS_PRECONVERT,
SEND_MODAL_DISABLED_INPUTS
SEND_MODAL_DISABLED_INPUTS,
SEND_MODAL_IDENTITY_TO_REVOKE_FIELD,
REVOKE_IDENTITY_SEND_MODAL,
SEND_MODAL_SYSTEM_ID,
SEND_MODAL_ENCRYPTED_IDENTITY_SEED,
RECOVER_IDENTITY_SEND_MODAL
} from '../../../../utils/constants/sendModal';
import {
CLOSE_SEND_COIN_MODAL,
Expand Down Expand Up @@ -129,6 +135,40 @@ export const openLinkIdentityModal = (coinObj, data) => {
);
};

export const openRevokeIdentitySendModal = (data) => {
openSendModal(
`Revoke VerusID`,
null,
null,
data == null
? {
[SEND_MODAL_IDENTITY_TO_REVOKE_FIELD]: '',
[SEND_MODAL_SYSTEM_ID]: coinsList.VRSC.system_id,
[SEND_MODAL_ENCRYPTED_IDENTITY_SEED]: ''
}
: data,
REVOKE_IDENTITY_SEND_MODAL,
'To revoke a VerusID, enter the handle or i-Address of a VerusID with a revocation VerusID that you control.',
);
};

export const openRecoverIdentitySendModal = (data) => {
openSendModal(
`Recover VerusID`,
null,
null,
data == null
? {
[SEND_MODAL_IDENTITY_TO_REVOKE_FIELD]: '',
[SEND_MODAL_SYSTEM_ID]: coinsList.VRSC.system_id,
[SEND_MODAL_ENCRYPTED_IDENTITY_SEED]: ''
}
: data,
RECOVER_IDENTITY_SEND_MODAL,
'To recover a VerusID, enter the new primary address you would like your VerusID to use.',
);
};

export const openAddPbaasCurrencyModal = (coinObj, data) => {
openSendModal(
`Add Currency`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ const LinkIdentityForm = (props) => {
);
}

const friendlyNames = await getFriendlyNameMap(coinObj, res.result);
const friendlyNames = await getFriendlyNameMap(coinObj.system_id, res.result);
props.setModalHeight(height >= 720 ? 696 : height - 24);

props.navigation.navigate(SEND_MODAL_FORM_STEP_CONFIRM, {
Expand Down
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;
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>
);
};
Loading

0 comments on commit 758398a

Please sign in to comment.