Skip to content

Commit

Permalink
fix recovery
Browse files Browse the repository at this point in the history
  • Loading branch information
yenda committed Aug 15, 2019
1 parent 4ad55a7 commit 6e1b731
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
10 changes: 7 additions & 3 deletions src/status_im/ethereum/transactions/core.cljs
Expand Up @@ -119,10 +119,14 @@
watched-transactions))))

(fx/defn add-transfer
"We determine a unique id for the transfer before adding it because some
transaction can contain multiple transfers and they would overwrite each other
in the transfer map if identified by hash"
[{:keys [db] :as cofx} {:keys [hash id] :as transfer} address]
(let [transfer-by-hash (get-in db [:wallet :accounts address :transactions hash])]
;;transfer-by-id (get-in db [:wallet :transaction id]) ;; TODO didn't found any usage of this
(when-let [unique-id (when (not= transfer transfer-by-hash) ;(or transfer-by-id)
(let [transfer-by-hash (get-in db [:wallet :accounts address :transactions hash])
transfer-by-id (get-in db [:wallet :transaction id])]
(when-let [unique-id (when-not (or transfer-by-id
(= transfer transfer-by-hash))
(if (and transfer-by-hash
(not (= :pending
(:type transfer-by-hash))))
Expand Down
16 changes: 9 additions & 7 deletions src/status_im/multiaccounts/login/core.cljs
Expand Up @@ -5,7 +5,6 @@
[status-im.chat.models :as chat-model]
[status-im.chat.models.loading :as chat.loading]
[status-im.contact.core :as contact]
[status-im.data-store.core :as data-store]
[status-im.ethereum.core :as ethereum]
[status-im.ethereum.json-rpc :as json-rpc]
[status-im.ethereum.transactions.core :as transactions]
Expand Down Expand Up @@ -166,14 +165,16 @@
(when save-password?
(save-user-password address password))
(navigation/navigate-to-cofx :home nil)
#_(notifications/process-stored-event address stored-pns)
(stickers/init-stickers-packs)
(chat.loading/initialize-chats {:to -1})
(contact/initialize-contacts)
(universal-links/process-stored-event)
(when platform/desktop?
(chat-model/update-dock-badge-label)))))

(defn- recovering-multiaccount? [cofx]
(boolean (get-in cofx [:db :multiaccounts/recover])))

(fx/defn create-only-events
[{:keys [db] :as cofx}]
(let [{:keys [multiaccount]} db]
Expand All @@ -200,18 +201,16 @@
(when-not platform/desktop?
(initialize-wallet)))))

(defn- recovering-multiaccount? [cofx]
(boolean (get-in cofx [:db :multiaccounts/recover])))

(defn- keycard-setup? [cofx]
(boolean (get-in cofx [:db :hardwallet :flow])))

(fx/defn multiaccount-login-success
[{:keys [db] :as cofx}]
(let [{:keys [address password save-password? name photo-path creating?]} (:multiaccounts/login db)
step (get-in db [:intro-wizard :step])
recovering? (recovering-multiaccount? cofx)
login-only? (not (or creating?
(recovering-multiaccount? cofx)
recovering?
(keycard-setup? cofx)))
nodes nil]
(fx/merge cofx
Expand All @@ -223,6 +222,7 @@
:pin
:multiaccount))
;;TODO remove once web3 has been replaced by json-rpc in protocol
;; after this call realm and the protocol are initialized as a callback
::web3/initialize [address password login-only?]
::json-rpc/call
[{:method "web3_clientVersion"
Expand All @@ -234,7 +234,9 @@
(initialize-multiaccount-db address)
(if login-only?
(login-only-events address password save-password?)
(create-only-events)))))
(create-only-events))
(when recovering?
(navigation/navigate-to-cofx :home nil)))))

(fx/defn open-keycard-login
[{:keys [db] :as cofx}]
Expand Down

0 comments on commit 6e1b731

Please sign in to comment.