Skip to content

Commit fe923b6

Browse files
committed
Update bare react native example
1 parent 142934f commit fe923b6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+7241
-19929
lines changed

demo/rn-bare-example/.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module.exports = {
22
root: true,
3-
extends: '@react-native-community',
3+
extends: '@react-native',
44
};

demo/rn-bare-example/.gitignore

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ DerivedData
2020
*.hmap
2121
*.ipa
2222
*.xcuserstate
23-
ios/.xcode.env.local
23+
**/.xcode.env.local
2424

2525
# Android/IntelliJ
2626
#
@@ -56,8 +56,19 @@ yarn-error.log
5656
*.jsbundle
5757

5858
# Ruby / CocoaPods
59-
/ios/Pods/
59+
**/Pods/
6060
/vendor/bundle/
6161

6262
# Temporary files created by Metro to check the health of the file watcher
6363
.metro-health-check*
64+
65+
# testing
66+
/coverage
67+
68+
# Yarn
69+
.yarn/*
70+
!.yarn/patches
71+
!.yarn/plugins
72+
!.yarn/releases
73+
!.yarn/sdks
74+
!.yarn/versions

demo/rn-bare-example/.node-version

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{}
1+
{}

demo/rn-bare-example/App.tsx

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ import {
99
TextInput,
1010
View,
1111
} from 'react-native';
12-
import React, { useEffect, useState } from 'react';
12+
import React, {useEffect, useState} from 'react';
1313
import Web3Auth, {
1414
IWeb3Auth,
1515
LOGIN_PROVIDER,
1616
OpenloginUserInfo,
1717
} from '@web3auth/react-native-sdk';
1818

19-
import { ChainNamespace } from '@web3auth/react-native-sdk';
19+
import {ChainNamespace} from '@web3auth/react-native-sdk';
2020
import EncryptedStorage from 'react-native-encrypted-storage';
2121
import RPC from './ethersRPC'; // for using ethers.js
2222

@@ -30,7 +30,7 @@ export default function App() {
3030
const [key, setKey] = useState<string | undefined>('');
3131
const [console, setConsole] = useState<string>('');
3232
const [web3auth, setWeb3Auth] = useState<IWeb3Auth | null>(null);
33-
const [email, setEmail] = React.useState('[email protected]');
33+
const [email, setEmail] = React.useState('[email protected]');
3434

3535
const login = async () => {
3636
try {
@@ -57,7 +57,6 @@ export default function App() {
5757
uiConsole('Logged In');
5858
}
5959
} catch (e: unknown) {
60-
console.log(e, (e as Error).stack);
6160
setConsole((e as Error).message);
6261
}
6362
};
@@ -86,8 +85,8 @@ export default function App() {
8685

8786
setConsole('Enable MFA');
8887
await web3auth.enableMFA();
89-
uiConsole('MFA enabled')
90-
}
88+
uiConsole('MFA enabled');
89+
};
9190

9291
const launchWallerSerices = async () => {
9392
if (!web3auth) {
@@ -96,23 +95,27 @@ export default function App() {
9695
}
9796

9897
setConsole('Launch Wallet Services');
99-
await web3auth.launchWalletServices({
100-
loginProvider: LOGIN_PROVIDER.EMAIL_PASSWORDLESS,
101-
redirectUrl: resolvedRedirectUrl,
102-
mfaLevel: 'default',
103-
curve: 'secp256k1',
104-
extraLoginOptions: {
105-
login_hint: email,
106-
connection: 'email',
98+
await web3auth.launchWalletServices(
99+
{
100+
loginProvider: LOGIN_PROVIDER.EMAIL_PASSWORDLESS,
101+
redirectUrl: resolvedRedirectUrl,
102+
mfaLevel: 'default',
103+
curve: 'secp256k1',
104+
extraLoginOptions: {
105+
login_hint: email,
106+
connection: 'email',
107+
},
107108
},
108-
}, {
109-
chainNamespace: ChainNamespace.EIP155,
110-
decimals: 18,
111-
chainId: "0x1",
112-
rpcTarget: "https://mainnet.infura.io/v3/daeee53504be4cd3a997d4f2718d33e0",
113-
ticker: "ETH",
114-
});
115-
}
109+
{
110+
chainNamespace: ChainNamespace.EIP155,
111+
decimals: 18,
112+
chainId: '0x1',
113+
rpcTarget:
114+
'https://mainnet.infura.io/v3/daeee53504be4cd3a997d4f2718d33e0',
115+
ticker: 'ETH',
116+
},
117+
);
118+
};
116119

117120
useEffect(() => {
118121
const init = async () => {
@@ -186,7 +189,10 @@ export default function App() {
186189
<View style={styles.buttonArea}>
187190
<Button title="Get User Info" onPress={() => uiConsole(userInfo)} />
188191
<Button title="Enable MFA" onPress={() => enableMFA()} />
189-
<Button title="launch Wallet Services" onPress={() => launchWallerSerices()} />
192+
<Button
193+
title="launch Wallet Services"
194+
onPress={() => launchWallerSerices()}
195+
/>
190196
<Button title="Get Chain ID" onPress={() => getChainId()} />
191197
<Button title="Get Accounts" onPress={() => getAccounts()} />
192198
<Button title="Get Balance" onPress={() => getBalance()} />
@@ -204,7 +210,7 @@ export default function App() {
204210
onChangeText={text => setEmail(text)}
205211
value={email}
206212
// eslint-disable-next-line react-native/no-inline-styles
207-
style={{ padding: 10 }}
213+
style={{padding: 10}}
208214
/>
209215
<Button title="Login with Web3Auth" onPress={login} />
210216
</View>

demo/rn-bare-example/Gemfile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
source 'https://rubygems.org'
22

33
# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
4-
ruby '>= 2.6.10'
4+
ruby ">= 2.6.10"
55

6-
gem 'cocoapods', '>= 1.11.3'
6+
# Cocoapods 1.15 introduced a bug which break the build. We will remove the upper
7+
# bound in the template on Cocoapods with next React Native release.
8+
gem 'cocoapods', '>= 1.13', '< 1.15'
9+
gem 'activesupport', '>= 6.1.7.5', '< 7.1.0'

demo/rn-bare-example/Gemfile.lock

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,29 @@
11
GEM
22
remote: https://rubygems.org/
33
specs:
4-
CFPropertyList (3.0.6)
4+
CFPropertyList (3.0.7)
5+
base64
6+
nkf
57
rexml
6-
activesupport (7.0.5)
8+
activesupport (7.0.8.1)
79
concurrent-ruby (~> 1.0, >= 1.0.2)
810
i18n (>= 1.6, < 2)
911
minitest (>= 5.1)
1012
tzinfo (~> 2.0)
11-
addressable (2.8.4)
13+
addressable (2.8.6)
1214
public_suffix (>= 2.0.2, < 6.0)
1315
algoliasearch (1.27.5)
1416
httpclient (~> 2.8, >= 2.8.3)
1517
json (>= 1.5.1)
1618
atomos (0.1.3)
19+
base64 (0.2.0)
1720
claide (1.1.0)
18-
cocoapods (1.12.1)
21+
cocoapods (1.14.3)
1922
addressable (~> 2.8)
2023
claide (>= 1.0.2, < 2.0)
21-
cocoapods-core (= 1.12.1)
24+
cocoapods-core (= 1.14.3)
2225
cocoapods-deintegrate (>= 1.0.3, < 2.0)
23-
cocoapods-downloader (>= 1.6.0, < 2.0)
26+
cocoapods-downloader (>= 2.1, < 3.0)
2427
cocoapods-plugins (>= 1.0.0, < 2.0)
2528
cocoapods-search (>= 1.0.0, < 2.0)
2629
cocoapods-trunk (>= 1.6.0, < 2.0)
@@ -32,8 +35,8 @@ GEM
3235
molinillo (~> 0.8.0)
3336
nap (~> 1.0)
3437
ruby-macho (>= 2.3.0, < 3.0)
35-
xcodeproj (>= 1.21.0, < 2.0)
36-
cocoapods-core (1.12.1)
38+
xcodeproj (>= 1.23.0, < 2.0)
39+
cocoapods-core (1.14.3)
3740
activesupport (>= 5.0, < 8)
3841
addressable (~> 2.8)
3942
algoliasearch (~> 1.0)
@@ -44,7 +47,7 @@ GEM
4447
public_suffix (~> 4.0)
4548
typhoeus (~> 1.0)
4649
cocoapods-deintegrate (1.0.5)
47-
cocoapods-downloader (1.6.3)
50+
cocoapods-downloader (2.1)
4851
cocoapods-plugins (1.0.0)
4952
nap
5053
cocoapods-search (1.0.1)
@@ -53,31 +56,32 @@ GEM
5356
netrc (~> 0.11)
5457
cocoapods-try (1.2.0)
5558
colored2 (3.1.2)
56-
concurrent-ruby (1.2.2)
59+
concurrent-ruby (1.2.3)
5760
escape (0.0.4)
5861
ethon (0.16.0)
5962
ffi (>= 1.15.0)
60-
ffi (1.15.5)
63+
ffi (1.16.3)
6164
fourflusher (2.3.1)
6265
fuzzy_match (2.0.4)
6366
gh_inspector (1.1.3)
6467
httpclient (2.8.3)
65-
i18n (1.14.1)
68+
i18n (1.14.5)
6669
concurrent-ruby (~> 1.0)
67-
json (2.6.3)
68-
minitest (5.18.0)
70+
json (2.7.2)
71+
minitest (5.22.3)
6972
molinillo (0.8.0)
7073
nanaimo (0.3.0)
7174
nap (1.1.0)
7275
netrc (0.11.0)
76+
nkf (0.2.0)
7377
public_suffix (4.0.7)
74-
rexml (3.2.5)
78+
rexml (3.2.6)
7579
ruby-macho (2.5.1)
76-
typhoeus (1.4.0)
80+
typhoeus (1.4.1)
7781
ethon (>= 0.9.0)
7882
tzinfo (2.0.6)
7983
concurrent-ruby (~> 1.0)
80-
xcodeproj (1.22.0)
84+
xcodeproj (1.24.0)
8185
CFPropertyList (>= 2.3.3, < 4.0)
8286
atomos (~> 0.1.3)
8387
claide (>= 1.0.2, < 2.0)
@@ -89,10 +93,11 @@ PLATFORMS
8993
ruby
9094

9195
DEPENDENCIES
92-
cocoapods (>= 1.11.3)
96+
activesupport (>= 6.1.7.5, < 7.1.0)
97+
cocoapods (>= 1.13, < 1.15)
9398

9499
RUBY VERSION
95-
ruby 2.7.7p221
100+
ruby 2.7.5p203
96101

97102
BUNDLED WITH
98-
2.3.26
103+
2.1.4

demo/rn-bare-example/README.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
This is a new [**React Native**](https://reactnative.dev) project, bootstrapped using [`@react-native-community/cli`](https://github.com/react-native-community/cli).
2+
3+
# Getting Started
4+
5+
>**Note**: Make sure you have completed the [React Native - Environment Setup](https://reactnative.dev/docs/environment-setup) instructions till "Creating a new application" step, before proceeding.
6+
7+
## Step 1: Start the Metro Server
8+
9+
First, you will need to start **Metro**, the JavaScript _bundler_ that ships _with_ React Native.
10+
11+
To start Metro, run the following command from the _root_ of your React Native project:
12+
13+
```bash
14+
# using npm
15+
npm start
16+
17+
# OR using Yarn
18+
yarn start
19+
```
20+
21+
## Step 2: Start your Application
22+
23+
Let Metro Bundler run in its _own_ terminal. Open a _new_ terminal from the _root_ of your React Native project. Run the following command to start your _Android_ or _iOS_ app:
24+
25+
### For Android
26+
27+
```bash
28+
# using npm
29+
npm run android
30+
31+
# OR using Yarn
32+
yarn android
33+
```
34+
35+
### For iOS
36+
37+
```bash
38+
# using npm
39+
npm run ios
40+
41+
# OR using Yarn
42+
yarn ios
43+
```
44+
45+
If everything is set up _correctly_, you should see your new app running in your _Android Emulator_ or _iOS Simulator_ shortly provided you have set up your emulator/simulator correctly.
46+
47+
This is one way to run your app — you can also run it directly from within Android Studio and Xcode respectively.
48+
49+
## Step 3: Modifying your App
50+
51+
Now that you have successfully run the app, let's modify it.
52+
53+
1. Open `App.tsx` in your text editor of choice and edit some lines.
54+
2. For **Android**: Press the <kbd>R</kbd> key twice or select **"Reload"** from the **Developer Menu** (<kbd>Ctrl</kbd> + <kbd>M</kbd> (on Window and Linux) or <kbd>Cmd ⌘</kbd> + <kbd>M</kbd> (on macOS)) to see your changes!
55+
56+
For **iOS**: Hit <kbd>Cmd ⌘</kbd> + <kbd>R</kbd> in your iOS Simulator to reload the app and see your changes!
57+
58+
## Congratulations! :tada:
59+
60+
You've successfully run and modified your React Native App. :partying_face:
61+
62+
### Now what?
63+
64+
- If you want to add this new React Native code to an existing application, check out the [Integration guide](https://reactnative.dev/docs/integration-with-existing-apps).
65+
- If you're curious to learn more about React Native, check out the [Introduction to React Native](https://reactnative.dev/docs/getting-started).
66+
67+
# Troubleshooting
68+
69+
If you can't get this to work, see the [Troubleshooting](https://reactnative.dev/docs/troubleshooting) page.
70+
71+
# Learn More
72+
73+
To learn more about React Native, take a look at the following resources:
74+
75+
- [React Native Website](https://reactnative.dev) - learn more about React Native.
76+
- [Getting Started](https://reactnative.dev/docs/environment-setup) - an **overview** of React Native and how setup your environment.
77+
- [Learn the Basics](https://reactnative.dev/docs/getting-started) - a **guided tour** of the React Native **basics**.
78+
- [Blog](https://reactnative.dev/blog) - read the latest official React Native **Blog** posts.
79+
- [`@facebook/react-native`](https://github.com/facebook/react-native) - the Open Source; GitHub **repository** for React Native.

demo/rn-bare-example/__tests__/App-test.tsx renamed to demo/rn-bare-example/__tests__/App.test.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ import 'react-native';
66
import React from 'react';
77
import App from '../App';
88

9+
// Note: import explicitly to use the types shipped with jest.
10+
import {it} from '@jest/globals';
11+
912
// Note: test renderer must be required after react-native.
1013
import renderer from 'react-test-renderer';
1114

0 commit comments

Comments
 (0)