2022-12-21 09:29:32 +00:00
|
|
|
import { useBridgeContract } from './use-bridge-contract';
|
2022-09-06 01:30:13 +00:00
|
|
|
import { useCallback } from 'react';
|
2023-06-06 13:10:03 +00:00
|
|
|
import { localLoggerFactory } from '@vegaprotocol/logger';
|
2022-09-06 01:30:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the delay in seconds thats required if the withdrawal amount is
|
|
|
|
* over the withdrawal threshold (contract.get_withdraw_threshold)
|
|
|
|
*/
|
|
|
|
export const useGetWithdrawDelay = () => {
|
|
|
|
const contract = useBridgeContract();
|
|
|
|
const getDelay = useCallback(async () => {
|
2023-05-17 06:31:53 +00:00
|
|
|
const logger = localLoggerFactory({ application: 'web3' });
|
2022-09-06 01:30:13 +00:00
|
|
|
try {
|
2023-05-17 06:31:53 +00:00
|
|
|
logger.info('get withdraw delay', { contract: contract?.toString() });
|
2022-09-06 01:30:13 +00:00
|
|
|
const res = await contract?.default_withdraw_delay();
|
|
|
|
return res.toNumber();
|
|
|
|
} catch (err) {
|
2023-05-17 06:31:53 +00:00
|
|
|
logger.error('get withdraw delay', err);
|
2022-09-06 01:30:13 +00:00
|
|
|
}
|
|
|
|
}, [contract]);
|
|
|
|
|
|
|
|
return getDelay;
|
|
|
|
};
|