Skip to content

Commit

Permalink
fix: (bitcoin module) Fix to gran bitcoin module properly
Browse files Browse the repository at this point in the history
  • Loading branch information
frichards committed Feb 26, 2025
1 parent a65794c commit dbd3436
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import {
JsonRpcResponse,
} from '../dAppConnection/models';
import { ModuleManager } from '@src/background/vmModules/ModuleManager';
import { caipToChainId, chainIdToCaip } from '@src/utils/caipConversion';

Check failure on line 14 in src/background/connections/middlewares/DAppRequestHandlerMiddleware.ts

View workflow job for this annotation

GitHub Actions / Lint and build

'chainIdToCaip' is defined but never used. Allowed unused vars must match /^_/u
import { isBitcoinNetwork } from '@src/background/services/network/utils/isBitcoinNetwork';

export function DAppRequestHandlerMiddleware(
handlers: DAppRequestHandler[],
Expand Down Expand Up @@ -49,9 +51,18 @@ export function DAppRequestHandlerMiddleware(
? handler.handleAuthenticated(params)
: handler.handleUnauthenticated(params);
} else {
const [module] = await resolve(
moduleManager.loadModule(context.request.params.scope, method),
);
const isBitcoin = context.network
? isBitcoinNetwork(context.network)
: false;
const scope = context.request.params.scope;
const chainId = isBitcoin
? scope.startsWith('0x')
? Number(scope).toString()
: caipToChainId(scope).toString()
: scope;

const [module] = await resolve(moduleManager.loadModule(chainId, method));


if (!context.network) {
promise = Promise.reject(ethErrors.provider.disconnected());
Expand Down

0 comments on commit dbd3436

Please sign in to comment.