daostack / alchemy

An app for collaborative networks (DAOs), based on the DAO stack.
https://alchemy.do
GNU General Public License v3.0
144 stars 80 forks source link

check if account is set before sending transactions and show a warning or instructions if it is not #338

Closed jellegerbrandy closed 5 years ago

jellegerbrandy commented 5 years ago

The behavior we want to see when the user is not logged in is that:

(1) action buttons are visible (2) clicking on it will show this warning (now it just logs a warning to the console)

We need some specs @A-Zak and copy

jellegerbrandy commented 5 years ago

There is also the "special case" o fthe "enable predicting" button that covers the staking graph. This I think we do not want to have when the user is not logged in.

jellegerbrandy commented 5 years ago

thinkin about this some more, what we probably should when clicking on a aciton button when no account is avialble is:

I'm ignoring the portis project for now - but this can be later inserted as a more sophisticated variant of the last step.

jellegerbrandy commented 5 years ago

@A-Zak we need some copy

jellegerbrandy commented 5 years ago

Ok, in #350 I have implemented a checkNetworkAndWarn function, and are calling that just before a transaction is sent. It checks the conditions, and shows an alert if something is wrong, and cancels the transaction. The function is defined here: https://github.com/daostack/alchemy/blob/jelle/src/lib/util.ts#L88

This is used like this

    if (!checkNetworkAndWarn()) { return;} 

What we still need to do here is:

A-Zak commented 5 years ago

@jellegerbrandy Question - what types of errors can we get? I'm guessing, no network, wrong network, unknown network... anything else?

jellegerbrandy commented 5 years ago

So the account/network can be not available for the following reasons:

There is a sepcial case in development/test mode, which works also without metamask. But that is not userland and we can ignore it.