[#12760] Add Binance Smart chain as main network

Signed-off-by: andrey <motor4ik@gmail.com>
This commit is contained in:
andrey 2021-11-10 13:20:54 +01:00
parent 345ae29ddb
commit a573ae70e5
No known key found for this signature in database
GPG Key ID: 89B67245FD2F0272
8 changed files with 44 additions and 22 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

@ -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]))

View File

@ -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.

View File

@ -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

View File

@ -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

View File

@ -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)])]

View File

@ -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]]))

View File

@ -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",