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';
21const getFromMaybe = (obj, key, defaultValue) =>
23 Nothing: () => defaultValue,
26 Ok: r => r.value[key],
27 Error: e => defaultValue,
31const hasTransferProxy = (details, point) =>
32 !isZeroAddress(details.transferProxy);
34const PointList = function({ points, className, actions, ...rest }) {
35 const { setPointCursor } = usePointCursor();
36 const history = useHistory();
39 <Grid gap={3} className={className}>
40 {points.map((point, i) => (
41 <Grid.Item half={(i % 2) + 1} key={point}>
47 setPointCursor(Just(point));
48 history.push(history.names.POINT);
53 <Flex.Item className="mt2">{actions(point, i)}</Flex.Item>
62function ActionButtons({ actions = [] }) {
65 {actions.map(action => (
70 onClick={action.onClick}>
78export default function Points() {
79 const { wallet } = useWallet();
80 const history = useHistory();
81 const { setPointCursor } = usePointCursor();
82 const { controlledPoints, getDetails } = usePointCache();
83 const isEclipticOwner = useIsEclipticOwner();
85 const address = need.addressFromWallet(wallet);
87 const loading = Nothing.hasInstance(controlledPoints);
89 const ownedPoints = getFromMaybe(controlledPoints, 'ownedPoints', []);
90 const incomingPoints = getFromMaybe(controlledPoints, 'incomingPoints', []);
91 const managingPoints = getFromMaybe(controlledPoints, 'managingPoints', []);
92 const votingPoints = getFromMaybe(controlledPoints, 'votingPoints', []);
93 const spawningPoints = getFromMaybe(controlledPoints, 'spawningPoints', []);
94 const outgoingPoints = ownedPoints.filter(point =>
95 getDetails(point).matchWith({
97 Just: p => hasTransferProxy(p.value),
101 const multipassPoints = [
108 // sync display details for known points
119 <Grid className="mt6">
120 <Grid.Item full as={H1} className="f6 mono gray4 mb4">
121 {abbreviateAddress(address)}
125 <Grid.Item full as={HelpText} className="mt8 t-center">
126 <Blinky /> Loading...
130 {incomingPoints.length > 0 && (
131 <Grid.Item full as={Grid} gap={1} className="mb6">
132 <Grid.Item full as={H5}>
138 points={incomingPoints}
139 actions={(point, i) => (
145 setPointCursor(Just(point));
146 history.push(history.names.ACCEPT_TRANSFER);
152 setPointCursor(Just(point));
153 history.push(history.names.REJECT_TRANSFER);
164 {outgoingPoints.length > 0 && (
165 <Grid.Item full as={Grid} gap={1} className="mb6">
166 <Grid.Item full as={H5}>
172 points={outgoingPoints}
173 actions={(point, i) => (
179 setPointCursor(Just(point));
180 // TODO: deep linking to fix this duplicate route
181 history.push(history.names.CANCEL_TRANSFER);
192 {multipassPoints.length > 0 && (
193 <Grid.Item full as={Grid} gap={1}>
194 <Grid.Item full as={H5}>
197 <Grid.Item full as={PointList} points={multipassPoints} />
201 {isEclipticOwner && (
203 detail="You have the authority to create a new Galaxy."
204 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