Skip to content

Commit

Permalink
🚸 Leverager: decode errors coming from Market
Browse files Browse the repository at this point in the history
  • Loading branch information
sebipap committed May 16, 2024
1 parent 6d3408a commit ce1c9c4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions contexts/DebtManagerContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import useDebtManager from 'hooks/useDebtManager';
import useAccountData from 'hooks/useAccountData';
import useMarket from 'hooks/useMarket';
import { useWeb3 } from 'hooks/useWeb3';
import type { DebtManager, Market } from 'types/contracts';
import type { Market } from 'types/contracts';
import handleOperationError from 'utils/handleOperationError';
import useIsContract from 'hooks/useIsContract';
import { gasLimit } from 'utils/gas';
Expand Down Expand Up @@ -61,7 +61,7 @@ type ContextValues = {
setPercent: (to: number) => void;
setSlippage: (slippage: string) => void;

debtManager?: DebtManager;
debtManager?: ReturnType<typeof useDebtManager>;
market?: Market;

errorData?: ErrorData;
Expand Down
4 changes: 2 additions & 2 deletions contexts/LeveragerContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import useDebtManager from 'hooks/useDebtManager';
import useAccountData, { type MarketAccount } from 'hooks/useAccountData';
import useMarket from 'hooks/useMarket';
import { useWeb3 } from 'hooks/useWeb3';
import type { DebtManager, Market } from 'types/contracts';
import type { Market } from 'types/contracts';
import handleOperationError from 'utils/handleOperationError';
import useIsContract from 'hooks/useIsContract';
import useBalance from 'hooks/useBalance';
Expand Down Expand Up @@ -125,7 +125,7 @@ type ContextValues = {

getHealthFactorColor: (healthFactor?: string) => { color: string; bg: string };

debtManager?: DebtManager;
debtManager?: ReturnType<typeof useDebtManager>;
market?: Market;

errorData?: ErrorData;
Expand Down
7 changes: 5 additions & 2 deletions hooks/useDebtManager.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { debtManagerABI } from 'types/abi';
import { debtManagerABI, marketABI } from 'types/abi';
import useContract from './useContract';

const marketErrorsABI = marketABI.filter(({ type }) => type === 'error');
const abi = [...debtManagerABI, ...marketErrorsABI] as const;

export default () => {
return useContract('DebtManager', debtManagerABI);
return useContract('DebtManager', abi);
};

0 comments on commit ce1c9c4

Please sign in to comment.