Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
0xAlec committed Sep 16, 2024
1 parent f0ae761 commit e41d832
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/swap/components/SwapProvider.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ describe('SwapProvider', () => {
});

it('should handle `useCallsStatus` for batched transactions', async () => {
const {} = renderHook(() => useSwapContext(), { wrapper });
renderHook(() => useSwapContext(), { wrapper });
const mockData = {
status: 'CONFIRMED',
receipts: [{}],
Expand Down Expand Up @@ -332,7 +332,7 @@ describe('SwapProvider', () => {
},
);

const {} = renderHook(() => useSwapContext(), { wrapper });
renderHook(() => useSwapContext(), { wrapper });
});

it('should use the appropriate refetch interval for non-CONFIRMED', async () => {
Expand All @@ -350,7 +350,7 @@ describe('SwapProvider', () => {
},
);

const {} = renderHook(() => useSwapContext(), { wrapper });
renderHook(() => useSwapContext(), { wrapper });
});

it('should emit onError when setLifecycleStatus is called with error', async () => {
Expand Down
5 changes: 2 additions & 3 deletions src/swap/components/SwapProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export function SwapProvider({
// Core Hooks
const accountConfig = useConfig();
const [callsId, setCallsId] = useState<Hex>();
const { data } = useCallsStatus({
const callsStatus = useCallsStatus({
id: callsId || '0x',
query: {
refetchInterval: (query) => {
Expand All @@ -79,7 +79,7 @@ export function SwapProvider({
const awaitCallsStatus = useAwaitCalls({
accountConfig,
config,
data,
callsStatus,
setLifecycleStatus,
});

Expand Down Expand Up @@ -355,7 +355,6 @@ export function SwapProvider({
lifecycleStatus,
sendCallsAsync,
sendTransactionAsync,
setCallsId,
to.token,
updateLifecycleStatus,
useAggregator,
Expand Down
11 changes: 5 additions & 6 deletions src/swap/hooks/useAwaitCalls.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
import { useCallback } from 'react';
import type { WalletCallReceipt } from 'viem';
import type { Config } from 'wagmi';
import { waitForTransactionReceipt } from 'wagmi/actions';
import type { UseCallsStatusReturnType } from 'wagmi/experimental';
import type { LifecycleStatus } from '../types';

export function useAwaitCalls({
accountConfig,
config,
data,
callsStatus,
setLifecycleStatus,
}: {
accountConfig: Config;
config: {
maxSlippage: number;
};
data: {
status: 'PENDING' | 'CONFIRMED';
receipts?: WalletCallReceipt<bigint, 'success' | 'reverted'>[] | undefined;
};
callsStatus: UseCallsStatusReturnType;
setLifecycleStatus: React.Dispatch<React.SetStateAction<LifecycleStatus>>;
}) {
const { data } = callsStatus;

Check failure on line 20 in src/swap/hooks/useAwaitCalls.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

src/swap/hooks/useAwaitCalls.test.ts > useAwaitCalls > should not call waitForTransactionReceipt when data status is not CONFIRMED

TypeError: Cannot destructure property 'data' of 'callsStatus' as it is undefined. ❯ Module.useAwaitCalls src/swap/hooks/useAwaitCalls.ts:20:11 ❯ src/swap/hooks/useAwaitCalls.test.ts:19:7 ❯ TestComponent node_modules/@testing-library/react/dist/pure.js:309:27 ❯ renderWithHooks node_modules/react-dom/cjs/react-dom.development.js:15486:18 ❯ mountIndeterminateComponent node_modules/react-dom/cjs/react-dom.development.js:20103:13 ❯ beginWork node_modules/react-dom/cjs/react-dom.development.js:21626:16 ❯ beginWork$1 node_modules/react-dom/cjs/react-dom.development.js:27465:14 ❯ performUnitOfWork node_modules/react-dom/cjs/react-dom.development.js:26599:12 ❯ workLoopSync node_modules/react-dom/cjs/react-dom.development.js:26505:5 ❯ renderRootSync node_modules/react-dom/cjs/react-dom.development.js:26473:7

Check failure on line 20 in src/swap/hooks/useAwaitCalls.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

src/swap/hooks/useAwaitCalls.test.ts > useAwaitCalls > should call waitForTransactionReceipt and update lifecycle status when data status is CONFIRMED

TypeError: Cannot destructure property 'data' of 'callsStatus' as it is undefined. ❯ Module.useAwaitCalls src/swap/hooks/useAwaitCalls.ts:20:11 ❯ src/swap/hooks/useAwaitCalls.test.ts:43:7 ❯ TestComponent node_modules/@testing-library/react/dist/pure.js:309:27 ❯ renderWithHooks node_modules/react-dom/cjs/react-dom.development.js:15486:18 ❯ mountIndeterminateComponent node_modules/react-dom/cjs/react-dom.development.js:20103:13 ❯ beginWork node_modules/react-dom/cjs/react-dom.development.js:21626:16 ❯ beginWork$1 node_modules/react-dom/cjs/react-dom.development.js:27465:14 ❯ performUnitOfWork node_modules/react-dom/cjs/react-dom.development.js:26599:12 ❯ workLoopSync node_modules/react-dom/cjs/react-dom.development.js:26505:5 ❯ renderRootSync node_modules/react-dom/cjs/react-dom.development.js:26473:7

return useCallback(async () => {
if (data?.status === 'CONFIRMED' && data?.receipts) {
const transactionReceipt = await waitForTransactionReceipt(
Expand Down

0 comments on commit e41d832

Please sign in to comment.