forked from cerc-io/laconic-wallet-web
Handle reject tx
This commit is contained in:
parent
d95483310f
commit
198ccd98c3
@ -200,7 +200,7 @@ export const WalletEmbed = () => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
window.addEventListener('message', handleTxRequested);
|
window.addEventListener('message', handleTxRequested);
|
||||||
return () => window.removeEventListener('message', handleTxRequested);
|
return () => window.removeEventListener('message', handleTxRequested);
|
||||||
}, [networksData, handleTxRequested]);
|
}, [handleTxRequested]);
|
||||||
|
|
||||||
const acceptRequestHandler = async () => {
|
const acceptRequestHandler = async () => {
|
||||||
try {
|
try {
|
||||||
@ -242,7 +242,7 @@ export const WalletEmbed = () => {
|
|||||||
|
|
||||||
const event = txEventRef.current;
|
const event = txEventRef.current;
|
||||||
if (event?.source) {
|
if (event?.source) {
|
||||||
sendMessage(event.source as Window, 'TRANSACTION_SUCCESS', txResult.transactionHash, event.origin);
|
sendMessage(event.source as Window, 'TRANSACTION_RESPONSE', txResult.transactionHash, event.origin);
|
||||||
} else {
|
} else {
|
||||||
console.error('No event source available to send message');
|
console.error('No event source available to send message');
|
||||||
}
|
}
|
||||||
@ -255,9 +255,15 @@ export const WalletEmbed = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const rejectRequestHandler = () => {
|
const rejectRequestHandler = () => {
|
||||||
|
const event = txEventRef.current;
|
||||||
|
|
||||||
setIsTxRequested(false);
|
setIsTxRequested(false);
|
||||||
setTransactionDetails(null);
|
setTransactionDetails(null);
|
||||||
sendMessage(window, 'TRANSACTION_REJECTED', null, '*');
|
if (event?.source) {
|
||||||
|
sendMessage(event.source as Window, 'TRANSACTION_RESPONSE', null, event.origin);
|
||||||
|
} else {
|
||||||
|
console.error('No event source available to send message');
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
Loading…
Reference in New Issue
Block a user