Skip to content

Commit

Permalink
Disable Smart Transactions for the Send and Swap feature
Browse files Browse the repository at this point in the history
  • Loading branch information
dan437 committed Jun 19, 2024
1 parent f5a3437 commit 741ff57
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
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
10 changes: 9 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,16 @@ class SmartTransactionHook {
}

async submit() {
const isUnsupportedTransactionTypeForSmartTransaction =
this.#transactionMeta.type &&
[TransactionType.swapAndSend].includes(this.#transactionMeta.type);

// 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

0 comments on commit 741ff57

Please sign in to comment.