Skip to content

Commit

Permalink
persist new pairings
Browse files Browse the repository at this point in the history
  • Loading branch information
bitgamma committed Nov 12, 2021
1 parent 0554c0d commit 96c79d2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
17 changes: 15 additions & 2 deletions src/status_im/keycard/common.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
[status-im.utils.keychain.core :as keychain]
[status-im.utils.types :as types]
[taoensso.timbre :as log]
[status-im.utils.datetime :as utils.datetime]
[status-im.bottom-sheet.core :as bottom-sheet]
[status-im.utils.platform :as platform]
[status-im.popover.core :as popover]))
Expand Down Expand Up @@ -416,6 +417,16 @@

;; Get application info

(fx/defn update-pairings
[{:keys [db] :as cofx} instance-uid pairing]
(let [paired-on (utils.datetime/timestamp)
pairings (-> (get-in db [:keycard :pairings])
(assoc instance-uid {:pairing pairing :paired-on paired-on}))]
(fx/merge
cofx
{:keycard/persist-pairings pairings
:db (assoc-in db [:keycard :pairings] pairings)})))

(fx/defn get-application-info
{:events [:keycard/get-application-info]}
[{:keys [db]} on-card-read]
Expand All @@ -425,9 +436,8 @@
(fx/defn on-get-application-info-success
{:events [:keycard.callback/on-get-application-info-success]}
[{:keys [db] :as cofx} info on-success]
(let [{:keys [pin-retry-counter puk-retry-counter]} info
(let [{:keys [pin-retry-counter puk-retry-counter instance-uid new-pairing]} info
view-id (:view-id db)

{:keys [on-card-read]} (:keycard db)
on-success' (or on-success on-card-read)
enter-step (get-in db [:keycard :pin :enter-step])]
Expand All @@ -443,6 +453,8 @@
(assoc-in [:keycard :application-info :applet-installed?] true)
(assoc-in [:keycard :application-info-error] nil))}
(stash-on-card-read)
(when new-pairing
(update-pairings instance-uid new-pairing))
(when (and (zero? pin-retry-counter)
(pos? puk-retry-counter)
(not= enter-step :puk))
Expand All @@ -452,6 +464,7 @@
(blocked-keycard-popup cofx)
(when on-success'
(dispatch-event cofx on-success')))))))

(fx/defn on-get-application-info-error
{:events [:keycard.callback/on-get-application-info-error]}
[{:keys [db] :as cofx} error]
Expand Down
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6736,8 +6736,8 @@ react-native-splash-screen@^3.2.0:
integrity sha512-Ls9qiNZzW/OLFoI25wfjjAcrf2DZ975hn2vr6U9gyuxi2nooVbzQeFoQS5vQcbCt9QX5NY8ASEEAtlLdIa6KVg==

"react-native-status-keycard@git+https://github.com/status-im/react-native-status-keycard.git#default-pairing":
version "2.5.35"
resolved "git+https://github.com/status-im/react-native-status-keycard.git#d74b800bfaca8dea6e5c3d51957257f977cff774"
version "2.5.36"
resolved "git+https://github.com/status-im/react-native-status-keycard.git#a11a103620fcbad6f42c4650ccc719a4aea2b291"

react-native-svg@^9.8.4:
version "9.13.6"
Expand Down

0 comments on commit 96c79d2

Please sign in to comment.