1import React from 'react';
2import cn from 'classnames';
13import { GenerateButton, ForwardButton, RestartButton } from './Buttons';
14import { useCheckboxInput } from 'lib/useInputs';
15import Blinky from './Blinky';
16import { hexify } from 'lib/txn';
17import { useExploreTxUrl } from 'lib/explorer';
19export default function InlineEthereumTransaction({
20 // from useEthereumTransaction.bind
37 // additional from parent
41 // show receipt after successful broadcast
42 const showReceipt = broadcasted || confirmed;
43 // show configure controls pre-broadcast
44 const showConfigureInput = !(signed || broadcasted || confirmed);
45 // show signed tx after signing
46 const showSignedTx = signed;
48 const exploreHashUrl = useExploreTxUrl(txHash);
49 const [advancedInput, { data: advancedOpen }] = useCheckboxInput({
51 label: 'Advanced Configuration',
52 inverseLabel: 'Hide Advanced Configuration',
53 disabled: !showConfigureInput,
57 viewSignedTransaction,
58 { data: signedTransactionOpen },
59 ] = useCheckboxInput({
61 label: 'View Signed Transaction',
62 inverseLabel: 'Hide Signed Transaction',
63 disabled: !showSignedTx,
66 const renderButton = () => {
69 <Grid.Item full as={RestartButton} solid onClick={() => reset()}>
73 } else if (confirmed) {
77 <Grid.Item full as={RestartButton} onClick={onReturn}>
82 } else if (broadcasted) {
90 accessory={<Blinky />}>
91 Sending Transaction...
101 onClick={() => broadcast()}>
110 onClick={generateAndSign}
112 accessory={!canSign && initializing ? <Blinky /> : undefined}>
113 Generate & Sign Transaction
120 <Grid className={cn(className, 'mt1')}>
124 <Grid.Item full as={ErrorText} className="mt1">
129 {showConfigureInput && (
132 <Grid.Item full as={ToggleInput} {...advancedInput} />
135 <Grid.Item full as={Flex} row justify="between" className="mt2">
136 <Flex.Item as={H5}>Gas Price</Flex.Item>
137 <Flex.Item as={H5}>{gasPrice} Gwei</Flex.Item>
146 onChange={e => setGasPrice(parseInt(e.target.value, 10))}
154 <Flex.Item as={Text}>Cheap</Flex.Item>
155 <Flex.Item as={Text}>Fast</Flex.Item>
157 <Grid.Item full as={HelpText} className="mt3">
160 <Grid.Item full as={HelpText} className="mt1">
170 <Grid.Item full as={ToggleInput} {...viewSignedTransaction} />
171 {signedTransactionOpen && (
172 <Grid.Item full as="code" className="f6 mono gray4 wrap">
173 {hexify(signedTransaction.serialize())}
182 <Grid.Item full as={Flex} col className="pv4">
183 <Flex.Item as={Flex} row justify="between">
184 <Flex.Item as={H5}>Transaction Hash</Flex.Item>
185 <Flex.Item as={LinkButton} href={exploreHashUrl}>
189 <Flex.Item as={Flex}>
190 <Flex.Item flex as="code" className="f6 mono gray4 wrap">
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list