Skip to content

Commit

Permalink
Adds provider in the constructor params
Browse files Browse the repository at this point in the history
  • Loading branch information
arch1995 committed Sep 25, 2024
1 parent 4ef529e commit b2a4c82
Show file tree
Hide file tree
Showing 8 changed files with 229 additions and 38 deletions.
13 changes: 6 additions & 7 deletions demo/rn-bare-example/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const web3auth = new Web3Auth(WebBrowser, EncryptedStorage, {
redirectUrl,
// IMP END - Whitelist bundle ID
network: WEB3AUTH_NETWORK.SAPPHIRE_MAINNET, // or other networks
privateKeyProvider: ethereumPrivateKeyProvider,
});
// IMP END - SDK Initialization

Expand All @@ -60,10 +61,9 @@ 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);
setProvider(web3auth.provider);
setLoggedIn(true);
}
};
Expand Down Expand Up @@ -91,10 +91,9 @@ export default function App() {
});
uiConsole(web3auth.userInfo);

if (web3auth.privKey) {
await ethereumPrivateKeyProvider.setupProvider(web3auth.privKey);
if (web3auth.connected) {
// IMP END - Login
setProvider(ethereumPrivateKeyProvider);
setProvider(web3auth.provider);
uiConsole("Logged In");
setLoggedIn(true);
}
Expand All @@ -114,7 +113,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
2 changes: 1 addition & 1 deletion demo/rn-bare-example/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

119 changes: 119 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"@types/node": "^20",
"@types/react-native": "^0.72.8",
"@types/urijs": "^1.19.25",
"@web3auth/base": "^9.0.2",
"eslint": "^8.53.0",
"husky": "^9.1.6",
"lint-staged": "^15.2.10",
Expand Down
Loading

0 comments on commit b2a4c82

Please sign in to comment.