1import React, { useState, useCallback } from 'react';
3import { Grid, H4, Text, ErrorText } from 'indigo-react';
4import { RestartButton } from 'components/Buttons';
5import WarningBox from 'components/WarningBox';
6import LoadingBar from 'components/LoadingBar';
7import Highlighted from 'components/Highlighted';
9import { claimPointFromInvite } from 'lib/invite';
10import { fromWei } from 'lib/txn';
12import * as need from 'lib/need';
13import { useNetwork } from 'store/network';
14import { useWallet } from 'store/wallet';
15import { usePointCursor } from 'store/pointCursor';
16import useLifecycle from 'lib/useLifecycle';
18//TODO maybe we want to drop in PassportTransfer here?
19export default function DoReticket({ newWallet, completed }) {
20 const { web3, contracts } = useNetwork();
21 const { wallet, setUrbitWallet } = useWallet();
22 const { pointCursor } = usePointCursor();
24 const [generalError, setGeneralError] = useState();
25 const [{ label, progress }, setState] = useState({
29 const [needFunds, setNeedFunds] = useState();
31 // start reticketing transactions on mount
33 claimPointFromInvite({
34 inviteWallet: need.wallet(wallet),
35 wallet: newWallet.value.wallet,
36 point: need.point(pointCursor),
37 web3: need.web3(web3),
38 contracts: need.contracts(contracts),
39 onUpdate: handleUpdate,
42 setUrbitWallet(newWallet.value.wallet);
43 next(); //TODO don't auto-redirect
50 const handleUpdate = useCallback(
51 ({ type, state, value }) => {
54 return setState(state);
56 return setNeedFunds(value);
58 return setNeedFunds(false);
60 console.error(`Unknown update: ${type}`);
63 [setState, setNeedFunds]
70 const renderAdditionalInfo = () => {
74 <Grid.Item full className="mt8">
75 <ErrorText>{generalError.message.toString()}</ErrorText>
81 //TODO onClick={goToRestart}
89 <Grid.Item full className="mt8">
91 The address {needFunds.address} needs at least{' '}
92 {fromWei(needFunds.minBalance)} ETH and currently has{' '}
93 {fromWei(needFunds.balance)} ETH. Waiting until the account has
100 if (progress < 100) {
102 <Grid.Item full as={WarningBox} className="mt8">
103 Never give your Master Ticket to anyone
112 <Grid className={'auto-rows-min'}>
113 <Grid.Item full as={H4}>
116 <Grid.Item full as={Grid} className="mt3" gap={3}>
117 <Grid.Item full as={LoadingBar} progress={progress} />
119 <Text className="f5 green4">
120 This process can take up to 5 minutes to complete. Don't leave this
121 page until the process is complete.
126 {renderAdditionalInfo()}
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