chore(trading): catch ethereum errors and capture to sentry (#3064)
This commit is contained in:
parent
f3d6aa1129
commit
5dd0cafeca
@ -1,5 +1,5 @@
|
|||||||
import { useEthWithdrawApprovalsManager } from './use-ethereum-withdraw-approvals-manager';
|
import { useEthWithdrawApprovalsManager } from './use-ethereum-withdraw-approvals-manager';
|
||||||
import { renderHook } from '@testing-library/react';
|
import { renderHook, waitFor } from '@testing-library/react';
|
||||||
import type { MockedResponse } from '@apollo/client/testing';
|
import type { MockedResponse } from '@apollo/client/testing';
|
||||||
import type { ReactNode } from 'react';
|
import type { ReactNode } from 'react';
|
||||||
import { MockedProvider } from '@apollo/client/testing';
|
import { MockedProvider } from '@apollo/client/testing';
|
||||||
@ -318,5 +318,25 @@ describe('useEthWithdrawApprovalsManager', () => {
|
|||||||
expect(update.mock.calls[0][1].message).toEqual(
|
expect(update.mock.calls[0][1].message).toEqual(
|
||||||
'You are on the wrong network'
|
'You are on the wrong network'
|
||||||
);
|
);
|
||||||
|
mockChainId = 111111;
|
||||||
|
});
|
||||||
|
|
||||||
|
it('catch ethereum errors', async () => {
|
||||||
|
const transaction = createWithdrawTransaction();
|
||||||
|
mockUseGetWithdrawThreshold.mockReturnValueOnce(() => {
|
||||||
|
throw new Error('call revert exception');
|
||||||
|
});
|
||||||
|
|
||||||
|
mockEthTransactionStoreState.mockReturnValue({ create });
|
||||||
|
mockEthWithdrawApprovalsStoreState.mockReturnValue({
|
||||||
|
transactions: [transaction],
|
||||||
|
update,
|
||||||
|
});
|
||||||
|
render();
|
||||||
|
await waitFor(() => {
|
||||||
|
const lastCall = update.mock.calls.pop();
|
||||||
|
expect(lastCall[1].status).toEqual(ApprovalStatus.Error);
|
||||||
|
expect(lastCall[1].message).toEqual('Something went wrong');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -5,6 +5,7 @@ import { addDecimal } from '@vegaprotocol/utils';
|
|||||||
import { useGetWithdrawThreshold } from './use-get-withdraw-threshold';
|
import { useGetWithdrawThreshold } from './use-get-withdraw-threshold';
|
||||||
import { useGetWithdrawDelay } from './use-get-withdraw-delay';
|
import { useGetWithdrawDelay } from './use-get-withdraw-delay';
|
||||||
import { t } from '@vegaprotocol/i18n';
|
import { t } from '@vegaprotocol/i18n';
|
||||||
|
import { localLoggerFactory } from '@vegaprotocol/utils';
|
||||||
|
|
||||||
import { CollateralBridge } from '@vegaprotocol/smart-contracts';
|
import { CollateralBridge } from '@vegaprotocol/smart-contracts';
|
||||||
|
|
||||||
@ -128,7 +129,16 @@ export const useEthWithdrawApprovalsManager = () => {
|
|||||||
approval.signatures,
|
approval.signatures,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
})();
|
})().catch((err) => {
|
||||||
|
localLoggerFactory({ application: 'web3' }).error(
|
||||||
|
'create withdrawal transaction',
|
||||||
|
err
|
||||||
|
);
|
||||||
|
update(transaction.id, {
|
||||||
|
status: ApprovalStatus.Error,
|
||||||
|
message: t('Something went wrong'),
|
||||||
|
});
|
||||||
|
});
|
||||||
}, [
|
}, [
|
||||||
getThreshold,
|
getThreshold,
|
||||||
getDelay,
|
getDelay,
|
||||||
|
Loading…
Reference in New Issue
Block a user