From 377f276142416d96c17c65687e546615c03aa7ed Mon Sep 17 00:00:00 2001 From: dan437 <80175477+dan437@users.noreply.github.com> Date: Wed, 13 Nov 2024 11:35:16 +0100 Subject: [PATCH 1/3] Rename returnTxHashAsap to mobileReturnTxHashAsap --- app/reducers/swaps/swaps.test.ts | 12 ++++++------ app/selectors/smartTransactionsController.test.ts | 2 +- .../smart-transactions/smart-publish-hook.test.ts | 4 ++-- app/util/smart-transactions/smart-publish-hook.ts | 10 +++++----- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/app/reducers/swaps/swaps.test.ts b/app/reducers/swaps/swaps.test.ts index 402b96bb85b..f8bfdeae4e9 100644 --- a/app/reducers/swaps/swaps.test.ts +++ b/app/reducers/swaps/swaps.test.ts @@ -24,7 +24,7 @@ const DEFAULT_FEATURE_FLAGS = { smartTransactions: { expectedDeadline: 45, maxDeadline: 150, - returnTxHashAsap: false, + mobileReturnTxHashAsap: false, }, }, bsc: { @@ -90,7 +90,7 @@ describe('swaps reducer', () => { smartTransactions: { expectedDeadline: 45, maxDeadline: 150, - returnTxHashAsap: false, + mobileReturnTxHashAsap: false, }, }; @@ -122,7 +122,7 @@ describe('swaps reducer', () => { smartTransactions: { expectedDeadline: 45, maxDeadline: 150, - returnTxHashAsap: false, + mobileReturnTxHashAsap: false, }, }; @@ -154,7 +154,7 @@ describe('swaps reducer', () => { smartTransactions: { expectedDeadline: 45, maxDeadline: 150, - returnTxHashAsap: false, + mobileReturnTxHashAsap: false, }, }; @@ -226,7 +226,7 @@ describe('swaps reducer', () => { smartTransactions: { expectedDeadline: 45, maxDeadline: 150, - returnTxHashAsap: false, + mobileReturnTxHashAsap: false, }, }, }, @@ -281,7 +281,7 @@ describe('swaps reducer', () => { smartTransactions: { expectedDeadline: 45, maxDeadline: 150, - returnTxHashAsap: false, + mobileReturnTxHashAsap: false, }, }, }, diff --git a/app/selectors/smartTransactionsController.test.ts b/app/selectors/smartTransactionsController.test.ts index a3a5fdabee5..12363ad1a0e 100644 --- a/app/selectors/smartTransactionsController.test.ts +++ b/app/selectors/smartTransactionsController.test.ts @@ -37,7 +37,7 @@ const getDefaultState = () => { smartTransactions: { expectedDeadline: 45, maxDeadline: 160, - returnTxHashAsap: false, + mobileReturnTxHashAsap: false, }, }, }, diff --git a/app/util/smart-transactions/smart-publish-hook.test.ts b/app/util/smart-transactions/smart-publish-hook.test.ts index 481932af255..0a902572214 100644 --- a/app/util/smart-transactions/smart-publish-hook.test.ts +++ b/app/util/smart-transactions/smart-publish-hook.test.ts @@ -200,7 +200,7 @@ function withRequest( smartTransactions: { expectedDeadline: 45, maxDeadline: 150, - returnTxHashAsap: false, + mobileReturnTxHashAsap: false, }, mobile_active: true, extension_active: true, @@ -231,7 +231,7 @@ describe('submitSmartTransactionHook', () => { it('returns a txHash asap if the feature flag requires it', async () => { withRequest(async ({ request }) => { - request.featureFlags.smartTransactions.returnTxHashAsap = true; + request.featureFlags.smartTransactions.mobileReturnTxHashAsap = true; const result = await submitSmartTransactionHook(request); expect(result).toEqual({ transactionHash }); }); diff --git a/app/util/smart-transactions/smart-publish-hook.ts b/app/util/smart-transactions/smart-publish-hook.ts index 8562b5d07f9..5f9c4c9d489 100644 --- a/app/util/smart-transactions/smart-publish-hook.ts +++ b/app/util/smart-transactions/smart-publish-hook.ts @@ -52,7 +52,7 @@ export interface SubmitSmartTransactionRequest { | { expectedDeadline: number; maxDeadline: number; - returnTxHashAsap: boolean; + mobileReturnTxHashAsap: boolean; } | Record; }; @@ -74,7 +74,7 @@ class SmartTransactionHook { smartTransactions: { expectedDeadline?: number; maxDeadline?: number; - returnTxHashAsap?: boolean; + mobileReturnTxHashAsap?: boolean; }; }; #shouldUseSmartTransaction: boolean; @@ -262,10 +262,10 @@ class SmartTransactionHook { uuid: string, ) => { let transactionHash: string | undefined | null; - const returnTxHashAsap = - this.#featureFlags?.smartTransactions?.returnTxHashAsap; + const mobileReturnTxHashAsap = + this.#featureFlags?.smartTransactions?.mobileReturnTxHashAsap; - if (returnTxHashAsap && submitTransactionResponse?.txHash) { + if (mobileReturnTxHashAsap && submitTransactionResponse?.txHash) { transactionHash = submitTransactionResponse.txHash; } else { transactionHash = await this.#waitForTransactionHash({ From b0a3490919be6958c70b96044839923bdc620697 Mon Sep 17 00:00:00 2001 From: dan437 <80175477+dan437@users.noreply.github.com> Date: Wed, 13 Nov 2024 13:52:56 +0100 Subject: [PATCH 2/3] Merge shared smartTransactions feature flags with network specific ones --- app/reducers/swaps/index.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/reducers/swaps/index.js b/app/reducers/swaps/index.js index d4d3bd26f31..8b852f53da3 100644 --- a/app/reducers/swaps/index.js +++ b/app/reducers/swaps/index.js @@ -89,7 +89,15 @@ export const swapsSmartTxFlagEnabled = createSelector( export const selectSwapsChainFeatureFlags = createSelector( swapsStateSelector, chainIdSelector, - (swapsState, chainId) => swapsState[chainId].featureFlags, + (swapsState, chainId) => { + return { + ...swapsState[chainId].featureFlags, + smartTransactions: { + ...swapsState[chainId].featureFlags.smartTransactions, + ...swapsState.featureFlags.smartTransactions, + }, + }; + }, ); /** From 83079b5608ff0ca85a1f87a5bb3088ac0a42dcd6 Mon Sep 17 00:00:00 2001 From: dan437 <80175477+dan437@users.noreply.github.com> Date: Thu, 14 Nov 2024 17:00:53 +0100 Subject: [PATCH 3/3] Linting Update a return value Update a test --- app/reducers/swaps/index.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/app/reducers/swaps/index.js b/app/reducers/swaps/index.js index 8b852f53da3..84674aee8ca 100644 --- a/app/reducers/swaps/index.js +++ b/app/reducers/swaps/index.js @@ -89,15 +89,13 @@ export const swapsSmartTxFlagEnabled = createSelector( export const selectSwapsChainFeatureFlags = createSelector( swapsStateSelector, chainIdSelector, - (swapsState, chainId) => { - return { - ...swapsState[chainId].featureFlags, - smartTransactions: { - ...swapsState[chainId].featureFlags.smartTransactions, - ...swapsState.featureFlags.smartTransactions, - }, - }; - }, + (swapsState, chainId) => ({ + ...swapsState[chainId].featureFlags, + smartTransactions: { + ...(swapsState[chainId].featureFlags?.smartTransactions || {}), + ...(swapsState.featureFlags?.smartTransactions || {}), + }, + }), ); /**