on master help sign in
activate:
f3fddfetomholford
src/lib/types/L2Transaction.ts+3−2
@@ -1,5 +1,6 @@
1import RollerRPCAPI, { EthAddress, Proxy, Ship } from '@urbit/roller-api';
1import RollerRPCAPI, { EthAddress, Proxy, Ship } from '@urbit/roller-api';
2import WalletConnect from '@walletconnect/client';
2import WalletConnect from '@walletconnect/client';
3+import BridgeWallet from './BridgeWallet';
3
4
4export type TransactionType =
5export type TransactionType =
5 | 'transferPoint'
6 | 'transferPoint'
@@ -43,6 +44,6 @@ export interface ReticketParams {
43 point: Ship;
44 point: Ship;
44 to: EthAddress;
45 to: EthAddress;
45 manager: EthAddress;
46 manager: EthAddress;
46− fromWallet: UrbitWallet;
47+ fromWallet: BridgeWallet;
47− toWallet: any; // TODO: wallet type
48+ toWallet: UrbitWallet;
48}
49}
src/views/Activate/ActivateCodeForm.tsx+9−2
@@ -19,8 +19,8 @@ import WarningBox from 'components/WarningBox';
19import useRoller from 'lib/useRoller';
19import useRoller from 'lib/useRoller';
20import useImpliedTicket from 'lib/useImpliedTicket';
20import useImpliedTicket from 'lib/useImpliedTicket';
21import { generateWallet } from 'lib/walletgen';
21import { generateWallet } from 'lib/walletgen';
22−import { urbitWalletFromTicket } from 'lib/wallet';
22+import { urbitWalletFromTicket, walletFromMnemonic } from 'lib/wallet';
23−import { POINT_PROXIES } from 'lib/constants';
23+import { DEFAULT_HD_PATH, POINT_PROXIES } from 'lib/constants';
24import useBreakpoints from 'lib/useBreakpoints';
24import useBreakpoints from 'lib/useBreakpoints';
25import { Ship } from '@urbit/roller-api';
25import { Ship } from '@urbit/roller-api';
26import { convertToInt } from 'lib/convertToInt';
26import { convertToInt } from 'lib/convertToInt';
@@ -45,6 +45,7 @@ const ActivateCodeForm = ({ afterSubmit }: ActivateCodeFormProps) => {
45 setDerivedWallet,
45 setDerivedWallet,
46 setInviteWallet,
46 setInviteWallet,
47 setIsIn,
47 setIsIn,
48+ setSendWallet,
48 } = useActivateFlow();
49 } = useActivateFlow();
49
50
50 // this is a pretty naive way to detect if we're on a mobile device
51 // this is a pretty naive way to detect if we're on a mobile device
@@ -114,6 +115,12 @@ const ActivateCodeForm = ({ afterSubmit }: ActivateCodeFormProps) => {
114 const _inviteWallet: UrbitWallet = need.wallet(inviteWallet);
115 const _inviteWallet: UrbitWallet = need.wallet(inviteWallet);
115 const inviteAddress = _inviteWallet.ownership.keys.address;
116 const inviteAddress = _inviteWallet.ownership.keys.address;
116
117
118+ const sendWallet = await walletFromMnemonic(
119+ _inviteWallet.ownership.seed,
120+ DEFAULT_HD_PATH
121+ );
122+ setSendWallet(sendWallet);
123+
117 let incoming = await loadPoints(inviteAddress);
124 let incoming = await loadPoints(inviteAddress);
118
125
119 // Set derived
126 // Set derived
src/views/Activate/MasterKeyTransfer.tsx+3−8
@@ -20,7 +20,7 @@ const MasterKeyTransfer = () => {
20 derivedPatp,
20 derivedPatp,
21 derivedPoint,
21 derivedPoint,
22 derivedWallet,
22 derivedWallet,
23− inviteWallet,
23+ sendWallet,
24 } = useActivateFlow();
24 } = useActivateFlow();
25 const [error, setError] = useState();
25 const [error, setError] = useState();
26
26
@@ -33,18 +33,13 @@ const MasterKeyTransfer = () => {
33 to: derivedWallet.value.ownership.keys.address,
33 to: derivedWallet.value.ownership.keys.address,
34 manager: derivedWallet.value.management.keys.address,
34 manager: derivedWallet.value.management.keys.address,
35 toWallet: derivedWallet.value,
35 toWallet: derivedWallet.value,
36− fromWallet: inviteWallet.value,
36+ fromWallet: sendWallet.value,
37 });
37 });
38 } catch (e) {
38 } catch (e) {
39 console.error(e);
39 console.error(e);
40 setError(e);
40 setError(e);
41 }
41 }
42− }, [
43− derivedWallet,
44− performL2Reticket,
42+ }, [derivedWallet, performL2Reticket, derivedPoint.value, sendWallet.value]);
45− derivedPoint.value,
46− inviteWallet.value,
47− ]);
48
43
49 useFadeIn();
44 useFadeIn();
50
45
src/views/Activate/useActivateFlowState.js+25−3
@@ -4,13 +4,30 @@ import { Nothing } from 'folktale/maybe';
4export default function useActivateFlowState() {
4export default function useActivateFlowState() {
5 const [derivedPatp, setDerivedPatp] = useState(Nothing());
5 const [derivedPatp, setDerivedPatp] = useState(Nothing());
6 const [derivedPoint, setDerivedPoint] = useState(Nothing());
6 const [derivedPoint, setDerivedPoint] = useState(Nothing());
7− const [derivedPointDominion, setDerivedPointDominion] = useState(Nothing());
8− const [derivedWallet, setDerivedWallet] = useState(Nothing());
9 const [generated, setGenerated] = useState(false);
7 const [generated, setGenerated] = useState(false);
10 const [incomingPoints, setIncomingPoints] = useState(Nothing());
8 const [incomingPoints, setIncomingPoints] = useState(Nothing());
11− const [inviteWallet, setInviteWallet] = useState(Nothing());
9+ const [derivedPointDominion, setDerivedPointDominion] = useState(Nothing());
12 const [isIn, setIsIn] = useState(false);
10 const [isIn, setIsIn] = useState(false);
13
11
12+ // A new wallet generated after confirming that the invite ticket is valid
13+ // and the point is available for activation.
14+ // At the end of the Activate flow, the point will be transferred
15+ // from the invite wallet to the derived wallet. When the user confirms
16+ // the Master Key (ticket) and downloads the passport / mnemonic,
17+ // it is for the derived wallet
18+ // type UrbitWallet
19+ const [derivedWallet, setDerivedWallet] = useState(Nothing());
20+ // The wallet generated deterministically during the invite flow;
21+ // it is re-generated when the user starts the Activate flow. It is used
22+ // to derive and confirm a shareable ticket that a user can activate a point with.
23+ // type UrbitWallet
24+ const [inviteWallet, setInviteWallet] = useState(Nothing());
25+ // This wallet is generated from the invite wallet's seed phrase.
26+ // It is used during the transfer phase of the invite flow to send transactions.
27+ // useMultiKeyFileGenerator.
28+ // type bip32.BIP32Interface
29+ const [sendWallet, setSendWallet] = useState(Nothing());
30+
14 const reset = useCallback(() => {
31 const reset = useCallback(() => {
15 setDerivedPatp(Nothing());
32 setDerivedPatp(Nothing());
16 setDerivedPoint(Nothing());
33 setDerivedPoint(Nothing());
@@ -19,13 +36,16 @@ export default function useActivateFlowState() {
19 setGenerated(false);
36 setGenerated(false);
20 setIncomingPoints(Nothing());
37 setIncomingPoints(Nothing());
21 setInviteWallet(Nothing());
38 setInviteWallet(Nothing());
39+ setSendWallet(Nothing());
22 }, [
40 }, [
41+ setDerivedPatp,
23 setDerivedPoint,
42 setDerivedPoint,
24 setDerivedPointDominion,
43 setDerivedPointDominion,
25 setDerivedWallet,
44 setDerivedWallet,
26 setGenerated,
45 setGenerated,
27 setIncomingPoints,
46 setIncomingPoints,
28 setInviteWallet,
47 setInviteWallet,
48+ setSendWallet,
29 ]);
49 ]);
30
50
31 return {
51 return {
@@ -38,6 +58,7 @@ export default function useActivateFlowState() {
38 inviteWallet,
58 inviteWallet,
39 isIn,
59 isIn,
40 reset,
60 reset,
61+ sendWallet,
41 setDerivedPatp,
62 setDerivedPatp,
42 setDerivedPoint,
63 setDerivedPoint,
43 setDerivedPointDominion,
64 setDerivedPointDominion,
@@ -46,5 +67,6 @@ export default function useActivateFlowState() {
46 setIncomingPoints,
67 setIncomingPoints,
47 setInviteWallet,
68 setInviteWallet,
48 setIsIn,
69 setIsIn,
70+ setSendWallet,
49 };
71 };
50}
72}