Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(wallet)_: Add status network sepolia #22267

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added resources/images/networks/Status@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/images/networks/Status@3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion src/quo/components/wallet/summary_info/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
{:ethereum "ETH"
:optimism "OP"
:arbitrum "ARB"
:base "ETH"})
:base "ETH"
:status "ETH"})

(defn networks
[networks-to-show theme]
Expand Down
1 change: 1 addition & 0 deletions src/quo/foundations/resources.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
:base (js/require "../resources/images/networks/Base.png")
:polygon (js/require "../resources/images/networks/Polygon.png")
:scroll (js/require "../resources/images/networks/Scroll.png")
:status (js/require "../resources/images/networks/Status.png")
:taiko (js/require "../resources/images/networks/Taiko.png")
:unknown (js/require "../resources/images/networks/Unknown.png")
:xdai (js/require "../resources/images/networks/xDAI.png")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(ns status-im.common.standard-authentication.events-test
(:require [cljs.test :refer [deftest is are testing]]
(:require [cljs.test :refer [are deftest is testing]]
matcher-combinators.test
[status-im.common.standard-authentication.events :as sut]))

Expand Down
2 changes: 2 additions & 0 deletions src/status_im/config.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
(def optimism-sepolia-tx-details-base-link "https://sepolia-optimistic.etherscan.io/tx")
(def arbitrum-sepolia-tx-details-base-link "https://sepolia.arbiscan.io/tx")
(def base-sepolia-tx-details-base-link "https://sepolia.basescan.org/tx")
(def status-network-sepolia-chain-explorer-base-link "https://sepoliascan.status.network/address/")
(def status-network-sepolia-tx-details-base-link "https://sepoliascan.status.network/tx")
(def opensea-link "https://opensea.io")
(def opensea-tesnet-link "https://testnets.opensea.io")

Expand Down
14 changes: 7 additions & 7 deletions src/status_im/constants.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@
(def ^:const optimism-sepolia-chain-id 11155420)
(def ^:const base-mainnet-chain-id 8453)
(def ^:const base-sepolia-chain-id 84532)
(def ^:const status-network-sepolia-chain-id 1660990954)

(def opensea-url-names
{:ethereum "ethereum"
Expand All @@ -402,23 +403,27 @@
#{ethereum-mainnet-chain-id arbitrum-mainnet-chain-id optimism-mainnet-chain-id base-mainnet-chain-id})

(def ^:const sepolia-chain-ids
#{ethereum-sepolia-chain-id arbitrum-sepolia-chain-id optimism-sepolia-chain-id base-sepolia-chain-id})
#{ethereum-sepolia-chain-id arbitrum-sepolia-chain-id optimism-sepolia-chain-id base-sepolia-chain-id
status-network-sepolia-chain-id})

(def ^:const mainnet-short-name "eth")
(def ^:const ethereum-short-name "eth")
(def ^:const optimism-short-name "oeth")
(def ^:const arbitrum-short-name "arb1")
(def ^:const base-short-name "base")
(def ^:const status-network-short-name "status")

(def ^:const mainnet-abbreviated-name "Eth.")
(def ^:const optimism-abbreviated-name "Oeth.")
(def ^:const arbitrum-abbreviated-name "Arb1.")
(def ^:const base-abbreviated-name "Base")
(def ^:const status-network-abbreviated-name "Status")

(def ^:const mainnet-full-name "Mainnet")
(def ^:const optimism-full-name "Optimism")
(def ^:const arbitrum-full-name "Arbitrum")
(def ^:const base-full-name "Base")
(def ^:const status-network-full-name "Status Network")

(def ^:const sepolia-full-name "Sepolia")

Expand All @@ -427,22 +432,17 @@
(def ^:const optimism-network-name :optimism)
(def ^:const arbitrum-network-name :arbitrum)
(def ^:const base-network-name :base)
(def ^:const status-network-name :status)

(def ^:const layer-1-network 1)
(def ^:const layer-2-network 2)

(def ^:const default-network-names
[mainnet-network-name optimism-network-name arbitrum-network-name base-network-name])

(def ^:const default-network-count (count default-network-names))

(def ^:const chain-id-separator ":")

(def ^:const account-default-customization-color :blue)

(def ^:const wallet-account-name-max-length 20)


(def ^:const gas-rate-low 0)
(def ^:const gas-rate-medium 1)
(def ^:const gas-rate-high 2)
Expand Down
40 changes: 23 additions & 17 deletions src/status_im/contexts/settings/wallet/network_settings/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@

(defn make-network-settings-item
[{:keys [details testnet-label testnet-mode?]}]
(let [{:keys [network-name]} details]
(let [{:keys [network-name full-name]} details]
(cond-> {:blur? true
:title (i18n/label network-name)
:title full-name
:image :icon-avatar
:image-props {:icon (resources/get-network network-name)
:size :size-20}}
Expand All @@ -38,21 +38,27 @@

(defn layer-2-settings
[{:keys [networks testnet-mode?]}]
[quo/category
{:key :layer-2-settings
:label (i18n/label :t/layer-2)
:data (map make-network-settings-item
[{:details (:optimism networks)
:testnet-mode? testnet-mode?
:testnet-label (i18n/label :t/sepolia-active)}
{:details (:base networks)
:testnet-mode? testnet-mode?
:testnet-label (i18n/label :t/sepolia-active)}
{:details (:arbitrum networks)
:testnet-mode? testnet-mode?
:testnet-label (i18n/label :t/sepolia-active)}])
:blur? true
:list-type :settings}])
(let [network-items [{:details (:arbitrum networks)
:testnet-mode? testnet-mode?
:testnet-label (i18n/label :t/sepolia-active)}
{:details (:base networks)
:testnet-mode? testnet-mode?
:testnet-label (i18n/label :t/sepolia-active)}
{:details (:optimism networks)
:testnet-mode? testnet-mode?
:testnet-label (i18n/label :t/sepolia-active)}]
network-items (if (and testnet-mode? (not-empty (:status networks)))
(conj network-items
{:details (:status networks)
:testnet-mode? testnet-mode?
:testnet-label (i18n/label :t/sepolia-active)})
network-items)]
[quo/category
{:key :layer-2-settings
:label (i18n/label :t/layer-2)
:data (map make-network-settings-item network-items)
:blur? true
:list-type :settings}]))

(defn testnet-mode-setting
[{:keys [testnet-mode? on-enable on-disable]}]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@

(defn view
[{:keys [name address customization-color] :as opts}]
(let [open-send-flow (rn/use-callback
(let [test-networks-enabled? (rf/sub [:profile/test-networks-enabled?])
open-send-flow (rn/use-callback
(fn []
(rf/dispatch [:wallet/init-send-flow-for-address
{:address address
Expand Down Expand Up @@ -41,6 +42,11 @@
{:address address
:network constants/base-network-name}])
[address])
open-status-chain-explorer (rn/use-callback
#(rf/dispatch [:wallet/navigate-to-chain-explorer
{:address address
:network constants/status-network-name}])
[address])
open-share (rn/use-callback
#(rf/dispatch
[:open-share
Expand Down Expand Up @@ -105,6 +111,13 @@
:blur? true
:on-press open-base-chain-explorer
:accessibility-label :view-address-on-basescan}
(when test-networks-enabled?
{:icon :i/link
:right-icon :i/external
:label (i18n/label :t/view-address-on-status-explorer)
:blur? true
:on-press open-status-chain-explorer
:accessibility-label :view-address-on-status-explorer})
{:icon :i/share
:on-press open-share
:label (i18n/label :t/share-address)
Expand Down
12 changes: 11 additions & 1 deletion src/status_im/contexts/wallet/account/tabs/about/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
(defn about-options
[]
(let [{:keys [address] :as account} (rf/sub [:wallet/current-viewing-account])
share-title (str (:name account) " " (i18n/label :t/address))]
share-title (str (:name account) " " (i18n/label :t/address))
testnet-mode? (rf/sub [:profile/test-networks-enabled?])]
[quo/action-drawer
[[{:icon :i/link
:accessibility-label :view-on-eth
Expand Down Expand Up @@ -48,6 +49,15 @@
[:wallet/navigate-to-chain-explorer-from-bottom-sheet
config/base-mainnet-chain-explorer-link
address])}
(when testnet-mode?
{:icon :i/link
:accessibility-label :view-on-status-explorer
:label (i18n/label :t/view-on-status-explorer)
:right-icon :i/external
:on-press #(rf/dispatch
[:wallet/navigate-to-chain-explorer-from-bottom-sheet
config/status-network-sepolia-chain-explorer-base-link
address])})
{:icon :i/copy
:accessibility-label :copy-address
:label (i18n/label :t/copy-address)
Expand Down
4 changes: 2 additions & 2 deletions src/status_im/contexts/wallet/common/utils.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,8 @@

(defn make-network-item
"This function generates props for quo/category component item"
[{:keys [network-name color on-change networks label-props type blur?]}]
(cond-> {:title (string/capitalize (name network-name))
[{:keys [network-name full-name color on-change networks label-props type blur?]}]
(cond-> {:title full-name
:image :icon-avatar
:image-props {:icon (resources/get-network network-name)
:size :size-20}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
constants/base-sepolia-chain-id
config/base-sepolia-chain-explorer-link

constants/status-network-sepolia-chain-id
config/status-network-sepolia-chain-explorer-base-link

config/mainnet-chain-explorer-link))

(defn get-base-url-for-tx-details-by-chain-id
Expand Down Expand Up @@ -58,6 +61,9 @@
constants/base-sepolia-chain-id
config/base-sepolia-tx-details-base-link

constants/status-network-sepolia-chain-id
config/status-network-sepolia-tx-details-base-link

config/mainnet-tx-details-base-link))

(defn get-link-to-tx-details
Expand Down
48 changes: 35 additions & 13 deletions src/status_im/contexts/wallet/common/utils/networks.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@
(def ^:private max-network-prefixes 2)

(def id->network
{constants/ethereum-mainnet-chain-id constants/mainnet-network-name
constants/ethereum-sepolia-chain-id constants/mainnet-network-name
constants/optimism-mainnet-chain-id constants/optimism-network-name
constants/optimism-sepolia-chain-id constants/optimism-network-name
constants/arbitrum-mainnet-chain-id constants/arbitrum-network-name
constants/arbitrum-sepolia-chain-id constants/arbitrum-network-name
constants/base-mainnet-chain-id constants/base-network-name
constants/base-sepolia-chain-id constants/base-network-name})
{constants/ethereum-mainnet-chain-id constants/mainnet-network-name
constants/ethereum-sepolia-chain-id constants/mainnet-network-name
constants/optimism-mainnet-chain-id constants/optimism-network-name
constants/optimism-sepolia-chain-id constants/optimism-network-name
constants/arbitrum-mainnet-chain-id constants/arbitrum-network-name
constants/arbitrum-sepolia-chain-id constants/arbitrum-network-name
constants/base-mainnet-chain-id constants/base-network-name
constants/base-sepolia-chain-id constants/base-network-name
constants/status-network-sepolia-chain-id constants/status-network-name})

(defn- get-chain-id
[{:keys [mainnet-chain-id sepolia-chain-id testnet-enabled?]}]
Expand Down Expand Up @@ -54,6 +55,13 @@
(get-chain-id
{:mainnet-chain-id constants/base-mainnet-chain-id
:sepolia-chain-id constants/base-sepolia-chain-id
:testnet-enabled? testnet-enabled?})

#{constants/status-network-name (keyword constants/status-network-short-name)}
(get-chain-id
;; TODO: Update mainnet chain ID when Status Network Mainnet is launched
{:mainnet-chain-id 0
:sepolia-chain-id constants/status-network-sepolia-chain-id
:testnet-enabled? testnet-enabled?}))))

(defn network-list
Expand Down Expand Up @@ -85,13 +93,15 @@
constants/optimism-network-name constants/optimism-short-name
constants/arbitrum-network-name constants/arbitrum-short-name
constants/ethereum-network-name constants/ethereum-short-name
constants/base-network-name constants/base-short-name})
constants/base-network-name constants/base-short-name
constants/status-network-name constants/status-network-short-name})

(def short-name->network
{constants/mainnet-short-name constants/mainnet-network-name
constants/optimism-short-name constants/optimism-network-name
constants/arbitrum-short-name constants/arbitrum-network-name
constants/base-short-name constants/base-network-name})
{constants/mainnet-short-name constants/mainnet-network-name
constants/optimism-short-name constants/optimism-network-name
constants/arbitrum-short-name constants/arbitrum-network-name
constants/base-short-name constants/base-network-name
constants/status-network-short-name constants/status-network-name})

(defn short-names->network-preference-prefix
[short-names]
Expand Down Expand Up @@ -171,6 +181,15 @@
:view-on-block-explorer-label :t/view-on-base
:link-to-block-explorer-label :t/share-link-to-base})

(def status-network-details
{:source (resources/get-network constants/status-network-name)
:short-name constants/status-network-short-name
:full-name constants/status-network-full-name
:network-name constants/status-network-name
:abbreviated-name constants/status-network-abbreviated-name
:view-on-block-explorer-label :t/view-on-status-explorer
:link-to-block-explorer-label :t/share-link-to-status-explorer})

(defn get-network-details
[chain-id]
(as-> chain-id $
Expand All @@ -187,6 +206,9 @@
#{constants/base-mainnet-chain-id constants/base-sepolia-chain-id}
base-network-details

#{constants/status-network-sepolia-chain-id}
status-network-details

nil)
(when $
(assoc $ :chain-id chain-id))))
Expand Down
45 changes: 26 additions & 19 deletions src/status_im/contexts/wallet/data_store.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -115,25 +115,32 @@

(defn rpc->network
[network]
(-> network
(set/rename-keys
{:Prod :prod
:Test :test
:isTest :test?
:tokenOverrides :token-overrides
:rpcUrl :rpc-url
:chainColor :chain-color
:chainName :chain-name
:nativeCurrencyDecimals :native-currency-decimals
:relatedChainId :related-chain-id
:shortName :short-name
:chainId :chain-id
:originalFallbackURL :original-fallback-url
:originalRpcUrl :original-rpc-url
:fallbackURL :fallback-url
:blockExplorerUrl :block-explorer-url
:nativeCurrencySymbol :native-currency-symbol
:nativeCurrencyName :native-currency-symbol})))
(set/rename-keys network
{:isTest :test?
:tokenOverrides :token-overrides
:rpcUrl :rpc-url
:chainColor :chain-color
:chainName :chain-name
:nativeCurrencyDecimals :native-currency-decimals
:relatedChainId :related-chain-id
:shortName :short-name
:chainId :chain-id
:originalFallbackURL :original-fallback-url
:originalRpcUrl :original-rpc-url
:fallbackURL :fallback-url
:blockExplorerUrl :block-explorer-url
:nativeCurrencySymbol :native-currency-symbol
:nativeCurrencyName :native-currency-symbol}))

(defn rpc->networks
[networks]
(reduce
(fn [result {:keys [Prod Test]}]
(cond-> result
Prod (update :prod (fnil conj []) (rpc->network Prod))
Test (update :test (fnil conj []) (rpc->network Test))))
{:prod [] :test []}
networks))

(defn partially-operable-accounts?
[accounts]
Expand Down
10 changes: 2 additions & 8 deletions src/status_im/contexts/wallet/db.cljs
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
(ns status-im.contexts.wallet.db
(:require [status-im.constants :as constants]))

(def network-filter-defaults
{:selector-state :default
:selected-networks (set constants/default-network-names)})
(ns status-im.contexts.wallet.db)

(def defaults
{:ui {:network-filter network-filter-defaults
;; Note: we set it to nil by default to differentiate when the user logs
{:ui {;; Note: we set it to nil by default to differentiate when the user logs
;; in and the device is offline, versus re-fetching when offline and
;; tokens already exist in the app-db.
:tokens-loading nil
Expand Down
Loading