add signTypedData_V4 to Keycard and update status-go

Signed-off-by: Michele Balistreri <michele@bitgamma.com>
This commit is contained in:
Michele Balistreri 2021-05-12 11:13:41 +03:00
parent 6c7d689a7c
commit 8cb0ad9285
No known key found for this signature in database
GPG Key ID: E9567DA33A4F791A
5 changed files with 43 additions and 6 deletions

View File

@ -918,6 +918,24 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
StatusThreadPoolExecutor.getInstance().execute(r); StatusThreadPoolExecutor.getInstance().execute(r);
} }
@ReactMethod
public void hashTypedDataV4(final String data, final Callback callback) {
Log.d(TAG, "hashTypedDataV4");
if (!checkAvailability()) {
callback.invoke(false);
return;
}
Runnable r = new Runnable() {
@Override
public void run() {
String res = Statusgo.hashTypedDataV4(data);
callback.invoke(res);
}
};
StatusThreadPoolExecutor.getInstance().execute(r);
}
@ReactMethod @ReactMethod
public void sendTransactionWithSignature(final String txArgsJSON, final String signature, final Callback callback) { public void sendTransactionWithSignature(final String txArgsJSON, final String signature, final Callback callback) {

View File

@ -321,6 +321,16 @@ RCT_EXPORT_METHOD(hashTypedData:(NSString *)data
callback(@[result]); callback(@[result]);
} }
//////////////////////////////////////////////////////////////////// hashTypedDataV4
RCT_EXPORT_METHOD(hashTypedDataV4:(NSString *)data
callback:(RCTResponseSenderBlock)callback) {
#if DEBUG
NSLog(@"hashTypedDataV4() method called");
#endif
NSString *result = StatusgoHashTypedDataV4(data);
callback(@[result]);
}
//////////////////////////////////////////////////////////////////// sendTransactionWithSignature //////////////////////////////////////////////////////////////////// sendTransactionWithSignature
RCT_EXPORT_METHOD(sendTransactionWithSignature:(NSString *)txArgsJSON RCT_EXPORT_METHOD(sendTransactionWithSignature:(NSString *)txArgsJSON
signature:(NSString *)signature signature:(NSString *)signature

View File

@ -229,6 +229,12 @@
(log/debug "[native-module] hash-typed-data") (log/debug "[native-module] hash-typed-data")
(.hashTypedData ^js (status) data callback)) (.hashTypedData ^js (status) data callback))
(defn hash-typed-data-v4
"used for keycard"
[data callback]
(log/debug "[native-module] hash-typed-data-v4")
(.hashTypedDataV4 ^js (status) data callback))
(defn send-transaction-with-signature (defn send-transaction-with-signature
"used for keycard" "used for keycard"
[rpcParams sig callback] [rpcParams sig callback]

View File

@ -18,8 +18,10 @@
(re-frame/reg-fx (re-frame/reg-fx
::hash-typed-data ::hash-typed-data
(fn [{:keys [data on-completed]}] (fn [{:keys [v4 data on-completed]}]
(status/hash-typed-data data on-completed))) (if v4
(status/hash-typed-data-v4 data on-completed)
(status/hash-typed-data data on-completed))))
(defn prepare-transaction (defn prepare-transaction
[{:keys [gas gasPrice data nonce tx-obj]}] [{:keys [gas gasPrice data nonce tx-obj]}]
@ -38,10 +40,11 @@
(assoc :nonce nonce)))) (assoc :nonce nonce))))
(fx/defn hash-message (fx/defn hash-message
[_ {:keys [data typed? on-completed]}] [_ {:keys [v4 data typed? on-completed]}]
(if typed? (if typed?
{::hash-typed-data {::hash-typed-data
{:data data {:data data
:v4 v4
:on-completed :on-completed
(or on-completed (or on-completed
#(re-frame/dispatch #(re-frame/dispatch

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.77.0", "version": "v0.77.1",
"commit-sha1": "6037570901233477cbef85d5494b257076a3acd9", "commit-sha1": "6a930ed0c601aca3dd13c9d4dedf3ea2d444848f",
"src-sha256": "1f5pr4w5a8lby2sqginddbjff2fp1d906nnr1y7zbsgafpi82j83" "src-sha256": "0jz4696xm99cy4dxi3dfd0b4rj5pqrsfj92zsfyxilgzjkwyzf78"
} }