-
Notifications
You must be signed in to change notification settings - Fork 4
/
Transfer.js
63 lines (59 loc) · 1.79 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
import React, { useState } from 'react'
import { Form, Input, Grid, Label, Icon } from 'semantic-ui-react'
import { TxButton } from './substrate-lib/components'
export default function Main (props) {
const [status, setStatus] = useState(null)
const [formState, setFormState] = useState({ addressTo: null, amount: 0 })
const { accountPair } = props
const onChange = (_, data) =>
setFormState(prev => ({ ...prev, [data.state]: data.value }))
const { addressTo, amount } = formState
return (
<Grid.Column width={8}>
<h1>Transfer</h1>
<Form>
<Form.Field>
<Label basic color='teal'>
<Icon name='hand point right' />
1 Unit = 1000000000000
</Label>
</Form.Field>
<Form.Field>Transfer more than the existential amount for account with 0 balance</Form.Field>
<Form.Field>
<Input
fluid
label='To'
type='text'
placeholder='address'
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
accountPair={accountPair}
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>
)
}