on master help sign in
netkeys: custom hook handles new point login
3fc5a9ctomholford
src/lib/types/L1Point.ts+1
@@ -4,6 +4,7 @@ export type L1Point = {
4 authenticationKey: string;
4 authenticationKey: string;
5 continuityNumber: string;
5 continuityNumber: string;
6 cryptoSuiteVersion: string;
6 cryptoSuiteVersion: string;
7+ dominion?: string;
7 encryptionKey: string;
8 encryptionKey: string;
8 escapeRequested: boolean;
9 escapeRequested: boolean;
9 escapeRequestedTo: string;
10 escapeRequestedTo: string;
src/lib/useHasNetworkKeysSet.tsx+2−1
@@ -1,5 +1,6 @@
1import { useEffect, useMemo, useState } from 'react';
1import { useEffect, useMemo, useState } from 'react';
2import * as need from 'lib/need';
2import * as need from 'lib/need';
3+import { Just } from 'folktale/maybe';
3import { usePointCache } from 'store/pointCache';
4import { usePointCache } from 'store/pointCache';
4import { usePointCursor } from 'store/pointCursor';
5import { usePointCursor } from 'store/pointCursor';
5import { convertToInt } from 'lib/convertToInt';
6import { convertToInt } from 'lib/convertToInt';
@@ -11,7 +12,7 @@ export const useHasNetworkKeysSet = () => {
11 const [networkKeysSet, setNetworkKeysSet] = useState<boolean>(true);
12 const [networkKeysSet, setNetworkKeysSet] = useState<boolean>(true);
12
13
13 useEffect(() => {
14 useEffect(() => {
14− if (point) {
15+ if (point && Just.hasInstance(getDetails(point))) {
15 const details = need.details(getDetails(point));
16 const details = need.details(getDetails(point));
16 const networkRevision = convertToInt(details.keyRevisionNumber, 10);
17 const networkRevision = convertToInt(details.keyRevisionNumber, 10);
17 setNetworkKeysSet(networkRevision > 0);
18 setNetworkKeysSet(networkRevision > 0);
src/store/lib/useDetailsStore.js → src/store/lib/useDetailsStore.tsrenamed+3−1
@@ -4,8 +4,10 @@ import * as azimuth from 'azimuth-js';
4
4
5import useRoller from '../../lib/useRoller';
5import useRoller from '../../lib/useRoller';
6import { useNetwork } from '../network';
6import { useNetwork } from '../network';
7+import { L1Point } from 'lib/types/L1Point';
8+import { L2Point } from '@urbit/roller-api';
7
9
8−const toL1Details = point => {
10+const toL1Details = (point: L2Point): L1Point => {
9 return {
11 return {
10 dominion: 'l2',
12 dominion: 'l2',
11 active: true,
13 active: true,