Skip to content

Commit 3879421

Browse files
committed
chore(w3i-rn-sdk): use latest Web3Inbox SDK
1 parent eac7392 commit 3879421

File tree

4 files changed

+1556
-1028
lines changed

4 files changed

+1556
-1028
lines changed

dapps/web3inbox/App.tsx

+25-11
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,16 @@ import {
99
useWalletConnectModal,
1010
} from '@walletconnect/modal-react-native';
1111

12-
const providerMetadata = {
12+
const clientMetadata = {
1313
name: 'Web3Inbox React Native Example',
1414
description:
1515
'An example app to showcase how to use Web3Inbox React Native SDK',
1616
url: 'https://github.com/WalletConnect/web3inbox-js-sdk',
1717
icons: ['https://avatars.githubusercontent.com/u/37784886'],
18+
};
19+
20+
const providerMetadata = {
21+
...clientMetadata,
1822
redirect: {
1923
native: 'YOUR_APP_SCHEME://',
2024
universal: 'YOUR_APP_UNIVERSAL_LINK.com',
@@ -32,6 +36,23 @@ export default function Native() {
3236
[],
3337
);
3438

39+
const handleSign = useCallback(
40+
async (message: string) => {
41+
if (!provider || !address) {
42+
return '';
43+
}
44+
const response = await provider?.request(
45+
{
46+
method: 'personal_sign',
47+
params: [message, address],
48+
},
49+
'eip155:1',
50+
);
51+
return response as string;
52+
},
53+
[provider, address],
54+
);
55+
3556
return (
3657
<View style={styles.container}>
3758
<Text style={styles.header}>Web3Inbox React Native Webview</Text>
@@ -53,20 +74,13 @@ export default function Native() {
5374
/>
5475
{address && isConnected && (
5576
<Web3Inbox
77+
clientMetadata={clientMetadata}
5678
projectId={projectId}
5779
ethAddress={address}
58-
onSign={async (message: string) => {
59-
const response = await provider?.request(
60-
{
61-
method: 'personal_sign',
62-
params: [message, address],
63-
},
64-
'eip155:1',
65-
);
66-
return response as string;
67-
}}
80+
onSign={handleSign}
6881
visible={isVisible}
6982
setVisible={toggleWeb3InboxModal}
83+
chatEnabled={false}
7084
/>
7185
)}
7286
</View>

dapps/web3inbox/babel.config.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
module.exports = {
22
presets: ['module:metro-react-native-babel-preset'],
33
plugins: [
4-
["module:react-native-dotenv"]
5-
]
4+
['module:react-native-dotenv'],
5+
[
6+
'module-resolver',
7+
{
8+
alias: {
9+
crypto: 'react-native-quick-crypto',
10+
stream: 'stream-browserify',
11+
buffer: '@craftzdog/react-native-buffer',
12+
},
13+
},
14+
],
15+
],
616
};

dapps/web3inbox/package.json

+11-13
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,38 @@
33
"version": "0.0.1",
44
"private": true,
55
"scripts": {
6-
"android": "react-native run-android --appId com.walletconnect.w3i.rnexample",
6+
"android": "react-native run-android --appId=com.w3idapp",
77
"android:build": "cd android && ./gradlew clean && ./gradlew assembleRelease",
88
"ios": "react-native run-ios",
99
"lint": "eslint .",
1010
"start": "react-native start",
1111
"test": "jest"
1212
},
1313
"dependencies": {
14-
"@craftzdog/react-native-buffer": "6.0.5",
14+
"@craftzdog/react-native-buffer": "^6.0.5",
1515
"@json-rpc-tools/utils": "1.7.6",
1616
"@react-native-async-storage/async-storage": "1.19.1",
17+
"@react-native-community/netinfo": "^9.4.1",
1718
"@react-navigation/native": "6.1.6",
1819
"@react-navigation/native-stack": "6.9.12",
19-
"@walletconnect/chat-client": "0.7.2",
20-
"@walletconnect/core": "2.9.2",
20+
"@walletconnect/core": "^2.10.0",
2121
"@walletconnect/modal-react-native": "1.0.0-rc.9",
22-
"@walletconnect/push-client": "0.10.7",
23-
"@walletconnect/react-native-compat": "2.9.2",
24-
"@walletconnect/sync-client": "0.3.7",
25-
"@walletconnect/types": "2.9.2",
26-
"@walletconnect/web3inbox-webview": "0.0.6",
22+
"@walletconnect/react-native-compat": "^2.10.0",
23+
"@walletconnect/types": "^2.10.0",
24+
"@walletconnect/web3inbox-webview": "^0.0.7",
2725
"babel-plugin-module-resolver": "5.0.0",
2826
"ethers": "5.7.2",
2927
"react": "18.2.0",
30-
"react-native": "0.72.3",
28+
"react-native": "^0.72.4",
3129
"react-native-get-random-values": "1.9.0",
3230
"react-native-modal": "13.0.1",
33-
"react-native-quick-base64": "2.0.7",
34-
"react-native-quick-crypto": "0.6.1",
31+
"react-native-quick-base64": "^2.0.7",
32+
"react-native-quick-crypto": "^0.6.1",
3533
"react-native-safe-area-context": "4.5.3",
3634
"react-native-screens": "3.20.0",
3735
"react-native-svg": "13.9.0",
3836
"react-native-webview": "13.3.1",
39-
"stream-browserify": "3.0.0",
37+
"stream-browserify": "^3.0.0",
4038
"text-encoding": "0.7.0"
4139
},
4240
"devDependencies": {

0 commit comments

Comments
 (0)