chore: capture contract call reverted as error, capture args for verify withdrawal and get allowance
This commit is contained in:
@@ -17,20 +17,20 @@ export const useGetAllowance = (
|
||||
if (!contract || !account || !config || !asset) {
|
||||
return;
|
||||
}
|
||||
|
||||
const logger = localLoggerFactory({ application: 'deposits' });
|
||||
try {
|
||||
logger.info('get allowance', {
|
||||
account,
|
||||
contractAddress: config.collateral_bridge_contract.address,
|
||||
});
|
||||
const res = await contract.allowance(
|
||||
account,
|
||||
config.collateral_bridge_contract.address
|
||||
);
|
||||
|
||||
return new BigNumber(addDecimal(res.toString(), asset.decimals));
|
||||
} catch (err) {
|
||||
const logger = localLoggerFactory({ application: 'deposits' });
|
||||
if ((err as Error).message.match(/call revert exception/)) {
|
||||
logger.info('call revert eth exception', err);
|
||||
} else {
|
||||
logger.error(err);
|
||||
}
|
||||
logger.error('get allowance', err);
|
||||
return;
|
||||
}
|
||||
}, [contract, account, config, asset]);
|
||||
|
||||
@@ -53,7 +53,9 @@ export const useVerifyWithdrawal = () => {
|
||||
|
||||
const verify = useCallback(
|
||||
async (withdrawal: WithdrawalFieldsFragment) => {
|
||||
const logger = localLoggerFactory({ application: 'withdraws' });
|
||||
try {
|
||||
logger.info('verify withdrawal', withdrawal);
|
||||
setState({ dialogOpen: true });
|
||||
|
||||
if (withdrawal.asset.source.__typename !== 'ERC20') {
|
||||
@@ -119,12 +121,7 @@ export const useVerifyWithdrawal = () => {
|
||||
|
||||
return true;
|
||||
} catch (err) {
|
||||
const logger = localLoggerFactory({ application: 'withdraws' });
|
||||
if ((err as Error).message.match(/call revert exception/)) {
|
||||
logger.info('call revert eth exception', err);
|
||||
} else {
|
||||
logger.error(err);
|
||||
}
|
||||
logger.error('use verify withdrawal', err);
|
||||
setState({
|
||||
status: ApprovalStatus.Error,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user