Keep method to post message in utils
This commit is contained in:
parent
a0977f910d
commit
5ab06ed460
@ -5,6 +5,7 @@ import { useNetworks } from '../context/NetworksContext';
|
||||
import { Account } from '../types';
|
||||
import { signMessage } from '../utils/sign-message';
|
||||
import { EIP155 } from '../utils/constants';
|
||||
import { sendMessage } from '../utils/misc';
|
||||
|
||||
export const AutoSignIn = () => {
|
||||
const { networksData } = useNetworks();
|
||||
@ -25,15 +26,6 @@ export const AutoSignIn = () => {
|
||||
return accounts
|
||||
}, [networksData]);
|
||||
|
||||
const sendMessage = (
|
||||
source: Window | null,
|
||||
type: string,
|
||||
data: any,
|
||||
origin: string
|
||||
): void => {
|
||||
source?.postMessage({ type, data }, origin);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
const handleSignIn = async (event: MessageEvent) => {
|
||||
if (event.data.type !== 'AUTO_SIGN_IN') return;
|
||||
@ -60,7 +52,6 @@ export const AutoSignIn = () => {
|
||||
const getAccountAddress = async (event: MessageEvent) => {
|
||||
if (event.data.type !== 'GET_ACCOUNT_ADDRESS') return;
|
||||
|
||||
|
||||
if (event.data.secret !== process.env.REACT_APP_AUTH_SECRET) {
|
||||
console.log('Unauthorized app.');
|
||||
return;
|
||||
|
||||
@ -169,7 +169,6 @@ export const WalletEmbed = () => {
|
||||
|
||||
if (!checkSufficientFunds(amount, balance.amount)) {
|
||||
console.log("Insufficient funds detected");
|
||||
sendMessage(event.source as Window, 'INSUFFICIENT_FUNDS', null, event.origin);
|
||||
throw new Error('Insufficient funds');
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user