2021-01-11 10:32:51 +00:00
|
|
|
package requests
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
|
|
|
|
"github.com/status-im/status-go/eth-node/types"
|
|
|
|
)
|
|
|
|
|
|
|
|
var ErrRequestToJoinCommunityInvalidCommunityID = errors.New("request-to-join-community: invalid community id")
|
2023-06-22 18:59:07 +00:00
|
|
|
var ErrRequestToJoinCommunityMissingPassword = errors.New("request-to-join-community: password is necessary when sending a list of addresses")
|
2023-07-14 17:33:47 +00:00
|
|
|
var ErrRequestToJoinNoAirdropAddress = errors.New("request-to-join-community: airdropAddress is necessary when sending a list of addresses")
|
2021-01-11 10:32:51 +00:00
|
|
|
|
|
|
|
type RequestToJoinCommunity struct {
|
2023-06-22 18:59:07 +00:00
|
|
|
CommunityID types.HexBytes `json:"communityId"`
|
|
|
|
ENSName string `json:"ensName"`
|
|
|
|
Password string `json:"password"`
|
|
|
|
AddressesToReveal []string `json:"addressesToReveal"`
|
2023-07-14 17:33:47 +00:00
|
|
|
AirdropAddress string `json:"airdropAddress"`
|
2021-01-11 10:32:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (j *RequestToJoinCommunity) Validate() error {
|
|
|
|
if len(j.CommunityID) == 0 {
|
|
|
|
return ErrRequestToJoinCommunityInvalidCommunityID
|
|
|
|
}
|
2023-06-22 18:59:07 +00:00
|
|
|
if len(j.AddressesToReveal) > 0 && j.Password == "" {
|
|
|
|
return ErrRequestToJoinCommunityMissingPassword
|
|
|
|
}
|
2023-07-14 17:33:47 +00:00
|
|
|
if len(j.AddressesToReveal) > 0 && j.AirdropAddress == "" {
|
|
|
|
return ErrRequestToJoinNoAirdropAddress
|
|
|
|
}
|
2021-01-11 10:32:51 +00:00
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|