on master help sign in
Merge pull request #255 from urbit/fix/unify-needs-funds

fix: unify needs funds component and give pending affordance

commit555fac968c24c4764b89097c3bf4e3cdeb2db19b authorMatt Condon <mattgcondon@gmail.com> dateTue 27 Aug 2019, 17:36 (7 years ago) parent4308d201463f63
5 files changed+44−50
src/components/InlineEthereumTransaction.js+7−10 src/components/NeedFundsNotice.js+25 src/views/Activate/PassportTransfer.js+2−11 src/views/Admin/Reticket/ReticketExecute.js+4−13 src/views/Invite/InviteEmail.js+6−16
src/components/InlineEthereumTransaction.js+7−10
@@ -9,7 +9,6 @@ import {
99 H5,
1010 Text,
1111} from 'indigo-react';
12−import { fromWei } from 'web3-utils';
1312
1413import { useExploreTxUrl } from 'lib/explorer';
1514import { hexify } from 'lib/txn';
@@ -19,11 +18,10 @@ import BridgeForm from 'form/BridgeForm';
1918import Condition from 'form/Condition';
2019
2120import { GenerateButton, ForwardButton, RestartButton } from './Buttons';
22−import WarningBox from './WarningBox';
2321import CopyButton from './CopyButton';
2422import ProgressButton from './ProgressButton';
25−import CopiableAddress from './CopiableAddress';
2623import convertToInt from 'lib/convertToInt';
24+import NeedFundsNotice from './NeedFundsNotice';
2725
2826export default function InlineEthereumTransaction({
2927 // from useEthereumTransaction.bind
@@ -152,13 +150,12 @@ export default function InlineEthereumTransaction({
152150 )}
153151
154152 {needFunds && (
155− <Grid.Item full as={WarningBox} className="mt3">
156− The address{' '}
157− <CopiableAddress>{needFunds.address}</CopiableAddress> needs at
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>
153+ <Grid.Item
154+ full
155+ as={NeedFundsNotice}
156+ className="mt3"
157+ {...needFunds}
158+ />
162159 )}
163160
164161 {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 @@
11import React, { useState, useCallback } from 'react';
22import { Grid, Text, ErrorText } from 'indigo-react';
3−import { fromWei } from 'web3-utils';
43
54import { useNetwork } from 'store/network';
65import { useWallet } from 'store/wallet';
@@ -17,12 +16,11 @@ import timeout from 'lib/timeout';
1716
1817import WarningBox from 'components/WarningBox';
1918import LoadingBar from 'components/LoadingBar';
20−import Highlighted from 'components/Highlighted';
2119import { RestartButton } from 'components/Buttons';
20+import NeedFundsNotice from 'components/NeedFundsNotice';
2221
2322import { useActivateFlow } from './ActivateFlow';
2423import PassportView from './PassportView';
25−import CopiableAddress from 'components/CopiableAddress';
2624
2725const labelForProgress = progress => {
2826 if (progress <= 0) {
@@ -162,14 +160,7 @@ export default function PassportTransfer({ className, resetActivateRouter }) {
162160
163161 if (needFunds) {
164162 return (
165− <Grid.Item full className="mt8">
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>
163+ <Grid.Item full as={NeedFundsNotice} className="mt8" {...needFunds} />
173164 );
174165 }
175166
src/views/Admin/Reticket/ReticketExecute.js+4−13
@@ -1,7 +1,6 @@
11import React, { useState, useCallback } from 'react';
22import { Just, Nothing } from 'folktale/maybe';
33import { Grid, H4, Text, ErrorText } from 'indigo-react';
4−import { fromWei } from 'web3-utils';
54
65import {
76 reticketPointBetweenWallets,
@@ -9,6 +8,8 @@ import {
98} from 'lib/reticket';
109import * as need from 'lib/need';
1110import useLifecycle from 'lib/useLifecycle';
11+import { WALLET_TYPES } from 'lib/wallet';
12+import convertToInt from 'lib/convertToInt';
1213
1314import { useNetwork } from 'store/network';
1415import { useWallet } from 'store/wallet';
@@ -19,10 +20,7 @@ import { useHistory } from 'store/history';
1920import { RestartButton, ForwardButton } from 'components/Buttons';
2021import WarningBox from 'components/WarningBox';
2122import LoadingBar from 'components/LoadingBar';
22−import Highlighted from 'components/Highlighted';
23−import { WALLET_TYPES } from 'lib/wallet';
24−import CopiableAddress from 'components/CopiableAddress';
25−import convertToInt from 'lib/convertToInt';
23+import NeedFundsNotice from 'components/NeedFundsNotice';
2624
2725const labelForProgress = progress => {
2826 if (progress <= 0) {
@@ -129,14 +127,7 @@ export default function ReticketExecute({ newWallet, setNewWallet }) {
129127
130128 if (needFunds) {
131129 return (
132− <Grid.Item full className="mt4">
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>
130+ <Grid.Item full as={NeedFundsNotice} className="mt4" {...needFunds} />
140131 );
141132 }
142133
src/views/Invite/InviteEmail.js+6−16
@@ -18,8 +18,9 @@ import {
1818 AccessoryIcon,
1919} from 'indigo-react';
2020import { uniq } from 'lodash';
21−import { fromWei, toWei, toBN } from 'web3-utils';
21+import { toWei, toBN } from 'web3-utils';
2222import { FieldArray } from 'react-final-form-arrays';
23+import { Field } from 'react-final-form';
2324
2425import { usePointCursor } from 'store/pointCursor';
2526import { useNetwork } from 'store/network';
@@ -43,8 +44,10 @@ import useMailer from 'lib/useMailer';
4344
4445import ProgressButton from 'components/ProgressButton';
4546import Highlighted from 'components/Highlighted';
47+import { ForwardButton } from 'components/Buttons';
48+import NeedFundsNotice from 'components/NeedFundsNotice';
49+
4650import BridgeForm from 'form/BridgeForm';
47−import { Field } from 'react-final-form';
4851import { EmailInput } from 'form/Inputs';
4952import {
5053 buildEmailValidator,
@@ -59,9 +62,6 @@ import { WARNING, onlyHasWarning } from 'form/helpers';
5962import useGasPrice from 'lib/useGasPrice';
6063import timeout from 'lib/timeout';
6164
62−import { ForwardButton } from 'components/Buttons';
63−import CopiableAddress from 'components/CopiableAddress';
64−
6565const INITIAL_VALUES = { emails: [''] };
6666
6767const GAS_LIMIT = GAS_LIMITS.GIFT_PLANET;
@@ -603,17 +603,7 @@ export default function InviteEmail() {
603603 {renderButton({ handleSubmit, fields })}
604604
605605 {needFunds && (
606− <Grid.Item full>
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>
606+ <Grid.Item full as={NeedFundsNotice} {...needFunds} />
617607 )}
618608
619609 <Grid.Item full as={FormError} />