Skip to content

Commit

Permalink
Upgraded expo example, tested
Browse files Browse the repository at this point in the history
  • Loading branch information
ihsraham committed Nov 6, 2024
1 parent 928ed6d commit a483069
Show file tree
Hide file tree
Showing 6 changed files with 529 additions and 524 deletions.
13 changes: 6 additions & 7 deletions react-native/rn-expo-example/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import "./globals";
// IMP START - Quick Start
import * as WebBrowser from "expo-web-browser";
import * as SecureStore from "expo-secure-store";
import Web3Auth, { OPENLOGIN_NETWORK, LOGIN_PROVIDER, ChainNamespace } from "@web3auth/react-native-sdk";
import Web3Auth, { WEB3AUTH_NETWORK, LOGIN_PROVIDER, ChainNamespace } from "@web3auth/react-native-sdk";
import {EthereumPrivateKeyProvider} from '@web3auth/ethereum-provider';
// IMP END - Quick Start
import {ethers} from 'ethers';
Expand Down Expand Up @@ -52,7 +52,8 @@ const web3auth = new Web3Auth(WebBrowser, SecureStore, {
// IMP START - Whitelist bundle ID
redirectUrl,
// IMP END - Whitelist bundle ID
network: OPENLOGIN_NETWORK.SAPPHIRE_MAINNET, // or other networks
network: WEB3AUTH_NETWORK.SAPPHIRE_MAINNET, // or other networks
privateKeyProvider: ethereumPrivateKeyProvider,
});
// IMP END - SDK Initialization

Expand All @@ -68,8 +69,7 @@ export default function App() {
// IMP START - SDK Initialization
await web3auth.init();

if (web3auth.privKey) {
await ethereumPrivateKeyProvider.setupProvider(web3auth.privKey);
if (web3auth.connected) {
// IMP END - SDK Initialization
setProvider(ethereumPrivateKeyProvider);
setLoggedIn(true);
Expand Down Expand Up @@ -98,8 +98,7 @@ export default function App() {
},
});

if (web3auth.privKey) {
await ethereumPrivateKeyProvider.setupProvider(web3auth.privKey);
if (web3auth.connected) {
// IMP END - Login
setProvider(ethereumPrivateKeyProvider);
uiConsole('Logged In');
Expand All @@ -121,7 +120,7 @@ export default function App() {
await web3auth.logout();
// IMP END - Logout

if (!web3auth.privKey) {
if (!web3auth.connected) {
setProvider(null);
uiConsole('Logged out');
setLoggedIn(false);
Expand Down
5 changes: 5 additions & 0 deletions react-native/rn-expo-example/globals.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
global.Buffer = require("buffer").Buffer;

// eslint-disable-next-line import/first
import { install } from "react-native-quick-crypto";

install();

// Needed so that 'stream-http' chooses the right default protocol.
global.location = {
protocol: "file:",
Expand Down
32 changes: 31 additions & 1 deletion react-native/rn-expo-example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ PODS:
- hermes-engine (0.74.1):
- hermes-engine/Pre-built (= 0.74.1)
- hermes-engine/Pre-built (0.74.1)
- OpenSSL-Universal (3.3.2000)
- RCT-Folly (2024.01.01.00):
- boost
- DoubleConversion
Expand Down Expand Up @@ -1000,6 +1001,29 @@ PODS:
- React-debug
- react-native-get-random-values (1.11.0):
- React-Core
- react-native-quick-crypto (0.7.6):
- DoubleConversion
- glog
- hermes-engine
- OpenSSL-Universal
- RCT-Folly (= 2024.01.01.00)
- RCTRequired
- RCTTypeSafety
- React
- React-Codegen
- React-Core
- React-debug
- React-Fabric
- React-featureflags
- React-graphics
- React-ImageManager
- React-NativeModulesApple
- React-RCTFabric
- React-rendererdebug
- React-utils
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- Yoga
- React-nativeconfig (0.74.1)
- React-NativeModulesApple (0.74.1):
- glog
Expand Down Expand Up @@ -1277,6 +1301,7 @@ DEPENDENCIES:
- React-logger (from `../node_modules/react-native/ReactCommon/logger`)
- React-Mapbuffer (from `../node_modules/react-native/ReactCommon`)
- react-native-get-random-values (from `../node_modules/react-native-get-random-values`)
- react-native-quick-crypto (from `../node_modules/react-native-quick-crypto`)
- React-nativeconfig (from `../node_modules/react-native/ReactCommon`)
- React-NativeModulesApple (from `../node_modules/react-native/ReactCommon/react/nativemodule/core/platform/ios`)
- React-perflogger (from `../node_modules/react-native/ReactCommon/reactperflogger`)
Expand Down Expand Up @@ -1304,6 +1329,7 @@ DEPENDENCIES:

SPEC REPOS:
trunk:
- OpenSSL-Universal
- SocketRocket

EXTERNAL SOURCES:
Expand Down Expand Up @@ -1392,6 +1418,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/ReactCommon"
react-native-get-random-values:
:path: "../node_modules/react-native-get-random-values"
react-native-quick-crypto:
:path: "../node_modules/react-native-quick-crypto"
React-nativeconfig:
:path: "../node_modules/react-native/ReactCommon"
React-NativeModulesApple:
Expand Down Expand Up @@ -1459,6 +1487,7 @@ SPEC CHECKSUMS:
fmt: 4c2741a687cc09f0634a2e2c72a838b99f1ff120
glog: c5d68082e772fa1c511173d6b30a9de2c05a69a2
hermes-engine: 16b8530de1b383cdada1476cf52d1b52f0692cbc
OpenSSL-Universal: b60a3702c9fea8b3145549d421fdb018e53ab7b4
RCT-Folly: 02617c592a293bd6d418e0a88ff4ee1f88329b47
RCTDeprecation: efb313d8126259e9294dc4ee0002f44a6f676aba
RCTRequired: f49ea29cece52aee20db633ae7edc4b271435562
Expand All @@ -1484,6 +1513,7 @@ SPEC CHECKSUMS:
React-logger: 7e7403a2b14c97f847d90763af76b84b152b6fce
React-Mapbuffer: 11029dcd47c5c9e057a4092ab9c2a8d10a496a33
react-native-get-random-values: 21325b2244dfa6b58878f51f9aa42821e7ba3d06
react-native-quick-crypto: 3d1d972bc231e88073b3821dbaf89f84d8208200
React-nativeconfig: b0073a590774e8b35192fead188a36d1dca23dec
React-NativeModulesApple: df46ff3e3de5b842b30b4ca8a6caae6d7c8ab09f
React-perflogger: 3d31e0d1e8ad891e43a09ac70b7b17a79773003a
Expand All @@ -1508,7 +1538,7 @@ SPEC CHECKSUMS:
React-utils: 3285151c9d1e3a28a9586571fc81d521678c196d
ReactCommon: f42444e384d82ab89184aed5d6f3142748b54768
SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d
Yoga: b9a182ab00cf25926e7f79657d08c5d23c2d03b0
Yoga: 348f8b538c3ed4423eb58a8e5730feec50bce372

PODFILE CHECKSUM: bfbfd8238e88552e99a7519782825f7b8a191e1c

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,12 @@
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-web3authexpoexample/Pods-web3authexpoexample-frameworks.sh",
"${PODS_XCFRAMEWORKS_BUILD_DIR}/OpenSSL-Universal/OpenSSL.framework/OpenSSL",
"${PODS_XCFRAMEWORKS_BUILD_DIR}/hermes-engine/Pre-built/hermes.framework/hermes",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/OpenSSL.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/hermes.framework",
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
Loading

0 comments on commit a483069

Please sign in to comment.