Changeset View
Changeset View
Standalone View
Standalone View
web/cashtab/src/utils/context.js
import React from 'react'; | import React from 'react'; | ||||
import useWallet from '../hooks/useWallet'; | import useWallet from '../hooks/useWallet'; | ||||
// Authentication Context | |||||
import useWebAuthentication from '../hooks/useWebAuthentication'; | |||||
export const WalletContext = React.createContext(); | export const WalletContext = React.createContext(); | ||||
export const WalletProvider = ({ children }) => { | export const WalletProvider = ({ children }) => { | ||||
const wallet = useWallet(); | const wallet = useWallet(); | ||||
return ( | return ( | ||||
<WalletContext.Provider value={wallet}> | <WalletContext.Provider value={wallet}> | ||||
{children} | {children} | ||||
</WalletContext.Provider> | </WalletContext.Provider> | ||||
); | ); | ||||
}; | }; | ||||
// Authentication Context | |||||
import useWebAuthentication from '../hooks/useWebAuthentication'; | |||||
export const AuthenticationContext = React.createContext(); | export const AuthenticationContext = React.createContext(); | ||||
export const AuthenticationProvider = ({ children }) => { | export const AuthenticationProvider = ({ children }) => { | ||||
// useWebAuthentication returns null if Web Authn is not supported | // useWebAuthentication returns null if Web Authn is not supported | ||||
const authentication = useWebAuthentication(); | const authentication = useWebAuthentication(); | ||||
return ( | return ( | ||||
<AuthenticationContext.Provider value={authentication}> | <AuthenticationContext.Provider value={authentication}> | ||||
{children} | {children} | ||||
</AuthenticationContext.Provider> | </AuthenticationContext.Provider> | ||||
); | ); | ||||
}; | }; |