From a2030cf58dd25b9028e751c9ccebadb67adcb60c Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Mon, 16 Oct 2023 17:33:01 +0530 Subject: [PATCH] fix: enable gas sufficiency check for SAFE (#142) --- packages/widget/src/components/GasMessage/GasMessage.tsx | 5 +---- packages/widget/src/hooks/useGasSufficiency.ts | 6 ++++-- .../src/pages/TransactionPage/StartTransactionButton.tsx | 6 +----- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/packages/widget/src/components/GasMessage/GasMessage.tsx b/packages/widget/src/components/GasMessage/GasMessage.tsx index 90963421b..9753df0bf 100644 --- a/packages/widget/src/components/GasMessage/GasMessage.tsx +++ b/packages/widget/src/components/GasMessage/GasMessage.tsx @@ -2,7 +2,6 @@ import type { Route } from '@lifi/sdk'; import type { BoxProps } from '@mui/material'; import { Box, Collapse } from '@mui/material'; import { useFromTokenSufficiency, useGasSufficiency } from '../../hooks'; -import { useWidgetConfig } from '../../providers'; import { FundsSufficiencyMessage } from './FundsSufficiencyMessage'; import { GasSufficiencyMessage } from './GasSufficiencyMessage'; @@ -13,10 +12,8 @@ interface GasMessageProps extends BoxProps { export const GasMessage: React.FC = ({ route, ...props }) => { const { insufficientGas } = useGasSufficiency(route); const { insufficientFromToken } = useFromTokenSufficiency(route); - const { sdkConfig } = useWidgetConfig(); - const isMultisigSigner = sdkConfig?.multisigConfig?.isMultisigSigner; - const validInsufficientGas = insufficientGas?.length && !isMultisigSigner; + const validInsufficientGas = insufficientGas?.length; return ( { const getTokenBalancesWithRetry = useGetTokenBalancesWithRetry( account.signer?.provider, ); + const { sdkConfig } = useWidgetConfig(); + const isMultisigSigner = sdkConfig?.multisigConfig?.isMultisigSigner; const { enabledAutoRefuel } = useSettings(['enabledAutoRefuel']); const { enabled, isLoading: isRefuelLoading } = useGasRefuel(); @@ -43,7 +45,7 @@ export const useGasSufficiency = (route?: Route) => { .filter((step) => !step.execution || step.execution.status !== 'DONE') .reduce( (groupedGasCosts, step) => { - if (step.estimate.gasCosts) { + if (step.estimate.gasCosts && !isMultisigSigner) { const { token } = step.estimate.gasCosts[0]; const gasCostAmount = step.estimate.gasCosts .reduce( diff --git a/packages/widget/src/pages/TransactionPage/StartTransactionButton.tsx b/packages/widget/src/pages/TransactionPage/StartTransactionButton.tsx index 04c594dfe..0fd53d3da 100644 --- a/packages/widget/src/pages/TransactionPage/StartTransactionButton.tsx +++ b/packages/widget/src/pages/TransactionPage/StartTransactionButton.tsx @@ -4,7 +4,6 @@ import { useGasSufficiency, useRoutes, } from '../../hooks'; -import { useWidgetConfig } from '../../providers'; import { useRouteExecutionStore } from '../../stores'; import type { StartTransactionButtonProps } from './types'; @@ -14,9 +13,6 @@ export const StartTransactionButton: React.FC = ({ text, loading, }) => { - const { sdkConfig } = useWidgetConfig(); - const isMultisigSigner = sdkConfig?.multisigConfig?.isMultisigSigner; - const { insufficientGas, isInitialLoading: isGasSufficiencyLoading } = useGasSufficiency(route); const { @@ -25,7 +21,7 @@ export const StartTransactionButton: React.FC = ({ } = useFromTokenSufficiency(route); const shouldDisableButton = - !isMultisigSigner && (insufficientFromToken || !!insufficientGas?.length); + insufficientFromToken || !!insufficientGas?.length; return (