mirror of
https://github.com/status-im/status-react.git
synced 2025-02-27 10:00:49 +00:00
bug #5356 - added snackbar for wallet errors, removed ATT from default tokens on ropsten
Signed-off-by: Goran Jovic <goranjovic@gmail.com>
This commit is contained in:
parent
8f13d97b43
commit
879e33b9b5
@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|||||||
- Added dismiss button to "Add to contacts" bar
|
- Added dismiss button to "Add to contacts" bar
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
- Partially fixed issue with 0 fiat in main Wallet screen. We are now explicitly showing an error when app can't fetch
|
||||||
|
asset prices, instead of silently failing.
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@
|
|||||||
(assoc default-wnodes-without-custom :custom (:testnet default-wnodes-without-custom)))
|
(assoc default-wnodes-without-custom :custom (:testnet default-wnodes-without-custom)))
|
||||||
|
|
||||||
(defn default-account-settings []
|
(defn default-account-settings []
|
||||||
{:wallet {:visible-tokens {:testnet #{:STT :ATT}
|
{:wallet {:visible-tokens {:testnet #{:STT :HND}
|
||||||
:mainnet #{:SNT}
|
:mainnet #{:SNT}
|
||||||
:rinkeby #{:MOKSHA}}}})
|
:rinkeby #{:MOKSHA}}}})
|
||||||
|
|
||||||
|
@ -5,7 +5,8 @@
|
|||||||
[status-im.data-store.realm.schemas.base.v4.core :as v4]
|
[status-im.data-store.realm.schemas.base.v4.core :as v4]
|
||||||
[status-im.data-store.realm.schemas.base.v5.core :as v5]
|
[status-im.data-store.realm.schemas.base.v5.core :as v5]
|
||||||
[status-im.data-store.realm.schemas.base.v6.core :as v6]
|
[status-im.data-store.realm.schemas.base.v6.core :as v6]
|
||||||
[status-im.data-store.realm.schemas.base.v7.core :as v7]))
|
[status-im.data-store.realm.schemas.base.v7.core :as v7]
|
||||||
|
[status-im.data-store.realm.schemas.base.v8.core :as v8]))
|
||||||
|
|
||||||
;; put schemas ordered by version
|
;; put schemas ordered by version
|
||||||
(def schemas [{:schema v1/schema
|
(def schemas [{:schema v1/schema
|
||||||
@ -28,4 +29,7 @@
|
|||||||
:migration v6/migration}
|
:migration v6/migration}
|
||||||
{:schema v7/schema
|
{:schema v7/schema
|
||||||
:schemaVersion 7
|
:schemaVersion 7
|
||||||
:migration v7/migration}])
|
:migration v7/migration}
|
||||||
|
{:schema v8/schema
|
||||||
|
:schemaVersion 8
|
||||||
|
:migration v8/migration}])
|
||||||
|
28
src/status_im/data_store/realm/schemas/base/v8/account.cljs
Normal file
28
src/status_im/data_store/realm/schemas/base/v8/account.cljs
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
(ns status-im.data-store.realm.schemas.base.v8.account
|
||||||
|
(:require [taoensso.timbre :as log]
|
||||||
|
[cognitect.transit :as transit]
|
||||||
|
[clojure.set :as set]
|
||||||
|
[status-im.data-store.realm.schemas.base.v4.account :as v7]))
|
||||||
|
|
||||||
|
(def schema v7/schema)
|
||||||
|
|
||||||
|
(def removed-tokens
|
||||||
|
#{:ATT})
|
||||||
|
|
||||||
|
(def reader (transit/reader :json))
|
||||||
|
(def writer (transit/writer :json))
|
||||||
|
|
||||||
|
(defn serialize [o] (transit/write writer o))
|
||||||
|
(defn deserialize [o] (try (transit/read reader o) (catch :default e nil)))
|
||||||
|
|
||||||
|
(defn migration [old-realm new-realm]
|
||||||
|
(log/debug "migrating accounts schema v8")
|
||||||
|
(let [accounts (.objects new-realm "account")]
|
||||||
|
(dotimes [i (.-length accounts)]
|
||||||
|
(let [account (aget accounts i)
|
||||||
|
old-settings (deserialize (aget account "settings"))
|
||||||
|
new-settings (-> old-settings
|
||||||
|
(update-in [:wallet :visible-tokens :testnet]
|
||||||
|
#(set/difference % removed-tokens)))
|
||||||
|
updated (serialize new-settings)]
|
||||||
|
(aset account "settings" updated)))))
|
13
src/status_im/data_store/realm/schemas/base/v8/core.cljs
Normal file
13
src/status_im/data_store/realm/schemas/base/v8/core.cljs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
(ns status-im.data-store.realm.schemas.base.v8.core
|
||||||
|
(:require [status-im.data-store.realm.schemas.base.v1.network :as network]
|
||||||
|
[status-im.data-store.realm.schemas.base.v4.bootnode :as bootnode]
|
||||||
|
[status-im.data-store.realm.schemas.base.v8.account :as account]
|
||||||
|
[taoensso.timbre :as log]))
|
||||||
|
|
||||||
|
(def schema [network/schema
|
||||||
|
bootnode/schema
|
||||||
|
account/schema])
|
||||||
|
|
||||||
|
(defn migration [old-realm new-realm]
|
||||||
|
(log/debug "migrating base database v8: " old-realm new-realm)
|
||||||
|
(account/migration old-realm new-realm))
|
@ -458,6 +458,10 @@
|
|||||||
:signing-phrase-description "Sign the transaction by entering your password. Make sure that the words above match your secret signing phrase"
|
:signing-phrase-description "Sign the transaction by entering your password. Make sure that the words above match your secret signing phrase"
|
||||||
:wallet-insufficient-funds "Insufficient funds"
|
:wallet-insufficient-funds "Insufficient funds"
|
||||||
:wallet-insufficient-gas "Not enough ETH for gas"
|
:wallet-insufficient-gas "Not enough ETH for gas"
|
||||||
|
:error-unable-to-get-prices "Currency conversion error. Try to refresh to update later"
|
||||||
|
:error-unable-to-get-balance "Unable to get balance"
|
||||||
|
:error-unable-to-get-token-balance "Unable to get token balance"
|
||||||
|
:error-unable-to-get-transactions "Unable to get transaction history"
|
||||||
:receive "Receive"
|
:receive "Receive"
|
||||||
:request-qr-legend "Share this code to receive assets"
|
:request-qr-legend "Share this code to receive assets"
|
||||||
:send-request "Send request"
|
:send-request "Send request"
|
||||||
|
@ -41,8 +41,7 @@
|
|||||||
(on-error "web3, contract or account-id not available")))
|
(on-error "web3, contract or account-id not available")))
|
||||||
|
|
||||||
(defn assoc-error-message [db error-type err]
|
(defn assoc-error-message [db error-type err]
|
||||||
(assoc-in db [:wallet :errors error-type] (or (when err (str err))
|
(assoc-in db [:wallet :errors error-type] (or err :unknown-error)))
|
||||||
:unknown-error)))
|
|
||||||
|
|
||||||
(defn clear-error-message [db error-type]
|
(defn clear-error-message [db error-type]
|
||||||
(update-in db [:wallet :errors] dissoc error-type))
|
(update-in db [:wallet :errors] dissoc error-type))
|
||||||
@ -189,7 +188,7 @@
|
|||||||
(fn [db [_ err]]
|
(fn [db [_ err]]
|
||||||
(log/debug "Unable to get transactions: " err)
|
(log/debug "Unable to get transactions: " err)
|
||||||
(-> db
|
(-> db
|
||||||
(assoc-error-message :transactions-update err)
|
(assoc-error-message :transactions-update :error-unable-to-get-transactions)
|
||||||
(assoc-in [:wallet :transactions-loading?] false))))
|
(assoc-in [:wallet :transactions-loading?] false))))
|
||||||
|
|
||||||
(handlers/register-handler-db
|
(handlers/register-handler-db
|
||||||
@ -204,7 +203,7 @@
|
|||||||
(fn [db [_ err]]
|
(fn [db [_ err]]
|
||||||
(log/debug "Unable to get balance: " err)
|
(log/debug "Unable to get balance: " err)
|
||||||
(-> db
|
(-> db
|
||||||
(assoc-error-message :balance-update err)
|
(assoc-error-message :balance-update :error-unable-to-get-balance)
|
||||||
(assoc-in [:wallet :balance-loading?] false))))
|
(assoc-in [:wallet :balance-loading?] false))))
|
||||||
|
|
||||||
(defn update-token-balance-success [symbol balance {:keys [db]}]
|
(defn update-token-balance-success [symbol balance {:keys [db]}]
|
||||||
@ -222,7 +221,7 @@
|
|||||||
(fn [db [_ symbol err]]
|
(fn [db [_ symbol err]]
|
||||||
(log/debug "Unable to get token " symbol "balance: " err)
|
(log/debug "Unable to get token " symbol "balance: " err)
|
||||||
(-> db
|
(-> db
|
||||||
(assoc-error-message :balance-update err)
|
(assoc-error-message :balance-update :error-unable-to-get-token-balance)
|
||||||
(assoc-in [:wallet :balance-loading?] false))))
|
(assoc-in [:wallet :balance-loading?] false))))
|
||||||
|
|
||||||
(handlers/register-handler-db
|
(handlers/register-handler-db
|
||||||
@ -237,7 +236,7 @@
|
|||||||
(fn [db [_ err]]
|
(fn [db [_ err]]
|
||||||
(log/debug "Unable to get prices: " err)
|
(log/debug "Unable to get prices: " err)
|
||||||
(-> db
|
(-> db
|
||||||
(assoc-error-message :prices-update err)
|
(assoc-error-message :prices-update :error-unable-to-get-prices)
|
||||||
(assoc :prices-loading? false))))
|
(assoc :prices-loading? false))))
|
||||||
|
|
||||||
(handlers/register-handler-fx
|
(handlers/register-handler-fx
|
||||||
@ -279,11 +278,6 @@
|
|||||||
(assoc-in db [:wallet :send-transaction :gas] (money/bignumber (int (* gas 1.2))))
|
(assoc-in db [:wallet :send-transaction :gas] (money/bignumber (int (* gas 1.2))))
|
||||||
db)))
|
db)))
|
||||||
|
|
||||||
(handlers/register-handler-fx
|
|
||||||
:wallet/show-error
|
|
||||||
(fn []
|
|
||||||
{:show-error (i18n/label :t/wallet-error)}))
|
|
||||||
|
|
||||||
(handlers/register-handler-fx
|
(handlers/register-handler-fx
|
||||||
:wallet-setup-navigate-back
|
:wallet-setup-navigate-back
|
||||||
(fn [{:keys [db]}]
|
(fn [{:keys [db]}]
|
||||||
|
@ -65,6 +65,15 @@
|
|||||||
:android {:letter-spacing 1.5}
|
:android {:letter-spacing 1.5}
|
||||||
:ios {:letter-spacing 1.16}})
|
:ios {:letter-spacing 1.16}})
|
||||||
|
|
||||||
|
(def snackbar-container
|
||||||
|
{:background-color colors/gray-notifications})
|
||||||
|
|
||||||
|
(def snackbar-text
|
||||||
|
{:color colors/white
|
||||||
|
:margin-horizontal 50
|
||||||
|
:margin-vertical 10
|
||||||
|
:text-align :center})
|
||||||
|
|
||||||
;; Actions section
|
;; Actions section
|
||||||
|
|
||||||
(def action-section
|
(def action-section
|
||||||
|
@ -18,7 +18,8 @@
|
|||||||
status-im.ui.screens.wallet.collectibles.cryptokitties.views
|
status-im.ui.screens.wallet.collectibles.cryptokitties.views
|
||||||
[status-im.ui.components.status-bar.view :as status-bar.view]
|
[status-im.ui.components.status-bar.view :as status-bar.view]
|
||||||
[status-im.ui.components.text :as text]
|
[status-im.ui.components.text :as text]
|
||||||
[status-im.ui.screens.wallet.transactions.views :as transactions.views]))
|
[status-im.ui.screens.wallet.transactions.views :as transactions.views]
|
||||||
|
[status-im.ui.components.colors :as colors]))
|
||||||
|
|
||||||
(defn toolbar-view []
|
(defn toolbar-view []
|
||||||
[toolbar/toolbar {:style wallet.styles/toolbar :flat? true}
|
[toolbar/toolbar {:style wallet.styles/toolbar :flat? true}
|
||||||
@ -147,12 +148,18 @@
|
|||||||
:data nfts
|
:data nfts
|
||||||
:render-fn #(render-collectible address-hex % modal?)}]}]]))
|
:render-fn #(render-collectible address-hex % modal?)}]}]]))
|
||||||
|
|
||||||
|
(defn snackbar [error-message]
|
||||||
|
[react/view styles/snackbar-container
|
||||||
|
[react/text {:style styles/snackbar-text}
|
||||||
|
(i18n/label error-message)]])
|
||||||
|
|
||||||
(views/defview wallet-root [modal?]
|
(views/defview wallet-root [modal?]
|
||||||
(views/letsubs [assets [:wallet/visible-assets-with-amount]
|
(views/letsubs [assets [:wallet/visible-assets-with-amount]
|
||||||
currency [:wallet/currency]
|
currency [:wallet/currency]
|
||||||
portfolio-value [:portfolio-value]
|
portfolio-value [:portfolio-value]
|
||||||
{:keys [modal-history?]} [:get :wallet]
|
{:keys [modal-history?]} [:get :wallet]
|
||||||
{:keys [seed-backed-up?]} [:get-current-account]
|
{:keys [seed-backed-up?]} [:get-current-account]
|
||||||
|
error-message [:wallet/error-message]
|
||||||
address-hex [:get-current-account-hex]]
|
address-hex [:get-current-account-hex]]
|
||||||
[react/view styles/main-section
|
[react/view styles/main-section
|
||||||
(if modal?
|
(if modal?
|
||||||
@ -166,7 +173,9 @@
|
|||||||
[react/refresh-control {:on-refresh #(re-frame/dispatch [:update-wallet])
|
[react/refresh-control {:on-refresh #(re-frame/dispatch [:update-wallet])
|
||||||
:tint-color :white
|
:tint-color :white
|
||||||
:refreshing false}])}
|
:refreshing false}])}
|
||||||
[total-section portfolio-value currency]
|
(if error-message
|
||||||
|
[snackbar error-message]
|
||||||
|
[total-section portfolio-value currency])
|
||||||
(when (and (not modal?)
|
(when (and (not modal?)
|
||||||
(not seed-backed-up?)
|
(not seed-backed-up?)
|
||||||
(some (fn [{:keys [amount]}]
|
(some (fn [{:keys [amount]}]
|
||||||
|
@ -80,7 +80,7 @@
|
|||||||
(fn [wallet]
|
(fn [wallet]
|
||||||
(:balance-loading? wallet)))
|
(:balance-loading? wallet)))
|
||||||
|
|
||||||
(re-frame/reg-sub :wallet/error-message?
|
(re-frame/reg-sub :wallet/error-message
|
||||||
:<- [:wallet]
|
:<- [:wallet]
|
||||||
(fn [wallet]
|
(fn [wallet]
|
||||||
(or (get-in wallet [:errors :balance-update])
|
(or (get-in wallet [:errors :balance-update])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user