@@ -7,19 +7,10 @@ import * as azimuth from 'azimuth-js'
77import PointList from '../components/PointList'
88import ReactSVGComponents from '../components/ReactSVGComponents'
99import KeysAndMetadata from './Point/KeysAndMetadata'
10+import Actions from './Point/Actions'
1011import { BRIDGE_ERROR } from '../lib/error'
11−import { ROUTE_NAMES } from '../lib/router'
12−import { Row, Col, H1, H2, H3, P } from '../components/Base'
13−import { Button } from '../components/Base'
14−import {
15− ETH_ZERO_ADDR,
16− CURVE_ZERO_ADDR,
17− addressFromSecp256k1Public,
18− eqAddr
19− } from '../lib/wallet'
12+import { Row, Col, H1, H3 } from '../components/Base'
2013
21−const isPlanet = point =>
22− parseInt(point, 10) > 65535
2314
2415class Point extends React.Component {
2516
@@ -84,12 +75,6 @@ class Point extends React.Component {
8475
8576 const { spawned } = this.state
8677
87− const addr = wallet.matchWith({
88− Just: (wal) => addressFromSecp256k1Public(wal.value.publicKey),
89− Nothing: () => {
90− throw BRIDGE_ERROR.MISSING_WALLET
91− }
92− })
9378
9479 const point = pointCursor.matchWith({
9580 Just: (cursor) => cursor.value,
@@ -113,93 +98,11 @@ class Point extends React.Component {
11398
11499 const online = Maybe.Just.hasInstance(web3)
115100
116− const canSetTransferProxy = pointDetails.matchWith({
117− // also should check is addr is operator
118− Nothing: _ => false,
119− Just: details => eqAddr(details.value.owner, addr)
101+ const authenticated = wallet.matchWith({
102+ Just: _ => true,
103+ Nothing: _ => false
120104 })
121105
122− const canSetSpawnProxy = pointDetails.matchWith({
123− Nothing: _ => false,
124− Just: details =>
125− eqAddr(details.value.owner, addr) && details.value.active
126− })
127−
128−
129− const canSetManagementProxy = pointDetails.matchWith({
130− Nothing: _ => false,
131− Just: details =>
132− eqAddr(details.value.owner, addr) && details.value.active
133− })
134−
135− const canConfigureKeys = pointDetails.matchWith({
136− Nothing: _ => false,
137− Just: details => {
138− const canManage =
139− eqAddr(details.value.owner, addr)
140− || eqAddr(details.value.managementProxy, addr)
141−
142− return canManage && details.value.active
143− }
144− })
145−
146− const canIssueChild =
147− pointDetails.matchWith({
148− Nothing: () => false,
149− Just: (details) => {
150− const hasPermission =
151− eqAddr(details.value.owner, addr)
152− || eqAddr(details.value.spawnProxy, addr)
153−
154− const isBooted =
155− details.value.keyRevisionNumber > 0
156−
157− const isNotPlanet = !isPlanet(point)
158−
159− return hasPermission && isBooted && isNotPlanet
160− }
161− })
162−
163− const planet = isPlanet(point)
164−
165− const canTransfer =
166− pointDetails.matchWith({
167− Nothing: () => false,
168− Just: (deets) =>
169− eqAddr(deets.value.transferProxy, addr) ||
170− eqAddr(deets.value.owner, addr)
171− })
172−
173− const canGenKeyfile =
174− pointDetails.matchWith({
175− Nothing: () => false,
176− Just: (deets) => {
177− const hasPermission =
178− eqAddr(deets.value.owner, addr)
179− || eqAddr(deets.value.managementProxy, addr)
180−
181− const isBooted =
182− deets.value.keyRevisionNumber > 0
183−
184− return hasPermission && isBooted
185− }
186− })
187−
188− const canAcceptTransfer =
189− pointDetails.matchWith({
190− Nothing: () => false,
191− Just: (deets) =>
192− eqAddr(deets.value.transferProxy, addr)
193− })
194−
195− const canCancelTransfer =
196− pointDetails.matchWith({
197− Nothing: () => false,
198− Just: (deets) =>
199− eqAddr(deets.value.owner, addr) &&
200− !eqAddr(deets.value.transferProxy, ETH_ZERO_ADDR)
201− })
202−
203106 const routeHandler = route => {
204107 popRoute()
205108 pushRoute(route)
@@ -219,141 +122,26 @@ class Point extends React.Component {
219122 </div>
220123
221124
222− const displayReminder = pointDetails.matchWith({
223− Nothing: () => false,
224− Just: (deets) => {
225− return deets.value.encryptionKey === CURVE_ZERO_ADDR
226− && deets.value.authenticationKey === CURVE_ZERO_ADDR
227− }
228− })
229125
230126 return (
231127 <Row>
232128 <Col>
233−
234129 <div className={'mt-12 pt-6'}>
235130 { sigil }
236131 </div>
237−
238132 <H1><code>{ name }</code></H1>
239−
240− <H2>{ 'Actions' }</H2>
241−
242133 {
243− displayReminder
244− ? <P>{`Before you can issue child points or generate your Arvo
245− keyfile, you need to set your public keys.`}</P>
246− : ''
134+ authenticated
135+ ? <Actions pushRoute={ pushRoute } online={ online } point={ point } pointDetails={ pointDetails } wallet={ wallet }/>
136+ : null
247137 }
248138
249− <Row>
250− <Col className={'flex flex-column items-start col-md-4'}>
251− <Button
252− prop-size={'sm'}
253− prop-type={'link'}
254− disabled={ (online || planet) && !canIssueChild }
255− onClick={ () => {
256− pushRoute(ROUTE_NAMES.ISSUE_CHILD)
257− }}
258− >
259− { 'Issue child' }
260− </Button>
261−
262− <Button
263− prop-size={'sm'}
264− prop-type={'link'}
265− disabled={ !canAcceptTransfer }
266− onClick={ () => {
267− pushRoute(ROUTE_NAMES.ACCEPT_TRANSFER)
268− }}
269− >
270− { 'Accept incoming transfer' }
271− </Button>
272−
273− <Button
274− prop-size={'sm'}
275− prop-type={'link'}
276− disabled={ online && !canCancelTransfer }
277− onClick={ () => {
278− pushRoute(ROUTE_NAMES.CANCEL_TRANSFER)
279− }}
280− >
281− { 'Cancel outgoing transfer' }
282− </Button>
283−
284− <Button
285− prop-size={'sm'}
286− prop-type={'link'}
287− disabled={ !canGenKeyfile }
288− onClick={ () => {
289− pushRoute(ROUTE_NAMES.GEN_KEYFILE)
290− }}
291− >
292− { 'Generate Arvo keyfile' }
293− </Button>
294−
295− </Col>
296− <Col className={'flex flex-column items-start col-md-4'}>
297−
298− <Button
299− disabled={ online && !canSetSpawnProxy }
300− prop-size={'sm'}
301− prop-type={'link'}
302− onClick={ () => {
303− pushRoute(ROUTE_NAMES.SET_SPAWN_PROXY)
304− }}
305− >
306− { 'Set spawn proxy' }
307− </Button>
308−
309− <Button
310− disabled={ online && !canSetManagementProxy }
311− prop-size={'sm'}
312− prop-type={'link'}
313− onClick={ () => {
314− pushRoute(ROUTE_NAMES.SET_MANAGEMENT_PROXY)
315− }}
316− >
317− { 'Set management proxy' }
318− </Button>
319−
320− <Button
321− disabled={ online && !canConfigureKeys }
322− prop-size={'sm'}
323− prop-type={'link'}
324− onClick={ () => {
325− pushRoute(ROUTE_NAMES.SET_KEYS)
326− }}
327− >
328− { 'Set public keys' }
329− </Button>
330−
331− <Button
332− disabled={ online && !canTransfer }
333− prop-size={'sm'}
334− prop-type={'link'}
335− onClick={ () => {
336− pushRoute(ROUTE_NAMES.TRANSFER)
337− }}
338− >
339− { 'Transfer' }
340− </Button>
341−
342− </Col>
343− </Row>
344−
345−
346−
347− {
139+ {
348140 online
349141 ? <KeysAndMetadata pointDetails={ pointDetails } />
350142 : <div />
351− }
352−
353−
354−
143+ }
355144 { issuedPointList }
356−
357145 </Col>
358146 </Row>
359147 )