1import React from 'react';
2import cn from 'classnames';
14import { useCheckboxInput } from 'lib/useInputs';
15import { hexify } from 'lib/txn';
16import { useExploreTxUrl } from 'lib/explorer';
18import { GenerateButton, ForwardButton, RestartButton } from './Buttons';
20export default function InlineEthereumTransaction({
21 // from useEthereumTransaction.bind
38 // additional from parent
42 // show receipt after successful broadcast
43 const showReceipt = broadcasted || confirmed;
44 // show configure controls pre-broadcast
45 const showConfigureInput = !(signed || broadcasted || confirmed);
46 // show signed tx only when signing (for offline usage)
47 const showSignedTx = signed;
49 const exploreTxUrl = useExploreTxUrl(txHash);
50 const [advancedInput, { data: advancedOpen }] = useCheckboxInput({
52 label: 'Advanced Configuration',
53 inverseLabel: 'Hide Advanced Configuration',
54 disabled: !showConfigureInput,
58 viewSignedTransaction,
59 { data: signedTransactionOpen },
60 ] = useCheckboxInput({
62 label: 'View Signed Transaction',
63 inverseLabel: 'Hide Signed Transaction',
64 disabled: !showSignedTx,
67 const renderPrimaryButton = () => {
70 <Grid.Item full as={RestartButton} solid onClick={() => reset()}>
74 } else if (confirmed) {
78 <Grid.Item full as={RestartButton} onClick={onReturn}>
83 } else if (signed || broadcasted) {
90 disabled={broadcasted}
92 onClick={() => broadcast()}>
101 onClick={generateAndSign}
103 loading={!canSign && initializing}>
104 Generate & Sign Transaction
111 <Grid className={cn(className, 'mt1')}>
112 {renderPrimaryButton()}
115 <Grid.Item full as={ErrorText} className="mt1">
120 {showConfigureInput && (
123 <Grid.Item full as={ToggleInput} {...advancedInput} />
126 <Grid.Item full as={Flex} row justify="between" className="mt2">
127 <Flex.Item as={H5}>Gas Price</Flex.Item>
128 <Flex.Item as={H5}>{gasPrice} Gwei</Flex.Item>
130 {/* TODO(shrugs): move to indigo/RangeInput */}
138 onChange={e => setGasPrice(parseInt(e.target.value, 10))}
146 <Flex.Item as={Text}>Cheap</Flex.Item>
147 <Flex.Item as={Text}>Fast</Flex.Item>
149 <Grid.Item full as={HelpText} className="mt3">
152 <Grid.Item full as={HelpText} className="mt1">
162 <Grid.Item full as={ToggleInput} {...viewSignedTransaction} />
163 {signedTransactionOpen && (
164 <Grid.Item full as="code" className="f6 mono gray4 wrap">
165 {hexify(signedTransaction.serialize())}
174 <Grid.Item full as={Flex} col className="pv4">
175 <Flex.Item as={Flex} row justify="between">
176 <Flex.Item as={H5}>Transaction Hash</Flex.Item>
177 <Flex.Item as={LinkButton} href={exploreTxUrl}>
181 <Flex.Item as={Flex}>
182 <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