Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
This commit is contained in:
andrey 2021-04-06 09:42:01 +02:00 committed by Andrea Maria Piana
parent 7f839f952d
commit adaf77ba1b
No known key found for this signature in database
GPG Key ID: AA6CCA6DE0E06424
7 changed files with 54 additions and 9 deletions

View File

@ -995,6 +995,25 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
StatusThreadPoolExecutor.getInstance().execute(r); StatusThreadPoolExecutor.getInstance().execute(r);
} }
@ReactMethod
public void signTypedDataV4(final String data, final String account, final String password, final Callback callback) {
Log.d(TAG, "signTypedDataV4");
if (!checkAvailability()) {
callback.invoke(false);
return;
}
Runnable r = new Runnable() {
@Override
public void run() {
String res = Statusgo.signTypedDataV4(data, account, password);
callback.invoke(res);
}
};
StatusThreadPoolExecutor.getInstance().execute(r);
}
@ReactMethod @ReactMethod
public void setAdjustResize() { public void setAdjustResize() {
Log.d(TAG, "setAdjustResize"); Log.d(TAG, "setAdjustResize");

View File

@ -620,6 +620,20 @@ RCT_EXPORT_METHOD(signTypedData:(NSString *)data
callback(@[result]); callback(@[result]);
} }
////////////////////////////////////////////////////////////////////
#pragma mark - SignTypedDataV4
//////////////////////////////////////////////////////////////////// signTypedDataV4
RCT_EXPORT_METHOD(signTypedDataV4:(NSString *)data
account:(NSString *)account
password:(NSString *)password
callback:(RCTResponseSenderBlock)callback) {
#if DEBUG
NSLog(@"SignTypedDataV4() method called");
#endif
NSString *result = StatusgoSignTypedDataV4(data, account, password);
callback(@[result]);
}
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
#pragma mark - SignGroupMembership #pragma mark - SignGroupMembership
//////////////////////////////////////////////////////////////////// signGroupMembership //////////////////////////////////////////////////////////////////// signGroupMembership

View File

@ -381,7 +381,8 @@
{:browser/send-to-bridge message}) {:browser/send-to-bridge message})
(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-sign-typed-data-v4
constants/web3-personal-sign
constants/web3-eth-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
@ -401,6 +402,7 @@
(if message? (if message?
{:message {:address address {:message {:address address
:data data :data data
:v4 (= constants/web3-sign-typed-data-v4 method)
:typed? typed? :typed? typed?
:pinless? (= method constants/web3-keycard-sign-typed-data) :pinless? (= method constants/web3-keycard-sign-typed-data)
:from dapps-address}} :from dapps-address}}

View File

@ -77,6 +77,7 @@
(def ^:const web3-eth-sign "eth_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")
(def ^:const web3-sign-typed-data-v4 "eth_signTypedData_v4")
(def ^:const web3-keycard-sign-typed-data "keycard_signTypedData") (def ^:const web3-keycard-sign-typed-data "keycard_signTypedData")

View File

@ -250,9 +250,15 @@
(defn sign-typed-data (defn sign-typed-data
"NOTE: beware, the password has to be sha3 hashed" "NOTE: beware, the password has to be sha3 hashed"
[data account hashed-password callback] [data account hashed-password callback]
(log/debug "[native-module] clear-web-data") (log/debug "[native-module] sign-typed-data")
(.signTypedData ^js (status) data account hashed-password callback)) (.signTypedData ^js (status) data account hashed-password callback))
(defn sign-typed-data-v4
"NOTE: beware, the password has to be sha3 hashed"
[data account hashed-password callback]
(log/debug "[native-module] sign-typed-data-v4")
(.signTypedDataV4 ^js (status) data account hashed-password callback))
(defn send-logs [dbJson js-logs callback] (defn send-logs [dbJson js-logs callback]
(log/debug "[native-module] send-logs") (log/debug "[native-module] send-logs")
(.sendLogs ^js (status) dbJson js-logs callback)) (.sendLogs ^js (status) dbJson js-logs callback))

View File

@ -48,8 +48,10 @@
(re-frame/reg-fx (re-frame/reg-fx
:signing.fx/sign-typed-data :signing.fx/sign-typed-data
(fn [{:keys [data account on-completed hashed-password]}] (fn [{:keys [v4 data account on-completed hashed-password]}]
(status/sign-typed-data data account hashed-password on-completed))) (if v4
(status/sign-typed-data-v4 data account hashed-password on-completed)
(status/sign-typed-data data account hashed-password on-completed))))
(defn get-contact [db to] (defn get-contact [db to]
(let [to (utils.hex/normalize-hex to)] (let [to (utils.hex/normalize-hex to)]
@ -68,7 +70,7 @@
(fx/defn sign-message (fx/defn sign-message
[{{:signing/keys [sign tx] :as db} :db}] [{{:signing/keys [sign tx] :as db} :db}]
(let [{{:keys [data typed? from]} :message} tx (let [{{:keys [data typed? from v4]} :message} tx
{:keys [in-progress? password]} sign {:keys [in-progress? password]} sign
from (or from (ethereum/default-address db)) from (or from (ethereum/default-address db))
hashed-password (ethereum/sha3 (security/safe-unmask-data password))] hashed-password (ethereum/sha3 (security/safe-unmask-data password))]
@ -76,7 +78,8 @@
(merge (merge
{:db (update db :signing/sign assoc :error nil :in-progress? true)} {:db (update db :signing/sign assoc :error nil :in-progress? true)}
(if typed? (if typed?
{:signing.fx/sign-typed-data {:data data {:signing.fx/sign-typed-data {:v4 v4
:data data
:account from :account from
:hashed-password hashed-password :hashed-password hashed-password
:on-completed #(re-frame/dispatch [:signing/sign-message-completed %])}} :on-completed #(re-frame/dispatch [:signing/sign-message-completed %])}}

View File

@ -2,7 +2,7 @@
"_comment": "DO NOT EDIT THIS FILE BY HAND. USE 'scripts/update-status-go.sh <tag>' instead", "_comment": "DO NOT EDIT THIS FILE BY HAND. USE 'scripts/update-status-go.sh <tag>' instead",
"owner": "status-im", "owner": "status-im",
"repo": "status-go", "repo": "status-go",
"version": "v0.76.3", "version": "v0.76.4",
"commit-sha1": "0e048081b0cb9f8324f4b64b1b042185a6798141", "commit-sha1": "ddc93981a7403bdc4ce205524789d5731cd58116",
"src-sha256": "1p0y8af3pzyab3f0qphyy1sm0x5m8c7kg05n0qrfpxsydy7sh1v4" "src-sha256": "0ijs1x20hkg7x2dnwjkbqn11pi7g1pm6bx3g62wwwfvk26qz4g6s"
} }