hicommonwealth / commonwealth

A platform for decentralized communities
https://commonwealth.im
GNU General Public License v3.0
67 stars 42 forks source link

Allow stake transactions without community membership. #6587

Closed HIM92 closed 5 months ago

HIM92 commented 7 months ago

Description

Being a member of a community is not a requirement to purchase stake. We want to empower users in the flow of discovering fast moving stake markets, or engaging purely Onchain to acquire stake.

When a user looks at a community and it has stake enabled, they should not be blocked from either liquidating or acquiring more community stake.

Blocking: #6594

Engineering requirements + acceptance criteria

mzparacha commented 6 months ago

How should we handle address selection for the user having multiple eth addresses connected in Community A in which they are a member, but they want to buy stake in Community B in which they are not a member.

If the user doesn't join the community, we don't show them the address switcher or the connected address indicator

image image

For the vote weight and other stake sections, what should be the default address (the address that is holding the stake value)?

image

cc: @HIM92

HIM92 commented 5 months ago

[x-post from slack] - Alright (i will post this in github as well) issue 1: A user has 3 addresses (1,2,3) and is looking at Community A. Address 1 has stake address 2 has none address 3 has none the vote weight display is showing address 1 since it has stake. If the user changes their address, then the vote weight should show what is in the selected address. If none of the addresses have stake, the user should be able to switch between addresses IMHO -- is this literally impossible in our systems now? If the user is not part of the community on any addresses, and they buy stake, they should be auto-joined to that community.

For now, with regard to managing your adresses - we will have to review the address handler within the vote weight modal, but for now update it with the current UX and design and I will land on some solutions for later iteration.

mzparacha commented 5 months ago

reposting from slack:

If the user is not part of the community on any addresses, and they buy stake, they should be auto-joined to that community.

this would happen if the user is in any community pages. (Background: we already discussed that joining user to a community outside a community page is tricky in issues/6872)

I was also assigned another issue issues/6870 which adds stake buying functionality in global explore and community directory pages. For these i didn't add the "join to buy stake" or "become member automatically after buying stake" since both of these have the issue as discussed in issues/6872#issuecomment-1978943607.

So bottom line, user can buy stake from

  1. global explore
  2. any community directory page
  3. and any active community page

without being a member of that community. The "become member automatically after buying stake" logic is tricky for 1 and 2, but can be implemented for 3. Confirming if we still want to implement it given the inconsistency?

cc: @HIM92 @zakhap

zakhap commented 5 months ago

Because purchasing Stake requires an EVM compatible address, regardless of location within the app, the user should join the community with the address used to purchase.

The general issue of joining a community from the xplore/global is downstream of active address selection is irrelevant here because we have the user's choice of address from when they purchased the stake.

mzparacha commented 5 months ago

Thanks for the feedback, Zak. Updated the issue description accordingly.

mzparacha commented 5 months ago

The feedback from here is applied in the draft PR https://github.com/hicommonwealth/commonwealth/pull/7181. I found 2 more edge cases

  1. Some communities show a TOS modal when joining that community. Do we show this TOS when we auto-join users to community after they buy stake, if yes how since we are joining user to community in the background?
  2. How do do we manage 'stake buying' when user is logged in with a different chain that the community in which they are buying stake, Ex: user is logged in with cosmos wallet, but trying to buy stake in ethereum based community. What should happen if the user clicks on 'Buy Stake'?

    On production code, if the user does this, we show the AuthModal and require them to login with the required wallet/base-chain (ethereum in this case) and then they can buy stake, this step also performs account linking i.e links both ethereum and cosmos accounts to a single user account. But this account linking won't work in 2/3 newly added branch cases a. User buys stake from active community page without community membership -- :white_check_mark: will work b. User buys stake from global explore without community membership -- :x: will not work, we don't do account linking here c. User buys stake from community directory without community membership -- :x: will not work, we don't do account linking here

currently blocked on this, feedback appreciated.

cc: @HIM92 @zakhap

HIM92 commented 5 months ago

@mzparacha, I think for the TOS groups this is a minority of our communities. One way of handing lit would be to nto show the TOS until the user visits the community for the first time. @zakhap do you have any thoughts here?

For a user buyign stake with a different wallet, all stake is currently EVM so they should be auto switched to an EVM address on their profile in order to make that transaction.

mzparacha commented 5 months ago

For a user buyign stake with a different wallet, all stake is currently EVM so they should be auto switched to an EVM address on their profile in order to make that transaction.

The issue is, if user is logged in with non-evm wallet, we cant automatically switch address to evm wallet, because we get that address after the user signs in. Can we block the 'buy stake' button with a tooltip -> 'Connect an evm wallet to buy stake' if user is logged in with a non-evm wallet?

https://github.com/hicommonwealth/commonwealth/assets/51641047/4e80e318-545b-4aa1-bd6e-2b236b30f36a

cc: @HIM92

HIM92 commented 5 months ago

I see, yes, I think we should block and have the tooltip.

mzparacha commented 5 months ago

Thanks, @HIM92, I have updated the PR https://github.com/hicommonwealth/commonwealth/pull/7181 with all the changes discussed. Currently waiting on the TOS modal answer, other than that, i will request reviews on the PR from other engineers

burtonator commented 5 months ago

One thought here is that since this is an out of order or unusual auth flow we should really have E2E tests for it to verify it works, or we'll have a regression at some point. Without knowing the internals this is my only concern. I still need to get time to dive into our auth.