switch to completeTransactions exposed method
This commit is contained in:
parent
8c262d0b07
commit
441ca66e96
|
@ -277,8 +277,8 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
|
|||
}
|
||||
|
||||
@ReactMethod
|
||||
public void completeTransaction(final String hash, final String password, final Callback callback) {
|
||||
Log.d(TAG, "completeTransaction");
|
||||
public void completeTransactions(final String hashes, final String password, final Callback callback) {
|
||||
Log.d(TAG, "completeTransactions");
|
||||
if (!checkAvailability()) {
|
||||
callback.invoke(false);
|
||||
return;
|
||||
|
@ -287,8 +287,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
|
|||
Thread thread = new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
String res = Statusgo.CompleteTransaction(hash, password);
|
||||
|
||||
String res = Statusgo.CompleteTransactions(hashes, password);
|
||||
callback.invoke(res);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -249,21 +249,21 @@ RCT_EXPORT_METHOD(login:(NSString *)address
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
#pragma mark - Complete Transaction
|
||||
//////////////////////////////////////////////////////////////////// completeTransaction
|
||||
RCT_EXPORT_METHOD(completeTransaction:(NSString *)hash
|
||||
#pragma mark - Complete Transactions
|
||||
//////////////////////////////////////////////////////////////////// completeTransactions
|
||||
RCT_EXPORT_METHOD(completeTransactions:(NSString *)hashes
|
||||
password:(NSString *)password
|
||||
callback:(RCTResponseSenderBlock)callback) {
|
||||
#if DEBUG
|
||||
NSLog(@"CompleteTransaction() method called");
|
||||
NSLog(@"CompleteTransactions() method called");
|
||||
#endif
|
||||
char * result = CompleteTransaction((char *) [hash UTF8String], (char *) [password UTF8String]);
|
||||
char * result = CompleteTransactions((char *) [hashes UTF8String], (char *) [password UTF8String]);
|
||||
callback(@[[NSString stringWithUTF8String: result]]);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
#pragma mark - Discard Transaction
|
||||
//////////////////////////////////////////////////////////////////// completeTransaction
|
||||
//////////////////////////////////////////////////////////////////// discardTransaction
|
||||
RCT_EXPORT_METHOD(discardTransaction:(NSString *)id) {
|
||||
#if DEBUG
|
||||
NSLog(@"DiscardTransaction() method called");
|
||||
|
|
|
@ -10,6 +10,9 @@
|
|||
[status-im.i18n :as i]
|
||||
[status-im.utils.platform :as p]))
|
||||
|
||||
(defn cljs->json [data]
|
||||
(.stringify js/JSON (clj->js data)))
|
||||
|
||||
;; if StatusModule is not initialized better to store
|
||||
;; calls and make them only when StatusModule is ready
|
||||
;; this flag helps to handle this
|
||||
|
@ -108,11 +111,11 @@
|
|||
(when status
|
||||
(call-module #(.login status address password on-result))))
|
||||
|
||||
(defn complete-transaction
|
||||
[hash password callback]
|
||||
(log/debug :complete-transaction (boolean status) hash password)
|
||||
(defn complete-transactions
|
||||
[hashes password callback]
|
||||
(log/debug :complete-transactions (boolean status) hashes password)
|
||||
(when status
|
||||
(call-module #(.completeTransaction status (str hash) password callback))))
|
||||
(call-module #(.completeTransactions status (cljs->json hashes) password callback))))
|
||||
|
||||
(defn discard-transaction
|
||||
[id]
|
||||
|
@ -124,9 +127,6 @@
|
|||
(when status
|
||||
(call-module #(.parseJail status chat-id file callback))))
|
||||
|
||||
(defn cljs->json [data]
|
||||
(.stringify js/JSON (clj->js data)))
|
||||
|
||||
(defn call-jail [chat-id path params callback]
|
||||
(when status
|
||||
(call-module
|
||||
|
|
|
@ -38,27 +38,22 @@
|
|||
:wrong-password? false)
|
||||
(assoc-in [:confirm-transactions :password] "")))
|
||||
|
||||
(defn on-unlock
|
||||
[ids password]
|
||||
(dispatch [:set :wrong-password? false])
|
||||
(doseq [id ids]
|
||||
(status/complete-transaction
|
||||
id
|
||||
password
|
||||
#(dispatch [:transaction-completed
|
||||
{:id id
|
||||
:response %}]))))
|
||||
(defn on-transactions-completed [raw-results]
|
||||
(let [results (:results (t/json->clj raw-results))]
|
||||
(doseq [result results]
|
||||
(dispatch [:transaction-completed {:id (name (key result)) :response (second result)}]))))
|
||||
|
||||
(register-handler :accept-transactions
|
||||
(u/side-effect!
|
||||
(fn [{:keys [transactions]} [_ password]]
|
||||
(let [ids (keys transactions)]
|
||||
(on-unlock ids password)))))
|
||||
(dispatch [:set :wrong-password? false])
|
||||
(status/complete-transactions (keys transactions) password on-transactions-completed))))
|
||||
|
||||
(register-handler :accept-transaction
|
||||
(u/side-effect!
|
||||
(fn [{:keys [transactions]} [_ password id]]
|
||||
(on-unlock (list id) password))))
|
||||
(fn [_ [_ password id]]
|
||||
(dispatch [:set :wrong-password? false])
|
||||
(status/complete-transactions (list id) password on-transactions-completed))))
|
||||
|
||||
(register-handler :deny-transactions
|
||||
(u/side-effect!
|
||||
|
@ -146,16 +141,15 @@
|
|||
(register-handler :transaction-completed
|
||||
(u/side-effect!
|
||||
(fn [{:keys [transactions modal]} [_ {:keys [id response]}]]
|
||||
(let [{:keys [hash error] :as parsed-response} (t/json->clj response)
|
||||
(let [{:keys [hash error]} response
|
||||
{:keys [message-id]} (transactions id)]
|
||||
(log/debug :parsed-response parsed-response)
|
||||
(log/debug :parsed-response response)
|
||||
(when-not (and error (string? error) (not (s/blank? error)))
|
||||
(if (and message-id (not (s/blank? message-id)))
|
||||
(do (dispatch [::add-transactions-hash {:id id
|
||||
:hash hash
|
||||
:message-id message-id}])
|
||||
(dispatch [::check-completed-transaction!
|
||||
{:message-id message-id}]))
|
||||
(dispatch [::check-completed-transaction! {:message-id message-id}]))
|
||||
(dispatch [::remove-transaction id]))
|
||||
(when (#{:unsigned-transactions :transaction-details} modal)
|
||||
(dispatch [:navigate-to-modal :confirmation-success])))))))
|
||||
|
|
Loading…
Reference in New Issue