fix(governance): dont start listening for pending eth events until connected (#3996)
This commit is contained in:
parent
ef25552311
commit
653ca034f2
@ -3,32 +3,32 @@ import { usePendingBalancesStore } from './use-pending-balances-manager';
|
|||||||
import type { Contract } from 'ethers';
|
import type { Contract } from 'ethers';
|
||||||
import { useListenForPendingEthEvents } from './use-listen-for-pending-eth-events';
|
import { useListenForPendingEthEvents } from './use-listen-for-pending-eth-events';
|
||||||
import { prepend0x } from '@vegaprotocol/smart-contracts';
|
import { prepend0x } from '@vegaprotocol/smart-contracts';
|
||||||
|
import { useWeb3React } from '@web3-react/core';
|
||||||
|
|
||||||
export const useListenForStakingEvents = (
|
export const useListenForStakingEvents = (
|
||||||
contract: Contract | undefined,
|
contract: Contract | undefined,
|
||||||
vegaPublicKey: string | null,
|
vegaPublicKey: string | null,
|
||||||
numberOfConfirmations: number
|
numberOfConfirmations: number
|
||||||
) => {
|
) => {
|
||||||
|
const { account } = useWeb3React();
|
||||||
const { addPendingTxs, removePendingTx, resetPendingTxs } =
|
const { addPendingTxs, removePendingTx, resetPendingTxs } =
|
||||||
usePendingBalancesStore((state) => ({
|
usePendingBalancesStore((state) => ({
|
||||||
addPendingTxs: state.addPendingTxs,
|
addPendingTxs: state.addPendingTxs,
|
||||||
removePendingTx: state.removePendingTx,
|
removePendingTx: state.removePendingTx,
|
||||||
resetPendingTxs: state.resetPendingTxs,
|
resetPendingTxs: state.resetPendingTxs,
|
||||||
}));
|
}));
|
||||||
const addFilter = useMemo(
|
const addFilter = useMemo(() => {
|
||||||
() =>
|
if (!account || !vegaPublicKey || !contract) return null;
|
||||||
vegaPublicKey && contract
|
return contract.filters.Stake_Deposited(
|
||||||
? contract.filters.Stake_Deposited(null, null, prepend0x(vegaPublicKey))
|
null,
|
||||||
: null,
|
null,
|
||||||
[contract, vegaPublicKey]
|
prepend0x(vegaPublicKey)
|
||||||
);
|
);
|
||||||
const removeFilter = useMemo(
|
}, [contract, vegaPublicKey, account]);
|
||||||
() =>
|
const removeFilter = useMemo(() => {
|
||||||
vegaPublicKey && contract
|
if (!account || !vegaPublicKey || !contract) return null;
|
||||||
? contract.filters.Stake_Removed(null, null, prepend0x(vegaPublicKey))
|
return contract.filters.Stake_Removed(null, null, prepend0x(vegaPublicKey));
|
||||||
: null,
|
}, [contract, vegaPublicKey, account]);
|
||||||
[contract, vegaPublicKey]
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Listen for all add stake events
|
* Listen for all add stake events
|
||||||
|
Loading…
Reference in New Issue
Block a user