Skip to content

Commit

Permalink
Update to pass lifeCycleStatus instead of maxSlippage to processSwapT…
Browse files Browse the repository at this point in the history
…ransaction
  • Loading branch information
cpcramer committed Sep 5, 2024
1 parent fce027d commit cab4738
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/swap/components/SwapProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ export function SwapProvider({
}
await processSwapTransaction({
config,
maxSlippage,
lifeCycleStatus,
sendTransactionAsync,
setLifeCycleStatus,
swapTransaction: response,
Expand Down
2 changes: 1 addition & 1 deletion src/swap/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,11 @@ export type LifeCycleStatus =

export type ProcessSwapTransactionParams = {
config: Config;
lifeCycleStatus: LifeCycleStatus;
setLifeCycleStatus: (state: LifeCycleStatus) => void;
sendTransactionAsync: SendTransactionMutateAsync<Config, unknown>;
swapTransaction: BuildSwapTransaction;
useAggregator: boolean;
maxSlippage: number;
};

/**
Expand Down
7 changes: 6 additions & 1 deletion src/swap/utils/processSwapTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,19 @@ import type { ProcessSwapTransactionParams } from '../types';

export async function processSwapTransaction({
config,
maxSlippage,
lifeCycleStatus,
sendTransactionAsync,
setLifeCycleStatus,
swapTransaction,
useAggregator,
}: ProcessSwapTransactionParams) {
const { transaction, approveTransaction, quote } = swapTransaction;

const maxSlippage =
lifeCycleStatus.statusName !== 'error'

Check failure on line 21 in src/swap/utils/processSwapTransaction.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

src/swap/utils/processSwapTransaction.test.ts > processSwapTransaction > should request approval and make the swap for ERC-20 tokens

TypeError: Cannot read properties of undefined (reading 'statusName') ❯ Module.processSwapTransaction src/swap/utils/processSwapTransaction.ts:21:21 ❯ src/swap/utils/processSwapTransaction.test.ts:98:11

Check failure on line 21 in src/swap/utils/processSwapTransaction.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

src/swap/utils/processSwapTransaction.test.ts > processSwapTransaction > should make the swap for non-ERC-20 tokens

TypeError: Cannot read properties of undefined (reading 'statusName') ❯ Module.processSwapTransaction src/swap/utils/processSwapTransaction.ts:21:21 ❯ src/swap/utils/processSwapTransaction.test.ts:156:11

Check failure on line 21 in src/swap/utils/processSwapTransaction.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

src/swap/utils/processSwapTransaction.test.ts > processSwapTransaction > should successfully use Permit2 approval process for `useAggregator`=false

TypeError: Cannot read properties of undefined (reading 'statusName') ❯ Module.processSwapTransaction src/swap/utils/processSwapTransaction.ts:21:21 ❯ src/swap/utils/processSwapTransaction.test.ts:208:11
? lifeCycleStatus.statusData.maxSlippage
: 3;

// for swaps from ERC-20 tokens,
// if there is an approveTransaction present,
// request approval for the amount
Expand Down

0 comments on commit cab4738

Please sign in to comment.