Skip to content

Commit

Permalink
fix: failing unit
Browse files Browse the repository at this point in the history
  • Loading branch information
asiaznik committed Jan 31, 2024
1 parent ec837a4 commit d459455
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
1 change: 0 additions & 1 deletion libs/web3/src/lib/use-gas-price.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ const retrieveGasData = async (

/**
* Gets the "current" gas price from the ethereum network.
* @returns gwei
*/
export const useGasPrice = (
method: ContractMethod,
Expand Down
7 changes: 3 additions & 4 deletions libs/withdraws/src/lib/withdraw-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ import { formatDistanceToNow } from 'date-fns';
import { useForm, Controller, useWatch } from 'react-hook-form';
import { WithdrawLimits } from './withdraw-limits';
import {
ContractMethod,
ETHEREUM_EAGER_CONNECT,
useGasPrice,
type GasData,
useWeb3ConnectStore,
useWeb3Disconnect,
} from '@vegaprotocol/web3';
Expand Down Expand Up @@ -58,6 +57,7 @@ export interface WithdrawFormProps {
delay: number | undefined;
onSelectAsset: (assetId: string) => void;
submitWithdraw: (withdrawal: WithdrawalArgs) => void;
gasPrice?: GasData;
}

const WithdrawDelayNotification = ({
Expand Down Expand Up @@ -119,6 +119,7 @@ export const WithdrawForm = ({
delay,
onSelectAsset,
submitWithdraw,
gasPrice,
}: WithdrawFormProps) => {
const t = useT();
const ethereumAddress = useEthereumAddress();
Expand All @@ -142,8 +143,6 @@ export const WithdrawForm = ({

const amount = useWatch({ name: 'amount', control });

const gasPrice = useGasPrice(ContractMethod.WITHDRAW_ASSET);

const onSubmit = async (fields: FormFields) => {
if (!selectedAsset) {
throw new Error('Asset not selected');
Expand Down
4 changes: 3 additions & 1 deletion libs/withdraws/src/lib/withdraw-limits.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,16 @@ export const WithdrawLimits = ({
'Estimated gas fee for the withdrawal transaction (refreshes each 15 seconds)'
),
label: t('Gas fee'),
value: (
value: gas ? (
<GasPrice
gasPrice={gas}
amount={{
value: removeDecimal(amount, asset.decimals),
quantum: asset.quantum,
}}
/>
) : (
'-'
),
},
];
Expand Down
1 change: 1 addition & 0 deletions libs/withdraws/src/lib/withdraw-manager.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ jest.mock('@vegaprotocol/web3', () => ({
useGetWithdrawDelay: () => {
return () => Promise.resolve(10000);
},
useGasPrice: () => undefined,
}));

describe('WithdrawManager', () => {
Expand Down
4 changes: 4 additions & 0 deletions libs/withdraws/src/lib/withdraw-manager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { WithdrawForm } from './withdraw-form';
import type { Asset } from '@vegaprotocol/assets';
import type { AccountFieldsFragment } from '@vegaprotocol/accounts';
import { useWithdrawAsset } from './use-withdraw-asset';
import { ContractMethod, useGasPrice } from '@vegaprotocol/web3';

export interface WithdrawManagerProps {
assets: Asset[];
Expand All @@ -20,6 +21,8 @@ export const WithdrawManager = ({
}: WithdrawManagerProps) => {
const { asset, balance, min, threshold, delay, handleSelectAsset } =
useWithdrawAsset(assets, accounts, assetId);
const gasPrice = useGasPrice(ContractMethod.WITHDRAW_ASSET);

return (
<WithdrawForm
selectedAsset={asset}
Expand All @@ -30,6 +33,7 @@ export const WithdrawManager = ({
submitWithdraw={submit}
threshold={threshold}
delay={delay}
gasPrice={gasPrice}
/>
);
};

0 comments on commit d459455

Please sign in to comment.