Skip to content
This repository has been archived by the owner on Jun 16, 2022. It is now read-only.

Commit

Permalink
Merge branch 'develop' of github.com:LedgerHQ/ledger-live-mobile into…
Browse files Browse the repository at this point in the history
… poc-detox
  • Loading branch information
ggilchrist-ledger committed May 3, 2022
2 parents 0092b61 + 2c9c363 commit fcfa9ab
Show file tree
Hide file tree
Showing 30 changed files with 328 additions and 258 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,20 @@ It communicates with the [Ledger Nano X](https://www.ledger.com/pages/ledger-nan

- Node LTS version
- Yarn 1.10.1 or above
- [Full React Native environment setup instructions here, **under "React Native CLI Quickstart" tab**](https://reactnative.dev/docs/environment-setup)

### iOS

- XCode
- Ruby 2.6.8 or above. The macOS built-in Ruby [does not work properly for installing dependencies of the iOS app](https://jeffreymorgan.io/articles/ruby-on-macos-with-rvm/), you have to install Ruby with for instance [Homebrew](https://brew.sh/) or [rvm](https://rvm.io/rvm/install) and make sure that `which ruby` points to that newly installed Ruby.

### Android

- Android Studio
- JDK 11
- Required SDK tools: (go to Android Studio > Tools > SDK Manager > SDK Tools > check "Show Package Details" at the bottom right)
- Android NDK 21.4.7075529 (in case this doc is outdated, check the version specified as `ndkVersion` in `android/build.gradle`)
- CMake 3.10.2

## Scripts

Expand Down
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ android {
multiDexEnabled true
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 36176144
versionCode 36176145
versionName "3.0.8"
resValue "string", "build_config_package", "com.ledger.live"
testBuildType System.getProperty('testBuildType', 'debug')
Expand Down
3 changes: 3 additions & 0 deletions fastlane/.env.staging
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ENVFILE=.env.staging
APP_IDENTIFIER="com.ledger.live.dev.staging"
APP_NAME="LL DEV"
37 changes: 26 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,29 @@ import { getEnabled } from "./src/components/HookSentry";
import logReport from "./src/log-report";
import pkg from "./package.json";

const blacklistErrorName = [
"NetworkDown",
// we exclude errors related to user's environment, not fixable by us
const excludedErrorName = [
// networking conditions
"DisconnectedError",
"Network Error",
"NetworkDown",
"NotConnectedError",
"TimeoutError",
"WebsocketConnectionError",
"DisconnectedDeviceDuringOperation",
// bad usage of device
"BleError",
"EthAppPleaseEnableContractData",
"CantOpenDevice",
"DisconnectedDeviceDuringOperation",
"PairingFailed",
];
const blacklistErrorDescription = [
const excludedErrorDescription = [
// networking
/timeout of .* exceeded/,
// base usage of device
/Device .* was disconnected/,
"Invalid channel",
// others
"Transaction signing request was rejected by the user",
];

Expand All @@ -40,16 +55,16 @@ if (Config.SENTRY_DSN && !__DEV__ && !Config.MOCK) {
// NB we do not need to explicitly set the release. we let the native side infers it.
// release: `com.ledger.live@${pkg.version}+${VersionNumber.buildVersion}`,
// dist: String(VersionNumber.buildVersion),
sampleRate: 0.05,
tracesSampleRate: 0.001,
sampleRate: 0.2,
tracesSampleRate: 0.02,
integrations: [
new Sentry.ReactNativeTracing({
routingInstrumentation,
}),
],
beforeSend(event: any) {
if (!getEnabled()) return null;
// If the error matches blacklistErrorName or blacklistErrorDescription,
// If the error matches excludedErrorName or excludedErrorDescription,
// we will not send it to Sentry.
if (event && typeof event === "object") {
const { exception } = event;
Expand All @@ -59,21 +74,21 @@ if (Config.SENTRY_DSN && !__DEV__ && !Config.MOCK) {
Array.isArray(exception.values)
) {
const { values } = exception;
const shouldBlacklist = values.some(item => {
const shouldExclude = values.some(item => {
if (item && typeof item === "object") {
const { type, value } = item;
return (typeof type === "string" &&
blacklistErrorName.some(pattern => type.match(pattern))) ||
excludedErrorName.some(pattern => type.match(pattern))) ||
(typeof value === "string" &&
blacklistErrorDescription.some(pattern =>
excludedErrorDescription.some(pattern =>
value.match(pattern),
))
? event
: null;
}
return null;
});
if (shouldBlacklist) return null;
if (shouldExclude) return null;
}
}

Expand Down
4 changes: 2 additions & 2 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ PODS:
- RNScreens (3.12.0):
- React-Core
- React-RCTImage
- RNSentry (3.4.0):
- RNSentry (3.4.1):
- React-Core
- Sentry (= 7.11.0)
- RNShare (6.5.0):
Expand Down Expand Up @@ -996,7 +996,7 @@ SPEC CHECKSUMS:
RNOS: 6f2f9a70895bbbfbdad7196abd952e7b01d45027
RNReanimated: 32c91e28f5780937b8efc07ddde1bab8d373fe0b
RNScreens: 2559f98b0835103cbef3b26ba77fa61d4bb37ae7
RNSentry: ec3c033c13bcb65c79f19d54ca54c514d1832bb5
RNSentry: fbbdcd7213058e3de5fbaa452b25a06a16b4b382
RNShare: 047d42214f875d731bde73a2b67418638af85ad9
RNSVG: 551acb6562324b1d52a4e0758f7ca0ec234e278f
RNVectorIcons: 31cebfcf94e8cf8686eb5303ae0357da64d7a5a4
Expand Down
21 changes: 11 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,30 @@
"e2e:build": "yarn detox build",
"e2e:test": "yarn detox test",
"prebeta": "bundle install",
"beta": "bundle exec fastlane beta --env production",
"beta": "bundle exec fastlane beta --env staging",
"ios:staging": "ENVFILE=.env.staging react-native run-ios --configuration Staging",
"preios:local:adhoc": "bundle install",
"ios:local:adhoc": "bundle exec fastlane ios local_adhoc --env adhoc",
"preoios:local:beta": "bundle install",
"ios:local:beta": "bundle exec fastlane ios local_beta --env production",
"ios:local:beta": "bundle exec fastlane ios local_beta --env staging",
"preoios:local:nightly": "bundle install",
"ios:local:nightly": "bundle exec fastlane ios local_nightly --env production",
"ios:local:nightly": "bundle exec fastlane ios local_nightly --env staging",
"preios:ci:testflight": "bundle install",
"ios:ci:testflight": "bundle exec fastlane ios ci_testflight --env production",
"preios:ci:adhoc": "bundle install",
"ios:ci:adhoc": "bundle exec fastlane ios ci_adhoc --env adhoc",
"preios:ci:nightly": "bundle install",
"ios:ci:nightly": "bundle exec fastlane ios ci_nightly --env production",
"ios:ci:nightly": "bundle exec fastlane ios ci_nightly --env staging",
"preandroid:local:apk": "bundle install",
"android:local:apk": "bundle exec fastlane android apk",
"android:local:apk": "bundle exec fastlane android apk --env staging",
"preandroid:local:beta": "bundle install",
"android:local:beta": "bundle exec fastlane android local_beta --env production",
"android:local:beta": "bundle exec fastlane android local_beta --env staging",
"preandroid:local:nightly": "bundle install",
"android:local:nightly": "bundle exec fastlane android local_nightly --env production",
"android:local:nightly": "bundle exec fastlane android local_nightly --env staging",
"preandroid:ci:playstore": "bundle install",
"android:ci:playstore": "bundle exec fastlane android ci_playstore --env production",
"preandroid:ci:nightly": "bundle install",
"android:ci:nightly": "bundle exec fastlane android ci_nightly --env production",
"android:ci:nightly": "bundle exec fastlane android ci_nightly --env staging",
"android:hermes:staging": "export HERMES_ENABLED_ANDROID=true && yarn android:staging",
"android:staging": "cd android && ./gradlew assembleStagingRelease",
"android:install": "./scripts/install-and-run-apk.sh",
Expand Down Expand Up @@ -76,7 +76,7 @@
"@ledgerhq/hw-transport-http": "6.27.0",
"@ledgerhq/live-common": "22.0.2",
"@ledgerhq/logs": "6.10.0",
"@ledgerhq/native-ui": "^0.7.14",
"@ledgerhq/native-ui": "^0.7.16",
"@ledgerhq/react-native-hid": "6.24.1",
"@ledgerhq/react-native-hw-transport-ble": "6.25.1",
"@ledgerhq/react-native-passcode-auth": "^2.1.0",
Expand All @@ -94,7 +94,7 @@
"@react-navigation/native": "^6.0.6",
"@react-navigation/stack": "^6.0.11",
"@segment/analytics-react-native": "^1.5.0",
"@sentry/react-native": "^3.4.0",
"@sentry/react-native": "^3.4.1",
"@tradle/react-native-http": "^2.0.0",
"assert": "^2.0.0",
"async": "^3.2.1",
Expand Down Expand Up @@ -208,6 +208,7 @@
"@types/jest": "^27.0.2",
"@types/react": "^17.0.30",
"@types/react-native": "^0.65.21",
"@types/react-native-video": "^5.0.13",
"@types/react-test-renderer": "^17.0.1",
"babel-jest": "^26.6.3",
"babel-plugin-module-resolver": "^4.1.0",
Expand Down
23 changes: 16 additions & 7 deletions src/components/Carousel/Slide.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,31 @@ import { Linking, Image } from "react-native";
import { Flex, Text, Link as TextLink, Icons } from "@ledgerhq/native-ui";
import { useTranslation } from "react-i18next";
import styled from "styled-components/native";
import { useNavigation } from "@react-navigation/native";
import Touchable from "../Touchable";
import { track } from "../../analytics";
import { SlideProps } from "./shared";

const StyledTouchable = styled(Touchable)`
flex: 1;
`;

type SlideProps = {
export type SlideProps = {
url: string;
onPress?: (navigate: (...args: any) => void) => void;
name: string;
title: string;
description: any;
cta: any;
image: any;
icon: any;
position: any;
width: number;
image?: any;
width?: number;
icon?: any;
position?: any;
};

const Slide = ({
url,
onPress,
name,
title,
description,
Expand All @@ -34,12 +38,17 @@ const Slide = ({
width,
}: SlideProps) => {
const { t } = useTranslation();
const { navigate } = useNavigation();
const onClick = useCallback(() => {
track("Portfolio Recommended OpenUrl", {
url,
});
Linking.openURL(url);
}, [url]);
if (onPress) {
onPress(navigate);
} else {
Linking.openURL(url);
}
}, [onPress, navigate, url]);
return (
<StyledTouchable event={`${name} Carousel`} onPress={onClick}>
<Flex
Expand Down
51 changes: 24 additions & 27 deletions src/components/Carousel/shared.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from "react";
import { Platform } from "react-native";
import { urls } from "../../config/urls";
import Slide from "./Slide";
import Slide, { SlideProps } from "./Slide";
import Illustration from "../../images/illustration/Illustration";
import { width } from "../../helpers/normalizeSize";
import { ScreenName } from "../../const";

const illustrations = {
dark: {
Expand All @@ -27,7 +27,7 @@ const illustrations = {
};

/*
const AcademySlide = {
const AcademySlide: SlideProps = {
url: urls.banners.ledgerAcademy,
name: "takeTour",
title: "carousel.banners.tour.title",
Expand All @@ -49,7 +49,7 @@ const AcademySlide = {
};
*/

const BuySlide = {
const BuySlide: SlideProps = {
url: "ledgerlive://buy",
name: "buyCrypto",
title: "carousel.banners.buyCrypto.title",
Expand All @@ -70,7 +70,7 @@ const BuySlide = {
},
};

const SwapSlide = {
const SwapSlide: SlideProps = {
url: "ledgerlive://swap",
name: "Swap",
title: "carousel.banners.swap.title",
Expand All @@ -91,8 +91,14 @@ const SwapSlide = {
},
};

const LidoSlide = {
const LidoSlide: SlideProps = {
url: "ledgerlive://discover/lido",
onPress: navigate => {
navigate(ScreenName.PlatformApp, {
platform: "lido",
name: "Lido",
});
},
name: "Lido",
title: "carousel.banners.lido.title",
description: "carousel.banners.lido.description",
Expand All @@ -112,7 +118,7 @@ const LidoSlide = {
},
};

const MarketSlide = {
const MarketSlide: SlideProps = {
url: "ledgerlive://market",
name: "Market",
title: "carousel.banners.market.title",
Expand All @@ -134,7 +140,7 @@ const MarketSlide = {
};

/**
const FamilyPackSlide = {
const FamilyPackSlide: SlideProps = {
url: urls.banners.familyPack,
name: "FamilyPack",
title: "carousel.banners.familyPack.title",
Expand All @@ -156,7 +162,7 @@ const FamilyPackSlide = {
};
*/

const FamilyPackXSlide = {
const FamilyPackXSlide: SlideProps = {
url: urls.banners.familyPackX,
name: "FamilyPack",
title: "carousel.banners.familyPackX.title",
Expand All @@ -177,29 +183,20 @@ const FamilyPackXSlide = {
},
};

export const SLIDES =
Platform.OS === "ios"
? [SwapSlide, BuySlide, MarketSlide, FamilyPackXSlide]
: [SwapSlide, LidoSlide, BuySlide, MarketSlide, FamilyPackXSlide];
export const SLIDES: SlideProps[] = [
SwapSlide,
LidoSlide,
BuySlide,
MarketSlide,
FamilyPackXSlide,
];

export const WIDTH = width * 0.8;

export const getDefaultSlides = () =>
SLIDES.map((slide: any) => ({
SLIDES.map(slide => ({
id: slide.name,
Component: () => (
<Slide
url={slide.url}
name={slide.name}
title={slide.title}
description={slide.description}
cta={slide.cta}
image={slide.image}
icon={slide.icon}
position={slide.position}
width={WIDTH}
/>
),
Component: () => <Slide width={WIDTH} {...slide} />,
}));

export const CAROUSEL_NONCE: number = 6;
Loading

0 comments on commit fcfa9ab

Please sign in to comment.