Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
0xAlec committed Sep 19, 2024
1 parent f7c720a commit 3c5c0c4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
21 changes: 16 additions & 5 deletions src/swap/utils/sendSwapTransactions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => ({
Expand Down Expand Up @@ -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,
Expand All @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion src/swap/utils/sendSwapTransactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export async function sendSwapTransactions({
statusName: 'transactionPending',
});
const callsId = await sendCallsAsync({
calls: transactions,
calls: transactions.map(({ transaction }) => transaction),
});
updateLifecycleStatus({
statusName: 'transactionApproved',
Expand Down

0 comments on commit 3c5c0c4

Please sign in to comment.