Skip to content

Commit

Permalink
feat: fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
omridan159 committed Apr 11, 2024
1 parent c12215a commit 198815b
Show file tree
Hide file tree
Showing 3 changed files with 125 additions and 179 deletions.
60 changes: 6 additions & 54 deletions app/core/SDKConnect/AndroidSDK/AndroidService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { EventEmitter2 } from 'eventemitter2';
import { NativeModules } from 'react-native';
import Engine from '../../Engine';
import { Minimizer } from '../../NativeModules';
import getRpcMethodMiddleware from '../../RPCMethods/RPCMethodMiddleware';
import { RPCQueueManager } from '../RPCQueueManager';

import {
Expand Down Expand Up @@ -34,6 +33,7 @@ import {
METHODS_TO_DELAY,
RPC_METHODS,
} from '../SDKConnectConstants';
import getDefaultBridgeParams from './getDefaultBridgeParams';
import handleBatchRpcResponse from '../handlers/handleBatchRpcResponse';
import handleCustomRpcCalls from '../handlers/handleCustomRpcCalls';
import DevLogger from '../utils/DevLogger';
Expand Down Expand Up @@ -350,13 +350,15 @@ export default class AndroidService extends EventEmitter2 {
PreferencesController: PreferencesController;
}
).PreferencesController;

const selectedAddress = preferencesController.state.selectedAddress;

const networkController = (
Engine.context as {
NetworkController: NetworkController;
}
).NetworkController;

const chainId = networkController.state.providerConfig.chainId;

this.currentClientId = sessionId;
Expand Down Expand Up @@ -426,66 +428,16 @@ export default class AndroidService extends EventEmitter2 {
return;
}

const defaultBridgeParams = getDefaultBridgeParams(clientInfo);

const bridge = new BackgroundBridge({
webview: null,
channelId: clientInfo.clientId,
isMMSDK: true,
url: PROTOCOLS.METAMASK + '://' + AppConstants.MM_SDK.SDK_REMOTE_ORIGIN,
isRemoteConn: true,
sendMessage: this.sendMessage.bind(this),
getApprovedHosts: (host: string) => ({
[host]: true,
}),
remoteConnHost:
clientInfo.originatorInfo.url ?? clientInfo.originatorInfo.title,
getRpcMethodMiddleware: ({
getProviderState,
}: {
hostname: string;
getProviderState: any;
}) =>
getRpcMethodMiddleware({
hostname:
clientInfo.originatorInfo.url ?? clientInfo.originatorInfo.title,
channelId: clientInfo.clientId,
getProviderState,
isMMSDK: true,
navigation: null, //props.navigation,
getApprovedHosts: (host: string) => ({
[host]: true,
}),
setApprovedHosts: () => true,
approveHost: () => ({}),
// Website info
url: {
current: clientInfo.originatorInfo?.url,
},
title: {
current: clientInfo.originatorInfo?.title,
},
icon: {
current: clientInfo.originatorInfo?.icon,
},
// Bookmarks
isHomepage: () => false,
// Show autocomplete
fromHomepage: { current: false },
// Wizard
wizardScrollAdjusted: { current: false },
tabId: '',
isWalletConnect: false,
analytics: {
isRemoteConn: true,
platform:
clientInfo.originatorInfo.platform ??
AppConstants.MM_SDK.UNKNOWN_PARAM,
},
toggleUrlModal: () => null,
injectHomePageScripts: () => null,
}),
isMainFrame: true,
isWalletConnect: false,
wcRequestActions: undefined,
...defaultBridgeParams,
});

this.bridgeByClientId[clientInfo.clientId] = bridge;
Expand Down
61 changes: 61 additions & 0 deletions app/core/SDKConnect/AndroidSDK/getDefaultBridgeParams.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import AppConstants from '../../AppConstants';
import getRpcMethodMiddleware from '../../RPCMethods/RPCMethodMiddleware';
import { DappClient } from './dapp-sdk-types';

const getDefaultBridgeParams = (clientInfo: DappClient) => ({
getApprovedHosts: (host: string) => ({
[host]: true,
}),
remoteConnHost:
clientInfo.originatorInfo.url ?? clientInfo.originatorInfo.title,
getRpcMethodMiddleware: ({
getProviderState,
}: {
hostname: string;
getProviderState: any;
}) =>
getRpcMethodMiddleware({
hostname:
clientInfo.originatorInfo.url ?? clientInfo.originatorInfo.title,
channelId: clientInfo.clientId,
getProviderState,
isMMSDK: true,
navigation: null, //props.navigation,
getApprovedHosts: (host: string) => ({
[host]: true,
}),
setApprovedHosts: () => true,
approveHost: () => ({}),
// Website info
url: {
current: clientInfo.originatorInfo?.url,
},
title: {
current: clientInfo.originatorInfo?.title,
},
icon: {
current: clientInfo.originatorInfo?.icon,
},
// Bookmarks
isHomepage: () => false,
// Show autocomplete
fromHomepage: { current: false },
// Wizard
wizardScrollAdjusted: { current: false },
tabId: '',
isWalletConnect: false,
analytics: {
isRemoteConn: true,
platform:
clientInfo.originatorInfo.platform ??
AppConstants.MM_SDK.UNKNOWN_PARAM,
},
toggleUrlModal: () => null,
injectHomePageScripts: () => null,
}),
isMainFrame: true,
isWalletConnect: false,
wcRequestActions: undefined,
});

export default getDefaultBridgeParams;
Loading

0 comments on commit 198815b

Please sign in to comment.