diff --git a/resources/images/tokens/bsc/0-native.png b/resources/images/tokens/bsc/0-native.png new file mode 100644 index 0000000000..e715b87e05 Binary files /dev/null and b/resources/images/tokens/bsc/0-native.png differ diff --git a/src/status_im/ethereum/core.cljs b/src/status_im/ethereum/core.cljs index 739d7df0d1..bfe7d71d61 100644 --- a/src/status_im/ethereum/core.cljs +++ b/src/status_im/ethereum/core.cljs @@ -25,7 +25,8 @@ :rinkeby {:id 4 :name "Rinkeby"} :xdai {:id 100 :name "xDai"} :poa {:id 99 :name "POA"} - :goerli {:id 5 :name "Goerli"}}) + :goerli {:id 5 :name "Goerli"} + :bsc {:id 56 :name "BSC"}}) (defn chain-id->chain-keyword [i] (or (some #(when (= i (:id (val %))) (key %)) chains) @@ -50,7 +51,8 @@ (defn sidechain? [id] (contains? #{(chain-keyword->chain-id :xdai) - (chain-keyword->chain-id :poa)} id)) + (chain-keyword->chain-id :poa) + (chain-keyword->chain-id :bsc)} id)) (defn network-with-upstream-rpc? [network] (get-in network [:config :UpstreamConfig :Enabled])) diff --git a/src/status_im/ethereum/macros.clj b/src/status_im/ethereum/macros.clj index f492b6bb0d..7dce3f213f 100644 --- a/src/status_im/ethereum/macros.clj +++ b/src/status_im/ethereum/macros.clj @@ -34,19 +34,20 @@ tokens)) (defn network->icon [network] - (let [s (str "../resources/images/tokens/" (name network) "/0-native.png") + (let [s (str "./resources/images/tokens/" (name network) "/0-native.png") + s-js (str "." s) image (gensym)] (if (.exists (io/file s)) `(let [~image (atom nil)] (fn [] (or @~image - (reset! ~image (js/require ~s))))) + (reset! ~image (js/require ~s-js))))) `(let [~image (atom nil)] (fn [] (or @~image (reset! ~image - (js/require "../resources/images/tokens/default-native.png")))))))) + (js/require "../resources/images/tokens/default-token.png")))))))) (defmacro resolve-native-currency-icons "In react-native arguments to require must be static strings. diff --git a/src/status_im/ethereum/tokens.cljs b/src/status_im/ethereum/tokens.cljs index a8685fbae3..0ec2150c11 100644 --- a/src/status_im/ethereum/tokens.cljs +++ b/src/status_im/ethereum/tokens.cljs @@ -6,10 +6,10 @@ (def default-native-currency (memoize (fn [] - {:name "Native" - :symbol :ETH - :decimals 18 - :icon {:source (js/require "../resources/images/tokens/default-native.png")}}))) + {:name "Native" + :symbol :ETH + :decimals 18 + :icon {:source (js/require "../resources/images/tokens/default-token.png")}}))) (def snt-icon-source (js/require "../resources/images/tokens/mainnet/SNT.png")) @@ -34,6 +34,10 @@ :symbol :ETH :symbol-display :xDAI :symbol-exchange :DAI + :decimals 18} + :bsc {:name "BSC" + :symbol :ETH + :symbol-display :BNB :decimals 18}})) (def native-currency-symbols diff --git a/src/status_im/multiaccounts/login/core.cljs b/src/status_im/multiaccounts/login/core.cljs index 6a5195b6eb..79d2a07549 100644 --- a/src/status_im/multiaccounts/login/core.cljs +++ b/src/status_im/multiaccounts/login/core.cljs @@ -300,17 +300,20 @@ (let [{:networks/keys [current-network networks] :as settings} (data-store.settings/rpc->settings settings) - multiaccount (dissoc settings :networks/current-network :networks/networks)] + multiaccount (dissoc settings :networks/current-network :networks/networks) + ;;for some reason we save default networks in db, in case when we want to modify default-networks for + ;; existing accounts we have to merge them again into networks + merged-networks (merge networks config/default-networks-by-id)] (fx/merge cofx {:db (-> db (dissoc :multiaccounts/login) (assoc :networks/current-network current-network - :networks/networks networks + :networks/networks merged-networks :multiaccount multiaccount))} (data-store.chats/fetch-chats-rpc {:on-success #(do (re-frame/dispatch [:chats-list/load-success %]) - (re-frame/dispatch [::get-chats-callback settings]))}) + (re-frame/dispatch [::get-chats-callback]))}) (acquisition/login) (initialize-appearance) (initialize-communities-enabled) @@ -321,9 +324,9 @@ (fx/defn get-chats-callback {:events [::get-chats-callback]} - [{:keys [db] :as cofx} settings] - (let [{:keys [notifications-enabled?] - :networks/keys [current-network networks]} settings + [{:keys [db] :as cofx}] + (let [{:networks/keys [current-network networks]} db + notifications-enabled? (get-in db [:multiaccount :notifications-enabled?]) network-id (str (get-in networks [current-network :config :NetworkId]))] (fx/merge cofx (cond-> {::eip1559/check-eip1559-activation diff --git a/src/status_im/ui/screens/wallet/account/views.cljs b/src/status_im/ui/screens/wallet/account/views.cljs index 2068769a4d..d70d4ef132 100644 --- a/src/status_im/ui/screens/wallet/account/views.cljs +++ b/src/status_im/ui/screens/wallet/account/views.cljs @@ -101,17 +101,21 @@ (views/letsubs [{:keys [tokens]} [:wallet/visible-assets-with-values address] currency [:wallet/currency] opensea-enabled? [:opensea-enabled?] - collectible-collection [:wallet/collectible-collection address]] + collectible-collection [:wallet/collectible-collection address] + mainnet? [:mainnet?]] (let [{:keys [tab]} @state] [react/view {:flex 1} [react/view {:flex-direction :row :margin-bottom 8 :padding-horizontal 4} [tabs/tab-title state :assets (i18n/label :t/wallet-assets) (= tab :assets)] - [tabs/tab-title state :nft (i18n/label :t/wallet-collectibles) (= tab :nft)] - [tabs/tab-title state :history (i18n/label :t/history) (= tab :history)]] + (when mainnet? + [tabs/tab-title state :nft (i18n/label :t/wallet-collectibles) (= tab :nft)]) + (when mainnet? + [tabs/tab-title state :history (i18n/label :t/history) (= tab :history)])] (cond (= tab :assets) [:<> - [buy-crypto/banner] + (when mainnet? + [buy-crypto/banner]) (for [item tokens] ^{:key (:name item)} [accounts/render-asset item nil nil (:code currency)])] diff --git a/src/status_im/ui/screens/wallet/accounts/views.cljs b/src/status_im/ui/screens/wallet/accounts/views.cljs index a496afd85b..cd7bd146c0 100644 --- a/src/status_im/ui/screens/wallet/accounts/views.cljs +++ b/src/status_im/ui/screens/wallet/accounts/views.cljs @@ -216,7 +216,8 @@ :onRefresh refresh-action}])) (defn accounts-overview [] - (let [mnemonic @(re-frame/subscribe [:mnemonic])] + (let [mnemonic @(re-frame/subscribe [:mnemonic]) + mainnet? @(re-frame/subscribe [:mainnet?])] [react/view {:style {:flex 1}} [quo/animated-header @@ -235,7 +236,8 @@ :icon :main-icons/more :accessibility-label :accounts-more-options}]} [accounts] - [buy-crypto/banner] + (when mainnet? + [buy-crypto/banner]) [assets] [react/view {:height 68}]] [send-button]])) diff --git a/src/status_im/utils/config.cljs b/src/status_im/utils/config.cljs index 1c4a269d68..608efecab6 100644 --- a/src/status_im/utils/config.cljs +++ b/src/status_im/utils/config.cljs @@ -114,7 +114,13 @@ :config {:NetworkId (ethereum/chain-keyword->chain-id :poa) :DataDir "/ethereum/poa_rpc" :UpstreamConfig {:Enabled true - :URL "https://core.poa.network"}}}]) + :URL "https://core.poa.network"}}} + {:id "bsc_rpc", + :name "BSC Network", + :config {:NetworkId (ethereum/chain-keyword->chain-id :bsc) + :DataDir "/ethereum/bsc_rpc" + :UpstreamConfig {:Enabled true + :URL "https://bsc-dataseed.binance.org"}}}]) (def testnet-networks [{:id "testnet_rpc",