-
Notifications
You must be signed in to change notification settings - Fork 265
chore: improve error reporting when joining community #7178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
f438471
95bcf95
8167c78
e53257b
b92a4b7
b1317b0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -1263,29 +1263,36 @@ func (m *Messenger) generateCommunityRequestsForSigning(memberPubKey string, com | |||||
| return nil, err | ||||||
| } | ||||||
|
|
||||||
| containsAddress := func(addresses []string, targetAddress string) bool { | ||||||
| for _, address := range addresses { | ||||||
| if types.HexToAddress(address) == types.HexToAddress(targetAddress) { | ||||||
| return true | ||||||
| } | ||||||
| } | ||||||
| return false | ||||||
| if len(addressesToReveal) == 0 { | ||||||
| return nil, errors.New("no addresses to reveal") | ||||||
| } | ||||||
|
|
||||||
| msgsToSign := make([]personal.SignParams, 0) | ||||||
| walletAccountsMap := make(map[string]*accsmanagementtypes.Account, len(walletAccounts)) | ||||||
| for _, walletAccount := range walletAccounts { | ||||||
| if walletAccount.Chat || walletAccount.Type == accsmanagementtypes.AccountTypeWatch { | ||||||
| continue | ||||||
| addressHex := strings.ToLower(walletAccount.Address.Hex()) | ||||||
| walletAccountsMap[addressHex] = walletAccount | ||||||
| } | ||||||
|
|
||||||
| msgsToSign := make([]personal.SignParams, 0) | ||||||
| for _, address := range addressesToReveal { | ||||||
| walletAccount, ok := walletAccountsMap[strings.ToLower(address)] | ||||||
| if !ok { | ||||||
| return nil, fmt.Errorf("address %s not found in wallet", address) | ||||||
| } | ||||||
|
|
||||||
| if len(addressesToReveal) > 0 && !containsAddress(addressesToReveal, walletAccount.Address.Hex()) { | ||||||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, this condition A few tests were relying on this behaviour, passing empty list of addresses: status-go/protocol/communities_messenger_shared_member_address_test.go Lines 207 to 208 in c0f75d6
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we should explicitly return an error when an empty
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added explicit error return here |
||||||
| continue | ||||||
| if walletAccount.Chat { | ||||||
| return nil, fmt.Errorf("address %s is a chat account", address) | ||||||
| } | ||||||
|
|
||||||
| if walletAccount.Type == accsmanagementtypes.AccountTypeWatch { | ||||||
| return nil, fmt.Errorf("address %s is a watch account", address) | ||||||
| } | ||||||
|
|
||||||
| requestID := []byte{} | ||||||
| if !isEdit { | ||||||
| requestID = communities.CalculateRequestID(memberPubKey, communityID) | ||||||
| } | ||||||
|
|
||||||
| msgsToSign = append(msgsToSign, personal.SignParams{ | ||||||
| Data: types.EncodeHex(crypto.Keccak256(m.IdentityPublicKeyCompressed(), communityID, requestID)), | ||||||
| Address: walletAccount.Address.Hex(), | ||||||
|
|
@@ -1354,7 +1361,7 @@ func (m *Messenger) RequestToJoinCommunity(request *requests.RequestToJoinCommun | |||||
| // TODO: Because of changes that need to be done in tests, calling this function and providing `request` without `AddressesToReveal` | ||||||
| // is not an error, but it should be. | ||||||
| logger := m.logger.Named("RequestToJoinCommunity") | ||||||
| logger.Debug("Addresses to reveal", zap.Any("Addresses:", request.AddressesToReveal)) | ||||||
| logger.Debug("addresses to reveal", zap.Strings("addresses", request.AddressesToReveal)) | ||||||
|
|
||||||
| if err := request.Validate(); err != nil { | ||||||
| logger.Debug("request failed to validate", zap.Error(err), zap.Any("request", request)) | ||||||
|
|
@@ -1371,7 +1378,10 @@ func (m *Messenger) RequestToJoinCommunity(request *requests.RequestToJoinCommun | |||||
| return nil, communities.ErrAlreadyJoined | ||||||
| } | ||||||
|
|
||||||
| requestToJoin := m.communitiesManager.CreateRequestToJoin(request, m.account.GetCustomizationColor()) | ||||||
| requestToJoin, err := m.communitiesManager.CreateRequestToJoin(request, m.account.GetCustomizationColor()) | ||||||
| if err != nil { | ||||||
| return nil, err | ||||||
| } | ||||||
|
|
||||||
| if len(request.AddressesToReveal) > 0 { | ||||||
| revealedAddresses := make([]gethcommon.Address, 0) | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we call
CreateRequestToJoinfor an open community also?If so the list of signatures is empty in that case and this will always return.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or
AddressesToRevealis also empty in that case? I really don't remember.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tested with Status Desktop.
Created a simplest community (auto accept, no permissions, no minted tokens). Member was still required to reveal addresses and input password for signatures. So it's the same flow, we should be good.