laconic-wallet/components/WalletConnect.tsx
shreerang6921 150f10b91f
Connect wallet to a dapp using WalletConnect (#38)
* Connect with dapp using WalletConnect

* Pair dapp with wallet

* Sign message taken from dapp and return the signature

* Add todos

* Move wallet connect functions to seperate screen

* Change ui

* Change ui for wc modals

* Add styles

* Remove border radius at the bottom

* Make review changes

* Add dependancy to useEffect

* Move pairing modal methods

---------

Co-authored-by: Adw8 <adwait@deepstacksoft.com>
2024-03-05 19:20:31 +05:30

43 lines
1.2 KiB
TypeScript

import React, { useState } from 'react';
import { View } from 'react-native';
import { Button, TextInput } from 'react-native-paper';
import { NativeStackNavigationProp } from '@react-navigation/native-stack';
import { useNavigation } from '@react-navigation/native';
import { web3WalletPair } from '../utils/wallet-connect/WalletConnectUtils';
import styles from '../styles/stylesheet';
import { StackParamsList } from '../types';
const WalletConnect = () => {
const [currentWCURI, setCurrentWCURI] = useState<string>('');
const navigation =
useNavigation<NativeStackNavigationProp<StackParamsList>>();
const pair = async () => {
const pairing = await web3WalletPair({ uri: currentWCURI });
navigation.navigate('Laconic');
return pairing;
};
return (
<View style={styles.appContainer}>
<TextInput
mode="outlined"
onChangeText={setCurrentWCURI}
value={currentWCURI}
placeholder="Enter WalletConnect URI"
/>
<View style={styles.signButton}>
<Button mode="contained" onPress={pair}>
Pair Session
</Button>
</View>
</View>
);
};
export default WalletConnect;