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: New mobile Flask Build Type #7837

Merged
merged 44 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
4e1949d
android flask build type
owencraston Nov 15, 2023
7a49c2b
Flask build for iOS
owencraston Nov 16, 2023
bc70b15
remove unused android deps
owencraston Nov 16, 2023
321e12b
build steps
owencraston Nov 16, 2023
aa9a96d
new test build
owencraston Nov 16, 2023
383274e
scripts in package.json
owencraston Nov 16, 2023
5fc119a
add cmake to android bitrise
owencraston Nov 16, 2023
7b095fd
rename from Flask to flask
owencraston Nov 17, 2023
4c890f2
code fenced flask icon
owencraston Nov 17, 2023
fe8d994
set env variable in xcode
owencraston Nov 20, 2023
9116cac
update MetaMask-Flask-Info.plist
owencraston Nov 20, 2023
50688b2
rename sentryUtils to sentry/utils
owencraston Nov 21, 2023
a005c6b
remove moonpay
owencraston Nov 21, 2023
606eed4
fix sentry import
owencraston Nov 21, 2023
14bad97
fixed start:ios:flask
owencraston Nov 21, 2023
2d31cae
set METAMASK_BUILD_TYPE in build scripts
owencraston Nov 21, 2023
31dd00e
set METAMASK_BUILD_TYPE='flask' in all flask commands
owencraston Nov 21, 2023
30179ce
update scripts to latest patterns
owencraston Nov 21, 2023
0874644
fix android start flask command
owencraston Nov 22, 2023
acc8319
new test build
owencraston Nov 22, 2023
19ee6a7
new new test build
owencraston Nov 22, 2023
2c6af47
new new new build
owencraston Nov 22, 2023
d22cfff
update podfile
owencraston Nov 22, 2023
819dbbf
update podfile
owencraston Nov 22, 2023
12f0022
env variables as strings
owencraston Nov 22, 2023
b138758
address test name comments and re add xml to launcher icon
owencraston Nov 22, 2023
86458a6
refactor checksum script
owencraston Nov 22, 2023
25418c5
specify android.env for remapFlaskEnvVariables
owencraston Nov 23, 2023
02e0430
remove duplicate test names
owencraston Nov 23, 2023
9b2870d
log METAMASK_BUILD_TYPE and METAMASK_ENVIRONMENT in build.sh
owencraston Nov 23, 2023
6fa4f2a
only uninstall flask in buildAndroidFlaskRelease
owencraston Nov 23, 2023
6d4423c
remove unused build command
owencraston Nov 23, 2023
19bb39b
new prod test build
owencraston Nov 23, 2023
b4de6af
undo code fencing
owencraston Nov 23, 2023
428b011
new flask build
owencraston Nov 23, 2023
6f59cb2
build 1211
owencraston Nov 23, 2023
b312f12
fix code fencing and back test
owencraston Nov 23, 2023
eb68690
regenerate target
owencraston Nov 23, 2023
8db8b29
flask test build 1212
owencraston Nov 23, 2023
63685d3
change provisioning profile
owencraston Nov 23, 2023
b04393d
testing prod build #1213
owencraston Nov 23, 2023
51be397
undo test builds
owencraston Nov 24, 2023
9f8bb52
remove duplicate test
owencraston Nov 24, 2023
b5eea4d
remove remaps of unused variables
owencraston Nov 28, 2023
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
50 changes: 31 additions & 19 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -152,25 +152,31 @@ android {
}

signingConfigs {
release {
storeFile file('../keystores/release.keystore')
storePassword System.getenv("BITRISEIO_ANDROID_KEYSTORE_PASSWORD")
keyAlias System.getenv("BITRISEIO_ANDROID_KEYSTORE_ALIAS")
keyPassword System.getenv("BITRISEIO_ANDROID_KEYSTORE_PRIVATE_KEY_PASSWORD")
}
qa {
storeFile file('../keystores/internalRelease.keystore')
storePassword System.getenv("BITRISEIO_ANDROID_QA_KEYSTORE_PASSWORD")
keyAlias System.getenv("BITRISEIO_ANDROID_QA_KEYSTORE_ALIAS")
keyPassword System.getenv("BITRISEIO_ANDROID_QA_KEYSTORE_PRIVATE_KEY_PASSWORD")
}
debug {
storeFile file('debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
}
release {
storeFile file('../keystores/release.keystore')
storePassword System.getenv("BITRISEIO_ANDROID_KEYSTORE_PASSWORD")
keyAlias System.getenv("BITRISEIO_ANDROID_KEYSTORE_ALIAS")
keyPassword System.getenv("BITRISEIO_ANDROID_KEYSTORE_PRIVATE_KEY_PASSWORD")
}
qa {
storeFile file('../keystores/internalRelease.keystore')
storePassword System.getenv("BITRISEIO_ANDROID_QA_KEYSTORE_PASSWORD")
keyAlias System.getenv("BITRISEIO_ANDROID_QA_KEYSTORE_ALIAS")
keyPassword System.getenv("BITRISEIO_ANDROID_QA_KEYSTORE_PRIVATE_KEY_PASSWORD")
}
debug {
storeFile file('debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
flask {
storeFile file('../keystores/flaskRelease.keystore')
storePassword System.getenv("BITRISEIO_ANDROID_FLASK_KEYSTORE_PASSWORD")
keyAlias System.getenv("BITRISEIO_ANDROID_FLASK_KEYSTORE_ALIAS")
keyPassword System.getenv("BITRISEIO_ANDROID_FLASK_KEYSTORE_PRIVATE_KEY_PASSWORD")
}
}

splits {
abi {
Expand Down Expand Up @@ -206,6 +212,12 @@ android {
applicationId "io.metamask"
signingConfig signingConfigs.release
}
flask {
dimension "version"
applicationIdSuffix ".flask"
applicationId "io.metamask"
signingConfig signingConfigs.flask
}
}

buildTypes.each {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions android/app/src/flask/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<resources>
<string name="app_name">MetaMask Flask</string>
</resources>
2 changes: 1 addition & 1 deletion app/components/Nav/App/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import branch from 'react-native-branch';
import AppConstants from '../../../core/AppConstants';
import Logger from '../../../util/Logger';
import { trackErrorAsAnalytics } from '../../../util/analyticsV2';
import { routingInstrumentation } from '../../../util/sentryUtils';
import { routingInstrumentation } from '../../../util/sentry/utils';
import Analytics from '../../../core/Analytics/Analytics';
import { connect, useDispatch } from 'react-redux';
import {
Expand Down
8 changes: 7 additions & 1 deletion app/components/Views/Settings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,12 @@ const Settings = () => {
trackEvent(MetaMetricsEvents.NAVIGATION_TAPS_LOGOUT);
};

let aboutMetaMaskTitle = strings('app_settings.info_title');

///: BEGIN:ONLY_INCLUDE_IN(flask)
owencraston marked this conversation as resolved.
Show resolved Hide resolved
aboutMetaMaskTitle = strings('app_settings.info_title_flask');
///: END:ONLY_INCLUDE_IN

return (
<ScrollView style={styles.wrapper}>
<SettingsDrawer
Expand Down Expand Up @@ -213,7 +219,7 @@ const Settings = () => {
testID={EXPERIMENTAL_SETTINGS}
/>
<SettingsDrawer
title={strings('app_settings.info_title')}
title={aboutMetaMaskTitle}
onPress={onPressInfo}
testID={ABOUT_METAMASK_SETTINGS}
/>
Expand Down
7 changes: 7 additions & 0 deletions app/transforms/remove-fenced-code.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,13 @@ eslintrc.overrides.forEach((override) => {
override.rules = rules;
});

// also override the rules section
owencraston marked this conversation as resolved.
Show resolved Hide resolved
// We don't want linting to fail for purely stylistic reasons.
eslintrc.rules['prettier/prettier'] = 0;
// Sometimes we use `let` instead of `const` to assign variables depending on
// the build type.
eslintrc.rules['prefer-const'] = 0;

// Remove all test-related overrides. We will never lint test files here.
eslintrc.overrides = eslintrc.overrides.filter(
(override) =>
Expand Down
46 changes: 40 additions & 6 deletions app/util/sentryUtils.js → app/util/sentry/utils.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
/* eslint-disable import/no-namespace */
import * as Sentry from '@sentry/react-native';
import { Dedupe, ExtraErrorData } from '@sentry/integrations';
import extractEthJsErrorMessage from './extractEthJsErrorMessage';
import extractEthJsErrorMessage from '../extractEthJsErrorMessage';
import DefaultPreference from 'react-native-default-preference';
import { AGREED, METRICS_OPT_IN } from '../constants/storage';
import { regex } from './regex';
import { regex } from '../regex';
import { AGREED, METRICS_OPT_IN } from '../../constants/storage';

const METAMASK_ENVIRONMENT = process.env['METAMASK_ENVIRONMENT'] || 'local'; // eslint-disable-line dot-notation
const METAMASK_BUILD_TYPE = process.env['METAMASK_BUILD_TYPE'] || 'main'; // eslint-disable-line dot-notation

const ERROR_URL_ALLOWLIST = [
'cryptocompare.com',
Expand Down Expand Up @@ -128,17 +129,50 @@ function sanitizeAddressesFromErrorMessages(report) {
});
}

/**
* Derives the Sentry environment based on input parameters.
* This function is similar to the environment logic used in MetaMask extension.
* - https://github.com/MetaMask/metamask-extension/blob/34375a57e558853aab95fe35d5f278aa52b66636/app/scripts/lib/setupSentry.js#L91
*
* @param {boolean} isDev - Represents if the current environment is development (__DEV__ global variable).
* @param {string} [metamaskEnvironment='local'] - The environment MetaMask is running in
* (process.env.METAMASK_ENVIRONMENT).
* It defaults to 'local' if not provided.
* @param {string} [metamaskBuildType='main'] - The build type of MetaMask
* (process.env.METAMASK_BUILD_TYPE).
* It defaults to 'main' if not provided.
*
* @returns {string} - "metamaskEnvironment-metamaskBuildType" or just "metamaskEnvironment" if the build type is "main".
*/
export function deriveSentryEnvironment(
owencraston marked this conversation as resolved.
Show resolved Hide resolved
isDev,
metamaskEnvironment = 'local',
metamaskBuildType = 'main',
) {
if (isDev || !metamaskEnvironment) {
return 'development';
}

if (metamaskBuildType === 'main') {
return metamaskEnvironment;
}

return `${metamaskEnvironment}-${metamaskBuildType}`;
}

// Setup sentry remote error reporting
export function setupSentry() {
const init = async () => {
const dsn = process.env.MM_SENTRY_DSN;

const environment =
__DEV__ || !METAMASK_ENVIRONMENT ? 'development' : METAMASK_ENVIRONMENT;

const metricsOptIn = await DefaultPreference.get(METRICS_OPT_IN);

const integrations = [new Dedupe(), new ExtraErrorData()];
const environment = deriveSentryEnvironment(
__DEV__,
METAMASK_ENVIRONMENT,
METAMASK_BUILD_TYPE,
);

Sentry.init({
dsn,
Expand Down
81 changes: 81 additions & 0 deletions app/util/sentry/utils.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/* eslint-disable dot-notation */
import { deriveSentryEnvironment } from './utils';

describe('deriveSentryEnvironment', () => {
test('returns production-flask for non-dev production environment and flask build type', async () => {
const METAMASK_ENVIRONMENT = 'production';
const METAMASK_BUILD_TYPE = 'flask';
const isDev = false;

const env = deriveSentryEnvironment(
isDev,
METAMASK_ENVIRONMENT,
METAMASK_BUILD_TYPE,
);
expect(env).toBe('production-flask');
});

test('returns local-flask for non-dev undefined environment and flask build type', async () => {
const METAMASK_BUILD_TYPE = 'flask';
const isDev = false;

const env = deriveSentryEnvironment(isDev, undefined, METAMASK_BUILD_TYPE);
expect(env).toBe('local-flask');
});

test('returns debug-flask for non-dev flask environment debug build type', async () => {
const METAMASK_BUILD_TYPE = 'flask';
const METAMASK_ENVIRONMENT = 'debug';
const isDev = false;

const env = deriveSentryEnvironment(
isDev,
METAMASK_ENVIRONMENT,
METAMASK_BUILD_TYPE,
);
expect(env).toBe('debug-flask');
});

test('returns local for non-dev local environment and undefined build type', async () => {
const isDev = false;
const METAMASK_ENVIRONMENT = 'local';

const env = deriveSentryEnvironment(isDev, METAMASK_ENVIRONMENT);
expect(env).toBe('local');
});

test('returns local for non-dev with both undefined environment and build type', async () => {
const isDev = false;

const env = deriveSentryEnvironment(isDev);
expect(env).toBe('local');
});

test('returns production for non-dev production environment and undefined build type', async () => {
const METAMASK_ENVIRONMENT = 'production';
const isDev = false;

const env = deriveSentryEnvironment(isDev, METAMASK_ENVIRONMENT, undefined);
expect(env).toBe('production');
});

test('returns development for dev environment', async () => {
const isDev = true;

const env = deriveSentryEnvironment(isDev, '', '');
expect(env).toBe('development');
});

test('returns development for dev environment regardless of environment and build type', async () => {
const isDev = true;
const METAMASK_ENVIRONMENT = 'production';
const METAMASK_BUILD_TYPE = 'flask';

const env = deriveSentryEnvironment(
isDev,
METAMASK_ENVIRONMENT,
METAMASK_BUILD_TYPE,
);
expect(env).toBe('development');
});
});
1 change: 1 addition & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ module.exports = {
},
},
comments: false,
compact: true,
};
Loading
Loading