forked from cerc-io/laconic-wallet
* Add qr-code scanner button in homescreen header * Display dapp details on sign request page * Center details coming from dapp * Remove request event state from request context
31 lines
780 B
TypeScript
31 lines
780 B
TypeScript
import React, { createContext, useContext, useState } from 'react';
|
|
|
|
import { AccountsState } from '../types';
|
|
|
|
const AccountsContext = createContext<{
|
|
accounts: AccountsState;
|
|
setAccounts: (account: AccountsState) => void;
|
|
}>({
|
|
accounts: { ethAccounts: [], cosmosAccounts: [] },
|
|
setAccounts: () => {},
|
|
});
|
|
|
|
const useAccounts = () => {
|
|
const accountsContext = useContext(AccountsContext);
|
|
return accountsContext;
|
|
};
|
|
|
|
const AccountsProvider = ({ children }: { children: any }) => {
|
|
const [accounts, setAccounts] = useState<AccountsState>({
|
|
ethAccounts: [],
|
|
cosmosAccounts: [],
|
|
});
|
|
return (
|
|
<AccountsContext.Provider value={{ accounts, setAccounts }}>
|
|
{children}
|
|
</AccountsContext.Provider>
|
|
);
|
|
};
|
|
|
|
export { useAccounts, AccountsProvider };
|