@@ -8,19 +8,21 @@ import {
8 LinkButton,
8 LinkButton,
12} from 'indigo-react';
11} from 'indigo-react';
13import { fromWei } from 'web3-utils';
12import { fromWei } from 'web3-utils';
15import { useExploreTxUrl } from 'lib/explorer';
14import { useExploreTxUrl } from 'lib/explorer';
16import { hexify } from 'lib/txn';
15import { hexify } from 'lib/txn';
18−import { GenerateButton, ForwardButton, RestartButton } from './Buttons';
19−import WarningBox from './WarningBox';
20import { composeValidator, buildCheckboxValidator } from 'form/validators';
17import { composeValidator, buildCheckboxValidator } from 'form/validators';
21import BridgeForm from 'form/BridgeForm';
18import BridgeForm from 'form/BridgeForm';
22import Condition from 'form/Condition';
19import Condition from 'form/Condition';
21+import { GenerateButton, ForwardButton, RestartButton } from './Buttons';
22+import WarningBox from './WarningBox';
23+import CopyButton from './CopyButton';
24+import ProgressButton from './ProgressButton';
24export default function InlineEthereumTransaction({
26export default function InlineEthereumTransaction({
25 // from useEthereumTransaction.bind
27 // from useEthereumTransaction.bind
26 initializing,
28 initializing,
@@ -41,6 +43,7 @@ export default function InlineEthereumTransaction({
42 needFunds,
44 needFunds,
43 signedTransaction,
45 signedTransaction,
46+ confirmationProgress,
45 // additional from parent
48 // additional from parent
46 label = 'Generate & Sign Transaction',
49 label = 'Generate & Sign Transaction',
@@ -52,9 +55,9 @@ export default function InlineEthereumTransaction({
52 // show configure controls pre-broadcast
55 // show configure controls pre-broadcast
53 const showConfigureInput = !(signed || broadcasted || confirmed || completed);
56 const showConfigureInput = !(signed || broadcasted || confirmed || completed);
54 // show the send/loading button while signed, broadcasting, or confirme
57 // show the send/loading button while signed, broadcasting, or confirme
55− const showBroadcastButton = signed || broadcasted || confirmed;
58+ const showBroadcastButton = signed;
59+ const showLoadingButton = broadcasted || confirmed;
56 const canBroadcast = signed && !needFunds;
60 const canBroadcast = signed && !needFunds;
57− const isLoading = broadcasted || confirmed;
58 // show signed tx only when signing (for offline usage)
61 // show signed tx only when signing (for offline usage)
59 const showSignedTx = signed;
62 const showSignedTx = signed;
@@ -78,7 +81,7 @@ export default function InlineEthereumTransaction({
78 [resetGasPrice]
81 [resetGasPrice]
81− const renderPrimaryButton = () => {
84+ const renderPrimarySection = () => {
82 if (error) {
85 if (error) {
84 <Grid.Item full as={RestartButton} solid onClick={() => reset()}>
87 <Grid.Item full as={RestartButton} solid onClick={() => reset()}>
@@ -87,12 +90,9 @@ export default function InlineEthereumTransaction({
88 } else if (completed) {
91 } else if (completed) {
90− <>
93+ <Grid.Item full className="pv4 black f5">
91− <Grid.Divider />
94+ Transaction Complete
92− <Grid.Item full as={RestartButton} onClick={onReturn}>
94− </Grid.Item>
95+ </Grid.Item>
97 } else if (showBroadcastButton) {
97 } else if (showBroadcastButton) {
@@ -102,11 +102,20 @@ export default function InlineEthereumTransaction({
104 disabled={!canBroadcast}
104 disabled={!canBroadcast}
106 onClick={() => broadcast()}>
105 onClick={() => broadcast()}>
107 Send Transaction
106 Send Transaction
108 </Grid.Item>
107 </Grid.Item>
109+ } else if (showLoadingButton) {
115+ progress={confirmationProgress}>
112 <Grid.Item
121 <Grid.Item
@@ -121,12 +130,17 @@ export default function InlineEthereumTransaction({
133+ const serializedTxHex = useMemo(
134+ () => signedTransaction && hexify(signedTransaction.serialize()),
125 <Grid className={cn(className, 'mt1')}>
139 <Grid className={cn(className, 'mt1')}>
126 <BridgeForm validate={validate} onValues={onValues}>
140 <BridgeForm validate={validate} onValues={onValues}>
127 {({ handleSubmit }) => (
141 {({ handleSubmit }) => (
129− {renderPrimaryButton()}
143+ {renderPrimarySection()}
131 {error && (
145 {error && (
132 <Grid.Item full as={ErrorText} className="mt1">
146 <Grid.Item full as={ErrorText} className="mt1">
@@ -149,12 +163,14 @@ export default function InlineEthereumTransaction({
150 as={ToggleInput}
164 as={ToggleInput}
151 name="useAdvanced"
165 name="useAdvanced"
152− label="Advanced Configuration"
166+ label="Advanced"
153− inverseLabel="Cancel Advanced Configuration"
167+ inverseLabel="Back to Defaults"
154 disabled={!showConfigureInput || initializing}
169 disabled={!showConfigureInput || initializing}
157 <Condition when="useAdvanced" is={true}>
172 <Condition when="useAdvanced" is={true}>
158 <Grid.Item
174 <Grid.Item
160 as={Flex}
176 as={Flex}
@@ -183,13 +199,7 @@ export default function InlineEthereumTransaction({
183 <Flex.Item as={Text}>Cheap</Flex.Item>
199 <Flex.Item as={Text}>Cheap</Flex.Item>
184 <Flex.Item as={Text}>Fast</Flex.Item>
200 <Flex.Item as={Text}>Fast</Flex.Item>
185 </Grid.Item>
201 </Grid.Item>
186− <Grid.Item full as={HelpText} className="mt3">
189− <Grid.Item full as={HelpText} className="mt1">
192− <Grid.Divider className="mt3" />
202+ <Grid.Divider className="mt4" />
193 </Condition>
203 </Condition>
@@ -200,14 +210,42 @@ export default function InlineEthereumTransaction({
201 as={ToggleInput}
211 as={ToggleInput}
202 name="viewSigned"
212 name="viewSigned"
203− label="View Signed Transaction"
213+ label="Signed Transaction"
204− inverseLabel="Hide Signed Transaction"
214+ inverseLabel="Hide"
205 disabled={!showSignedTx}
215 disabled={!showSignedTx}
207 <Condition when="viewSigned" is={true}>
217 <Condition when="viewSigned" is={true}>
223+ className="pv4 black f5">
224+ <Flex.Item>Nonce</Flex.Item>
225+ <Flex.Item>{nonce}</Flex.Item>
232+ className="pv4 black f5">
233+ <Flex.Item>Gas Price</Flex.Item>
234+ <Flex.Item>{gasPrice.toFixed()} Gwei</Flex.Item>
241+ className="mt3 mb2">
242+ <Flex.Item as={H5}>Signed Transaction Hex</Flex.Item>
243+ <Flex.Item as={CopyButton} text={serializedTxHex} />
208− <Grid.Item full as="code" className="f6 mono gray4 wrap">
245+ <Grid.Item full as="code" className="mb4 f6 mono gray4 wrap">
209− {hexify(signedTransaction.serialize())}
246+ {serializedTxHex}
210 </Grid.Item>
247 </Grid.Item>
211 </Condition>
249 </Condition>
@@ -232,6 +270,15 @@ export default function InlineEthereumTransaction({
232 <Grid.Divider />
270 <Grid.Divider />
276+ <Grid.Item full as={RestartButton} onClick={onReturn}>
237 </BridgeForm>
284 </BridgeForm>