From 9f9a1121c6899e06d4aeef29017bb479df142adb Mon Sep 17 00:00:00 2001 From: Mark Stacey Date: Wed, 19 Feb 2020 13:56:37 -0400 Subject: [PATCH] Fix mixed tabs and spaces (#1379) Tabs are now used consistently in any files that had previously been a mix of tabs and spaces. --- android/app/build.gradle | 274 +++++++++--------- .../java/com/metamask/DetoxTest.java | 12 +- android/app/src/main/AndroidManifest.xml | 244 ++++++++-------- .../main/java/io/metamask/MainActivity.java | 48 +-- .../java/io/metamask/MainApplication.java | 62 ++-- .../main/java/io/metamask/SplashActivity.java | 14 +- .../metamask/nativeModules/RCTAnalytics.java | 266 ++++++++--------- .../nativeModules/RCTAnalyticsPackage.java | 22 +- .../main/res/drawable/background_splash.xml | 14 +- android/app/src/main/res/values/colors.xml | 4 +- android/app/src/main/res/values/strings.xml | 2 +- android/app/src/main/res/values/styles.xml | 18 +- .../src/main/res/xml/react_native_config.xml | 10 +- android/build.gradle | 80 ++--- app/util/browserScripts.js | 32 +- .../xcshareddata/xcschemes/MetaMask.xcscheme | 196 ++++++------- ios/MetaMask/Base.lproj/LaunchScreen.xib | 40 +-- ios/fastlane/Fastfile | 16 +- scripts/auto-changelog.sh | 82 +++--- scripts/build.sh | 121 ++++---- shim.js | 16 +- 21 files changed, 786 insertions(+), 787 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 0dd6b222f2b..5afe2180c5b 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -1,6 +1,6 @@ def getPassword(String currentUser, String keyChain) { - def stdout = new ByteArrayOutputStream() - def stderr = new ByteArrayOutputStream() + def stdout = new ByteArrayOutputStream() + def stderr = new ByteArrayOutputStream() if (org.gradle.internal.os.OperatingSystem.current().isMacOsX()) { exec { commandLine 'security', '-q', 'find-generic-password', '-a', currentUser, '-s', keyChain, '-w' @@ -12,7 +12,7 @@ def getPassword(String currentUser, String keyChain) { exec { // In order for this to work you need to store it: // secret-tool store --label='mm' server mm user mm key mm-upload-key - commandLine 'secret-tool', 'lookup', 'server', currentUser, 'user', currentUser, 'key', keyChain + commandLine 'secret-tool', 'lookup', 'server', currentUser, 'user', currentUser, 'key', keyChain standardOutput = stdout errorOutput = stderr ignoreExitValue true @@ -20,23 +20,23 @@ def getPassword(String currentUser, String keyChain) { } else { throw new GradleException('Unsupported OS! Only MacOSx and Linux are supported') } - //noinspection GroovyAssignabilityCheck - stdout.toString().trim() + //noinspection GroovyAssignabilityCheck + stdout.toString().trim() } buildscript { - repositories { - maven { url 'https://maven.fabric.io/public' } - } - - dependencies { - // These docs use an open ended version so that our plugin - // can be updated quickly in response to Android tooling updates - - // We recommend changing it to the latest version from our changelog: - // https://docs.fabric.io/android/changelog.html#fabric-gradle-plugin - classpath 'io.fabric.tools:gradle:1.+' - } + repositories { + maven { url 'https://maven.fabric.io/public' } + } + + dependencies { + // These docs use an open ended version so that our plugin + // can be updated quickly in response to Android tooling updates + + // We recommend changing it to the latest version from our changelog: + // https://docs.fabric.io/android/changelog.html#fabric-gradle-plugin + classpath 'io.fabric.tools:gradle:1.+' + } } apply plugin: "com.android.application" @@ -45,7 +45,7 @@ apply plugin: 'io.fabric' repositories { - maven { url 'https://maven.fabric.io/public' } + maven { url 'https://maven.fabric.io/public' } jcenter() } @@ -76,8 +76,8 @@ import com.android.build.OutputFile * // whether to bundle JS and assets in another build variant (if configured). * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants * // The configuration property can be in the following formats - * // 'bundleIn${productFlavor}${buildType}' - * // 'bundleIn${buildType}' + * // 'bundleIn${productFlavor}${buildType}' + * // 'bundleIn${buildType}' * // bundleInFreeDebug: true, * // bundleInPaidRelease: true, * // bundleInBeta: true, @@ -86,8 +86,8 @@ import com.android.build.OutputFile * // for example: to disable dev mode in the staging build type (if configured) * devDisabledInStaging: true, * // The configuration property can be in the following formats - * // 'devDisabledIn${productFlavor}${buildType}' - * // 'devDisabledIn${buildType}' + * // 'devDisabledIn${productFlavor}${buildType}' + * // 'devDisabledIn${buildType}' * * // the root of your project, i.e. where "package.json" lives * root: "../../", @@ -122,7 +122,7 @@ import com.android.build.OutputFile */ project.ext.react = [ - entryFile: "index.js" + entryFile: "index.js" ] apply from: "../../node_modules/react-native/react.gradle" @@ -147,13 +147,13 @@ def enableProguardInReleaseBuilds = false * override fabric properties file if MM_FABRIC_API_KEY is set */ def buildFabricPropertiesIfNeeded() { - def FABRIC_API_KEY = System.getenv('MM_FABRIC_API_KEY') - if (FABRIC_API_KEY) { - def commentMessage = "AUTOGEN FABRIC PROPERTIES" - ant.propertyfile(file: "fabric.properties", comment: commentMessage) { - entry(key: "apiKey", value: FABRIC_API_KEY) - } - } + def FABRIC_API_KEY = System.getenv('MM_FABRIC_API_KEY') + if (FABRIC_API_KEY) { + def commentMessage = "AUTOGEN FABRIC PROPERTIES" + ant.propertyfile(file: "fabric.properties", comment: commentMessage) { + entry(key: "apiKey", value: FABRIC_API_KEY) + } + } } android { @@ -163,138 +163,138 @@ android { buildFabricPropertiesIfNeeded() } - compileSdkVersion rootProject.ext.compileSdkVersion + compileSdkVersion rootProject.ext.compileSdkVersion compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - - defaultConfig { - applicationId "io.metamask" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode 26 - versionName "0.2.13" - multiDexEnabled true - testBuildType System.getProperty('testBuildType', 'debug') - missingDimensionStrategy "minReactNative", "minReactNative46" - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - ndk { - abiFilters "armeabi-v7a", "x86", "arm64-v8a", "x86_64" - } - dexOptions { - javaMaxHeapSize "2048M" - } - - manifestPlaceholders = [ - MM_BRANCH_KEY_TEST: "$System.env.MM_BRANCH_KEY_TEST", - MM_BRANCH_KEY_LIVE: "$System.env.MM_BRANCH_KEY_LIVE", - MM_MIXPANEL_TOKEN: "$System.env.MM_MIXPANEL_TOKEN" - ] + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + defaultConfig { + applicationId "io.metamask" + minSdkVersion rootProject.ext.minSdkVersion + targetSdkVersion rootProject.ext.targetSdkVersion + versionCode 26 + versionName "0.2.13" + multiDexEnabled true + testBuildType System.getProperty('testBuildType', 'debug') + missingDimensionStrategy "minReactNative", "minReactNative46" + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + ndk { + abiFilters "armeabi-v7a", "x86", "arm64-v8a", "x86_64" + } + dexOptions { + javaMaxHeapSize "2048M" + } + + manifestPlaceholders = [ + MM_BRANCH_KEY_TEST: "$System.env.MM_BRANCH_KEY_TEST", + MM_BRANCH_KEY_LIVE: "$System.env.MM_BRANCH_KEY_LIVE", + MM_MIXPANEL_TOKEN: "$System.env.MM_MIXPANEL_TOKEN" + ] missingDimensionStrategy 'react-native-camera', 'general' - } + } signingConfigs { def pass = getPassword("mm","mm-upload-key") - release { - storeFile file('../keystores/release.keystore') - storePassword pass - keyAlias 'key0' - keyPassword pass - } - } - - splits { - abi { - reset() - enable enableSeparateBuildPerCPUArchitecture - universalApk false // If true, also generate a universal APK - include "armeabi-v7a", "x86", "arm64-v8a", "x86_64" - } - } - - buildTypes { - debug { - manifestPlaceholders = [isDebug:true] - } - release { - manifestPlaceholders = [isDebug:false] - minifyEnabled enableProguardInReleaseBuilds - proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" - signingConfig signingConfigs.release - } - } + release { + storeFile file('../keystores/release.keystore') + storePassword pass + keyAlias 'key0' + keyPassword pass + } + } + + splits { + abi { + reset() + enable enableSeparateBuildPerCPUArchitecture + universalApk false // If true, also generate a universal APK + include "armeabi-v7a", "x86", "arm64-v8a", "x86_64" + } + } + + buildTypes { + debug { + manifestPlaceholders = [isDebug:true] + } + release { + manifestPlaceholders = [isDebug:false] + minifyEnabled enableProguardInReleaseBuilds + proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" + signingConfig signingConfigs.release + } + } buildTypes.each { - it.buildConfigField 'String', 'foxCode', "\"$System.env.MM_FOX_CODE\"" + it.buildConfigField 'String', 'foxCode', "\"$System.env.MM_FOX_CODE\"" } packagingOptions { // Make sure libjsc.so does not packed in APK exclude "**/libjsc.so" } - // applicationVariants are e.g. debug, release - applicationVariants.all { variant -> - variant.outputs.each { output -> - // For each separate APK per architecture, set a unique version code as described here: - // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits - def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a": 3, "x86_64": 4] - def abi = output.getFilter(OutputFile.ABI) - if (abi != null) { // null for the universal-debug, universal-release variants - output.versionCodeOverride = - versionCodes.get(abi) * 1048576 + defaultConfig.versionCode - } - } - } + // applicationVariants are e.g. debug, release + applicationVariants.all { variant -> + variant.outputs.each { output -> + // For each separate APK per architecture, set a unique version code as described here: + // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits + def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a": 3, "x86_64": 4] + def abi = output.getFilter(OutputFile.ABI) + if (abi != null) { // null for the universal-debug, universal-release variants + output.versionCodeOverride = + versionCodes.get(abi) * 1048576 + defaultConfig.versionCode + } + } + } } dependencies { - implementation project(':react-native-sensors') - implementation project(':react-native-reanimated') - implementation project(':react-native-webview') - implementation project(':react-native-fabric') - implementation project(':@react-native-community_netinfo') - implementation project(':react-native-view-shot') - implementation project(':lottie-react-native') - implementation project(':@react-native-community_async-storage') - implementation project(':react-native-push-notification') - implementation project(':react-native-background-timer') - implementation project(':react-native-device-info') - implementation project(':react-native-svg') - implementation project(':react-native-gesture-handler') - implementation project(':react-native-screens') - implementation 'androidx.multidex:multidex:2.0.0' - implementation 'androidx.annotation:annotation:1.1.0' - implementation 'androidx.appcompat:appcompat:1.0.0' - implementation "com.facebook.react:react-native:+" // From node_modules - implementation 'org.chromium:v8-android:7.8.+' - - implementation project(':react-native-branch') + implementation project(':react-native-sensors') + implementation project(':react-native-reanimated') + implementation project(':react-native-webview') + implementation project(':react-native-fabric') + implementation project(':@react-native-community_netinfo') + implementation project(':react-native-view-shot') + implementation project(':lottie-react-native') + implementation project(':@react-native-community_async-storage') + implementation project(':react-native-push-notification') + implementation project(':react-native-background-timer') + implementation project(':react-native-device-info') + implementation project(':react-native-svg') + implementation project(':react-native-gesture-handler') + implementation project(':react-native-screens') + implementation 'androidx.multidex:multidex:2.0.0' + implementation 'androidx.annotation:annotation:1.1.0' + implementation 'androidx.appcompat:appcompat:1.0.0' + implementation "com.facebook.react:react-native:+" // From node_modules + implementation 'org.chromium:v8-android:7.8.+' + + implementation project(':react-native-branch') implementation "io.branch.sdk.android:library:4.1.2" - implementation project(':react-native-camera') - implementation project(':react-native-share') - implementation project(':react-native-i18n') - implementation project(':react-native-aes-crypto') - implementation project(':react-native-keychain') - implementation project(':react-native-os') - implementation project(':react-native-randombytes') - implementation project(':react-native-fs') - implementation project(':react-native-vector-icons') + implementation project(':react-native-camera') + implementation project(':react-native-share') + implementation project(':react-native-i18n') + implementation project(':react-native-aes-crypto') + implementation project(':react-native-keychain') + implementation project(':react-native-os') + implementation project(':react-native-randombytes') + implementation project(':react-native-fs') + implementation project(':react-native-vector-icons') implementation 'com.mixpanel.android:mixpanel-android:5.+' - implementation('com.crashlytics.sdk.android:crashlytics:2.9.4@aar') { - transitive = true; - } - androidTestImplementation('com.wix:detox:+') { transitive = true } - androidTestImplementation 'junit:junit:4.12' + implementation('com.crashlytics.sdk.android:crashlytics:2.9.4@aar') { + transitive = true; + } + androidTestImplementation('com.wix:detox:+') { transitive = true } + androidTestImplementation 'junit:junit:4.12' } // Run this once to be able to run the application with BUCK // puts all compile dependencies into folder libs for BUCK to use task copyDownloadableDepsToLibs(type: Copy) { - from configurations.compile - into 'libs' + from configurations.compile + into 'libs' } diff --git a/android/app/src/androidTest/java/com/metamask/DetoxTest.java b/android/app/src/androidTest/java/com/metamask/DetoxTest.java index c01ede93472..e10f76fd031 100644 --- a/android/app/src/androidTest/java/com/metamask/DetoxTest.java +++ b/android/app/src/androidTest/java/com/metamask/DetoxTest.java @@ -14,11 +14,11 @@ @LargeTest public class DetoxTest { - @Rule - public ActivityTestRule mActivityRule = new ActivityTestRule<>(MainActivity.class, false, false); + @Rule + public ActivityTestRule mActivityRule = new ActivityTestRule<>(MainActivity.class, false, false); - @Test - public void runDetoxTests() { - Detox.runTests(mActivityRule); - } + @Test + public void runDetoxTests() { + Detox.runTests(mActivityRule); + } } diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index b24e883ff64..ece5c011d0a 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,135 +1,137 @@ - + - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - + + - - - - - - - - - - - - + + + + + + + + + + diff --git a/android/app/src/main/java/io/metamask/MainActivity.java b/android/app/src/main/java/io/metamask/MainActivity.java index 3af0f56e99e..082dfe0cb6b 100644 --- a/android/app/src/main/java/io/metamask/MainActivity.java +++ b/android/app/src/main/java/io/metamask/MainActivity.java @@ -18,13 +18,13 @@ public class MainActivity extends ReactFragmentActivity { - /** - * Returns the name of the main component registered from JavaScript. - * This is used to schedule rendering of the component. - */ - @Override - protected String getMainComponentName() { - return "MetaMask"; + /** + * Returns the name of the main component registered from JavaScript. + * This is used to schedule rendering of the component. + */ + @Override + protected String getMainComponentName() { + return "MetaMask"; } // Override onStart, onNewIntent: @@ -53,24 +53,24 @@ public void onNewIntent(Intent intent) { } @Override - protected ReactActivityDelegate createReactActivityDelegate() { - return new ReactActivityDelegate(this, getMainComponentName()) { - @NonNull - @Override - protected Bundle getLaunchOptions() { - Bundle bundle = new Bundle(); - if(BuildConfig.foxCode != null){ - bundle.putString("foxCode", BuildConfig.foxCode); - } else { - bundle.putString("foxCode", "debug"); - } - return bundle; - } - @Override + protected ReactActivityDelegate createReactActivityDelegate() { + return new ReactActivityDelegate(this, getMainComponentName()) { + @NonNull + @Override + protected Bundle getLaunchOptions() { + Bundle bundle = new Bundle(); + if(BuildConfig.foxCode != null){ + bundle.putString("foxCode", BuildConfig.foxCode); + } else { + bundle.putString("foxCode", "debug"); + } + return bundle; + } + @Override protected ReactRootView createRootView() { - return new RNGestureHandlerEnabledRootView(MainActivity.this); - } - }; + return new RNGestureHandlerEnabledRootView(MainActivity.this); + } + }; } diff --git a/android/app/src/main/java/io/metamask/MainApplication.java b/android/app/src/main/java/io/metamask/MainApplication.java index 85cd167e907..953609ef87d 100644 --- a/android/app/src/main/java/io/metamask/MainApplication.java +++ b/android/app/src/main/java/io/metamask/MainApplication.java @@ -49,39 +49,39 @@ public boolean getUseDeveloperSupport() { @Override protected List getPackages() { return Arrays.asList( - new MainReactPackage(), - new RNSensorsPackage(), - new ReanimatedPackage(), - new RNCWebViewPackage(), - new FabricPackage(), - new NetInfoPackage(), - new RNViewShotPackage(), - new LottiePackage(), - new AsyncStoragePackage(), - new ReactNativePushNotificationPackage(), - new BackgroundTimerPackage(), - new RNDeviceInfo(), - new SvgPackage(), - new RNGestureHandlerPackage(), - new RNScreensPackage(), - new RNBranchPackage(), - new KeychainPackage(), - new RandomBytesPackage(), - new RCTAesPackage(), - new RNCameraPackage(), - new RNFSPackage(), - new RNI18nPackage(), - new RNOSModule(), - new RNSharePackage(), - new VectorIconsPackage(), - new RCTAnalyticsPackage() + new MainReactPackage(), + new RNSensorsPackage(), + new ReanimatedPackage(), + new RNCWebViewPackage(), + new FabricPackage(), + new NetInfoPackage(), + new RNViewShotPackage(), + new LottiePackage(), + new AsyncStoragePackage(), + new ReactNativePushNotificationPackage(), + new BackgroundTimerPackage(), + new RNDeviceInfo(), + new SvgPackage(), + new RNGestureHandlerPackage(), + new RNScreensPackage(), + new RNBranchPackage(), + new KeychainPackage(), + new RandomBytesPackage(), + new RCTAesPackage(), + new RNCameraPackage(), + new RNFSPackage(), + new RNI18nPackage(), + new RNOSModule(), + new RNSharePackage(), + new VectorIconsPackage(), + new RCTAnalyticsPackage() ); } @Override protected String getJSMainModuleName() { return "index"; - } + } }; @Override @@ -97,8 +97,8 @@ public void onCreate() { SoLoader.init(this, /* native exopackage */ false); } - @Override - public String getFileProviderAuthority() { - return BuildConfig.APPLICATION_ID + ".provider"; - } + @Override + public String getFileProviderAuthority() { + return BuildConfig.APPLICATION_ID + ".provider"; + } } diff --git a/android/app/src/main/java/io/metamask/SplashActivity.java b/android/app/src/main/java/io/metamask/SplashActivity.java index f8d2552c096..98d69117ef6 100644 --- a/android/app/src/main/java/io/metamask/SplashActivity.java +++ b/android/app/src/main/java/io/metamask/SplashActivity.java @@ -5,12 +5,12 @@ import androidx.appcompat.app.AppCompatActivity; public class SplashActivity extends AppCompatActivity { - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); - Intent intent = new Intent(this, MainActivity.class); - startActivity(intent); - finish(); - } + Intent intent = new Intent(this, MainActivity.class); + startActivity(intent); + finish(); + } } diff --git a/android/app/src/main/java/io/metamask/nativeModules/RCTAnalytics.java b/android/app/src/main/java/io/metamask/nativeModules/RCTAnalytics.java index 1b75f39efba..21df544d7ad 100644 --- a/android/app/src/main/java/io/metamask/nativeModules/RCTAnalytics.java +++ b/android/app/src/main/java/io/metamask/nativeModules/RCTAnalytics.java @@ -28,161 +28,161 @@ public class RCTAnalytics extends ReactContextBaseJavaModule { MixpanelAPI mixpanel; - private static Tweak remoteVariables = MixpanelAPI.stringTweak("remoteVariables","{}"); + private static Tweak remoteVariables = MixpanelAPI.stringTweak("remoteVariables","{}"); - public RCTAnalytics(ReactApplicationContext reactContext) { - super(reactContext); - try{ - ApplicationInfo ai = reactContext.getPackageManager().getApplicationInfo(reactContext.getPackageName(), PackageManager.GET_META_DATA); - String mixpanelToken = (String)ai.metaData.get("com.mixpanel.android.mpmetrics.MixpanelAPI.token"); - this.mixpanel = - MixpanelAPI.getInstance(reactContext, mixpanelToken); + public RCTAnalytics(ReactApplicationContext reactContext) { + super(reactContext); + try{ + ApplicationInfo ai = reactContext.getPackageManager().getApplicationInfo(reactContext.getPackageName(), PackageManager.GET_META_DATA); + String mixpanelToken = (String)ai.metaData.get("com.mixpanel.android.mpmetrics.MixpanelAPI.token"); + this.mixpanel = + MixpanelAPI.getInstance(reactContext, mixpanelToken); - }catch (PackageManager.NameNotFoundException e){ - Log.d("RCTAnalytics","init:token missing"); - } - } + }catch (PackageManager.NameNotFoundException e){ + Log.d("RCTAnalytics","init:token missing"); + } + } - @Override - public String getName() { - return "Analytics"; - } + @Override + public String getName() { + return "Analytics"; + } - @ReactMethod - public void trackEvent(ReadableMap e) { + @ReactMethod + public void trackEvent(ReadableMap e) { String eventCategory = e.getString("category"); JSONObject props = toJSONObject(e); props.remove("category"); this.mixpanel.track(eventCategory, props); - } + } @ReactMethod - public void optIn(boolean val) { + public void optIn(boolean val) { - if(val){ + if(val){ this.mixpanel.optInTracking(); - Fabric.with(this.getReactApplicationContext(), new Crashlytics()); + Fabric.with(this.getReactApplicationContext(), new Crashlytics()); }else{ this.mixpanel.optOutTracking(); } - } + } - @ReactMethod - public void getRemoteVariables(Promise promise) { - try{ - String vars = remoteVariables.get(); - promise.resolve(vars); - } catch (Error e){ - promise.reject(e); - } + @ReactMethod + public void getRemoteVariables(Promise promise) { + try{ + String vars = remoteVariables.get(); + promise.resolve(vars); + } catch (Error e){ + promise.reject(e); + } - } + } private JSONObject toJSONObject(ReadableMap readableMap){ - ReadableMapKeySetIterator iterator = readableMap.keySetIterator(); - JSONObject map = new JSONObject(); - while (iterator.hasNextKey()) { - String key = iterator.nextKey(); - try{ - switch (readableMap.getType(key)) { - case Null: - map.put(key, null); - break; - case Boolean: - map.put(key, readableMap.getBoolean(key)); - break; - case Number: - map.put(key, readableMap.getDouble(key)); - break; - case String: - map.put(key, readableMap.getString(key)); - break; - case Map: - map.put(key, toHashMap(readableMap.getMap(key))); - break; - case Array: - map.put(key, toArrayList(readableMap.getArray(key))); - break; - default: - throw new IllegalArgumentException("Could not convert object with key: " + key + "."); - } - }catch(JSONException e){ - Log.d("RCTAnalytics","JSON parse error"); - } - } - return map; - - } - - private HashMap toHashMap(ReadableMap readableMap){ - - ReadableMapKeySetIterator iterator = readableMap.keySetIterator(); - HashMap hashMap = new HashMap<>(); - while (iterator.hasNextKey()) { - String key = iterator.nextKey(); - switch (readableMap.getType(key)) { - case Null: - hashMap.put(key, null); - break; - case Boolean: - hashMap.put(key, readableMap.getBoolean(key)); - break; - case Number: - hashMap.put(key, readableMap.getDouble(key)); - break; - case String: - hashMap.put(key, readableMap.getString(key)); - break; - case Map: - hashMap.put(key, toHashMap(readableMap.getMap(key))); - break; - case Array: - hashMap.put(key, toArrayList(readableMap.getArray(key))); - break; - default: - throw new IllegalArgumentException("Could not convert object with key: " + key + "."); - } - } - return hashMap; - - } - - - private ArrayList toArrayList(ReadableArray readableArray) { - - - ArrayList arrayList = new ArrayList<>(); - - for (int i = 0; i < readableArray.size(); i++) { - switch (readableArray.getType(i)) { - case Null: - arrayList.add(null); - break; - case Boolean: - arrayList.add(readableArray.getBoolean(i)); - break; - case Number: - arrayList.add(readableArray.getDouble(i)); - break; - case String: - arrayList.add(readableArray.getString(i)); - break; - case Map: - arrayList.add(toHashMap(readableArray.getMap(i))); - break; - case Array: - arrayList.add(toArrayList(readableArray.getArray(i))); - break; - default: - throw new IllegalArgumentException("Could not convert object at index: " + i + "."); - } - } - return arrayList; - - } + ReadableMapKeySetIterator iterator = readableMap.keySetIterator(); + JSONObject map = new JSONObject(); + while (iterator.hasNextKey()) { + String key = iterator.nextKey(); + try{ + switch (readableMap.getType(key)) { + case Null: + map.put(key, null); + break; + case Boolean: + map.put(key, readableMap.getBoolean(key)); + break; + case Number: + map.put(key, readableMap.getDouble(key)); + break; + case String: + map.put(key, readableMap.getString(key)); + break; + case Map: + map.put(key, toHashMap(readableMap.getMap(key))); + break; + case Array: + map.put(key, toArrayList(readableMap.getArray(key))); + break; + default: + throw new IllegalArgumentException("Could not convert object with key: " + key + "."); + } + }catch(JSONException e){ + Log.d("RCTAnalytics","JSON parse error"); + } + } + return map; + + } + + private HashMap toHashMap(ReadableMap readableMap){ + + ReadableMapKeySetIterator iterator = readableMap.keySetIterator(); + HashMap hashMap = new HashMap<>(); + while (iterator.hasNextKey()) { + String key = iterator.nextKey(); + switch (readableMap.getType(key)) { + case Null: + hashMap.put(key, null); + break; + case Boolean: + hashMap.put(key, readableMap.getBoolean(key)); + break; + case Number: + hashMap.put(key, readableMap.getDouble(key)); + break; + case String: + hashMap.put(key, readableMap.getString(key)); + break; + case Map: + hashMap.put(key, toHashMap(readableMap.getMap(key))); + break; + case Array: + hashMap.put(key, toArrayList(readableMap.getArray(key))); + break; + default: + throw new IllegalArgumentException("Could not convert object with key: " + key + "."); + } + } + return hashMap; + + } + + + private ArrayList toArrayList(ReadableArray readableArray) { + + + ArrayList arrayList = new ArrayList<>(); + + for (int i = 0; i < readableArray.size(); i++) { + switch (readableArray.getType(i)) { + case Null: + arrayList.add(null); + break; + case Boolean: + arrayList.add(readableArray.getBoolean(i)); + break; + case Number: + arrayList.add(readableArray.getDouble(i)); + break; + case String: + arrayList.add(readableArray.getString(i)); + break; + case Map: + arrayList.add(toHashMap(readableArray.getMap(i))); + break; + case Array: + arrayList.add(toArrayList(readableArray.getArray(i))); + break; + default: + throw new IllegalArgumentException("Could not convert object at index: " + i + "."); + } + } + return arrayList; + + } } diff --git a/android/app/src/main/java/io/metamask/nativeModules/RCTAnalyticsPackage.java b/android/app/src/main/java/io/metamask/nativeModules/RCTAnalyticsPackage.java index d16fa85c53f..64cad409dbf 100644 --- a/android/app/src/main/java/io/metamask/nativeModules/RCTAnalyticsPackage.java +++ b/android/app/src/main/java/io/metamask/nativeModules/RCTAnalyticsPackage.java @@ -11,19 +11,19 @@ public class RCTAnalyticsPackage implements ReactPackage { - @Override - public List createViewManagers(ReactApplicationContext reactContext) { - return Collections.emptyList(); - } + @Override + public List createViewManagers(ReactApplicationContext reactContext) { + return Collections.emptyList(); + } - @Override - public List createNativeModules( - ReactApplicationContext reactContext) { - List modules = new ArrayList<>(); + @Override + public List createNativeModules( + ReactApplicationContext reactContext) { + List modules = new ArrayList<>(); - modules.add(new RCTAnalytics(reactContext)); + modules.add(new RCTAnalytics(reactContext)); - return modules; - } + return modules; + } } diff --git a/android/app/src/main/res/drawable/background_splash.xml b/android/app/src/main/res/drawable/background_splash.xml index 8054ee64fb6..bad31bfda6a 100644 --- a/android/app/src/main/res/drawable/background_splash.xml +++ b/android/app/src/main/res/drawable/background_splash.xml @@ -1,13 +1,13 @@ - + - + diff --git a/android/app/src/main/res/values/colors.xml b/android/app/src/main/res/values/colors.xml index 045d41be017..9c78943dbfe 100644 --- a/android/app/src/main/res/values/colors.xml +++ b/android/app/src/main/res/values/colors.xml @@ -1,5 +1,5 @@ - #FFFFFF - #EBEBED + #FFFFFF + #EBEBED diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml index cd54b47e7b0..7f5cdee58df 100644 --- a/android/app/src/main/res/values/strings.xml +++ b/android/app/src/main/res/values/strings.xml @@ -1,3 +1,3 @@ - MetaMask + MetaMask diff --git a/android/app/src/main/res/values/styles.xml b/android/app/src/main/res/values/styles.xml index cd3e4e74878..61c6d9f8964 100644 --- a/android/app/src/main/res/values/styles.xml +++ b/android/app/src/main/res/values/styles.xml @@ -1,22 +1,22 @@ - - + - + diff --git a/android/app/src/main/res/xml/react_native_config.xml b/android/app/src/main/res/xml/react_native_config.xml index ba4b23070be..818a4ca6c99 100644 --- a/android/app/src/main/res/xml/react_native_config.xml +++ b/android/app/src/main/res/xml/react_native_config.xml @@ -1,8 +1,8 @@ - - localhost - 10.0.2.2 - 10.0.3.2 - + + localhost + 10.0.2.2 + 10.0.3.2 + diff --git a/android/build.gradle b/android/build.gradle index bbad32b02b5..d5c8ec19342 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -11,63 +11,63 @@ buildscript { kotlin_version = "1.3.50" kotlinVersion = "$kotlin_version" } - repositories { - google() - jcenter() - } + repositories { + google() + jcenter() + } dependencies { - classpath 'com.android.tools.build:gradle:3.3.2' + classpath 'com.android.tools.build:gradle:3.3.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files - } + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } } allprojects { - repositories { - mavenLocal() - google() - jcenter() - maven { // Replace AAR from original RN with AAR from react-native-v8 - url("$rootDir/../node_modules/react-native-v8/dist") - } - maven { - // prebuilt libv8android.so - url("$rootDir/../node_modules/v8-android/dist") + repositories { + mavenLocal() + google() + jcenter() + maven { // Replace AAR from original RN with AAR from react-native-v8 + url("$rootDir/../node_modules/react-native-v8/dist") + } + maven { + // prebuilt libv8android.so + url("$rootDir/../node_modules/v8-android/dist") } maven { url "https://jitpack.io" } maven { - // All of Detox' artifacts are provided via the npm module - url "$rootDir/../node_modules/detox/Detox-android" - } - } + // All of Detox' artifacts are provided via the npm module + url "$rootDir/../node_modules/detox/Detox-android" + } + } subprojects { - afterEvaluate { - project -> - if (project.hasProperty("android")) { - android { - compileSdkVersion = rootProject.ext.compileSdkVersion - buildToolsVersion = rootProject.ext.buildToolsVersion - } - } - } - } + afterEvaluate { + project -> + if (project.hasProperty("android")) { + android { + compileSdkVersion = rootProject.ext.compileSdkVersion + buildToolsVersion = rootProject.ext.buildToolsVersion + } + } + } + } } subprojects {project -> - if (project.name.contains('react-native-fabric')) { - buildscript { - repositories { + if (project.name.contains('react-native-fabric')) { + buildscript { + repositories { google() jcenter() - maven { - url = 'https://dl.bintray.com/android/android-tools/' + maven { + url = 'https://dl.bintray.com/android/android-tools/' } - } - } - } + } + } + } } diff --git a/app/util/browserScripts.js b/app/util/browserScripts.js index 7e890e38ecd..6baf8dadd5a 100644 --- a/app/util/browserScripts.js +++ b/app/util/browserScripts.js @@ -1,19 +1,19 @@ const getWindowInformation = ` - const shortcutIcon = window.document.querySelector('head > link[rel="shortcut icon"]'); - const icon = shortcutIcon || Array.from(window.document.querySelectorAll('head > link[rel="icon"]')).find((icon) => Boolean(icon.href)); + const shortcutIcon = window.document.querySelector('head > link[rel="shortcut icon"]'); + const icon = shortcutIcon || Array.from(window.document.querySelectorAll('head > link[rel="icon"]')).find((icon) => Boolean(icon.href)); - const siteName = document.querySelector('head > meta[property="og:site_name"]'); - const title = siteName || document.querySelector('head > meta[name="title"]'); - window.ReactNativeWebView && window.ReactNativeWebView.postMessage(JSON.stringify( - { - type: 'GET_TITLE_FOR_BOOKMARK', - payload: { - title: title ? title.content : document.title, - url: location.href, - icon: icon && icon.href - } - } - )) + const siteName = document.querySelector('head > meta[property="og:site_name"]'); + const title = siteName || document.querySelector('head > meta[name="title"]'); + window.ReactNativeWebView && window.ReactNativeWebView.postMessage(JSON.stringify( + { + type: 'GET_TITLE_FOR_BOOKMARK', + payload: { + title: title ? title.content : document.title, + url: location.href, + icon: icon && icon.href + } + } + )) `; export const SPA_urlChangeListener = `(function () { @@ -69,8 +69,8 @@ export const SPA_urlChangeListener = `(function () { export const JS_WINDOW_INFORMATION = ` (function () { - ${getWindowInformation} - })(); + ${getWindowInformation} + })(); `; export const JS_DESELECT_TEXT = `if (window.getSelection) {window.getSelection().removeAllRanges();} diff --git a/ios/MetaMask.xcodeproj/xcshareddata/xcschemes/MetaMask.xcscheme b/ios/MetaMask.xcodeproj/xcshareddata/xcschemes/MetaMask.xcscheme index 6572100d12f..8fed9d7f758 100644 --- a/ios/MetaMask.xcodeproj/xcshareddata/xcschemes/MetaMask.xcscheme +++ b/ios/MetaMask.xcodeproj/xcshareddata/xcschemes/MetaMask.xcscheme @@ -1,101 +1,101 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + LastUpgradeVersion = "1010" + version = "1.3"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ios/MetaMask/Base.lproj/LaunchScreen.xib b/ios/MetaMask/Base.lproj/LaunchScreen.xib index 485f66bde80..0ce36f3be1d 100644 --- a/ios/MetaMask/Base.lproj/LaunchScreen.xib +++ b/ios/MetaMask/Base.lproj/LaunchScreen.xib @@ -1,23 +1,23 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/ios/fastlane/Fastfile b/ios/fastlane/Fastfile index 7c60aa33fdb..c4bf937119d 100644 --- a/ios/fastlane/Fastfile +++ b/ios/fastlane/Fastfile @@ -3,11 +3,11 @@ # # For a list of all available actions, check out # -# https://docs.fastlane.tools/actions +# https://docs.fastlane.tools/actions # # For a list of all available plugins, check out # -# https://docs.fastlane.tools/plugins/available-plugins +# https://docs.fastlane.tools/plugins/available-plugins # # Uncomment the line if you want fastlane to automatically update itself @@ -31,13 +31,13 @@ platform :ios do clean: true, scheme: "MetaMask", configuration: "Release", - export_method: "app-store", + export_method: "app-store", output_name: "MetaMask" ) upload_to_testflight( - distribute_external: false, + distribute_external: false, skip_waiting_for_build_processing: true - ) + ) end @@ -54,13 +54,13 @@ platform :ios do clean: true, scheme: "MetaMask", configuration: "Release", - export_method: "app-store", + export_method: "app-store", output_name: "MetaMask" ) upload_to_testflight( - distribute_external: false, + distribute_external: false, skip_waiting_for_build_processing: true - ) + ) end end diff --git a/scripts/auto-changelog.sh b/scripts/auto-changelog.sh index 2a9a3893d0b..a5100690f34 100755 --- a/scripts/auto-changelog.sh +++ b/scripts/auto-changelog.sh @@ -13,48 +13,48 @@ most_recent_tag="$(git describe --tags "$(git rev-list --tags --max-count=1)")" git rev-list "${most_recent_tag}"..HEAD --reverse | while read commit do - subject="$(git show -s --format="%s" "$commit")" - - # Squash & Merge: the commit subject is parsed as ` (#)` - if grep -E -q '\(#[[:digit:]]+\)' <<< "$subject" - then - pr="$(awk '{print $NF}' <<< "$subject" | tr -d '()')" - prefix="[$pr]($URL/pull/${pr###}): " - description="$(awk '{NF--; print $0}' <<< "$subject")" - - # Merge: the PR ID is parsed from the git subject (which is of the form `Merge pull request - # # from `, and the description is assumed to be the first line of the body. - # If no body is found, the description is set to the commit subject - elif grep -E -q '#[[:digit:]]+\sfrom' <<< "$subject" - then - pr="$(awk '{print $4}' <<< "$subject")" - prefix="[$pr]($URL/pull/${pr###}): " - - first_line_of_body="$(git show -s --format="%b" "$commit" | head -n 1 | tr -d '\r')" - if [[ -z "$first_line_of_body" ]] - then - description="$subject" - else - description="$first_line_of_body" - fi - - # Normal commits: The commit subject is the description, and the PR ID is omitted. - else - pr='' - prefix='' - description="$subject" - fi - - # add entry to CHANGELOG - if [[ "$OSTYPE" == "linux-gnu" ]] - then - # shellcheck disable=SC1004 - sed -i'' '/## Current Develop Branch/a\ + subject="$(git show -s --format="%s" "$commit")" + + # Squash & Merge: the commit subject is parsed as ` (#)` + if grep -E -q '\(#[[:digit:]]+\)' <<< "$subject" + then + pr="$(awk '{print $NF}' <<< "$subject" | tr -d '()')" + prefix="[$pr]($URL/pull/${pr###}): " + description="$(awk '{NF--; print $0}' <<< "$subject")" + + # Merge: the PR ID is parsed from the git subject (which is of the form `Merge pull request + # # from `, and the description is assumed to be the first line of the body. + # If no body is found, the description is set to the commit subject + elif grep -E -q '#[[:digit:]]+\sfrom' <<< "$subject" + then + pr="$(awk '{print $4}' <<< "$subject")" + prefix="[$pr]($URL/pull/${pr###}): " + + first_line_of_body="$(git show -s --format="%b" "$commit" | head -n 1 | tr -d '\r')" + if [[ -z "$first_line_of_body" ]] + then + description="$subject" + else + description="$first_line_of_body" + fi + + # Normal commits: The commit subject is the description, and the PR ID is omitted. + else + pr='' + prefix='' + description="$subject" + fi + + # add entry to CHANGELOG + if [[ "$OSTYPE" == "linux-gnu" ]] + then + # shellcheck disable=SC1004 + sed -i'' '/## Current Develop Branch/a\ - '"$prefix$description"''$'\n' CHANGELOG.md - else - # shellcheck disable=SC1004 - sed -i '' '/## Current Develop Branch/a\ + else + # shellcheck disable=SC1004 + sed -i '' '/## Current Develop Branch/a\ - '"$prefix$description"''$'\n' CHANGELOG.md - fi + fi done echo 'CHANGELOG updated' diff --git a/scripts/build.sh b/scripts/build.sh index 41eedbd21f7..2c8fcf9b7c5 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -20,15 +20,15 @@ envFileMissing() { } displayHelp() { - echo '' - echo "Usage: $0 {platform} ${--device}" >&2 - echo '' - echo "Platform is required. Can be android or ios" - echo '' + echo '' + echo "Usage: $0 {platform} ${--device}" >&2 + echo '' + echo "Platform is required. Can be android or ios" + echo '' echo "Mode is required. Can be debug or release" - echo '' + echo '' echo "Target is optional and valid for iOS only" - echo '' + echo '' echo "examples: $0 ios debug" echo '' echo " $0 ios debug --device" @@ -37,69 +37,69 @@ displayHelp() { echo '' echo " $0 android release" echo '' - exit 1 + exit 1 } printTitle(){ - echo '' - echo '-------------------------------------------' - echo '' - echo " 🚀 BUILDING $PLATFORM in $MODE mode $TARGET" | tr [a-z] [A-Z] - echo '' - echo '-------------------------------------------' - echo '' + echo '' + echo '-------------------------------------------' + echo '' + echo " 🚀 BUILDING $PLATFORM in $MODE mode $TARGET" | tr [a-z] [A-Z] + echo '' + echo '-------------------------------------------' + echo '' } printError(){ - ERROR_ICON=$'\342\235\214' - echo '' - echo " $ERROR_ICON $1" - echo '' + ERROR_ICON=$'\342\235\214' + echo '' + echo " $ERROR_ICON $1" + echo '' } checkParameters(){ - if [ "$#" -eq "0" ] - then - printError 'Platform is a required parameter' - displayHelp - exit 0; - elif [ "$1" == "--help" ] - then - displayHelp - exit 0; - elif [ "$1" == "-h" ] - then - displayHelp - exit 0; - elif [ -z "$1" ] - then - displayHelp - exit 0; - elif [ -z "$1" ] - then - printError 'No platform supplied' - displayHelp - exit 0; - fi - - if [[ $# -gt 2 ]] ; then - if [ "$3" == "--device" ] ; then - RUN_DEVICE=true - - if [ "$#" -gt "3" ] ; then - printError "Incorrect number of arguments" - displayHelp - exit 0; - fi + if [ "$#" -eq "0" ] + then + printError 'Platform is a required parameter' + displayHelp + exit 0; + elif [ "$1" == "--help" ] + then + displayHelp + exit 0; + elif [ "$1" == "-h" ] + then + displayHelp + exit 0; + elif [ -z "$1" ] + then + displayHelp + exit 0; + elif [ -z "$1" ] + then + printError 'No platform supplied' + displayHelp + exit 0; + fi + + if [[ $# -gt 2 ]] ; then + if [ "$3" == "--device" ] ; then + RUN_DEVICE=true + + if [ "$#" -gt "3" ] ; then + printError "Incorrect number of arguments" + displayHelp + exit 0; + fi elif [ "$3" == "--pre" ] ; then PRE_RELEASE=true - else - printError "Unknown argument: $4" - displayHelp - exit 0; - fi - fi + else + printError "Unknown argument: $4" + displayHelp + exit 0; + fi + fi } @@ -221,7 +221,7 @@ buildAndroid() { buildIos() { if [ "$MODE" == "release" ] ; then buildIosRelease - else + else if [ "$RUN_DEVICE" = true ] ; then buildIosDevice else @@ -241,9 +241,6 @@ if [ "$PLATFORM" == "ios" ]; then else envFileMissing $IOS_ENV_FILE fi - - - else # we don't care about env file in CI if [ -f "$ANDROID_ENV_FILE" ] || [ "$CI" = true ]; then diff --git a/shim.js b/shim.js index aee0f2188e1..a1bb55aeeed 100644 --- a/shim.js +++ b/shim.js @@ -17,14 +17,14 @@ if (typeof global.self === 'undefined') { if (typeof __dirname === 'undefined') global.__dirname = '/' if (typeof __filename === 'undefined') global.__filename = '' if (typeof process === 'undefined') { - global.process = require('process') + global.process = require('process') } else { - const bProcess = require('process') - for (var p in bProcess) { - if (!(p in process)) { - process[p] = bProcess[p] - } - } + const bProcess = require('process') + for (var p in bProcess) { + if (!(p in process)) { + process[p] = bProcess[p] + } + } } process.browser = false @@ -36,7 +36,7 @@ Object.assign(process.env, {'NODE_ENV': isDev ? 'development' : 'production'}); if (typeof localStorage !== 'undefined') { - localStorage.debug = isDev ? '*' : '' + localStorage.debug = isDev ? '*' : '' } // If using the crypto shim, uncomment the following line to ensure