Skip to content

Commit bd7da02

Browse files
Implement Wallet Connect 2.0
Signed-off-by: Brian Sztamfater <brian@status.im>
1 parent ece2605 commit bd7da02

File tree

37 files changed

+1752
-70
lines changed

37 files changed

+1752
-70
lines changed

index.js

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
import "node-libs-react-native/globals";
12
import "./app/index.js";

ios/Podfile.lock

+12
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,8 @@ PODS:
208208
- React
209209
- react-native-blob-util (0.13.18):
210210
- React-Core
211+
- react-native-blur (0.8.0):
212+
- React
211213
- react-native-camera-kit (8.0.4):
212214
- React
213215
- react-native-cameraroll (4.0.4):
@@ -224,6 +226,8 @@ PODS:
224226
- React
225227
- react-native-notifications (4.1.3):
226228
- React-Core
229+
- react-native-randombytes (3.6.1):
230+
- React-Core
227231
- react-native-safe-area-context (2.0.0):
228232
- React
229233
- react-native-shake (3.4.0):
@@ -422,13 +426,15 @@ DEPENDENCIES:
422426
- React-jsinspector (from `../node_modules/react-native/ReactCommon/jsinspector`)
423427
- react-native-background-timer (from `../node_modules/react-native-background-timer`)
424428
- react-native-blob-util (from `../node_modules/react-native-blob-util`)
429+
- "react-native-blur (from `../node_modules/@react-native-community/blur`)"
425430
- react-native-camera-kit (from `../node_modules/react-native-camera-kit`)
426431
- "react-native-cameraroll (from `../node_modules/@react-native-community/cameraroll`)"
427432
- react-native-config (from `../node_modules/react-native-config`)
428433
- react-native-image-resizer (from `../node_modules/react-native-image-resizer`)
429434
- react-native-mail (from `../node_modules/react-native-mail`)
430435
- "react-native-netinfo (from `../node_modules/@react-native-community/netinfo`)"
431436
- react-native-notifications (from `../node_modules/react-native-notifications`)
437+
- react-native-randombytes (from `../node_modules/react-native-randombytes`)
432438
- react-native-safe-area-context (from `../node_modules/react-native-safe-area-context`)
433439
- react-native-shake (from `../node_modules/react-native-shake`)
434440
- "react-native-slider (from `../node_modules/@react-native-community/slider`)"
@@ -525,6 +531,8 @@ EXTERNAL SOURCES:
525531
:path: "../node_modules/react-native-background-timer"
526532
react-native-blob-util:
527533
:path: "../node_modules/react-native-blob-util"
534+
react-native-blur:
535+
:path: "../node_modules/@react-native-community/blur"
528536
react-native-camera-kit:
529537
:path: "../node_modules/react-native-camera-kit"
530538
react-native-cameraroll:
@@ -539,6 +547,8 @@ EXTERNAL SOURCES:
539547
:path: "../node_modules/@react-native-community/netinfo"
540548
react-native-notifications:
541549
:path: "../node_modules/react-native-notifications"
550+
react-native-randombytes:
551+
:path: "../node_modules/react-native-randombytes"
542552
react-native-safe-area-context:
543553
:path: "../node_modules/react-native-safe-area-context"
544554
react-native-shake:
@@ -653,13 +663,15 @@ SPEC CHECKSUMS:
653663
React-jsinspector: 58aef7155bc9a9683f5b60b35eccea8722a4f53a
654664
react-native-background-timer: 1f7d560647b40e6a60b01c452ba29c54bf581fc4
655665
react-native-blob-util: 600972b1782380a5a7d5db61a3817ea32349dae9
666+
react-native-blur: cad4d93b364f91e7b7931b3fa935455487e5c33c
656667
react-native-camera-kit: 498a6d111a904834e0824e9073cfadef7303235f
657668
react-native-cameraroll: 88f4e62d9ecd0e1f253abe4f685474f2ea14bfa2
658669
react-native-config: c98128a72bc2c3a1ca72caec0b021f0fa944aa29
659670
react-native-image-resizer: 2f1577efa3bc762597681f530c8e8d05ce0ceeb3
660671
react-native-mail: 8fdcd3aef007c33a6877a18eb4cf7447a1d4ce4a
661672
react-native-netinfo: ddaca8bbb9e6e914b1a23787ccb879bc642931c9
662673
react-native-notifications: 805108822ceff3440644d5701944f0cda35f5b4b
674+
react-native-randombytes: 421f1c7d48c0af8dbcd471b0324393ebf8fe7846
663675
react-native-safe-area-context: 60f654e00b6cc416573f6d5dbfce3839958eb57a
664676
react-native-shake: de052eaa3eadc4a326b8ddd7ac80c06e8d84528c
665677
react-native-slider: 12bd76d3d568c9c5500825db54123d44b48e4ad4

metro.config.js

+3
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,7 @@ module.exports = {
1313
},
1414
}),
1515
},
16+
resolver: {
17+
extraNodeModules: require('node-libs-react-native'),
18+
},
1619
};

package.json

+4
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@
1313
"dependencies": {
1414
"@react-native-community/async-storage": "^1.11.0",
1515
"@react-native-community/audio-toolkit": "git+https://github.com/tbenr/react-native-audio-toolkit.git#v2.0.3-status-v6",
16+
"@react-native-community/blur": "^3.6.0",
1617
"@react-native-community/cameraroll": "git+https://github.com/status-im/react-native-cameraroll.git#v4.0.4-status.0",
1718
"@react-native-community/clipboard": "^1.2.2",
1819
"@react-native-community/hooks": "^2.5.1",
1920
"@react-native-community/masked-view": "^0.1.6",
2021
"@react-native-community/netinfo": "^4.4.0",
2122
"@react-native-community/push-notification-ios": "^1.4.1",
2223
"@react-native-community/slider": "^3.0.0",
24+
"@walletconnect/client": "^2.0.0-beta.23",
2325
"bignumber.js": "git+https://github.com/status-im/bignumber.js.git#v4.0.2-status",
2426
"buffer": "^5.4.2",
2527
"chance": "^1.1.0",
@@ -30,6 +32,7 @@
3032
"hermes-engine": "0.5.2-rc1",
3133
"hi-base32": "^0.5.0",
3234
"i18n-js": "^3.3.0",
35+
"node-libs-react-native": "^1.2.1",
3336
"qrcode": "^1.4.1",
3437
"react": "16.13.1",
3538
"react-dom": "^16.4.2",
@@ -56,6 +59,7 @@
5659
"react-native-navigation": "^7.13.0",
5760
"react-native-notifications": "^4.1.3",
5861
"react-native-permissions": "^2.1.5",
62+
"react-native-randombytes": "^3.6.1",
5963
"react-native-reanimated": "^2.1.0",
6064
"react-native-redash": "^16.0.11",
6165
"react-native-safe-area-context": "^2.0.0",

react-native.config.js

+5
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,10 @@ module.exports = {
2222
ios: null,
2323
},
2424
},
25+
'@react-native-community/blur': {
26+
platforms: {
27+
android: null,
28+
},
29+
},
2530
},
2631
};
469 Bytes
Loading
637 Bytes
Loading
386 Bytes
Loading
539 Bytes
Loading
-89 Bytes
Loading
-144 Bytes
Loading
338 Bytes
Loading
467 Bytes
Loading

src/mocks/js_dependencies.cljs

+12
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,16 @@
213213
(def react-native-notifications
214214
#js {:Notifications #js {}})
215215

216+
(def react-native-blur
217+
(clj->js {:BlurView {}}))
218+
219+
(def wallet-connect-client #js {:default #js {}
220+
:CLIENT_EVENTS #js {:session #js {:request nil
221+
:created nil
222+
:deleted nil
223+
:proposal nil
224+
:updated nil}}})
225+
216226
;; Update i18n_resources.cljs
217227
(defn mock [module]
218228
(case module
@@ -243,12 +253,14 @@
243253
"react-native-linear-gradient" react-native-gradien
244254
"react-native-navigation" react-native-navigation
245255
"@react-native-community/push-notification-ios" push-notification-ios
256+
"@react-native-community/blur" react-native-blur
246257
"react-native-camera-kit" react-native-camera-kit
247258
"rn-emoji-keyboard" rn-emoji-keyboard
248259
"react-native-notifications" react-native-notifications
249260
"react-native-draggable-flatlist" react-native-draggable-flatlist
250261
"./fleets.js" default-fleets
251262
"./chats.js" default-chats
263+
"@walletconnect/client" wallet-connect-client
252264
"../translations/ar.json" (js/JSON.parse (slurp "./translations/ar.json"))
253265
"../translations/de.json" (js/JSON.parse (slurp "./translations/de.json"))
254266
"../translations/en.json" (js/JSON.parse (slurp "./translations/en.json"))

src/quo/components/animated/pressable.cljs

+5-1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@
5757
(defn pressable-hooks [props]
5858
(let [{background-color :bgColor
5959
border-radius :borderRadius
60+
border-color :borderColor
61+
border-width :borderWidth
6062
type :type
6163
disabled :disabled
6264
on-press :onPress
@@ -121,7 +123,9 @@
121123
[animated/view {:style (merge absolute-fill
122124
background
123125
{:background-color background-color
124-
:border-radius border-radius})}]
126+
:border-radius border-radius
127+
:border-color border-color
128+
:border-width border-width})}]
125129
(into [animated/view {:style foreground}]
126130
(react/get-children children))]]]])))
127131

src/quo/components/button/view.cljs

+29-22
Original file line numberDiff line numberDiff line change
@@ -28,27 +28,31 @@
2828

2929
(defn themes [theme]
3030
(case theme
31-
:main {:icon-color (:icon-04 @colors/theme)
32-
:background-color (:interactive-02 @colors/theme)
33-
:text-color (:text-04 @colors/theme)}
34-
:icon {:icon-color (:icon-01 @colors/theme)
35-
:background-color (:interactive-02 @colors/theme)
36-
:text-color (:text-01 @colors/theme)}
37-
:negative {:icon-color (:negative-01 @colors/theme)
38-
:background-color (:negative-02 @colors/theme)
39-
:text-color (:negative-01 @colors/theme)}
40-
:positive {:icon-color (:positive-01 @colors/theme)
41-
:background-color (:positive-02 @colors/theme)
42-
:text-color (:positive-01 @colors/theme)}
43-
:accent {:icon-color (:icon-05 @colors/theme)
44-
:background-color (:interactive-01 @colors/theme)
45-
:text-color (:text-05 @colors/theme)}
46-
:secondary {:icon-color (:icon-02 @colors/theme)
47-
:background-color (:interactive-02 @colors/theme)
48-
:text-color (:text-02 @colors/theme)}
49-
:disabled {:icon-color (:icon-02 @colors/theme)
50-
:background-color (:ui-01 @colors/theme)
51-
:text-color (:text-02 @colors/theme)}))
31+
:main {:icon-color (:icon-04 @colors/theme)
32+
:background-color (:interactive-02 @colors/theme)
33+
:text-color (:text-04 @colors/theme)}
34+
:icon {:icon-color (:icon-01 @colors/theme)
35+
:background-color (:interactive-02 @colors/theme)
36+
:text-color (:text-01 @colors/theme)}
37+
:negative {:icon-color (:negative-01 @colors/theme)
38+
:background-color (:negative-02 @colors/theme)
39+
:text-color (:negative-01 @colors/theme)}
40+
:positive {:icon-color (:positive-01 @colors/theme)
41+
:background-color (:positive-02 @colors/theme)
42+
:text-color (:positive-01 @colors/theme)}
43+
:accent {:icon-color (:icon-05 @colors/theme)
44+
:background-color (:interactive-01 @colors/theme)
45+
:text-color (:text-05 @colors/theme)}
46+
:secondary {:icon-color (:icon-02 @colors/theme)
47+
:background-color (:interactive-02 @colors/theme)
48+
:text-color (:text-02 @colors/theme)}
49+
:disabled {:icon-color (:icon-02 @colors/theme)
50+
:background-color (:ui-01 @colors/theme)
51+
:text-color (:text-02 @colors/theme)}
52+
:monocromatic {:icon-color (:icon-01 @colors/theme)
53+
:background-color (:ui-background @colors/theme)
54+
:text-color (:text-01 @colors/theme)
55+
:border-color (:ui-01 @colors/theme)}))
5256

5357
(defn button [{:keys [on-press disabled type theme before after
5458
haptic-feedback haptic-type on-long-press on-press-start
@@ -62,7 +66,7 @@
6266
(let [theme' (cond
6367
disabled :disabled
6468
:else theme)
65-
{:keys [icon-color background-color text-color]}
69+
{:keys [icon-color background-color text-color border-color]}
6670
(themes theme')
6771

6872
optional-haptic (fn []
@@ -73,6 +77,9 @@
7377
:type type
7478
:disabled disabled
7579
:accessibility-label accessibility-label}
80+
(when border-color
81+
{:border-color border-color
82+
:border-width 1})
7683
(when on-press
7784
{:on-press (fn []
7885
(optional-haptic)

src/quo/design_system/colors.cljs

+6-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
(def light-theme
2121
{:positive-01 "rgba(68,208,88,1)" ; Primary Positive, text, icons color
2222
:positive-02 "rgba(78,188,96,0.1)" ; Secondary Positive, Supporting color for success illustrations
23+
:positive-03 "rgba(78,188,96,1)" ; Lighter Positive, Supporting color for success illustrations
2324
:negative-01 "rgba(255,45,85,1)" ; Primary Negative, text, icons color
2425
:negative-02 "rgba(255,45,85,0.1))" ; Secondary Negative, Supporting color for errors illustrations
2526
:warning-01 "rgba(255, 202, 15, 1)"
@@ -46,11 +47,13 @@
4647
:backdrop "rgba(0,0,0,0.4)" ; Backdrop for modals and bottom sheet
4748
:border-01 "rgba(238,242,245,1)"
4849
:border-02 "rgba(67, 96, 223, 0.1)"
49-
:highlight "rgba(67,96,223,0.4)"})
50+
:highlight "rgba(67,96,223,0.4)"
51+
:blurred-bg "rgba(255,255,255,0.3)"})
5052

5153
(def dark-theme
5254
{:positive-01 "rgba(68,208,88,1)"
5355
:positive-02 "rgba(78,188,96,0.1)"
56+
:positive-03 "rgba(78,188,96,1)"
5457
:negative-01 "rgba(252,95,95,1)"
5558
:negative-02 "rgba(252,95,95,0.1)"
5659
:warning-01 "rgba(255, 202, 15, 1)"
@@ -77,7 +80,8 @@
7780
:backdrop "rgba(0,0,0,0.4)"
7881
:border-01 "rgba(37,37,40,1)"
7982
:border-02 "rgba(97,119,229,0.1)"
80-
:highlight "rgba(67,96,223,0.4)"})
83+
:highlight "rgba(67,96,223,0.4)"
84+
:blurred-bg "rgba(0,0,0,0.3)"})
8185

8286
(def theme (reagent/atom light-theme))
8387

src/status_im/events.cljs

+2-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@
6161
status-im.wallet.custom-tokens.core
6262
[status-im.navigation.core :as navigation.core]
6363
[status-im.multiaccounts.login.core :as login.core]
64-
[status-im.signing.core :as signing]))
64+
[status-im.signing.core :as signing]
65+
status-im.wallet-connect.core))
6566

6667
(re-frame/reg-fx
6768
:dismiss-keyboard

src/status_im/multiaccounts/login/core.cljs

+21-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@
4242
[status-im.ui.components.react :as react]
4343
[status-im.utils.platform :as platform]
4444
[status-im.ethereum.tokens :as tokens]
45-
[clojure.string :as string]))
45+
[clojure.string :as string]
46+
[status-im.utils.wallet-connect :as wallet-connect]))
4647

4748
(re-frame/reg-fx
4849
::initialize-communities-enabled
@@ -82,6 +83,20 @@
8283
(fn []
8384
(status/start-local-notifications)))
8485

86+
(re-frame/reg-fx
87+
::initialize-wallet-connect
88+
(fn []
89+
(wallet-connect/init
90+
#(re-frame/dispatch [:wallet-connect/client-init %])
91+
#(log/error "[wallet-connect]" %))))
92+
93+
(re-frame/reg-fx
94+
::initialize-wallet-connect
95+
(fn []
96+
(async-storage/get-item
97+
:wallet-connect-enabled?
98+
#(re-frame/dispatch [:multiaccounts.ui/switch-wallet-connect-enabled %]))))
99+
85100
(defn rpc->accounts [accounts]
86101
(reduce (fn [acc {:keys [chat type wallet] :as account}]
87102
(if chat
@@ -343,6 +358,10 @@
343358
[cofx]
344359
{::initialize-transactions-management-enabled nil})
345360

361+
(fx/defn initialize-wallet-connect
362+
[cofx]
363+
{::initialize-wallet-connect nil})
364+
346365
(fx/defn get-node-config-callback
347366
{:events [::get-node-config-callback]}
348367
[{:keys [db] :as cofx} node-config-json]
@@ -377,6 +396,7 @@
377396
(acquisition/login)
378397
(initialize-appearance)
379398
(initialize-communities-enabled)
399+
(initialize-wallet-connect)
380400
(get-node-config)
381401
(communities/fetch)
382402
(logging/set-log-level (:log-level multiaccount))

src/status_im/navigation.cljs

+17
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,20 @@
8686
[_]
8787
{:hide-select-acc-sheet nil})
8888

89+
(fx/defn hide-wallet-connect-sheet
90+
{:events [:hide-wallet-connect-sheet]}
91+
[_]
92+
{:hide-wallet-connect-sheet nil})
93+
94+
(fx/defn hide-wallet-connect-success-sheet
95+
{:events [:hide-wallet-connect-success-sheet]}
96+
[_]
97+
{:hide-wallet-connect-success-sheet nil})
98+
99+
(fx/defn hide-wallet-connect-app-management-sheet
100+
{:events [:hide-wallet-connect-app-management-sheet]}
101+
[{:keys [db]}]
102+
{:db (-> db
103+
(assoc db :wallet-connect/showing-app-management-sheet? false)
104+
(dissoc :wallet-connect/session-managed))
105+
:hide-wallet-connect-app-management-sheet nil})

0 commit comments

Comments
 (0)