diff --git a/native/.gitignore b/native/.gitignore --- a/native/.gitignore +++ b/native/.gitignore @@ -59,6 +59,7 @@ codegen/dist facts/network.json +facts/alchemy.json # Expo .expo diff --git a/native/package.json b/native/package.json --- a/native/package.json +++ b/native/package.json @@ -51,6 +51,7 @@ "dependencies": { "@commapp/android-lifecycle": "0.0.1", "@commapp/sqlcipher-amalgamation": "^4.4.3-a", + "@ethersproject/shims": "^5.7.0", "@expo/react-native-action-sheet": "^3.14.0", "@expo/vector-icons": "^13.0.0", "@gorhom/bottom-sheet": "^4.4.5", @@ -67,6 +68,7 @@ "@react-navigation/native": "^6.0.13", "@react-navigation/stack": "^6.3.2", "base-64": "^0.1.0", + "ethers": "^5.7.2", "expo": "47.0.8", "expo-dev-client": "~2.0.1", "expo-font": "~11.0.1", diff --git a/native/root.react.js b/native/root.react.js --- a/native/root.react.js +++ b/native/root.react.js @@ -18,6 +18,7 @@ import { Provider } from 'react-redux'; import { PersistGate as ReduxPersistGate } from 'redux-persist/integration/react'; +import { ENSCacheProvider } from 'lib/components/ens-cache-provider.react'; import { actionLogger } from 'lib/utils/action-logger'; import ChatContextProvider from './chat/chat-context-provider.react'; @@ -48,6 +49,7 @@ import { useLoadCommFonts } from './themes/fonts'; import { DarkTheme, LightTheme } from './themes/navigation'; import ThemeHandler from './themes/theme-handler.react'; +import { provider } from './utils/ethers-utils'; if (Platform.OS === 'android') { UIManager.setLayoutAnimationEnabledExperimental && @@ -248,23 +250,25 @@ - - - - - - {gated} - - - - - {navigation} - - + + + + + + + {gated} + + + + + {navigation} + + + diff --git a/native/utils/ethers-utils.js b/native/utils/ethers-utils.js new file mode 100644 --- /dev/null +++ b/native/utils/ethers-utils.js @@ -0,0 +1,21 @@ +// @flow + +import '@ethersproject/shims'; + +import { ethers } from 'ethers'; + +import type { EthersProvider } from 'lib/utils/ens-cache'; + +let alchemyKey; +try { + // $FlowExpectedError: file might not exist + const { key } = require('../facts/alchemy.json'); + alchemyKey = key; +} catch {} + +const provider: EthersProvider = new ethers.providers.AlchemyProvider( + 'mainnet', + alchemyKey, +); + +export { provider }; diff --git a/yarn.lock b/yarn.lock --- a/yarn.lock +++ b/yarn.lock @@ -2337,6 +2337,11 @@ "@ethersproject/logger" "^5.7.0" hash.js "1.1.7" +"@ethersproject/shims@^5.7.0": + version "5.7.0" + resolved "https://registry.yarnpkg.com/@ethersproject/shims/-/shims-5.7.0.tgz#ee32e543418595774029c5ea6123ea8995e7e154" + integrity sha512-WeDptc6oAprov5CCN2LJ/6/+dC9gTonnkdAtLepm/7P5Z+3PRxS5NpfVWmOMs1yE4Vitl2cU8bOPWC0GvGSbVg== + "@ethersproject/signing-key@5.7.0", "@ethersproject/signing-key@^5.7.0": version "5.7.0" resolved "https://registry.yarnpkg.com/@ethersproject/signing-key/-/signing-key-5.7.0.tgz#06b2df39411b00bc57c7c09b01d1e41cf1b16ab3" @@ -18923,7 +18928,6 @@ react-native-flipper@^0.164.0, "react-native-flipper@https://registry.yarnpkg.com/@favware/skip-dependency/-/skip-dependency-1.1.1.tgz": version "1.1.1" - uid f8cae15d883ffc0abc663b5eaaa711fcc64bb5c2 resolved "https://registry.yarnpkg.com/@favware/skip-dependency/-/skip-dependency-1.1.1.tgz#f8cae15d883ffc0abc663b5eaaa711fcc64bb5c2" react-native-floating-action@^1.22.0: