From f10977ab35f953c3148d99b61799788f47d2a5a2 Mon Sep 17 00:00:00 2001 From: Richard Moore Date: Tue, 17 Nov 2020 13:41:43 -0500 Subject: [PATCH] Fixing React Native tests. --- misc/ReactNativeTestApp/App.js | 11 ++++++----- misc/ReactNativeTestApp/crypto-shims.js | 3 --- misc/ReactNativeTestApp/ios/Podfile.lock | 12 ++++++------ misc/ReactNativeTestApp/package-lock.json | 18 +++++++++++++----- misc/ReactNativeTestApp/package.json | 4 ++-- misc/ReactNativeTestApp/run-tests.sh | 2 +- 6 files changed, 28 insertions(+), 22 deletions(-) delete mode 100644 misc/ReactNativeTestApp/crypto-shims.js diff --git a/misc/ReactNativeTestApp/App.js b/misc/ReactNativeTestApp/App.js index a797aee21..f24e7b45c 100644 --- a/misc/ReactNativeTestApp/App.js +++ b/misc/ReactNativeTestApp/App.js @@ -21,15 +21,16 @@ import { } from 'react-native/Libraries/NewAppScreen'; - -// Inject the crpyot shims (BEFORE the ethers shims) -import "./crypto-shims.js"; +// Inject the crypto shims (BEFORE the ethers shims) +import "react-native-get-random-values"; // Inject the missing features with the ethers shims -import "./libs/shims.js"; +//import "@ethersproject/shims"; +import "./libs/shims"; // Import ethers -import { ethers } from "./libs/ethers.js"; +//import { ethers } from "ethers"; +import { ethers } from "./libs/ethers"; // Import the test framework import "./libs/mocha.js"; diff --git a/misc/ReactNativeTestApp/crypto-shims.js b/misc/ReactNativeTestApp/crypto-shims.js deleted file mode 100644 index 6aae71aad..000000000 --- a/misc/ReactNativeTestApp/crypto-shims.js +++ /dev/null @@ -1,3 +0,0 @@ -try { - require("get-random-values-polypony").polyfill(); -} catch (error) { }; diff --git a/misc/ReactNativeTestApp/ios/Podfile.lock b/misc/ReactNativeTestApp/ios/Podfile.lock index 19737642d..fc546da89 100644 --- a/misc/ReactNativeTestApp/ios/Podfile.lock +++ b/misc/ReactNativeTestApp/ios/Podfile.lock @@ -66,8 +66,6 @@ PODS: - boost-for-react-native - DoubleConversion - glog - - get-random-values-polypony (1.0.0): - - React - glog (0.3.5) - OpenSSL-Universal (1.0.2.19): - OpenSSL-Universal/Static (= 1.0.2.19) @@ -238,6 +236,8 @@ PODS: - React-cxxreact (= 0.63.2) - React-jsi (= 0.63.2) - React-jsinspector (0.63.2) + - react-native-get-random-values (1.5.0): + - React - React-RCTActionSheet (0.63.2): - React-Core/RCTActionSheetHeaders (= 0.63.2) - React-RCTAnimation (0.63.2): @@ -326,7 +326,6 @@ DEPENDENCIES: - FlipperKit/FlipperKitUserDefaultsPlugin (~> 0.41.1) - FlipperKit/SKIOSNetworkPlugin (~> 0.41.1) - Folly (from `../node_modules/react-native/third-party-podspecs/Folly.podspec`) - - get-random-values-polypony (from `../node_modules/get-random-values-polypony`) - glog (from `../node_modules/react-native/third-party-podspecs/glog.podspec`) - RCTRequired (from `../node_modules/react-native/Libraries/RCTRequired`) - RCTTypeSafety (from `../node_modules/react-native/Libraries/TypeSafety`) @@ -340,6 +339,7 @@ DEPENDENCIES: - React-jsi (from `../node_modules/react-native/ReactCommon/jsi`) - React-jsiexecutor (from `../node_modules/react-native/ReactCommon/jsiexecutor`) - React-jsinspector (from `../node_modules/react-native/ReactCommon/jsinspector`) + - react-native-get-random-values (from `../node_modules/react-native-get-random-values`) - React-RCTActionSheet (from `../node_modules/react-native/Libraries/ActionSheetIOS`) - React-RCTAnimation (from `../node_modules/react-native/Libraries/NativeAnimation`) - React-RCTBlob (from `../node_modules/react-native/Libraries/Blob`) @@ -376,8 +376,6 @@ EXTERNAL SOURCES: :path: "../node_modules/react-native/Libraries/FBReactNativeSpec" Folly: :podspec: "../node_modules/react-native/third-party-podspecs/Folly.podspec" - get-random-values-polypony: - :path: "../node_modules/get-random-values-polypony" glog: :podspec: "../node_modules/react-native/third-party-podspecs/glog.podspec" RCTRequired: @@ -400,6 +398,8 @@ EXTERNAL SOURCES: :path: "../node_modules/react-native/ReactCommon/jsiexecutor" React-jsinspector: :path: "../node_modules/react-native/ReactCommon/jsinspector" + react-native-get-random-values: + :path: "../node_modules/react-native-get-random-values" React-RCTActionSheet: :path: "../node_modules/react-native/Libraries/ActionSheetIOS" React-RCTAnimation: @@ -438,7 +438,6 @@ SPEC CHECKSUMS: Flipper-RSocket: 64e7431a55835eb953b0bf984ef3b90ae9fdddd7 FlipperKit: bc68102cd4952a258a23c9c1b316c7bec1fecf83 Folly: b73c3869541e86821df3c387eb0af5f65addfab4 - get-random-values-polypony: 6caa66e41322297b72477ffe91201a06890fcf8a glog: 40a13f7840415b9a77023fbcae0f1e6f43192af3 OpenSSL-Universal: 8b48cc0d10c1b2923617dfe5c178aa9ed2689355 RCTRequired: f13f25e7b12f925f1f6a6a8c69d929a03c0129fe @@ -451,6 +450,7 @@ SPEC CHECKSUMS: React-jsi: 54245e1d5f4b690dec614a73a3795964eeef13a8 React-jsiexecutor: 8ca588cc921e70590820ce72b8789b02c67cce38 React-jsinspector: b14e62ebe7a66e9231e9581279909f2fc3db6606 + react-native-get-random-values: 1404bd5cc0ab0e287f75ee1c489555688fc65f89 React-RCTActionSheet: 910163b6b09685a35c4ebbc52b66d1bfbbe39fc5 React-RCTAnimation: 9a883bbe1e9d2e158d4fb53765ed64c8dc2200c6 React-RCTBlob: 39cf0ece1927996c4466510e25d2105f67010e13 diff --git a/misc/ReactNativeTestApp/package-lock.json b/misc/ReactNativeTestApp/package-lock.json index 6c66e0e5f..6965d0f25 100644 --- a/misc/ReactNativeTestApp/package-lock.json +++ b/misc/ReactNativeTestApp/package-lock.json @@ -4560,6 +4560,11 @@ "time-stamp": "^1.0.0" } }, + "fast-base64-decode": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fast-base64-decode/-/fast-base64-decode-1.0.0.tgz", + "integrity": "sha512-qwaScUgUGBYeDNRnbc/KyllVU88Jk1pRHPStuF/lO7B0/RTRLj7U0lkdTAutlBblY08rwZDff6tNU9cjv6j//Q==" + }, "fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", @@ -4848,11 +4853,6 @@ "integrity": "sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q==", "dev": true }, - "get-random-values-polypony": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/get-random-values-polypony/-/get-random-values-polypony-1.0.0.tgz", - "integrity": "sha512-UtDFXSNnVWkocN5Rbe0zabJVLqlEiEPjy7yZ9PaXVeCW8WvalKyY63NKbX1uF3FlPk2Uyk8SvWcQX7fz+eeMiQ==" - }, "get-stdin": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-6.0.0.tgz", @@ -9837,6 +9837,14 @@ } } }, + "react-native-get-random-values": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/react-native-get-random-values/-/react-native-get-random-values-1.5.0.tgz", + "integrity": "sha512-LK+Wb8dEimJkd/dub7qziDmr9Tw4chhpzVeQ6JDo4czgfG4VXbptRyOMdu8503RiMF6y9pTH6ZUTkrrpprqT7w==", + "requires": { + "fast-base64-decode": "^1.0.0" + } + }, "react-refresh": { "version": "0.4.3", "resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.4.3.tgz", diff --git a/misc/ReactNativeTestApp/package.json b/misc/ReactNativeTestApp/package.json index 0df320172..ce94ebded 100644 --- a/misc/ReactNativeTestApp/package.json +++ b/misc/ReactNativeTestApp/package.json @@ -10,9 +10,9 @@ "lint": "eslint ." }, "dependencies": { - "get-random-values-polypony": "^1.0.0", "react": "16.13.1", - "react-native": "0.63.2" + "react-native": "0.63.2", + "react-native-get-random-values": "1.5.0" }, "devDependencies": { "@babel/core": "^7.8.4", diff --git a/misc/ReactNativeTestApp/run-tests.sh b/misc/ReactNativeTestApp/run-tests.sh index f949252f9..c0f036be4 100755 --- a/misc/ReactNativeTestApp/run-tests.sh +++ b/misc/ReactNativeTestApp/run-tests.sh @@ -1,6 +1,6 @@ #!/bin/bash -cp ../../packages/ethers/dist/ethers-all.umd.min.js libs/ethers.js +cp ../../packages/ethers/dist/ethers.umd.min.js libs/ethers.js cp ../../node_modules/mocha/mocha.js libs/mocha.js cp ../../packages/tests/dist/tests.umd.js libs/tests.js cp ../../packages/shims/dist/index.js libs/shims.js