mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 01:39:44 +01:00
Adding check for transaction.id in useTransactionEventFragment hook (#13587)
This commit is contained in:
parent
79e96f93db
commit
a06a0d21e0
@ -1,4 +1,4 @@
|
|||||||
import { useCallback, useEffect } from 'react';
|
import { useCallback } from 'react';
|
||||||
import { useSelector } from 'react-redux';
|
import { useSelector } from 'react-redux';
|
||||||
|
|
||||||
import { useGasFeeContext } from '../contexts/gasFee';
|
import { useGasFeeContext } from '../contexts/gasFee';
|
||||||
@ -18,23 +18,20 @@ export const useTransactionEventFragment = () => {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!fragment && transaction) {
|
|
||||||
createTransactionEventFragment(
|
|
||||||
transaction.id,
|
|
||||||
TRANSACTION_EVENTS.APPROVED,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}, [fragment, transaction]);
|
|
||||||
|
|
||||||
const updateTransactionEventFragment = useCallback(
|
const updateTransactionEventFragment = useCallback(
|
||||||
(params) => {
|
async (params) => {
|
||||||
if (!transaction) {
|
if (!transaction || !transaction.id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!fragment) {
|
||||||
|
await createTransactionEventFragment(
|
||||||
|
transaction.id,
|
||||||
|
TRANSACTION_EVENTS.APPROVED,
|
||||||
|
);
|
||||||
|
}
|
||||||
updateEventFragment(`transaction-added-${transaction.id}`, params);
|
updateEventFragment(`transaction-added-${transaction.id}`, params);
|
||||||
},
|
},
|
||||||
[transaction],
|
[fragment, transaction],
|
||||||
);
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
Loading…
Reference in New Issue
Block a user