forked from cerc-io/laconic-wallet
* Update keystore data structure (#83) * Update create wallet and retrieve accounts functionality for updated data structure * Refactor accounts state * Use constant variable for cosmos * Update add accounts incrementally and with custom HD path for updated data structure (#85) * Change data structure * Reset wallet change * Fix signEthMessage * Fix sign request * Fix pairing with laconic pay dApp and sending tokens * Add accounts to configured networks * Update add account from hd path flow * Handle review changes --------- Co-authored-by: Shreerang Kale <shreerangkale@gmail.com> * Remove network type state * Refactor create wallet code (#89) * Refactor create wallet code * Create cosmos accounts with correct address prefix * Use networks data from state while creating wallet * Refactor code and add network id in types (#91) * Refactor add new networks component * Add selected network state in context * Remove returning account from create wallet --------- Co-authored-by: IshaVenikar <145848618+IshaVenikar@users.noreply.github.com>
61 lines
1.7 KiB
TypeScript
61 lines
1.7 KiB
TypeScript
import React, { useState } from 'react';
|
|
import { ScrollView, View, Alert } from 'react-native';
|
|
import { Button, Text, TextInput } from 'react-native-paper';
|
|
|
|
import { NativeStackScreenProps } from '@react-navigation/native-stack';
|
|
|
|
import { StackParamsList } from '../types';
|
|
import styles from '../styles/stylesheet';
|
|
import { signMessage } from '../utils/sign-message';
|
|
import AccountDetails from '../components/AccountDetails';
|
|
|
|
type SignProps = NativeStackScreenProps<StackParamsList, 'SignMessage'>;
|
|
|
|
const SignMessage = ({ route }: SignProps) => {
|
|
const namespace = route.params.selectedNamespace;
|
|
const chainId = route.params.selectedChainId;
|
|
const account = route.params.accountInfo;
|
|
|
|
const [message, setMessage] = useState<string>('');
|
|
|
|
const signMessageHandler = async () => {
|
|
const signedMessage = await signMessage({
|
|
message,
|
|
namespace,
|
|
chainId,
|
|
accountId: account.index,
|
|
});
|
|
Alert.alert('Signature', signedMessage);
|
|
};
|
|
|
|
return (
|
|
<ScrollView style={styles.signPage}>
|
|
<View style={styles.accountInfo}>
|
|
<View>
|
|
<Text variant="titleMedium">
|
|
{account && `Account ${account.index + 1}`}
|
|
</Text>
|
|
</View>
|
|
<View style={styles.accountContainer}>
|
|
<AccountDetails account={account} />
|
|
</View>
|
|
</View>
|
|
|
|
<TextInput
|
|
mode="outlined"
|
|
placeholder="Enter your message"
|
|
onChangeText={text => setMessage(text)}
|
|
value={message}
|
|
/>
|
|
|
|
<View style={styles.signButton}>
|
|
<Button mode="contained" onPress={signMessageHandler}>
|
|
Sign
|
|
</Button>
|
|
</View>
|
|
</ScrollView>
|
|
);
|
|
};
|
|
|
|
export default SignMessage;
|