save account with accounts_saveAccounts rpc call

so that transaction history starts being fetch without having to relogin
This commit is contained in:
yenda 2019-08-24 03:32:13 +02:00
parent ddefae11b1
commit 84c04949aa
No known key found for this signature in database
GPG Key ID: 0095623C0069DCE6
2 changed files with 18 additions and 14 deletions

View File

@ -70,7 +70,8 @@
"settings_getConfig" {} "settings_getConfig" {}
"settings_getConfigs" {} "settings_getConfigs" {}
"settings_saveNodeConfig" {} "settings_saveNodeConfig" {}
"accounts_getAccounts" {}}) "accounts_getAccounts" {}
"accounts_saveAccounts" {}})
(defn call (defn call
[{:keys [method params on-success on-error] :as p}] [{:keys [method params on-success on-error] :as p}]

View File

@ -1,18 +1,17 @@
(ns status-im.wallet.accounts.core (ns status-im.wallet.accounts.core
(:require [re-frame.core :as re-frame] (:require [re-frame.core :as re-frame]
[status-im.ethereum.core :as ethereum]
[status-im.utils.fx :as fx]
[status-im.ethereum.eip55 :as eip55]
[status-im.ui.components.list-selection :as list-selection]
[status-im.utils.handlers :as handlers]
[status-im.native-module.core :as status]
[status-im.utils.types :as types]
[status-im.constants :as constants] [status-im.constants :as constants]
[status-im.ui.components.colors :as colors] [status-im.ethereum.eip55 :as eip55]
[status-im.ui.screens.navigation :as navigation] [status-im.ethereum.json-rpc :as json-rpc]
[status-im.i18n :as i18n]
[status-im.multiaccounts.update.core :as multiaccounts.update] [status-im.multiaccounts.update.core :as multiaccounts.update]
[status-im.wallet.core :as wallet] [status-im.native-module.core :as status]
[status-im.i18n :as i18n])) [status-im.ui.components.colors :as colors]
[status-im.ui.components.list-selection :as list-selection]
[status-im.ui.screens.navigation :as navigation]
[status-im.utils.fx :as fx]
[status-im.utils.types :as types]
[status-im.wallet.core :as wallet]))
(re-frame/reg-fx (re-frame/reg-fx
:list.selection/open-share :list.selection/open-share
@ -61,9 +60,13 @@
(fx/defn save-account (fx/defn save-account
{:events [:wallet.accounts/save-generated-account]} {:events [:wallet.accounts/save-generated-account]}
[{:keys [db] :as cofx}] [{:keys [db] :as cofx}]
(let [new-account (get-in db [:generate-account :account]) (let [{:keys [accounts latest-derived-path]} (:multiaccount db)
{:keys [accounts latest-derived-path]} (:multiaccount db)] new-account (assoc (get-in db [:generate-account :account])
:path (str constants/path-root "/" latest-derived-path))]
(fx/merge cofx (fx/merge cofx
{::json-rpc/call [{:method "accounts_saveAccounts"
:params [[new-account]]
:on-success #()}]}
(multiaccounts.update/multiaccount-update {:accounts (conj accounts new-account) (multiaccounts.update/multiaccount-update {:accounts (conj accounts new-account)
:latest-derived-path (inc latest-derived-path)} nil) :latest-derived-path (inc latest-derived-path)} nil)
(wallet/update-balances nil) (wallet/update-balances nil)