diff --git a/src/background/connections/middlewares/DAppRequestHandlerMiddleware.ts b/src/background/connections/middlewares/DAppRequestHandlerMiddleware.ts index 72abdf2c..bcfedda0 100644 --- a/src/background/connections/middlewares/DAppRequestHandlerMiddleware.ts +++ b/src/background/connections/middlewares/DAppRequestHandlerMiddleware.ts @@ -11,7 +11,6 @@ import { JsonRpcRequestParams, JsonRpcResponse, } from '../dAppConnection/models'; -import ModuleManager from '@src/background/vmModules/ModuleManager'; export function DAppRequestHandlerMiddleware( handlers: DAppRequestHandler[], @@ -28,15 +27,6 @@ export function DAppRequestHandlerMiddleware( const handler = handlerMap.get(context.request.params.request.method); // Call correct handler method based on authentication status let promise: Promise>; - - if (!context.domainMetadata) { - context.response = { - error: ethErrors.rpc.invalidRequest('Unknown request domain'), - }; - - return next(); - } - if (handler) { const params: JsonRpcRequestParams = { ...context.request.params, @@ -56,36 +46,13 @@ export function DAppRequestHandlerMiddleware( if (!activeNetwork) { promise = Promise.reject(ethErrors.provider.disconnected()); } else { - const module = await ModuleManager.loadModule( - context.request.params.scope, - context.request.params.request.method + promise = engine(activeNetwork).then((e) => + e.handle({ + ...context.request.params.request, + id: crypto.randomUUID(), + jsonrpc: '2.0', + }) ); - - if (module) { - promise = module.onRpcRequest( - { - chainId: activeNetwork.caipId, - dappInfo: { - icon: context.domainMetadata.icon ?? '', - name: context.domainMetadata.name ?? '', - url: context.domainMetadata.domain, - }, - requestId: context.request.id, - sessionId: context.request.params.sessionId, - method: context.request.params.request.method, - params: context.request.params.request.params, - }, - activeNetwork - ); - } else { - promise = engine(activeNetwork).then((e) => - e.handle({ - ...context.request.params.request, - id: crypto.randomUUID(), - jsonrpc: '2.0', - }) - ); - } } }