Update event handlers
This commit is contained in:
parent
16d307bba6
commit
383c00cc26
@ -22,7 +22,7 @@ const IFrameModal = ({
|
|||||||
|
|
||||||
if (event.data.type === 'WALLET_ACCOUNTS_DATA') {
|
if (event.data.type === 'WALLET_ACCOUNTS_DATA') {
|
||||||
setIsDataReceived(true);
|
setIsDataReceived(true);
|
||||||
setAccount(event.data.data[0]);
|
setAccount(event.data.data[0].address);
|
||||||
} else if (event.data.type === 'ERROR') {
|
} else if (event.data.type === 'ERROR') {
|
||||||
console.error('Error from wallet:', event.data.message);
|
console.error('Error from wallet:', event.data.message);
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ const AutoSignInIFrameModal = () => {
|
|||||||
const handleInitiateAutoSignIn = async (event: MessageEvent) => {
|
const handleInitiateAutoSignIn = async (event: MessageEvent) => {
|
||||||
if (event.origin !== VITE_WALLET_IFRAME_URL) return;
|
if (event.origin !== VITE_WALLET_IFRAME_URL) return;
|
||||||
|
|
||||||
if (event.data.type === 'ACCOUNT_ADDRESS_RESPONSE') {
|
if (event.data.type === 'WALLET_ACCOUNTS_DATA') {
|
||||||
const iframe = document.getElementById(
|
const iframe = document.getElementById(
|
||||||
'autoSignInFrame',
|
'autoSignInFrame',
|
||||||
) as HTMLIFrameElement;
|
) as HTMLIFrameElement;
|
||||||
@ -70,7 +70,7 @@ const AutoSignInIFrameModal = () => {
|
|||||||
domain: window.location.host,
|
domain: window.location.host,
|
||||||
uri: window.location.origin,
|
uri: window.location.origin,
|
||||||
chainId: 1,
|
chainId: 1,
|
||||||
address: event.data.data,
|
address: event.data.data[0].address,
|
||||||
nonce: generateNonce(),
|
nonce: generateNonce(),
|
||||||
// Human-readable ASCII assertion that the user will sign, and it must not contain `\n`.
|
// Human-readable ASCII assertion that the user will sign, and it must not contain `\n`.
|
||||||
statement: 'Sign in With Ethereum.',
|
statement: 'Sign in With Ethereum.',
|
||||||
@ -108,7 +108,7 @@ const AutoSignInIFrameModal = () => {
|
|||||||
|
|
||||||
iframe.contentWindow.postMessage(
|
iframe.contentWindow.postMessage(
|
||||||
{
|
{
|
||||||
type: 'GET_ACCOUNT_ADDRESS',
|
type: 'REQUEST_CREATE_OR_GET_ACCOUNTS',
|
||||||
chainId: '1',
|
chainId: '1',
|
||||||
secret: VITE_AUTH_SECRET,
|
secret: VITE_AUTH_SECRET,
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user