1import React from 'react';
2import { Just, Nothing } from 'folktale/maybe';
3import { Grid, H5, H1, HelpText, LinkButton, Flex } from 'indigo-react';
5import { useHistory } from 'store/history';
6import { useWallet } from 'store/wallet';
7import { usePointCache } from 'store/pointCache';
8import { usePointCursor } from 'store/pointCursor';
10import * as need from 'lib/need';
11import { ROUTE_NAMES } from 'lib/routeNames';
12import { isZeroAddress, abbreviateAddress } from 'lib/wallet';
13import useIsEclipticOwner from 'lib/useIsEclipticOwner';
14import { useSyncKnownPoints } from 'lib/useSyncPoints';
16import View from 'components/View';
17import FooterButton from 'components/FooterButton';
18import Blinky from 'components/Blinky';
19import Passport from 'components/Passport';
20import useRejectedIncomingPointTransfers from 'lib/useRejectedIncomingPointTransfers';
21import pluralize from 'lib/pluralize';
23const getFromMaybe = (obj, key, defaultValue) =>
25 Nothing: () => defaultValue,
28 Ok: r => r.value[key],
29 Error: e => defaultValue,
33const hasTransferProxy = (details, point) =>
34 !isZeroAddress(details.transferProxy);
36const PointList = function({ points, className, actions, ...rest }) {
37 const { setPointCursor } = usePointCursor();
38 const history = useHistory();
41 <Grid gap={3} className={className}>
42 {points.map((point, i) => (
43 <Grid.Item half={(i % 2) + 1} key={point}>
49 setPointCursor(Just(point));
50 history.push(history.names.POINT);
55 <Flex.Item className="mt2">{actions(point, i)}</Flex.Item>
64function ActionButtons({ actions = [] }) {
67 {actions.map(action => (
72 onClick={action.onClick}>
80export default function Points() {
81 const { wallet } = useWallet();
82 const history = useHistory();
83 const { setPointCursor } = usePointCursor();
84 const { controlledPoints, getDetails } = usePointCache();
85 const isEclipticOwner = useIsEclipticOwner();
89 ] = useRejectedIncomingPointTransfers();
91 const address = need.addressFromWallet(wallet);
93 const loading = Nothing.hasInstance(controlledPoints);
95 const ownedPoints = getFromMaybe(controlledPoints, 'ownedPoints', []);
96 const incomingPoints = getFromMaybe(
100 ).filter(point => !rejectedPoints.includes(point));
101 const managingPoints = getFromMaybe(controlledPoints, 'managingPoints', []);
102 const votingPoints = getFromMaybe(controlledPoints, 'votingPoints', []);
103 const spawningPoints = getFromMaybe(controlledPoints, 'spawningPoints', []);
104 const outgoingPoints = ownedPoints.filter(point =>
105 getDetails(point).matchWith({
106 Nothing: () => false,
107 Just: p => hasTransferProxy(p.value),
111 const multipassPoints = [
118 // sync display details for known points
129 <Grid className="mt6">
130 <Grid.Item full as={H1} className="f6 mono gray4 mb4">
131 {abbreviateAddress(address)}
135 <Grid.Item full as={HelpText} className="mt8 t-center">
136 <Blinky /> Loading...
140 {incomingPoints.length > 0 && (
141 <Grid.Item full as={Grid} gap={1} className="mb6">
142 <Grid.Item full as={H5}>
144 incomingPoints.length,
152 points={incomingPoints}
153 actions={(point, i) => (
159 setPointCursor(Just(point));
160 history.push(history.names.ACCEPT_TRANSFER);
166 addRejectedPoint(point);
177 {outgoingPoints.length > 0 && (
178 <Grid.Item full as={Grid} gap={1} className="mb6">
179 <Grid.Item full as={H5}>
181 outgoingPoints.length,
189 points={outgoingPoints}
190 actions={(point, i) => (
196 setPointCursor(Just(point));
197 // TODO: deep linking to fix this duplicate route
198 history.push(history.names.CANCEL_TRANSFER);
209 {multipassPoints.length > 0 && (
210 <Grid.Item full as={Grid} gap={1}>
211 <Grid.Item full as={H5}>
212 {pluralize(multipassPoints.length, 'Multipass', 'Multipasses')}
214 <Grid.Item full as={PointList} points={multipassPoints} />
218 {isEclipticOwner && (
220 detail="You have the authority to create a new Galaxy."
221 onClick={() => history.push(ROUTE_NAMES.CREATE_GALAXY)}>
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