1import React, { useState, useCallback } from 'react';
2import { Just } from 'folktale/maybe';
4import { Grid, H4, Text, ErrorText } from 'indigo-react';
5import { RestartButton } from 'components/Buttons';
6import WarningBox from 'components/WarningBox';
7import LoadingBar from 'components/LoadingBar';
8import Highlighted from 'components/Highlighted';
10import { claimPointFromInvite } from 'lib/invite';
11import { fromWei } from 'lib/txn';
13import * as need from 'lib/need';
14import { useNetwork } from 'store/network';
15import { useWallet } from 'store/wallet';
16import { usePointCursor } from 'store/pointCursor';
17import useLifecycle from 'lib/useLifecycle';
19//TODO maybe we want to drop in PassportTransfer here?
20export default function DoReticket({ newWallet, completed }) {
21 const { web3, contracts } = useNetwork();
22 const { wallet, setUrbitWallet } = useWallet();
23 const { pointCursor } = usePointCursor();
25 const [generalError, setGeneralError] = useState();
26 const [{ label, progress }, setState] = useState({
30 const [needFunds, setNeedFunds] = useState();
32 // start reticketing transactions on mount
36 await claimPointFromInvite({
37 inviteWallet: need.wallet(wallet),
38 wallet: newWallet.value.wallet,
39 point: need.point(pointCursor),
40 web3: need.web3(web3),
41 contracts: need.contracts(contracts),
42 onUpdate: handleUpdate,
44 //TODO would it be better for this to happen in completed()?
45 setUrbitWallet(Just(newWallet.value.wallet));
46 completed(); //TODO don't auto-redirect
53 const handleUpdate = useCallback(
54 ({ type, state, value }) => {
57 return setState(state);
59 return setNeedFunds(value);
61 return setNeedFunds(false);
63 console.error(`Unknown update: ${type}`);
66 [setState, setNeedFunds]
69 const renderAdditionalInfo = () => {
73 <Grid.Item full className="mt8">
74 <ErrorText>{generalError.message.toString()}</ErrorText>
80 //TODO onClick={goToRestart}
88 <Grid.Item full className="mt8">
90 The address {needFunds.address} needs at least{' '}
91 {fromWei(needFunds.minBalance)} ETH and currently has{' '}
92 {fromWei(needFunds.balance)} ETH. Waiting until the account has
101 <Grid.Item full as={WarningBox} className="mt8">
102 Never give your Master Ticket to anyone
111 <Grid className={'auto-rows-min'}>
112 <Grid.Item full as={H4}>
115 <Grid.Item full as={Grid} className="mt3" gap={3}>
116 <Grid.Item full as={LoadingBar} progress={progress} />
118 <Text className="f5 green4">
119 This process can take up to 5 minutes to complete. Don't leave this
120 page until the process is complete.
125 {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