Merge pull request #389 from status-im/bug/transactions
Transactions screen bugs (#371 #372)
Former-commit-id: d16fcfa973
This commit is contained in:
commit
8a1584d42b
|
@ -14,5 +14,5 @@ android {
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile 'com.facebook.react:react-native:+'
|
compile 'com.facebook.react:react-native:+'
|
||||||
compile(group: 'status-im', name: 'status-go', version: '0.1.2', ext: 'aar')
|
compile(group: 'status-im', name: 'status-go', version: 'tx-complete-updates-3', ext: 'aar')
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
<artifactItem>
|
<artifactItem>
|
||||||
<groupId>status-im</groupId>
|
<groupId>status-im</groupId>
|
||||||
<artifactId>status-go-ios</artifactId>
|
<artifactId>status-go-ios</artifactId>
|
||||||
<version>0.1.2</version>
|
<version>tx-complete-updates-3</version>
|
||||||
<type>zip</type>
|
<type>zip</type>
|
||||||
<overWrite>true</overWrite>
|
<overWrite>true</overWrite>
|
||||||
<outputDirectory>./</outputDirectory>
|
<outputDirectory>./</outputDirectory>
|
||||||
|
|
|
@ -7,12 +7,10 @@
|
||||||
[org.clojure/clojurescript "1.9.229"]
|
[org.clojure/clojurescript "1.9.229"]
|
||||||
[reagent "0.5.1" :exclusions [cljsjs/react]]
|
[reagent "0.5.1" :exclusions [cljsjs/react]]
|
||||||
[re-frame "0.7.0"]
|
[re-frame "0.7.0"]
|
||||||
[prismatic/schema "1.0.4"]
|
|
||||||
[natal-shell "0.3.0"]
|
[natal-shell "0.3.0"]
|
||||||
[com.andrewmcveigh/cljs-time "0.4.0"]
|
[com.andrewmcveigh/cljs-time "0.4.0"]
|
||||||
[tailrecursion/cljs-priority-map "1.2.0"]
|
[tailrecursion/cljs-priority-map "1.2.0"]
|
||||||
[com.taoensso/timbre "4.7.4"]
|
[com.taoensso/timbre "4.7.4"]]
|
||||||
[org.clojure/test.check "0.9.0"]]
|
|
||||||
:plugins [[lein-cljsbuild "1.1.4"]
|
:plugins [[lein-cljsbuild "1.1.4"]
|
||||||
[lein-figwheel "0.5.0-2"]]
|
[lein-figwheel "0.5.0-2"]]
|
||||||
:clean-targets ["target/" "index.ios.js" "index.android.js"]
|
:clean-targets ["target/" "index.ios.js" "index.android.js"]
|
||||||
|
|
|
@ -1,12 +1,8 @@
|
||||||
(ns status-im.db
|
(ns status-im.db
|
||||||
(:require [schema.core :as s :include-macros true]
|
(:require [status-im.components.react :refer [animated]]
|
||||||
[status-im.components.react :refer [animated]]
|
|
||||||
[status-im.components.animation :as anim]
|
[status-im.components.animation :as anim]
|
||||||
[status-im.constants :refer [console-chat-id]]))
|
[status-im.constants :refer [console-chat-id]]))
|
||||||
|
|
||||||
;; schema of app-db
|
|
||||||
(def schema {:greeting s/Str})
|
|
||||||
|
|
||||||
;; initial state of app-db
|
;; initial state of app-db
|
||||||
(def app-db {:identity-password "replace-me-with-user-entered-password"
|
(def app-db {:identity-password "replace-me-with-user-entered-password"
|
||||||
:identity "me"
|
:identity "me"
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
(ns status-im.handlers
|
(ns status-im.handlers
|
||||||
(:require
|
(:require
|
||||||
[re-frame.core :refer [after dispatch dispatch-sync debug]]
|
[re-frame.core :refer [after dispatch dispatch-sync debug]]
|
||||||
[schema.core :as s :include-macros true]
|
[status-im.db :refer [app-db]]
|
||||||
[status-im.db :refer [app-db schema]]
|
|
||||||
[status-im.data-store.core :as data-store]
|
[status-im.data-store.core :as data-store]
|
||||||
[taoensso.timbre :as log]
|
[taoensso.timbre :as log]
|
||||||
[status-im.utils.crypt :refer [gen-random-bytes]]
|
[status-im.utils.crypt :refer [gen-random-bytes]]
|
||||||
|
@ -109,6 +108,7 @@
|
||||||
(let [{:keys [type event]} (t/json->clj event-str)]
|
(let [{:keys [type event]} (t/json->clj event-str)]
|
||||||
(case type
|
(case type
|
||||||
"transaction.queued" (dispatch [:transaction-queued event])
|
"transaction.queued" (dispatch [:transaction-queued event])
|
||||||
|
"transaction.failed" (dispatch [:transaction-failed event])
|
||||||
"node.started" (log/debug "Event *node.started* received")
|
"node.started" (log/debug "Event *node.started* received")
|
||||||
"module.initialized" (dispatch [:status-module-initialized!])
|
"module.initialized" (dispatch [:status-module-initialized!])
|
||||||
(log/debug "Event " type " not handled"))))))
|
(log/debug "Event " type " not handled"))))))
|
||||||
|
|
|
@ -23,7 +23,11 @@
|
||||||
|
|
||||||
(defmethod nav/preload-data! :confirm
|
(defmethod nav/preload-data! :confirm
|
||||||
[{:keys [transactions-queue] :as db} _]
|
[{:keys [transactions-queue] :as db} _]
|
||||||
(assoc db :transactions transactions-queue))
|
(-> db
|
||||||
|
(assoc :transactions transactions-queue
|
||||||
|
:wrong-password-counter 0
|
||||||
|
:wrong-password? false)
|
||||||
|
(assoc-in [:confirm-transactions :password] 0)))
|
||||||
|
|
||||||
(defn on-unlock
|
(defn on-unlock
|
||||||
[ids password previous-view-id]
|
[ids password previous-view-id]
|
||||||
|
@ -69,6 +73,9 @@
|
||||||
(update :transactions-queue #(apply dissoc % hashes)))))
|
(update :transactions-queue #(apply dissoc % hashes)))))
|
||||||
|
|
||||||
(register-handler ::remove-transaction
|
(register-handler ::remove-transaction
|
||||||
|
(after (fn [{:keys [transactions]}]
|
||||||
|
(when-not (seq transactions)
|
||||||
|
(dispatch [:navigate-back]))))
|
||||||
(fn [db [_ hash]]
|
(fn [db [_ hash]]
|
||||||
(-> db
|
(-> db
|
||||||
(update :transactions dissoc hash)
|
(update :transactions dissoc hash)
|
||||||
|
@ -122,19 +129,11 @@
|
||||||
|
|
||||||
(register-handler :transaction-completed
|
(register-handler :transaction-completed
|
||||||
(u/side-effect!
|
(u/side-effect!
|
||||||
(fn [{:keys [transactions command->chat]} [_ {:keys [id response previous-view-id]}]]
|
(fn [{:keys [transactions]} [_ {:keys [id response previous-view-id]}]]
|
||||||
(let [{:keys [hash error] :as parsed-response} (t/json->clj response)
|
(let [{:keys [hash error] :as parsed-response} (t/json->clj response)
|
||||||
{:keys [message-id]} (transactions id)]
|
{:keys [message-id]} (transactions id)]
|
||||||
(log/debug :parsed-response parsed-response)
|
(log/debug :parsed-response parsed-response)
|
||||||
(if (and error (string? error) (not (s/blank? error)))
|
(when-not (and error (string? error) (not (s/blank? error)))
|
||||||
;; todo: revisit this
|
|
||||||
;; currently transaction is removed after attempt
|
|
||||||
;; to complete it with wrong password
|
|
||||||
(do
|
|
||||||
(dispatch [::remove-transaction id])
|
|
||||||
(dispatch [:set :wrong-password? true])
|
|
||||||
(when-let [chat-id (get command->chat message-id)]
|
|
||||||
(dispatch [:clear-command chat-id message-id])))
|
|
||||||
(if message-id
|
(if message-id
|
||||||
(do (dispatch [::add-transactions-hash {:id id
|
(do (dispatch [::add-transactions-hash {:id id
|
||||||
:hash hash
|
:hash hash
|
||||||
|
@ -172,3 +171,27 @@
|
||||||
(when (and pending-message id hash)
|
(when (and pending-message id hash)
|
||||||
(dispatch [::send-pending-message message-id hash])
|
(dispatch [::send-pending-message message-id hash])
|
||||||
(dispatch [::remove-transaction id]))))))
|
(dispatch [::remove-transaction id]))))))
|
||||||
|
|
||||||
|
(def wrong-password-code "2")
|
||||||
|
|
||||||
|
(register-handler :transaction-failed
|
||||||
|
(u/side-effect!
|
||||||
|
(fn [_ [_ {:keys [id message_id error_code]}]]
|
||||||
|
(if-not (= wrong-password-code error_code)
|
||||||
|
(do (when message_id
|
||||||
|
(dispatch [::remove-pending-message message_id]))
|
||||||
|
(dispatch [::remove-transaction id]))
|
||||||
|
(dispatch [:set-wrong-password!])))))
|
||||||
|
|
||||||
|
(def attempts-limit 3)
|
||||||
|
|
||||||
|
(register-handler :set-wrong-password!
|
||||||
|
(after (fn [{:keys [wrong-password-counter]}]
|
||||||
|
(when (>= wrong-password-counter attempts-limit)
|
||||||
|
(dispatch [:set :wrong-password? false])
|
||||||
|
(dispatch [:set :wrong-password-counter 0])
|
||||||
|
(dispatch [:set-in [:confirm-transactions :password] ""]))))
|
||||||
|
(fn [db]
|
||||||
|
(-> db
|
||||||
|
(assoc :wrong-password? true)
|
||||||
|
(update :wrong-password-counter (fnil inc 0)))))
|
||||||
|
|
Loading…
Reference in New Issue