forked from HugoByte/aurras
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Transfer.js
94 lines (86 loc) · 2.53 KB
/
Transfer.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import React, { useState } from 'react'
import { Form, Input, Grid, Label, Icon, Dropdown } from 'semantic-ui-react'
import { TxButton } from './substrate-lib/components'
import { useSubstrateState } from './substrate-lib'
export default function Main(props) {
const [status, setStatus] = useState(null)
const [formState, setFormState] = useState({ addressTo: '', amount: 0 })
const onChange = (_, data) =>
setFormState(prev => ({ ...prev, [data.state]: data.value }))
const { addressTo, amount } = formState
const { keyring } = useSubstrateState()
const accounts = keyring.getPairs()
const availableAccounts = []
accounts.map(account => {
return availableAccounts.push({
key: account.meta.name,
text: account.meta.name,
value: account.address,
})
})
return (
<Grid.Column width={8}>
<h1>Transfer</h1>
<Form>
<Form.Field>
<Label basic color="teal">
<Icon name="hand point right" />1 Unit = 1000000000000
</Label>
<Label
basic
color="teal"
style={{ marginLeft: 0, marginTop: '.5em' }}
>
<Icon name="hand point right" />
Transfer more than the existential amount for account with 0 balance
</Label>
</Form.Field>
<Form.Field>
<Dropdown
placeholder="Select from available addresses"
fluid
selection
search
options={availableAccounts}
state="addressTo"
onChange={onChange}
/>
</Form.Field>
<Form.Field>
<Input
fluid
label="To"
type="text"
placeholder="address"
value={addressTo}
state="addressTo"
onChange={onChange}
/>
</Form.Field>
<Form.Field>
<Input
fluid
label="Amount"
type="number"
state="amount"
onChange={onChange}
/>
</Form.Field>
<Form.Field style={{ textAlign: 'center' }}>
<TxButton
label="Submit"
type="SIGNED-TX"
setStatus={setStatus}
attrs={{
palletRpc: 'balances',
callable: 'transfer',
inputParams: [addressTo, amount],
paramFields: [true, true],
}}
/>
</Form.Field>
<div style={{ overflowWrap: 'break-word' }}>{status}</div>
</Form>
</Grid.Column>
)
}