Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ses on v8 #614

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ android {
applicationId "network.hathor.wallet"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 76
versionName "0.28.0"
versionCode 80
versionName "0.29.0-rc.4"
missingDimensionStrategy "react-native-camera", "general"
}
signingConfigs {
Expand All @@ -103,6 +103,9 @@ android {
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
packagingOptions {
exclude "**/libjsc.so"
}
}

dependencies {
Expand Down
13 changes: 13 additions & 0 deletions android/app/src/main/java/com/hathormobile/MainApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@
import com.facebook.react.PackageList;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.bridge.JavaScriptExecutorFactory;
import com.facebook.react.ReactPackage;
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint;
import com.facebook.react.defaults.DefaultReactNativeHost;
import com.facebook.react.modules.systeminfo.AndroidInfoHelpers;
import com.facebook.soloader.SoLoader;
import java.util.List;

import io.csie.kudo.reactnative.v8.executor.V8ExecutorFactory;

public class MainApplication extends Application implements ReactApplication {

private final ReactNativeHost mReactNativeHost =
Expand Down Expand Up @@ -42,6 +46,15 @@ protected boolean isNewArchEnabled() {
protected Boolean isHermesEnabled() {
return BuildConfig.IS_HERMES_ENABLED;
}

@Override
protected JavaScriptExecutorFactory getJavaScriptExecutorFactory() {
return new V8ExecutorFactory(
getApplicationContext(),
getPackageName(),
AndroidInfoHelpers.getFriendlyDeviceName(),
getUseDeveloperSupport());
}
};

@Override
Expand Down
8 changes: 4 additions & 4 deletions ios/HathorMobile.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = HathorMobile/HathorMobile.entitlements;
CURRENT_PROJECT_VERSION = 1.0.0;
CURRENT_PROJECT_VERSION = 0.4.0;
DEVELOPMENT_TEAM = 55SHY647CG;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = HathorMobile/Info.plist;
Expand All @@ -485,7 +485,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 0.28.0;
MARKETING_VERSION = 0.29.0;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand All @@ -506,15 +506,15 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = HathorMobile/HathorMobile.entitlements;
CURRENT_PROJECT_VERSION = 1.0.0;
CURRENT_PROJECT_VERSION = 0.4.0;
DEVELOPMENT_TEAM = 55SHY647CG;
INFOPLIST_FILE = HathorMobile/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 0.28.0;
MARKETING_VERSION = 0.29.0;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand Down
54 changes: 29 additions & 25 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "HathorMobile",
"version": "0.28.0",
"version": "0.29.0-rc.4",
"engines": {
"node": ">=18.0.0",
"npm": ">=9.0.0"
Expand All @@ -14,6 +14,7 @@
"lint": "eslint .",
"test": "jest",
"setup": "npm install && ./node_modules/.bin/allow-scripts && rn-nodeify --install stream,process,path,events,crypto,console,buffer --hack && npx patch-package",
"setup:release": "npm ci && ./node_modules/.bin/allow-scripts && rn-nodeify --install stream,process,path,events,crypto,console,buffer --hack && npx patch-package",
"locale-update-pot": "ttag extract -o ./locale/texts.pot ./src/"
},
"dependencies": {
Expand Down Expand Up @@ -78,6 +79,7 @@
"react-native-svg": "13.10.0",
"react-native-tab-view": "3.5.2",
"react-native-url-polyfill": "2.0.0",
"react-native-v8": "^2.5.1",
"react-native-vector-icons": "9.2.0",
"react-native-version-number": "0.3.6",
"react-redux": "7.2.9",
Expand All @@ -88,7 +90,8 @@
"stream-browserify": "1.0.0",
"text-encoding": "0.7.0",
"ttag": "1.7.24",
"url": "0.11.1"
"url": "0.11.1",
"v8-android-jit": "^11.1000.4"
},
"devDependencies": {
"@babel/core": "7.22.8",
Expand Down
2 changes: 1 addition & 1 deletion pre_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ rm -f ./android/app/google-services.json
rm -f ./android/app/GoogleService-Info.plist
rm -f ./notifications/GoogleService-Info.plist

npm ci
npm run setup:release

(cd ios/ && pod install)

Expand Down
8 changes: 6 additions & 2 deletions src/sagas/featureToggle.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,15 @@ import {
SAFE_BIOMETRY_MODE_FEATURE_TOGGLE,
} from '../constants';
import { disableFeaturesIfNeeded } from './helpers';
import { logger } from '../logger';

const MAX_RETRIES = 5;

const log = logger('featureToggle');

export function* handleInitFailed(currentRetry) {
if (currentRetry >= MAX_RETRIES) {
console.error('Max retries reached while trying to create the unleash-proxy client.');
log.error('Max retries reached while trying to create the unleash-proxy client.');
const unleashClient = yield select((state) => state.unleashClient);

if (unleashClient) {
Expand Down Expand Up @@ -75,7 +78,7 @@ export function* fetchTogglesRoutine() {
} catch (e) {
// No need to do anything here as it will try again automatically in
// UNLEASH_POLLING_INTERVAL. Just prevent it from crashing the saga.
console.error('Erroed fetching feature toggles');
log.error('Erroed fetching feature toggles', e);
}
}
}
Expand Down Expand Up @@ -128,6 +131,7 @@ export function* monitorFeatureFlags(currentRetry = 0) {
yield put(setUseSafeBiometryMode(featureToggles[SAFE_BIOMETRY_MODE_FEATURE_TOGGLE]));
yield put(featureToggleInitialized());
} catch (e) {
log.error(e);
yield put(setUnleashClient(null));

// Wait 500ms before retrying
Expand Down
2 changes: 2 additions & 0 deletions src/sagas/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import { logger } from '../logger';

const MAX_RETRIES = 5;

console.log(`V8 version is ${global._v8runtime().version}`);

const log = logger('rootSaga');

const sagas = {
Expand Down
4 changes: 2 additions & 2 deletions src/sagas/reown.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ export function* checkForPendingRequests() {
}
const { walletKit } = reownClient;

yield call([walletKit, walletKit.getPendingAuthRequests]);
yield call([walletKit, walletKit.getPendingSessionProposals]);
yield call([walletKit, walletKit.getPendingSessionRequests]);
}

Expand Down Expand Up @@ -899,7 +899,7 @@ export function* onSessionProposal(action) {
}));
} catch (e) {
// Only if this fails, send the exception to Sentry
yield put(onExceptionCaptured(error));
yield put(onExceptionCaptured(e));
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/sagas/tokens.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { t } from 'ttag';
import { metadataApi } from '@hathor/wallet-lib';
import { channel } from 'redux-saga';
import { get } from 'lodash';
import { specificTypeAndPayload, dispatchAndWait, getRegisteredTokenUids } from './helpers';
import { specificTypeAndPayload, dispatchAndWait, getRegisteredTokenUids, getNetworkSettings } from './helpers';
import { mapToTxHistory, splitInGroups } from '../utils';
import {
types,
Expand Down Expand Up @@ -241,7 +241,7 @@ function* fetchTokenMetadataConsumer(fetchTokenMetadataChannel) {
* @inner
*/
export function* fetchTokenMetadata({ tokenId }) {
const { network } = yield select((state) => state.serverInfo);
const { network } = yield select((state) => getNetworkSettings(state));

try {
// Retry mechanism
Expand Down
5 changes: 3 additions & 2 deletions src/sagas/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ import {
firstAddressFailure,
firstAddressSuccess,
setUseSafeBiometryMode,
lockScreen,
} from '../actions';
import { fetchTokenData } from './tokens';
import {
Expand Down Expand Up @@ -437,8 +438,8 @@ export function* onPushNotificationDisabled() {
}

export function* onSafeBiometryToggleChanged() {
log.debug('Safe biometry mode feature toggle changed state, reloading wallet.');
yield put(reloadWalletRequested());
log.debug('Safe biometry mode feature toggle changed state, locking wallet.');
yield put(lockScreen());
}

/**
Expand Down
31 changes: 21 additions & 10 deletions src/screens/PinScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ import baseStyle from '../styles/init';
import Spinner from '../components/Spinner';
import FeedbackModal from '../components/FeedbackModal';
import errorIcon from '../assets/images/icErrorBig.png';
import { logger } from '../logger';

const log = logger('PIN_SCREEN');

/**
* loadHistoryActive {bool} whether we still need to load history
Expand Down Expand Up @@ -147,17 +150,25 @@ class PinScreen extends React.Component {
if (this.props.isLockScreen) {
// in case it's the lock screen, we just have to execute the data migration
// method an change redux state. No need to execute callback or go back on navigation
await STORE.handleDataMigration(pin);
await biometricsMigration(pin, this.props.safeBiometryEnabled);
if (!this.props.wallet) {
// We have already made sure we have an available accessData
// The handleDataMigration method ensures we have already migrated if necessary
// This means the wallet is loaded and the access data is ready to be used.

const words = await STORE.getWalletWords(pin);
this.props.startWalletRequested({ words, pin });
try {
await STORE.handleDataMigration(pin);
const newPin = await biometricsMigration(pin, this.props.safeBiometryEnabled);
if (!this.props.wallet) {
// We have already made sure we have an available accessData
// The handleDataMigration method ensures we have already migrated if necessary
// This means the wallet is loaded and the access data is ready to be used.

const words = await STORE.getWalletWords(newPin);
this.props.startWalletRequested({ words, pin: newPin });
}
this.props.unlockScreen();
} catch (e) {
log.error(e);
this.props.onExceptionCaptured(
e,
true, // Fatal since we can't start the wallet
);
}
this.props.unlockScreen();
} else {
// dismiss the pin screen first because doing it after the callback can
// end up dismissing the wrong screen
Expand Down
Loading