File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed
src/background/connections/middlewares Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,8 @@ import {
1111 JsonRpcResponse ,
1212} from '../dAppConnection/models' ;
1313import { ModuleManager } from '@src/background/vmModules/ModuleManager' ;
14+ import { caipToChainId , chainIdToCaip } from '@src/utils/caipConversion' ;
15+ import { isBitcoinNetwork } from '@src/background/services/network/utils/isBitcoinNetwork' ;
1416
1517export function DAppRequestHandlerMiddleware (
1618 handlers : DAppRequestHandler [ ] ,
@@ -49,9 +51,18 @@ export function DAppRequestHandlerMiddleware(
4951 ? handler . handleAuthenticated ( params )
5052 : handler . handleUnauthenticated ( params ) ;
5153 } else {
52- const [ module ] = await resolve (
53- moduleManager . loadModule ( context . request . params . scope , method ) ,
54- ) ;
54+ const isBitcoin = context . network
55+ ? isBitcoinNetwork ( context . network )
56+ : false ;
57+ const scope = context . request . params . scope ;
58+ const chainId = isBitcoin
59+ ? scope . startsWith ( '0x' )
60+ ? Number ( scope ) . toString ( )
61+ : caipToChainId ( scope ) . toString ( )
62+ : scope ;
63+
64+ const [ module ] = await resolve ( moduleManager . loadModule ( chainId , method ) ) ;
65+
5566
5667 if ( ! context . network ) {
5768 promise = Promise . reject ( ethErrors . provider . disconnected ( ) ) ;
You can’t perform that action at this time.
0 commit comments