Keep method to post message in utils

This commit is contained in:
IshaVenikar 2025-02-10 17:35:47 +05:30
parent a0977f910d
commit 5ab06ed460
2 changed files with 1 additions and 11 deletions

View File

@ -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;

View File

@ -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');
}