Skip to content

Commit

Permalink
feat: integrate base chain
Browse files Browse the repository at this point in the history
Signed-off-by: Brian Sztamfater <brian@status.im>
  • Loading branch information
briansztamfater committed Jan 20, 2025
1 parent ef7d977 commit ca954f4
Show file tree
Hide file tree
Showing 19 changed files with 92 additions and 26 deletions.
Binary file added resources/images/networks/Base@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/Base@3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions scripts/build-android.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ SECRETS_ENV_VARS=(
'ALCHEMY_ARBITRUM_SEPOLIA_TOKEN'
'ALCHEMY_OPTIMISM_MAINNET_TOKEN'
'ALCHEMY_OPTIMISM_SEPOLIA_TOKEN'
'ALCHEMY_BASE_MAINNET_TOKEN'
'ALCHEMY_BASE_SEPOLIA_TOKEN'
'RARIBLE_MAINNET_API_KEY'
'RARIBLE_TESTNET_API_KEY'
'INFURA_TOKEN'
Expand Down
10 changes: 8 additions & 2 deletions shadow-cljs.edn
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@
status-im.config/ALCHEMY_ARBITRUM_MAINNET_TOKEN #shadow/env "ALCHEMY_ARBITRUM_MAINNET_TOKEN"
status-im.config/ALCHEMY_ARBITRUM_SEPOLIA_TOKEN #shadow/env "ALCHEMY_ARBITRUM_SEPOLIA_TOKEN"
status-im.config/ALCHEMY_OPTIMISM_MAINNET_TOKEN #shadow/env "ALCHEMY_OPTIMISM_MAINNET_TOKEN"
status-im.config/ALCHEMY_OPTIMISM_SEPOLIA_TOKEN #shadow/env "ALCHEMY_OPTIMISM_SEPOLIA_TOKEN"}
status-im.config/ALCHEMY_OPTIMISM_SEPOLIA_TOKEN #shadow/env "ALCHEMY_OPTIMISM_SEPOLIA_TOKEN"
status-im.config/ALCHEMY_BASE_MAINNET_TOKEN #shadow/env "ALCHEMY_BASE_MAINNET_TOKEN"
status-im.config/ALCHEMY_BASE_SEPOLIA_TOKEN #shadow/env "ALCHEMY_BASE_SEPOLIA_TOKEN"}
:compiler-options {:output-feature-set :es5
;; We disable `:fn-deprecated` warnings because we
;; are managing deprecation via clj-kondo and we
Expand Down Expand Up @@ -123,7 +125,9 @@
status-im.config/ALCHEMY_ARBITRUM_MAINNET_TOKEN #shadow/env "ALCHEMY_ARBITRUM_MAINNET_TOKEN"
status-im.config/ALCHEMY_ARBITRUM_SEPOLIA_TOKEN #shadow/env "ALCHEMY_ARBITRUM_SEPOLIA_TOKEN"
status-im.config/ALCHEMY_OPTIMISM_MAINNET_TOKEN #shadow/env "ALCHEMY_OPTIMISM_MAINNET_TOKEN"
status-im.config/ALCHEMY_OPTIMISM_SEPOLIA_TOKEN #shadow/env "ALCHEMY_OPTIMISM_SEPOLIA_TOKEN"}
status-im.config/ALCHEMY_OPTIMISM_SEPOLIA_TOKEN #shadow/env "ALCHEMY_OPTIMISM_SEPOLIA_TOKEN"
status-im.config/ALCHEMY_BASE_MAINNET_TOKEN #shadow/env "ALCHEMY_BASE_MAINNET_TOKEN"
status-im.config/ALCHEMY_BASE_SEPOLIA_TOKEN #shadow/env "ALCHEMY_BASE_SEPOLIA_TOKEN"}
:compiler-options {:output-feature-set :es6
;;disable for android build as there
;;is an intermittent warning with deftype
Expand Down Expand Up @@ -165,6 +169,8 @@
status-im.config/ALCHEMY_ARBITRUM_SEPOLIA_TOKEN #shadow/env "ALCHEMY_ARBITRUM_SEPOLIA_TOKEN"
status-im.config/ALCHEMY_OPTIMISM_MAINNET_TOKEN #shadow/env "ALCHEMY_OPTIMISM_MAINNET_TOKEN"
status-im.config/ALCHEMY_OPTIMISM_SEPOLIA_TOKEN #shadow/env "ALCHEMY_OPTIMISM_SEPOLIA_TOKEN"
status-im.config/ALCHEMY_BASE_MAINNET_TOKEN #shadow/env "ALCHEMY_BASE_MAINNET_TOKEN"
status-im.config/ALCHEMY_BASE_SEPOLIA_TOKEN #shadow/env "ALCHEMY_BASE_SEPOLIA_TOKEN"
status-im.config/WALLET_CONNECT_PROJECT_ID #shadow/env "WALLET_CONNECT_PROJECT_ID"}
:compiler-options
{;; needed because we override require and it
Expand Down
22 changes: 15 additions & 7 deletions src/quo/components/wallet/summary_info/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,16 @@

(defn networks
[values theme]
(let [{:keys [ethereum optimism arbitrum]} values
show-optimism? (and optimism
(or (pos? (:amount optimism))
(= (:amount optimism) "<0.01")))
show-arbitrum? (and arbitrum
(or (pos? (:amount arbitrum))
(= (:amount arbitrum) "<0.01")))]
(let [{:keys [ethereum optimism arbitrum base]} values
show-optimism? (and optimism
(or (pos? (:amount optimism))
(= (:amount optimism) "<0.01")))
show-arbitrum? (and arbitrum
(or (pos? (:amount arbitrum))
(= (:amount arbitrum) "<0.01")))
show-base? (and base
(or (pos? (:amount base))
(= (:amount base) "<0.01")))]
[rn/view
{:style style/networks-container
:accessibility-label :networks}
Expand All @@ -56,6 +59,11 @@
[network-amount
{:network :arbitrum
:amount (str (:amount arbitrum) " " (or (:token-symbol arbitrum) "ARB"))
:theme theme}])
(when show-base?
[network-amount
{:network :base
:amount (str (:amount base) " " (or (:token-symbol base) "ETH"))
:theme theme}])]))

(defn- view-internal
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 @@ -44,6 +44,7 @@
:hermez (js/require "../resources/images/networks/Hermez.png")
:optimism (js/require "../resources/images/networks/Optimism.png")
:paraswap (js/require "../resources/images/networks/Paraswap.png")
:base (js/require "../resources/images/networks/Base.png")
:polygon (js/require "../resources/images/networks/Polygon.png")
:scroll (js/require "../resources/images/networks/Scroll.png")
:taiko (js/require "../resources/images/networks/Taiko.png")
Expand Down
4 changes: 4 additions & 0 deletions src/status_im/config.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
(goog-define ALCHEMY_ARBITRUM_SEPOLIA_TOKEN "")
(goog-define ALCHEMY_OPTIMISM_MAINNET_TOKEN "")
(goog-define ALCHEMY_OPTIMISM_SEPOLIA_TOKEN "")
(goog-define ALCHEMY_BASE_MAINNET_TOKEN "")
(goog-define ALCHEMY_BASE_SEPOLIA_TOKEN "")
(goog-define WALLET_CONNECT_PROJECT_ID "87815d72a81d739d2a7ce15c2cfdefb3")
(goog-define MIXPANEL_APP_ID "3350627")
(goog-define MIXPANEL_TOKEN "5c73bda2d36a9f688a5ee45641fb6775")
Expand All @@ -38,9 +40,11 @@
(def mainnet-tx-details-base-link "https://etherscan.io/tx")
(def optimism-mainnet-tx-details-base-link "https://optimistic.etherscan.io/tx")
(def arbitrum-mainnet-tx-details-base-link "https://arbiscan.io/tx")
(def base-mainnet-tx-details-base-link "https://basescan.org/tx")
(def mainnet-sepolia-tx-details-base-link "https://sepolia.etherscan.io/tx")
(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 opensea-link "https://opensea.io")
(def opensea-tesnet-link "https://testnets.opensea.io")

Expand Down
13 changes: 10 additions & 3 deletions src/status_im/constants.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -396,41 +396,48 @@
(def ^:const arbitrum-sepolia-chain-id 421614)
(def ^:const optimism-mainnet-chain-id 10)
(def ^:const optimism-sepolia-chain-id 11155420)
(def ^:const base-mainnet-chain-id 8453)
(def ^:const base-sepolia-chain-id 84532)

(def opensea-url-names
{:ethereum "ethereum"
:sepolia "sepolia"})

(def ^:const mainnet-chain-ids
#{ethereum-mainnet-chain-id arbitrum-mainnet-chain-id optimism-mainnet-chain-id})
#{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})
#{ethereum-sepolia-chain-id arbitrum-sepolia-chain-id optimism-sepolia-chain-id base-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 mainnet-abbreviated-name "Eth.")
(def ^:const optimism-abbreviated-name "Oeth.")
(def ^:const arbitrum-abbreviated-name "Arb1.")
(def ^:const base-abbreviated-name "Base")

(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 sepolia-full-name "Sepolia")

(def ^:const mainnet-network-name :mainnet)
(def ^:const ethereum-network-name :ethereum)
(def ^:const optimism-network-name :optimism)
(def ^:const arbitrum-network-name :arbitrum)
(def ^:const base-network-name :base)

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

Expand Down
4 changes: 3 additions & 1 deletion src/status_im/contexts/profile/config.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
:alchemyOptimismMainnetToken config/ALCHEMY_OPTIMISM_MAINNET_TOKEN
:alchemyOptimismSepoliaToken config/ALCHEMY_OPTIMISM_SEPOLIA_TOKEN
:alchemyArbitrumMainnetToken config/ALCHEMY_ARBITRUM_MAINNET_TOKEN
:alchemyArbitrumSepoliaToken config/ALCHEMY_ARBITRUM_SEPOLIA_TOKEN})
:alchemyArbitrumSepoliaToken config/ALCHEMY_ARBITRUM_SEPOLIA_TOKEN
:alchemyBaseMainnetToken config/ALCHEMY_BASE_MAINNET_TOKEN
:alchemyBaseSepoliaToken config/ALCHEMY_BASE_SEPOLIA_TOKEN})

(defn create
[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
[{: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)}])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
constants/optimism-mainnet-chain-id
config/optimism-mainnet-tx-details-base-link

constants/base-mainnet-chain-id
config/base-mainnet-tx-details-base-link

constants/ethereum-sepolia-chain-id
config/mainnet-sepolia-tx-details-base-link

Expand All @@ -46,6 +49,9 @@
constants/optimism-sepolia-chain-id
config/optimism-sepolia-tx-details-base-link

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

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

(defn get-link-to-tx-details
Expand Down
28 changes: 25 additions & 3 deletions src/status_im/contexts/wallet/common/utils/networks.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
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/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})

(defn- get-chain-id
[{:keys [mainnet-chain-id sepolia-chain-id testnet-enabled?]}]
Expand Down Expand Up @@ -46,6 +48,12 @@
(get-chain-id
{:mainnet-chain-id constants/arbitrum-mainnet-chain-id
:sepolia-chain-id constants/arbitrum-sepolia-chain-id
:testnet-enabled? testnet-enabled?})

#{constants/base-network-name (keyword constants/base-short-name)}
(get-chain-id
{:mainnet-chain-id constants/base-mainnet-chain-id
:sepolia-chain-id constants/base-sepolia-chain-id
:testnet-enabled? testnet-enabled?}))))

(defn network-list
Expand Down Expand Up @@ -76,12 +84,14 @@
{constants/mainnet-network-name constants/mainnet-short-name
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/ethereum-network-name constants/ethereum-short-name
constants/base-network-name constants/base-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/arbitrum-short-name constants/arbitrum-network-name
constants/base-short-name constants/base-network-name})

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

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

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

#{constants/base-mainnet-chain-id constants/base-sepolia-chain-id}
base-network-details

nil)
(when $
(assoc $ :chain-id chain-id))))
Expand Down
3 changes: 2 additions & 1 deletion src/status_im/contexts/wallet/send/utils.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@
(def ^:private network-priority-score
{:ethereum 1
:optimism 2
:arbitrum 3})
:arbitrum 3
:base 4})

(defn reset-loading-network-amounts-to-zero
[network-amounts]
Expand Down
4 changes: 1 addition & 3 deletions src/status_im/contexts/wallet/swap/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,7 @@
(fn [{:keys [db]} [{:keys [sent-transactions swap-data approval-transaction?]}]]
(let [wallet-transactions (get-in db [:wallet :transactions] {})
transactions (utils/transactions->hash-to-transaction-map sent-transactions)
transaction-ids (->> transactions
vals
(map :hash))
transaction-ids (keys transactions)
transaction-id (first transaction-ids)
transaction-details (cond-> transactions
:always (assoc-in [transaction-id :tx-type] :swap)
Expand Down
2 changes: 1 addition & 1 deletion src/status_im/subs/wallet/wallet_test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,7 @@
(swap! rf-db/app-db #(assoc % :wallet db/defaults))
(is
(match? (sort [constants/ethereum-mainnet-chain-id constants/arbitrum-mainnet-chain-id
constants/optimism-mainnet-chain-id])
constants/optimism-mainnet-chain-id constants/base-mainnet-chain-id])
(sort (rf/sub [sub-name])))))
(testing "selected networks -> chain-ids - specific network"
(swap! rf-db/app-db #(assoc-in %
Expand Down
4 changes: 3 additions & 1 deletion src/tests/contract_test/wallet_test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,11 @@
(is (some #(= constants/ethereum-mainnet-chain-id (get-in % [:Prod :chainId])) response))
(is (some #(= constants/optimism-mainnet-chain-id (get-in % [:Prod :chainId])) response))
(is (some #(= constants/arbitrum-mainnet-chain-id (get-in % [:Prod :chainId])) response))
(is (some #(= constants/base-mainnet-chain-id (get-in % [:Prod :chainId])) response))
(is (some #(= constants/ethereum-sepolia-chain-id (get-in % [:Test :chainId])) response))
(is (some #(= constants/arbitrum-sepolia-chain-id (get-in % [:Test :chainId])) response))
(is (some #(= constants/optimism-sepolia-chain-id (get-in % [:Test :chainId])) response)))
(is (some #(= constants/optimism-sepolia-chain-id (get-in % [:Test :chainId])) response))
(is (some #(= constants/base-sepolia-chain-id (get-in % [:Test :chainId])) response)))

(deftest accounts-get-chains-contract-test
(h/test-async :contract/wallet_get-ethereum-chains
Expand Down
3 changes: 2 additions & 1 deletion src/utils/ethereum/chain.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
:bsc-testnet {:id BSC-testnet-chain-id
:name "BSC testnet"}
:arbitrum {:id 42161 :name "Arbitrum"}
:optimism {:id 10 :name "Optimism"}})
:optimism {:id 10 :name "Optimism"}
:base {:id 8453 :name "Base"}})

(defn chain-id->chain-keyword
[i]
Expand Down
6 changes: 3 additions & 3 deletions status-go-version.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
"owner": "status-im",
"repo": "status-go",
"version": "v9.0.0",
"commit-sha1": "59caca61960752c464cf21de99103c8649dfb0c5",
"src-sha256": "008qmdkgf9vxpz0q57his9wmlkahykcnyrq6qbcpjqfvk55cq5gr"
"version": "v9.1.0",
"commit-sha1": "4ec885a91f2857a30d1838213000f0a5a91fd52a",
"src-sha256": "1fkvhazv7v2vyqpffx3r4p3aii5ai464nx2pdfgn6b6gmb24bxdq"
}
3 changes: 3 additions & 0 deletions translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@
"backup-through-waku": "Backup through waku",
"bad-fees-description": "Your priority fee is below our suggested parameters.",
"balance": "Balance",
"base": "Base",
"be-safe-with-secure-cold-wallet": "Be safe with secure cold wallet",
"begin-set-up": "Begin setup",
"below-base-fee": "max fee below base fee",
Expand Down Expand Up @@ -2390,6 +2391,7 @@
"share-invite-link": "Share an invite link",
"share-link": "Share link",
"share-link-to-arb": "Share link to Arbiscan",
"share-link-to-base": "Share link to Basescan",
"share-link-to-eth": "Share link to Etherscan",
"share-link-to-oeth": "Share link to Optimism Explorer",
"share-logs": "Share logs",
Expand Down Expand Up @@ -2818,6 +2820,7 @@
"view-gitcoin": "View in Gitcoin",
"view-members": "View members",
"view-on-arb": "View on Arbiscan",
"view-on-base": "View on Basescan",
"view-on-eth": "View on Etherscan",
"view-on-oeth": "View on Optimism Explorer",
"view-on-opensea": "View on OpenSea",
Expand Down

0 comments on commit ca954f4

Please sign in to comment.