diff --git a/modules/react-native-status/android/src/main/java/im/status/ethereum/module/StatusModule.java b/modules/react-native-status/android/src/main/java/im/status/ethereum/module/StatusModule.java index d83d75d19e..4baf281e1d 100644 --- a/modules/react-native-status/android/src/main/java/im/status/ethereum/module/StatusModule.java +++ b/modules/react-native-status/android/src/main/java/im/status/ethereum/module/StatusModule.java @@ -995,6 +995,25 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL 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 public void setAdjustResize() { Log.d(TAG, "setAdjustResize"); diff --git a/modules/react-native-status/ios/RCTStatus/RCTStatus.m b/modules/react-native-status/ios/RCTStatus/RCTStatus.m index ef8dbbb99e..72d425c69f 100644 --- a/modules/react-native-status/ios/RCTStatus/RCTStatus.m +++ b/modules/react-native-status/ios/RCTStatus/RCTStatus.m @@ -620,6 +620,20 @@ RCT_EXPORT_METHOD(signTypedData:(NSString *)data 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 //////////////////////////////////////////////////////////////////// signGroupMembership diff --git a/src/status_im/browser/core.cljs b/src/status_im/browser/core.cljs index c241ddbfef..81760338eb 100644 --- a/src/status_im/browser/core.cljs +++ b/src/status_im/browser/core.cljs @@ -381,7 +381,8 @@ {:browser/send-to-bridge message}) (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)) (fx/defn web3-send-async @@ -401,6 +402,7 @@ (if message? {:message {:address address :data data + :v4 (= constants/web3-sign-typed-data-v4 method) :typed? typed? :pinless? (= method constants/web3-keycard-sign-typed-data) :from dapps-address}} diff --git a/src/status_im/constants.cljs b/src/status_im/constants.cljs index 1c7cf74a2d..65bb127220 100644 --- a/src/status_im/constants.cljs +++ b/src/status_im/constants.cljs @@ -77,6 +77,7 @@ (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") +(def ^:const web3-sign-typed-data-v4 "eth_signTypedData_v4") (def ^:const web3-keycard-sign-typed-data "keycard_signTypedData") diff --git a/src/status_im/native_module/core.cljs b/src/status_im/native_module/core.cljs index 83e8890075..9106de603b 100644 --- a/src/status_im/native_module/core.cljs +++ b/src/status_im/native_module/core.cljs @@ -250,9 +250,15 @@ (defn sign-typed-data "NOTE: beware, the password has to be sha3 hashed" [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)) +(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] (log/debug "[native-module] send-logs") (.sendLogs ^js (status) dbJson js-logs callback)) diff --git a/src/status_im/signing/core.cljs b/src/status_im/signing/core.cljs index d84af45911..12eb13404c 100644 --- a/src/status_im/signing/core.cljs +++ b/src/status_im/signing/core.cljs @@ -48,8 +48,10 @@ (re-frame/reg-fx :signing.fx/sign-typed-data - (fn [{:keys [data account on-completed hashed-password]}] - (status/sign-typed-data data account hashed-password on-completed))) + (fn [{:keys [v4 data account on-completed hashed-password]}] + (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] (let [to (utils.hex/normalize-hex to)] @@ -68,7 +70,7 @@ (fx/defn sign-message [{{: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 from (or from (ethereum/default-address db)) hashed-password (ethereum/sha3 (security/safe-unmask-data password))] @@ -76,7 +78,8 @@ (merge {:db (update db :signing/sign assoc :error nil :in-progress? true)} (if typed? - {:signing.fx/sign-typed-data {:data data + {:signing.fx/sign-typed-data {:v4 v4 + :data data :account from :hashed-password hashed-password :on-completed #(re-frame/dispatch [:signing/sign-message-completed %])}} diff --git a/status-go-version.json b/status-go-version.json index 7afb0bb718..f86fdb454a 100644 --- a/status-go-version.json +++ b/status-go-version.json @@ -2,7 +2,7 @@ "_comment": "DO NOT EDIT THIS FILE BY HAND. USE 'scripts/update-status-go.sh ' instead", "owner": "status-im", "repo": "status-go", - "version": "v0.76.3", - "commit-sha1": "0e048081b0cb9f8324f4b64b1b042185a6798141", - "src-sha256": "1p0y8af3pzyab3f0qphyy1sm0x5m8c7kg05n0qrfpxsydy7sh1v4" + "version": "v0.76.4", + "commit-sha1": "ddc93981a7403bdc4ce205524789d5731cd58116", + "src-sha256": "0ijs1x20hkg7x2dnwjkbqn11pi7g1pm6bx3g62wwwfvk26qz4g6s" }