Skip to content

Commit 94e492f

Browse files
feat: integrate base chain
Signed-off-by: Brian Sztamfater <[email protected]>
1 parent 5dc1bfe commit 94e492f

File tree

19 files changed

+173
-180
lines changed

19 files changed

+173
-180
lines changed
2.73 KB
Loading
4.17 KB
Loading

src/quo/components/wallet/summary_info/view.cljs

+15-7
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,16 @@
3030

3131
(defn networks
3232
[values theme]
33-
(let [{:keys [ethereum optimism arbitrum]} values
34-
show-optimism? (and optimism
35-
(or (pos? (:amount optimism))
36-
(= (:amount optimism) "<0.01")))
37-
show-arbitrum? (and arbitrum
38-
(or (pos? (:amount arbitrum))
39-
(= (:amount arbitrum) "<0.01")))]
33+
(let [{:keys [ethereum optimism arbitrum base]} values
34+
show-optimism? (and optimism
35+
(or (pos? (:amount optimism))
36+
(= (:amount optimism) "<0.01")))
37+
show-arbitrum? (and arbitrum
38+
(or (pos? (:amount arbitrum))
39+
(= (:amount arbitrum) "<0.01")))
40+
show-base? (and base
41+
(or (pos? (:amount base))
42+
(= (:amount base) "<0.01")))]
4043
[rn/view
4144
{:style style/networks-container
4245
:accessibility-label :networks}
@@ -56,6 +59,11 @@
5659
[network-amount
5760
{:network :arbitrum
5861
:amount (str (:amount arbitrum) " " (or (:token-symbol arbitrum) "ARB"))
62+
:theme theme}])
63+
(when show-base?
64+
[network-amount
65+
{:network :base
66+
:amount (str (:amount base) " " (or (:token-symbol base) "ETH"))
5967
:theme theme}])]))
6068

6169
(defn- view-internal

src/quo/foundations/resources.cljs

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
:hermez (js/require "../resources/images/networks/Hermez.png")
4545
:optimism (js/require "../resources/images/networks/Optimism.png")
4646
:paraswap (js/require "../resources/images/networks/Paraswap.png")
47+
:base (js/require "../resources/images/networks/Base.png")
4748
:polygon (js/require "../resources/images/networks/Polygon.png")
4849
:scroll (js/require "../resources/images/networks/Scroll.png")
4950
:taiko (js/require "../resources/images/networks/Taiko.png")

src/status_im/constants.cljs

+10-3
Original file line numberDiff line numberDiff line change
@@ -396,41 +396,48 @@
396396
(def ^:const arbitrum-sepolia-chain-id 421614)
397397
(def ^:const optimism-mainnet-chain-id 10)
398398
(def ^:const optimism-sepolia-chain-id 11155420)
399+
(def ^:const base-mainnet-chain-id 8453)
400+
(def ^:const base-sepolia-chain-id 84532)
399401

400402
(def opensea-url-names
401403
{:ethereum "ethereum"
402404
:sepolia "sepolia"})
403405

404406
(def ^:const mainnet-chain-ids
405-
#{ethereum-mainnet-chain-id arbitrum-mainnet-chain-id optimism-mainnet-chain-id})
407+
#{ethereum-mainnet-chain-id arbitrum-mainnet-chain-id optimism-mainnet-chain-id base-mainnet-chain-id})
406408

407409
(def ^:const sepolia-chain-ids
408-
#{ethereum-sepolia-chain-id arbitrum-sepolia-chain-id optimism-sepolia-chain-id})
410+
#{ethereum-sepolia-chain-id arbitrum-sepolia-chain-id optimism-sepolia-chain-id base-sepolia-chain-id})
409411

410412
(def ^:const mainnet-short-name "eth")
411413
(def ^:const ethereum-short-name "eth")
412414
(def ^:const optimism-short-name "oeth")
413415
(def ^:const arbitrum-short-name "arb1")
416+
(def ^:const base-short-name "base")
414417

415418
(def ^:const mainnet-abbreviated-name "Eth.")
416419
(def ^:const optimism-abbreviated-name "Oeth.")
417420
(def ^:const arbitrum-abbreviated-name "Arb1.")
421+
(def ^:const base-abbreviated-name "Base")
418422

419423
(def ^:const mainnet-full-name "Mainnet")
420424
(def ^:const optimism-full-name "Optimism")
421425
(def ^:const arbitrum-full-name "Arbitrum")
426+
(def ^:const base-full-name "Base")
422427

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

425430
(def ^:const mainnet-network-name :mainnet)
426431
(def ^:const ethereum-network-name :ethereum)
427432
(def ^:const optimism-network-name :optimism)
428433
(def ^:const arbitrum-network-name :arbitrum)
434+
(def ^:const base-network-name :base)
429435

430436
(def ^:const layer-1-network 1)
431437
(def ^:const layer-2-network 2)
432438

433-
(def ^:const default-network-names [mainnet-network-name optimism-network-name arbitrum-network-name])
439+
(def ^:const default-network-names
440+
[mainnet-network-name optimism-network-name arbitrum-network-name base-network-name])
434441

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

src/status_im/contexts/settings/wallet/saved_addresses/events_test.cljs

+80-89
Original file line numberDiff line numberDiff line change
@@ -28,30 +28,28 @@
2828
:removed false})
2929

3030
(def saved-address-1
31-
{:test? true
32-
:address "0x1"
33-
:mixedcase-address "0x1"
34-
:chain-short-names "eth:oeth:"
35-
:network-preferences-names `(:mainnet :optimism)
36-
:name "Bob"
37-
:created-at 1716826714
38-
:ens ""
39-
:ens? false
40-
:customization-color :blue
41-
:removed? false})
31+
{:test? true
32+
:address "0x1"
33+
:mixedcase-address "0x1"
34+
:chain-short-names "eth:oeth:"
35+
:name "Bob"
36+
:created-at 1716826714
37+
:ens ""
38+
:ens? false
39+
:customization-color :blue
40+
:removed? false})
4241

4342
(def saved-address-2
44-
{:test? false
45-
:address "0x2"
46-
:mixedcase-address "0x2"
47-
:chain-short-names "eth:arb1:oeth:"
48-
:network-preferences-names `(:mainnet :arbitrum :optimism)
49-
:name "Alicia Keys"
50-
:created-at 1716826806
51-
:ens "alicia.eth"
52-
:ens? true
53-
:customization-color :purple
54-
:removed? false})
43+
{:test? false
44+
:address "0x2"
45+
:mixedcase-address "0x2"
46+
:chain-short-names "eth:arb1:oeth:"
47+
:name "Alicia Keys"
48+
:created-at 1716826806
49+
:ens "alicia.eth"
50+
:ens? true
51+
:customization-color :purple
52+
:removed? false})
5553

5654
(deftest get-saved-addresses-success-test
5755
(let [cofx {:db {}}
@@ -76,17 +74,16 @@
7674
effects (events/reconcile-saved-addresses cofx [[saved-address-1]])
7775
result-db (:db effects)
7876
expected-db {:wallet {:saved-addresses
79-
{:test {"0x1" {:test? true
80-
:address "0x1"
81-
:mixedcase-address "0x1"
82-
:chain-short-names "eth:oeth:"
83-
:ens? false
84-
:network-preferences-names `(:mainnet :optimism)
85-
:name "Bob"
86-
:created-at 1716826714
87-
:ens ""
88-
:customization-color :blue
89-
:removed? false}}
77+
{:test {"0x1" {:test? true
78+
:address "0x1"
79+
:mixedcase-address "0x1"
80+
:chain-short-names "eth:oeth:"
81+
:ens? false
82+
:name "Bob"
83+
:created-at 1716826714
84+
:ens ""
85+
:customization-color :blue
86+
:removed? false}}
9087
:prod {}}}}]
9188
(is (match? expected-db result-db))))
9289

@@ -95,72 +92,66 @@
9592
effects (events/reconcile-saved-addresses cofx [[saved-address-1 saved-address-2]])
9693
result-db (:db effects)
9794
expected-db {:wallet {:saved-addresses
98-
{:test {"0x1" {:test? true
99-
:address "0x1"
100-
:mixedcase-address "0x1"
101-
:chain-short-names "eth:oeth:"
102-
:ens? false
103-
:network-preferences-names `(:mainnet :optimism)
104-
:name "Bob"
105-
:created-at 1716826714
106-
:ens ""
107-
:customization-color :blue
108-
:removed? false}}
109-
:prod {"0x2" {:test? false
110-
:address "0x2"
111-
:mixedcase-address "0x2"
112-
:chain-short-names "eth:arb1:oeth:"
113-
:network-preferences-names `(:mainnet :arbitrum :optimism)
114-
:ens? true
115-
:name "Alicia Keys"
116-
:created-at 1716826806
117-
:ens "alicia.eth"
118-
:customization-color :purple
119-
:removed? false}}}}}]
95+
{:test {"0x1" {:test? true
96+
:address "0x1"
97+
:mixedcase-address "0x1"
98+
:chain-short-names "eth:oeth:"
99+
:ens? false
100+
:name "Bob"
101+
:created-at 1716826714
102+
:ens ""
103+
:customization-color :blue
104+
:removed? false}}
105+
:prod {"0x2" {:test? false
106+
:address "0x2"
107+
:mixedcase-address "0x2"
108+
:chain-short-names "eth:arb1:oeth:"
109+
:ens? true
110+
:name "Alicia Keys"
111+
:created-at 1716826806
112+
:ens "alicia.eth"
113+
:customization-color :purple
114+
:removed? false}}}}}]
120115
(is (match? expected-db result-db))))
121116

122117
(testing "remove a test saved addresses"
123118
(let [cofx {:db {:wallet {:saved-addresses
124-
{:test {"0x1" {:test? true
125-
:address "0x1"
126-
:mixedcase-address "0x1"
127-
:chain-short-names "eth:oeth:"
128-
:ens? false
129-
:network-preferences-names `(:mainnet :optimism)
130-
:name "Bob"
131-
:created-at 1716826714
132-
:ens ""
133-
:customization-color :blue
134-
:removed? false}}
135-
:prod {"0x2" {:test? false
136-
:address "0x2"
137-
:mixedcase-address "0x2"
138-
:chain-short-names "eth:arb1:oeth:"
139-
:network-preferences-names `(:mainnet :arbitrum
140-
:optimism)
141-
:ens? true
142-
:name "Alicia Keys"
143-
:created-at 1716826806
144-
:ens "alicia.eth"
145-
:customization-color :purple
146-
:removed? false}}}}}}
119+
{:test {"0x1" {:test? true
120+
:address "0x1"
121+
:mixedcase-address "0x1"
122+
:chain-short-names "eth:oeth:"
123+
:ens? false
124+
:name "Bob"
125+
:created-at 1716826714
126+
:ens ""
127+
:customization-color :blue
128+
:removed? false}}
129+
:prod {"0x2" {:test? false
130+
:address "0x2"
131+
:mixedcase-address "0x2"
132+
:chain-short-names "eth:arb1:oeth:"
133+
:ens? true
134+
:name "Alicia Keys"
135+
:created-at 1716826806
136+
:ens "alicia.eth"
137+
:customization-color :purple
138+
:removed? false}}}}}}
147139
effects (events/reconcile-saved-addresses cofx
148140
[[(assoc saved-address-1 :removed? true)
149141
saved-address-2]])
150142
result-db (:db effects)
151143
expected-db {:wallet {:saved-addresses
152144
{:test {}
153-
:prod {"0x2" {:test? false
154-
:address "0x2"
155-
:mixedcase-address "0x2"
156-
:chain-short-names "eth:arb1:oeth:"
157-
:network-preferences-names `(:mainnet :arbitrum :optimism)
158-
:ens? true
159-
:name "Alicia Keys"
160-
:created-at 1716826806
161-
:ens "alicia.eth"
162-
:customization-color :purple
163-
:removed? false}}}}}]
145+
:prod {"0x2" {:test? false
146+
:address "0x2"
147+
:mixedcase-address "0x2"
148+
:chain-short-names "eth:arb1:oeth:"
149+
:ens? true
150+
:name "Alicia Keys"
151+
:created-at 1716826806
152+
:ens "alicia.eth"
153+
:customization-color :purple
154+
:removed? false}}}}}]
164155
(is (match? expected-db result-db)))))
165156

166157
(deftest save-address-test

src/status_im/contexts/settings/wallet/saved_addresses/save_address/view.cljs

+2-3
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,14 @@
3636
(defn view
3737
[]
3838
(let [{:keys [edit?]} (rf/sub [:get-screen-params])
39-
{:keys [address name customization-color ens ens? network-preferences-names]}
39+
{:keys [address name customization-color ens ens?]}
4040
(rf/sub [:wallet/saved-address])
4141
[network-prefixes address-without-prefix] (utils/split-prefix-and-address address)
4242
[address-label set-address-label] (rn/use-state (or name ""))
4343
[address-color set-address-color] (rn/use-state (or customization-color
4444
(rand-nth colors/account-colors)))
4545
[selected-networks set-selected-networks]
46-
(rn/use-state (or network-preferences-names
47-
(network-utils/network-preference-prefix->network-names network-prefixes)))
46+
(rn/use-state (network-utils/network-preference-prefix->network-names network-prefixes))
4847
chain-short-names (rn/use-memo
4948
#(network-utils/network-names->network-preference-prefix
5049
selected-networks)

0 commit comments

Comments
 (0)