From 3c5c0c49f81cd76cc941f806507d315f7fcf7792 Mon Sep 17 00:00:00 2001 From: Alec Chen <93971719+0xAlec@users.noreply.github.com> Date: Thu, 19 Sep 2024 16:28:53 -0400 Subject: [PATCH] fix --- src/swap/utils/sendSwapTransactions.test.ts | 21 ++++++++++++++++----- src/swap/utils/sendSwapTransactions.ts | 2 +- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/swap/utils/sendSwapTransactions.test.ts b/src/swap/utils/sendSwapTransactions.test.ts index 57eaf0789..4cb5ec3c3 100644 --- a/src/swap/utils/sendSwapTransactions.test.ts +++ b/src/swap/utils/sendSwapTransactions.test.ts @@ -4,7 +4,6 @@ import { waitForTransactionReceipt } from 'wagmi/actions'; import { mainnet, sepolia } from 'wagmi/chains'; import { mock } from 'wagmi/connectors'; import { Capabilities } from '../../constants'; -import type { Call } from '../../transaction/types'; import { sendSwapTransactions } from './sendSwapTransactions'; vi.mock('wagmi/actions', () => ({ @@ -51,9 +50,19 @@ describe('sendSwapTransactions', () => { }); it('should execute atomic batch transactions when supported', async () => { - const transactions: Call[] = [ - { to: '0x123', value: 0n, data: '0x' }, - { to: '0x456', value: 0n, data: '0x' }, + const transactions = [ + { + transaction: { to: '0x123', value: 0n, data: '0x' }, + transactionType: 'Permit2', + }, + { + transaction: { to: '0x456', value: 0n, data: '0x' }, + transactionType: 'ERC20', + }, + { + transaction: { to: '0x789', value: 0n, data: '0x' }, + transactionType: 'Swap', + }, ]; await sendSwapTransactions({ config, @@ -64,7 +73,9 @@ describe('sendSwapTransactions', () => { transactions, }); expect(sendCallsAsync).toHaveBeenCalledTimes(1); - expect(sendCallsAsync).toHaveBeenCalledWith({ calls: transactions }); + expect(sendCallsAsync).toHaveBeenCalledWith({ + calls: transactions.map(({ transaction }) => transaction), + }); expect(updateLifecycleStatus).toHaveBeenCalledTimes(2); expect(updateLifecycleStatus).toHaveBeenNthCalledWith(1, { statusName: 'transactionPending', diff --git a/src/swap/utils/sendSwapTransactions.ts b/src/swap/utils/sendSwapTransactions.ts index d61dd7c57..0a2c38022 100644 --- a/src/swap/utils/sendSwapTransactions.ts +++ b/src/swap/utils/sendSwapTransactions.ts @@ -16,7 +16,7 @@ export async function sendSwapTransactions({ statusName: 'transactionPending', }); const callsId = await sendCallsAsync({ - calls: transactions, + calls: transactions.map(({ transaction }) => transaction), }); updateLifecycleStatus({ statusName: 'transactionApproved',