From 135f0bb4f099bcd447d413f4102ae224eb7a9dff Mon Sep 17 00:00:00 2001 From: Daniel <80175477+dan437@users.noreply.github.com> Date: Tue, 6 Apr 2021 17:19:55 -0700 Subject: [PATCH] Add validation for the `fee` property from the `/trades` API response (#10836) --- ui/app/pages/swaps/swaps-util-test-constants.js | 1 + ui/app/pages/swaps/swaps.util.js | 4 ++++ ui/app/pages/swaps/swaps.util.test.js | 1 + 3 files changed, 6 insertions(+) diff --git a/ui/app/pages/swaps/swaps-util-test-constants.js b/ui/app/pages/swaps/swaps-util-test-constants.js index 1491b1184..cf54889b1 100644 --- a/ui/app/pages/swaps/swaps-util-test-constants.js +++ b/ui/app/pages/swaps/swaps-util-test-constants.js @@ -101,6 +101,7 @@ export const MOCK_TRADE_RESPONSE_1 = [ sourceAmount: '10000000000000000', destinationAmount: '2248687', error: null, + fee: 0.875, sourceToken: TOKENS[0].address, destinationToken: TOKENS[1].address, fetchTime: 553, diff --git a/ui/app/pages/swaps/swaps.util.js b/ui/app/pages/swaps/swaps.util.js index f4da20606..e97a751ae 100644 --- a/ui/app/pages/swaps/swaps.util.js +++ b/ui/app/pages/swaps/swaps.util.js @@ -131,6 +131,10 @@ const QUOTE_VALIDATORS = [ type: 'number|undefined', validator: (gasEstimate) => gasEstimate === undefined || gasEstimate > 0, }, + { + property: 'fee', + type: 'number', + }, ]; const TOKEN_VALIDATORS = [ diff --git a/ui/app/pages/swaps/swaps.util.test.js b/ui/app/pages/swaps/swaps.util.test.js index df305e675..8d61b4e1f 100644 --- a/ui/app/pages/swaps/swaps.util.test.js +++ b/ui/app/pages/swaps/swaps.util.test.js @@ -64,6 +64,7 @@ describe('Swaps Util', function () { sourceAmount: '10000000000000000', destinationAmount: '2248687', error: null, + fee: 0.875, sourceToken: TOKENS[0].address, destinationToken: TOKENS[1].address, fetchTime: 553,