Skip to content

Commit b376ab1

Browse files
authored
Select from available addreses dropdown (jimmychu0807#222)
* select from available addreses dropdown * fix linter
1 parent ecbc18d commit b376ab1

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

src/Transfer.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, { useState } from 'react';
2-
import { Form, Input, Grid, Label, Icon } from 'semantic-ui-react';
2+
import { Form, Input, Grid, Label, Icon, Dropdown } from 'semantic-ui-react';
33
import { TxButton } from './substrate-lib/components';
4+
import { useSubstrate } from './substrate-lib';
45

56
export default function Main (props) {
67
const [status, setStatus] = useState(null);
@@ -12,6 +13,14 @@ export default function Main (props) {
1213

1314
const { addressTo, amount } = formState;
1415

16+
const { keyring } = useSubstrate();
17+
const accounts = keyring.getPairs();
18+
19+
const availableAccounts = [];
20+
accounts.map(account => {
21+
return availableAccounts.push({ key: account.meta.name, text: account.meta.name, value: account.address });
22+
});
23+
1524
return (
1625
<Grid.Column width={8}>
1726
<h1>Transfer</h1>
@@ -27,12 +36,25 @@ export default function Main (props) {
2736
</Label>
2837
</Form.Field>
2938

39+
<Form.Field>
40+
<Dropdown
41+
placeholder='Select from available addresses'
42+
fluid
43+
selection
44+
search
45+
options={availableAccounts}
46+
state='addressTo'
47+
onChange={onChange}
48+
/>
49+
</Form.Field>
50+
3051
<Form.Field>
3152
<Input
3253
fluid
3354
label='To'
3455
type='text'
3556
placeholder='address'
57+
value={addressTo}
3658
state='addressTo'
3759
onChange={onChange}
3860
/>

0 commit comments

Comments
 (0)