diff --git a/lib/features/dapps/subfeatures/open_dapp/open_dapp_presenter.dart b/lib/features/dapps/subfeatures/open_dapp/open_dapp_presenter.dart index 2a170e75..f9c8d341 100644 --- a/lib/features/dapps/subfeatures/open_dapp/open_dapp_presenter.dart +++ b/lib/features/dapps/subfeatures/open_dapp/open_dapp_presenter.dart @@ -188,6 +188,19 @@ class OpenDAppPresenter extends CompletePresenter { _chainConfigurationUseCase.switchDefaultNetwork(toNetwork); _authUseCase.resetNetwork(toNetwork); notify(() => state.network = toNetwork); + // state.webviewController?.send("eth_chainId"); + var config = """{ + ethereum: { + chainId: ${toNetwork.chainId}, + rpcUrl: "${toNetwork.web3RpcHttpUrl}", + address: "${state.account!.address}", + isDebug: true, + networkVersion: "${toNetwork.chainId}", + isMetaMask: true + } + }"""; + state.webviewController + ?.setConfig(config, "0x${toNetwork.chainId.toRadixString(16)}"); state.webviewController?.sendResult('null', id); } } diff --git a/packages/web3_provider/lib/js_bridge_callback_bean.dart b/packages/web3_provider/lib/js_bridge_callback_bean.dart index c213c364..eeac902f 100644 --- a/packages/web3_provider/lib/js_bridge_callback_bean.dart +++ b/packages/web3_provider/lib/js_bridge_callback_bean.dart @@ -38,4 +38,11 @@ extension Web3Result on InAppWebViewController { await evaluateJavascript(source: script); sendResults([address], id); } + + void setConfig(String config, String chainId) async { + final script = "window.ethereum.setConfig($config);"; + final script2 = "window.ethereum.emitConnect($chainId);"; + await evaluateJavascript(source: script); + await evaluateJavascript(source: script2); + } }