Skip to content

Commit bc015d7

Browse files
flexsurferqfrank
authored andcommitted
[status-im#12920] Unable to perform swap on 1inch.exchange if initial swap was cancelled by closing bottom sheet
Signed-off-by: andrey <[email protected]>
1 parent d41ee99 commit bc015d7

File tree

6 files changed

+57
-6
lines changed

6 files changed

+57
-6
lines changed

modules/react-native-status/android/src/main/java/im/status/ethereum/module/StatusModule.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,6 +1011,25 @@ public void run() {
10111011
StatusThreadPoolExecutor.getInstance().execute(r);
10121012
}
10131013

1014+
@ReactMethod
1015+
public void recover(final String rpcParams, final Callback callback) {
1016+
Log.d(TAG, "recover");
1017+
if (!checkAvailability()) {
1018+
callback.invoke(false);
1019+
return;
1020+
}
1021+
1022+
Runnable r = new Runnable() {
1023+
@Override
1024+
public void run() {
1025+
String res = Statusgo.recover(rpcParams);
1026+
callback.invoke(res);
1027+
}
1028+
};
1029+
1030+
StatusThreadPoolExecutor.getInstance().execute(r);
1031+
}
1032+
10141033
@ReactMethod
10151034
public void signTypedData(final String data, final String account, final String password, final Callback callback) {
10161035
Log.d(TAG, "signTypedData");

modules/react-native-status/ios/RCTStatus/RCTStatus.m

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,18 @@ - (void) migrateKeystore:(NSString *)accountData
662662
callback(@[result]);
663663
}
664664

665+
////////////////////////////////////////////////////////////////////
666+
#pragma mark - Recover
667+
//////////////////////////////////////////////////////////////////// recover
668+
RCT_EXPORT_METHOD(recover:(NSString *)message
669+
callback:(RCTResponseSenderBlock)callback) {
670+
#if DEBUG
671+
NSLog(@"Recover() method called");
672+
#endif
673+
NSString *result = StatusgoRecover(message);
674+
callback(@[result]);
675+
}
676+
665677
////////////////////////////////////////////////////////////////////
666678
#pragma mark - SignTypedData
667679
//////////////////////////////////////////////////////////////////// signTypedData

resources/js/provider.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@
107107
}
108108
else
109109
{
110+
if (window.statusAppDebug) { console.log("resolve " + callback.method + " :" + JSON.stringify(data.result.result)); }
110111
callback.resolve(data.result.result);
111112
}
112113
}
@@ -239,6 +240,7 @@
239240

240241
return new Promise(function (resolve, reject) {
241242
callbacks[messageId] = {beta: true,
243+
method: method,
242244
resolve: resolve,
243245
reject: reject};
244246
});

src/status_im/browser/core.cljs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -418,12 +418,19 @@
418418
:result {:jsonrpc "2.0"
419419
:id (int id)
420420
:result (if (= method "eth_coinbase") dapps-address [dapps-address])}})
421-
{:browser/call-rpc [payload
422-
#(re-frame/dispatch [:browser.callback/call-rpc
423-
{:type constants/web3-send-async-callback
424-
:messageId message-id
425-
:error %1
426-
:result %2}])]}))))
421+
(if (= method "personal_ecRecover")
422+
{:signing.fx/recover-message {:params {:message (first params)
423+
:signature (second params)}
424+
:on-completed #(re-frame/dispatch [:browser.callback/call-rpc
425+
{:type constants/web3-send-async-callback
426+
:messageId message-id
427+
:result (types/json->clj %)}])}}
428+
{:browser/call-rpc [payload
429+
#(re-frame/dispatch [:browser.callback/call-rpc
430+
{:type constants/web3-send-async-callback
431+
:messageId message-id
432+
:error %1
433+
:result %2}])]})))))
427434

428435
(fx/defn handle-no-permissions [cofx {:keys [method id]} message-id]
429436
(if (= method "eth_accounts")

src/status_im/native_module/core.cljs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,11 @@
253253
(log/debug "[native-module] sign-message")
254254
(.signMessage ^js (status) rpcParams callback))
255255

256+
(defn recover-message
257+
[rpcParams callback]
258+
(log/debug "[native-module] recover")
259+
(.recover ^js (status) rpcParams callback))
260+
256261
(defn send-transaction
257262
"NOTE: beware, the password has to be sha3 hashed"
258263
[rpcParams hashed-password callback]

src/status_im/signing/core.cljs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@
4747
(status/sign-message (types/clj->json params)
4848
on-completed)))
4949

50+
(re-frame/reg-fx
51+
:signing.fx/recover-message
52+
(fn [{:keys [params on-completed]}]
53+
(status/recover-message (types/clj->json params)
54+
on-completed)))
55+
5056
(re-frame/reg-fx
5157
:signing.fx/sign-typed-data
5258
(fn [{:keys [v4 data account on-completed hashed-password]}]

0 commit comments

Comments
 (0)