laconic-wallet/components/SignMessage.tsx
shreerang6921 09a3b9fc75
Integrate functions with UI (#14)
* Add the creatHDWallet function

* Make review changes

* Add signMessage and signEthMessage functions

* Add signCosmosMessage function

* Add resetWallet function

* Add resetWallet function

* Integrate functions with UI

* Add Alerts to react component

* Make review changes

* Add comment in utils file

* Remove lowerCase conversion in signCosmosmessage function

---------

Co-authored-by: IshaVenikar <ishavenikar7@gmail.com>
2024-02-14 19:14:21 +05:30

43 lines
1.2 KiB
TypeScript

import { View } from 'react-native';
import { Button, TextInput } from 'react-native-paper';
import React, { useState } from 'react';
import { Alert } from 'react-native';
import { NativeStackScreenProps } from '@react-navigation/native-stack';
import { StackParamsList } from '../types';
import { signMessage } from '../utils';
type SignProps = NativeStackScreenProps<StackParamsList, 'SignMessage'>;
const SignMessage = ({ route }: SignProps) => {
const network = route.params?.selectedNetwork;
const [message, setMessage] = useState<string>('');
const signMessageHandler = async () => {
if (network) {
const signedMessage = await signMessage(message, network, 0);
Alert.alert('Signature', signedMessage);
}
};
return (
<View style={{ marginTop: 30, paddingHorizontal: 48 }}>
<TextInput
mode="outlined"
placeholder="Enter your message"
onChangeText={text => setMessage(text)}
value={message}
/>
<View style={{ marginTop: 20, width: 150, alignSelf: 'center' }}>
<Button mode="contained" onPress={signMessageHandler}>
Sign
</Button>
</View>
</View>
);
};
export default SignMessage;