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

fix: Disable Smart Transactions for the new Send&Swap feature #25422

Merged
merged 2 commits into from
Jun 19, 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
7 changes: 7 additions & 0 deletions app/scripts/lib/transaction/smart-transactions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,13 @@ describe('submitSmartTransactionHook', () => {
expect(result).toEqual({ transactionHash: undefined });
});

it('falls back to regular transaction submit if the transaction type is "swapAndSend"', async () => {
const request: SubmitSmartTransactionRequestMocked = createRequest();
request.transactionMeta.type = TransactionType.swapAndSend;
const result = await submitSmartTransactionHook(request);
expect(result).toEqual({ transactionHash: undefined });
});

it('falls back to regular transaction submit if /getFees throws an error', async () => {
const request: SubmitSmartTransactionRequestMocked = createRequest();
jest
Expand Down
9 changes: 8 additions & 1 deletion app/scripts/lib/transaction/smart-transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
TransactionController,
TransactionMeta,
TransactionParams,
TransactionType,
} from '@metamask/transaction-controller';
import log from 'loglevel';
import {
Expand Down Expand Up @@ -120,9 +121,15 @@ class SmartTransactionHook {
}

async submit() {
const isUnsupportedTransactionTypeForSmartTransaction =
this.#transactionMeta?.type === TransactionType.swapAndSend;

// Will cause TransactionController to publish to the RPC provider as normal.
const useRegularTransactionSubmit = { transactionHash: undefined };
if (!this.#isSmartTransaction) {
if (
!this.#isSmartTransaction ||
isUnsupportedTransactionTypeForSmartTransaction
) {
return useRegularTransactionSubmit;
}
const { id: approvalFlowId } = await this.#controllerMessenger.call(
Expand Down