mirror of
https://github.com/status-im/status-react.git
synced 2025-02-20 06:39:22 +00:00
[#9025] fix keycard pairings persistence
Signed-off-by: Dmitry Novotochinov <dmitry.novot@gmail.com>
This commit is contained in:
parent
696df8ea2e
commit
c1c195adbe
@ -389,7 +389,7 @@
|
|||||||
[{:keys [db] :as cofx} flow instance-uid]
|
[{:keys [db] :as cofx} flow instance-uid]
|
||||||
(if (= flow :import)
|
(if (= flow :import)
|
||||||
(navigation/navigate-to-cofx cofx :keycard-recovery-no-key nil)
|
(navigation/navigate-to-cofx cofx :keycard-recovery-no-key nil)
|
||||||
(let [pairing-data (get-in db [:hardwallet :pairings (keyword instance-uid)])]
|
(let [pairing-data (get-in db [:hardwallet :pairings instance-uid])]
|
||||||
(if pairing-data
|
(if pairing-data
|
||||||
(fx/merge cofx
|
(fx/merge cofx
|
||||||
{:db (update-in db [:hardwallet :secrets] merge pairing-data)}
|
{:db (update-in db [:hardwallet :secrets] merge pairing-data)}
|
||||||
@ -1499,21 +1499,27 @@
|
|||||||
{:db (assoc-in db [:hardwallet :pairings] pairings)})
|
{:db (assoc-in db [:hardwallet :pairings] pairings)})
|
||||||
|
|
||||||
(fx/defn on-pair-success
|
(fx/defn on-pair-success
|
||||||
|
"When pairing to device has completed, we need to persist pairing data to
|
||||||
|
local storage. That's needed to ensure that during keycard setup
|
||||||
|
keycard won't run out of pairings slots, ie. we don't pair the same
|
||||||
|
card to the same device more than one time. Also, this allows the user to proceed
|
||||||
|
with setup and skip the pairing step if the pairing was already done during a previous
|
||||||
|
unfinished setup."
|
||||||
[{:keys [db] :as cofx} pairing]
|
[{:keys [db] :as cofx} pairing]
|
||||||
(let [setup-step (get-in db [:hardwallet :setup-step])
|
(let [setup-step (get-in db [:hardwallet :setup-step])
|
||||||
flow (get-in db [:hardwallet :flow])
|
flow (get-in db [:hardwallet :flow])
|
||||||
instance-uid (get-in db [:hardwallet :application-info :instance-uid])
|
instance-uid (get-in db [:hardwallet :application-info :instance-uid])
|
||||||
multiaccount (find-multiaccount-by-keycard-instance-uid db instance-uid)
|
multiaccount (find-multiaccount-by-keycard-instance-uid db instance-uid)
|
||||||
paired-on (utils.datetime/timestamp)
|
paired-on (utils.datetime/timestamp)
|
||||||
pairings (get-in db [:hardwallet :pairings])
|
pairings (assoc (get-in db [:hardwallet :pairings]) instance-uid {:pairing pairing
|
||||||
instance-uid (get-in db [:hardwallet :application-info :instance-uid])
|
:paired-on paired-on})
|
||||||
next-step (if (= setup-step :pair)
|
next-step (if (= setup-step :pair)
|
||||||
:begin
|
:begin
|
||||||
:card-ready)]
|
:card-ready)]
|
||||||
(fx/merge cofx
|
(fx/merge cofx
|
||||||
{:hardwallet/persist-pairings (assoc pairings instance-uid {:pairing pairing
|
{:hardwallet/persist-pairings pairings
|
||||||
:paired-on paired-on})
|
|
||||||
:db (-> db
|
:db (-> db
|
||||||
|
(assoc-in [:hardwallet :pairings] pairings)
|
||||||
(assoc-in [:hardwallet :application-info :paired?] true)
|
(assoc-in [:hardwallet :application-info :paired?] true)
|
||||||
(assoc-in [:hardwallet :on-card-connected] nil)
|
(assoc-in [:hardwallet :on-card-connected] nil)
|
||||||
(assoc-in [:hardwallet :setup-step] next-step)
|
(assoc-in [:hardwallet :setup-step] next-step)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user