Skip to content

Commit

Permalink
Refactor eth_sendTransaction handler (#5619)
Browse files Browse the repository at this point in the history
The handler for `eth_sendTransaction` was previously spread between
`RPCMethodMiddleware.ts` and the static middleware of
`web3-provider-engine`. Instead it is all handled in
`RPCMethodMiddleware.ts` now.

This should have no functional impact. It is difficult to trace through
`web3-provider-engine`, but this case is one of the easier ones because
the static middleware is run first, and in this case it will always end
the request.

This relates to #5513
  • Loading branch information
Gudahtt authored Apr 5, 2023
1 parent 3b46059 commit 580c4d4
Show file tree
Hide file tree
Showing 5 changed files with 775 additions and 57 deletions.
22 changes: 0 additions & 22 deletions app/core/Engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import { PreferencesController } from '@metamask/preferences-controller';
import {
Transaction,
TransactionController,
WalletDevice,
} from '@metamask/transaction-controller';
import { GasFeeController } from '@metamask/gas-fee-controller';
import { ApprovalController } from '@metamask/approval-controller';
Expand Down Expand Up @@ -113,27 +112,6 @@ class Engine {

const networkController = new NetworkController(networkControllerOpts);
networkController.providerConfig = {
static: {
eth_sendTransaction: async (
payload: { params: any[]; origin: any },
_next: any,
end: (arg0: undefined, arg1: undefined) => void,
) => {
const { TransactionController } = this.context;
try {
const hash = await (
await TransactionController.addTransaction(
payload.params[0],
payload.origin,
WalletDevice.MM_MOBILE,
)
).result;
end(undefined, hash);
} catch (error) {
end(error);
}
},
},
getAccounts: (
end: (arg0: null, arg1: any[]) => void,
payload: { hostname: string | number },
Expand Down
Loading

0 comments on commit 580c4d4

Please sign in to comment.