on master help sign in
Merge pull request #255 from urbit/fix/unify-needs-funds
555fac9Matt Condon
src/components/InlineEthereumTransaction.js+7−10
@@ -9,7 +9,6 @@ import {
9 H5,
9 H5,
10 Text,
10 Text,
11} from 'indigo-react';
11} from 'indigo-react';
12−import { fromWei } from 'web3-utils';
13
12
14import { useExploreTxUrl } from 'lib/explorer';
13import { useExploreTxUrl } from 'lib/explorer';
15import { hexify } from 'lib/txn';
14import { hexify } from 'lib/txn';
@@ -19,11 +18,10 @@ import BridgeForm from 'form/BridgeForm';
19import Condition from 'form/Condition';
18import Condition from 'form/Condition';
20
19
21import { GenerateButton, ForwardButton, RestartButton } from './Buttons';
20import { GenerateButton, ForwardButton, RestartButton } from './Buttons';
22−import WarningBox from './WarningBox';
23import CopyButton from './CopyButton';
21import CopyButton from './CopyButton';
24import ProgressButton from './ProgressButton';
22import ProgressButton from './ProgressButton';
25−import CopiableAddress from './CopiableAddress';
26import convertToInt from 'lib/convertToInt';
23import convertToInt from 'lib/convertToInt';
24+import NeedFundsNotice from './NeedFundsNotice';
27
25
28export default function InlineEthereumTransaction({
26export default function InlineEthereumTransaction({
29 // from useEthereumTransaction.bind
27 // from useEthereumTransaction.bind
@@ -152,13 +150,12 @@ export default function InlineEthereumTransaction({
152 )}
150 )}
153
151
154 {needFunds && (
152 {needFunds && (
153+ <Grid.Item
154+ full
155+ as={NeedFundsNotice}
155− <Grid.Item full as={WarningBox} className="mt3">
156+ className="mt3"
156− The address{' '}
157+ {...needFunds}
157− <CopiableAddress>{needFunds.address}</CopiableAddress> needs at
158+ />
158− least {fromWei(needFunds.minBalance)} ETH and currently has{' '}
159− {fromWei(needFunds.balance)} ETH. Waiting until the account has
160− enough funds.
161− </Grid.Item>
162 )}
159 )}
163
160
164 {showConfigureInput && (
161 {showConfigureInput && (
src/components/NeedFundsNotice.jsnew file+25
@@ -0,0 +1,25 @@
1+import React from 'react';
2+import { fromWei } from 'web3-utils';
3+
4+import Highlighted from './Highlighted';
5+import CopiableAddress from './CopiableAddress';
6+import WarningBox from './WarningBox';
7+import Blinky from './Blinky';
8+
9+export default function NeedFundsNotice({
10+ address,
11+ minBalance,
12+ balance,
13+ ...rest
14+}) {
15+ return (
16+ <WarningBox {...rest}>
17+ <Highlighted warning>
18+ Your ownership address <CopiableAddress>{address}</CopiableAddress>{' '}
19+ needs at least {fromWei(minBalance)} ETH and currently has{' '}
20+ {fromWei(balance)} ETH. The transaction will automatically resume once
21+ enough ETH is available. Waiting... <Blinky />
22+ </Highlighted>
23+ </WarningBox>
24+ );
25+}
src/views/Activate/PassportTransfer.js+2−11
@@ -1,6 +1,5 @@
1import React, { useState, useCallback } from 'react';
1import React, { useState, useCallback } from 'react';
2import { Grid, Text, ErrorText } from 'indigo-react';
2import { Grid, Text, ErrorText } from 'indigo-react';
3−import { fromWei } from 'web3-utils';
4
3
5import { useNetwork } from 'store/network';
4import { useNetwork } from 'store/network';
6import { useWallet } from 'store/wallet';
5import { useWallet } from 'store/wallet';
@@ -17,12 +16,11 @@ import timeout from 'lib/timeout';
17
16
18import WarningBox from 'components/WarningBox';
17import WarningBox from 'components/WarningBox';
19import LoadingBar from 'components/LoadingBar';
18import LoadingBar from 'components/LoadingBar';
20−import Highlighted from 'components/Highlighted';
21import { RestartButton } from 'components/Buttons';
19import { RestartButton } from 'components/Buttons';
20+import NeedFundsNotice from 'components/NeedFundsNotice';
22
21
23import { useActivateFlow } from './ActivateFlow';
22import { useActivateFlow } from './ActivateFlow';
24import PassportView from './PassportView';
23import PassportView from './PassportView';
25−import CopiableAddress from 'components/CopiableAddress';
26
24
27const labelForProgress = progress => {
25const labelForProgress = progress => {
28 if (progress <= 0) {
26 if (progress <= 0) {
@@ -162,14 +160,7 @@ export default function PassportTransfer({ className, resetActivateRouter }) {
162
160
163 if (needFunds) {
161 if (needFunds) {
164 return (
162 return (
165− <Grid.Item full className="mt8">
163+ <Grid.Item full as={NeedFundsNotice} className="mt8" {...needFunds} />
166− <Highlighted warning>
167− The address <CopiableAddress>{needFunds.address}</CopiableAddress>{' '}
168− needs at least {fromWei(needFunds.minBalance)} ETH and currently has{' '}
169− {fromWei(needFunds.balance)} ETH. Waiting until the account has
170− enough funds.
171− </Highlighted>
172− </Grid.Item>
173 );
164 );
174 }
165 }
175
166
src/views/Admin/Reticket/ReticketExecute.js+4−13
@@ -1,7 +1,6 @@
1import React, { useState, useCallback } from 'react';
1import React, { useState, useCallback } from 'react';
2import { Just, Nothing } from 'folktale/maybe';
2import { Just, Nothing } from 'folktale/maybe';
3import { Grid, H4, Text, ErrorText } from 'indigo-react';
3import { Grid, H4, Text, ErrorText } from 'indigo-react';
4−import { fromWei } from 'web3-utils';
5
4
6import {
5import {
7 reticketPointBetweenWallets,
6 reticketPointBetweenWallets,
@@ -9,6 +8,8 @@ import {
9} from 'lib/reticket';
8} from 'lib/reticket';
10import * as need from 'lib/need';
9import * as need from 'lib/need';
11import useLifecycle from 'lib/useLifecycle';
10import useLifecycle from 'lib/useLifecycle';
11+import { WALLET_TYPES } from 'lib/wallet';
12+import convertToInt from 'lib/convertToInt';
12
13
13import { useNetwork } from 'store/network';
14import { useNetwork } from 'store/network';
14import { useWallet } from 'store/wallet';
15import { useWallet } from 'store/wallet';
@@ -19,10 +20,7 @@ import { useHistory } from 'store/history';
19import { RestartButton, ForwardButton } from 'components/Buttons';
20import { RestartButton, ForwardButton } from 'components/Buttons';
20import WarningBox from 'components/WarningBox';
21import WarningBox from 'components/WarningBox';
21import LoadingBar from 'components/LoadingBar';
22import LoadingBar from 'components/LoadingBar';
22−import Highlighted from 'components/Highlighted';
23+import NeedFundsNotice from 'components/NeedFundsNotice';
23−import { WALLET_TYPES } from 'lib/wallet';
24−import CopiableAddress from 'components/CopiableAddress';
25−import convertToInt from 'lib/convertToInt';
26
24
27const labelForProgress = progress => {
25const labelForProgress = progress => {
28 if (progress <= 0) {
26 if (progress <= 0) {
@@ -129,14 +127,7 @@ export default function ReticketExecute({ newWallet, setNewWallet }) {
129
127
130 if (needFunds) {
128 if (needFunds) {
131 return (
129 return (
132− <Grid.Item full className="mt4">
130+ <Grid.Item full as={NeedFundsNotice} className="mt4" {...needFunds} />
133− <Highlighted warning>
134− The address <CopiableAddress>{needFunds.address}</CopiableAddress>{' '}
135− needs at least {fromWei(needFunds.minBalance)} ETH and currently has{' '}
136− {fromWei(needFunds.balance)} ETH. Waiting until the account has
137− enough funds.
138− </Highlighted>
139− </Grid.Item>
140 );
131 );
141 }
132 }
142
133
src/views/Invite/InviteEmail.js+6−16
@@ -18,8 +18,9 @@ import {
18 AccessoryIcon,
18 AccessoryIcon,
19} from 'indigo-react';
19} from 'indigo-react';
20import { uniq } from 'lodash';
20import { uniq } from 'lodash';
21−import { fromWei, toWei, toBN } from 'web3-utils';
21+import { toWei, toBN } from 'web3-utils';
22import { FieldArray } from 'react-final-form-arrays';
22import { FieldArray } from 'react-final-form-arrays';
23+import { Field } from 'react-final-form';
23
24
24import { usePointCursor } from 'store/pointCursor';
25import { usePointCursor } from 'store/pointCursor';
25import { useNetwork } from 'store/network';
26import { useNetwork } from 'store/network';
@@ -43,8 +44,10 @@ import useMailer from 'lib/useMailer';
43
44
44import ProgressButton from 'components/ProgressButton';
45import ProgressButton from 'components/ProgressButton';
45import Highlighted from 'components/Highlighted';
46import Highlighted from 'components/Highlighted';
47+import { ForwardButton } from 'components/Buttons';
48+import NeedFundsNotice from 'components/NeedFundsNotice';
49+
46import BridgeForm from 'form/BridgeForm';
50import BridgeForm from 'form/BridgeForm';
47−import { Field } from 'react-final-form';
48import { EmailInput } from 'form/Inputs';
51import { EmailInput } from 'form/Inputs';
49import {
52import {
50 buildEmailValidator,
53 buildEmailValidator,
@@ -59,9 +62,6 @@ import { WARNING, onlyHasWarning } from 'form/helpers';
59import useGasPrice from 'lib/useGasPrice';
62import useGasPrice from 'lib/useGasPrice';
60import timeout from 'lib/timeout';
63import timeout from 'lib/timeout';
61
64
62−import { ForwardButton } from 'components/Buttons';
63−import CopiableAddress from 'components/CopiableAddress';
64−
65const INITIAL_VALUES = { emails: [''] };
65const INITIAL_VALUES = { emails: [''] };
66
66
67const GAS_LIMIT = GAS_LIMITS.GIFT_PLANET;
67const GAS_LIMIT = GAS_LIMITS.GIFT_PLANET;
@@ -603,17 +603,7 @@ export default function InviteEmail() {
603 {renderButton({ handleSubmit, fields })}
603 {renderButton({ handleSubmit, fields })}
604
604
605 {needFunds && (
605 {needFunds && (
606− <Grid.Item full>
606+ <Grid.Item full as={NeedFundsNotice} {...needFunds} />
607− <Highlighted warning>
608− Your ownership address{' '}
609− <CopiableAddress>
610− {needFunds.address}
611− </CopiableAddress>{' '}
612− needs at least {fromWei(needFunds.minBalance)} ETH
613− and currently has {fromWei(needFunds.balance)} ETH.
614− Waiting until the account has enough funds.
615− </Highlighted>
616− </Grid.Item>
617 )}
607 )}
618
608
619 <Grid.Item full as={FormError} />
609 <Grid.Item full as={FormError} />