From c4a4cf0e1bc25036b44551b0464c1f01e95c39a1 Mon Sep 17 00:00:00 2001 From: IF <139582705+infiniteflower@users.noreply.github.com> Date: Thu, 11 Jul 2024 13:27:58 -0400 Subject: [PATCH 1/7] fix: missing deadline in swaps stx status screen --- app/scripts/controllers/swaps.constants.ts | 2 ++ app/scripts/controllers/swaps.types.ts | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/scripts/controllers/swaps.constants.ts b/app/scripts/controllers/swaps.constants.ts index d959c02c439e..6228dd2bcb66 100644 --- a/app/scripts/controllers/swaps.constants.ts +++ b/app/scripts/controllers/swaps.constants.ts @@ -1,4 +1,5 @@ import { + FALLBACK_SMART_TRANSACTIONS_DEADLINE, FALLBACK_SMART_TRANSACTIONS_MAX_FEE_MULTIPLIER, FALLBACK_SMART_TRANSACTIONS_REFRESH_TIME, } from '../../../shared/constants/smartTransactions'; @@ -42,6 +43,7 @@ export const swapsControllerInitialState: { swapsState: SwapsControllerState } = swapsQuoteRefreshTime: FALLBACK_QUOTE_REFRESH_TIME, swapsQuotePrefetchingRefreshTime: FALLBACK_QUOTE_REFRESH_TIME, swapsStxBatchStatusRefreshTime: FALLBACK_SMART_TRANSACTIONS_REFRESH_TIME, + swapsStxStatusDeadline: FALLBACK_SMART_TRANSACTIONS_DEADLINE, swapsStxGetTransactionsRefreshTime: FALLBACK_SMART_TRANSACTIONS_REFRESH_TIME, swapsStxMaxFeeMultiplier: FALLBACK_SMART_TRANSACTIONS_MAX_FEE_MULTIPLIER, diff --git a/app/scripts/controllers/swaps.types.ts b/app/scripts/controllers/swaps.types.ts index 0164e253678e..99b71acd569a 100644 --- a/app/scripts/controllers/swaps.types.ts +++ b/app/scripts/controllers/swaps.types.ts @@ -41,7 +41,7 @@ export type SwapsControllerState = { swapsQuoteRefreshTime: number; swapsQuotePrefetchingRefreshTime: number; swapsStxBatchStatusRefreshTime: number; - swapsStxStatusDeadline?: number; + swapsStxStatusDeadline: number; swapsStxGetTransactionsRefreshTime: number; swapsStxMaxFeeMultiplier: number; swapsFeatureFlags: Record; From 924a839c25c3b3905c87d29335ee5fd4222a196b Mon Sep 17 00:00:00 2001 From: IF <139582705+infiniteflower@users.noreply.github.com> Date: Fri, 12 Jul 2024 17:47:28 -0400 Subject: [PATCH 2/7] fix: broken tests --- app/scripts/controllers/swaps.test.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/scripts/controllers/swaps.test.js b/app/scripts/controllers/swaps.test.js index e5059467532d..087756502b49 100644 --- a/app/scripts/controllers/swaps.test.js +++ b/app/scripts/controllers/swaps.test.js @@ -9,6 +9,7 @@ import { GasEstimateTypes } from '../../../shared/constants/gas'; import { FALLBACK_SMART_TRANSACTIONS_REFRESH_TIME, FALLBACK_SMART_TRANSACTIONS_MAX_FEE_MULTIPLIER, + FALLBACK_SMART_TRANSACTIONS_DEADLINE, } from '../../../shared/constants/smartTransactions'; import SwapsController from './swaps'; import { getMedianEthValueQuote } from './swaps.utils'; @@ -117,6 +118,7 @@ const EMPTY_INIT_STATE = { swapsQuoteRefreshTime: 60000, swapsQuotePrefetchingRefreshTime: 60000, swapsStxBatchStatusRefreshTime: FALLBACK_SMART_TRANSACTIONS_REFRESH_TIME, + swapsStxStatusDeadline: FALLBACK_SMART_TRANSACTIONS_DEADLINE, swapsStxGetTransactionsRefreshTime: FALLBACK_SMART_TRANSACTIONS_REFRESH_TIME, swapsStxMaxFeeMultiplier: FALLBACK_SMART_TRANSACTIONS_MAX_FEE_MULTIPLIER, From e267f6d903cee0702176c8104196d9a6178e0e53 Mon Sep 17 00:00:00 2001 From: IF <139582705+infiniteflower@users.noreply.github.com> Date: Mon, 15 Jul 2024 15:33:22 -0400 Subject: [PATCH 3/7] chore: update snapshots for tests --- .../errors-after-init-opt-in-background-state.json | 1 + .../state-snapshots/errors-after-init-opt-in-ui-state.json | 1 + 2 files changed, 2 insertions(+) diff --git a/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-background-state.json b/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-background-state.json index eb815b7727eb..db9f9787495b 100644 --- a/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-background-state.json +++ b/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-background-state.json @@ -271,6 +271,7 @@ "swapsQuoteRefreshTime": 60000, "swapsQuotePrefetchingRefreshTime": 60000, "swapsStxBatchStatusRefreshTime": 10000, + "swapsStxStatusDeadline": 180, "swapsStxGetTransactionsRefreshTime": 10000, "swapsStxMaxFeeMultiplier": 2 } diff --git a/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-ui-state.json b/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-ui-state.json index 5f9666cb6702..bf00b799b98d 100644 --- a/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-ui-state.json +++ b/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-ui-state.json @@ -251,6 +251,7 @@ "swapsQuoteRefreshTime": 60000, "swapsQuotePrefetchingRefreshTime": 60000, "swapsStxBatchStatusRefreshTime": 10000, + "swapsStxStatusDeadline": 180, "swapsStxGetTransactionsRefreshTime": 10000, "swapsStxMaxFeeMultiplier": 2 }, From fb970d5e1ba4056c84cbf981877d8d05cfe1488f Mon Sep 17 00:00:00 2001 From: IF <139582705+infiniteflower@users.noreply.github.com> Date: Mon, 15 Jul 2024 16:30:15 -0400 Subject: [PATCH 4/7] chore: attempt at fixing tests --- app/scripts/controllers/swaps.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/scripts/controllers/swaps.ts b/app/scripts/controllers/swaps.ts index b0915b2ed21f..00a6dbde5414 100644 --- a/app/scripts/controllers/swaps.ts +++ b/app/scripts/controllers/swaps.ts @@ -22,6 +22,7 @@ import { } from '../../../shared/constants/metametrics'; import { CHAIN_IDS } from '../../../shared/constants/network'; import { + FALLBACK_SMART_TRANSACTIONS_DEADLINE, FALLBACK_SMART_TRANSACTIONS_MAX_FEE_MULTIPLIER, FALLBACK_SMART_TRANSACTIONS_REFRESH_TIME, } from '../../../shared/constants/smartTransactions'; @@ -938,6 +939,9 @@ export default class SwapsController { swapsStxGetTransactionsRefreshTime: swapsNetworkConfig?.stxGetTransactions || FALLBACK_SMART_TRANSACTIONS_REFRESH_TIME, + swapsStxStatusDeadline: + swapsNetworkConfig?.stxStatusDeadline || + FALLBACK_SMART_TRANSACTIONS_DEADLINE, swapsStxBatchStatusRefreshTime: swapsNetworkConfig?.stxBatchStatus || FALLBACK_SMART_TRANSACTIONS_REFRESH_TIME, From 190ac46ee09afa39ee6f56a586f956f8966bcf16 Mon Sep 17 00:00:00 2001 From: Marta Poling Date: Fri, 16 Aug 2024 14:11:09 -0500 Subject: [PATCH 5/7] fix: updates snapshot value for swaps stx tx deadline --- .../errors-after-init-opt-in-background-state.json | 2 +- .../state-snapshots/errors-after-init-opt-in-ui-state.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-background-state.json b/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-background-state.json index 6860c4b681ec..c294f6e1f34f 100644 --- a/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-background-state.json +++ b/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-background-state.json @@ -272,7 +272,7 @@ "swapsQuoteRefreshTime": 60000, "swapsQuotePrefetchingRefreshTime": 60000, "swapsStxBatchStatusRefreshTime": 10000, - "swapsStxStatusDeadline": 180, + "swapsStxStatusDeadline": "number", "swapsStxGetTransactionsRefreshTime": 10000, "swapsStxMaxFeeMultiplier": 2, "swapsFeatureFlags": {} diff --git a/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-ui-state.json b/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-ui-state.json index 1353e503c819..78113057ffe7 100644 --- a/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-ui-state.json +++ b/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-ui-state.json @@ -247,7 +247,7 @@ "swapsQuoteRefreshTime": 60000, "swapsQuotePrefetchingRefreshTime": 60000, "swapsStxBatchStatusRefreshTime": 10000, - "swapsStxStatusDeadline": 180, + "swapsStxStatusDeadline": "number", "swapsStxGetTransactionsRefreshTime": 10000, "swapsStxMaxFeeMultiplier": 2, "swapsFeatureFlags": {} From 596e7222529edf43ecbea26216dfcc51204c4611 Mon Sep 17 00:00:00 2001 From: Marta Poling Date: Mon, 19 Aug 2024 11:55:41 -0500 Subject: [PATCH 6/7] fix: include swaps stx status deadline from api --- app/scripts/controllers/swaps/index.ts | 4 ++++ .../smart-transaction-status/smart-transaction-status.js | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/scripts/controllers/swaps/index.ts b/app/scripts/controllers/swaps/index.ts index 4decda4995ed..c2a947686ad3 100644 --- a/app/scripts/controllers/swaps/index.ts +++ b/app/scripts/controllers/swaps/index.ts @@ -23,6 +23,7 @@ import { CHAIN_IDS } from '../../../../shared/constants/network'; import { FALLBACK_SMART_TRANSACTIONS_MAX_FEE_MULTIPLIER, FALLBACK_SMART_TRANSACTIONS_REFRESH_TIME, + FALLBACK_SMART_TRANSACTIONS_DEADLINE, } from '../../../../shared/constants/smartTransactions'; import { DEFAULT_ERC20_APPROVE_GAS, @@ -1082,6 +1083,9 @@ export default class SwapsController extends BaseController< _state.swapsState.swapsStxMaxFeeMultiplier = swapsNetworkConfig?.stxMaxFeeMultiplier || FALLBACK_SMART_TRANSACTIONS_MAX_FEE_MULTIPLIER; + _state.swapsState.swapsStxStatusDeadline = + swapsNetworkConfig?.stxStatusDeadline || + FALLBACK_SMART_TRANSACTIONS_DEADLINE; }); } diff --git a/ui/pages/swaps/smart-transaction-status/smart-transaction-status.js b/ui/pages/swaps/smart-transaction-status/smart-transaction-status.js index ad60188f4ce1..157190687f31 100644 --- a/ui/pages/swaps/smart-transaction-status/smart-transaction-status.js +++ b/ui/pages/swaps/smart-transaction-status/smart-transaction-status.js @@ -110,7 +110,6 @@ export default function SmartTransactionStatusPage() { cancellationFeeWei = latestSmartTransaction?.statusMetadata?.cancellationFeeWei; } - const [timeLeftForPendingStxInSec, setTimeLeftForPendingStxInSec] = useState( swapsNetworkConfig.stxStatusDeadline, ); From af3c138e82aa31469ba5ef102cdb8c505f340532 Mon Sep 17 00:00:00 2001 From: Marta Poling Date: Mon, 19 Aug 2024 15:57:08 -0500 Subject: [PATCH 7/7] fix: update tests to use number instead of type for swapsStxStatusDeadline --- app/scripts/controllers/swaps/swaps.test.ts | 3 +++ app/scripts/lib/setupSentry.js | 1 + .../errors-after-init-opt-in-background-state.json | 2 +- .../state-snapshots/errors-after-init-opt-in-ui-state.json | 2 +- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/scripts/controllers/swaps/swaps.test.ts b/app/scripts/controllers/swaps/swaps.test.ts index 8b2fbd22d032..3fa4f1ff9409 100644 --- a/app/scripts/controllers/swaps/swaps.test.ts +++ b/app/scripts/controllers/swaps/swaps.test.ts @@ -1096,6 +1096,7 @@ describe('SwapsController', function () { oldState.swapsState.swapsStxGetTransactionsRefreshTime, swapsStxBatchStatusRefreshTime: oldState.swapsState.swapsStxBatchStatusRefreshTime, + swapsStxStatusDeadline: oldState.swapsState.swapsStxStatusDeadline, }); }); @@ -1171,6 +1172,7 @@ describe('SwapsController', function () { const swapsQuotePrefetchingRefreshTime = 0; const swapsStxBatchStatusRefreshTime = 0; const swapsStxGetTransactionsRefreshTime = 0; + const swapsStxStatusDeadline = 0; swapsController.__test__updateState({ swapsState: { ...swapsController.state.swapsState, @@ -1182,6 +1184,7 @@ describe('SwapsController', function () { swapsQuotePrefetchingRefreshTime, swapsStxBatchStatusRefreshTime, swapsStxGetTransactionsRefreshTime, + swapsStxStatusDeadline, }, }); diff --git a/app/scripts/lib/setupSentry.js b/app/scripts/lib/setupSentry.js index 57ef48e14717..62dae2b8da52 100644 --- a/app/scripts/lib/setupSentry.js +++ b/app/scripts/lib/setupSentry.js @@ -351,6 +351,7 @@ export const SENTRY_BACKGROUND_STATE = { swapsQuotePrefetchingRefreshTime: true, swapsQuoteRefreshTime: true, swapsStxBatchStatusRefreshTime: true, + swapsStxStatusDeadline: true, swapsStxGetTransactionsRefreshTime: true, swapsStxMaxFeeMultiplier: true, swapsUserFeeLevel: true, diff --git a/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-background-state.json b/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-background-state.json index c294f6e1f34f..6860c4b681ec 100644 --- a/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-background-state.json +++ b/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-background-state.json @@ -272,7 +272,7 @@ "swapsQuoteRefreshTime": 60000, "swapsQuotePrefetchingRefreshTime": 60000, "swapsStxBatchStatusRefreshTime": 10000, - "swapsStxStatusDeadline": "number", + "swapsStxStatusDeadline": 180, "swapsStxGetTransactionsRefreshTime": 10000, "swapsStxMaxFeeMultiplier": 2, "swapsFeatureFlags": {} diff --git a/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-ui-state.json b/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-ui-state.json index 78113057ffe7..1353e503c819 100644 --- a/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-ui-state.json +++ b/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-ui-state.json @@ -247,7 +247,7 @@ "swapsQuoteRefreshTime": 60000, "swapsQuotePrefetchingRefreshTime": 60000, "swapsStxBatchStatusRefreshTime": 10000, - "swapsStxStatusDeadline": "number", + "swapsStxStatusDeadline": 180, "swapsStxGetTransactionsRefreshTime": 10000, "swapsStxMaxFeeMultiplier": 2, "swapsFeatureFlags": {}