Skip to content

Commit

Permalink
feat(suite-native): add walletconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
martykan committed Feb 6, 2025
1 parent 849bd9a commit 1ce5c0e
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 0 deletions.
7 changes: 7 additions & 0 deletions suite-native/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"dependencies": {
"@gorhom/bottom-sheet": "5.0.5",
"@mobily/ts-belt": "^3.13.1",
"@react-native-async-storage/async-storage": "^2.1.1",
"@react-native-community/netinfo": "^11.4.1",
"@react-native/metro-config": "^0.76.1",
"@react-navigation/bottom-tabs": "6.6.1",
Expand All @@ -42,6 +43,7 @@
"@suite-common/token-definitions": "workspace:*",
"@suite-common/wallet-core": "workspace:*",
"@suite-common/wallet-types": "workspace:*",
"@suite-common/walletconnect": "workspace:*",
"@suite-native/accounts": "workspace:*",
"@suite-native/alerts": "workspace:*",
"@suite-native/analytics": "workspace:*",
Expand Down Expand Up @@ -83,6 +85,7 @@
"@trezor/styles": "workspace:*",
"@trezor/theme": "workspace:*",
"@trezor/trezor-user-env-link": "workspace:*",
"@walletconnect/react-native-compat": "^2.18.0",
"@whatwg-node/events": "0.1.2",
"abortcontroller-polyfill": "1.7.6",
"buffer": "^6.0.3",
Expand All @@ -104,13 +107,15 @@
"expo-system-ui": "^4.0.2",
"expo-updates": "0.26.6",
"expo-video": "^2.0.1",
"fast-text-encoding": "^1.0.6",
"lottie-react-native": "^7.1.0",
"node-libs-browser": "^2.2.1",
"react": "18.2.0",
"react-intl": "^6.6.8",
"react-native": "0.76.1",
"react-native-edge-to-edge": "^1.3.1",
"react-native-gesture-handler": "^2.21.0",
"react-native-get-random-values": "^1.11.0",
"react-native-keyboard-aware-scroll-view": "0.9.5",
"react-native-mmkv": "2.12.2",
"react-native-quick-crypto": "^0.7.6",
Expand All @@ -132,8 +137,10 @@
"@react-native/babel-preset": "^0.75.2",
"@suite-common/test-utils": "workspace:^",
"@trezor/connect-mobile": "workspace:^",
"@types/fast-text-encoding": "^1",
"@types/jest": "^29.5.12",
"@types/node": "22.10.1",
"@types/react-native-get-random-values": "^1",
"babel-plugin-transform-inline-environment-variables": "^0.4.4",
"babel-plugin-transform-remove-console": "^6.9.4",
"detox": "^20.25.6",
Expand Down
5 changes: 5 additions & 0 deletions suite-native/app/src/initActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import {
initStakeDataThunk,
periodicFetchFiatRatesThunk,
} from '@suite-common/wallet-core';
// WalletConnect and its polyfills for RN
import '@walletconnect/react-native-compat';
import { walletConnectInitThunk } from '@suite-common/walletconnect';
import { initAnalyticsThunk } from '@suite-native/analytics';
import { selectFiatCurrencyCode } from '@suite-native/settings';
import { setIsAppReady, setIsConnectInitialized } from '@suite-native/state/src/appSlice';
Expand Down Expand Up @@ -47,6 +50,8 @@ export const applicationInit = createThunk(
}),
);

dispatch(walletConnectInitThunk());

// Create Portfolio Tracker device if it doesn't exist
dispatch(createImportedDeviceThunk());
} catch (error) {
Expand Down
3 changes: 3 additions & 0 deletions suite-native/app/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
{
"path": "../../suite-common/wallet-types"
},
{
"path": "../../suite-common/walletconnect"
},
{ "path": "../accounts" },
{ "path": "../alerts" },
{ "path": "../analytics" },
Expand Down
1 change: 1 addition & 0 deletions suite-native/state/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"@suite-common/toast-notifications": "workspace:*",
"@suite-common/token-definitions": "workspace:*",
"@suite-common/wallet-core": "workspace:*",
"@suite-common/walletconnect": "workspace:*",
"@suite-native/blockchain": "workspace:*",
"@suite-native/device": "workspace:*",
"@suite-native/device-authorization": "workspace:*",
Expand Down
3 changes: 3 additions & 0 deletions suite-native/state/src/reducers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
prepareStakeReducer,
prepareTransactionsReducer,
} from '@suite-common/wallet-core';
import { prepareWalletConnectReducer } from '@suite-common/walletconnect';
import { deviceAuthorizationReducer } from '@suite-native/device-authorization';
import {
DiscoveryConfigState,
Expand Down Expand Up @@ -63,6 +64,7 @@ const sendFormReducer = sendFormSlice.prepareReducer(extraDependencies);
const stakeReducer = prepareStakeReducer(extraDependencies);
const firmwareReducer = prepareFirmwareReducer(extraDependencies);
const connectPopupReducer = prepareConnectPopupReducer(extraDependencies);
const walletConnectReducer = prepareWalletConnectReducer(extraDependencies);

export const prepareRootReducers = async () => {
const appSettingsPersistedReducer = await preparePersistReducer({
Expand All @@ -85,6 +87,7 @@ export const prepareRootReducers = async () => {
fees: feesReducer,
stake: stakeReducer,
connectPopup: connectPopupReducer,
walletConnect: walletConnectReducer,
});

const walletPersistedReducer = await preparePersistReducer({
Expand Down
3 changes: 3 additions & 0 deletions suite-native/state/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
{
"path": "../../suite-common/wallet-core"
},
{
"path": "../../suite-common/walletconnect"
},
{ "path": "../blockchain" },
{ "path": "../device" },
{ "path": "../device-authorization" },
Expand Down
98 changes: 98 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6885,6 +6885,17 @@ __metadata:
languageName: node
linkType: hard

"@react-native-async-storage/async-storage@npm:^2.1.1":
version: 2.1.1
resolution: "@react-native-async-storage/async-storage@npm:2.1.1"
dependencies:
merge-options: "npm:^3.0.4"
peerDependencies:
react-native: ^0.0.0-0 || >=0.65 <1.0
checksum: 10/ae65d10606e2ba307dc7a4362612c3568fdae3833dae407810c2f457ab1a6ec2c50f2979c8afbf6477b56c8033b8f332038c54e617165618d1b5305e91784300
languageName: node
linkType: hard

"@react-native-community/cli-clean@npm:15.1.2":
version: 15.1.2
resolution: "@react-native-community/cli-clean@npm:15.1.2"
Expand Down Expand Up @@ -10537,6 +10548,7 @@ __metadata:
"@gorhom/bottom-sheet": "npm:5.0.5"
"@jest/globals": "npm:^29.7.0"
"@mobily/ts-belt": "npm:^3.13.1"
"@react-native-async-storage/async-storage": "npm:^2.1.1"
"@react-native-community/cli": "npm:^15.1.2"
"@react-native-community/netinfo": "npm:^11.4.1"
"@react-native/babel-preset": "npm:^0.75.2"
Expand All @@ -10559,6 +10571,7 @@ __metadata:
"@suite-common/token-definitions": "workspace:*"
"@suite-common/wallet-core": "workspace:*"
"@suite-common/wallet-types": "workspace:*"
"@suite-common/walletconnect": "workspace:*"
"@suite-native/accounts": "workspace:*"
"@suite-native/alerts": "workspace:*"
"@suite-native/analytics": "workspace:*"
Expand Down Expand Up @@ -10601,8 +10614,11 @@ __metadata:
"@trezor/styles": "workspace:*"
"@trezor/theme": "workspace:*"
"@trezor/trezor-user-env-link": "workspace:*"
"@types/fast-text-encoding": "npm:^1"
"@types/jest": "npm:^29.5.12"
"@types/node": "npm:22.10.1"
"@types/react-native-get-random-values": "npm:^1"
"@walletconnect/react-native-compat": "npm:^2.18.0"
"@whatwg-node/events": "npm:0.1.2"
abortcontroller-polyfill: "npm:1.7.6"
babel-plugin-transform-inline-environment-variables: "npm:^0.4.4"
Expand All @@ -10628,6 +10644,7 @@ __metadata:
expo-system-ui: "npm:^4.0.2"
expo-updates: "npm:0.26.6"
expo-video: "npm:^2.0.1"
fast-text-encoding: "npm:^1.0.6"
jest: "npm:^29.7.0"
jest-junit: "npm:^16.0.0"
lottie-react-native: "npm:^7.1.0"
Expand All @@ -10638,6 +10655,7 @@ __metadata:
react-native: "npm:0.76.1"
react-native-edge-to-edge: "npm:^1.3.1"
react-native-gesture-handler: "npm:^2.21.0"
react-native-get-random-values: "npm:^1.11.0"
react-native-keyboard-aware-scroll-view: "npm:0.9.5"
react-native-mmkv: "npm:2.12.2"
react-native-quick-crypto: "npm:^0.7.6"
Expand Down Expand Up @@ -11707,6 +11725,7 @@ __metadata:
"@suite-common/toast-notifications": "workspace:*"
"@suite-common/token-definitions": "workspace:*"
"@suite-common/wallet-core": "workspace:*"
"@suite-common/walletconnect": "workspace:*"
"@suite-native/blockchain": "workspace:*"
"@suite-native/device": "workspace:*"
"@suite-native/device-authorization": "workspace:*"
Expand Down Expand Up @@ -14078,6 +14097,13 @@ __metadata:
languageName: node
linkType: hard

"@types/fast-text-encoding@npm:^1":
version: 1.0.3
resolution: "@types/fast-text-encoding@npm:1.0.3"
checksum: 10/34ec2bbaf3e3ee36b7b74375293becc735378f77e9cd93b810ad988b42991ee80d30fb942e6ba03adfc1f0cb0e2024a0aeee84475847563ed6782e21c4c0f5f0
languageName: node
linkType: hard

"@types/file-saver@npm:^2.0.6":
version: 2.0.7
resolution: "@types/file-saver@npm:2.0.7"
Expand Down Expand Up @@ -14766,6 +14792,13 @@ __metadata:
languageName: node
linkType: hard

"@types/react-native-get-random-values@npm:^1":
version: 1.8.2
resolution: "@types/react-native-get-random-values@npm:1.8.2"
checksum: 10/08f3f82efbb5b6d9acd8f7f55a2dac9f228886323ac3018a1bab46cd1b45f24809d194fd2a3fe02a9ec4196606325e5cfffde0b0057ae785208b658fdc83c821
languageName: node
linkType: hard

"@types/react-qr-reader@npm:^2.1.7":
version: 2.1.7
resolution: "@types/react-qr-reader@npm:2.1.7"
Expand Down Expand Up @@ -15631,6 +15664,26 @@ __metadata:
languageName: node
linkType: hard

"@walletconnect/react-native-compat@npm:^2.18.0":
version: 2.18.0
resolution: "@walletconnect/react-native-compat@npm:2.18.0"
dependencies:
events: "npm:3.3.0"
fast-text-encoding: "npm:1.0.6"
react-native-url-polyfill: "npm:2.0.0"
peerDependencies:
"@react-native-async-storage/async-storage": "*"
"@react-native-community/netinfo": "*"
expo-application: "*"
react-native: "*"
react-native-get-random-values: "*"
peerDependenciesMeta:
expo-application:
optional: true
checksum: 10/ef82bffb1f85f588b2f813ae30dbaf7ed87f37138548e5b3820e68df42f8a2c446d9c8a8a1f6c0fbd6d7a0c8ae89009aa02d75e208c7e58442433d2d93b97f2f
languageName: node
linkType: hard

"@walletconnect/relay-api@npm:1.0.11":
version: 1.0.11
resolution: "@walletconnect/relay-api@npm:1.0.11"
Expand Down Expand Up @@ -24538,6 +24591,13 @@ __metadata:
languageName: node
linkType: hard

"fast-base64-decode@npm:^1.0.0":
version: 1.0.0
resolution: "fast-base64-decode@npm:1.0.0"
checksum: 10/4c59eb1775a7f132333f296c5082476fdcc8f58d023c42ed6d378d2e2da4c328c7a71562f271181a725dd17cdaa8f2805346cc330cdbad3b8e4b9751508bd0a3
languageName: node
linkType: hard

"fast-copy@npm:^3.0.2":
version: 3.0.2
resolution: "fast-copy@npm:3.0.2"
Expand Down Expand Up @@ -24628,6 +24688,13 @@ __metadata:
languageName: node
linkType: hard

"fast-text-encoding@npm:1.0.6, fast-text-encoding@npm:^1.0.6":
version: 1.0.6
resolution: "fast-text-encoding@npm:1.0.6"
checksum: 10/f7b9e2e7a21e4ae5f4b8d3729850be83fb45052b28c9c38c09b8366463a291d6dc5448359238bdaf87f6a9e907d5895a94319a2c5e0e9f0786859ad6312d1d06
languageName: node
linkType: hard

"fast-uri@npm:^3.0.1":
version: 3.0.1
resolution: "fast-uri@npm:3.0.1"
Expand Down Expand Up @@ -31764,6 +31831,15 @@ __metadata:
languageName: node
linkType: hard

"merge-options@npm:^3.0.4":
version: 3.0.4
resolution: "merge-options@npm:3.0.4"
dependencies:
is-plain-obj: "npm:^2.1.0"
checksum: 10/d86ddb3dd6e85d558dbf25dc944f3527b6bacb944db3fdda6e84a3f59c4e4b85231095f58b835758b9a57708342dee0f8de0dffa352974a48221487fe9f4584f
languageName: node
linkType: hard

"merge-source-map@npm:1.0.4":
version: 1.0.4
resolution: "merge-source-map@npm:1.0.4"
Expand Down Expand Up @@ -37352,6 +37428,17 @@ __metadata:
languageName: node
linkType: hard

"react-native-get-random-values@npm:^1.11.0":
version: 1.11.0
resolution: "react-native-get-random-values@npm:1.11.0"
dependencies:
fast-base64-decode: "npm:^1.0.0"
peerDependencies:
react-native: ">=0.56"
checksum: 10/eb04833ce2b66309d737f1447ab01ad32aca00a8d1cc4de7b4e751c23f4d9f8059a2643bb16e0b6f3e6b074a9e57e769bb2bf2afc50a912c5661d80a6ce4de34
languageName: node
linkType: hard

"react-native-iphone-x-helper@npm:^1.0.3":
version: 1.3.1
resolution: "react-native-iphone-x-helper@npm:1.3.1"
Expand Down Expand Up @@ -37481,6 +37568,17 @@ __metadata:
languageName: node
linkType: hard

"react-native-url-polyfill@npm:2.0.0":
version: 2.0.0
resolution: "react-native-url-polyfill@npm:2.0.0"
dependencies:
whatwg-url-without-unicode: "npm:8.0.0-3"
peerDependencies:
react-native: "*"
checksum: 10/6a8d605eeb1b0ee9b0f47f1866acc2edfa2131a4a8fb1ea3839ceb507e225b894ed66f49a3bd826fc964f2c8005b3678c9d3b65d07eb0a3b979be830cb618686
languageName: node
linkType: hard

"react-native@npm:0.76.1":
version: 0.76.1
resolution: "react-native@npm:0.76.1"
Expand Down

0 comments on commit 1ce5c0e

Please sign in to comment.