mirror of
https://github.com/status-im/status-mobile.git
synced 2025-02-03 04:14:02 +00:00
eth_sign support
This commit is contained in:
parent
b29912f7f7
commit
7f839f952d
@ -178,6 +178,7 @@
|
|||||||
this._events[name].forEach(cb => cb(data));
|
this._events[name].forEach(cb => cb(data));
|
||||||
}
|
}
|
||||||
EthereumProvider.prototype.enable = function () {
|
EthereumProvider.prototype.enable = function () {
|
||||||
|
if (window.statusAppDebug) { console.log("enable"); }
|
||||||
return sendAPIrequest('web3');
|
return sendAPIrequest('web3');
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -187,6 +188,7 @@
|
|||||||
|
|
||||||
EthereumProvider.prototype.request = function (requestArguments)
|
EthereumProvider.prototype.request = function (requestArguments)
|
||||||
{
|
{
|
||||||
|
if (window.statusAppDebug) { console.log("request: " + JSON.stringify(requestArguments)); }
|
||||||
if (!requestArguments) {
|
if (!requestArguments) {
|
||||||
return new Error('Request is not valid.');
|
return new Error('Request is not valid.');
|
||||||
}
|
}
|
||||||
@ -232,12 +234,14 @@
|
|||||||
// (DEPRECATED) Support for legacy send method
|
// (DEPRECATED) Support for legacy send method
|
||||||
EthereumProvider.prototype.send = function (method, params = [])
|
EthereumProvider.prototype.send = function (method, params = [])
|
||||||
{
|
{
|
||||||
|
if (window.statusAppDebug) { console.log("send (legacy): " + method);}
|
||||||
return this.request({method: method, params: params});
|
return this.request({method: method, params: params});
|
||||||
}
|
}
|
||||||
|
|
||||||
// (DEPRECATED) Support for legacy sendSync method
|
// (DEPRECATED) Support for legacy sendSync method
|
||||||
EthereumProvider.prototype.sendSync = function (payload)
|
EthereumProvider.prototype.sendSync = function (payload)
|
||||||
{
|
{
|
||||||
|
if (window.statusAppDebug) { console.log("sendSync (legacy)" + JSON.stringify(payload));}
|
||||||
if (payload.method == "eth_uninstallFilter"){
|
if (payload.method == "eth_uninstallFilter"){
|
||||||
this.sendAsync(payload, function (res, err) {})
|
this.sendAsync(payload, function (res, err) {})
|
||||||
}
|
}
|
||||||
@ -252,6 +256,7 @@
|
|||||||
// (DEPRECATED) Support for legacy sendAsync method
|
// (DEPRECATED) Support for legacy sendAsync method
|
||||||
EthereumProvider.prototype.sendAsync = function (payload, callback)
|
EthereumProvider.prototype.sendAsync = function (payload, callback)
|
||||||
{
|
{
|
||||||
|
if (window.statusAppDebug) { console.log("sendAsync (legacy)" + JSON.stringify(payload));}
|
||||||
if (!payload) {
|
if (!payload) {
|
||||||
return new Error('Request is not valid.');
|
return new Error('Request is not valid.');
|
||||||
}
|
}
|
||||||
|
@ -382,13 +382,13 @@
|
|||||||
|
|
||||||
(defn web3-sign-message? [method]
|
(defn web3-sign-message? [method]
|
||||||
(#{constants/web3-sign-typed-data constants/web3-sign-typed-data-v3 constants/web3-personal-sign
|
(#{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
|
(fx/defn web3-send-async
|
||||||
[cofx {:keys [method params id] :as payload} message-id]
|
[cofx {:keys [method params id] :as payload} message-id]
|
||||||
(let [message? (web3-sign-message? method)
|
(let [message? (web3-sign-message? method)
|
||||||
dapps-address (get-in cofx [:db :multiaccount :dapps-address])
|
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))
|
(if (or message? (= constants/web3-send-transaction method))
|
||||||
(let [[address data] (cond (and (= method constants/web3-keycard-sign-typed-data)
|
(let [[address data] (cond (and (= method constants/web3-keycard-sign-typed-data)
|
||||||
(not (vector? params)))
|
(not (vector? params)))
|
||||||
|
@ -74,6 +74,7 @@
|
|||||||
|
|
||||||
(def ^:const web3-send-transaction "eth_sendTransaction")
|
(def ^:const web3-send-transaction "eth_sendTransaction")
|
||||||
(def ^:const web3-personal-sign "personal_sign")
|
(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 "eth_signTypedData")
|
||||||
(def ^:const web3-sign-typed-data-v3 "eth_signTypedData_v3")
|
(def ^:const web3-sign-typed-data-v3 "eth_signTypedData_v3")
|
||||||
|
|
||||||
|
@ -49,6 +49,7 @@
|
|||||||
(def communities-management-enabled? (and (enabled? (get-config :COMMUNITIES_MANAGEMENT_ENABLED "0"))
|
(def communities-management-enabled? (and (enabled? (get-config :COMMUNITIES_MANAGEMENT_ENABLED "0"))
|
||||||
communities-enabled?))
|
communities-enabled?))
|
||||||
(def database-management-enabled? (enabled? (get-config :DATABASE_MANAGEMENT_ENABLED "0")))
|
(def database-management-enabled? (enabled? (get-config :DATABASE_MANAGEMENT_ENABLED "0")))
|
||||||
|
(def debug-webview? (enabled? (get-config :DEBUG_WEBVIEW "0")))
|
||||||
|
|
||||||
;; CONFIG VALUES
|
;; CONFIG VALUES
|
||||||
(def log-level
|
(def log-level
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
(ns status-im.utils.js-resources
|
(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"))
|
(def provider-file (slurp "resources/js/provider.js"))
|
||||||
(defn ethereum-provider [network-id]
|
(defn ethereum-provider [network-id]
|
||||||
(str "window.statusAppNetworkId = \"" network-id "\";"
|
(str "window.statusAppNetworkId = \"" network-id "\";"
|
||||||
|
(when config/debug-webview? "window.statusAppDebug = true;")
|
||||||
provider-file))
|
provider-file))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user