@@ -0,0 +1,212 @@
1+import React, { useState, useCallback, useMemo, useEffect } from 'react';
3+import { useNetwork } from 'store/network';
4+import { useWallet } from 'store/wallet';
5+import { useHistory } from 'store/history';
6+import { usePointCursor } from 'store/pointCursor';
8+import * as need from 'lib/need';
9+import useLifecycle from 'lib/useLifecycle';
10+import useBlockWindowClose from 'lib/useBlockWindowClose';
11+import { reticketPointBetweenWallets } from 'lib/reticket';
13+import { Anchor, Box, Text } from '@tlon/indigo-react';
14+import { useActivateFlow } from './ActivateFlow';
15+import ActivateView from './ActivateView';
16+import { POINT_DOMINIONS } from 'lib/constants';
17+import { From } from '@urbit/roller-api';
18+import useRoller from 'lib/useRoller';
19+import { FadeableActivateHeader as ActivateHeader } from './ActivateHeader';
20+import { FadeableActivateButton as ActivateButton } from './ActivateButton';
21+import useFadeIn from './useFadeIn';
22+import PointPresenter from './PointPresenter';
24+const MasterKeyTransfer = ({ className, resetActivateRouter }) => {
25+ const { replaceWith, names } = useHistory();
26+ const { setUrbitWallet } = useWallet();
27+ const { setPointCursor } = usePointCursor();
28+ const { web3, contracts, networkType } = useNetwork();
29+ const { api, transferPoint } = useRoller();
33+ derivedPointDominion,
36+ reset: resetActivateFlow,
37+ } = useActivateFlow();
38+ const [generalError, setGeneralError] = useState();
39+ const [progress, setProcesss] = useState(0);
40+ const [needFunds, setNeedFunds] = useState();
42+ // const [transferTxHash, setTransferTxHash] = useState<string | null>(null);
44+ const _inviteWallet = need.wallet(inviteWallet);
45+ const _wallet = need.wallet(derivedWallet);
46+ const _point = need.point(derivedPoint);
47+ const _web3 = need.web3(web3);
48+ const _contracts = need.contracts(contracts);
50+ const goToLogin = useCallback(
51+ () => replaceWith([{ key: names.LOGIN }, { key: names.POINT }]),
55+ const goToRestart = useCallback(() => {
56+ // NOTE: because we're already on the ACTIVATE view in the history,
57+ // react (intelligently) doesn't trigger a re-render and that means the
58+ // current state of the two nested routers (activate & passport) stick
59+ // around unless we manually clear them.
60+ // we only need to clear activate because that will unmount the passport
61+ // router (which will be set to initialRoutes when mounted again)
63+ // 2) reset local router
64+ resetActivateRouter();
65+ // 3) clear the state
67+ }, [resetActivateRouter, resetActivateFlow]);
69+ const claimL2Point = useCallback(async () => {
70+ console.log('claiming l2 point:');
71+ const transferFrom: From = {
72+ ship: derivedPatp.value,
76+ const l2point = await api.getPoint(derivedPoint.value);
77+ const fromAddress = l2point.ownership?.owner?.address!;
78+ const txHash = await transferPoint({
79+ point: derivedPoint.value,
81+ to: _inviteWallet.address,
82+ fromAddress: fromAddress,
83+ signingKey: derivedWallet.value.ownership.keys.private,
86+ // setTransferTxHash(txHash);
88+ _inviteWallet.address,
96+ // const claimL1Point = useCallback(async () => {
97+ // await reticketPointBetweenWallets({
98+ // fromWallet: _inviteWallet,
99+ // toWallet: _wallet,
102+ // contracts: _contracts,
104+ // onUpdate: handleUpdate,
105+ // transferEth: true,
106+ // //NOTE not passing wc function, we always have invite ticket wallet
108+ // }, [_contracts, _inviteWallet, _point, _wallet, _web3, networkType]);
110+ const claimPoint = useCallback(async () => {
111+ setGeneralError(false);
115+ if (derivedPointDominion.value === POINT_DOMINIONS.L2) {
116+ await claimL2Point();
118+ // await claimL1Point();
119+ console.log('do nothing for now');
124+ // set the global wallet
125+ // setUrbitWallet(derivedWallet);
126+ // setPointCursor(derivedPoint);
128+ // and redirect to login
129+ // await timeout(3000);
132+ console.error(error);
133+ // some generic error
134+ setGeneralError(error);
136+ }, [derivedPointDominion, claimL2Point]);
138+ // useBlockWindowClose();
141+ useLifecycle(() => {
145+ const header = useMemo(() => {
150+ Congratulations{' '}
151+ <Text fontFamily="Source Code Pro" fontSize={3} fontWeight={600}>
159+ }, [derivedPatp.value]);
161+ const footer = useMemo(() => {
165+ flexDirection={'column'}
167+ justifyContent={'space-between'}>
171+ 'https://github.com/urbit/port/releases/latest/download/Port.dmg'
175+ Download the Client for Mac
178+ href="https://urbit.org/getting-started/cli"
180+ marginBottom={'10px'}
182+ fontFamily={'Inter'}
186+ textAlign={'center'}>
187+ or setup via command line
194+ <ActivateView header={header} footer={footer}>
196+ alignItems={'center'}
198+ flexDirection={'column'}
201+ justifyContent={'center'}>
203+ patp={derivedPatp.value}
212+export default MasterKeyTransfer;