Skip to content

Commit

Permalink
automatically set recipient address to self whenever connected wallet…
Browse files Browse the repository at this point in the history
… changes
  • Loading branch information
brenzi committed Apr 16, 2024
1 parent 9405603 commit eb21065
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/components/TransferForm.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useForm } from '@mantine/form';
import { isValidWalletAddress } from '../utils';
import { FC } from 'react';
import {FC, useEffect} from 'react';
import { Button, Stack, TextInput } from '@mantine/core';
import { TNodeWithRelayChains } from '@paraspell/sdk';
import {useWallet} from "../providers/WalletProvider.tsx";
Expand All @@ -21,13 +21,18 @@ type Props = {

const TransferForm: FC<Props> = ({ onSubmit, loading }) => {
const { selectedAccount } = useWallet();

useEffect(() => {
if (selectedAccount) form.values.address = selectedAccount.address;
}, [selectedAccount]);

const form = useForm<FormValues>({
initialValues: {
from: 'Encointer',
to: 'Kusama',
currency: 'KSM',
amount: 0.2,
address: selectedAccount? selectedAccount.address : '',
address: '',
useApi: false,
},

Expand All @@ -39,7 +44,7 @@ const TransferForm: FC<Props> = ({ onSubmit, loading }) => {
return (
<form onSubmit={form.onSubmit(onSubmit)}>
<Stack>
<TextInput label="Amount KSM to send" placeholder="0.1" required {...form.getInputProps('amount')} />
<TextInput label="Amount KSM to send to same account on relaychain" placeholder="0.1" required {...form.getInputProps('amount')} />
<Button type="submit" loading={loading}>
Submit transaction
</Button>
Expand Down

0 comments on commit eb21065

Please sign in to comment.