diff --git a/src/status_im/constants.cljs b/src/status_im/constants.cljs index c03f45a836..e445218932 100644 --- a/src/status_im/constants.cljs +++ b/src/status_im/constants.cljs @@ -161,12 +161,10 @@ :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"} - :bmd {:id :bmd :code "BMD" :display-name (i18n/label :t/currency-display-name-bmd) :symbol "$"} :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."} - :bzd {:id :bzd :code "BZD" :display-name (i18n/label :t/currency-display-name-bzd) :symbol "BZ$"} :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 "$"} @@ -182,8 +180,6 @@ :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 "¢"} - :gmd {:id :gmd :code "GMD" :display-name (i18n/label :t/currency-display-name-gmd) :symbol "D"} - :gyd {:id :gyd :code "GYD" :display-name (i18n/label :t/currency-display-name-gyd) :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"} @@ -196,16 +192,10 @@ :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 "د.ك"} - :kyd {:id :kyd :code "KYD" :display-name (i18n/label :t/currency-display-name-kyd) :symbol "$"} :kzt {:id :kzt :code "KZT" :display-name (i18n/label :t/currency-display-name-kzt) :symbol "лв"} - :lak {:id :lak :code "LAK" :display-name (i18n/label :t/currency-display-name-lak) :symbol "₭"} :lkr {:id :lkr :code "LKR" :display-name (i18n/label :t/currency-display-name-lkr) :symbol "₨"} - :lrd {:id :lrd :code "LRD" :display-name (i18n/label :t/currency-display-name-lrd) :symbol "$"} - :ltl {:id :ltl :code "LTL" :display-name (i18n/label :t/currency-display-name-ltl) :symbol "Lt"} :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"} - :mkd {:id :mkd :code "MKD" :display-name (i18n/label :t/currency-display-name-mkd) :symbol "ден"} - :mnt {:id :mnt :code "MNT" :display-name (i18n/label :t/currency-display-name-mnt) :symbol "₮"} :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 "$"} @@ -213,7 +203,6 @@ :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 "₦"} - :nio {:id :nio :code "NIO" :display-name (i18n/label :t/currency-display-name-nio) :symbol "C$"} :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 "$"} @@ -231,8 +220,6 @@ :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 "$"} - :sos {:id :sos :code "SOS" :display-name (i18n/label :t/currency-display-name-sos) :symbol "S"} - :srd {:id :srd :code "SRD" :display-name (i18n/label :t/currency-display-name-srd) :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$"} @@ -244,7 +231,6 @@ :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 "₫"} - :yer {:id :yer :code "YER" :display-name (i18n/label :t/currency-display-name-yer) :symbol "﷼"} :zar {:id :zar :code "ZAR" :display-name (i18n/label :t/currency-display-name-zar) :symbol "R"}}) ;; Used to generate topic for contact discoveries diff --git a/src/status_im/data_store/realm/schemas/base/core.cljs b/src/status_im/data_store/realm/schemas/base/core.cljs index 0a5d7d34c1..956a3c4a9f 100644 --- a/src/status_im/data_store/realm/schemas/base/core.cljs +++ b/src/status_im/data_store/realm/schemas/base/core.cljs @@ -2,7 +2,8 @@ (:require [status-im.data-store.realm.schemas.base.v1.core :as v1] [status-im.data-store.realm.schemas.base.v2.core :as v2] [status-im.data-store.realm.schemas.base.v3.core :as v3] - [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])) ;; put schemas ordered by version (def schemas [{:schema v1/schema @@ -16,4 +17,7 @@ :migration v3/migration} {:schema v4/schema :schemaVersion 4 - :migration v4/migration}]) + :migration v4/migration} + {:schema v5/schema + :schemaVersion 5 + :migration v5/migration}]) diff --git a/src/status_im/data_store/realm/schemas/base/v5/account.cljs b/src/status_im/data_store/realm/schemas/base/v5/account.cljs new file mode 100644 index 0000000000..76cb01b71d --- /dev/null +++ b/src/status_im/data_store/realm/schemas/base/v5/account.cljs @@ -0,0 +1,33 @@ +(ns status-im.data-store.realm.schemas.base.v5.account + (:require [taoensso.timbre :as log] + [cognitect.transit :as transit] + [clojure.set :as set] + [status-im.data-store.realm.schemas.base.v4.account :as v4])) + +(def schema v4/schema) + +(def removed-tokens + #{:ATMChain :Centra :ROL}) + +(def removed-fiat-currencies + #{:bmd :bzd :gmd :gyd :kyd :lak :lrd :ltl :mkd :mnt :nio :sos :srd :yer}) + +(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 v4") + (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 :mainnet] + #(set/difference % removed-tokens)) + (update-in [:wallet :currency] + #(if (removed-fiat-currencies %) :usd %))) + updated (serialize new-settings)] + (aset account "settings" updated))))) \ No newline at end of file diff --git a/src/status_im/data_store/realm/schemas/base/v5/core.cljs b/src/status_im/data_store/realm/schemas/base/v5/core.cljs new file mode 100644 index 0000000000..bac68ff5fb --- /dev/null +++ b/src/status_im/data_store/realm/schemas/base/v5/core.cljs @@ -0,0 +1,13 @@ +(ns status-im.data-store.realm.schemas.base.v5.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.v5.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 v5: " old-realm new-realm) + (account/migration old-realm new-realm)) diff --git a/src/status_im/utils/ethereum/tokens.cljs b/src/status_im/utils/ethereum/tokens.cljs index faf6863be5..0c924bf67d 100644 --- a/src/status_im/utils/ethereum/tokens.cljs +++ b/src/status_im/utils/ethereum/tokens.cljs @@ -102,10 +102,6 @@ :name "Gnosis Token" :address "0x6810e776880c02933d47db1b9fc05908e5386b96" :decimals 18} - {:symbol :ATMChain - :name "Attention Token of Media" - :address "0x9B11EFcAAA1890f6eE52C6bB7CF8153aC5d74139" - :decimals 8} {:symbol :STORJ :name "StorjToken" :address "0xb64ef51c888972c908cfacf59b47c1afbc0ab8ac" @@ -206,10 +202,6 @@ :name "PILLAR" :address "0xe3818504c1b32bf1557b16c238b2e01fd3149c17" :decimals 18} - {:symbol :Centra - :name "Centra Token" - :address "0x96A65609a7B84E8842732DEB08f56C3E21aC6f8a" - :decimals 18} {:symbol :QRL :name "QRL" :address "0x697beac28b09e122c4332d163985e8a73121b97f" @@ -370,10 +362,26 @@ :name "DomRaider Token" :address "0x9af4f26941677c706cfecf6d3379ff01bb85d5ab" :decimals 8} + ;; NOTE(goranjovic) : the following three tokens are removed from the Manage Assets list + ;; and automatically removed from user's selection by a migration. However, we still need + ;; them listed here in order to correctly display any previous transactions the user had + ;; in their history prior to the upgrade. So, we're just hiding them, not actually deleting from the + ;; app. + {:symbol :Centra + :name "Centra Token" + :address "0x96A65609a7B84E8842732DEB08f56C3E21aC6f8a" + :decimals 18 + :hidden? true} {:symbol :ROL :name "Dice" :address "0x2e071D2966Aa7D8dECB1005885bA1977D6038A65" - :decimals 16}]) + :decimals 16 + :hidden? true} + {:symbol :ATMChain + :name "Attention Token of Media" + :address "0x9B11EFcAAA1890f6eE52C6bB7CF8153aC5d74139" + :decimals 8 + :hidden? true}]) :testnet (resolve-icons :testnet [{:name "Status Test Token" @@ -406,6 +414,7 @@ (defn sorted-tokens-for [chain] (->> (tokens-for chain) + (filter #(not (:hidden? %))) (sort #(compare (string/lower-case (:name %1)) (string/lower-case (:name %2))))))