Spaces:
Running
Running
| import React, {useState} from 'react'; | |
| import {View, Text, Button} from 'react-native'; | |
| import {connect} from '../services/walletConnect'; | |
| export default function WalletScreen() { | |
| const [account, setAccount] = useState<string | null>(null); | |
| async function handleConnect() { | |
| try { | |
| const res: any = await connect(); | |
| const accounts = res.accounts as string[]; | |
| setAccount(accounts[0]); | |
| } catch (e) { | |
| console.error(e); | |
| } | |
| } | |
| return ( | |
| <View style={{flex:1, padding:20}}> | |
| <Text style={{fontSize:18}}>Wallet</Text> | |
| <Text>{account ?? 'Nenhuma carteira conectada'}</Text> | |
| <Button title="Conectar Wallet" onPress={handleConnect} /> | |
| </View> | |
| ); | |
| } | |