diff --git a/app/scripts/lib/transaction/smart-transactions.test.ts b/app/scripts/lib/transaction/smart-transactions.test.ts index 507ab83ecdf2..04c029c3ef8b 100644 --- a/app/scripts/lib/transaction/smart-transactions.test.ts +++ b/app/scripts/lib/transaction/smart-transactions.test.ts @@ -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 diff --git a/app/scripts/lib/transaction/smart-transactions.ts b/app/scripts/lib/transaction/smart-transactions.ts index 38f57f597947..97e37965d6ea 100644 --- a/app/scripts/lib/transaction/smart-transactions.ts +++ b/app/scripts/lib/transaction/smart-transactions.ts @@ -10,6 +10,7 @@ import { TransactionController, TransactionMeta, TransactionParams, + TransactionType, } from '@metamask/transaction-controller'; import log from 'loglevel'; import { @@ -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(