Skip to content

Commit 54d6978

Browse files
feat(wallet)_: Add BNB Smart Chain (#22417)
This commit - adds support for BNB Smart Chain - removes categorisation (L1/L2) of chains in settings and token network selection --------- Signed-off-by: Mohamed Javid <[email protected]> Co-authored-by: Shivek Khurana <[email protected]>
1 parent 2ddb642 commit 54d6978

File tree

41 files changed

+447
-325
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+447
-325
lines changed
1012 Bytes
Loading
1.4 KB
Loading

src/quo/components/utilities/token/loader.cljs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,18 @@
55
(def ^:private tokens (loader/resolve-tokens))
66
(def ^:private safe-lower-case (comp string/lower-case str))
77

8+
;; NOTE: temporarily workaround added to show USDC and USDT on different chains
9+
;; with different decimals. This should be removed when the we move to CoinGecko API
10+
(def ^:private tokens-with-different-decimals #{"usdc (evm)" "usdc (bsc)" "usdt (evm)" "usdt (bsc)"})
11+
812
(defn- get-token-image*
913
[token]
10-
(let [token-symbol (cond-> token
11-
(keyword? token) name
12-
:always safe-lower-case)]
14+
(let [lower-case-token-symbol (cond-> token
15+
(keyword? token) name
16+
:always safe-lower-case)
17+
token-symbol (if (tokens-with-different-decimals lower-case-token-symbol)
18+
(-> (string/split lower-case-token-symbol #" ") first)
19+
lower-case-token-symbol)]
1320
(get tokens token-symbol)))
1421

1522
(def get-token-image (memoize get-token-image*))

src/quo/foundations/resources.cljs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838

3939
(def ^:private networks
4040
{:arbitrum (js/require "../resources/images/networks/Arbitrum.png")
41+
:bsc (js/require "../resources/images/networks/Binance.png")
4142
:ethereum (js/require "../resources/images/networks/Ethereum.png")
4243
:mainnet (js/require "../resources/images/networks/Ethereum.png")
4344
:gnosis (js/require "../resources/images/networks/Gnosis.png")

src/status_im/constants.cljs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,8 @@
414414

415415
(def ^:const bridge-name-hop "Hop")
416416

417-
(def ^:const bridge-assets #{"ETH" "USDT" "USDC" "DAI"})
417+
;; remove the decimal from the token symbol once we move to CoinGecko token list
418+
(def ^:const bridge-assets #{"ETH" "USDT (EVM)" "USDC (EVM)" "DAI"})
418419

419420
(def ^:const wallet-contract-type-erc-1155 3)
420421

@@ -449,8 +450,6 @@
449450
(def ^:const swap-tokens-my :my)
450451
(def ^:const swap-tokens-popular :popular)
451452

452-
(def ^:const token-for-fees-symbol "ETH")
453-
454453
;; The 15% buffer accounts for Ethereum's EIP-1559 fee mechanism, where the base fee can increase
455454
;; by up to 12.5% per block in periods of high congestion. The extra 2.5% provides additional
456455
;; safety to prevent failed transactions due to rapid gas price fluctuations.
@@ -480,8 +479,6 @@
480479

481480
(def ^:const wallet-connect-transaction-refresh-interval-ms 10000)
482481

483-
(def ^:const native-token-symbol "ETH")
484-
485482
;; About app links
486483
(def ^:const status-app-url "http://status.app")
487484
(def ^:const go-waku-url "https://github.com/waku-org/go-waku")

src/status_im/contexts/wallet/bridge/bridge_to/view.cljs

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
[status-im.contexts.wallet.bridge.bridge-to.style :as style]
88
[status-im.contexts.wallet.common.account-switcher.view :as account-switcher]
99
[status-im.contexts.wallet.common.utils :as utils]
10-
[status-im.contexts.wallet.networks.core :as networks]
1110
[status-im.setup.hot-reload :as hot-reload]
1211
[utils.i18n :as i18n]
1312
[utils.re-frame :as rf]))
@@ -42,21 +41,19 @@
4241

4342
(defn view
4443
[]
45-
(let [account (rf/sub [:wallet/current-viewing-account])
46-
token (rf/sub [:wallet/wallet-send-token])
47-
network (rf/sub [:wallet/send-network])
48-
network-name (:full-name network)
49-
token-symbol (:symbol token)
50-
tokens (:tokens account)
51-
to-networks (rf/sub [:wallet/bridge-to-networks])
52-
mainnet (-> to-networks :layer-1 first)
53-
layer-2-networks (:layer-2 to-networks)
54-
account-token (some #(when (= token-symbol (:symbol %)) %) tokens)
55-
account-token (when account-token
56-
(assoc account-token
57-
:networks (:networks token)
58-
:supported-networks (:supported-networks token)))
59-
bridge-to-title (i18n/label :t/select-network-to-receive)]
44+
(let [account (rf/sub [:wallet/current-viewing-account])
45+
token (rf/sub [:wallet/wallet-send-token])
46+
network (rf/sub [:wallet/send-network])
47+
network-name (:full-name network)
48+
token-symbol (:symbol token)
49+
tokens (:tokens account)
50+
to-networks (rf/sub [:wallet/bridge-to-networks])
51+
account-token (some #(when (= token-symbol (:symbol %)) %) tokens)
52+
account-token (when account-token
53+
(assoc account-token
54+
:networks (:networks token)
55+
:supported-networks (:supported-networks token)))
56+
bridge-to-title (i18n/label :t/select-network-to-receive)]
6057
(hot-reload/use-safe-unmount #(rf/dispatch [:wallet/clean-bridge-to-selection]))
6158
[rn/view
6259
[account-switcher/view
@@ -84,12 +81,8 @@
8481
:type :network
8582
:network-logo (:source network)
8683
:size 24}]]
87-
(when-not (networks/eth-mainnet? network)
88-
[rn/view style/content-container
89-
[bridge-token-component (assoc mainnet :network-name :t/mainnet) account-token]])
90-
[quo/divider-label (i18n/label :t/layer-2)]
9184
[rn/flat-list
92-
{:data layer-2-networks
85+
{:data to-networks
9386
:render-fn (fn [network]
9487
[bridge-token-component network account-token])
9588
:content-container-style style/content-container}]]))

src/status_im/contexts/wallet/bridge/select_asset/view.cljs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
[status-im.contexts.wallet.bridge.select-asset.style :as style]
77
[status-im.contexts.wallet.common.account-switcher.view :as account-switcher]
88
[status-im.contexts.wallet.common.asset-list.view :as asset-list]
9+
[status-im.contexts.wallet.networks.core :as networks]
910
[utils.i18n :as i18n]
1011
[utils.re-frame :as rf]))
1112

@@ -28,6 +29,7 @@
2829
:placeholder (i18n/label :t/search-assets)}]
2930
[asset-list/view
3031
{:search-text @search-text
32+
:chain-ids (networks/get-bridge-supported-networks)
3133
:on-token-press (fn [token]
3234
(rf/dispatch [:wallet/bridge-select-token
3335
{:token token

src/status_im/contexts/wallet/collectible/options/view.cljs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
(defn view
99
[{:keys [image name id]}]
1010
(let [chain-id (get-in id [:contract-id :chain-id])
11-
{:keys [block-explorer-name]} (rf/sub [:wallet/network-details-by-chain-id chain-id])
11+
{:keys [block-explorer-name]} (rf/sub [:wallet/network-by-id chain-id])
1212
token-id (:token-id id)
1313
contract-address (get-in id [:contract-id :address])
1414
uri (url/replace-port image (rf/sub [:mediaserver/port]))]
@@ -41,10 +41,3 @@
4141
:contract-address contract-address
4242
:chain-id chain-id
4343
:title name}])}]]]))
44-
45-
"222"
46-
"https://nft-cdn.alchemy.com/eth-mainnet/219530f9b3a7901f02169334d593823e"
47-
"Tengria #913"
48-
{:contract-id {:chain-id 1 :address "0x1a4ceef5d575c2228d142ef862a9b60be8161e7f"} :token-id "913"}
49-
50-
{:contract-id {:chain-id 1 :address "0x1a4ceef5d575c2228d142ef862a9b60be8161e7f"} :token-id "913"}

src/status_im/contexts/wallet/common/collectibles_tab/view.cljs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,9 @@
9898
:render-fn collectible-item
9999
:on-end-reached on-end-reached
100100
:key-fn :unique-id
101+
:header [quo/information-box
102+
{:type :default
103+
:icon :i/info
104+
:style {:margin-horizontal 10}}
105+
(i18n/label :t/bsc-collectibles-not-supported)]
101106
:on-end-reached-threshold 4}]))))

src/status_im/contexts/wallet/common/token_value/view.cljs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
(:require [quo.core :as quo]
33
[status-im.contexts.wallet.send.utils :as send-utils]
44
[status-im.contexts.wallet.sheets.buy-token.view :as buy-token]
5-
[status-im.contexts.wallet.swap.utils :as swap-utils]
65
[status-im.feature-flags :as ff]
76
[utils.i18n :as i18n]
87
[utils.money :as money]
@@ -49,17 +48,17 @@
4948
(rf/dispatch [:wallet/bridge-select-token params]))})
5049

5150
(defn- action-swap
52-
[{:keys [token asset-to-receive token-symbol testnet-mode?]}]
51+
[{:keys [token token-symbol testnet-mode?]}]
5352
{:icon :i/transaction
5453
:accessibility-label :swap
5554
:label (i18n/label :t/swap)
5655
:disabled? testnet-mode?
5756
:on-press (fn []
5857
(rf/dispatch [:hide-bottom-sheet])
5958
(rf/dispatch [:wallet/clean-send-data])
59+
(rf/dispatch [:wallet/clean-swap])
6060
(rf/dispatch [:wallet.swap/start
6161
{:asset-to-pay (or token {:symbol token-symbol})
62-
:asset-to-receive asset-to-receive
6362
:open-new-screen? true}]))})
6463

6564
(defn- action-manage-tokens
@@ -88,8 +87,6 @@
8887
account-owns-token? (rf/sub [:wallet/current-account-owns-token token-symbol])
8988
networks (rf/sub [:wallet/active-networks])
9089
token-owned? (if selected-account account-owns-token? (seq token-owners))
91-
asset-to-receive (rf/sub [:wallet/token-by-symbol-from-first-available-account-with-balance
92-
(swap-utils/default-asset-to-receive token-symbol)])
9390
unique-owner? (= (count token-owners) 1)
9491
params (cond-> {:start-flow? true
9592
:owners token-owners
@@ -118,9 +115,7 @@
118115
(action-send params entry-point))
119116
(action-receive selected-account)
120117
(when token-owned?
121-
(action-swap (assoc params
122-
:asset-to-receive
123-
asset-to-receive)))
118+
(action-swap params))
124119
(when token-owned?
125120
(action-bridge (assoc params
126121
:networks

0 commit comments

Comments
 (0)