chore: suppress sentry logs when eth fails

This commit is contained in:
maciek
2023-05-11 14:53:38 +02:00
parent bf73559c30
commit 08dd73bee5
8 changed files with 56 additions and 14 deletions
@@ -6,7 +6,7 @@ import { useGetAllowance } from './use-get-allowance';
import { useGetBalanceOfERC20Token } from './use-get-balance-of-erc20-token';
import { useGetDepositMaximum } from './use-get-deposit-maximum';
import { useGetDepositedAmount } from './use-get-deposited-amount';
import { isAssetTypeERC20 } from '@vegaprotocol/utils';
import { isAssetTypeERC20, localLoggerFactory } from '@vegaprotocol/utils';
import { useAccountBalance } from '@vegaprotocol/accounts';
import type { Asset } from '@vegaprotocol/assets';
@@ -63,7 +63,12 @@ export const useDepositBalances = (
allowance: allowance ?? initialState.allowance,
});
} catch (err) {
Sentry.captureException(err);
const logger = localLoggerFactory({ application: 'deposits' });
if (err.message.match(/call revert exception/)) {
logger.info('call revert eth exception', err);
} else {
logger.error(err);
}
setState(null);
}
}, [asset, getAllowance, getBalance, getDepositMaximum, getDepositedAmount]);
+7 -2
View File
@@ -5,7 +5,7 @@ import { useCallback } from 'react';
import { useEthereumConfig } from '@vegaprotocol/web3';
import BigNumber from 'bignumber.js';
import type { Asset } from '@vegaprotocol/assets';
import { addDecimal } from '@vegaprotocol/utils';
import { addDecimal, localLoggerFactory } from '@vegaprotocol/utils';
export const useGetAllowance = (
contract: Token | null,
@@ -26,7 +26,12 @@ export const useGetAllowance = (
return new BigNumber(addDecimal(res.toString(), asset.decimals));
} catch (err) {
Sentry.captureException(err);
const logger = localLoggerFactory({ application: 'deposits' });
if (err.message.match(/call revert exception/)) {
logger.info('call revert eth exception', err);
} else {
logger.error(err);
}
return;
}
}, [contract, account, config, asset]);
@@ -2,7 +2,7 @@ import { useCallback } from 'react';
import * as Sentry from '@sentry/react';
import BigNumber from 'bignumber.js';
import type { Asset } from '@vegaprotocol/assets';
import { addDecimal } from '@vegaprotocol/utils';
import { addDecimal, localLoggerFactory } from '@vegaprotocol/utils';
import type { CollateralBridge } from '@vegaprotocol/smart-contracts';
export const useGetDepositMaximum = (
@@ -20,7 +20,12 @@ export const useGetDepositMaximum = (
const max = new BigNumber(addDecimal(res.toString(), asset.decimals));
return max.isEqualTo(0) ? new BigNumber(Infinity) : max;
} catch (err) {
Sentry.captureException(err);
const logger = localLoggerFactory({ application: 'deposits' });
if (err.message.match(/call revert exception/)) {
logger.info('call revert eth exception', err);
} else {
logger.error(err);
}
return;
}
}, [contract, asset]);
@@ -4,7 +4,7 @@ import { ethers } from 'ethers';
import { useEthereumConfig } from '@vegaprotocol/web3';
import BigNumber from 'bignumber.js';
import type { Asset } from '@vegaprotocol/assets';
import { addDecimal } from '@vegaprotocol/utils';
import { addDecimal, localLoggerFactory } from '@vegaprotocol/utils';
import { useWeb3React } from '@web3-react/core';
export const useGetDepositedAmount = (asset: Asset | undefined) => {
@@ -41,7 +41,12 @@ export const useGetDepositedAmount = (asset: Asset | undefined) => {
const value = new BigNumber(res, 16).toString();
return new BigNumber(addDecimal(value, asset.decimals));
} catch (err) {
Sentry.captureException(err);
const logger = localLoggerFactory({ application: 'deposits' });
if (err.message.match(/call revert exception/)) {
logger.info('call revert eth exception', err);
} else {
logger.error(err);
}
return;
}
}, [provider, asset, config, account]);
+7 -1
View File
@@ -1,6 +1,7 @@
import * as Sentry from '@sentry/react';
import { useBridgeContract } from './use-bridge-contract';
import { useCallback } from 'react';
import { localLoggerFactory } from '@vegaprotocol/utils';
/**
* Gets the delay in seconds thats required if the withdrawal amount is
@@ -13,7 +14,12 @@ export const useGetWithdrawDelay = () => {
const res = await contract?.default_withdraw_delay();
return res.toNumber();
} catch (err) {
Sentry.captureException(err);
const logger = localLoggerFactory({ application: 'web3' });
if (err.message.match(/call revert exception/)) {
logger.info('call revert eth exception', err);
} else {
logger.error(err);
}
}
}, [contract]);
@@ -7,6 +7,7 @@ import {
useEthereumTransaction,
} from '@vegaprotocol/web3';
import { useCallback, useEffect, useState } from 'react';
import { localLoggerFactory } from '@vegaprotocol/utils';
import { Erc20ApprovalDocument } from './__generated__/Erc20Approval';
import type {
Erc20ApprovalQuery,
@@ -55,7 +56,12 @@ export const useCompleteWithdraw = () => {
approval.signatures
);
} catch (err) {
captureException(err);
const logger = localLoggerFactory({ application: 'deposits' });
if (err.message.match(/call revert exception/)) {
logger.info('call revert eth exception', err);
} else {
logger.error(err);
}
}
},
[contract, query, perform]
@@ -1,7 +1,7 @@
import { useCallback, useState } from 'react';
import { captureException } from '@sentry/react';
import BigNumber from 'bignumber.js';
import { addDecimal } from '@vegaprotocol/utils';
import { addDecimal, localLoggerFactory } from '@vegaprotocol/utils';
import { t } from '@vegaprotocol/i18n';
import {
ApprovalStatus,
@@ -120,7 +120,12 @@ export const useVerifyWithdrawal = () => {
return true;
} catch (err) {
captureException(err);
const logger = localLoggerFactory({ application: 'withdraws' });
if (err.message.match(/call revert exception/)) {
logger.info('call revert eth exception', err);
} else {
logger.error(err);
}
setState({
status: ApprovalStatus.Error,
});
@@ -1,6 +1,6 @@
import { captureException } from '@sentry/react';
import type { Asset } from '@vegaprotocol/assets';
import { addDecimal } from '@vegaprotocol/utils';
import { addDecimal, localLoggerFactory } from '@vegaprotocol/utils';
import * as Schema from '@vegaprotocol/types';
import BigNumber from 'bignumber.js';
import { useCallback, useEffect } from 'react';
@@ -47,7 +47,12 @@ export const useWithdrawAsset = (
threshold = result[0];
delay = result[1];
} catch (err) {
captureException(err);
const logger = localLoggerFactory({ application: 'withdraws' });
if (err.message.match(/call revert exception/)) {
logger.info('call revert eth exception', err);
} else {
logger.error(err);
}
}
update({ asset, balance, min, threshold, delay });