diff --git a/AlphaWallet/Browser/Factory/WKWebViewConfiguration.swift b/AlphaWallet/Browser/Factory/WKWebViewConfiguration.swift index b45c6a312..4001be871 100644 --- a/AlphaWallet/Browser/Factory/WKWebViewConfiguration.swift +++ b/AlphaWallet/Browser/Factory/WKWebViewConfiguration.swift @@ -5,18 +5,18 @@ import WebKit import JavaScriptCore enum WebViewType { - case dappBrowser + case dappBrowser(RPCServer) case tokenScriptRenderer } extension WKWebViewConfiguration { - static func make(forType type: WebViewType, server: RPCServer, address: AlphaWallet.Address, in messageHandler: WKScriptMessageHandler) -> WKWebViewConfiguration { + static func make(forType type: WebViewType, address: AlphaWallet.Address, in messageHandler: WKScriptMessageHandler) -> WKWebViewConfiguration { let webViewConfig = WKWebViewConfiguration() var js = "" switch type { - case .dappBrowser: + case .dappBrowser(let server): guard let bundlePath = Bundle.main.path(forResource: "AlphaWalletWeb3Provider", ofType: "bundle"), let bundle = Bundle(path: bundlePath) else { return webViewConfig } @@ -28,7 +28,7 @@ extension WKWebViewConfiguration { } js += javaScriptForDappBrowser(server: server, address: address) case .tokenScriptRenderer: - js += javaScriptForTokenScriptRenderer(server: server, address: address) + js += javaScriptForTokenScriptRenderer(address: address) js += """ \n web3.tokens = { @@ -141,7 +141,7 @@ extension WKWebViewConfiguration { """ } - fileprivate static func javaScriptForTokenScriptRenderer(server: RPCServer, address: AlphaWallet.Address) -> String { + fileprivate static func javaScriptForTokenScriptRenderer(address: AlphaWallet.Address) -> String { return """ window.web3CallBacks = {} window.tokenScriptCallBacks = {} diff --git a/AlphaWallet/Browser/ViewControllers/BrowserViewController.swift b/AlphaWallet/Browser/ViewControllers/BrowserViewController.swift index b67bec46e..25fa8b981 100644 --- a/AlphaWallet/Browser/ViewControllers/BrowserViewController.swift +++ b/AlphaWallet/Browser/ViewControllers/BrowserViewController.swift @@ -62,7 +62,7 @@ final class BrowserViewController: UIViewController { }() lazy var config: WKWebViewConfiguration = { - let config = WKWebViewConfiguration.make(forType: .dappBrowser, server: server, address: account.address, in: ScriptMessageProxy(delegate: self)) + let config = WKWebViewConfiguration.make(forType: .dappBrowser(server), address: account.address, in: ScriptMessageProxy(delegate: self)) config.websiteDataStore = WKWebsiteDataStore.default() return config }() diff --git a/AlphaWallet/Tokens/Views/TokenInstanceWebView.swift b/AlphaWallet/Tokens/Views/TokenInstanceWebView.swift index 4c3e2c924..f9be88d68 100644 --- a/AlphaWallet/Tokens/Views/TokenInstanceWebView.swift +++ b/AlphaWallet/Tokens/Views/TokenInstanceWebView.swift @@ -53,7 +53,7 @@ class TokenInstanceWebView: UIView { private var hashOfLoadedHtml: Int? lazy private var heightConstraint = heightAnchor.constraint(equalToConstant: 100) lazy private var webView: WKWebView = { - let webViewConfig = WKWebViewConfiguration.make(forType: .tokenScriptRenderer, server: server, address: walletAddress, in: ScriptMessageProxy(delegate: self)) + let webViewConfig = WKWebViewConfiguration.make(forType: .tokenScriptRenderer, address: walletAddress, in: ScriptMessageProxy(delegate: self)) webViewConfig.websiteDataStore = .default() return .init(frame: .zero, configuration: webViewConfig) }()