-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: cleaned the useOnboardingData hook
- Loading branch information
1 parent
00c3fa0
commit 0eb8d83
Showing
6 changed files
with
100 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { ChainNamespace } from "@web3auth/react-native-sdk"; | ||
|
||
export const STRINGS = { | ||
continueWith: "Continue with:", | ||
loginWith: "Login with Auth0", | ||
logout: "Logout", | ||
or: "or", | ||
createWallet: "Create a new wallet", | ||
alreadyHaveWallet: "I already have a wallet", | ||
byProceeding: "By proceeding, you agree to Umami's", | ||
terms: "Terms of Use", | ||
and: "and", | ||
privacyPolicy: "Privacy Policy", | ||
}; | ||
|
||
export const WEB3_AUTH_CLIENT_ID = process.env.EXPO_PUBLIC_WEB3_AUTH_CLIENT_ID; | ||
|
||
export const CHAIN_CONFIG = { | ||
chainNamespace: ChainNamespace.EIP155, | ||
chainId: "0x1", | ||
rpcTarget: "https://rpc.tzbeta.net/", | ||
displayName: "Tezos Mainnet", | ||
blockExplorerUrl: "https://tzstats.com", | ||
ticker: "XTZ", | ||
tickerName: "Tezos", | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./constants"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import Web3Auth, { WEB3AUTH_NETWORK } from "@web3auth/react-native-sdk"; | ||
import { CommonPrivateKeyProvider } from "@web3auth/base-provider"; | ||
import { CHAIN_CONFIG, WEB3_AUTH_CLIENT_ID } from "../constants"; | ||
import * as WebBrowser from "expo-web-browser"; | ||
import * as SecureStore from "expo-secure-store"; | ||
import { makeRedirectUri } from "expo-auth-session"; | ||
|
||
export const createWeb3AuthInstance = () => { | ||
const privateKeyProvider = new CommonPrivateKeyProvider({ | ||
config: { chainConfig: CHAIN_CONFIG }, | ||
}); | ||
|
||
const redirectUrl = makeRedirectUri({ | ||
scheme: "umami", | ||
path: "auth", | ||
}); | ||
|
||
console.log("redirectUrl", redirectUrl); | ||
|
||
return new Web3Auth(WebBrowser, SecureStore, { | ||
clientId: WEB3_AUTH_CLIENT_ID ?? "", | ||
network: WEB3AUTH_NETWORK.SAPPHIRE_DEVNET, | ||
privateKeyProvider, | ||
redirectUrl, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import * as WebBrowser from "expo-web-browser"; | ||
|
||
export const openBrowser = async (link: string): Promise<void> => { | ||
try { | ||
await WebBrowser.openBrowserAsync(link); | ||
} catch (error) { | ||
console.error("Error opening browser:", error); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import * as SecureStore from "expo-secure-store"; | ||
|
||
export const saveToken = async (key: string, value: string): Promise<void> => { | ||
try { | ||
await SecureStore.setItemAsync(key, value); | ||
} catch (error) { | ||
console.error("Error saving token:", error); | ||
} | ||
}; | ||
|
||
export const getToken = async (key: string): Promise<string | null> => { | ||
try { | ||
return await SecureStore.getItemAsync(key); | ||
} catch (error) { | ||
console.error("Error retrieving token:", error); | ||
return null; | ||
} | ||
}; |