Skip to content

Commit c3b2b6b

Browse files
authored
Merge pull request #1283 from Web3Auth/rn-v8-upgrade
Update Web3Auth React Native SDK Examples to v8
2 parents e36b441 + 3d5050f commit c3b2b6b

32 files changed

+3270
-3225
lines changed

react-native/rn-bare-aggregate-verifier-example/App.tsx

+11-12
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import React, { useEffect, useState } from "react";
2-
import { StyleSheet, Text, View, Button, ScrollView, Dimensions } from "react-native";
31
import * as WebBrowser from "@toruslabs/react-native-web-browser";
4-
import EncryptedStorage from "react-native-encrypted-storage";
5-
import Web3Auth, { OPENLOGIN_NETWORK, ChainNamespace } from "@web3auth/react-native-sdk";
62
import { EthereumPrivateKeyProvider } from "@web3auth/ethereum-provider";
3+
import Web3Auth, { ChainNamespace, WEB3AUTH_NETWORK } from "@web3auth/react-native-sdk";
4+
import React, { useEffect, useState } from "react";
5+
import { Button, Dimensions, ScrollView, StyleSheet, Text, View } from "react-native";
6+
import EncryptedStorage from "react-native-encrypted-storage";
77

88
// import RPC from './web3RPC'; // for using web3.js
99
// import RPC from "./viemRPC"; // for using viem
1010
import RPC from "./ethersRPC"; // for using ethers.js
1111

1212
const scheme = "web3authrnbareaggregateexample"; // Or your desired app redirection scheme
13-
const redirectUrl = `${scheme}://openlogin`;
13+
const redirectUrl = `${scheme}://auth`;
1414
const clientId = "BPi5PB_UiIZ-cPz1GtV5i1I2iOSOHuimiXBI0e-Oe_u6X3oVAbCiAZOTEBtTXw4tsluTITPqA8zMsfxIKMjiqNQ";
1515

1616
const chainConfig = {
@@ -35,9 +35,10 @@ const ethereumPrivateKeyProvider = new EthereumPrivateKeyProvider({
3535

3636
const web3auth = new Web3Auth(WebBrowser, EncryptedStorage, {
3737
clientId,
38-
network: OPENLOGIN_NETWORK.SAPPHIRE_MAINNET, // or other networks
38+
network: WEB3AUTH_NETWORK.SAPPHIRE_MAINNET, // or other networks
3939
redirectUrl,
4040
useCoreKitKey: true,
41+
privateKeyProvider: ethereumPrivateKeyProvider,
4142
loginConfig: {
4243
google: {
4344
verifier: "aggregate-sapphire",
@@ -84,8 +85,7 @@ export default function App() {
8485
// IMP START - SDK Initialization
8586
await web3auth.init();
8687

87-
if (web3auth.privKey) {
88-
await ethereumPrivateKeyProvider.setupProvider(web3auth.privKey);
88+
if (web3auth.connected) {
8989
// IMP END - SDK Initialization
9090
setProvider(ethereumPrivateKeyProvider);
9191
setLoggedIn(true);
@@ -103,8 +103,7 @@ export default function App() {
103103
});
104104

105105
uiConsole("Logged In");
106-
if (web3auth.privKey) {
107-
await ethereumPrivateKeyProvider.setupProvider(web3auth.privKey);
106+
if (web3auth.connected) {
108107
// IMP END - Login
109108
setProvider(ethereumPrivateKeyProvider);
110109
uiConsole("Logged In");
@@ -124,7 +123,7 @@ export default function App() {
124123
setConsole("Logging out");
125124
await web3auth.logout();
126125

127-
if (!web3auth.privKey) {
126+
if (!web3auth.connected) {
128127
setProvider(null);
129128
uiConsole("Logged out");
130129
setLoggedIn(false);
@@ -301,7 +300,7 @@ export default function App() {
301300
};
302301

303302
const uiConsole = (...args: unknown[]) => {
304-
setConsole(JSON.stringify(args || {}, null, 2) + "\n\n\n\n" + console);
303+
setConsole(`${JSON.stringify(args || {}, null, 2)}\n\n\n\n${console}`);
305304
};
306305

307306
const loggedInView = (
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
1+
// eslint-disable-next-line @typescript-eslint/no-var-requires
12
global.Buffer = require("buffer").Buffer;
23

4+
// eslint-disable-next-line import/first
5+
import { install } from "react-native-quick-crypto";
6+
7+
install();
8+
39
// Needed so that 'stream-http' chooses the right default protocol.
410
global.location = {
5-
protocol: "file:",
11+
protocol: "file:",
612
};
713

814
global.process.version = "v16.0.0";
915
if (!global.process.version) {
10-
global.process = require("process");
11-
console.log({ process: global.process });
16+
global.process = require("process");
17+
// eslint-disable-next-line no-console
18+
console.log({ process: global.process });
1219
}
1320

14-
process.browser = true;
21+
process.browser = true;

react-native/rn-bare-aggregate-verifier-example/ios/Podfile.lock

+31-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ PODS:
77
- hermes-engine (0.74.2):
88
- hermes-engine/Pre-built (= 0.74.2)
99
- hermes-engine/Pre-built (0.74.2)
10+
- OpenSSL-Universal (3.3.2000)
1011
- RCT-Folly (2024.01.01.00):
1112
- boost
1213
- DoubleConversion
@@ -939,6 +940,29 @@ PODS:
939940
- React-Core
940941
- react-native-get-random-values (1.11.0):
941942
- React-Core
943+
- react-native-quick-crypto (0.7.6):
944+
- DoubleConversion
945+
- glog
946+
- hermes-engine
947+
- OpenSSL-Universal
948+
- RCT-Folly (= 2024.01.01.00)
949+
- RCTRequired
950+
- RCTTypeSafety
951+
- React
952+
- React-Codegen
953+
- React-Core
954+
- React-debug
955+
- React-Fabric
956+
- React-featureflags
957+
- React-graphics
958+
- React-ImageManager
959+
- React-NativeModulesApple
960+
- React-RCTFabric
961+
- React-rendererdebug
962+
- React-utils
963+
- ReactCommon/turbomodule/bridging
964+
- ReactCommon/turbomodule/core
965+
- Yoga
942966
- react-native-web-browser (1.1.0):
943967
- React-Core
944968
- React-nativeconfig (0.74.2)
@@ -1208,6 +1232,7 @@ DEPENDENCIES:
12081232
- React-Mapbuffer (from `../node_modules/react-native/ReactCommon`)
12091233
- react-native-encrypted-storage (from `../node_modules/react-native-encrypted-storage`)
12101234
- react-native-get-random-values (from `../node_modules/react-native-get-random-values`)
1235+
- react-native-quick-crypto (from `../node_modules/react-native-quick-crypto`)
12111236
- "react-native-web-browser (from `../node_modules/@toruslabs/react-native-web-browser`)"
12121237
- React-nativeconfig (from `../node_modules/react-native/ReactCommon`)
12131238
- React-NativeModulesApple (from `../node_modules/react-native/ReactCommon/react/nativemodule/core/platform/ios`)
@@ -1236,6 +1261,7 @@ DEPENDENCIES:
12361261

12371262
SPEC REPOS:
12381263
trunk:
1264+
- OpenSSL-Universal
12391265
- SocketRocket
12401266

12411267
EXTERNAL SOURCES:
@@ -1304,6 +1330,8 @@ EXTERNAL SOURCES:
13041330
:path: "../node_modules/react-native-encrypted-storage"
13051331
react-native-get-random-values:
13061332
:path: "../node_modules/react-native-get-random-values"
1333+
react-native-quick-crypto:
1334+
:path: "../node_modules/react-native-quick-crypto"
13071335
react-native-web-browser:
13081336
:path: "../node_modules/@toruslabs/react-native-web-browser"
13091337
React-nativeconfig:
@@ -1362,6 +1390,7 @@ SPEC CHECKSUMS:
13621390
fmt: 4c2741a687cc09f0634a2e2c72a838b99f1ff120
13631391
glog: fdfdfe5479092de0c4bdbebedd9056951f092c4f
13641392
hermes-engine: 01d3e052018c2a13937aca1860fbedbccd4a41b7
1393+
OpenSSL-Universal: b60a3702c9fea8b3145549d421fdb018e53ab7b4
13651394
RCT-Folly: 02617c592a293bd6d418e0a88ff4ee1f88329b47
13661395
RCTDeprecation: b03c35057846b685b3ccadc9bfe43e349989cdb2
13671396
RCTRequired: 194626909cfa8d39ca6663138c417bc6c431648c
@@ -1388,6 +1417,7 @@ SPEC CHECKSUMS:
13881417
React-Mapbuffer: bf56147c9775491e53122a94c423ac201417e326
13891418
react-native-encrypted-storage: db300a3f2f0aba1e818417c1c0a6be549038deb7
13901419
react-native-get-random-values: 21325b2244dfa6b58878f51f9aa42821e7ba3d06
1420+
react-native-quick-crypto: 3d1d972bc231e88073b3821dbaf89f84d8208200
13911421
react-native-web-browser: 087b454e1e94b58b40ba73f54251d77486144d19
13921422
React-nativeconfig: 9f223cd321823afdecf59ed00861ab2d69ee0fc1
13931423
React-NativeModulesApple: ff7efaff7098639db5631236cfd91d60abff04c0
@@ -1413,7 +1443,7 @@ SPEC CHECKSUMS:
14131443
React-utils: 4476b7fcbbd95cfd002f3e778616155241d86e31
14141444
ReactCommon: ecad995f26e0d1e24061f60f4e5d74782f003f12
14151445
SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d
1416-
Yoga: 2f71ecf38d934aecb366e686278102a51679c308
1446+
Yoga: ae3c32c514802d30f687a04a6a35b348506d411f
14171447

14181448
PODFILE CHECKSUM: cdf505c86a042435106cb526157d127c0fa9785c
14191449

0 commit comments

Comments
 (0)