eth_sign support

This commit is contained in:
andrey 2021-03-25 10:48:11 +01:00 committed by Andrea Maria Piana
parent b29912f7f7
commit 7f839f952d
No known key found for this signature in database
GPG Key ID: AA6CCA6DE0E06424
5 changed files with 12 additions and 3 deletions

View File

@ -178,6 +178,7 @@
this._events[name].forEach(cb => cb(data));
}
EthereumProvider.prototype.enable = function () {
if (window.statusAppDebug) { console.log("enable"); }
return sendAPIrequest('web3');
};
@ -187,6 +188,7 @@
EthereumProvider.prototype.request = function (requestArguments)
{
if (window.statusAppDebug) { console.log("request: " + JSON.stringify(requestArguments)); }
if (!requestArguments) {
return new Error('Request is not valid.');
}
@ -232,12 +234,14 @@
// (DEPRECATED) Support for legacy send method
EthereumProvider.prototype.send = function (method, params = [])
{
if (window.statusAppDebug) { console.log("send (legacy): " + method);}
return this.request({method: method, params: params});
}
// (DEPRECATED) Support for legacy sendSync method
EthereumProvider.prototype.sendSync = function (payload)
{
if (window.statusAppDebug) { console.log("sendSync (legacy)" + JSON.stringify(payload));}
if (payload.method == "eth_uninstallFilter"){
this.sendAsync(payload, function (res, err) {})
}
@ -252,6 +256,7 @@
// (DEPRECATED) Support for legacy sendAsync method
EthereumProvider.prototype.sendAsync = function (payload, callback)
{
if (window.statusAppDebug) { console.log("sendAsync (legacy)" + JSON.stringify(payload));}
if (!payload) {
return new Error('Request is not valid.');
}

View File

@ -382,13 +382,13 @@
(defn web3-sign-message? [method]
(#{constants/web3-sign-typed-data constants/web3-sign-typed-data-v3 constants/web3-personal-sign
constants/web3-keycard-sign-typed-data} method))
constants/web3-eth-sign constants/web3-keycard-sign-typed-data} method))
(fx/defn web3-send-async
[cofx {:keys [method params id] :as payload} message-id]
(let [message? (web3-sign-message? method)
dapps-address (get-in cofx [:db :multiaccount :dapps-address])
typed? (not= constants/web3-personal-sign method)]
typed? (and (not= constants/web3-personal-sign method) (not= constants/web3-eth-sign method))]
(if (or message? (= constants/web3-send-transaction method))
(let [[address data] (cond (and (= method constants/web3-keycard-sign-typed-data)
(not (vector? params)))

View File

@ -74,6 +74,7 @@
(def ^:const web3-send-transaction "eth_sendTransaction")
(def ^:const web3-personal-sign "personal_sign")
(def ^:const web3-eth-sign "eth_sign")
(def ^:const web3-sign-typed-data "eth_signTypedData")
(def ^:const web3-sign-typed-data-v3 "eth_signTypedData_v3")

View File

@ -49,6 +49,7 @@
(def communities-management-enabled? (and (enabled? (get-config :COMMUNITIES_MANAGEMENT_ENABLED "0"))
communities-enabled?))
(def database-management-enabled? (enabled? (get-config :DATABASE_MANAGEMENT_ENABLED "0")))
(def debug-webview? (enabled? (get-config :DEBUG_WEBVIEW "0")))
;; CONFIG VALUES
(def log-level

View File

@ -1,7 +1,9 @@
(ns status-im.utils.js-resources
(:require-macros [status-im.utils.slurp :refer [slurp]]))
(:require-macros [status-im.utils.slurp :refer [slurp]])
(:require [status-im.utils.config :as config]))
(def provider-file (slurp "resources/js/provider.js"))
(defn ethereum-provider [network-id]
(str "window.statusAppNetworkId = \"" network-id "\";"
(when config/debug-webview? "window.statusAppDebug = true;")
provider-file))