2020-07-10 10:05:36 +00:00
|
|
|
(ns status-im.keycard.recovery
|
2020-04-29 13:11:24 +00:00
|
|
|
(:require [status-im.navigation :as navigation]
|
2020-02-25 08:52:40 +00:00
|
|
|
[status-im.utils.datetime :as utils.datetime]
|
|
|
|
[status-im.multiaccounts.create.core :as multiaccounts.create]
|
2021-05-17 08:10:08 +00:00
|
|
|
[status-im.multiaccounts.model :as multiaccounts.model]
|
2020-02-25 08:52:40 +00:00
|
|
|
[status-im.utils.fx :as fx]
|
|
|
|
[re-frame.core :as re-frame]
|
2021-07-13 13:41:45 +00:00
|
|
|
[clojure.string :as string]
|
2021-02-12 14:58:43 +00:00
|
|
|
[status-im.i18n.i18n :as i18n]
|
2020-02-25 08:52:40 +00:00
|
|
|
[taoensso.timbre :as log]
|
2020-07-10 10:05:36 +00:00
|
|
|
[status-im.keycard.common :as common]
|
|
|
|
status-im.keycard.fx
|
2020-02-25 08:52:40 +00:00
|
|
|
[status-im.constants :as constants]
|
|
|
|
[status-im.ethereum.eip55 :as eip55]
|
|
|
|
[status-im.ethereum.core :as ethereum]
|
2021-02-12 14:58:43 +00:00
|
|
|
[status-im.bottom-sheet.core :as bottom-sheet]
|
2021-07-13 13:41:45 +00:00
|
|
|
[status-im.native-module.core :as status]
|
|
|
|
[status-im.utils.types :as types]
|
|
|
|
[status-im.utils.security :as security]
|
|
|
|
[status-im.utils.keychain.core :as keychain]
|
2020-07-03 12:24:07 +00:00
|
|
|
[status-im.utils.platform :as platform]))
|
2020-02-25 08:52:40 +00:00
|
|
|
|
|
|
|
(fx/defn pair* [_ password]
|
2020-07-10 10:05:36 +00:00
|
|
|
{:keycard/pair {:password password}})
|
2020-02-25 08:52:40 +00:00
|
|
|
|
|
|
|
(fx/defn pair
|
2020-07-10 10:05:36 +00:00
|
|
|
{:events [:keycard/pair]}
|
2020-03-13 12:42:26 +00:00
|
|
|
[cofx]
|
2020-07-10 10:05:36 +00:00
|
|
|
(let [{:keys [password]} (get-in cofx [:db :keycard :secrets])]
|
2020-03-13 12:42:26 +00:00
|
|
|
(common/show-connection-sheet
|
|
|
|
cofx
|
2020-07-10 10:05:36 +00:00
|
|
|
{:on-card-connected :keycard/pair
|
2020-03-13 12:42:26 +00:00
|
|
|
:handler (pair* password)})))
|
2020-02-25 08:52:40 +00:00
|
|
|
|
|
|
|
(fx/defn pair-code-next-button-pressed
|
|
|
|
{:events [:keycard.onboarding.pair.ui/input-submitted
|
2020-07-10 10:05:36 +00:00
|
|
|
:keycard.ui/pair-code-next-button-pressed
|
2020-02-25 08:52:40 +00:00
|
|
|
:keycard.onboarding.pair.ui/next-pressed]}
|
|
|
|
[{:keys [db] :as cofx}]
|
2020-07-10 10:05:36 +00:00
|
|
|
(let [pairing (get-in db [:keycard :secrets :pairing])
|
|
|
|
paired-on (get-in db [:keycard :secrets :paired-on] (utils.datetime/timestamp))]
|
2020-02-25 08:52:40 +00:00
|
|
|
(fx/merge cofx
|
|
|
|
(if pairing
|
|
|
|
{:db (-> db
|
2020-07-10 10:05:36 +00:00
|
|
|
(assoc-in [:keycard :setup-step] :import-multiaccount)
|
|
|
|
(assoc-in [:keycard :secrets :paired-on] paired-on))}
|
2020-02-25 08:52:40 +00:00
|
|
|
(pair)))))
|
|
|
|
|
|
|
|
(fx/defn load-pair-screen
|
|
|
|
[{:keys [db] :as cofx}]
|
2020-07-10 10:05:36 +00:00
|
|
|
(log/debug "[keycard] load-pair-screen")
|
2020-02-25 08:52:40 +00:00
|
|
|
(fx/merge cofx
|
|
|
|
{:db (-> db
|
2020-07-10 10:05:36 +00:00
|
|
|
(assoc-in [:keycard :setup-step] :pair))
|
2020-05-19 10:40:39 +00:00
|
|
|
:dispatch [:bottom-sheet/hide]}
|
2020-02-25 08:52:40 +00:00
|
|
|
(common/listen-to-hardware-back-button)
|
|
|
|
(navigation/navigate-to-cofx :keycard-recovery-pair nil)))
|
|
|
|
|
|
|
|
(fx/defn keycard-storage-selected-for-recovery
|
|
|
|
{:events [:recovery.ui/keycard-storage-selected]}
|
|
|
|
[{:keys [db] :as cofx}]
|
|
|
|
(fx/merge cofx
|
2020-07-10 10:05:36 +00:00
|
|
|
{:db (assoc-in db [:keycard :flow] :recovery)}
|
2020-02-25 08:52:40 +00:00
|
|
|
(navigation/navigate-to-cofx :keycard-recovery-enter-mnemonic nil)))
|
|
|
|
|
|
|
|
(fx/defn start-import-flow
|
2020-02-25 09:22:33 +00:00
|
|
|
{:events [::recover-with-keycard-pressed]}
|
2020-02-25 08:52:40 +00:00
|
|
|
[{:keys [db] :as cofx}]
|
|
|
|
(fx/merge cofx
|
2021-03-04 09:43:53 +00:00
|
|
|
{:db
|
|
|
|
(-> db
|
|
|
|
(assoc-in [:keycard :flow] :import)
|
|
|
|
(assoc :recovered-account? true))
|
2020-07-10 10:05:36 +00:00
|
|
|
:keycard/check-nfc-enabled nil}
|
2020-02-25 08:52:40 +00:00
|
|
|
(bottom-sheet/hide-bottom-sheet)
|
|
|
|
(navigation/navigate-to-cofx :keycard-recovery-intro nil)))
|
|
|
|
|
|
|
|
(fx/defn access-key-pressed
|
|
|
|
{:events [:multiaccounts.recover.ui/recover-multiaccount-button-pressed]}
|
|
|
|
[_]
|
|
|
|
{:dispatch [:bottom-sheet/show-sheet :recover-sheet]})
|
|
|
|
|
|
|
|
(fx/defn recovery-keycard-selected
|
|
|
|
{:events [:recovery.ui/keycard-option-pressed]}
|
|
|
|
[{:keys [db] :as cofx}]
|
|
|
|
(fx/merge cofx
|
2020-07-10 10:05:36 +00:00
|
|
|
{:db (assoc-in db [:keycard :flow] :recovery)
|
|
|
|
:keycard/check-nfc-enabled nil}
|
2020-02-25 08:52:40 +00:00
|
|
|
(navigation/navigate-to-cofx :keycard-onboarding-intro nil)))
|
|
|
|
|
2021-06-28 12:54:28 +00:00
|
|
|
(fx/defn cancel-pressed
|
|
|
|
{:events [::cancel-pressed]}
|
|
|
|
[cofx]
|
2020-02-25 09:54:11 +00:00
|
|
|
(fx/merge cofx
|
|
|
|
(common/cancel-sheet-confirm)
|
|
|
|
(navigation/navigate-back)))
|
|
|
|
|
2020-02-25 08:52:40 +00:00
|
|
|
(fx/defn begin-setup-pressed
|
|
|
|
{:events [:keycard.recovery.intro.ui/begin-recovery-pressed]}
|
|
|
|
[{:keys [db] :as cofx}]
|
2020-03-13 12:42:26 +00:00
|
|
|
(fx/merge
|
|
|
|
cofx
|
|
|
|
{:db (-> db
|
2020-07-10 10:05:36 +00:00
|
|
|
(update :keycard
|
2020-03-13 12:42:26 +00:00
|
|
|
dissoc :secrets :card-state :multiaccount-wallet-address
|
|
|
|
:multiaccount-whisper-public-key
|
|
|
|
:application-info)
|
2020-07-10 10:05:36 +00:00
|
|
|
(assoc-in [:keycard :setup-step] :begin)
|
|
|
|
(assoc-in [:keycard :pin :on-verified] nil))}
|
2020-03-13 12:42:26 +00:00
|
|
|
(common/show-connection-sheet
|
2020-07-10 10:05:36 +00:00
|
|
|
{:on-card-connected :keycard/get-application-info
|
|
|
|
:on-card-read :keycard/check-card-state
|
2020-03-13 12:42:26 +00:00
|
|
|
:sheet-options {:on-cancel [::cancel-pressed]}
|
2021-03-10 12:42:50 +00:00
|
|
|
:handler (common/get-application-info :keycard/check-card-state)})))
|
2020-02-25 08:52:40 +00:00
|
|
|
|
|
|
|
(fx/defn recovery-success-finish-pressed
|
|
|
|
{:events [:keycard.recovery.success/finish-pressed]}
|
|
|
|
[{:keys [db] :as cofx}]
|
|
|
|
(fx/merge cofx
|
2020-07-10 10:05:36 +00:00
|
|
|
{:db (update db :keycard dissoc
|
2020-02-25 08:52:40 +00:00
|
|
|
:multiaccount-wallet-address
|
|
|
|
:multiaccount-whisper-public-key)}
|
2020-07-03 12:24:07 +00:00
|
|
|
(navigation/navigate-to-cofx (if platform/android?
|
|
|
|
:notifications-settings :welcome) nil)))
|
2020-02-25 08:52:40 +00:00
|
|
|
|
2021-05-24 14:25:05 +00:00
|
|
|
(fx/defn intro-wizard
|
|
|
|
{:events [:multiaccounts.create.ui/intro-wizard]}
|
|
|
|
[{:keys [db] :as cofx}]
|
|
|
|
(fx/merge cofx
|
|
|
|
{:db (-> db
|
|
|
|
(update :keycard dissoc :flow)
|
|
|
|
(dissoc :restored-account?))}
|
|
|
|
(multiaccounts.create/prepare-intro-wizard)
|
|
|
|
(navigation/navigate-to-cofx :get-your-keys nil)))
|
|
|
|
|
2020-02-25 08:52:40 +00:00
|
|
|
(fx/defn recovery-no-key
|
|
|
|
{:events [:keycard.recovery.no-key.ui/generate-key-pressed]}
|
|
|
|
[{:keys [db] :as cofx}]
|
|
|
|
(fx/merge cofx
|
2020-07-10 10:05:36 +00:00
|
|
|
{:db (assoc-in db [:keycard :flow] :create)
|
|
|
|
:keycard/check-nfc-enabled nil}
|
2021-05-24 14:25:05 +00:00
|
|
|
(intro-wizard)))
|
2020-02-25 08:52:40 +00:00
|
|
|
|
|
|
|
(fx/defn create-keycard-multiaccount
|
|
|
|
[{:keys [db] :as cofx}]
|
2020-07-10 10:05:36 +00:00
|
|
|
(let [{{:keys [multiaccount secrets flow]} :keycard} db
|
2020-02-25 08:52:40 +00:00
|
|
|
{:keys [address
|
|
|
|
name
|
2020-11-30 11:11:06 +00:00
|
|
|
identicon
|
2020-02-25 08:52:40 +00:00
|
|
|
public-key
|
|
|
|
whisper-public-key
|
|
|
|
wallet-public-key
|
|
|
|
wallet-root-public-key
|
|
|
|
whisper-address
|
|
|
|
wallet-address
|
|
|
|
wallet-root-address
|
|
|
|
whisper-private-key
|
|
|
|
encryption-public-key
|
|
|
|
instance-uid
|
2020-10-05 10:11:57 +00:00
|
|
|
key-uid
|
2020-11-30 11:11:06 +00:00
|
|
|
recovered]} multiaccount
|
|
|
|
{:keys [pairing paired-on]} secrets
|
|
|
|
{:keys [name identicon]}
|
2020-02-25 08:52:40 +00:00
|
|
|
(if (nil? name)
|
|
|
|
;; name might have been generated during recovery via passphrase
|
|
|
|
(get-in db [:intro-wizard :derived constants/path-whisper-keyword])
|
|
|
|
{:name name
|
2020-11-30 11:11:06 +00:00
|
|
|
:identicon identicon})]
|
2020-02-25 08:52:40 +00:00
|
|
|
;; if a name is still `nil` we have to generate it before multiaccount's
|
|
|
|
;; creation otherwise spec validation will fail
|
|
|
|
(if (nil? name)
|
2020-07-10 10:05:36 +00:00
|
|
|
{:keycard/generate-name-and-photo
|
2020-02-25 18:36:29 +00:00
|
|
|
{:public-key whisper-public-key
|
2020-02-25 09:22:33 +00:00
|
|
|
:on-success ::on-name-and-photo-generated}}
|
2020-02-25 08:52:40 +00:00
|
|
|
(fx/merge cofx
|
|
|
|
{:db (-> db
|
2020-07-10 10:05:36 +00:00
|
|
|
(assoc-in [:keycard :setup-step] nil)
|
2021-07-20 13:02:03 +00:00
|
|
|
(dissoc :intro-wizard))}
|
2020-02-25 08:52:40 +00:00
|
|
|
(multiaccounts.create/on-multiaccount-created
|
2020-10-05 10:11:57 +00:00
|
|
|
{:recovered (or recovered (get-in db [:intro-wizard :recovering?]))
|
|
|
|
:derived {constants/path-wallet-root-keyword
|
2020-02-25 08:52:40 +00:00
|
|
|
{:public-key wallet-root-public-key
|
|
|
|
:address (eip55/address->checksum wallet-root-address)}
|
|
|
|
constants/path-whisper-keyword
|
|
|
|
{:public-key whisper-public-key
|
|
|
|
:address (eip55/address->checksum whisper-address)
|
|
|
|
:name name
|
2020-11-30 11:11:06 +00:00
|
|
|
:identicon identicon}
|
2020-02-25 08:52:40 +00:00
|
|
|
constants/path-default-wallet-keyword
|
|
|
|
{:public-key wallet-public-key
|
|
|
|
:address (eip55/address->checksum wallet-address)}}
|
|
|
|
:address address
|
|
|
|
:public-key public-key
|
|
|
|
:keycard-instance-uid instance-uid
|
|
|
|
:key-uid (ethereum/normalized-hex key-uid)
|
|
|
|
:keycard-pairing pairing
|
|
|
|
:keycard-paired-on paired-on
|
|
|
|
:chat-key whisper-private-key}
|
|
|
|
encryption-public-key
|
2021-05-24 14:25:05 +00:00
|
|
|
{})))))
|
2020-02-25 08:52:40 +00:00
|
|
|
|
2021-05-17 08:10:08 +00:00
|
|
|
(fx/defn return-to-keycard-login
|
|
|
|
[{:keys [db] :as cofx}]
|
|
|
|
(fx/merge cofx
|
|
|
|
{:db (-> db
|
|
|
|
(update-in [:keycard :pin] assoc :enter-step :login
|
|
|
|
:status nil
|
|
|
|
:login [])
|
|
|
|
(update :keycard dissoc :application-info))}
|
2021-05-24 14:25:05 +00:00
|
|
|
(navigation/set-stack-root :multiaccounts-stack [:multiaccounts
|
|
|
|
:keycard-login-pin])))
|
2021-05-17 08:10:08 +00:00
|
|
|
|
2021-03-25 13:39:13 +00:00
|
|
|
(fx/defn on-backup-success
|
2021-05-20 08:13:04 +00:00
|
|
|
[{:keys [db] :as cofx} backup-type]
|
2021-03-25 13:39:13 +00:00
|
|
|
(fx/merge cofx
|
2021-05-20 08:13:04 +00:00
|
|
|
{:utils/show-popup {:title (i18n/label (if (= backup-type :recovery-card)
|
|
|
|
:t/keycard-access-reset :t/keycard-backup-success-title))
|
|
|
|
:content (i18n/label (if (= backup-type :recovery-card)
|
|
|
|
:t/keycard-can-use-with-new-passcode :t/keycard-backup-success-body))}}
|
2021-12-27 08:37:31 +00:00
|
|
|
(cond
|
|
|
|
(multiaccounts.model/logged-in? cofx)
|
2021-07-05 12:14:48 +00:00
|
|
|
(navigation/set-stack-root :profile-stack [:my-profile :keycard-settings])
|
2021-12-27 08:37:31 +00:00
|
|
|
|
|
|
|
(:multiaccounts/login db)
|
|
|
|
(return-to-keycard-login)
|
|
|
|
|
|
|
|
:else
|
|
|
|
(navigation/set-stack-root :onboarding [:get-your-keys]))))
|
2021-03-25 13:39:13 +00:00
|
|
|
|
2021-07-13 13:41:45 +00:00
|
|
|
(re-frame/reg-fx
|
|
|
|
::finish-migration
|
|
|
|
(fn [[account settings password encryption-pass login-params]]
|
|
|
|
(status/convert-to-keycard-account
|
|
|
|
account
|
|
|
|
settings
|
|
|
|
password
|
|
|
|
encryption-pass
|
|
|
|
#(let [{:keys [error]} (types/json->clj %)]
|
|
|
|
(if (string/blank? error)
|
|
|
|
(status/login-with-keycard login-params)
|
|
|
|
(throw (js/Error. "Please shake the phone to report this error and restart the app. Migration failed unexpectedly.")))))))
|
|
|
|
|
|
|
|
(fx/defn migrate-account
|
|
|
|
[{:keys [db] :as cofx}]
|
|
|
|
(let [pairing (get-in db [:keycard :secrets :pairing])
|
|
|
|
paired-on (get-in db [:keycard :secrets :paired-on])
|
|
|
|
instance-uid (get-in db [:keycard :multiaccount :instance-uid])
|
|
|
|
account (-> db
|
|
|
|
:multiaccounts/login
|
|
|
|
(assoc :keycard-pairing pairing)
|
|
|
|
(assoc :save-password? false))
|
|
|
|
key-uid (-> account :key-uid)
|
|
|
|
settings {:keycard-instance-uid instance-uid
|
|
|
|
:keycard-paired-on paired-on
|
|
|
|
:keycard-pairing pairing}
|
|
|
|
password (ethereum/sha3 (security/safe-unmask-data (get-in db [:keycard :migration-password])))
|
|
|
|
encryption-pass (get-in db [:keycard :multiaccount :encryption-public-key])
|
|
|
|
login-params {:key-uid key-uid
|
|
|
|
:multiaccount-data (types/clj->json account)
|
|
|
|
:password encryption-pass
|
|
|
|
:chat-key (get-in db [:keycard :multiaccount :whisper-private-key])}]
|
|
|
|
{:db (-> db
|
|
|
|
(assoc-in [:multiaccounts/multiaccounts key-uid :keycard-pairing] pairing)
|
|
|
|
(assoc :multiaccounts/login account)
|
|
|
|
(assoc :auth-method keychain/auth-method-none)
|
|
|
|
(update :keycard dissoc :flow :migration-password)
|
|
|
|
(dissoc :recovered-account?))
|
|
|
|
::finish-migration [account settings password encryption-pass login-params]}))
|
|
|
|
|
2020-02-25 08:52:40 +00:00
|
|
|
(fx/defn on-generate-and-load-key-success
|
2020-07-10 10:05:36 +00:00
|
|
|
{:events [:keycard.callback/on-generate-and-load-key-success]
|
2020-02-25 08:52:40 +00:00
|
|
|
:interceptors [(re-frame/inject-cofx :random-guid-generator)
|
|
|
|
(re-frame/inject-cofx ::multiaccounts.create/get-signing-phrase)]}
|
|
|
|
[{:keys [db random-guid-generator] :as cofx} data]
|
2021-03-25 13:39:13 +00:00
|
|
|
(let [account-data (js->clj data :keywordize-keys true)
|
2021-07-13 13:41:45 +00:00
|
|
|
backup? (get-in db [:keycard :creating-backup?])
|
|
|
|
migration? (get-in db [:keycard :converting-account?])]
|
2020-02-25 08:52:40 +00:00
|
|
|
(fx/merge cofx
|
|
|
|
{:db (-> db
|
2020-07-10 10:05:36 +00:00
|
|
|
(assoc-in [:keycard :multiaccount]
|
2020-02-25 08:52:40 +00:00
|
|
|
(-> account-data
|
|
|
|
(update :address ethereum/normalized-hex)
|
|
|
|
(update :whisper-address ethereum/normalized-hex)
|
|
|
|
(update :wallet-address ethereum/normalized-hex)
|
|
|
|
(update :wallet-root-address ethereum/normalized-hex)
|
|
|
|
(update :public-key ethereum/normalized-hex)
|
|
|
|
(update :whisper-public-key ethereum/normalized-hex)
|
|
|
|
(update :wallet-public-key ethereum/normalized-hex)
|
|
|
|
(update :wallet-root-public-key ethereum/normalized-hex)
|
2020-07-10 10:05:36 +00:00
|
|
|
(update :instance-uid #(get-in db [:keycard :multiaccount :instance-uid] %))))
|
|
|
|
(assoc-in [:keycard :multiaccount-wallet-address] (:wallet-address account-data))
|
|
|
|
(assoc-in [:keycard :multiaccount-whisper-public-key] (:whisper-public-key account-data))
|
2020-11-25 09:30:00 +00:00
|
|
|
(assoc-in [:keycard :pin :status] nil)
|
2020-07-10 10:05:36 +00:00
|
|
|
(assoc-in [:keycard :application-info :key-uid]
|
2020-04-10 09:06:51 +00:00
|
|
|
(ethereum/normalized-hex (:key-uid account-data)))
|
2021-07-13 13:41:45 +00:00
|
|
|
(update :keycard dissoc :recovery-phrase :creating-backup? :converting-account?)
|
|
|
|
(update-in [:keycard :secrets] dissoc :pin :puk :password :mnemonic)
|
|
|
|
(assoc :multiaccounts/new-installation-id (random-guid-generator)))}
|
2020-02-25 08:52:40 +00:00
|
|
|
(common/remove-listener-to-hardware-back-button)
|
2020-03-13 12:42:26 +00:00
|
|
|
(common/hide-connection-sheet)
|
2021-07-13 13:41:45 +00:00
|
|
|
(cond backup? (on-backup-success backup?)
|
|
|
|
migration? (migrate-account)
|
|
|
|
:else (create-keycard-multiaccount)))))
|
2020-02-25 08:52:40 +00:00
|
|
|
|
|
|
|
(fx/defn on-generate-and-load-key-error
|
2020-07-10 10:05:36 +00:00
|
|
|
{:events [:keycard.callback/on-generate-and-load-key-error]}
|
2020-02-25 08:52:40 +00:00
|
|
|
[{:keys [db] :as cofx} {:keys [error code]}]
|
2020-07-10 10:05:36 +00:00
|
|
|
(log/debug "[keycard] generate and load key error: " error)
|
2020-02-25 09:54:11 +00:00
|
|
|
(when-not (common/tag-lost? error)
|
|
|
|
(fx/merge cofx
|
2020-07-10 10:05:36 +00:00
|
|
|
{:db (assoc-in db [:keycard :setup-error] error)}
|
|
|
|
(common/set-on-card-connected :keycard/load-loading-keys-screen)
|
2020-02-25 09:54:11 +00:00
|
|
|
(common/process-error code error))))
|
2020-02-25 08:52:40 +00:00
|
|
|
|
|
|
|
(fx/defn import-multiaccount
|
2020-07-10 10:05:36 +00:00
|
|
|
{:events [:keycard/import-multiaccount]}
|
2020-02-25 08:52:40 +00:00
|
|
|
[{:keys [db] :as cofx}]
|
2020-07-10 10:05:36 +00:00
|
|
|
(let [{:keys [pairing]} (get-in db [:keycard :secrets])
|
|
|
|
instance-uid (get-in db [:keycard :application-info :instance-uid])
|
|
|
|
key-uid (get-in db [:keycard :application-info :key-uid])
|
2020-02-25 08:52:40 +00:00
|
|
|
pairing' (or pairing (common/get-pairing db key-uid))
|
2020-07-10 10:05:36 +00:00
|
|
|
pin (common/vector->string (get-in db [:keycard :pin :import-multiaccount]))]
|
2020-02-25 08:52:40 +00:00
|
|
|
(fx/merge cofx
|
|
|
|
{:db (-> db
|
2020-07-10 10:05:36 +00:00
|
|
|
(assoc-in [:keycard :multiaccount :instance-uid] instance-uid)
|
2020-11-25 09:30:00 +00:00
|
|
|
(assoc-in [:keycard :pin :status] :verifying)
|
2020-07-10 10:05:36 +00:00
|
|
|
(assoc-in [:keycard :secrets] {:pairing pairing'
|
|
|
|
:paired-on (utils.datetime/timestamp)}))
|
2021-03-10 12:42:50 +00:00
|
|
|
:keycard/import-keys {:pin pin
|
2021-02-19 10:01:16 +00:00
|
|
|
:on-success :keycard.callback/on-generate-and-load-key-success}})))
|
2020-02-25 08:52:40 +00:00
|
|
|
|
|
|
|
(fx/defn load-recovering-key-screen
|
2020-07-10 10:05:36 +00:00
|
|
|
{:events [:keycard/load-recovering-key-screen]}
|
2020-03-13 12:42:26 +00:00
|
|
|
[cofx]
|
|
|
|
(common/show-connection-sheet
|
|
|
|
cofx
|
2020-07-10 10:05:36 +00:00
|
|
|
{:on-card-connected :keycard/load-recovering-key-screen
|
|
|
|
:handler (common/dispatch-event :keycard/import-multiaccount)}))
|
2020-02-25 08:52:40 +00:00
|
|
|
|
|
|
|
(fx/defn on-name-and-photo-generated
|
2020-02-25 09:22:33 +00:00
|
|
|
{:events [::on-name-and-photo-generated]
|
2020-02-25 08:52:40 +00:00
|
|
|
:interceptors [(re-frame/inject-cofx :random-guid-generator)
|
|
|
|
(re-frame/inject-cofx ::multiaccounts.create/get-signing-phrase)]}
|
2020-11-30 11:11:06 +00:00
|
|
|
[{:keys [db] :as cofx} whisper-name identicon]
|
2020-02-25 08:52:40 +00:00
|
|
|
(fx/merge
|
|
|
|
cofx
|
2020-07-10 10:05:36 +00:00
|
|
|
{:db (update-in db [:keycard :multiaccount]
|
2020-02-25 08:52:40 +00:00
|
|
|
(fn [multiacc]
|
|
|
|
(assoc multiacc
|
2021-03-04 09:43:53 +00:00
|
|
|
:recovered (get db :recovered-account?)
|
2020-02-25 08:52:40 +00:00
|
|
|
:name whisper-name
|
2020-11-30 11:11:06 +00:00
|
|
|
:identicon identicon)))}
|
2020-02-25 08:52:40 +00:00
|
|
|
(create-keycard-multiaccount)))
|