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 d83d75d19e4..4baf281e1de 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 @@ public void run() { 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 ef8dbbb99ef..72d425c69f7 100644 --- a/modules/react-native-status/ios/RCTStatus/RCTStatus.m +++ b/modules/react-native-status/ios/RCTStatus/RCTStatus.m @@ -620,6 +620,20 @@ - (void) migrateKeystore:(NSString *)accountData 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 e586b97933a..81760338ebc 100644 --- a/src/status_im/browser/core.cljs +++ b/src/status_im/browser/core.cljs @@ -402,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/native_module/core.cljs b/src/status_im/native_module/core.cljs index 83e88900756..9106de603b1 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 d84af459110..12eb13404c3 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 f81e1848613..142ccf1c49e 100644 --- a/status-go-version.json +++ b/status-go-version.json @@ -3,6 +3,6 @@ "owner": "status-im", "repo": "status-go", "version": "chore/sign-typed-data-v4", - "commit-sha1": "beef4a7a2b69da9595e1a95cc181944f8ee93f94", - "src-sha256": "1clacysxjw0pwcfr7kj9mv0l9y8911i1rkcnjx1n4dymq3vd2w3a" + "commit-sha1": "ee6659cce7103bd989a758f156c5a18502a1239c", + "src-sha256": "0jccqk0hv3zla3lsz5zckxv63i6h98armk8w861abrdkajv5hxhn" }