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';
22const getFromMaybe = (obj, key, defaultValue) =>
24 Nothing: () => defaultValue,
27 Ok: r => r.value[key],
28 Error: e => defaultValue,
32const hasTransferProxy = (details, point) =>
33 !isZeroAddress(details.transferProxy);
35const PointList = function({ points, className, actions, ...rest }) {
36 const { setPointCursor } = usePointCursor();
37 const history = useHistory();
40 <Grid gap={3} className={className}>
41 {points.map((point, i) => (
42 <Grid.Item half={(i % 2) + 1} key={point}>
48 setPointCursor(Just(point));
49 history.push(history.names.POINT);
54 <Flex.Item className="mt2">{actions(point, i)}</Flex.Item>
63function ActionButtons({ actions = [] }) {
66 {actions.map(action => (
71 onClick={action.onClick}>
79export default function Points() {
80 const { wallet } = useWallet();
81 const history = useHistory();
82 const { setPointCursor } = usePointCursor();
83 const { controlledPoints, getDetails } = usePointCache();
84 const isEclipticOwner = useIsEclipticOwner();
88 ] = useRejectedIncomingPointTransfers();
90 const address = need.addressFromWallet(wallet);
92 const loading = Nothing.hasInstance(controlledPoints);
94 const ownedPoints = getFromMaybe(controlledPoints, 'ownedPoints', []);
95 const incomingPoints = getFromMaybe(
99 ).filter(point => !rejectedPoints.includes(point));
100 const managingPoints = getFromMaybe(controlledPoints, 'managingPoints', []);
101 const votingPoints = getFromMaybe(controlledPoints, 'votingPoints', []);
102 const spawningPoints = getFromMaybe(controlledPoints, 'spawningPoints', []);
103 const outgoingPoints = ownedPoints.filter(point =>
104 getDetails(point).matchWith({
105 Nothing: () => false,
106 Just: p => hasTransferProxy(p.value),
110 const multipassPoints = [
117 // sync display details for known points
128 <Grid className="mt6">
129 <Grid.Item full as={H1} className="f6 mono gray4 mb4">
130 {abbreviateAddress(address)}
134 <Grid.Item full as={HelpText} className="mt8 t-center">
135 <Blinky /> Loading...
139 {incomingPoints.length > 0 && (
140 <Grid.Item full as={Grid} gap={1} className="mb6">
141 <Grid.Item full as={H5}>
147 points={incomingPoints}
148 actions={(point, i) => (
154 setPointCursor(Just(point));
155 history.push(history.names.ACCEPT_TRANSFER);
161 addRejectedPoint(point);
172 {outgoingPoints.length > 0 && (
173 <Grid.Item full as={Grid} gap={1} className="mb6">
174 <Grid.Item full as={H5}>
180 points={outgoingPoints}
181 actions={(point, i) => (
187 setPointCursor(Just(point));
188 // TODO: deep linking to fix this duplicate route
189 history.push(history.names.CANCEL_TRANSFER);
200 {multipassPoints.length > 0 && (
201 <Grid.Item full as={Grid} gap={1}>
202 <Grid.Item full as={H5}>
205 <Grid.Item full as={PointList} points={multipassPoints} />
209 {isEclipticOwner && (
211 detail="You have the authority to create a new Galaxy."
212 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