* [#20720] feat: add ability to set currency from account Settings
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 4.1 KiB |
After Width: | Height: | Size: 6.1 KiB |
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 28 KiB |
|
@ -1,6 +1,7 @@
|
||||||
(ns legacy.status-im.data-store.settings
|
(ns legacy.status-im.data-store.settings
|
||||||
(:require
|
(:require
|
||||||
[clojure.set :as set]
|
[clojure.set :as set]
|
||||||
|
[clojure.string :as string]
|
||||||
[legacy.status-im.data-store.visibility-status-updates :as visibility-status-updates]
|
[legacy.status-im.data-store.visibility-status-updates :as visibility-status-updates]
|
||||||
[utils.ethereum.eip.eip55 :as eip55]))
|
[utils.ethereum.eip.eip55 :as eip55]))
|
||||||
|
|
||||||
|
@ -18,6 +19,13 @@
|
||||||
{}
|
{}
|
||||||
pinned-mailservers))
|
pinned-mailservers))
|
||||||
|
|
||||||
|
(defn rpc->currency
|
||||||
|
[currency]
|
||||||
|
(-> currency
|
||||||
|
(name)
|
||||||
|
(string/lower-case)
|
||||||
|
(keyword)))
|
||||||
|
|
||||||
(defn rpc->settings
|
(defn rpc->settings
|
||||||
[settings]
|
[settings]
|
||||||
(-> settings
|
(-> settings
|
||||||
|
@ -26,7 +34,7 @@
|
||||||
(update :wallet-legacy/visible-tokens rpc->visible-tokens)
|
(update :wallet-legacy/visible-tokens rpc->visible-tokens)
|
||||||
(update :pinned-mailservers rpc->pinned-mailservers)
|
(update :pinned-mailservers rpc->pinned-mailservers)
|
||||||
(update :link-previews-enabled-sites set)
|
(update :link-previews-enabled-sites set)
|
||||||
(update :currency keyword)
|
(update :currency rpc->currency)
|
||||||
(visibility-status-updates/<-rpc-settings)
|
(visibility-status-updates/<-rpc-settings)
|
||||||
(set/rename-keys {:compressedKey :compressed-key
|
(set/rename-keys {:compressedKey :compressed-key
|
||||||
:emojiHash :emoji-hash})))
|
:emojiHash :emoji-hash})))
|
||||||
|
@ -34,5 +42,5 @@
|
||||||
(defn rpc->setting-value
|
(defn rpc->setting-value
|
||||||
[{:keys [name] :as setting}]
|
[{:keys [name] :as setting}]
|
||||||
(condp = name
|
(condp = name
|
||||||
:currency (update setting :value keyword)
|
:currency (update setting :value rpc->currency)
|
||||||
setting))
|
setting))
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
(ns legacy.status-im.multiaccounts.update.core
|
(ns legacy.status-im.multiaccounts.update.core
|
||||||
(:require
|
(:require
|
||||||
|
[legacy.status-im.data-store.settings :as settings]
|
||||||
[legacy.status-im.utils.deprecated-types :as types]
|
[legacy.status-im.utils.deprecated-types :as types]
|
||||||
[status-im.constants :as constants]
|
[status-im.constants :as constants]
|
||||||
[taoensso.timbre :as log]
|
[taoensso.timbre :as log]
|
||||||
|
@ -81,7 +82,7 @@
|
||||||
[{:keys [db] :as cofx} setting setting-value]
|
[{:keys [db] :as cofx} setting setting-value]
|
||||||
(let [current-multiaccount (:profile/profile db)
|
(let [current-multiaccount (:profile/profile db)
|
||||||
setting-value (if (= :currency setting)
|
setting-value (if (= :currency setting)
|
||||||
(keyword setting-value)
|
(settings/rpc->currency setting-value)
|
||||||
setting-value)
|
setting-value)
|
||||||
db (case setting
|
db (case setting
|
||||||
:stickers/packs-pending
|
:stickers/packs-pending
|
||||||
|
@ -104,7 +105,9 @@
|
||||||
db)]
|
db)]
|
||||||
{:db (if setting-value
|
{:db (if setting-value
|
||||||
(assoc-in db [:profile/profile setting] setting-value)
|
(assoc-in db [:profile/profile setting] setting-value)
|
||||||
(update db :profile/profile dissoc setting))}))
|
(update db :profile/profile dissoc setting))
|
||||||
|
:fx [(when (= setting :currency)
|
||||||
|
[:dispatch [:wallet/get-wallet-token-for-all-accounts]])]}))
|
||||||
|
|
||||||
(rf/defn set-many-js
|
(rf/defn set-many-js
|
||||||
[cofx settings-js]
|
[cofx settings-js]
|
||||||
|
|
|
@ -1,84 +0,0 @@
|
||||||
(ns legacy.status-im.utils.currency
|
|
||||||
(:require
|
|
||||||
[utils.i18n :as i18n]))
|
|
||||||
|
|
||||||
(def currencies
|
|
||||||
{:aed {:id :aed :code "AED" :display-name (i18n/label :t/currency-display-name-aed) :symbol "د.إ"}
|
|
||||||
:afn {:id :afn :code "AFN" :display-name (i18n/label :t/currency-display-name-afn) :symbol "؋"}
|
|
||||||
:ars {:id :ars :code "ARS" :display-name (i18n/label :t/currency-display-name-ars) :symbol "$"}
|
|
||||||
:aud {:id :aud :code "AUD" :display-name (i18n/label :t/currency-display-name-aud) :symbol "$"}
|
|
||||||
:bbd {:id :bbd :code "BBD" :display-name (i18n/label :t/currency-display-name-bbd) :symbol "$"}
|
|
||||||
:bdt {:id :bdt :code "BDT" :display-name (i18n/label :t/currency-display-name-bdt) :symbol " Tk"}
|
|
||||||
:bgn {:id :bgn :code "BGN" :display-name (i18n/label :t/currency-display-name-bgn) :symbol "лв"}
|
|
||||||
:bhd {:id :bhd :code "BHD" :display-name (i18n/label :t/currency-display-name-bhd) :symbol "BD"}
|
|
||||||
:bnd {:id :bnd :code "BND" :display-name (i18n/label :t/currency-display-name-bnd) :symbol "$"}
|
|
||||||
:bob {:id :bob :code "BOB" :display-name (i18n/label :t/currency-display-name-bob) :symbol "$b"}
|
|
||||||
:brl {:id :brl :code "BRL" :display-name (i18n/label :t/currency-display-name-brl) :symbol "R$"}
|
|
||||||
:btn {:id :btn :code "BTN" :display-name (i18n/label :t/currency-display-name-btn) :symbol "Nu."}
|
|
||||||
:cad {:id :cad :code "CAD" :display-name (i18n/label :t/currency-display-name-cad) :symbol "$"}
|
|
||||||
:chf {:id :chf :code "CHF" :display-name (i18n/label :t/currency-display-name-chf) :symbol "CHF"}
|
|
||||||
:clp {:id :clp :code "CLP" :display-name (i18n/label :t/currency-display-name-clp) :symbol "$"}
|
|
||||||
:cny {:id :cny :code "CNY" :display-name (i18n/label :t/currency-display-name-cny) :symbol "¥"}
|
|
||||||
:cop {:id :cop :code "COP" :display-name (i18n/label :t/currency-display-name-cop) :symbol "$"}
|
|
||||||
:crc {:id :crc :code "CRC" :display-name (i18n/label :t/currency-display-name-crc) :symbol "₡"}
|
|
||||||
:czk {:id :czk :code "CZK" :display-name (i18n/label :t/currency-display-name-czk) :symbol "Kč"}
|
|
||||||
:dkk {:id :dkk :code "DKK" :display-name (i18n/label :t/currency-display-name-dkk) :symbol "kr"}
|
|
||||||
:dop {:id :dop :code "DOP" :display-name (i18n/label :t/currency-display-name-dop) :symbol "RD$"}
|
|
||||||
:egp {:id :egp :code "EGP" :display-name (i18n/label :t/currency-display-name-egp) :symbol "£"}
|
|
||||||
:etb {:id :etb :code "ETB" :display-name (i18n/label :t/currency-display-name-etb) :symbol "Br"}
|
|
||||||
:eur {:id :eur :code "EUR" :display-name (i18n/label :t/currency-display-name-eur) :symbol "€"}
|
|
||||||
:gbp {:id :gbp :code "GBP" :display-name (i18n/label :t/currency-display-name-gbp) :symbol "£"}
|
|
||||||
:gel {:id :gel :code "GEL" :display-name (i18n/label :t/currency-display-name-gel) :symbol "₾"}
|
|
||||||
:ghs {:id :ghs :code "GHS" :display-name (i18n/label :t/currency-display-name-ghs) :symbol "¢"}
|
|
||||||
:hkd {:id :hkd :code "HKD" :display-name (i18n/label :t/currency-display-name-hkd) :symbol "$"}
|
|
||||||
:hrk {:id :hrk :code "HRK" :display-name (i18n/label :t/currency-display-name-hrk) :symbol "kn"}
|
|
||||||
:huf {:id :huf :code "HUF" :display-name (i18n/label :t/currency-display-name-huf) :symbol "Ft"}
|
|
||||||
:idr {:id :idr :code "IDR" :display-name (i18n/label :t/currency-display-name-idr) :symbol "Rp"}
|
|
||||||
:ils {:id :ils :code "ILS" :display-name (i18n/label :t/currency-display-name-ils) :symbol "₪"}
|
|
||||||
:inr {:id :inr :code "INR" :display-name (i18n/label :t/currency-display-name-inr) :symbol "₹"}
|
|
||||||
:isk {:id :isk :code "ISK" :display-name (i18n/label :t/currency-display-name-isk) :symbol "kr"}
|
|
||||||
:jmd {:id :jmd :code "JMD" :display-name (i18n/label :t/currency-display-name-jmd) :symbol "J$"}
|
|
||||||
:jpy {:id :jpy :code "JPY" :display-name (i18n/label :t/currency-display-name-jpy) :symbol "¥"}
|
|
||||||
:kes {:id :kes :code "KES" :display-name (i18n/label :t/currency-display-name-kes) :symbol "KSh"}
|
|
||||||
:krw {:id :krw :code "KRW" :display-name (i18n/label :t/currency-display-name-krw) :symbol "₩"}
|
|
||||||
:kwd {:id :kwd :code "KWD" :display-name (i18n/label :t/currency-display-name-kwd) :symbol "د.ك"}
|
|
||||||
:kzt {:id :kzt :code "KZT" :display-name (i18n/label :t/currency-display-name-kzt) :symbol "лв"}
|
|
||||||
:lkr {:id :lkr :code "LKR" :display-name (i18n/label :t/currency-display-name-lkr) :symbol "₨"}
|
|
||||||
:mad {:id :mad :code "MAD" :display-name (i18n/label :t/currency-display-name-mad) :symbol "MAD"}
|
|
||||||
:mdl {:id :mdl :code "MDL" :display-name (i18n/label :t/currency-display-name-mdl) :symbol "MDL"}
|
|
||||||
:mur {:id :mur :code "MUR" :display-name (i18n/label :t/currency-display-name-mur) :symbol "₨"}
|
|
||||||
:mwk {:id :mwk :code "MWK" :display-name (i18n/label :t/currency-display-name-mwk) :symbol "MK"}
|
|
||||||
:mxn {:id :mxn :code "MXN" :display-name (i18n/label :t/currency-display-name-mxn) :symbol "$"}
|
|
||||||
:myr {:id :myr :code "MYR" :display-name (i18n/label :t/currency-display-name-myr) :symbol "RM"}
|
|
||||||
:mzn {:id :mzn :code "MZN" :display-name (i18n/label :t/currency-display-name-mzn) :symbol "MT"}
|
|
||||||
:nad {:id :nad :code "NAD" :display-name (i18n/label :t/currency-display-name-nad) :symbol "$"}
|
|
||||||
:ngn {:id :ngn :code "NGN" :display-name (i18n/label :t/currency-display-name-ngn) :symbol "₦"}
|
|
||||||
:nok {:id :nok :code "NOK" :display-name (i18n/label :t/currency-display-name-nok) :symbol "kr"}
|
|
||||||
:npr {:id :npr :code "NPR" :display-name (i18n/label :t/currency-display-name-npr) :symbol "₨"}
|
|
||||||
:nzd {:id :nzd :code "NZD" :display-name (i18n/label :t/currency-display-name-nzd) :symbol "$"}
|
|
||||||
:omr {:id :omr :code "OMR" :display-name (i18n/label :t/currency-display-name-omr) :symbol "﷼"}
|
|
||||||
:pen {:id :pen :code "PEN" :display-name (i18n/label :t/currency-display-name-pen) :symbol "S/."}
|
|
||||||
:pgk {:id :pgk :code "PGK" :display-name (i18n/label :t/currency-display-name-pgk) :symbol "K"}
|
|
||||||
:php {:id :php :code "PHP" :display-name (i18n/label :t/currency-display-name-php) :symbol "₱"}
|
|
||||||
:pkr {:id :pkr :code "PKR" :display-name (i18n/label :t/currency-display-name-pkr) :symbol "₨"}
|
|
||||||
:pln {:id :pln :code "PLN" :display-name (i18n/label :t/currency-display-name-pln) :symbol "zł"}
|
|
||||||
:pyg {:id :pyg :code "PYG" :display-name (i18n/label :t/currency-display-name-pyg) :symbol "Gs"}
|
|
||||||
:qar {:id :qar :code "QAR" :display-name (i18n/label :t/currency-display-name-qar) :symbol "﷼"}
|
|
||||||
:ron {:id :ron :code "RON" :display-name (i18n/label :t/currency-display-name-ron) :symbol "lei"}
|
|
||||||
:rsd {:id :rsd :code "RSD" :display-name (i18n/label :t/currency-display-name-rsd) :symbol "Дин."}
|
|
||||||
:rub {:id :rub :code "RUB" :display-name (i18n/label :t/currency-display-name-rub) :symbol "₽"}
|
|
||||||
:sar {:id :sar :code "SAR" :display-name (i18n/label :t/currency-display-name-sar) :symbol "﷼"}
|
|
||||||
:sek {:id :sek :code "SEK" :display-name (i18n/label :t/currency-display-name-sek) :symbol "kr"}
|
|
||||||
:sgd {:id :sgd :code "SGD" :display-name (i18n/label :t/currency-display-name-sgd) :symbol "$"}
|
|
||||||
:thb {:id :thb :code "THB" :display-name (i18n/label :t/currency-display-name-thb) :symbol "฿"}
|
|
||||||
:ttd {:id :ttd :code "TTD" :display-name (i18n/label :t/currency-display-name-ttd) :symbol "TT$"}
|
|
||||||
:twd {:id :twd :code "TWD" :display-name (i18n/label :t/currency-display-name-twd) :symbol "NT$"}
|
|
||||||
:tzs {:id :tzs :code "TZS" :display-name (i18n/label :t/currency-display-name-tzs) :symbol "TSh"}
|
|
||||||
:try {:id :try :code "TRY" :display-name (i18n/label :t/currency-display-name-try) :symbol "₺"}
|
|
||||||
:uah {:id :uah :code "UAH" :display-name (i18n/label :t/currency-display-name-uah) :symbol "₴"}
|
|
||||||
:ugx {:id :ugx :code "UGX" :display-name (i18n/label :t/currency-display-name-ugx) :symbol "USh"}
|
|
||||||
:uyu {:id :uyu :code "UYU" :display-name (i18n/label :t/currency-display-name-uyu) :symbol "$U"}
|
|
||||||
:usd {:id :usd :code "USD" :display-name (i18n/label :t/currency-display-name-usd) :symbol "$"}
|
|
||||||
:vef {:id :vef :code "VEF" :display-name (i18n/label :t/currency-display-name-vef) :symbol "Bs"}
|
|
||||||
:vnd {:id :vnd :code "VND" :display-name (i18n/label :t/currency-display-name-vnd) :symbol "₫"}
|
|
||||||
:zar {:id :zar :code "ZAR" :display-name (i18n/label :t/currency-display-name-zar) :symbol "R"}})
|
|
|
@ -10,6 +10,7 @@
|
||||||
[quo.components.settings.settings-item.style :as style]
|
[quo.components.settings.settings-item.style :as style]
|
||||||
[quo.components.tags.context-tag.view :as context-tag]
|
[quo.components.tags.context-tag.view :as context-tag]
|
||||||
[quo.components.tags.status-tags :as status-tags]
|
[quo.components.tags.status-tags :as status-tags]
|
||||||
|
[quo.components.utilities.token.view :as token]
|
||||||
[quo.foundations.colors :as colors]
|
[quo.foundations.colors :as colors]
|
||||||
[quo.theme :as quo.theme]
|
[quo.theme :as quo.theme]
|
||||||
[react-native.core :as rn]
|
[react-native.core :as rn]
|
||||||
|
@ -59,6 +60,7 @@
|
||||||
:icon [icon/icon image-props (style/color blur? theme)]
|
:icon [icon/icon image-props (style/color blur? theme)]
|
||||||
:avatar [user-avatar/user-avatar image-props]
|
:avatar [user-avatar/user-avatar image-props]
|
||||||
:icon-avatar [icon-avatar/icon-avatar image-props]
|
:icon-avatar [icon-avatar/icon-avatar image-props]
|
||||||
|
:token [token/view image-props]
|
||||||
nil)]))
|
nil)]))
|
||||||
|
|
||||||
(defn tag-component
|
(defn tag-component
|
||||||
|
|
|
@ -94,3 +94,11 @@
|
||||||
(fn [params]
|
(fn [params]
|
||||||
(doseq [param params]
|
(doseq [param params]
|
||||||
(call param))))
|
(call param))))
|
||||||
|
|
||||||
|
(defn log-rpc-error
|
||||||
|
[_ [{:keys [event params]} error]]
|
||||||
|
(log/error (str "Failed to " event)
|
||||||
|
{:params params
|
||||||
|
:error error}))
|
||||||
|
|
||||||
|
(rf/reg-event-fx :log-rpc-error log-rpc-error)
|
||||||
|
|
|
@ -90,7 +90,10 @@
|
||||||
:dark (js/require "../resources/images/ui2/sweating-man-dark.png")}
|
:dark (js/require "../resources/images/ui2/sweating-man-dark.png")}
|
||||||
:no-pinned-messages
|
:no-pinned-messages
|
||||||
{:light (js/require "../resources/images/ui2/no-pinned-messages-light.png")
|
{:light (js/require "../resources/images/ui2/no-pinned-messages-light.png")
|
||||||
:dark (js/require "../resources/images/ui2/no-pinned-messages-dark.png")}})
|
:dark (js/require "../resources/images/ui2/no-pinned-messages-dark.png")}
|
||||||
|
:no-assets
|
||||||
|
{:light (js/require "../resources/images/ui2/no-assets-light.png")
|
||||||
|
:dark (js/require "../resources/images/ui2/no-assets-dark.png")}})
|
||||||
|
|
||||||
(def mock-images
|
(def mock-images
|
||||||
{:bored-ape (js/require "../resources/images/mock2/bored-ape.png")
|
{:bored-ape (js/require "../resources/images/mock2/bored-ape.png")
|
||||||
|
|
|
@ -586,6 +586,8 @@
|
||||||
|
|
||||||
(def ^:const contact-item-height 56)
|
(def ^:const contact-item-height 56)
|
||||||
|
|
||||||
|
(def ^:const currency-item-height 64)
|
||||||
|
|
||||||
(def ^:const slippages [0.1 0.5 1])
|
(def ^:const slippages [0.1 0.5 1])
|
||||||
(def ^:const default-slippage 0.5)
|
(def ^:const default-slippage 0.5)
|
||||||
(def ^:const max-recommended-slippage 5)
|
(def ^:const max-recommended-slippage 5)
|
||||||
|
|
|
@ -95,6 +95,7 @@
|
||||||
[:dispatch-later [{:ms 1500 :dispatch [:profile.login/non-critical-initialization]}]]
|
[:dispatch-later [{:ms 1500 :dispatch [:profile.login/non-critical-initialization]}]]
|
||||||
[:dispatch [:network/check-expensive-connection]]
|
[:dispatch [:network/check-expensive-connection]]
|
||||||
[:profile.settings/get-profile-picture key-uid]
|
[:profile.settings/get-profile-picture key-uid]
|
||||||
|
[:settings/get-currencies]
|
||||||
(when (ff/enabled? ::ff/wallet.wallet-connect)
|
(when (ff/enabled? ::ff/wallet.wallet-connect)
|
||||||
[:dispatch [:wallet-connect/init]])
|
[:dispatch [:wallet-connect/init]])
|
||||||
(when notifications-enabled?
|
(when notifications-enabled?
|
||||||
|
|
|
@ -151,3 +151,8 @@
|
||||||
[{:method "settings_mnemonicWasShown"
|
[{:method "settings_mnemonicWasShown"
|
||||||
:on-success #(log/debug "mnemonic was marked as shown")
|
:on-success #(log/debug "mnemonic was marked as shown")
|
||||||
:on-error #(log/error "mnemonic was not marked as shown" %)}]]]}))
|
:on-error #(log/error "mnemonic was not marked as shown" %)}]]]}))
|
||||||
|
|
||||||
|
(rf/reg-event-fx :profile.settings/update-currency
|
||||||
|
(fn [_ [currency]]
|
||||||
|
{:fx [[:dispatch [:profile.settings/profile-update :currency currency]]
|
||||||
|
[:dispatch [:wallet/get-wallet-token-for-all-accounts]]]}))
|
||||||
|
|
|
@ -85,13 +85,12 @@
|
||||||
:image :icon
|
:image :icon
|
||||||
:blur? true
|
:blur? true
|
||||||
:action :arrow}
|
:action :arrow}
|
||||||
(when config/show-not-implemented-features?
|
{:title (i18n/label :t/language-and-currency)
|
||||||
{:title (i18n/label :t/language-and-currency)
|
:on-press #(rf/dispatch [:open-modal :screen/settings.language-and-currency])
|
||||||
:on-press not-implemented/alert
|
:image-props :i/globe
|
||||||
:image-props :i/globe
|
:image :icon
|
||||||
:image :icon
|
:blur? true
|
||||||
:blur? true
|
:action :arrow}]
|
||||||
:action :arrow})]
|
|
||||||
[(when config/show-not-implemented-features?
|
[(when config/show-not-implemented-features?
|
||||||
{:title (i18n/label :t/data-usage)
|
{:title (i18n/label :t/data-usage)
|
||||||
:on-press not-implemented/alert
|
:on-press not-implemented/alert
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
(ns status-im.contexts.settings.language-and-currency.currency.style)
|
||||||
|
|
||||||
|
(def input-container
|
||||||
|
{:padding-horizontal 20
|
||||||
|
:padding-vertical 8})
|
||||||
|
|
||||||
|
(def empty-results
|
||||||
|
{:margin-top 100})
|
|
@ -0,0 +1,20 @@
|
||||||
|
(ns status-im.contexts.settings.language-and-currency.currency.utils
|
||||||
|
(:require [status-im.constants :as constants]))
|
||||||
|
|
||||||
|
(defn make-currency-item
|
||||||
|
"This function generates props for quo/category component item"
|
||||||
|
[{:keys [currency selected-currency on-change]}]
|
||||||
|
{:title (if (:token? currency)
|
||||||
|
(:short-name currency)
|
||||||
|
(str (:short-name currency) " · " (:symbol currency)))
|
||||||
|
:description :text
|
||||||
|
:description-props {:text (:name currency)}
|
||||||
|
:container-style {:height constants/currency-item-height}
|
||||||
|
:image (when (:token? currency) :token)
|
||||||
|
:image-props {:token (:id currency)
|
||||||
|
:size :size-20}
|
||||||
|
:action :selector
|
||||||
|
:action-props {:type :radio
|
||||||
|
:blur? true
|
||||||
|
:checked? (= selected-currency (:id currency))
|
||||||
|
:on-change #(on-change (:id currency))}})
|
|
@ -0,0 +1,84 @@
|
||||||
|
(ns status-im.contexts.settings.language-and-currency.currency.view
|
||||||
|
(:require [quo.core :as quo]
|
||||||
|
[react-native.core :as rn]
|
||||||
|
[status-im.common.resources :as resources]
|
||||||
|
[status-im.constants :as constants]
|
||||||
|
[status-im.contexts.settings.language-and-currency.currency.style :as style]
|
||||||
|
[status-im.contexts.settings.language-and-currency.currency.utils :as utils]
|
||||||
|
[status-im.contexts.settings.language-and-currency.data-store :as data-store]
|
||||||
|
[utils.debounce :as debounce]
|
||||||
|
[utils.i18n :as i18n]
|
||||||
|
[utils.re-frame :as rf]))
|
||||||
|
|
||||||
|
(defn- navigate-back
|
||||||
|
[]
|
||||||
|
(rf/dispatch [:navigate-back]))
|
||||||
|
|
||||||
|
(defn- get-item-layout
|
||||||
|
[_ index]
|
||||||
|
#js {:length constants/currency-item-height
|
||||||
|
:offset (* constants/currency-item-height index)
|
||||||
|
:index index})
|
||||||
|
|
||||||
|
(defn- settings-category-view
|
||||||
|
[{:keys [title data]} _ _ {:keys [selected-currency on-currency-press]}]
|
||||||
|
[rn/delay-render
|
||||||
|
[quo/category
|
||||||
|
{:label title
|
||||||
|
:data (map (fn [currency]
|
||||||
|
(utils/make-currency-item
|
||||||
|
{:currency currency
|
||||||
|
:selected-currency selected-currency
|
||||||
|
:on-change on-currency-press}))
|
||||||
|
data)
|
||||||
|
:blur? true
|
||||||
|
:list-type :settings}]])
|
||||||
|
|
||||||
|
(defn view
|
||||||
|
[]
|
||||||
|
(let [[search-text set-search-text] (rn/use-state "")
|
||||||
|
on-currency-press (rn/use-callback #(rf/dispatch [:profile.settings/update-currency
|
||||||
|
%]))
|
||||||
|
selected-currency (rf/sub [:profile/currency])
|
||||||
|
currencies (rf/sub [:currencies/categorized search-text])
|
||||||
|
on-change-text (rn/use-callback
|
||||||
|
(debounce/debounce
|
||||||
|
#(set-search-text %)
|
||||||
|
300))
|
||||||
|
formatted-data (rn/use-memo
|
||||||
|
#(data-store/get-formatted-currency-data currencies)
|
||||||
|
[search-text currencies])]
|
||||||
|
[quo/overlay
|
||||||
|
{:type :shell
|
||||||
|
:top-inset? true}
|
||||||
|
[quo/page-nav
|
||||||
|
{:background :blur
|
||||||
|
:icon-name :i/arrow-left
|
||||||
|
:on-press navigate-back}]
|
||||||
|
[quo/page-top
|
||||||
|
{:title (i18n/label :t/currency)}]
|
||||||
|
[quo/input
|
||||||
|
{:small? true
|
||||||
|
:blur? true
|
||||||
|
:container-style style/input-container
|
||||||
|
:placeholder (i18n/label :t/search-currencies)
|
||||||
|
:icon-name :i/search
|
||||||
|
:on-change-text on-change-text}]
|
||||||
|
(when (zero? (:total currencies))
|
||||||
|
[quo/empty-state
|
||||||
|
{:title (i18n/label :t/no-result)
|
||||||
|
:image (resources/get-themed-image :no-assets :dark)
|
||||||
|
:container-style style/empty-results
|
||||||
|
:description (i18n/label :t/try-with-different-currency)}])
|
||||||
|
[rn/flat-list
|
||||||
|
{:data formatted-data
|
||||||
|
:render-data {:selected-currency selected-currency
|
||||||
|
:on-currency-press on-currency-press}
|
||||||
|
:render-fn settings-category-view
|
||||||
|
:get-item-layout get-item-layout
|
||||||
|
:initial-num-to-render 14
|
||||||
|
:max-to-render-per-batch 20
|
||||||
|
:scroll-event-throttle 16
|
||||||
|
:shows-vertical-scroll-indicator false
|
||||||
|
:bounces false
|
||||||
|
:over-scroll-mode :never}]]))
|
|
@ -0,0 +1,30 @@
|
||||||
|
(ns status-im.contexts.settings.language-and-currency.data-store
|
||||||
|
(:require [clojure.set :as set]
|
||||||
|
[utils.i18n :as i18n]))
|
||||||
|
|
||||||
|
(defn rpc->currency
|
||||||
|
[currency]
|
||||||
|
(some-> currency
|
||||||
|
(dissoc :unicode)
|
||||||
|
(set/rename-keys
|
||||||
|
{:shortName :short-name
|
||||||
|
:isPopular :popular?
|
||||||
|
:isToken :token?})
|
||||||
|
(update :id keyword)))
|
||||||
|
|
||||||
|
(defn rpc->currencies
|
||||||
|
[currencies]
|
||||||
|
(map rpc->currency currencies))
|
||||||
|
|
||||||
|
(defn get-formatted-currency-data
|
||||||
|
[{:keys [popular crypto other]}]
|
||||||
|
(concat
|
||||||
|
(when (seq popular)
|
||||||
|
[{:title (i18n/label :t/popular-currencies)
|
||||||
|
:data popular}])
|
||||||
|
(when (seq crypto)
|
||||||
|
[{:title (i18n/label :t/crypto)
|
||||||
|
:data crypto}])
|
||||||
|
(when (seq other)
|
||||||
|
[{:title (i18n/label :t/all-currencies)
|
||||||
|
:data other}])))
|
|
@ -0,0 +1,56 @@
|
||||||
|
(ns status-im.contexts.settings.language-and-currency.data-store-test
|
||||||
|
(:require
|
||||||
|
[cljs.test :refer-macros [deftest is testing]]
|
||||||
|
matcher-combinators.test
|
||||||
|
[status-im.contexts.settings.language-and-currency.data-store :as sut]))
|
||||||
|
|
||||||
|
(def raw-currency-popular
|
||||||
|
{:id "usd"
|
||||||
|
:shortName "USD"
|
||||||
|
:name "US Dollar"
|
||||||
|
:symbol "$"
|
||||||
|
:emoji "🇺🇸"
|
||||||
|
:isPopular true
|
||||||
|
:isToken false
|
||||||
|
:imageSource "https://example.com/image.png"})
|
||||||
|
|
||||||
|
(def raw-currency-token
|
||||||
|
{:id "btc"
|
||||||
|
:shortName "BTC"
|
||||||
|
:name "Bitcoin"
|
||||||
|
:symbol ""
|
||||||
|
:emoji ""
|
||||||
|
:isPopular false
|
||||||
|
:isToken true
|
||||||
|
:imageSource "https://example.com/image.png"})
|
||||||
|
|
||||||
|
(deftest rpc->currency-test
|
||||||
|
(testing "transforms a currency"
|
||||||
|
(is
|
||||||
|
(match? {:id :usd
|
||||||
|
:short-name "USD"
|
||||||
|
:symbol "$"
|
||||||
|
:emoji "🇺🇸"
|
||||||
|
:name "US Dollar"
|
||||||
|
:popular? true
|
||||||
|
:token? false}
|
||||||
|
(sut/rpc->currency raw-currency-popular)))))
|
||||||
|
|
||||||
|
(deftest rpc->currencies-test
|
||||||
|
(testing "transforms and sorts raw keypairs"
|
||||||
|
(is
|
||||||
|
(match? [(sut/rpc->currency raw-currency-popular)
|
||||||
|
(sut/rpc->currency raw-currency-token)]
|
||||||
|
(sut/rpc->currencies [raw-currency-popular
|
||||||
|
raw-currency-token])))))
|
||||||
|
|
||||||
|
(deftest get-formatted-currency-data-test
|
||||||
|
(testing "returns formatted currency data"
|
||||||
|
(is
|
||||||
|
(match? [{:title "Popular currencies"
|
||||||
|
:data [(sut/rpc->currency raw-currency-popular)]}
|
||||||
|
{:title "Crypto"
|
||||||
|
:data [(sut/rpc->currency raw-currency-token)]}]
|
||||||
|
(sut/get-formatted-currency-data {:popular [(sut/rpc->currency raw-currency-popular)]
|
||||||
|
:crypto [(sut/rpc->currency raw-currency-token)]
|
||||||
|
:other []})))))
|
|
@ -0,0 +1,18 @@
|
||||||
|
(ns status-im.contexts.settings.language-and-currency.events
|
||||||
|
(:require [status-im.common.json-rpc.events :as json-rpc]
|
||||||
|
[status-im.contexts.settings.language-and-currency.data-store :as data-store]
|
||||||
|
[utils.collection]
|
||||||
|
[utils.re-frame :as rf]))
|
||||||
|
|
||||||
|
(rf/reg-event-fx :settings/get-currencies-success
|
||||||
|
(fn [{:keys [db]} [currencies]]
|
||||||
|
(let [all-currencies (data-store/rpc->currencies currencies)]
|
||||||
|
{:db (assoc db
|
||||||
|
:currencies
|
||||||
|
(utils.collection/index-by :id all-currencies))})))
|
||||||
|
|
||||||
|
(rf/reg-fx :settings/get-currencies
|
||||||
|
(fn []
|
||||||
|
(json-rpc/call {:method "appgeneral_getCurrencies"
|
||||||
|
:on-success [:settings/get-currencies-success]
|
||||||
|
:on-error [:log-rpc-error {:event :settings/get-currencies}]})))
|
|
@ -0,0 +1,27 @@
|
||||||
|
(ns status-im.contexts.settings.language-and-currency.events-test
|
||||||
|
(:require
|
||||||
|
[cljs.test :refer-macros [is]]
|
||||||
|
matcher-combinators.test
|
||||||
|
status-im.contexts.settings.language-and-currency.events
|
||||||
|
[test-helpers.unit :as h]))
|
||||||
|
|
||||||
|
(def raw-currency-popular
|
||||||
|
{:id "usd"
|
||||||
|
:shortName "USD"
|
||||||
|
:name "US Dollar"
|
||||||
|
:symbol "$"
|
||||||
|
:emoji "🇺🇸"
|
||||||
|
:isPopular true
|
||||||
|
:isToken false
|
||||||
|
:imageSource "https://example.com/image.png"})
|
||||||
|
|
||||||
|
(h/deftest-event :settings/get-currencies-success
|
||||||
|
[event-id dispatch]
|
||||||
|
(let [expected-effects {:db {:currencies {:usd {:id :usd
|
||||||
|
:short-name "USD"
|
||||||
|
:symbol "$"
|
||||||
|
:emoji "🇺🇸"
|
||||||
|
:name "US Dollar"
|
||||||
|
:popular? true
|
||||||
|
:token? false}}}}]
|
||||||
|
(is (match? expected-effects (dispatch [event-id [raw-currency-popular]])))))
|
|
@ -0,0 +1,36 @@
|
||||||
|
(ns status-im.contexts.settings.language-and-currency.view
|
||||||
|
(:require [quo.core :as quo]
|
||||||
|
[utils.i18n :as i18n]
|
||||||
|
[utils.re-frame :as rf]))
|
||||||
|
|
||||||
|
(defn- navigate-back
|
||||||
|
[]
|
||||||
|
(rf/dispatch [:navigate-back]))
|
||||||
|
|
||||||
|
(defn- on-currency-press
|
||||||
|
[]
|
||||||
|
(rf/dispatch [:open-modal :screen/settings.currency-selection]))
|
||||||
|
|
||||||
|
(defn view
|
||||||
|
[]
|
||||||
|
(let [{:keys [name short-name token?]
|
||||||
|
:as currency} (rf/sub [:profile/currency-info])
|
||||||
|
currency-title (if token? name (str short-name " · " (:symbol currency)))]
|
||||||
|
[quo/overlay
|
||||||
|
{:type :shell
|
||||||
|
:top-inset? true}
|
||||||
|
[quo/page-nav
|
||||||
|
{:background :blur
|
||||||
|
:icon-name :i/arrow-left
|
||||||
|
:on-press navigate-back}]
|
||||||
|
[quo/page-top
|
||||||
|
{:title (i18n/label :t/language-and-currency)}]
|
||||||
|
[quo/category
|
||||||
|
{:label (i18n/label :t/currency)
|
||||||
|
:data [{:title currency-title
|
||||||
|
:on-press on-currency-press
|
||||||
|
:description :text
|
||||||
|
:action :arrow
|
||||||
|
:description-props {:text name}}]
|
||||||
|
:blur? true
|
||||||
|
:list-type :settings}]]))
|
|
@ -95,7 +95,7 @@
|
||||||
show-profile-pictures-to
|
show-profile-pictures-to
|
||||||
open-show-profile-pictures-to-options))
|
open-show-profile-pictures-to-options))
|
||||||
(setting-preview-privacy preview-privacy? customization-color toggle-preview-privacy)
|
(setting-preview-privacy preview-privacy? customization-color toggle-preview-privacy)
|
||||||
{:title (i18n/label :t/share-usage-data)
|
{:title (i18n/label :t/share-usage-data-with-status)
|
||||||
:description :text
|
:description :text
|
||||||
:description-props {:text (i18n/label :t/from-all-profiles-on-device)}
|
:description-props {:text (i18n/label :t/from-all-profiles-on-device)}
|
||||||
:blur? true
|
:blur? true
|
||||||
|
|
|
@ -22,7 +22,10 @@
|
||||||
|
|
||||||
(defn prettify-balance
|
(defn prettify-balance
|
||||||
[currency-symbol balance]
|
[currency-symbol balance]
|
||||||
(str currency-symbol (cut-fiat-balance-to-two-decimals balance)))
|
(let [formatted-symbol (if (> (count currency-symbol) 1)
|
||||||
|
(str currency-symbol " ")
|
||||||
|
currency-symbol)]
|
||||||
|
(str formatted-symbol (cut-fiat-balance-to-two-decimals balance))))
|
||||||
|
|
||||||
(defn get-derivation-path
|
(defn get-derivation-path
|
||||||
[number-of-accounts]
|
[number-of-accounts]
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
:pairing/installations {}
|
:pairing/installations {}
|
||||||
:group/selected-contacts #{}
|
:group/selected-contacts #{}
|
||||||
:chats {}
|
:chats {}
|
||||||
|
:currencies {}
|
||||||
:current-chat-id nil
|
:current-chat-id nil
|
||||||
:group-chat/selected-participants #{}
|
:group-chat/selected-participants #{}
|
||||||
:group-chat/deselected-members #{}
|
:group-chat/deselected-members #{}
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
status-im.contexts.onboarding.events
|
status-im.contexts.onboarding.events
|
||||||
status-im.contexts.profile.events
|
status-im.contexts.profile.events
|
||||||
status-im.contexts.profile.settings.events
|
status-im.contexts.profile.settings.events
|
||||||
|
status-im.contexts.settings.language-and-currency.events
|
||||||
status-im.contexts.settings.wallet.saved-addresses.events
|
status-im.contexts.settings.wallet.saved-addresses.events
|
||||||
status-im.contexts.shell.qr-reader.events
|
status-im.contexts.shell.qr-reader.events
|
||||||
status-im.contexts.shell.share.events
|
status-im.contexts.shell.share.events
|
||||||
|
|
|
@ -58,6 +58,8 @@
|
||||||
[status-im.contexts.profile.settings.screens.password.view :as settings-password]
|
[status-im.contexts.profile.settings.screens.password.view :as settings-password]
|
||||||
[status-im.contexts.profile.settings.screens.syncing.view :as settings.syncing]
|
[status-im.contexts.profile.settings.screens.syncing.view :as settings.syncing]
|
||||||
[status-im.contexts.profile.settings.view :as settings]
|
[status-im.contexts.profile.settings.view :as settings]
|
||||||
|
[status-im.contexts.settings.language-and-currency.currency.view :as settings.currency-selection]
|
||||||
|
[status-im.contexts.settings.language-and-currency.view :as settings.language-and-currency]
|
||||||
[status-im.contexts.settings.privacy-and-security.view :as settings.privacy-and-security]
|
[status-im.contexts.settings.privacy-and-security.view :as settings.privacy-and-security]
|
||||||
[status-im.contexts.settings.wallet.keypairs-and-accounts.missing-keypairs.encrypted-qr.view
|
[status-im.contexts.settings.wallet.keypairs-and-accounts.missing-keypairs.encrypted-qr.view
|
||||||
:as encrypted-keypair-qr]
|
:as encrypted-keypair-qr]
|
||||||
|
@ -643,6 +645,14 @@
|
||||||
:options options/transparent-modal-screen-options
|
:options options/transparent-modal-screen-options
|
||||||
:component settings.privacy-and-security/view}
|
:component settings.privacy-and-security/view}
|
||||||
|
|
||||||
|
{:name :screen/settings.language-and-currency
|
||||||
|
:options options/transparent-modal-screen-options
|
||||||
|
:component settings.language-and-currency/view}
|
||||||
|
|
||||||
|
{:name :screen/settings.currency-selection
|
||||||
|
:options options/transparent-modal-screen-options
|
||||||
|
:component settings.currency-selection/view}
|
||||||
|
|
||||||
{:name :screen/change-password
|
{:name :screen/change-password
|
||||||
:options (assoc options/transparent-modal-screen-options :theme :dark)
|
:options (assoc options/transparent-modal-screen-options :theme :dark)
|
||||||
:component change-password/view}
|
:component change-password/view}
|
||||||
|
|
|
@ -161,3 +161,27 @@
|
||||||
:<- [:network/status]
|
:<- [:network/status]
|
||||||
(fn [status]
|
(fn [status]
|
||||||
(= status :online)))
|
(= status :online)))
|
||||||
|
|
||||||
|
(re-frame/reg-sub :currencies/categorized
|
||||||
|
:<- [:currencies]
|
||||||
|
(fn [currencies [_ query]]
|
||||||
|
(let [search-lc (string/lower-case query)]
|
||||||
|
(reduce
|
||||||
|
(fn [acc currency]
|
||||||
|
(let [{:keys [popular? token? name short-name]} currency
|
||||||
|
matches-query? (or (string/includes? (string/lower-case
|
||||||
|
name)
|
||||||
|
search-lc)
|
||||||
|
(string/includes? (string/lower-case
|
||||||
|
short-name)
|
||||||
|
search-lc))]
|
||||||
|
(cond-> acc
|
||||||
|
matches-query? (update :total inc)
|
||||||
|
(and popular? matches-query?) (update :popular conj currency)
|
||||||
|
(and token? matches-query?) (update :crypto conj currency)
|
||||||
|
(and matches-query? (not popular?) (not token?)) (update :other conj currency))))
|
||||||
|
{:total 0
|
||||||
|
:popular []
|
||||||
|
:crypto []
|
||||||
|
:other []}
|
||||||
|
(vals currencies)))))
|
||||||
|
|
|
@ -0,0 +1,187 @@
|
||||||
|
(ns status-im.subs.general-test
|
||||||
|
(:require
|
||||||
|
[cljs.test :refer [is testing use-fixtures]]
|
||||||
|
[re-frame.db :as rf-db]
|
||||||
|
[test-helpers.unit :as h]
|
||||||
|
[utils.re-frame :as rf]))
|
||||||
|
|
||||||
|
(use-fixtures :each
|
||||||
|
{:before #(reset! rf-db/app-db {})
|
||||||
|
:after #(reset! rf-db/app-db {})})
|
||||||
|
|
||||||
|
(def currencies
|
||||||
|
{:usd
|
||||||
|
{:id :usd :short-name "USD" :symbol "$" :emoji "🇺🇸" :name "US Dollar" :popular? true :token? false}
|
||||||
|
:eur {:id :eur :short-name "EUR" :symbol "€" :emoji "🇪🇺" :name "Euro" :popular? true :token? false}
|
||||||
|
:btc
|
||||||
|
{:id :btc :short-name "BTC" :symbol "₿" :emoji "🇧🇹" :name "Bitcoin" :popular? false :token? true}
|
||||||
|
:eth
|
||||||
|
{:id :eth :short-name "ETH" :symbol "Ξ" :emoji "🇪🇹" :name "Ethereum" :popular? false :token? true}
|
||||||
|
:gbp {:id :gbp
|
||||||
|
:short-name "GBP"
|
||||||
|
:symbol "£"
|
||||||
|
:emoji "🇬🇧"
|
||||||
|
:name "British Pound"
|
||||||
|
:popular? false
|
||||||
|
:token? false}
|
||||||
|
:jpy {:id :jpy
|
||||||
|
:short-name "JPY"
|
||||||
|
:symbol "¥"
|
||||||
|
:emoji "🇯🇵"
|
||||||
|
:name "Japanese Yen"
|
||||||
|
:popular? false
|
||||||
|
:token? false}})
|
||||||
|
|
||||||
|
(h/deftest-sub :currencies/categorized
|
||||||
|
[sub-name]
|
||||||
|
(swap! rf-db/app-db assoc :currencies currencies)
|
||||||
|
|
||||||
|
(testing "all currencies categorized correctly"
|
||||||
|
(is
|
||||||
|
(= {:total 6
|
||||||
|
:popular [{:id :usd
|
||||||
|
:short-name "USD"
|
||||||
|
:symbol "$"
|
||||||
|
:emoji "🇺🇸"
|
||||||
|
:name "US Dollar"
|
||||||
|
:popular? true
|
||||||
|
:token? false}
|
||||||
|
{:id :eur
|
||||||
|
:short-name "EUR"
|
||||||
|
:symbol "€"
|
||||||
|
:emoji "🇪🇺"
|
||||||
|
:name "Euro"
|
||||||
|
:popular? true
|
||||||
|
:token? false}]
|
||||||
|
:crypto [{:id :btc
|
||||||
|
:short-name "BTC"
|
||||||
|
:symbol "₿"
|
||||||
|
:emoji "🇧🇹"
|
||||||
|
:name "Bitcoin"
|
||||||
|
:popular? false
|
||||||
|
:token? true}
|
||||||
|
{:id :eth
|
||||||
|
:short-name "ETH"
|
||||||
|
:symbol "Ξ"
|
||||||
|
:emoji "🇪🇹"
|
||||||
|
:name "Ethereum"
|
||||||
|
:popular? false
|
||||||
|
:token? true}]
|
||||||
|
:other [{:id :gbp
|
||||||
|
:short-name "GBP"
|
||||||
|
:symbol "£"
|
||||||
|
:emoji "🇬🇧"
|
||||||
|
:name "British Pound"
|
||||||
|
:popular? false
|
||||||
|
:token? false}
|
||||||
|
{:id :jpy
|
||||||
|
:short-name "JPY"
|
||||||
|
:symbol "¥"
|
||||||
|
:emoji "🇯🇵"
|
||||||
|
:name "Japanese Yen"
|
||||||
|
:popular? false
|
||||||
|
:token? false}]}
|
||||||
|
(rf/sub [sub-name ""]))))
|
||||||
|
|
||||||
|
(testing "search query filters correctly"
|
||||||
|
(is (= {:total 1
|
||||||
|
:popular [{:id :usd
|
||||||
|
:short-name "USD"
|
||||||
|
:symbol "$"
|
||||||
|
:emoji "🇺🇸"
|
||||||
|
:name "US Dollar"
|
||||||
|
:popular? true
|
||||||
|
:token? false}]
|
||||||
|
:crypto []
|
||||||
|
:other []}
|
||||||
|
(rf/sub [sub-name "usd"])))
|
||||||
|
(is
|
||||||
|
(=
|
||||||
|
{:total 1
|
||||||
|
:popular
|
||||||
|
[{:id :eur :short-name "EUR" :symbol "€" :emoji "🇪🇺" :name "Euro" :popular? true :token? false}]
|
||||||
|
:crypto []
|
||||||
|
:other []}
|
||||||
|
(rf/sub [sub-name "eur"])))
|
||||||
|
(is
|
||||||
|
(= {:total 3
|
||||||
|
:popular []
|
||||||
|
:crypto [{:id :btc
|
||||||
|
:short-name "BTC"
|
||||||
|
:symbol "₿"
|
||||||
|
:emoji "🇧🇹"
|
||||||
|
:name "Bitcoin"
|
||||||
|
:popular? false
|
||||||
|
:token? true}
|
||||||
|
{:id :eth
|
||||||
|
:short-name "ETH"
|
||||||
|
:symbol "Ξ"
|
||||||
|
:emoji "🇪🇹"
|
||||||
|
:name "Ethereum"
|
||||||
|
:popular? false
|
||||||
|
:token? true}]
|
||||||
|
:other [{:id :gbp
|
||||||
|
:short-name "GBP"
|
||||||
|
:symbol "£"
|
||||||
|
:emoji "🇬🇧"
|
||||||
|
:name "British Pound"
|
||||||
|
:popular? false
|
||||||
|
:token? false}]}
|
||||||
|
(rf/sub [sub-name "t"]))))
|
||||||
|
|
||||||
|
(testing "case insensitive search query"
|
||||||
|
(is (= {:total 1
|
||||||
|
:popular [{:id :usd
|
||||||
|
:short-name "USD"
|
||||||
|
:symbol "$"
|
||||||
|
:emoji "🇺🇸"
|
||||||
|
:name "US Dollar"
|
||||||
|
:popular? true
|
||||||
|
:token? false}]
|
||||||
|
:crypto []
|
||||||
|
:other []}
|
||||||
|
(rf/sub [sub-name "USD"])))
|
||||||
|
(is
|
||||||
|
(=
|
||||||
|
{:total 1
|
||||||
|
:popular
|
||||||
|
[{:id :eur :short-name "EUR" :symbol "€" :emoji "🇪🇺" :name "Euro" :popular? true :token? false}]
|
||||||
|
:crypto []
|
||||||
|
:other []}
|
||||||
|
(rf/sub [sub-name "eUr"])))
|
||||||
|
(is
|
||||||
|
(= {:total 3
|
||||||
|
:popular []
|
||||||
|
:crypto [{:id :btc
|
||||||
|
:short-name "BTC"
|
||||||
|
:symbol "₿"
|
||||||
|
:emoji "🇧🇹"
|
||||||
|
:name "Bitcoin"
|
||||||
|
:popular? false
|
||||||
|
:token? true}
|
||||||
|
{:id :eth
|
||||||
|
:short-name "ETH"
|
||||||
|
:symbol "Ξ"
|
||||||
|
:emoji "🇪🇹"
|
||||||
|
:name "Ethereum"
|
||||||
|
:popular? false
|
||||||
|
:token? true}]
|
||||||
|
:other [{:id :gbp
|
||||||
|
:short-name "GBP"
|
||||||
|
:symbol "£"
|
||||||
|
:emoji "🇬🇧"
|
||||||
|
:name "British Pound"
|
||||||
|
:popular? false
|
||||||
|
:token? false}]}
|
||||||
|
(rf/sub [sub-name "T"]))))
|
||||||
|
|
||||||
|
(testing "search with no matching results"
|
||||||
|
(is (= {:total 0
|
||||||
|
:popular []
|
||||||
|
:crypto []
|
||||||
|
:other []}
|
||||||
|
(rf/sub [sub-name "xyz"]))))
|
||||||
|
|
||||||
|
(testing "all categories are included"
|
||||||
|
(is (= [:total :popular :crypto :other]
|
||||||
|
(keys (rf/sub [sub-name ""]))))))
|
|
@ -4,7 +4,6 @@
|
||||||
[clojure.string :as string]
|
[clojure.string :as string]
|
||||||
[legacy.status-im.fleet.core :as fleet]
|
[legacy.status-im.fleet.core :as fleet]
|
||||||
[legacy.status-im.multiaccounts.db :as multiaccounts.db]
|
[legacy.status-im.multiaccounts.db :as multiaccounts.db]
|
||||||
[legacy.status-im.utils.currency :as currency]
|
|
||||||
[quo.theme]
|
[quo.theme]
|
||||||
[re-frame.core :as re-frame]
|
[re-frame.core :as re-frame]
|
||||||
[status-im.common.pixel-ratio :as pixel-ratio]
|
[status-im.common.pixel-ratio :as pixel-ratio]
|
||||||
|
@ -20,9 +19,9 @@
|
||||||
|
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
:profile/currency
|
:profile/currency
|
||||||
(fn []
|
:<- [:profile/profile]
|
||||||
;; returns "usd" by default as the support for other currencies are in progress on Mobile
|
(fn [{:keys [currency]}]
|
||||||
constants/profile-default-currency))
|
(or currency constants/profile-default-currency)))
|
||||||
|
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
:profile/syncing-on-mobile-network?
|
:profile/syncing-on-mobile-network?
|
||||||
|
@ -32,10 +31,20 @@
|
||||||
|
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
:profile/currency-symbol
|
:profile/currency-symbol
|
||||||
|
:<- [:currencies]
|
||||||
:<- [:profile/currency]
|
:<- [:profile/currency]
|
||||||
(fn [currency-id]
|
(fn [[currencies currency-id]]
|
||||||
(-> (get currency/currencies currency-id)
|
(let [currency (get currencies currency-id)]
|
||||||
:symbol)))
|
(if (:token? currency)
|
||||||
|
(:short-name currency)
|
||||||
|
(:symbol currency)))))
|
||||||
|
|
||||||
|
(re-frame/reg-sub
|
||||||
|
:profile/currency-info
|
||||||
|
:<- [:currencies]
|
||||||
|
:<- [:profile/currency]
|
||||||
|
(fn [[currencies currency-id]]
|
||||||
|
(get currencies currency-id)))
|
||||||
|
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
:profile/login-profiles-picture
|
:profile/login-profiles-picture
|
||||||
|
|
|
@ -100,6 +100,15 @@
|
||||||
:colorHash [[3 25] [4 3] [5 4] [2 0] [1 10] [5 2] [2 4] [1 17] [3 23] [2 19] [4 1]]
|
:colorHash [[3 25] [4 3] [5 4] [2 0] [1 10] [5 2] [2 4] [1 17] [3 23] [2 19] [4 1]]
|
||||||
:installation-id "cee7e269-1ca7-4468-a1dd-e60e5cfb0894"})
|
:installation-id "cee7e269-1ca7-4468-a1dd-e60e5cfb0894"})
|
||||||
|
|
||||||
|
(def sample-currency
|
||||||
|
{:usd {:id :usd
|
||||||
|
:short-name "USD"
|
||||||
|
:symbol "$"
|
||||||
|
:emoji "🇺🇸"
|
||||||
|
:name "US Dollar"
|
||||||
|
:popular? true
|
||||||
|
:token? false}})
|
||||||
|
|
||||||
(h/deftest-sub :profile/currency
|
(h/deftest-sub :profile/currency
|
||||||
[sub-name]
|
[sub-name]
|
||||||
(testing "returns the selected currency of user"
|
(testing "returns the selected currency of user"
|
||||||
|
@ -109,7 +118,9 @@
|
||||||
(h/deftest-sub :profile/currency-symbol
|
(h/deftest-sub :profile/currency-symbol
|
||||||
[sub-name]
|
[sub-name]
|
||||||
(testing "returns the symbol of the user's selected currency"
|
(testing "returns the symbol of the user's selected currency"
|
||||||
(swap! rf-db/app-db #(assoc % :profile/profile sample-profile))
|
(swap! rf-db/app-db assoc
|
||||||
|
:profile/profile sample-profile
|
||||||
|
:currencies sample-currency)
|
||||||
(is (match? "$" (rf/sub [sub-name])))))
|
(is (match? "$" (rf/sub [sub-name])))))
|
||||||
|
|
||||||
(h/deftest-sub :profile/public-key
|
(h/deftest-sub :profile/public-key
|
||||||
|
|
|
@ -74,6 +74,7 @@
|
||||||
(reg-root-key-sub :initials-avatar-font-file :initials-avatar-font-file)
|
(reg-root-key-sub :initials-avatar-font-file :initials-avatar-font-file)
|
||||||
(reg-root-key-sub :alert-banners :alert-banners)
|
(reg-root-key-sub :alert-banners :alert-banners)
|
||||||
(reg-root-key-sub :alert-banners/hide? :alert-banners/hide?)
|
(reg-root-key-sub :alert-banners/hide? :alert-banners/hide?)
|
||||||
|
(reg-root-key-sub :currencies :currencies)
|
||||||
|
|
||||||
;;onboarding
|
;;onboarding
|
||||||
(reg-root-key-sub :onboarding/generated-keys? :onboarding/generated-keys?)
|
(reg-root-key-sub :onboarding/generated-keys? :onboarding/generated-keys?)
|
||||||
|
|
|
@ -7,6 +7,15 @@
|
||||||
[test-helpers.unit :as h]
|
[test-helpers.unit :as h]
|
||||||
[utils.re-frame :as rf]))
|
[utils.re-frame :as rf]))
|
||||||
|
|
||||||
|
(def ^:private currencies
|
||||||
|
{:usd {:id :usd
|
||||||
|
:short-name "USD"
|
||||||
|
:symbol "$"
|
||||||
|
:emoji "🇺🇸"
|
||||||
|
:name "US Dollar"
|
||||||
|
:popular? true
|
||||||
|
:token? false}})
|
||||||
|
|
||||||
(def networks
|
(def networks
|
||||||
{:mainnet-network
|
{:mainnet-network
|
||||||
{:full-name "Mainnet"
|
{:full-name "Mainnet"
|
||||||
|
@ -146,7 +155,8 @@
|
||||||
(h/deftest-sub :wallet/swap-asset-to-pay-network-balance
|
(h/deftest-sub :wallet/swap-asset-to-pay-network-balance
|
||||||
[sub-name]
|
[sub-name]
|
||||||
(testing "Return swap asset-to-pay"
|
(testing "Return swap asset-to-pay"
|
||||||
(swap! rf-db/app-db assoc-in
|
(swap! rf-db/app-db
|
||||||
[:wallet :ui :swap]
|
#(-> %
|
||||||
swap-data)
|
(assoc :currencies currencies)
|
||||||
|
(assoc-in [:wallet :ui :swap] swap-data)))
|
||||||
(is (match? {:crypto "1 SNT" :fiat "$0.03"} (rf/sub [sub-name 1])))))
|
(is (match? {:crypto "1 SNT" :fiat "$0.03"} (rf/sub [sub-name 1])))))
|
||||||
|
|
|
@ -12,6 +12,15 @@
|
||||||
(use-fixtures :each
|
(use-fixtures :each
|
||||||
{:before #(reset! rf-db/app-db {})})
|
{:before #(reset! rf-db/app-db {})})
|
||||||
|
|
||||||
|
(def ^:private currencies
|
||||||
|
{:usd {:id :usd
|
||||||
|
:short-name "USD"
|
||||||
|
:symbol "$"
|
||||||
|
:emoji "🇺🇸"
|
||||||
|
:name "US Dollar"
|
||||||
|
:popular? true
|
||||||
|
:token? false}})
|
||||||
|
|
||||||
(def ^:private accounts-with-tokens
|
(def ^:private accounts-with-tokens
|
||||||
{:0x1 {:tokens [{:symbol "ETH"
|
{:0x1 {:tokens [{:symbol "ETH"
|
||||||
:balances-per-chain {1 {:raw-balance "100"}}
|
:balances-per-chain {1 {:raw-balance "100"}}
|
||||||
|
@ -318,6 +327,7 @@
|
||||||
(swap! rf-db/app-db
|
(swap! rf-db/app-db
|
||||||
#(-> %
|
#(-> %
|
||||||
(assoc :wallet db/defaults)
|
(assoc :wallet db/defaults)
|
||||||
|
(assoc :currencies currencies)
|
||||||
(assoc-in [:wallet :accounts] accounts)
|
(assoc-in [:wallet :accounts] accounts)
|
||||||
(assoc-in [:wallet :current-viewing-account-address] "0x1")
|
(assoc-in [:wallet :current-viewing-account-address] "0x1")
|
||||||
(assoc-in [:wallet :networks] network-data)))
|
(assoc-in [:wallet :networks] network-data)))
|
||||||
|
@ -600,6 +610,7 @@
|
||||||
(testing "returns aggregated tokens (in quo/token-value props) and balances from all accounts"
|
(testing "returns aggregated tokens (in quo/token-value props) and balances from all accounts"
|
||||||
(swap! rf-db/app-db #(-> %
|
(swap! rf-db/app-db #(-> %
|
||||||
(assoc :wallet db/defaults)
|
(assoc :wallet db/defaults)
|
||||||
|
(assoc :currencies currencies)
|
||||||
(assoc-in [:wallet :accounts] accounts)))
|
(assoc-in [:wallet :accounts] accounts)))
|
||||||
(let [{:keys [formatted-balance tokens]} (rf/sub [sub-name])]
|
(let [{:keys [formatted-balance tokens]} (rf/sub [sub-name])]
|
||||||
(is (match? 2 (count tokens)))
|
(is (match? 2 (count tokens)))
|
||||||
|
@ -873,6 +884,7 @@
|
||||||
(assoc-in [:wallet :accounts] accounts)
|
(assoc-in [:wallet :accounts] accounts)
|
||||||
(assoc-in [:wallet :networks] network-data)
|
(assoc-in [:wallet :networks] network-data)
|
||||||
(assoc-in [:wallet :current-viewing-account-address] "0x2")
|
(assoc-in [:wallet :current-viewing-account-address] "0x2")
|
||||||
|
(assoc :currencies currencies)
|
||||||
(assoc-in [:profile/profile :currency] :usd)))
|
(assoc-in [:profile/profile :currency] :usd)))
|
||||||
(is (match? (count (rf/sub [sub-name ""])) 2))
|
(is (match? (count (rf/sub [sub-name ""])) 2))
|
||||||
(is (match? (count (rf/sub [sub-name "et"])) 1))))
|
(is (match? (count (rf/sub [sub-name "et"])) 1))))
|
||||||
|
@ -936,6 +948,7 @@
|
||||||
#(-> %
|
#(-> %
|
||||||
(assoc-in [:wallet :accounts] accounts)
|
(assoc-in [:wallet :accounts] accounts)
|
||||||
(assoc-in [:wallet :networks] network-data)
|
(assoc-in [:wallet :networks] network-data)
|
||||||
|
(assoc :currencies currencies)
|
||||||
(assoc-in [:profile/profile :currency] :usd)))
|
(assoc-in [:profile/profile :currency] :usd)))
|
||||||
|
|
||||||
(let [result (rf/sub [sub-name])
|
(let [result (rf/sub [sub-name])
|
||||||
|
@ -952,6 +965,7 @@
|
||||||
(assoc-in [:wallet :accounts] accounts)
|
(assoc-in [:wallet :accounts] accounts)
|
||||||
(assoc-in [:wallet :networks] network-data)
|
(assoc-in [:wallet :networks] network-data)
|
||||||
(assoc-in [:wallet :current-viewing-account-address] "0x2")
|
(assoc-in [:wallet :current-viewing-account-address] "0x2")
|
||||||
|
(assoc :currencies currencies)
|
||||||
(assoc-in [:profile/profile :currency] :usd)))
|
(assoc-in [:profile/profile :currency] :usd)))
|
||||||
|
|
||||||
(let [result (rf/sub [sub-name])
|
(let [result (rf/sub [sub-name])
|
||||||
|
@ -969,6 +983,7 @@
|
||||||
(assoc-in [:wallet :accounts] accounts-with-tokens)
|
(assoc-in [:wallet :accounts] accounts-with-tokens)
|
||||||
(assoc-in [:wallet :current-viewing-account-address] "0x1")
|
(assoc-in [:wallet :current-viewing-account-address] "0x1")
|
||||||
(assoc-in [:wallet :ui :send :route] route-data)
|
(assoc-in [:wallet :ui :send :route] route-data)
|
||||||
|
(assoc :currencies currencies)
|
||||||
(assoc-in [:profile/profile :currency] :usd)
|
(assoc-in [:profile/profile :currency] :usd)
|
||||||
(assoc-in [:profile/profile :currency-symbol] "$")))
|
(assoc-in [:profile/profile :currency-symbol] "$")))
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
|
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
|
||||||
"owner": "status-im",
|
"owner": "status-im",
|
||||||
"repo": "status-go",
|
"repo": "status-go",
|
||||||
"version": "v0.184.47",
|
"version": "v0.184.48",
|
||||||
"commit-sha1": "83aa01c7daf69d518e624fc584ea22ca27b34b73",
|
"commit-sha1": "0f8e6d0b4e4ebfb1258dacde52d7603ad44c84d4",
|
||||||
"src-sha256": "07gqijx652ap0lf0kvcpd0lxx5x58air19pxgjawwymq2b8kly16"
|
"src-sha256": "0jp91py71marsiiw726518d9pb38dg7wv1di55cc1rjmd312xplx"
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,6 +112,7 @@
|
||||||
"all-addresses": "All addresses",
|
"all-addresses": "All addresses",
|
||||||
"all-changes-will-be-discarded": "All changes in shared addresses for permissions will be discarded.",
|
"all-changes-will-be-discarded": "All changes in shared addresses for permissions will be discarded.",
|
||||||
"all-connections": "All Connections",
|
"all-connections": "All Connections",
|
||||||
|
"all-currencies": "All currencies",
|
||||||
"all-messages": "All messages",
|
"all-messages": "All messages",
|
||||||
"all-networks": "All networks",
|
"all-networks": "All networks",
|
||||||
"all-time": "All time",
|
"all-time": "All time",
|
||||||
|
@ -539,6 +540,7 @@
|
||||||
"create-profile-password-info-box-description": "Your Status keys are the foundation of your self-sovereign identity in Web3. You have complete control over these keys, which you can use to sign transactions, access your data, and interact with Web3 services.\n\nYour keys are always securely stored on your device and protected by your Status profile password. Status doesn't know your password and can't reset it for you. If you forget your password, you may lose access to your Status profile and wallet funds.\n\nRemember your Status password and don't share it with anyone.",
|
"create-profile-password-info-box-description": "Your Status keys are the foundation of your self-sovereign identity in Web3. You have complete control over these keys, which you can use to sign transactions, access your data, and interact with Web3 services.\n\nYour keys are always securely stored on your device and protected by your Status profile password. Status doesn't know your password and can't reset it for you. If you forget your password, you may lose access to your Status profile and wallet funds.\n\nRemember your Status password and don't share it with anyone.",
|
||||||
"create-profile-password-info-box-title": "About your profile password",
|
"create-profile-password-info-box-title": "About your profile password",
|
||||||
"created-group-chat-description": "You created the group {{group-name}}",
|
"created-group-chat-description": "You created the group {{group-name}}",
|
||||||
|
"crypto": "Crypto",
|
||||||
"cryptokitty-name": "CryptoKitty #{{id}}",
|
"cryptokitty-name": "CryptoKitty #{{id}}",
|
||||||
"currency": "Currency",
|
"currency": "Currency",
|
||||||
"currency-display-name-aed": "Emirati Dirham",
|
"currency-display-name-aed": "Emirati Dirham",
|
||||||
|
@ -552,6 +554,7 @@
|
||||||
"currency-display-name-bnd": "Brunei Darussalam Dollar",
|
"currency-display-name-bnd": "Brunei Darussalam Dollar",
|
||||||
"currency-display-name-bob": "Bolivia Bolíviano",
|
"currency-display-name-bob": "Bolivia Bolíviano",
|
||||||
"currency-display-name-brl": "Brazil Real",
|
"currency-display-name-brl": "Brazil Real",
|
||||||
|
"currency-display-name-btc": "Bitcoin",
|
||||||
"currency-display-name-btn": "Bhutanese Ngultrum",
|
"currency-display-name-btn": "Bhutanese Ngultrum",
|
||||||
"currency-display-name-cad": "Canada Dollar",
|
"currency-display-name-cad": "Canada Dollar",
|
||||||
"currency-display-name-chf": "Switzerland Franc",
|
"currency-display-name-chf": "Switzerland Franc",
|
||||||
|
@ -560,10 +563,12 @@
|
||||||
"currency-display-name-cop": "Colombia Peso",
|
"currency-display-name-cop": "Colombia Peso",
|
||||||
"currency-display-name-crc": "Costa Rica Colon",
|
"currency-display-name-crc": "Costa Rica Colon",
|
||||||
"currency-display-name-czk": "Czech Koruna",
|
"currency-display-name-czk": "Czech Koruna",
|
||||||
|
"currency-display-name-dai": "DAI",
|
||||||
"currency-display-name-dkk": "Denmark Krone",
|
"currency-display-name-dkk": "Denmark Krone",
|
||||||
"currency-display-name-dop": "Dominican Republic Peso",
|
"currency-display-name-dop": "Dominican Republic Peso",
|
||||||
"currency-display-name-egp": "Egypt Pound",
|
"currency-display-name-egp": "Egypt Pound",
|
||||||
"currency-display-name-etb": "Ethiopian Birr",
|
"currency-display-name-etb": "Ethiopian Birr",
|
||||||
|
"currency-display-name-eth": "Ethereum",
|
||||||
"currency-display-name-eur": "Euro",
|
"currency-display-name-eur": "Euro",
|
||||||
"currency-display-name-gbp": "British Pound",
|
"currency-display-name-gbp": "British Pound",
|
||||||
"currency-display-name-gel": "Georgian Lari",
|
"currency-display-name-gel": "Georgian Lari",
|
||||||
|
@ -608,6 +613,7 @@
|
||||||
"currency-display-name-sar": "Saudi Arabia Riyal",
|
"currency-display-name-sar": "Saudi Arabia Riyal",
|
||||||
"currency-display-name-sek": "Sweden Krona",
|
"currency-display-name-sek": "Sweden Krona",
|
||||||
"currency-display-name-sgd": "Singapore Dollar",
|
"currency-display-name-sgd": "Singapore Dollar",
|
||||||
|
"currency-display-name-snt": "Status Network Token",
|
||||||
"currency-display-name-thb": "Thailand Baht",
|
"currency-display-name-thb": "Thailand Baht",
|
||||||
"currency-display-name-try": "Turkish Lira",
|
"currency-display-name-try": "Turkish Lira",
|
||||||
"currency-display-name-ttd": "Trinidad and Tobago Dollar",
|
"currency-display-name-ttd": "Trinidad and Tobago Dollar",
|
||||||
|
@ -1901,6 +1907,7 @@
|
||||||
},
|
},
|
||||||
"pinned-messages-empty": "Pinned messages will appear here. To pin a message, press and hold it and tap `Pin`",
|
"pinned-messages-empty": "Pinned messages will appear here. To pin a message, press and hold it and tap `Pin`",
|
||||||
"podcasts": "Podcasts",
|
"podcasts": "Podcasts",
|
||||||
|
"popular-currencies": "Popular currencies",
|
||||||
"positive": "Positive",
|
"positive": "Positive",
|
||||||
"powered-by-paraswap": "Powered by Paraswap",
|
"powered-by-paraswap": "Powered by Paraswap",
|
||||||
"preference": "Preference",
|
"preference": "Preference",
|
||||||
|
@ -2125,6 +2132,7 @@
|
||||||
"search": "Search",
|
"search": "Search",
|
||||||
"search-assets": "Search assets",
|
"search-assets": "Search assets",
|
||||||
"search-contacts": "Search contacts",
|
"search-contacts": "Search contacts",
|
||||||
|
"search-currencies": "Search currencies",
|
||||||
"search-discover-communities": "Search communities or categories",
|
"search-discover-communities": "Search communities or categories",
|
||||||
"search-no-chat-found": "No search results. Do you mean",
|
"search-no-chat-found": "No search results. Do you mean",
|
||||||
"searching-for-activity": "Searching for activity...",
|
"searching-for-activity": "Searching for activity...",
|
||||||
|
@ -2231,8 +2239,8 @@
|
||||||
"share-profile": "Share profile",
|
"share-profile": "Share profile",
|
||||||
"share-profile-link": "Share profile link",
|
"share-profile-link": "Share profile link",
|
||||||
"share-public-chat-text": "Check out this public chat on the Status app: {{link}}",
|
"share-public-chat-text": "Check out this public chat on the Status app: {{link}}",
|
||||||
"share-usage-data": "Share usage data with Status",
|
|
||||||
"share-usage-data": "Share usage data",
|
"share-usage-data": "Share usage data",
|
||||||
|
"share-usage-data-with-status": "Share usage data with Status",
|
||||||
"shared": "Shared",
|
"shared": "Shared",
|
||||||
"shared-a-community": "Shared a community",
|
"shared-a-community": "Shared a community",
|
||||||
"sharing-copied-to-clipboard": "Copied",
|
"sharing-copied-to-clipboard": "Copied",
|
||||||
|
@ -2506,6 +2514,7 @@
|
||||||
"try-again": "Try again",
|
"try-again": "Try again",
|
||||||
"try-keeping-the-card-still": "Try keeping the card still",
|
"try-keeping-the-card-still": "Try keeping the card still",
|
||||||
"try-to-search-something-else": "Try to search something else",
|
"try-to-search-something-else": "Try to search something else",
|
||||||
|
"try-with-different-currency": "Try with a different currency",
|
||||||
"try-your-luck-again": "Try your luck again!",
|
"try-your-luck-again": "Try your luck again!",
|
||||||
"tu": "Tu",
|
"tu": "Tu",
|
||||||
"tue": "Tue",
|
"tue": "Tue",
|
||||||
|
|