-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into remove_api_mock
- Loading branch information
Showing
14 changed files
with
144 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 8 additions & 7 deletions
15
apps/cowswap-frontend/src/modules/ordersTable/pure/ReceiptModal/FeeField.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
apps/cowswap-frontend/src/modules/ordersTable/utils/getFeeToken.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { getFeeToken } from './getFeeToken' // Adjust the import path as necessary | ||
|
||
import { ordersMock } from '../pure/OrdersTableContainer/orders.mock' | ||
|
||
const BASE_ORDER = ordersMock[3] | ||
|
||
describe('getFeeToken', () => { | ||
it("should return inputToken when that's the fee token", () => { | ||
const input = BASE_ORDER | ||
const expectedOutput = BASE_ORDER.inputToken | ||
|
||
const result = getFeeToken(input) | ||
|
||
expect(result).toEqual(expectedOutput) | ||
}) | ||
|
||
it("should return outputToken when that's the fee token", () => { | ||
const input = { | ||
...BASE_ORDER, | ||
executionData: { ...BASE_ORDER.executionData, executedFeeToken: BASE_ORDER.outputToken.address }, | ||
} | ||
const expectedOutput = BASE_ORDER.outputToken | ||
|
||
const result = getFeeToken(input) | ||
|
||
expect(result).toEqual(expectedOutput) | ||
}) | ||
|
||
it('should return inputToken when there is no fee token', () => { | ||
const input = { ...BASE_ORDER, executionData: { ...BASE_ORDER.executionData, executedFeeToken: null } } | ||
const expectedOutput = BASE_ORDER.inputToken | ||
|
||
const result = getFeeToken(input) | ||
|
||
expect(result).toEqual(expectedOutput) | ||
}) | ||
}) |
14 changes: 14 additions & 0 deletions
14
apps/cowswap-frontend/src/modules/ordersTable/utils/getFeeToken.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { ParsedOrder } from 'utils/orderUtils/parseOrder' | ||
|
||
export function getFeeToken(order: ParsedOrder) { | ||
const { inputToken, outputToken } = order | ||
const { executedFeeToken } = order.executionData | ||
|
||
const feeTokenAddress = executedFeeToken?.toLowerCase() | ||
|
||
if (!feeTokenAddress) { | ||
return inputToken | ||
} | ||
|
||
return [inputToken, outputToken].find((token) => token?.address.toLowerCase() === feeTokenAddress) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.