Skip to content

Commit

Permalink
Revert "chore(llm): crypto polyfill rework"
Browse files Browse the repository at this point in the history
This reverts commit 5eecbeb.
  • Loading branch information
gre committed Jul 25, 2024
1 parent c1a40d5 commit 1de4de0
Show file tree
Hide file tree
Showing 17 changed files with 78 additions and 147 deletions.
5 changes: 0 additions & 5 deletions .changeset/sharp-keys-explode.md

This file was deleted.

3 changes: 1 addition & 2 deletions apps/ledger-live-mobile/.unimportedrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
"react-native-randombytes",
"react-native-tcp",
"react-native-tcp-socket",
"react-native-udp",
"safe-buffer"
"react-native-udp"
]
}
7 changes: 0 additions & 7 deletions apps/ledger-live-mobile/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,6 @@ android {
matchingFallbacks = ['stagingRelease', 'release']
}
}

packagingOptions {
pickFirst "lib/x86/libcrypto.so"
pickFirst "lib/x86_64/libcrypto.so"
pickFirst "lib/armeabi-v7a/libcrypto.so"
pickFirst "lib/arm64-v8a/libcrypto.so"
}
}

dependencies {
Expand Down
38 changes: 36 additions & 2 deletions apps/ledger-live-mobile/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,36 @@
import "./src/polyfills";
import "./src/init";
// Injects node.js shims.
// https://github.com/parshap/node-libs-react-native
import "node-libs-react-native/globals";

// Fix for crash with `Unsupported top level event type "onGestureHandlerStateChange" dispatched`
// https://github.com/kmagiera/react-native-gesture-handler/issues/320#issuecomment-443815828
import "react-native-gesture-handler";

/** URL polyfill */
// URL object `intentionally` lightweight, does not support URLSearchParams features
// https://github.com/facebook/react-native/issues/23922
import "react-native-url-polyfill/auto";

// cosmjs use TextEncoder that's not available in React Native but on Node
import "text-encoding-polyfill";

// import all possible polyfills done by live-common for React Native. See in reactNative.ts for more details.
import "@ledgerhq/live-common/reactNative";

import { AppRegistry } from "react-native";
import BackgroundRunnerService from "./services/BackgroundRunnerService";
import App from "./src";
import logReport from "./src/log-report";
import { withSentry } from "./src/sentry";

if (__DEV__) {
// eslint-disable-next-line @typescript-eslint/no-var-requires
require("react-native-performance-flipper-reporter").setupDefaultFlipperReporter();
}

logReport.logReportInit();

const Root = withSentry(App);

AppRegistry.registerComponent("ledgerlivemobile", () => Root);
AppRegistry.registerHeadlessTask("BackgroundRunnerService", () => BackgroundRunnerService);
10 changes: 0 additions & 10 deletions apps/ledger-live-mobile/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1122,12 +1122,6 @@ PODS:
- React-Core
- react-native-performance (3.1.2):
- React-Core
- react-native-quick-crypto (0.7.1):
- glog
- OpenSSL-Universal
- RCT-Folly (= 2022.05.16.00)
- React
- React-Core
- react-native-randombytes (3.6.1):
- React-Core
- react-native-restart (0.0.24):
Expand Down Expand Up @@ -1489,7 +1483,6 @@ DEPENDENCIES:
- "react-native-netinfo (from `../node_modules/@react-native-community/netinfo`)"
- react-native-pager-view (from `../node_modules/react-native-pager-view`)
- react-native-performance (from `../node_modules/react-native-performance`)
- react-native-quick-crypto (from `../node_modules/react-native-quick-crypto`)
- react-native-randombytes (from `../node_modules/react-native-randombytes`)
- react-native-restart (from `../node_modules/react-native-restart`)
- react-native-safe-area-context (from `../node_modules/react-native-safe-area-context`)
Expand Down Expand Up @@ -1695,8 +1688,6 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native-pager-view"
react-native-performance:
:path: "../node_modules/react-native-performance"
react-native-quick-crypto:
:path: "../node_modules/react-native-quick-crypto"
react-native-randombytes:
:path: "../node_modules/react-native-randombytes"
react-native-restart:
Expand Down Expand Up @@ -1892,7 +1883,6 @@ SPEC CHECKSUMS:
react-native-netinfo: 48c5f79a84fbc3ba1d28a8b0d04adeda72885fa8
react-native-pager-view: 0eb900a8c5d83c02a74b0125d4b5f9fdcc5b8f44
react-native-performance: e66c3730f9e463b959dc21ff38fd2c8b8e53ea79
react-native-quick-crypto: 2980fb54ccfd2316ea7fa06b9c99352507570bea
react-native-randombytes: 421f1c7d48c0af8dbcd471b0324393ebf8fe7846
react-native-restart: 45c8dca02491980f2958595333cbccd6877cb57e
react-native-safe-area-context: b97eb6f9e3b7f437806c2ce5983f479f8eb5de4b
Expand Down
1 change: 0 additions & 1 deletion apps/ledger-live-mobile/metro.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ const metroConfig = {
resolverMainFields: ["react-native", "browser", "main"],
extraNodeModules: {
...require("node-libs-react-native"),
crypto: require.resolve("react-native-quick-crypto"),
fs: require.resolve("react-native-level-fs"),
net: require.resolve("react-native-tcp-socket"),
tls: require.resolve("tls"),
Expand Down
6 changes: 2 additions & 4 deletions apps/ledger-live-mobile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@
"@ledgerhq/ethereum-provider": "workspace:^",
"@ledgerhq/hw-transport": "workspace:^",
"@ledgerhq/hw-transport-http": "workspace:^",
"@ledgerhq/hw-trustchain": "workspace:^",
"@ledgerhq/icons-ui": "workspace:^",
"@ledgerhq/live-common": "workspace:^",
"@ledgerhq/live-config": "workspace:^",
Expand All @@ -102,6 +101,7 @@
"@ledgerhq/types-cryptoassets": "workspace:^",
"@ledgerhq/types-devices": "workspace:^",
"@ledgerhq/types-live": "workspace:^",
"@ledgerhq/hw-trustchain": "workspace:^",
"@likashefqet/react-native-image-zoom": "^1.3.0",
"@react-native-async-storage/async-storage": "^1.19.2",
"@react-native-clipboard/clipboard": "^1.11.2",
Expand Down Expand Up @@ -172,7 +172,7 @@
"react-native-fast-crypto": "^2.2.0",
"react-native-fast-image": "^8.5.11",
"react-native-gesture-handler": "^2.9.0",
"react-native-get-random-values": "1",
"react-native-get-random-values": "^1.11.0",
"react-native-haptic-feedback": "^2.0.3",
"react-native-image-crop-tools": "^1.6.4",
"react-native-image-picker": "^5.6.1",
Expand All @@ -185,7 +185,6 @@
"react-native-navigation-bar-color": "^2.0.1",
"react-native-pager-view": "^6.0.1",
"react-native-qrcode-svg": "6.1.1",
"react-native-quick-crypto": "^0.7.1",
"react-native-randombytes": "^3.6.1",
"react-native-reanimated": "3.8.1",
"react-native-restart": "^0.0.24",
Expand All @@ -211,7 +210,6 @@
"reselect": "4.0.0",
"rn-fetch-blob": "^0.12.0",
"rxjs": "^7.8.1",
"safe-buffer": "^5.2.1",
"semver": "^7.3.7",
"storyly-react-native": "2.0.1",
"styled-components": "^5.3.3",
Expand Down
6 changes: 4 additions & 2 deletions apps/ledger-live-mobile/services/BackgroundRunnerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const BackgroundRunnerService = async ({
}: {
deviceId: string;
firmwareSerializedJson: string;
}): Promise<void> => {
}) => {
const emitEvent = (event: FwUpdateBackgroundEvent) =>
store.dispatch(addBackgroundEvent({ event }));
const latestFirmware = JSON.parse(firmwareSerializedJson) as
Expand All @@ -37,7 +37,7 @@ const BackgroundRunnerService = async ({

if (!latestFirmware) {
log(TAG, "no need to update");
return;
return 0;
}

const onError = (error: Error) => {
Expand Down Expand Up @@ -101,6 +101,8 @@ const BackgroundRunnerService = async ({
}
},
});

return null;
};

export default BackgroundRunnerService;
2 changes: 2 additions & 0 deletions apps/ledger-live-mobile/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import "./polyfill";
import "./live-common-setup";
import { GestureHandlerRootView } from "react-native-gesture-handler";
import React, { Component, useCallback, useMemo, useEffect } from "react";
import { StyleSheet, LogBox, Appearance, AppState } from "react-native";
Expand Down
17 changes: 0 additions & 17 deletions apps/ledger-live-mobile/src/init.ts

This file was deleted.

5 changes: 0 additions & 5 deletions apps/ledger-live-mobile/src/polyfill-crypto.ts

This file was deleted.

20 changes: 0 additions & 20 deletions apps/ledger-live-mobile/src/polyfill-react-native.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// CORE JS polyfills only

/* eslint-disable no-console */

// Intl polyfill for Hermes. Could be useless in future react-native versions. See https://hermesengine.dev/docs/intl/
Expand Down Expand Up @@ -57,3 +55,24 @@ Promise.allSettled =
));

process.browser = true; // for readable-stream/lib/_stream_writable.js

// FIXME shim want to set it to false tho...
if (__DEV__ && process.env.NODE_ENV !== "test") {
setTimeout(() => {
// it logs weird things without the timeout...
try {
// just for tests
// eslint-disable-next-line @typescript-eslint/no-var-requires
require("react-native").LogBox.ignoreLogs([
"Warning: isMounted(...) is deprecated in plain JavaScript React classes. Instead, make sure to clean up subscriptions and pending requests in componentWillUnmount to prevent memory leaks.",
"Setting a timer for a long period of time, i.e. multiple minutes, is a performance and correctness issue on Android as it keeps the timer module awake, and timers can only be called when the app is in the foreground. See https://github.com/facebook/react-native/issues/12981 for more info.",
"Warning: componentWillReceiveProps has been renamed",
"Warning: componentWillUpdate has been renamed",
"Warning: componentWillMount has been renamed",
"exported from 'deprecated-react-native-prop-types'.", // https://github.com/facebook/react-native/issues/33557#issuecomment-1093083115
]);
} catch (e) {
console.warn(e);
}
}, 100);
}
25 changes: 0 additions & 25 deletions apps/ledger-live-mobile/src/polyfills.ts

This file was deleted.

3 changes: 2 additions & 1 deletion libs/coin-modules/coin-evm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
"imurmurhash": "^0.1.4",
"invariant": "^2.2.2",
"lodash": "^4.17.21",
"react-native-get-random-values": "^1.8.0",
"rxjs": "^7.8.1"
},
"devDependencies": {
Expand All @@ -101,4 +102,4 @@
"prando": "^6.0.1",
"ts-jest": "^29.1.1"
}
}
}
2 changes: 2 additions & 0 deletions libs/coin-modules/coin-evm/src/api/node/rpc.native.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/* istanbul ignore file: pure exports, test unecessary */

/** ⚠️ keep this order of import. @see https://docs.ethers.io/v5/cookbook/react-native/#cookbook-reactnative ⚠️ */
import "react-native-get-random-values";
import "@ethersproject/shims";
export * from "./rpc.common";
export * as default from "./rpc.common";
Loading

0 comments on commit 1de4de0

Please sign in to comment.