on master help sign in
fix: clean up logic for login/ticket
c622065Matt Condon (shrugs)
src/views/Activate/ActivateCode.js+2−4
@@ -77,11 +77,9 @@ export default function ActivateCode() {
77 const _contracts = need.contracts(contracts);
77 const _contracts = need.contracts(contracts);
78 const { seed } = await generateTemporaryOwnershipWallet(ticket);
78 const { seed } = await generateTemporaryOwnershipWallet(ticket);
79
79
80− // TODO(fang): isn't all this accessible in the ownership object?
81− const inviteWallet = walletFromMnemonic(seed, DEFAULT_HD_PATH);
80+ cachedInviteWallet.current = walletFromMnemonic(seed, DEFAULT_HD_PATH);
82− cachedInviteWallet.current = inviteWallet;
83
81
84− const _inviteWallet = need.wallet(inviteWallet);
82+ const _inviteWallet = need.wallet(cachedInviteWallet.current);
85
83
86 const owned = await azimuth.azimuth.getOwnedPoints(
84 const owned = await azimuth.azimuth.getOwnedPoints(
87 _contracts,
85 _contracts,
src/views/Login/Ticket.js+40−51
@@ -47,70 +47,59 @@ export default function Ticket({ className, goHome }) {
47 return errors;
47 return errors;
48 }
48 }
49
49
50+ await timeout(100); // allow ui events to flush
51+
52+ let ticket;
50 if (values.useShards) {
53 if (values.useShards) {
51 if (errors.shard1 || errors.shard2 || errors.shard3) {
54 if (errors.shard1 || errors.shard2 || errors.shard3) {
52 return errors;
55 return errors;
53 }
56 }
54
57
55− // shards
56− try {
57− const ticket = kg.combine([
58+ ticket = kg.combine([values.shard1, values.shard2, values.shard3]);
58− values.shard1,
59− values.shard2,
60− values.shard3,
61− ]);
62− const point = patp2dec(values.point);
63− cachedUrbitWallet.current = await urbitWalletFromTicket(
64− ticket,
65− point,
66− values.passphrase
67− );
68− } catch (error) {
69− console.error(error);
70− return { [FORM_ERROR]: 'Unable to derive wallet from shards.' };
71− }
72 } else {
59 } else {
73 if (errors.ticket) {
60 if (errors.ticket) {
74 return errors;
61 return errors;
75 }
62 }
76
63
77− await timeout(100); // allow ui events to flush
78− try {
79− // ticket
64+ ticket = values.ticket;
80− const _contracts = need.contracts(contracts);
65+ }
81− const point = patp2dec(values.point);
82
66
83− console.log('computing...');
67+ try {
68+ // ticket
69+ const _contracts = need.contracts(contracts);
70+ const point = patp2dec(values.point);
71+
84− const urbitWallet = await urbitWalletFromTicket(
72+ cachedUrbitWallet.current = await urbitWalletFromTicket(
73+ ticket,
74+ point,
85− values.ticket,
75+ values.passphrase
76+ );
77+
78+ const [isOwner, isTransferProxy] = await Promise.all([
79+ azimuth.azimuth.isOwner(
80+ _contracts,
81+ point,
82+ cachedUrbitWallet.current.ownership.keys.address
83+ ),
84+ azimuth.azimuth.isTransferProxy(
85+ _contracts,
86 point,
86 point,
87− values.passphrase
88− );
89−
90− cachedUrbitWallet.current = urbitWallet;
87+ cachedUrbitWallet.current.ownership.keys.address
91−
92− const [isOwner, isTransferProxy] = await Promise.all([
93− azimuth.azimuth.isOwner(
94− _contracts,
95− point,
96− urbitWallet.ownership.keys.address
97− ),
88+ ),
98− azimuth.azimuth.isTransferProxy(
99− _contracts,
100− point,
101− urbitWallet.ownership.keys.address
102− ),
103− ]);
89+ ]);
104−
90+
105− if (!isOwner && !isTransferProxy) {
91+ if (!isOwner && !isTransferProxy) {
106− // notify the user, but allow login regardless
92+ // notify the user, but allow login regardless
107− // TODO: warnings
93+ // TODO: warnings
108− // 'This ticket is not the owner of or transfer proxy for this point.'
94+ // 'This ticket is not the owner of or transfer proxy for this point.'
109− }
110− } catch (error) {
111− console.error(error);
112− return { ticket: 'Unable to derive wallet from ticket.' };
113 }
95 }
96+ } catch (error) {
97+ console.error(error);
98+ return {
99+ [FORM_ERROR]: `Unable to derive wallet from ${
100+ values.useShards ? 'shards' : 'ticket'
101+ }.`,
102+ };
114 }
103 }
115 },
104 },
116 [contracts]
105 [contracts]