diff --git a/src/swap/components/SwapButton.test.tsx b/src/swap/components/SwapButton.test.tsx index 89351398d0..29d5206dd9 100644 --- a/src/swap/components/SwapButton.test.tsx +++ b/src/swap/components/SwapButton.test.tsx @@ -31,7 +31,7 @@ describe('SwapButton', () => { address: '0x123', to: { loading: false, amount: 1, token: 'ETH' }, from: { loading: false, amount: 1, token: 'BTC' }, - lifeCycleStatus: { statusName: 'init' }, + lifecycleStatus: { statusName: 'init' }, handleSubmit: mockHandleSubmit, }); render(); @@ -44,7 +44,7 @@ describe('SwapButton', () => { useSwapContextMock.mockReturnValue({ to: { loading: true, amount: 1, token: 'ETH' }, from: { loading: false, amount: 1, token: 'BTC' }, - lifeCycleStatus: { statusName: 'init' }, + lifecycleStatus: { statusName: 'init' }, handleSubmit: mockHandleSubmit, }); render(); @@ -57,7 +57,7 @@ describe('SwapButton', () => { useSwapContextMock.mockReturnValue({ to: { loading: false, amount: 1, token: 'ETH' }, from: { loading: false, amount: 1, token: 'BTC' }, - lifeCycleStatus: { statusName: 'transactionPending' }, + lifecycleStatus: { statusName: 'transactionPending' }, handleSubmit: mockHandleSubmit, }); render(); @@ -70,7 +70,7 @@ describe('SwapButton', () => { useSwapContextMock.mockReturnValue({ to: { loading: false, amount: 1, token: 'ETH' }, from: { loading: false, amount: 1, token: 'BTC' }, - lifeCycleStatus: { statusName: 'transactionApproved' }, + lifecycleStatus: { statusName: 'transactionApproved' }, handleSubmit: mockHandleSubmit, }); render(); @@ -83,7 +83,7 @@ describe('SwapButton', () => { useSwapContextMock.mockReturnValue({ to: { loading: false, amount: 1, token: 'ETH' }, from: { loading: false, amount: null, token: 'BTC' }, - lifeCycleStatus: { statusName: 'init' }, + lifecycleStatus: { statusName: 'init' }, handleSubmit: mockHandleSubmit, }); render(); @@ -96,7 +96,7 @@ describe('SwapButton', () => { address: '0x123', to: { loading: false, amount: 1, token: 'ETH' }, from: { loading: false, amount: 1, token: 'BTC' }, - lifeCycleStatus: { statusName: 'init' }, + lifecycleStatus: { statusName: 'init' }, handleSubmit: mockHandleSubmit, }); render(); @@ -110,7 +110,7 @@ describe('SwapButton', () => { address: '0x123', to: { loading: false, amount: 1, token: 'ETH' }, from: { loading: false, amount: 1, token: 'BTC' }, - lifeCycleStatus: { statusName: 'init' }, + lifecycleStatus: { statusName: 'init' }, handleSubmit: mockHandleSubmit, }); const customClass = 'custom-class'; @@ -123,7 +123,7 @@ describe('SwapButton', () => { useSwapContextMock.mockReturnValue({ to: { loading: false, amount: 1, token: 'ETH' }, from: { loading: false, amount: 1, token: 'BTC' }, - lifeCycleStatus: { statusName: 'init' }, + lifecycleStatus: { statusName: 'init' }, handleSubmit: mockHandleSubmit, }); vi.mocked(useAccount).mockReturnValue({ diff --git a/src/swap/components/SwapButton.tsx b/src/swap/components/SwapButton.tsx index 71405f424c..24ab8d8da5 100644 --- a/src/swap/components/SwapButton.tsx +++ b/src/swap/components/SwapButton.tsx @@ -9,7 +9,7 @@ export function SwapButton({ className, disabled = false }: SwapButtonReact) { address, to, from, - lifeCycleStatus: { statusName }, + lifecycleStatus: { statusName }, handleSubmit, } = useSwapContext(); diff --git a/src/swap/components/SwapMessage.test.tsx b/src/swap/components/SwapMessage.test.tsx index 49e458122c..899626670c 100644 --- a/src/swap/components/SwapMessage.test.tsx +++ b/src/swap/components/SwapMessage.test.tsx @@ -27,7 +27,7 @@ describe('SwapMessage', () => { const mockContext = { to: {}, from: {}, - lifeCycleStatus: { statusName: 'init', statusData: null }, + lifecycleStatus: { statusName: 'init', statusData: null }, }; useSwapContextMock.mockReturnValue(mockContext); mockGetSwapMessage.mockReturnValue(mockMessage); @@ -42,7 +42,7 @@ describe('SwapMessage', () => { const mockContext = { to: {}, from: {}, - lifeCycleStatus: { + lifecycleStatus: { statusName: 'error', statusData: { message: 'Error occurred' }, }, @@ -59,7 +59,7 @@ describe('SwapMessage', () => { const mockContext = { to: {}, from: {}, - lifeCycleStatus: { statusName: 'transactionPending', statusData: null }, + lifecycleStatus: { statusName: 'transactionPending', statusData: null }, }; useSwapContextMock.mockReturnValue(mockContext); mockGetSwapMessage.mockReturnValue(mockMessage); @@ -73,7 +73,7 @@ describe('SwapMessage', () => { const mockContext = { to: {}, from: {}, - lifeCycleStatus: { statusName: 'transactionApproved', statusData: null }, + lifecycleStatus: { statusName: 'transactionApproved', statusData: null }, }; useSwapContextMock.mockReturnValue(mockContext); mockGetSwapMessage.mockReturnValue(mockMessage); @@ -86,7 +86,7 @@ describe('SwapMessage', () => { const mockContext = { to: {}, from: {}, - lifeCycleStatus: { statusName: 'init', statusData: null }, + lifecycleStatus: { statusName: 'init', statusData: null }, }; useSwapContextMock.mockReturnValue(mockContext); @@ -98,7 +98,7 @@ describe('SwapMessage', () => { }); it('should set isMissingRequiredFields to true when reflected in statusData', () => { - const mockLifeCycleStatus = { + const mockLifecycleStatus = { statusName: 'init', statusData: { isMissingRequiredField: true }, }; @@ -106,14 +106,14 @@ describe('SwapMessage', () => { to: { amount: 1, token: 'ETH' }, from: { amount: null, token: 'DAI' }, address: '0x123', - lifeCycleStatus: mockLifeCycleStatus, + lifecycleStatus: mockLifecycleStatus, }; useSwapContextMock.mockReturnValue(mockContext); render(); expect(mockGetSwapMessage).toHaveBeenCalledWith({ address: '0x123', from: { amount: null, token: 'DAI' }, - lifeCycleStatus: mockLifeCycleStatus, + lifecycleStatus: mockLifecycleStatus, to: { amount: 1, token: 'ETH' }, }); }); diff --git a/src/swap/components/SwapMessage.tsx b/src/swap/components/SwapMessage.tsx index da5185077e..bf208d34e8 100644 --- a/src/swap/components/SwapMessage.tsx +++ b/src/swap/components/SwapMessage.tsx @@ -4,12 +4,12 @@ import { getSwapMessage } from '../utils/getSwapMessage'; import { useSwapContext } from './SwapProvider'; export function SwapMessage({ className }: SwapMessageReact) { - const { address, to, from, lifeCycleStatus } = useSwapContext(); + const { address, to, from, lifecycleStatus } = useSwapContext(); const message = getSwapMessage({ address, from, - lifeCycleStatus, + lifecycleStatus, to, }); diff --git a/src/swap/components/SwapProvider.test.tsx b/src/swap/components/SwapProvider.test.tsx index 23c4c1bc65..af9845beef 100644 --- a/src/swap/components/SwapProvider.test.tsx +++ b/src/swap/components/SwapProvider.test.tsx @@ -113,7 +113,7 @@ const TestSwapComponent = () => { context.to.setToken(DEGEN_TOKEN); }, [context]); const handleStatusError = async () => { - context.updateLifeCycleStatus({ + context.updateLifecycleStatus({ statusName: 'error', statusData: { code: 'code', @@ -123,7 +123,7 @@ const TestSwapComponent = () => { }); }; const handleStatusAmountChange = async () => { - context.updateLifeCycleStatus({ + context.updateLifecycleStatus({ statusName: 'amountChange', statusData: { amountFrom: '', @@ -132,12 +132,12 @@ const TestSwapComponent = () => { }); }; const handleStatusTransactionPending = async () => { - context.updateLifeCycleStatus({ + context.updateLifecycleStatus({ statusName: 'transactionPending', }); }; const handleStatusTransactionApproved = async () => { - context.updateLifeCycleStatus({ + context.updateLifecycleStatus({ statusName: 'transactionApproved', statusData: { transactionHash: '0x123', @@ -146,7 +146,7 @@ const TestSwapComponent = () => { }); }; const handleStatusSuccess = async () => { - context.updateLifeCycleStatus({ + context.updateLifecycleStatus({ statusName: 'success', statusData: { transactionReceipt: { transactionHash: '0x123' }, @@ -155,28 +155,28 @@ const TestSwapComponent = () => { }; return (
- - {context.lifeCycleStatus.statusName} + + {context.lifecycleStatus.statusName} - {context.lifeCycleStatus.statusName === 'error' && ( - - {context.lifeCycleStatus.statusData.code} + {context.lifecycleStatus.statusName === 'error' && ( + + {context.lifecycleStatus.statusData.code} )}
); @@ -165,19 +165,19 @@ describe('TransactionProvider', () => { }); }); - it('should emit onError when setLifeCycleStatus is called with error', async () => { + it('should emit onError when setLifecycleStatus is called with error', async () => { const onErrorMock = vi.fn(); render( , ); - const button = screen.getByText('setLifeCycleStatus.error'); + const button = screen.getByText('setLifecycleStatus.error'); fireEvent.click(button); expect(onErrorMock).toHaveBeenCalled(); }); - it('should emit onStatus when setLifeCycleStatus is called with transactionLegacyExecuted', async () => { + it('should emit onStatus when setLifecycleStatus is called with transactionLegacyExecuted', async () => { const onStatusMock = vi.fn(); render( @@ -185,7 +185,7 @@ describe('TransactionProvider', () => { , ); const button = screen.getByText( - 'setLifeCycleStatus.transactionLegacyExecuted', + 'setLifecycleStatus.transactionLegacyExecuted', ); fireEvent.click(button); expect(onStatusMock).toHaveBeenCalledWith({ @@ -196,14 +196,14 @@ describe('TransactionProvider', () => { }); }); - it('should emit onStatus when setLifeCycleStatus is called', async () => { + it('should emit onStatus when setLifecycleStatus is called', async () => { const onStatusMock = vi.fn(); render( , ); - const button = screen.getByText('setLifeCycleStatus.error'); + const button = screen.getByText('setLifecycleStatus.error'); fireEvent.click(button); expect(onStatusMock).toHaveBeenCalled(); }); @@ -251,7 +251,7 @@ describe('TransactionProvider', () => { , ); const button = screen.getByText( - 'setLifeCycleStatus.transactionLegacyExecutedMultipleContracts', + 'setLifecycleStatus.transactionLegacyExecutedMultipleContracts', ); fireEvent.click(button); await waitFor(() => { @@ -279,7 +279,7 @@ describe('TransactionProvider', () => { , ); const button = screen.getByText( - 'setLifeCycleStatus.transactionLegacyExecutedMultipleContracts', + 'setLifecycleStatus.transactionLegacyExecutedMultipleContracts', ); fireEvent.click(button); await waitFor(() => { @@ -287,7 +287,7 @@ describe('TransactionProvider', () => { }); }); - it('should set setLifeCycleStatus to transactionPending when writeContractsAsync is pending', async () => { + it('should set setLifecycleStatus to transactionPending when writeContractsAsync is pending', async () => { const writeContractsAsyncMock = vi.fn(); (useWriteContracts as ReturnType).mockReturnValue({ status: 'pending', @@ -307,13 +307,13 @@ describe('TransactionProvider', () => { fireEvent.click(button); await waitFor(() => { expect( - screen.getByTestId('context-value-lifeCycleStatus-statusName') + screen.getByTestId('context-value-lifecycleStatus-statusName') .textContent, ).toBe('transactionPending'); }); }); - it('should set setLifeCycleStatus to transactionPending when writeContractAsync is pending', async () => { + it('should set setLifecycleStatus to transactionPending when writeContractAsync is pending', async () => { const writeContractsAsyncMock = vi.fn(); (useWriteContract as ReturnType).mockReturnValue({ status: 'pending', @@ -328,7 +328,7 @@ describe('TransactionProvider', () => { fireEvent.click(button); await waitFor(() => { expect( - screen.getByTestId('context-value-lifeCycleStatus-statusName') + screen.getByTestId('context-value-lifecycleStatus-statusName') .textContent, ).toBe('transactionPending'); }); diff --git a/src/transaction/components/TransactionProvider.tsx b/src/transaction/components/TransactionProvider.tsx index a9568fcada..d32a709e81 100644 --- a/src/transaction/components/TransactionProvider.tsx +++ b/src/transaction/components/TransactionProvider.tsx @@ -28,7 +28,7 @@ import { useSendWalletTransactions } from '../hooks/useSendWalletTransactions'; import { useWriteContract } from '../hooks/useWriteContract'; import { useWriteContracts } from '../hooks/useWriteContracts'; import type { - LifeCycleStatus, + LifecycleStatus, TransactionContextType, TransactionProviderReact, } from '../types'; @@ -65,7 +65,7 @@ export function TransactionProvider({ const [errorMessage, setErrorMessage] = useState(''); const [errorCode, setErrorCode] = useState(''); const [isToastVisible, setIsToastVisible] = useState(false); - const [lifeCycleStatus, setLifeCycleStatus] = useState({ + const [lifecycleStatus, setLifecycleStatus] = useState({ statusName: 'init', statusData: null, }); // Component lifecycle @@ -97,7 +97,7 @@ export function TransactionProvider({ // Used for contract calls with an ABI and functions. const { status: statusWriteContracts, writeContractsAsync } = useWriteContracts({ - setLifeCycleStatus, + setLifecycleStatus, setTransactionId, }); const { @@ -105,13 +105,13 @@ export function TransactionProvider({ writeContractAsync, data: writeContractTransactionHash, } = useWriteContract({ - setLifeCycleStatus, + setLifecycleStatus, transactionHashList, }); // useSendCalls or useSendCall // Used for contract calls with raw calldata. const { status: statusSendCalls, sendCallsAsync } = useSendCalls({ - setLifeCycleStatus, + setLifecycleStatus, setTransactionId, }); const { @@ -119,7 +119,7 @@ export function TransactionProvider({ sendCallAsync, data: sendCallTransactionHash, } = useSendCall({ - setLifeCycleStatus, + setLifecycleStatus, transactionHashList, }); @@ -165,7 +165,7 @@ export function TransactionProvider({ const { transactionHash: batchedTransactionHash, status: callStatus } = useCallsStatus({ - setLifeCycleStatus, + setLifecycleStatus, transactionId, }); const { data: receipt } = useWaitForTransactionReceipt({ @@ -176,36 +176,36 @@ export function TransactionProvider({ useEffect(() => { setErrorMessage(''); // Error - if (lifeCycleStatus.statusName === 'error') { - setErrorMessage(lifeCycleStatus.statusData.message); - setErrorCode(lifeCycleStatus.statusData.code); - onError?.(lifeCycleStatus.statusData); + if (lifecycleStatus.statusName === 'error') { + setErrorMessage(lifecycleStatus.statusData.message); + setErrorCode(lifecycleStatus.statusData.code); + onError?.(lifecycleStatus.statusData); } // Transaction Legacy Executed - if (lifeCycleStatus.statusName === 'transactionLegacyExecuted') { - setTransactionHashList(lifeCycleStatus.statusData.transactionHashList); + if (lifecycleStatus.statusName === 'transactionLegacyExecuted') { + setTransactionHashList(lifecycleStatus.statusData.transactionHashList); } // Success - if (lifeCycleStatus.statusName === 'success') { + if (lifecycleStatus.statusName === 'success') { onSuccess?.({ - transactionReceipts: lifeCycleStatus.statusData.transactionReceipts, + transactionReceipts: lifecycleStatus.statusData.transactionReceipts, }); } // Emit Status - onStatus?.(lifeCycleStatus); + onStatus?.(lifecycleStatus); }, [ onError, onStatus, onSuccess, - lifeCycleStatus, - lifeCycleStatus.statusData, // Keep statusData, so that the effect runs when it changes - lifeCycleStatus.statusName, // Keep statusName, so that the effect runs when it changes + lifecycleStatus, + lifecycleStatus.statusData, // Keep statusData, so that the effect runs when it changes + lifecycleStatus.statusName, // Keep statusName, so that the effect runs when it changes ]); // Set transaction pending status when writeContracts or writeContract is pending useEffect(() => { if (transactionStatus === 'pending') { - setLifeCycleStatus({ + setLifecycleStatus({ statusName: 'transactionPending', statusData: null, }); @@ -217,7 +217,7 @@ export function TransactionProvider({ if (!receipt) { return; } - setLifeCycleStatus({ + setLifecycleStatus({ statusName: 'success', statusData: { transactionReceipts: [receipt], @@ -247,7 +247,7 @@ export function TransactionProvider({ }); receipts.push(txnReceipt); } catch (err) { - setLifeCycleStatus({ + setLifecycleStatus({ statusName: 'error', statusData: { code: 'TmTPc01', // Transaction module TransactionProvider component 01 error @@ -257,7 +257,7 @@ export function TransactionProvider({ }); } } - setLifeCycleStatus({ + setLifecycleStatus({ statusName: 'success', statusData: { transactionReceipts: receipts, @@ -285,7 +285,7 @@ export function TransactionProvider({ const errorMessage = isUserRejectedRequestError(err) ? 'Request denied.' : GENERIC_ERROR_MESSAGE; - setLifeCycleStatus({ + setLifecycleStatus({ statusName: 'error', statusData: { code: 'TmTPc03', // Transaction module TransactionProvider component 03 error @@ -302,12 +302,12 @@ export function TransactionProvider({ errorMessage, isLoading: callStatus === 'PENDING', isToastVisible, - lifeCycleStatus, + lifecycleStatus, onSubmit: handleSubmit, paymasterUrl: getPaymasterUrl(capabilities), receipt, setIsToastVisible, - setLifeCycleStatus, + setLifecycleStatus, setTransactionId, transactions, transactionId, diff --git a/src/transaction/components/TransactionSponsor.test.tsx b/src/transaction/components/TransactionSponsor.test.tsx index c8a4881a01..b29c24dd8b 100644 --- a/src/transaction/components/TransactionSponsor.test.tsx +++ b/src/transaction/components/TransactionSponsor.test.tsx @@ -10,7 +10,7 @@ vi.mock('./TransactionProvider', () => ({ describe('TransactionSponsor', () => { it('should render correctly', () => { (useTransactionContext as Mock).mockReturnValue({ - lifeCycleStatus: { statusName: 'init', statusData: null }, + lifecycleStatus: { statusName: 'init', statusData: null }, paymasterUrl: 'paymasterUrl', }); render(); @@ -20,7 +20,7 @@ describe('TransactionSponsor', () => { it('should not render if paymasterUrl is null', () => { (useTransactionContext as Mock).mockReturnValue({ - lifeCycleStatus: { statusName: 'init', statusData: null }, + lifecycleStatus: { statusName: 'init', statusData: null }, paymasterUrl: null, }); render(); @@ -29,7 +29,7 @@ describe('TransactionSponsor', () => { it('should not render if statusName is not init', () => { (useTransactionContext as Mock).mockReturnValue({ - lifeCycleStatus: { statusName: 'blah', statusData: null }, + lifecycleStatus: { statusName: 'blah', statusData: null }, paymasterUrl: null, }); render(); @@ -38,7 +38,7 @@ describe('TransactionSponsor', () => { it('should render if statusName is init', () => { (useTransactionContext as Mock).mockReturnValue({ - lifeCycleStatus: { statusName: 'init', statusData: null }, + lifecycleStatus: { statusName: 'init', statusData: null }, paymasterUrl: 'paymasterUrl', }); render(); diff --git a/src/transaction/components/TransactionSponsor.tsx b/src/transaction/components/TransactionSponsor.tsx index 8437bfcff5..ff28fbc8b5 100644 --- a/src/transaction/components/TransactionSponsor.tsx +++ b/src/transaction/components/TransactionSponsor.tsx @@ -5,7 +5,7 @@ import { useTransactionContext } from './TransactionProvider'; export function TransactionSponsor({ className }: TransactionSponsorReact) { const { errorMessage, - lifeCycleStatus, + lifecycleStatus, paymasterUrl, receipt, transactionHash, @@ -14,7 +14,7 @@ export function TransactionSponsor({ className }: TransactionSponsorReact) { const transactionInProgress = transactionId || transactionHash; if ( - lifeCycleStatus.statusName !== 'init' || + lifecycleStatus.statusName !== 'init' || !paymasterUrl || errorMessage || transactionInProgress || diff --git a/src/transaction/hooks/useCallsStatus.test.ts b/src/transaction/hooks/useCallsStatus.test.ts index ce2e17409e..3cf3df6bc0 100644 --- a/src/transaction/hooks/useCallsStatus.test.ts +++ b/src/transaction/hooks/useCallsStatus.test.ts @@ -24,20 +24,20 @@ describe('useCallsStatus', () => { }); it('should handle errors and call onError callback', () => { - const mockSetLifeCycleStatus = vi.fn(); + const mockSetLifecycleStatus = vi.fn(); const mockError = new Error('Test error'); (useCallsStatusWagmi as ReturnType).mockImplementation(() => { throw mockError; }); const { result } = renderHook(() => useCallsStatus({ - setLifeCycleStatus: mockSetLifeCycleStatus, + setLifecycleStatus: mockSetLifecycleStatus, transactionId, }), ); expect(result.current.status).toBe('error'); expect(result.current.transactionHash).toBeUndefined(); - expect(mockSetLifeCycleStatus).toHaveBeenCalledWith({ + expect(mockSetLifecycleStatus).toHaveBeenCalledWith({ statusName: 'error', statusData: { code: 'TmUCSh01', @@ -86,7 +86,7 @@ describe('useCallsStatus', () => { }); it('should not fetch data when transactionId is not provided', () => { - const mockSetLifeCycleStatus = vi.fn(); + const mockSetLifecycleStatus = vi.fn(); const mockData = undefined; (useCallsStatusWagmi as ReturnType).mockReturnValue({ @@ -95,7 +95,7 @@ describe('useCallsStatus', () => { const { result } = renderHook(() => useCallsStatus({ - setLifeCycleStatus: mockSetLifeCycleStatus, + setLifecycleStatus: mockSetLifecycleStatus, transactionId: undefined, }), ); diff --git a/src/transaction/hooks/useCallsStatus.ts b/src/transaction/hooks/useCallsStatus.ts index ff6162f278..6bbeb2952b 100644 --- a/src/transaction/hooks/useCallsStatus.ts +++ b/src/transaction/hooks/useCallsStatus.ts @@ -2,7 +2,7 @@ import { useCallsStatus as useCallsStatusWagmi } from 'wagmi/experimental'; import type { UseCallsStatusParams } from '../types'; export function useCallsStatus({ - setLifeCycleStatus, + setLifecycleStatus, transactionId, }: UseCallsStatusParams) { try { @@ -18,7 +18,7 @@ export function useCallsStatus({ const transactionHash = data?.receipts?.[0]?.transactionHash; return { status: data?.status, transactionHash }; } catch (err) { - setLifeCycleStatus({ + setLifecycleStatus({ statusName: 'error', statusData: { code: 'TmUCSh01', diff --git a/src/transaction/hooks/useGetTransactionStatusLabel.test.tsx b/src/transaction/hooks/useGetTransactionStatusLabel.test.tsx index d829b736b7..e61cf88136 100644 --- a/src/transaction/hooks/useGetTransactionStatusLabel.test.tsx +++ b/src/transaction/hooks/useGetTransactionStatusLabel.test.tsx @@ -34,7 +34,7 @@ describe('useGetTransactionStatusLabel', () => { it('should return correct status when transaction is pending', () => { (useTransactionContext as Mock).mockReturnValue({ - lifeCycleStatus: { statusName: 'transactionPending', statusData: null }, + lifecycleStatus: { statusName: 'transactionPending', statusData: null }, }); const { result } = renderHook(() => useGetTransactionStatusLabel()); expect(result.current.label).toBe('Confirm in wallet.'); @@ -42,7 +42,7 @@ describe('useGetTransactionStatusLabel', () => { it('should return status when transaction hash exists', () => { (useTransactionContext as Mock).mockReturnValue({ - lifeCycleStatus: { statusName: 'init', statusData: null }, + lifecycleStatus: { statusName: 'init', statusData: null }, transactionHash: '0x123', }); const { result } = renderHook(() => useGetTransactionStatusLabel()); @@ -51,7 +51,7 @@ describe('useGetTransactionStatusLabel', () => { it('should return status when transaction id exists', () => { (useTransactionContext as Mock).mockReturnValue({ - lifeCycleStatus: { statusName: 'init', statusData: null }, + lifecycleStatus: { statusName: 'init', statusData: null }, transactionId: 'ab123', onSubmit: vi.fn(), }); @@ -63,7 +63,7 @@ describe('useGetTransactionStatusLabel', () => { it('should return status when receipt exists', () => { (useTransactionContext as Mock).mockReturnValue({ - lifeCycleStatus: { statusName: 'init', statusData: null }, + lifecycleStatus: { statusName: 'init', statusData: null }, receipt: 'receipt', transactionHash: '123', }); @@ -73,7 +73,7 @@ describe('useGetTransactionStatusLabel', () => { it('should return status when error occurs', () => { (useTransactionContext as Mock).mockReturnValue({ - lifeCycleStatus: { statusName: 'init', statusData: null }, + lifecycleStatus: { statusName: 'init', statusData: null }, errorMessage: 'error', }); const { result } = renderHook(() => useGetTransactionStatusLabel()); @@ -82,7 +82,7 @@ describe('useGetTransactionStatusLabel', () => { it('should return status when no status available', () => { (useTransactionContext as Mock).mockReturnValue({ - lifeCycleStatus: { statusName: 'init', statusData: null }, + lifecycleStatus: { statusName: 'init', statusData: null }, errorMessage: '', }); const { result } = renderHook(() => useGetTransactionStatusLabel()); diff --git a/src/transaction/hooks/useGetTransactionStatusLabel.tsx b/src/transaction/hooks/useGetTransactionStatusLabel.tsx index d19cce3fa6..0408bc4847 100644 --- a/src/transaction/hooks/useGetTransactionStatusLabel.tsx +++ b/src/transaction/hooks/useGetTransactionStatusLabel.tsx @@ -7,7 +7,7 @@ export function useGetTransactionStatusLabel() { errorMessage, isLoading, receipt, - lifeCycleStatus, + lifecycleStatus, transactionHash, transactionId, } = useTransactionContext(); @@ -15,7 +15,7 @@ export function useGetTransactionStatusLabel() { const isInProgress = isLoading || !!transactionId || !!transactionHash; // user started txn and needs to confirm in wallet - const isPending = lifeCycleStatus.statusName === 'transactionPending'; + const isPending = lifecycleStatus.statusName === 'transactionPending'; return useMemo(() => { let label = ''; diff --git a/src/transaction/hooks/useSendCall.test.ts b/src/transaction/hooks/useSendCall.test.ts index a4556b3349..44218232e8 100644 --- a/src/transaction/hooks/useSendCall.test.ts +++ b/src/transaction/hooks/useSendCall.test.ts @@ -27,7 +27,7 @@ type MockUseSendCallReturn = { }; describe('useSendCall', () => { - const mockSetLifeCycleStatus = vi.fn(); + const mockSetLifecycleStatus = vi.fn(); beforeEach(() => { vi.resetAllMocks(); @@ -43,7 +43,7 @@ describe('useSendCall', () => { }); const { result } = renderHook(() => useSendCall({ - setLifeCycleStatus: mockSetLifeCycleStatus, + setLifecycleStatus: mockSetLifecycleStatus, transactionHashList: [], }), ); @@ -67,13 +67,13 @@ describe('useSendCall', () => { ); renderHook(() => useSendCall({ - setLifeCycleStatus: mockSetLifeCycleStatus, + setLifecycleStatus: mockSetLifecycleStatus, transactionHashList: [], }), ); expect(onErrorCallback).toBeDefined(); onErrorCallback?.(genericError); - expect(mockSetLifeCycleStatus).toHaveBeenCalledWith({ + expect(mockSetLifecycleStatus).toHaveBeenCalledWith({ statusName: 'error', statusData: { code: 'TmUSCh01', @@ -99,13 +99,13 @@ describe('useSendCall', () => { (isUserRejectedRequestError as Mock).mockReturnValue(true); renderHook(() => useSendCall({ - setLifeCycleStatus: mockSetLifeCycleStatus, + setLifecycleStatus: mockSetLifecycleStatus, transactionHashList: [], }), ); expect(onErrorCallback).toBeDefined(); onErrorCallback?.(userRejectedError); - expect(mockSetLifeCycleStatus).toHaveBeenCalledWith({ + expect(mockSetLifecycleStatus).toHaveBeenCalledWith({ statusName: 'error', statusData: { code: 'TmUSCh01', @@ -130,13 +130,13 @@ describe('useSendCall', () => { ); renderHook(() => useSendCall({ - setLifeCycleStatus: mockSetLifeCycleStatus, + setLifecycleStatus: mockSetLifecycleStatus, transactionHashList: [], }), ); expect(onSuccessCallback).toBeDefined(); onSuccessCallback?.(transactionHash); - expect(mockSetLifeCycleStatus).toHaveBeenCalledWith({ + expect(mockSetLifecycleStatus).toHaveBeenCalledWith({ statusName: 'transactionLegacyExecuted', statusData: { transactionHashList: [transactionHash], @@ -159,13 +159,13 @@ describe('useSendCall', () => { ); renderHook(() => useSendCall({ - setLifeCycleStatus: mockSetLifeCycleStatus, + setLifecycleStatus: mockSetLifecycleStatus, transactionHashList: [], }), ); expect(onSuccessCallback).toBeDefined(); onSuccessCallback?.(transactionHash); - expect(mockSetLifeCycleStatus).toHaveBeenCalledWith({ + expect(mockSetLifecycleStatus).toHaveBeenCalledWith({ statusName: 'transactionLegacyExecuted', statusData: { transactionHashList: [transactionHash], @@ -173,12 +173,12 @@ describe('useSendCall', () => { }); renderHook(() => useSendCall({ - setLifeCycleStatus: mockSetLifeCycleStatus, + setLifecycleStatus: mockSetLifecycleStatus, transactionHashList: [transactionHash], }), ); onSuccessCallback?.(transactionHash); - expect(mockSetLifeCycleStatus).toHaveBeenCalledWith({ + expect(mockSetLifecycleStatus).toHaveBeenCalledWith({ statusName: 'transactionLegacyExecuted', statusData: { transactionHashList: [transactionHash, transactionHash], diff --git a/src/transaction/hooks/useSendCall.ts b/src/transaction/hooks/useSendCall.ts index be245409ed..0822b69dd9 100644 --- a/src/transaction/hooks/useSendCall.ts +++ b/src/transaction/hooks/useSendCall.ts @@ -10,7 +10,7 @@ import { isUserRejectedRequestError } from '../utils/isUserRejectedRequestError' * Does not support transaction batching or paymasters. */ export function useSendCall({ - setLifeCycleStatus, + setLifecycleStatus, transactionHashList, }: UseSendCallParams) { const { @@ -23,7 +23,7 @@ export function useSendCall({ const errorMessage = isUserRejectedRequestError(e) ? 'Request denied.' : GENERIC_ERROR_MESSAGE; - setLifeCycleStatus({ + setLifecycleStatus({ statusName: 'error', statusData: { code: 'TmUSCh01', // Transaction module UseSendCall hook 01 error @@ -33,7 +33,7 @@ export function useSendCall({ }); }, onSuccess: (hash: Address) => { - setLifeCycleStatus({ + setLifecycleStatus({ statusName: 'transactionLegacyExecuted', statusData: { transactionHashList: [...transactionHashList, hash], diff --git a/src/transaction/hooks/useSendCalls.test.ts b/src/transaction/hooks/useSendCalls.test.ts index 137bca6f13..48ce8973cb 100644 --- a/src/transaction/hooks/useSendCalls.test.ts +++ b/src/transaction/hooks/useSendCalls.test.ts @@ -23,7 +23,7 @@ type UseSendCallsConfig = { }; describe('useSendCalls', () => { - const mockSetLifeCycleStatus = vi.fn(); + const mockSetLifecycleStatus = vi.fn(); const mockSetTransactionId = vi.fn(); beforeEach(() => { @@ -40,7 +40,7 @@ describe('useSendCalls', () => { }); const { result } = renderHook(() => useSendCalls({ - setLifeCycleStatus: mockSetLifeCycleStatus, + setLifecycleStatus: mockSetLifecycleStatus, setTransactionId: mockSetTransactionId, }), ); @@ -67,13 +67,13 @@ describe('useSendCalls', () => { (isUserRejectedRequestError as Mock).mockReturnValue(false); renderHook(() => useSendCalls({ - setLifeCycleStatus: mockSetLifeCycleStatus, + setLifecycleStatus: mockSetLifecycleStatus, setTransactionId: mockSetTransactionId, }), ); expect(onErrorCallback).toBeDefined(); onErrorCallback?.(genericError as TransactionExecutionError); - expect(mockSetLifeCycleStatus).toHaveBeenCalledWith({ + expect(mockSetLifecycleStatus).toHaveBeenCalledWith({ statusName: 'error', statusData: { code: 'TmUSCSh01', @@ -101,13 +101,13 @@ describe('useSendCalls', () => { (isUserRejectedRequestError as Mock).mockReturnValue(true); renderHook(() => useSendCalls({ - setLifeCycleStatus: mockSetLifeCycleStatus, + setLifecycleStatus: mockSetLifecycleStatus, setTransactionId: mockSetTransactionId, }), ); expect(onErrorCallback).toBeDefined(); onErrorCallback?.(userRejectedError as TransactionExecutionError); - expect(mockSetLifeCycleStatus).toHaveBeenCalledWith({ + expect(mockSetLifecycleStatus).toHaveBeenCalledWith({ statusName: 'error', statusData: { code: 'TmUSCSh01', @@ -132,7 +132,7 @@ describe('useSendCalls', () => { ); renderHook(() => useSendCalls({ - setLifeCycleStatus: mockSetLifeCycleStatus, + setLifecycleStatus: mockSetLifecycleStatus, setTransactionId: mockSetTransactionId, }), ); diff --git a/src/transaction/hooks/useSendCalls.ts b/src/transaction/hooks/useSendCalls.ts index 71b14a4480..62abe53a63 100644 --- a/src/transaction/hooks/useSendCalls.ts +++ b/src/transaction/hooks/useSendCalls.ts @@ -10,7 +10,7 @@ import { isUserRejectedRequestError } from '../utils/isUserRejectedRequestError' * Does not support EOAs. */ export function useSendCalls({ - setLifeCycleStatus, + setLifecycleStatus, setTransactionId, }: UseSendCallsParams) { const { status, sendCallsAsync, data } = useSendCallsWagmi({ @@ -19,7 +19,7 @@ export function useSendCalls({ const errorMessage = isUserRejectedRequestError(e) ? 'Request denied.' : GENERIC_ERROR_MESSAGE; - setLifeCycleStatus({ + setLifecycleStatus({ statusName: 'error', statusData: { code: 'TmUSCSh01', // Transaction module UseSendCalls hook 01 error diff --git a/src/transaction/hooks/useWriteContract.test.ts b/src/transaction/hooks/useWriteContract.test.ts index d85531a218..74ba9aad4c 100644 --- a/src/transaction/hooks/useWriteContract.test.ts +++ b/src/transaction/hooks/useWriteContract.test.ts @@ -26,7 +26,7 @@ type MockUseWriteContractReturn = { }; describe('useWriteContract', () => { - const mockSetLifeCycleStatus = vi.fn(); + const mockSetLifecycleStatus = vi.fn(); beforeEach(() => { vi.resetAllMocks(); @@ -42,7 +42,7 @@ describe('useWriteContract', () => { } as MockUseWriteContractReturn); const { result } = renderHook(() => useWriteContract({ - setLifeCycleStatus: mockSetLifeCycleStatus, + setLifecycleStatus: mockSetLifecycleStatus, transactionHashList: [], }), ); @@ -66,13 +66,13 @@ describe('useWriteContract', () => { ); renderHook(() => useWriteContract({ - setLifeCycleStatus: mockSetLifeCycleStatus, + setLifecycleStatus: mockSetLifecycleStatus, transactionHashList: [], }), ); expect(onErrorCallback).toBeDefined(); onErrorCallback?.(genericError); - expect(mockSetLifeCycleStatus).toHaveBeenCalledWith({ + expect(mockSetLifecycleStatus).toHaveBeenCalledWith({ statusName: 'error', statusData: { code: 'TmUWCh01', @@ -98,13 +98,13 @@ describe('useWriteContract', () => { (isUserRejectedRequestError as Mock).mockReturnValue(true); renderHook(() => useWriteContract({ - setLifeCycleStatus: mockSetLifeCycleStatus, + setLifecycleStatus: mockSetLifecycleStatus, transactionHashList: [], }), ); expect(onErrorCallback).toBeDefined(); onErrorCallback?.(useRejectedError); - expect(mockSetLifeCycleStatus).toHaveBeenCalledWith({ + expect(mockSetLifecycleStatus).toHaveBeenCalledWith({ statusName: 'error', statusData: { code: 'TmUWCh01', @@ -129,13 +129,13 @@ describe('useWriteContract', () => { ); renderHook(() => useWriteContract({ - setLifeCycleStatus: mockSetLifeCycleStatus, + setLifecycleStatus: mockSetLifecycleStatus, transactionHashList: [], }), ); expect(onSuccessCallback).toBeDefined(); onSuccessCallback?.(transactionId); - expect(mockSetLifeCycleStatus).toHaveBeenCalledWith({ + expect(mockSetLifecycleStatus).toHaveBeenCalledWith({ statusName: 'transactionLegacyExecuted', statusData: { transactionHashList: [transactionId], @@ -158,13 +158,13 @@ describe('useWriteContract', () => { ); renderHook(() => useWriteContract({ - setLifeCycleStatus: mockSetLifeCycleStatus, + setLifecycleStatus: mockSetLifecycleStatus, transactionHashList: [], }), ); expect(onSuccessCallback).toBeDefined(); onSuccessCallback?.(transactionId); - expect(mockSetLifeCycleStatus).toHaveBeenCalledWith({ + expect(mockSetLifecycleStatus).toHaveBeenCalledWith({ statusName: 'transactionLegacyExecuted', statusData: { transactionHashList: [transactionId], @@ -172,12 +172,12 @@ describe('useWriteContract', () => { }); renderHook(() => useWriteContract({ - setLifeCycleStatus: mockSetLifeCycleStatus, + setLifecycleStatus: mockSetLifecycleStatus, transactionHashList: [transactionId], }), ); onSuccessCallback?.(transactionId); - expect(mockSetLifeCycleStatus).toHaveBeenCalledWith({ + expect(mockSetLifecycleStatus).toHaveBeenCalledWith({ statusName: 'transactionLegacyExecuted', statusData: { transactionHashList: [transactionId, transactionId], diff --git a/src/transaction/hooks/useWriteContract.ts b/src/transaction/hooks/useWriteContract.ts index 53ec6c26c6..f535456428 100644 --- a/src/transaction/hooks/useWriteContract.ts +++ b/src/transaction/hooks/useWriteContract.ts @@ -10,7 +10,7 @@ import { isUserRejectedRequestError } from '../utils/isUserRejectedRequestError' * Does not support transaction batching or paymasters. */ export function useWriteContract({ - setLifeCycleStatus, + setLifecycleStatus, transactionHashList, }: UseWriteContractParams) { const { status, writeContractAsync, data } = useWriteContractWagmi({ @@ -19,7 +19,7 @@ export function useWriteContract({ const errorMessage = isUserRejectedRequestError(e) ? 'Request denied.' : GENERIC_ERROR_MESSAGE; - setLifeCycleStatus({ + setLifecycleStatus({ statusName: 'error', statusData: { code: 'TmUWCh01', // Transaction module UseWriteContract hook 01 error @@ -29,7 +29,7 @@ export function useWriteContract({ }); }, onSuccess: (hash: Address) => { - setLifeCycleStatus({ + setLifecycleStatus({ statusName: 'transactionLegacyExecuted', statusData: { transactionHashList: [...transactionHashList, hash], diff --git a/src/transaction/hooks/useWriteContracts.test.ts b/src/transaction/hooks/useWriteContracts.test.ts index dd75038698..53272a3753 100644 --- a/src/transaction/hooks/useWriteContracts.test.ts +++ b/src/transaction/hooks/useWriteContracts.test.ts @@ -9,7 +9,7 @@ vi.mock('wagmi/experimental', () => ({ })); describe('useWriteContracts', () => { - const mockSetLifeCycleStatus = vi.fn(); + const mockSetLifecycleStatus = vi.fn(); const mockSetTransactionId = vi.fn(); beforeEach(() => { @@ -30,13 +30,13 @@ describe('useWriteContracts', () => { ); renderHook(() => useWriteContracts({ - setLifeCycleStatus: mockSetLifeCycleStatus, + setLifecycleStatus: mockSetLifecycleStatus, setTransactionId: mockSetTransactionId, }), ); expect(onErrorCallback).toBeDefined(); onErrorCallback?.(genericError); - expect(mockSetLifeCycleStatus).toHaveBeenCalledWith({ + expect(mockSetLifecycleStatus).toHaveBeenCalledWith({ statusName: 'error', statusData: { code: 'TmUWCSh01', @@ -61,7 +61,7 @@ describe('useWriteContracts', () => { ); renderHook(() => useWriteContracts({ - setLifeCycleStatus: mockSetLifeCycleStatus, + setLifecycleStatus: mockSetLifecycleStatus, setTransactionId: mockSetTransactionId, }), ); @@ -72,7 +72,7 @@ describe('useWriteContracts', () => { }, message: 'Request denied.', }); - expect(mockSetLifeCycleStatus).toHaveBeenCalledWith({ + expect(mockSetLifecycleStatus).toHaveBeenCalledWith({ statusName: 'error', statusData: { code: 'TmUWCSh01', @@ -98,7 +98,7 @@ describe('useWriteContracts', () => { ); renderHook(() => useWriteContracts({ - setLifeCycleStatus: mockSetLifeCycleStatus, + setLifecycleStatus: mockSetLifecycleStatus, setTransactionId: mockSetTransactionId, }), ); @@ -109,7 +109,7 @@ describe('useWriteContracts', () => { }, message: 'this request method is not supported', }); - expect(mockSetLifeCycleStatus).not.toHaveBeenCalled(); + expect(mockSetLifecycleStatus).not.toHaveBeenCalled(); }); it('should handle successful transaction', () => { @@ -126,7 +126,7 @@ describe('useWriteContracts', () => { ); renderHook(() => useWriteContracts({ - setLifeCycleStatus: mockSetLifeCycleStatus, + setLifecycleStatus: mockSetLifecycleStatus, setTransactionId: mockSetTransactionId, }), ); diff --git a/src/transaction/hooks/useWriteContracts.ts b/src/transaction/hooks/useWriteContracts.ts index 67b2cf829c..670afb4fe5 100644 --- a/src/transaction/hooks/useWriteContracts.ts +++ b/src/transaction/hooks/useWriteContracts.ts @@ -13,7 +13,7 @@ import { isUserRejectedRequestError } from '../utils/isUserRejectedRequestError' * Does not support EOAs. */ export function useWriteContracts({ - setLifeCycleStatus, + setLifecycleStatus, setTransactionId, }: UseWriteContractsParams) { const { status, writeContractsAsync } = useWriteContractsWagmi({ @@ -26,7 +26,7 @@ export function useWriteContracts({ const errorMessage = isUserRejectedRequestError(e) ? 'Request denied.' : GENERIC_ERROR_MESSAGE; - setLifeCycleStatus({ + setLifecycleStatus({ statusName: 'error', statusData: { code: 'TmUWCSh01', // Transaction module UseWriteContracts hook 01 error diff --git a/src/transaction/index.ts b/src/transaction/index.ts index 84a31c0e4a..2a033a0e7b 100644 --- a/src/transaction/index.ts +++ b/src/transaction/index.ts @@ -10,7 +10,7 @@ export { TransactionToastIcon } from './components/TransactionToastIcon'; export { TransactionToastAction } from './components/TransactionToastAction'; export { TransactionToastLabel } from './components/TransactionToastLabel'; export type { - LifeCycleStatus, + LifecycleStatus, TransactionButtonReact, TransactionError, TransactionReact, diff --git a/src/transaction/types.ts b/src/transaction/types.ts index 33a0da17aa..10f1656844 100644 --- a/src/transaction/types.ts +++ b/src/transaction/types.ts @@ -25,7 +25,7 @@ export type Call = { to: Hex; data?: Hex; value?: bigint }; * * Note: exported as public Type */ -export type LifeCycleStatus = +export type LifecycleStatus = | { statusName: 'init'; statusData: null; @@ -59,7 +59,7 @@ export type IsSpinnerDisplayedProps = { errorMessage?: string; hasReceipt?: boolean; isLoading?: boolean; - lifeCycleStatus: LifeCycleStatus; + lifecycleStatus: LifecycleStatus; transactionHash?: string; transactionId?: string; }; @@ -82,9 +82,9 @@ export type TransactionContextType = { onSubmit: () => void; // A function called when the transaction is submitted. paymasterUrl: string | null; // The paymaster URL for the transaction. receipt?: TransactionReceipt; // The receipt of the transaction - lifeCycleStatus: LifeCycleStatus; // The lifecycle status of the transaction. + lifecycleStatus: LifecycleStatus; // The lifecycle status of the transaction. setIsToastVisible: (isVisible: boolean) => void; // A function to set the visibility of the transaction toast. - setLifeCycleStatus: (state: LifeCycleStatus) => void; // A function to set the lifecycle status of the component + setLifecycleStatus: (state: LifecycleStatus) => void; // A function to set the lifecycle status of the component setTransactionId: (id: string) => void; // A function to set the transaction ID. transactions?: Call[] | ContractFunctionParameters[]; // An array of transactions for the component. transactionId?: string; // An optional string representing the ID of the transaction. @@ -128,7 +128,7 @@ export type TransactionProviderReact = { children: ReactNode; // The child components to be rendered within the provider component. contracts?: ContractFunctionParameters[]; // An array of contract function parameters provided to the child components. Mutually exclusive with the `calls` prop. onError?: (e: TransactionError) => void; // An optional callback function that handles errors within the provider. - onStatus?: (lifeCycleStatus: LifeCycleStatus) => void; // An optional callback function that exposes the component lifecycle state + onStatus?: (lifecycleStatus: LifecycleStatus) => void; // An optional callback function that exposes the component lifecycle state onSuccess?: (response: TransactionResponse) => void; // An optional callback function that exposes the transaction receipts }; @@ -143,7 +143,7 @@ export type TransactionReact = { className?: string; // An optional CSS class name for styling the component. contracts?: ContractFunctionParameters[]; // An array of contract function parameters for the transaction. Mutually exclusive with the `calls` prop. onError?: (e: TransactionError) => void; // An optional callback function that handles transaction errors. - onStatus?: (lifeCycleStatus: LifeCycleStatus) => void; // An optional callback function that exposes the component lifecycle state + onStatus?: (lifecycleStatus: LifecycleStatus) => void; // An optional callback function that exposes the component lifecycle state onSuccess?: (response: TransactionResponse) => void; // An optional callback function that exposes the transaction receipts }; @@ -215,27 +215,27 @@ export type TransactionToastLabelReact = { }; export type UseCallsStatusParams = { - setLifeCycleStatus: (state: LifeCycleStatus) => void; + setLifecycleStatus: (state: LifecycleStatus) => void; transactionId: string; }; export type UseWriteContractParams = { - setLifeCycleStatus: (state: LifeCycleStatus) => void; + setLifecycleStatus: (state: LifecycleStatus) => void; transactionHashList: Address[]; }; export type UseWriteContractsParams = { - setLifeCycleStatus: (state: LifeCycleStatus) => void; + setLifecycleStatus: (state: LifecycleStatus) => void; setTransactionId: (id: string) => void; }; export type UseSendCallParams = { - setLifeCycleStatus: (state: LifeCycleStatus) => void; + setLifecycleStatus: (state: LifecycleStatus) => void; transactionHashList: Address[]; }; export type UseSendCallsParams = { - setLifeCycleStatus: (state: LifeCycleStatus) => void; + setLifecycleStatus: (state: LifecycleStatus) => void; setTransactionId: (id: string) => void; }; diff --git a/src/transaction/utils/isSpinnerDisplayed.test.ts b/src/transaction/utils/isSpinnerDisplayed.test.ts index cecd3d4d48..f09f0a3228 100644 --- a/src/transaction/utils/isSpinnerDisplayed.test.ts +++ b/src/transaction/utils/isSpinnerDisplayed.test.ts @@ -1,18 +1,18 @@ import { beforeEach, describe, expect, it } from 'vitest'; -import type { LifeCycleStatus } from '../types'; +import type { LifecycleStatus } from '../types'; import { isSpinnerDisplayed } from './isSpinnerDisplayed'; describe('isSpinnerDisplayed', () => { let transactionHash: string; let errorMessage: string; - let lifeCycleStatus: LifeCycleStatus; + let lifecycleStatus: LifecycleStatus; let transactionId: string; let isLoading: boolean; beforeEach(() => { transactionHash = '123'; errorMessage = ''; - lifeCycleStatus = { statusName: 'init', statusData: null }; + lifecycleStatus = { statusName: 'init', statusData: null }; transactionId = ''; isLoading = false; }); @@ -21,7 +21,7 @@ describe('isSpinnerDisplayed', () => { const result = isSpinnerDisplayed({ errorMessage, isLoading, - lifeCycleStatus, + lifecycleStatus, transactionHash, transactionId, }); @@ -36,7 +36,7 @@ describe('isSpinnerDisplayed', () => { const result = isSpinnerDisplayed({ errorMessage, isLoading, - lifeCycleStatus, + lifecycleStatus, transactionHash, transactionId, }); @@ -46,13 +46,13 @@ describe('isSpinnerDisplayed', () => { it('should return true if status is pending', () => { transactionHash = ''; errorMessage = ''; - lifeCycleStatus = { statusName: 'transactionPending', statusData: null }; + lifecycleStatus = { statusName: 'transactionPending', statusData: null }; transactionId = ''; isLoading = false; const result = isSpinnerDisplayed({ errorMessage, isLoading, - lifeCycleStatus, + lifecycleStatus, transactionHash, transactionId, }); @@ -67,7 +67,7 @@ describe('isSpinnerDisplayed', () => { const result = isSpinnerDisplayed({ errorMessage, isLoading, - lifeCycleStatus, + lifecycleStatus, transactionHash, transactionId, }); @@ -82,7 +82,7 @@ describe('isSpinnerDisplayed', () => { const result = isSpinnerDisplayed({ errorMessage, isLoading, - lifeCycleStatus, + lifecycleStatus, transactionHash, transactionId, }); diff --git a/src/transaction/utils/isSpinnerDisplayed.ts b/src/transaction/utils/isSpinnerDisplayed.ts index 5508ae9f63..5dce5beac8 100644 --- a/src/transaction/utils/isSpinnerDisplayed.ts +++ b/src/transaction/utils/isSpinnerDisplayed.ts @@ -4,11 +4,11 @@ export function isSpinnerDisplayed({ errorMessage, hasReceipt, isLoading, - lifeCycleStatus, + lifecycleStatus, transactionHash, transactionId, }: IsSpinnerDisplayedProps) { - const isPending = lifeCycleStatus.statusName === 'transactionPending'; + const isPending = lifecycleStatus.statusName === 'transactionPending'; const isInProgress = transactionId || transactionHash; if (hasReceipt || errorMessage) {