Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Update naming for returning a txHash asap for smart transactions #12274

Merged
merged 3 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion app/reducers/swaps/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,13 @@ export const swapsSmartTxFlagEnabled = createSelector(
export const selectSwapsChainFeatureFlags = createSelector(
swapsStateSelector,
chainIdSelector,
(swapsState, chainId) => swapsState[chainId].featureFlags,
(swapsState, chainId) => ({
...swapsState[chainId].featureFlags,
smartTransactions: {
...(swapsState[chainId].featureFlags?.smartTransactions || {}),
...(swapsState.featureFlags?.smartTransactions || {}),
},
}),
);

/**
Expand Down
12 changes: 6 additions & 6 deletions app/reducers/swaps/swaps.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const DEFAULT_FEATURE_FLAGS = {
smartTransactions: {
expectedDeadline: 45,
maxDeadline: 150,
returnTxHashAsap: false,
mobileReturnTxHashAsap: false,
},
},
bsc: {
Expand Down Expand Up @@ -90,7 +90,7 @@ describe('swaps reducer', () => {
smartTransactions: {
expectedDeadline: 45,
maxDeadline: 150,
returnTxHashAsap: false,
mobileReturnTxHashAsap: false,
},
};

Expand Down Expand Up @@ -122,7 +122,7 @@ describe('swaps reducer', () => {
smartTransactions: {
expectedDeadline: 45,
maxDeadline: 150,
returnTxHashAsap: false,
mobileReturnTxHashAsap: false,
},
};

Expand Down Expand Up @@ -154,7 +154,7 @@ describe('swaps reducer', () => {
smartTransactions: {
expectedDeadline: 45,
maxDeadline: 150,
returnTxHashAsap: false,
mobileReturnTxHashAsap: false,
},
};

Expand Down Expand Up @@ -226,7 +226,7 @@ describe('swaps reducer', () => {
smartTransactions: {
expectedDeadline: 45,
maxDeadline: 150,
returnTxHashAsap: false,
mobileReturnTxHashAsap: false,
},
},
},
Expand Down Expand Up @@ -281,7 +281,7 @@ describe('swaps reducer', () => {
smartTransactions: {
expectedDeadline: 45,
maxDeadline: 150,
returnTxHashAsap: false,
mobileReturnTxHashAsap: false,
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion app/selectors/smartTransactionsController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const getDefaultState = () => {
smartTransactions: {
expectedDeadline: 45,
maxDeadline: 160,
returnTxHashAsap: false,
mobileReturnTxHashAsap: false,
},
},
},
Expand Down
4 changes: 2 additions & 2 deletions app/util/smart-transactions/smart-publish-hook.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ function withRequest<ReturnValue>(
smartTransactions: {
expectedDeadline: 45,
maxDeadline: 150,
returnTxHashAsap: false,
mobileReturnTxHashAsap: false,
},
mobile_active: true,
extension_active: true,
Expand Down Expand Up @@ -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 });
});
Expand Down
10 changes: 5 additions & 5 deletions app/util/smart-transactions/smart-publish-hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export interface SubmitSmartTransactionRequest {
| {
expectedDeadline: number;
maxDeadline: number;
returnTxHashAsap: boolean;
mobileReturnTxHashAsap: boolean;
}
| Record<string, never>;
};
Expand All @@ -74,7 +74,7 @@ class SmartTransactionHook {
smartTransactions: {
expectedDeadline?: number;
maxDeadline?: number;
returnTxHashAsap?: boolean;
mobileReturnTxHashAsap?: boolean;
};
};
#shouldUseSmartTransaction: boolean;
Expand Down Expand Up @@ -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({
Expand Down
Loading