diff --git a/.detoxrc.js b/.detoxrc.js index 38584d0a6be5..67ddaec1a2fe 100644 --- a/.detoxrc.js +++ b/.detoxrc.js @@ -76,7 +76,7 @@ module.exports = { 'android.emulator': { type: 'android.emulator', device: { - avdName: 'Pixel_5_Pro_API_34', + avdName: 'Pixel_5_Pro_API_30', }, }, }, diff --git a/.e2e.env.example b/.e2e.env.example index fd46ecba3365..90de88133c05 100644 --- a/.e2e.env.example +++ b/.e2e.env.example @@ -2,4 +2,4 @@ export MM_TEST_ACCOUNT_SRP='word1 word... word12' export MM_TEST_ACCOUNT_ADDRESS='0x...' export MM_TEST_ACCOUNT_PRIVATE_KEY='' -export IS_TEST="true" +export IS_TEST="true" \ No newline at end of file diff --git a/.eslintrc.js b/.eslintrc.js index 3acfbb068c7f..df74ef0d17d3 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -19,10 +19,6 @@ module.exports = { rules: { // TODO: re-enable 'jsdoc/no-types': 'off', - 'react/display-name': 'off', - 'react/no-unused-prop-types': 'off', - 'react/prop-types': 'off', - 'react/self-closing-comp': 'off', // This change is included in `@metamask/eslint-config-typescript@10.0.0 '@typescript-eslint/no-unused-vars': [ 'error', @@ -190,5 +186,5 @@ module.exports = { radix: 0, }, - ignorePatterns: ['wdio.conf.js', 'app/util/termsOfUse/termsOfUseContent.js'], + ignorePatterns: ['wdio.conf.js'], }; diff --git a/.github/scripts/add-team-label.ts b/.github/scripts/add-team-label-to-pr.ts similarity index 93% rename from .github/scripts/add-team-label.ts rename to .github/scripts/add-team-label-to-pr.ts index 40461c598bd6..fbbbe30cac37 100644 --- a/.github/scripts/add-team-label.ts +++ b/.github/scripts/add-team-label-to-pr.ts @@ -16,11 +16,11 @@ async function main(): Promise { // We can't use "GITHUB_TOKEN" here, as its permissions are scoped to the repository where the action is running. // "GITHUB_TOKEN" does not have access to other repositories, even when they belong to the same organization. // As we want to get files which are not necessarily located in the same repository, - // we need to create our own "PERSONAL_ACCESS_TOKEN" with "repo" permissions. + // we need to create our own "RELEASE_LABEL_TOKEN" with "repo" permissions. // Such a token allows to access other repositories of the MetaMask organisation. - const personalAccessToken = process.env.PERSONAL_ACCESS_TOKEN; + const personalAccessToken = process.env.RELEASE_LABEL_TOKEN; if (!personalAccessToken) { - core.setFailed('PERSONAL_ACCESS_TOKEN not found'); + core.setFailed('RELEASE_LABEL_TOKEN not found'); process.exit(1); } diff --git a/.github/workflows/add-team-label.yml b/.github/workflows/add-team-label.yml index e5b819858555..eba9e48c1f15 100644 --- a/.github/workflows/add-team-label.yml +++ b/.github/workflows/add-team-label.yml @@ -1,4 +1,4 @@ -name: Add team label +name: Add team label to PR when it is opened on: pull_request: @@ -7,6 +7,31 @@ on: jobs: add-team-label: - uses: metamask/github-tools/.github/workflows/add-team-label.yml@7c10eb3bafb3f221111a9e4309ae5dcaee171de5 - secrets: - PERSONAL_ACCESS_TOKEN: ${{ secrets.RELEASE_LABEL_TOKEN }} + runs-on: ubuntu-latest + steps: + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 'lts/*' + + - run: corepack enable + + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 # This is needed to checkout all branches + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version-file: '.nvmrc' + cache: yarn + + - name: Install dependencies + run: yarn --immutable + + - name: Add team label to PR + id: add-team-label-to-pr + env: + RELEASE_LABEL_TOKEN: ${{ secrets.RELEASE_LABEL_TOKEN }} + run: yarn run add-team-label-to-pr diff --git a/.github/workflows/cla.yml b/.github/workflows/cla.yml index 66bb206bd2f8..0f7977000c63 100644 --- a/.github/workflows/cla.yml +++ b/.github/workflows/cla.yml @@ -22,6 +22,6 @@ jobs: url-to-cladocument: 'https://metamask.io/cla.html' # This branch can't have protections, commits are made directly to the specified branch. branch: 'cla-signatures' - allowlist: 'dependabot[bot],metamaskbot,crowdin-bot,runway-github[bot]' + allowlist: 'dependabot[bot],metamaskbot,crowdin-bot' allow-organization-members: true blockchain-storage-flag: false diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index f577c5ba7553..ed244adfe350 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -4,21 +4,20 @@ on: branches: main pull_request: - jobs: docker: runs-on: ubuntu-latest steps: - name: Set up QEMU - uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3 + uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3 + uses: docker/setup-buildx-action@v3 - uses: actions/checkout@v3 - name: Build and load - uses: docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 # v5 + uses: docker/build-push-action@v5 with: context: . file: scripts/docker/Dockerfile diff --git a/.github/workflows/update-attributions.yml b/.github/workflows/update-attributions.yml index 54f026106896..101270ac270a 100644 --- a/.github/workflows/update-attributions.yml +++ b/.github/workflows/update-attributions.yml @@ -113,7 +113,7 @@ jobs: uses: actions/checkout@v4 with: # Use PAT to ensure that the commit later can trigger status check workflows - token: ${{ secrets.ACTIONS_WRITE_TOKEN }} + token: ${{ secrets.GITHUB_TOKEN }} - name: Checkout pull request run: gh pr checkout "${PR_NUMBER}" env: @@ -144,6 +144,8 @@ jobs: git config --global user.email 'metamaskbot@users.noreply.github.com' git commit -am "Update Attributions" git push + env: + GITHUB_TOKEN: ${{ secrets.ACTIONS_WRITE_TOKEN }} - name: Post comment run: | if [[ $HAS_CHANGES == 'true' ]] diff --git a/.gitignore b/.gitignore index 8e34d2528f11..d0ee5c4774a3 100644 --- a/.gitignore +++ b/.gitignore @@ -118,7 +118,3 @@ ccache # open-rpc/test-coverage html-report/ - -# terms of use -app/util/termsOfUse/termsOfUseContent.js -docs/assets/termsOfUse.html \ No newline at end of file diff --git a/.iyarc b/.iyarc index 270b51b76106..7f087f7444b7 100644 --- a/.iyarc +++ b/.iyarc @@ -1,4 +1,8 @@ # ReDoS vulnerability, no impact to this application, and fix not backported yet to the versions we use GHSA-c2qf-rxjj-qqgw -GHSA-8hc4-vh64-cxmj \ No newline at end of file + +# ip SSRF improper categorization in isPublic, since it only affect dev tools on, and the server is actually a local server, this advisory shouldn't apply to this use cases + +GHSA-2p57-rm9w-gvfp +GHSA-8hc4-vh64-cxmj diff --git a/CHANGELOG.md b/CHANGELOG.md index e4f0ce126ea2..4f26869ff088 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,8 @@ - [#10172](https://github.com/MetaMask/metamask-mobile/pull/10172): chore: changelog release automation (#10172) - [#10282](https://github.com/MetaMask/metamask-mobile/pull/10282): chore: update Android SDK to API Level 34 (#10282) - [#10241](https://github.com/MetaMask/metamask-mobile/pull/10241): chore: add Sentry snapshot with masked data (#10241) +- [#10305](https://github.com/MetaMask/metamask-mobile/pull/10305): chore: 7.27.0 RC 2 (#10305) +- [#10292](https://github.com/MetaMask/metamask-mobile/pull/10292): chore: cleanup (#10292) - [#10289](https://github.com/MetaMask/metamask-mobile/pull/10289): chore: Download state logs on login screen (#10289) - [#10291](https://github.com/MetaMask/metamask-mobile/pull/10291): chore: Update webview to v 14.0.2 (#10291) - [#10253](https://github.com/MetaMask/metamask-mobile/pull/10253): chore: typescript hooks and base folder coverage (#10253) diff --git a/android/app/build.gradle b/android/app/build.gradle index 729ad41693a1..6b6239613c58 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -3,6 +3,8 @@ apply plugin: "com.facebook.react" apply plugin: "io.sentry.android.gradle" apply plugin: 'com.google.gms.google-services' +import com.android.build.OutputFile + /** * This is the configuration block to customize your React Native Android app. * By default you don't need to apply any configuration, just uncomment the lines you need. @@ -13,8 +15,8 @@ react { // root = file("../") // The folder where the react-native NPM package is. Default is ../node_modules/react-native // reactNativeDir = file("../node_modules/react-native") - // The folder where the react-native Codegen package is. Default is ../node_modules/@react-native/codegen - // codegenDir = file("../node_modules/@react-native/codegen") + // The folder where the react-native Codegen package is. Default is ../node_modules/react-native-codegen + // codegenDir = file("../node_modules/react-native-codegen") // The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js // cliFile = file("../node_modules/react-native/cli.js") /* Variants */ @@ -125,6 +127,14 @@ def getPassword(String currentUser, String keyChain) { stdout.toString().trim() } +/** + * Set this to true to create four separate APKs instead of one, + * one for each native architecture. This is useful if you don't + * use App Bundles (https://developer.android.com/guide/app-bundle/) + * and want to have separate APKs to upload to the Play Store. + */ +def enableSeparateBuildPerCPUArchitecture = false + /** * Set this to true to Run Proguard on Release builds to minify the Java bytecode. */ @@ -153,7 +163,6 @@ def reactNativeArchitectures() { return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"] } - /** * Adding function that will retuen the Bitrise ndkPath if it is a QA or Production Build */ @@ -173,8 +182,8 @@ android { applicationId "io.metamask" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion - versionCode 1375 - versionName "7.28.0" + versionCode 1379 + versionName "7.28.1" testBuildType System.getProperty('testBuildType', 'debug') missingDimensionStrategy 'react-native-camera', 'general' testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" @@ -184,14 +193,6 @@ android { packagingOptions { exclude 'META-INF/DEPENDENCIES' - pickFirst 'lib/x86/libc++_shared.so' - pickFirst 'lib/x86_64/libc++_shared.so' - pickFirst 'lib/armeabi-v7a/libc++_shared.so' - pickFirst 'lib/arm64-v8a/libc++_shared.so' - pickFirst 'lib/arm64-v8a/libcrypto.so' - pickFirst 'lib/armeabi-v7a/libcrypto.so' - pickFirst 'lib/x86/libcrypto.so' - pickFirst 'lib/x86_64/libcrypto.so' } signingConfigs { @@ -221,6 +222,15 @@ android { } } + splits { + abi { + reset() + enable enableSeparateBuildPerCPUArchitecture + universalApk false // If true, also generate a universal APK + include (*reactNativeArchitectures()) + } + } + buildTypes { debug { manifestPlaceholders.isDebug = true @@ -260,6 +270,21 @@ android { it.buildConfigField 'String', 'IS_RAMP_UAT', "\"$System.env.RAMP_INTERNAL_BUILD\"" // Used to point to dev environment API for ramp it.buildConfigField 'String', 'IS_RAMP_DEV', "\"$System.env.RAMP_DEV_BUILD\"" + } + // 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: + // https://developer.android.com/studio/build/configure-apk-splits.html + // Example: versionCode will generate 1001 for armeabi-v7a, 1002 for x86, etc. + 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 = + defaultConfig.versionCode * 1000 + versionCodes.get(abi) + } + + } } } @@ -268,6 +293,7 @@ dependencies { implementation(files("../libs/ecies.aar")) implementation(files("../libs/nativesdk.aar")) implementation("com.facebook.react:react-android") + implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.0.0") implementation 'org.apache.commons:commons-compress:1.22' androidTestImplementation 'org.mockito:mockito-android:4.2.0' androidTestImplementation 'androidx.test:core:1.5.0' diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index bd03aa9f0cf2..4d1cd2cc0438 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -30,7 +30,7 @@ android:theme="@style/AppTheme" android:hardwareAccelerated="true" android:usesCleartextTraffic="${isDebug}" - tools:targetApi="33" + tools:targetApi="29" tools:ignore="GoogleAppIndexingWarning" android:networkSecurityConfig="@xml/react_native_config" android:largeHeap="true" diff --git a/android/app/src/main/java/io/metamask/MainActivity.java b/android/app/src/main/java/io/metamask/MainActivity.java index 6b89721a9f45..97dc77383873 100644 --- a/android/app/src/main/java/io/metamask/MainActivity.java +++ b/android/app/src/main/java/io/metamask/MainActivity.java @@ -66,7 +66,7 @@ public void onNewIntent(Intent intent) { */ @Override protected ReactActivityDelegate createReactActivityDelegate() { - return new DefaultReactActivityDelegate(this, getMainComponentName(), DefaultNewArchitectureEntryPoint.getFabricEnabled()) { + return new ReactActivityDelegate(this, getMainComponentName()) { @Override protected Bundle getLaunchOptions() { Bundle initialProperties = new Bundle(); diff --git a/android/app/src/main/java/io/metamask/MainApplication.java b/android/app/src/main/java/io/metamask/MainApplication.java index 42be05c5b371..aa603943497d 100644 --- a/android/app/src/main/java/io/metamask/MainApplication.java +++ b/android/app/src/main/java/io/metamask/MainApplication.java @@ -24,12 +24,6 @@ import io.metamask.nativesdk.NativeSDKPackage; import io.metamask.nativeModules.RNTar.RNTarPackage; -import android.content.Context; -import android.content.Intent; -import android.content.BroadcastReceiver; -import android.content.IntentFilter; -import android.os.Build; - public class MainApplication extends Application implements ShareApplication, ReactApplication { @Override @@ -77,14 +71,6 @@ public ReactNativeHost getReactNativeHost() { return mReactNativeHost; } - @Override - public Intent registerReceiver(BroadcastReceiver receiver, IntentFilter filter) { - if (Build.VERSION.SDK_INT >= 34 && getApplicationInfo().targetSdkVersion >= 34) { - return super.registerReceiver(receiver, filter, Context.RECEIVER_EXPORTED); - } else { - return super.registerReceiver(receiver, filter); - } - } @Override public void onCreate() { super.onCreate(); diff --git a/android/build.gradle b/android/build.gradle index 214173dd6971..497382a75336 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -3,14 +3,14 @@ buildscript { ext { - buildToolsVersion = "34.0.0" + buildToolsVersion = "33.0.0" minSdkVersion = project.hasProperty('minSdkVersion') ? project.getProperty('minSdkVersion') : 23 - compileSdkVersion = 34 - targetSdkVersion = 34 + compileSdkVersion = 33 + targetSdkVersion = 33 // We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP. ndkVersion = "24.0.8215888" bitriseNdkPath = "/usr/local/share/android-sdk/ndk-bundle" - kotlin_version = "1.7.22" + kotlin_version = "1.7.0" kotlinVersion = "$kotlin_version" supportLibVersion = "28.0.0" } @@ -20,7 +20,8 @@ buildscript { } dependencies { - classpath("com.android.tools.build:gradle") + classpath('com.android.tools.build:gradle:7.3.1') + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" classpath("com.facebook.react:react-native-gradle-plugin") classpath("io.sentry:sentry-android-gradle-plugin:4.2.0") classpath("com.google.gms:google-services:4.4.2") diff --git a/android/gradle.properties b/android/gradle.properties index 2ecaf5b78808..75e967545020 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -23,10 +23,9 @@ org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m android.useAndroidX=true # Automatically convert third-party libraries to use AndroidX android.enableJetifier=true -android.disableAutomaticComponentCreation=true # Version of flipper SDK to use with React Native -FLIPPER_VERSION=0.182.0 +FLIPPER_VERSION=0.125.0 # TODO: favour arch options here over cli options # replace them @@ -47,6 +46,5 @@ newArchEnabled=false hermesEnabled=true # TODO: explain following config options -# Some of these are depreceated in RN 0.72.15 but when removed the app won't build android.disableResourceValidation=true android.enableDexingArtifactTransform.desugaring=false diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index 6ec1567a0f88..8fad3f5a98bf 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-all.zip -networkTimeout=10000 +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/android/gradlew b/android/gradlew index 424c8148efce..bdb2f02c162d 100755 --- a/android/gradlew +++ b/android/gradlew @@ -35,11 +35,13 @@ while [ -h "$PRG" ] ; do PRG=`dirname "$PRG"`"/$link" fi done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null -# This is normally unused -# shellcheck disable=SC2034 -APP_BASE_NAME=${0##*/} -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' @@ -120,7 +122,7 @@ fi # For Darwin, add options to specify how the application appears in the dock if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\" \"-Xmx2048m\" \"-Xms256m\"" + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\" \"-Xmx2048m\" \"-Xms256m\" \"-XX:MaxPermSize=2048m\"" fi # For Cygwin or MSYS, switch paths to Windows format before running java @@ -178,10 +180,4 @@ APP_ARGS=`save "$@"` # Collect all arguments for the java command, following the shell quoting and substitution rules eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" -exec "$JAVACMD" "$@" - -# Stop when "xargs" is not available. -if ! command -v xargs >/dev/null 2>&1 -then - die "xargs is not available" -fi \ No newline at end of file +exec "$JAVACMD" "$@" \ No newline at end of file diff --git a/android/gradlew.bat b/android/gradlew.bat index d111a4b731c4..e61892156e82 100644 --- a/android/gradlew.bat +++ b/android/gradlew.bat @@ -14,7 +14,7 @@ @rem limitations under the License. @rem -@if "%DEBUG%"=="" @echo off +@if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,8 +25,7 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%"=="" set DIRNAME=. -@rem This is normally unused +if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @@ -41,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if %ERRORLEVEL% equ 0 goto execute +if "%ERRORLEVEL%" == "0" goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -75,16 +74,13 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar :end @rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd +if "%ERRORLEVEL%"=="0" goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! - -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/android/settings.gradle b/android/settings.gradle index 8e99b8ad9aef..33d27562bf9a 100644 --- a/android/settings.gradle +++ b/android/settings.gradle @@ -10,8 +10,15 @@ pluginManagement { rootProject.name = 'MetaMask' apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) include ':app' -includeBuild('../node_modules/@react-native/gradle-plugin') -includeBuild('../node_modules/@react-native') {} +includeBuild('../node_modules/react-native-gradle-plugin') +includeBuild('../node_modules/react-native') { + dependencySubstitution { + substitute(module("com.facebook.react:react-android")).using(project(":ReactAndroid")) + substitute(module("com.facebook.react:react-native")).using(project(":ReactAndroid")) + substitute(module("com.facebook.react:hermes-android")).using(project(":ReactAndroid:hermes-engine")) + substitute(module("com.facebook.react:hermes-engine")).using(project(":ReactAndroid:hermes-engine")) + } +} include ':@react-native-community_blur' project(':@react-native-community_blur').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-community/blur/android') include ':lottie-react-native' diff --git a/app/actions/notification/helpers/index.ts b/app/actions/notification/helpers/index.ts index 27c05de367c3..f1483a50cc99 100644 --- a/app/actions/notification/helpers/index.ts +++ b/app/actions/notification/helpers/index.ts @@ -4,21 +4,25 @@ import { notificationsErrors } from '../constants'; import Engine from '../../../core/Engine'; import { Notification } from '../../../util/notifications'; -export type MarkAsReadNotificationsParam = Pick< +const { + AuthenticationController, + UserStorageController, + NotificationServicesController, +} = Engine.context; + +type MarkAsReadNotificationsParam = Pick< Notification, 'id' | 'type' | 'isRead' >[]; export const signIn = async () => { try { - const accessToken = - await Engine.context.AuthenticationController.performSignIn(); + const accessToken = await AuthenticationController.performSignIn(); if (!accessToken) { return getErrorMessage(notificationsErrors.PERFORM_SIGN_IN); } - const profile = - await Engine.context.AuthenticationController.getSessionProfile(); + const profile = await AuthenticationController.getSessionProfile(); if (!profile) { return getErrorMessage(notificationsErrors.PERFORM_SIGN_IN); } @@ -29,7 +33,7 @@ export const signIn = async () => { export const signOut = async () => { try { - await Engine.context.AuthenticationController.performSignOut(); + await AuthenticationController.performSignOut(); } catch (error) { return getErrorMessage(error); } @@ -37,7 +41,7 @@ export const signOut = async () => { export const enableProfileSyncing = async () => { try { - await Engine.context.UserStorageController.enableProfileSyncing(); + await UserStorageController.enableProfileSyncing(); } catch (error) { return getErrorMessage(error); } @@ -45,8 +49,8 @@ export const enableProfileSyncing = async () => { export const disableProfileSyncing = async () => { try { - await Engine.context.NotificationServicesController.disableNotificationServices(); - await Engine.context.UserStorageController.disableProfileSyncing(); + await NotificationServicesController.disableNotificationServices(); + await UserStorageController.disableProfileSyncing(); } catch (error) { return getErrorMessage(error); } @@ -54,7 +58,7 @@ export const disableProfileSyncing = async () => { export const enableNotificationServices = async () => { try { - await Engine.context.NotificationServicesController.enableMetamaskNotifications(); + await NotificationServicesController.enableMetamaskNotifications(); } catch (error) { return getErrorMessage(error); } @@ -62,7 +66,7 @@ export const enableNotificationServices = async () => { export const disableNotificationServices = async () => { try { - await Engine.context.NotificationServicesController.disableNotificationServices(); + await NotificationServicesController.disableNotificationServices(); } catch (error) { return getErrorMessage(error); } @@ -71,9 +75,7 @@ export const disableNotificationServices = async () => { export const checkAccountsPresence = async (accounts: string[]) => { try { const { presence } = - await Engine.context.NotificationServicesController.checkAccountsPresence( - accounts, - ); + await NotificationServicesController.checkAccountsPresence(accounts); if (!presence) { return getErrorMessage(notificationsErrors.CHECK_ACCOUNTS_PRESENCE); } @@ -85,7 +87,7 @@ export const checkAccountsPresence = async (accounts: string[]) => { export const deleteOnChainTriggersByAccount = async (accounts: string[]) => { try { const { userStorage } = - await Engine.context.NotificationServicesController.deleteOnChainTriggersByAccount( + await NotificationServicesController.deleteOnChainTriggersByAccount( accounts, ); if (!userStorage) { @@ -101,7 +103,7 @@ export const deleteOnChainTriggersByAccount = async (accounts: string[]) => { export const updateOnChainTriggersByAccount = async (accounts: string[]) => { try { const { userStorage } = - await Engine.context.NotificationServicesController.updateOnChainTriggersByAccount( + await NotificationServicesController.updateOnChainTriggersByAccount( accounts, ); if (!userStorage) { @@ -118,7 +120,7 @@ export const setFeatureAnnouncementsEnabled = async ( featureAnnouncementsEnabled: boolean, ) => { try { - await Engine.context.NotificationServicesController.setFeatureAnnouncementsEnabled( + await NotificationServicesController.setFeatureAnnouncementsEnabled( featureAnnouncementsEnabled, ); } catch (error) { @@ -129,7 +131,7 @@ export const setFeatureAnnouncementsEnabled = async ( export const fetchAndUpdateMetamaskNotifications = async () => { try { const metamaskNotifications = - await Engine.context.NotificationServicesController.fetchAndUpdateMetamaskNotifications(); + await NotificationServicesController.fetchAndUpdateMetamaskNotifications(); if (!metamaskNotifications) { return getErrorMessage( notificationsErrors.FETCH_AND_UPDATE_METAMASK_NOTIFICATIONS, @@ -144,7 +146,7 @@ export const markMetamaskNotificationsAsRead = async ( notifications: MarkAsReadNotificationsParam, ) => { try { - await Engine.context.NotificationServicesController.markMetamaskNotificationsAsRead( + await NotificationServicesController.markMetamaskNotificationsAsRead( notifications, ); } catch (error) { diff --git a/app/actions/transaction/index.js b/app/actions/transaction/index.js index 7cc0d95a3e04..f2ecbae38d1f 100644 --- a/app/actions/transaction/index.js +++ b/app/actions/transaction/index.js @@ -144,6 +144,42 @@ export function setEtherTransaction(transaction) { }; } +/** + * Enable individual ERC20 asset only to send in a transaction + * + * @param {object} token - Token object to be sent + */ +export function setIndividualTokenTransaction(token) { + return { + type: 'SET_INDIVIDUAL_TOKEN_TRANSACTION', + token, + }; +} + +/** + * Enable individual ERC721 asset only to send in a transaction + * + * @param {object} collectible - Collectible object to be sent + */ +export function setIndividualCollectibleTransaction(collectible) { + return { + type: 'SET_INDIVIDUAL_COLLECTIBLE_TRANSACTION', + collectible, + }; +} + +/** + * Enable selectable ERC721 assets who's current account is owner of a specific contract to be sent in a transaction + * + * @param {object} collectible - Collectible of the type contract collectible that the user wants to send + */ +export function setCollectibleContractTransaction(collectible) { + return { + type: 'SET_COLLECTIBLE_CONTRACT_TRANSACTION', + collectible, + }; +} + export function setNonce(nonce) { return { type: 'SET_NONCE', diff --git a/app/component-library/components-temp/Contracts/ContractBoxBase/ContractBoxBase.tsx b/app/component-library/components-temp/Contracts/ContractBoxBase/ContractBoxBase.tsx index d92a8bbb5d7c..728d824fbfa1 100644 --- a/app/component-library/components-temp/Contracts/ContractBoxBase/ContractBoxBase.tsx +++ b/app/component-library/components-temp/Contracts/ContractBoxBase/ContractBoxBase.tsx @@ -70,7 +70,7 @@ const ContractBoxBase = ({