21
vendor/github.com/status-im/status-go/protocol/requests/accept_contact_request.go
generated
vendored
Normal file
21
vendor/github.com/status-im/status-go/protocol/requests/accept_contact_request.go
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/status-im/status-go/eth-node/types"
|
||||
)
|
||||
|
||||
var ErrAcceptContactRequestInvalidID = errors.New("accept-contact-request: invalid id")
|
||||
|
||||
type AcceptContactRequest struct {
|
||||
ID types.HexBytes `json:"id"`
|
||||
}
|
||||
|
||||
func (a *AcceptContactRequest) Validate() error {
|
||||
if len(a.ID) == 0 {
|
||||
return ErrAcceptContactRequestInvalidID
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
21
vendor/github.com/status-im/status-go/protocol/requests/accept_latest_contact_request_for_contact.go
generated
vendored
Normal file
21
vendor/github.com/status-im/status-go/protocol/requests/accept_latest_contact_request_for_contact.go
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/status-im/status-go/eth-node/types"
|
||||
)
|
||||
|
||||
var ErrAcceptLatestContactRequestForContactInvalidID = errors.New("accept-latest-contact-request-for-contact: invalid id")
|
||||
|
||||
type AcceptLatestContactRequestForContact struct {
|
||||
ID types.HexBytes `json:"id"`
|
||||
}
|
||||
|
||||
func (a *AcceptLatestContactRequestForContact) Validate() error {
|
||||
if len(a.ID) == 0 {
|
||||
return ErrAcceptLatestContactRequestForContactInvalidID
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
21
vendor/github.com/status-im/status-go/protocol/requests/accept_request_to_join_community.go
generated
vendored
Normal file
21
vendor/github.com/status-im/status-go/protocol/requests/accept_request_to_join_community.go
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/status-im/status-go/eth-node/types"
|
||||
)
|
||||
|
||||
var ErrAcceptRequestToJoinCommunityInvalidID = errors.New("accept-request-to-join-community: invalid id")
|
||||
|
||||
type AcceptRequestToJoinCommunity struct {
|
||||
ID types.HexBytes `json:"id"`
|
||||
}
|
||||
|
||||
func (j *AcceptRequestToJoinCommunity) Validate() error {
|
||||
if len(j.ID) == 0 {
|
||||
return ErrAcceptRequestToJoinCommunityInvalidID
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
26
vendor/github.com/status-im/status-go/protocol/requests/add_contact.go
generated
vendored
Normal file
26
vendor/github.com/status-im/status-go/protocol/requests/add_contact.go
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
)
|
||||
|
||||
var ErrAddContactInvalidID = errors.New("add-contact: invalid id")
|
||||
|
||||
type AddContact struct {
|
||||
ID string `json:"id"`
|
||||
Nickname string `json:"nickname"`
|
||||
DisplayName string `json:"displayName"`
|
||||
ENSName string `json:"ensName"`
|
||||
}
|
||||
|
||||
func (a *AddContact) Validate() error {
|
||||
if len(a.ID) == 0 {
|
||||
return ErrAddContactInvalidID
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *AddContact) HexID() (string, error) {
|
||||
return ConvertCompressedToLegacyKey(a.ID)
|
||||
}
|
||||
34
vendor/github.com/status-im/status-go/protocol/requests/add_role_to_member.go
generated
vendored
Normal file
34
vendor/github.com/status-im/status-go/protocol/requests/add_role_to_member.go
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/status-im/status-go/eth-node/types"
|
||||
"github.com/status-im/status-go/protocol/protobuf"
|
||||
)
|
||||
|
||||
var ErrAddRoleToMemberInvalidCommunityID = errors.New("add-role-to-member: invalid community id")
|
||||
var ErrAddRoleToMemberInvalidUser = errors.New("add-role-to-member: invalid user id")
|
||||
var ErrAddRoleToMemberInvalidRole = errors.New("add-role-to-member: invalid role")
|
||||
|
||||
type AddRoleToMember struct {
|
||||
CommunityID types.HexBytes `json:"communityId"`
|
||||
User types.HexBytes `json:"user"`
|
||||
Role protobuf.CommunityMember_Roles `json:"role"`
|
||||
}
|
||||
|
||||
func (a *AddRoleToMember) Validate() error {
|
||||
if len(a.CommunityID) == 0 {
|
||||
return ErrAddRoleToMemberInvalidCommunityID
|
||||
}
|
||||
|
||||
if len(a.User) == 0 {
|
||||
return ErrAddRoleToMemberInvalidUser
|
||||
}
|
||||
|
||||
if a.Role == protobuf.CommunityMember_ROLE_NONE {
|
||||
return ErrAddRoleToMemberInvalidRole
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
37
vendor/github.com/status-im/status-go/protocol/requests/add_wallet_connect_session.go
generated
vendored
Normal file
37
vendor/github.com/status-im/status-go/protocol/requests/add_wallet_connect_session.go
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
)
|
||||
|
||||
var ErrAddWalletConnectSessionInvalidID = errors.New("add-wallet-connect-session: invalid id")
|
||||
var ErrAddWalletConnectSessionInvalidDAppName = errors.New("add-wallet-connect-session: invalid dapp name")
|
||||
var ErrAddWalletConnectSessionInvalidDAppURL = errors.New("add-wallet-connect-session: invalid dapp url")
|
||||
var ErrAddWalletConnectSessionInvalidInfo = errors.New("add-wallet-connect-session: invalid info")
|
||||
|
||||
type AddWalletConnectSession struct {
|
||||
PeerID string `json:"id"`
|
||||
DAppName string `json:"dappName"`
|
||||
DAppURL string `json:"dappUrl"`
|
||||
Info string `json:"info"`
|
||||
}
|
||||
|
||||
func (c *AddWalletConnectSession) Validate() error {
|
||||
if len(c.PeerID) == 0 {
|
||||
return ErrAddWalletConnectSessionInvalidID
|
||||
}
|
||||
|
||||
if len(c.DAppName) == 0 {
|
||||
return ErrAddWalletConnectSessionInvalidDAppName
|
||||
}
|
||||
|
||||
if len(c.DAppURL) == 0 {
|
||||
return ErrAddWalletConnectSessionInvalidDAppURL
|
||||
}
|
||||
|
||||
if len(c.Info) == 0 {
|
||||
return ErrAddWalletConnectSessionInvalidInfo
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
27
vendor/github.com/status-im/status-go/protocol/requests/ban_user_from_community.go
generated
vendored
Normal file
27
vendor/github.com/status-im/status-go/protocol/requests/ban_user_from_community.go
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/status-im/status-go/eth-node/types"
|
||||
)
|
||||
|
||||
var ErrBanUserFromCommunityInvalidCommunityID = errors.New("ban-user-from-community: invalid community id")
|
||||
var ErrBanUserFromCommunityInvalidUser = errors.New("ban-user-from-community: invalid user id")
|
||||
|
||||
type BanUserFromCommunity struct {
|
||||
CommunityID types.HexBytes `json:"communityId"`
|
||||
User types.HexBytes `json:"user"`
|
||||
}
|
||||
|
||||
func (b *BanUserFromCommunity) Validate() error {
|
||||
if len(b.CommunityID) == 0 {
|
||||
return ErrBanUserFromCommunityInvalidCommunityID
|
||||
}
|
||||
|
||||
if len(b.User) == 0 {
|
||||
return ErrBanUserFromCommunityInvalidUser
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
6
vendor/github.com/status-im/status-go/protocol/requests/build_contact.go
generated
vendored
Normal file
6
vendor/github.com/status-im/status-go/protocol/requests/build_contact.go
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
package requests
|
||||
|
||||
type BuildContact struct {
|
||||
PublicKey string `json:"publicKey"`
|
||||
ENSName string `json:"ENSName"`
|
||||
}
|
||||
21
vendor/github.com/status-im/status-go/protocol/requests/cancel_request_to_join_community.go
generated
vendored
Normal file
21
vendor/github.com/status-im/status-go/protocol/requests/cancel_request_to_join_community.go
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/status-im/status-go/eth-node/types"
|
||||
)
|
||||
|
||||
var ErrCancelRequestToJoinCommunityInvalidID = errors.New("cancel-request-to-join-community: invalid id")
|
||||
|
||||
type CancelRequestToJoinCommunity struct {
|
||||
ID types.HexBytes `json:"id"`
|
||||
}
|
||||
|
||||
func (j *CancelRequestToJoinCommunity) Validate() error {
|
||||
if len(j.ID) == 0 {
|
||||
return ErrCancelRequestToJoinCommunityInvalidID
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
24
vendor/github.com/status-im/status-go/protocol/requests/check_all_community_channels_permissions.go
generated
vendored
Normal file
24
vendor/github.com/status-im/status-go/protocol/requests/check_all_community_channels_permissions.go
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/status-im/status-go/eth-node/types"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrCheckAllCommunityChannelsPermissionsInvalidID = errors.New("check-community-channel-permissions: invalid id")
|
||||
)
|
||||
|
||||
type CheckAllCommunityChannelsPermissions struct {
|
||||
CommunityID types.HexBytes
|
||||
Addresses []string `json:"addresses"`
|
||||
}
|
||||
|
||||
func (u *CheckAllCommunityChannelsPermissions) Validate() error {
|
||||
if len(u.CommunityID) == 0 {
|
||||
return ErrCheckAllCommunityChannelsPermissionsInvalidID
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
29
vendor/github.com/status-im/status-go/protocol/requests/check_community_channel_permissions.go
generated
vendored
Normal file
29
vendor/github.com/status-im/status-go/protocol/requests/check_community_channel_permissions.go
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/status-im/status-go/eth-node/types"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrCheckCommunityChannelPermissionsInvalidID = errors.New("check-community-channel-permissions: invalid id")
|
||||
ErrCheckCommunityChannelPermissionsInvalidChatID = errors.New("check-community-channel-permissions: invalid chat id")
|
||||
)
|
||||
|
||||
type CheckCommunityChannelPermissions struct {
|
||||
CommunityID types.HexBytes
|
||||
ChatID string
|
||||
Addresses []string `json:"addresses"`
|
||||
}
|
||||
|
||||
func (u *CheckCommunityChannelPermissions) Validate() error {
|
||||
if len(u.CommunityID) == 0 {
|
||||
return ErrCheckCommunityChannelPermissionsInvalidID
|
||||
}
|
||||
if len(u.ChatID) == 0 {
|
||||
return ErrCheckCommunityChannelPermissionsInvalidChatID
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
24
vendor/github.com/status-im/status-go/protocol/requests/check_permission_to_join_community.go
generated
vendored
Normal file
24
vendor/github.com/status-im/status-go/protocol/requests/check_permission_to_join_community.go
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/status-im/status-go/eth-node/types"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrCheckPermissionToJoinCommunityInvalidID = errors.New("check-permission-to-join-community: invalid id")
|
||||
)
|
||||
|
||||
type CheckPermissionToJoinCommunity struct {
|
||||
CommunityID types.HexBytes `json:"communityId"`
|
||||
Addresses []string `json:"addresses"`
|
||||
}
|
||||
|
||||
func (u *CheckPermissionToJoinCommunity) Validate() error {
|
||||
if len(u.CommunityID) == 0 {
|
||||
return ErrCheckPermissionToJoinCommunityInvalidID
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
19
vendor/github.com/status-im/status-go/protocol/requests/clear_history.go
generated
vendored
Normal file
19
vendor/github.com/status-im/status-go/protocol/requests/clear_history.go
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
)
|
||||
|
||||
var ErrClearHistoryInvalidID = errors.New("clear-history: invalid id")
|
||||
|
||||
type ClearHistory struct {
|
||||
ID string `json:"id"`
|
||||
}
|
||||
|
||||
func (c *ClearHistory) Validate() error {
|
||||
if len(c.ID) == 0 {
|
||||
return ErrClearHistoryInvalidID
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
18
vendor/github.com/status-im/status-go/protocol/requests/community_channel_share_url.go
generated
vendored
Normal file
18
vendor/github.com/status-im/status-go/protocol/requests/community_channel_share_url.go
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"github.com/status-im/status-go/eth-node/types"
|
||||
)
|
||||
|
||||
type CommunityChannelShareURL struct {
|
||||
CommunityID types.HexBytes
|
||||
ChannelID string
|
||||
}
|
||||
|
||||
func (r *CommunityChannelShareURL) Validate() error {
|
||||
if len(r.CommunityID) == 0 {
|
||||
return ErrCheckPermissionToJoinCommunityInvalidID
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
44
vendor/github.com/status-im/status-go/protocol/requests/community_metrics_request.go
generated
vendored
Normal file
44
vendor/github.com/status-im/status-go/protocol/requests/community_metrics_request.go
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/status-im/status-go/eth-node/types"
|
||||
)
|
||||
|
||||
var ErrNoCommunityID = errors.New("community metrics request has no community id")
|
||||
var ErrInvalidTimestampIntervals = errors.New("community metrics request invalid time intervals")
|
||||
|
||||
type CommunityMetricsRequestType uint
|
||||
|
||||
const (
|
||||
CommunityMetricsRequestMessagesTimestamps CommunityMetricsRequestType = iota
|
||||
CommunityMetricsRequestMessagesCount
|
||||
CommunityMetricsRequestMembers
|
||||
CommunityMetricsRequestControlNodeUptime
|
||||
)
|
||||
|
||||
type MetricsIntervalRequest struct {
|
||||
StartTimestamp uint64 `json:"startTimestamp"`
|
||||
EndTimestamp uint64 `json:"endTimestamp"`
|
||||
}
|
||||
|
||||
type CommunityMetricsRequest struct {
|
||||
CommunityID types.HexBytes `json:"communityId"`
|
||||
Type CommunityMetricsRequestType `json:"type"`
|
||||
Intervals []MetricsIntervalRequest `json:"intervals"`
|
||||
}
|
||||
|
||||
func (r *CommunityMetricsRequest) Validate() error {
|
||||
if len(r.CommunityID) == 0 {
|
||||
return ErrNoCommunityID
|
||||
}
|
||||
|
||||
for _, interval := range r.Intervals {
|
||||
if interval.StartTimestamp == 0 || interval.EndTimestamp == 0 || interval.StartTimestamp >= interval.EndTimestamp {
|
||||
return ErrInvalidTimestampIntervals
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
94
vendor/github.com/status-im/status-go/protocol/requests/community_tags.go
generated
vendored
Normal file
94
vendor/github.com/status-im/status-go/protocol/requests/community_tags.go
generated
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
package requests
|
||||
|
||||
var TagsEmojies map[string]string
|
||||
|
||||
func init() {
|
||||
TagsEmojies = make(map[string]string)
|
||||
TagsEmojies["Activism"] = "✊"
|
||||
TagsEmojies["Art"] = "🎨"
|
||||
TagsEmojies["Blockchain"] = "🔗"
|
||||
TagsEmojies["Books & blogs"] = "📚"
|
||||
TagsEmojies["Career"] = "💼"
|
||||
TagsEmojies["Collaboration"] = "🤝"
|
||||
TagsEmojies["Commerce"] = "🛒"
|
||||
TagsEmojies["Culture"] = "🎎"
|
||||
TagsEmojies["DAO"] = "🚀"
|
||||
TagsEmojies["DeFi"] = "📈"
|
||||
TagsEmojies["Design"] = "🧩"
|
||||
TagsEmojies["DIY"] = "🔨"
|
||||
TagsEmojies["Environment"] = "🌿"
|
||||
TagsEmojies["Education"] = "🎒"
|
||||
TagsEmojies["Entertainment"] = "🍿"
|
||||
TagsEmojies["Ethereum"] = "Ξ"
|
||||
TagsEmojies["Event"] = "🗓"
|
||||
TagsEmojies["Fantasy"] = "🧙♂️"
|
||||
TagsEmojies["Fashion"] = "🧦"
|
||||
TagsEmojies["Food"] = "🌶"
|
||||
TagsEmojies["Gaming"] = "🎮"
|
||||
TagsEmojies["Global"] = "🌍"
|
||||
TagsEmojies["Health"] = "🧠"
|
||||
TagsEmojies["Hobby"] = "📐"
|
||||
TagsEmojies["Innovation"] = "🧪"
|
||||
TagsEmojies["Language"] = "📜"
|
||||
TagsEmojies["Lifestyle"] = "✨"
|
||||
TagsEmojies["Local"] = "📍"
|
||||
TagsEmojies["Love"] = "❤️"
|
||||
TagsEmojies["Markets"] = "💎"
|
||||
TagsEmojies["Movies & TV"] = "🎞"
|
||||
TagsEmojies["Music"] = "🎶"
|
||||
TagsEmojies["News"] = "🗞"
|
||||
TagsEmojies["NFT"] = "🖼"
|
||||
TagsEmojies["Non-profit"] = "🙏"
|
||||
TagsEmojies["NSFW"] = "🍆"
|
||||
TagsEmojies["Org"] = "🏢"
|
||||
TagsEmojies["Pets"] = "🐶"
|
||||
TagsEmojies["Play"] = "🎲"
|
||||
TagsEmojies["Podcast"] = "🎙️"
|
||||
TagsEmojies["Politics"] = "🗳️"
|
||||
TagsEmojies["Product"] = "🍱"
|
||||
TagsEmojies["Psyche"] = "🍁"
|
||||
TagsEmojies["Privacy"] = "👻"
|
||||
TagsEmojies["Security"] = "🔒"
|
||||
TagsEmojies["Social"] = "☕"
|
||||
TagsEmojies["Software dev"] = "👩💻"
|
||||
TagsEmojies["Sports"] = "⚽️"
|
||||
TagsEmojies["Tech"] = "📱"
|
||||
TagsEmojies["Travel"] = "🗺"
|
||||
TagsEmojies["Vehicles"] = "🚕"
|
||||
TagsEmojies["Web3"] = "🌐"
|
||||
}
|
||||
|
||||
func ValidateTags(input []string) bool {
|
||||
for _, t := range input {
|
||||
_, ok := TagsEmojies[t]
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// False if contains duplicates. Shouldn't have happened
|
||||
return len(unique(input)) == len(input)
|
||||
}
|
||||
|
||||
func RemoveUnknownAndDeduplicateTags(input []string) []string {
|
||||
var result []string
|
||||
for _, t := range input {
|
||||
_, ok := TagsEmojies[t]
|
||||
if ok {
|
||||
result = append(result, t)
|
||||
}
|
||||
}
|
||||
return unique(result)
|
||||
}
|
||||
|
||||
func unique(slice []string) []string {
|
||||
uniqMap := make(map[string]struct{})
|
||||
for _, v := range slice {
|
||||
uniqMap[v] = struct{}{}
|
||||
}
|
||||
uniqSlice := make([]string, 0, len(uniqMap))
|
||||
for v := range uniqMap {
|
||||
uniqSlice = append(uniqSlice, v)
|
||||
}
|
||||
return uniqSlice
|
||||
}
|
||||
95
vendor/github.com/status-im/status-go/protocol/requests/create_account.go
generated
vendored
Normal file
95
vendor/github.com/status-im/status-go/protocol/requests/create_account.go
generated
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
)
|
||||
|
||||
var ErrCreateAccountInvalidDisplayName = errors.New("create-account: invalid display name")
|
||||
var ErrCreateAccountInvalidPassword = errors.New("create-account: invalid password")
|
||||
var ErrCreateAccountInvalidCustomizationColor = errors.New("create-account: invalid customization color")
|
||||
var ErrCreateAccountInvalidRootKeystoreDir = errors.New("create-account: invalid root keystore directory")
|
||||
var ErrCreateAccountInvalidBackupDisabledDataDir = errors.New("create-account: invalid backup disabled data directory")
|
||||
var ErrCreateAccountInvalidLogFilePath = errors.New("create-account: invalid log file path")
|
||||
|
||||
type CreateAccount struct {
|
||||
// BackupDisabledDataDir is the directory where backup is disabled
|
||||
BackupDisabledDataDir string `json:"backupDisabledDataDir"`
|
||||
|
||||
DeviceName string `json:"deviceName"`
|
||||
DisplayName string `json:"displayName"`
|
||||
Password string `json:"password"`
|
||||
ImagePath string `json:"imagePath"`
|
||||
CustomizationColor string `json:"customizationColor"`
|
||||
Emoji string `json:"emoji"`
|
||||
|
||||
WakuV2Nameserver *string `json:"wakuV2Nameserver"`
|
||||
WakuV2LightClient bool `json:"wakuV2LightClient"`
|
||||
|
||||
LogLevel *string `json:"logLevel"`
|
||||
LogFilePath string `json:"logFilePath"`
|
||||
LogEnabled bool `json:"logEnabled"`
|
||||
|
||||
PreviewPrivacy bool `json:"previewPrivacy"`
|
||||
|
||||
VerifyTransactionURL *string `json:"verifyTransactionURL"`
|
||||
VerifyENSURL *string `json:"verifyENSURL"`
|
||||
VerifyENSContractAddress *string `json:"verifyENSContractAddress"`
|
||||
VerifyTransactionChainID *int64 `json:"verifyTransactionChainID"`
|
||||
UpstreamConfig string `json:"upstreamConfig"`
|
||||
|
||||
CurrentNetwork string `json:"currentNetwork"`
|
||||
NetworkID uint64 `json:"networkId"`
|
||||
|
||||
WalletSecretsConfig
|
||||
}
|
||||
|
||||
type WalletSecretsConfig struct {
|
||||
PoktToken string `json:"poktToken"`
|
||||
InfuraToken string `json:"infuraToken"`
|
||||
InfuraSecret string `json:"infuraSecret"`
|
||||
OpenseaAPIKey string `json:"openseaApiKey"`
|
||||
RaribleMainnetAPIKey string `json:"raribleMainnetApiKey"`
|
||||
RaribleTestnetAPIKey string `json:"raribleTestnetApiKey"`
|
||||
|
||||
// Testing
|
||||
GanacheURL string `json:"ganacheURL"`
|
||||
AlchemyEthereumMainnetToken string `json:"alchemyEthereumMainnetToken"`
|
||||
AlchemyEthereumGoerliToken string `json:"alchemyEthereumGoerliToken"`
|
||||
AlchemyEthereumSepoliaToken string `json:"alchemyEthereumSepoliaToken"`
|
||||
AlchemyArbitrumMainnetToken string `json:"alchemyArbitrumMainnetToken"`
|
||||
AlchemyArbitrumGoerliToken string `json:"alchemyArbitrumGoerliToken"`
|
||||
AlchemyArbitrumSepoliaToken string `json:"alchemyArbitrumSepoliaToken"`
|
||||
AlchemyOptimismMainnetToken string `json:"alchemyOptimismMainnetToken"`
|
||||
AlchemyOptimismGoerliToken string `json:"alchemyOptimismGoerliToken"`
|
||||
AlchemyOptimismSepoliaToken string `json:"alchemyOptimismSepoliaToken"`
|
||||
}
|
||||
|
||||
func (c *CreateAccount) Validate() error {
|
||||
return ValidateAccountCreationRequest(*c)
|
||||
}
|
||||
|
||||
func ValidateAccountCreationRequest(c CreateAccount) error {
|
||||
// TODO(cammellos): Add proper validation for password/displayname/etc
|
||||
if len(c.DisplayName) == 0 {
|
||||
return ErrCreateAccountInvalidDisplayName
|
||||
}
|
||||
|
||||
if len(c.Password) == 0 {
|
||||
return ErrCreateAccountInvalidPassword
|
||||
}
|
||||
|
||||
if len(c.CustomizationColor) == 0 {
|
||||
return ErrCreateAccountInvalidCustomizationColor
|
||||
}
|
||||
|
||||
if len(c.BackupDisabledDataDir) == 0 {
|
||||
return ErrCreateAccountInvalidBackupDisabledDataDir
|
||||
}
|
||||
|
||||
if len(c.LogFilePath) == 0 {
|
||||
return ErrCreateAccountInvalidLogFilePath
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
}
|
||||
29
vendor/github.com/status-im/status-go/protocol/requests/create_community_category.go
generated
vendored
Normal file
29
vendor/github.com/status-im/status-go/protocol/requests/create_community_category.go
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/status-im/status-go/eth-node/types"
|
||||
)
|
||||
|
||||
var ErrCreateCommunityCategoryInvalidCommunityID = errors.New("create-community-category: invalid community id")
|
||||
var ErrCreateCommunityCategoryInvalidName = errors.New("create-community-category: invalid category name")
|
||||
|
||||
type CreateCommunityCategory struct {
|
||||
CommunityID types.HexBytes `json:"communityId"`
|
||||
CategoryName string `json:"categoryName"`
|
||||
ChatIDs []string `json:"chatIds"`
|
||||
ThirdPartyID string `json:"thirdPartyID,omitempty"`
|
||||
}
|
||||
|
||||
func (j *CreateCommunityCategory) Validate() error {
|
||||
if len(j.CommunityID) == 0 {
|
||||
return ErrCreateCommunityCategoryInvalidCommunityID
|
||||
}
|
||||
|
||||
if len(j.CategoryName) == 0 {
|
||||
return ErrCreateCommunityCategoryInvalidName
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
134
vendor/github.com/status-im/status-go/protocol/requests/create_community_request.go
generated
vendored
Normal file
134
vendor/github.com/status-im/status-go/protocol/requests/create_community_request.go
generated
vendored
Normal file
@@ -0,0 +1,134 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
"github.com/status-im/status-go/images"
|
||||
"github.com/status-im/status-go/protocol/protobuf"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrCreateCommunityInvalidName = errors.New("create-community: invalid name")
|
||||
ErrCreateCommunityInvalidColor = errors.New("create-community: invalid color")
|
||||
ErrCreateCommunityInvalidDescription = errors.New("create-community: invalid description")
|
||||
ErrCreateCommunityInvalidIntroMessage = errors.New("create-community: invalid intro message")
|
||||
ErrCreateCommunityInvalidOutroMessage = errors.New("create-community: invalid outro message")
|
||||
ErrCreateCommunityInvalidMembership = errors.New("create-community: invalid membership")
|
||||
ErrCreateCommunityInvalidTags = errors.New("create-community: invalid tags")
|
||||
)
|
||||
|
||||
const (
|
||||
maxNameLength = 30
|
||||
maxDescriptionLength = 140
|
||||
maxIntroMessageLength = 1400
|
||||
maxOutroMessageLength = 80
|
||||
)
|
||||
|
||||
type CreateCommunity struct {
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
IntroMessage string `json:"introMessage,omitempty"`
|
||||
OutroMessage string `json:"outroMessage,omitempty"`
|
||||
Color string `json:"color"`
|
||||
Emoji string `json:"emoji"`
|
||||
Membership protobuf.CommunityPermissions_Access `json:"membership"`
|
||||
EnsOnly bool `json:"ensOnly"`
|
||||
Image string `json:"image"`
|
||||
ImageAx int `json:"imageAx"`
|
||||
ImageAy int `json:"imageAy"`
|
||||
ImageBx int `json:"imageBx"`
|
||||
ImageBy int `json:"imageBy"`
|
||||
Banner images.CroppedImage `json:"banner"`
|
||||
HistoryArchiveSupportEnabled bool `json:"historyArchiveSupportEnabled,omitempty"`
|
||||
PinMessageAllMembersEnabled bool `json:"pinMessageAllMembersEnabled,omitempty"`
|
||||
Tags []string `json:"tags,omitempty"`
|
||||
}
|
||||
|
||||
func adaptIdentityImageToProtobuf(img images.IdentityImage) *protobuf.IdentityImage {
|
||||
return &protobuf.IdentityImage{
|
||||
Payload: img.Payload,
|
||||
SourceType: protobuf.IdentityImage_RAW_PAYLOAD,
|
||||
ImageFormat: images.GetProtobufImageFormat(img.Payload),
|
||||
}
|
||||
}
|
||||
|
||||
func (c *CreateCommunity) Validate() error {
|
||||
if c.Name == "" || len(c.Name) > maxNameLength {
|
||||
return ErrCreateCommunityInvalidName
|
||||
}
|
||||
|
||||
if c.Description == "" || len(c.Description) > maxDescriptionLength {
|
||||
return ErrCreateCommunityInvalidDescription
|
||||
}
|
||||
|
||||
if len(c.IntroMessage) > maxIntroMessageLength {
|
||||
return ErrCreateCommunityInvalidIntroMessage
|
||||
}
|
||||
|
||||
if len(c.OutroMessage) > maxOutroMessageLength {
|
||||
return ErrCreateCommunityInvalidOutroMessage
|
||||
}
|
||||
|
||||
if c.Membership == protobuf.CommunityPermissions_UNKNOWN_ACCESS {
|
||||
return ErrCreateCommunityInvalidMembership
|
||||
}
|
||||
|
||||
if c.Color == "" {
|
||||
return ErrCreateCommunityInvalidColor
|
||||
}
|
||||
|
||||
if !ValidateTags(c.Tags) {
|
||||
return ErrCreateCommunityInvalidTags
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *CreateCommunity) ToCommunityDescription() (*protobuf.CommunityDescription, error) {
|
||||
ci := &protobuf.ChatIdentity{
|
||||
DisplayName: c.Name,
|
||||
Color: c.Color,
|
||||
Emoji: c.Emoji,
|
||||
Description: c.Description,
|
||||
}
|
||||
|
||||
if c.Image != "" || c.Banner.ImagePath != "" {
|
||||
ciis := make(map[string]*protobuf.IdentityImage)
|
||||
if c.Image != "" {
|
||||
log.Info("has-image", "image", c.Image)
|
||||
imgs, err := images.GenerateIdentityImages(c.Image, c.ImageAx, c.ImageAy, c.ImageBx, c.ImageBy)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for i := range imgs {
|
||||
ciis[imgs[i].Name] = adaptIdentityImageToProtobuf(imgs[i])
|
||||
}
|
||||
}
|
||||
if c.Banner.ImagePath != "" {
|
||||
log.Info("has-banner", "image", c.Banner.ImagePath)
|
||||
img, err := images.GenerateBannerImage(c.Banner.ImagePath, c.Banner.X, c.Banner.Y, c.Banner.X+c.Banner.Width, c.Banner.Y+c.Banner.Height)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ciis[img.Name] = adaptIdentityImageToProtobuf(*img)
|
||||
}
|
||||
ci.Images = ciis
|
||||
log.Info("set images", "images", ci)
|
||||
}
|
||||
|
||||
description := &protobuf.CommunityDescription{
|
||||
Identity: ci,
|
||||
Permissions: &protobuf.CommunityPermissions{
|
||||
Access: c.Membership,
|
||||
EnsOnly: c.EnsOnly,
|
||||
},
|
||||
AdminSettings: &protobuf.CommunityAdminSettings{
|
||||
PinMessageAllMembersEnabled: c.PinMessageAllMembersEnabled,
|
||||
},
|
||||
IntroMessage: c.IntroMessage,
|
||||
OutroMessage: c.OutroMessage,
|
||||
Tags: c.Tags,
|
||||
}
|
||||
return description, nil
|
||||
}
|
||||
62
vendor/github.com/status-im/status-go/protocol/requests/create_community_token_permission_request.go
generated
vendored
Normal file
62
vendor/github.com/status-im/status-go/protocol/requests/create_community_token_permission_request.go
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"strconv"
|
||||
|
||||
"github.com/status-im/status-go/eth-node/types"
|
||||
"github.com/status-im/status-go/protocol/protobuf"
|
||||
)
|
||||
|
||||
const maxTokenCriteriaPerPermission = 5
|
||||
|
||||
var (
|
||||
ErrCreateCommunityTokenPermissionInvalidCommunityID = errors.New("create community token permission needs a valid community id")
|
||||
ErrCreateCommunityTokenPermissionTooManyTokenCriteria = errors.New("too many token criteria")
|
||||
ErrCreateCommunityTokenPermissionInvalidPermissionType = errors.New("invalid community token permission type")
|
||||
ErrCreateCommunityTokenPermissionInvalidTokenCriteria = errors.New("invalid community permission token criteria data")
|
||||
)
|
||||
|
||||
type CreateCommunityTokenPermission struct {
|
||||
CommunityID types.HexBytes `json:"communityId"`
|
||||
Type protobuf.CommunityTokenPermission_Type `json:"type"`
|
||||
TokenCriteria []*protobuf.TokenCriteria `json:"tokenCriteria"`
|
||||
IsPrivate bool `json:"isPrivate"`
|
||||
ChatIds []string `json:"chat_ids"`
|
||||
}
|
||||
|
||||
func (p *CreateCommunityTokenPermission) Validate() error {
|
||||
if len(p.CommunityID) == 0 {
|
||||
return ErrCreateCommunityTokenPermissionInvalidCommunityID
|
||||
}
|
||||
|
||||
if len(p.TokenCriteria) > maxTokenCriteriaPerPermission {
|
||||
return ErrCreateCommunityTokenPermissionTooManyTokenCriteria
|
||||
}
|
||||
|
||||
if p.Type == protobuf.CommunityTokenPermission_UNKNOWN_TOKEN_PERMISSION {
|
||||
return ErrCreateCommunityTokenPermissionInvalidPermissionType
|
||||
}
|
||||
|
||||
for _, c := range p.TokenCriteria {
|
||||
if c.EnsPattern == "" && len(c.ContractAddresses) == 0 {
|
||||
return ErrCreateCommunityTokenPermissionInvalidTokenCriteria
|
||||
}
|
||||
|
||||
floatAmount, _ := strconv.ParseFloat(c.Amount, 32)
|
||||
if len(c.ContractAddresses) > 0 && floatAmount == 0 {
|
||||
return ErrCreateCommunityTokenPermissionInvalidTokenCriteria
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *CreateCommunityTokenPermission) ToCommunityTokenPermission() protobuf.CommunityTokenPermission {
|
||||
return protobuf.CommunityTokenPermission{
|
||||
Type: p.Type,
|
||||
TokenCriteria: p.TokenCriteria,
|
||||
IsPrivate: p.IsPrivate,
|
||||
ChatIds: p.ChatIds,
|
||||
}
|
||||
}
|
||||
22
vendor/github.com/status-im/status-go/protocol/requests/create_one_to_one_chat.go
generated
vendored
Normal file
22
vendor/github.com/status-im/status-go/protocol/requests/create_one_to_one_chat.go
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/status-im/status-go/eth-node/types"
|
||||
)
|
||||
|
||||
var ErrCreateOneToOneChatInvalidID = errors.New("create-one-to-one-chat: invalid id")
|
||||
|
||||
type CreateOneToOneChat struct {
|
||||
ID types.HexBytes `json:"id"`
|
||||
ENSName string `json:"ensName"`
|
||||
}
|
||||
|
||||
func (c *CreateOneToOneChat) Validate() error {
|
||||
if len(c.ID) == 0 {
|
||||
return ErrCreateOneToOneChatInvalidID
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
32
vendor/github.com/status-im/status-go/protocol/requests/create_profile_chat.go
generated
vendored
Normal file
32
vendor/github.com/status-im/status-go/protocol/requests/create_profile_chat.go
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/status-im/status-go/deprecation"
|
||||
)
|
||||
|
||||
// Deprecated: errCreateProfileChatInvalidID shouldn't be used
|
||||
// and is only left here in case profile chat feature is re-introduced.
|
||||
var errCreateProfileChatInvalidID = errors.New("create-public-chat: invalid id")
|
||||
|
||||
// Deprecated: CreateProfileChat shouldn't be used
|
||||
// and is only left here in case profile chat feature is re-introduced.
|
||||
type CreateProfileChat struct {
|
||||
ID string `json:"id"`
|
||||
}
|
||||
|
||||
// Deprecated: Validate shouldn't be used
|
||||
// and is only left here in case profile chat feature is re-introduced.
|
||||
func (c *CreateProfileChat) Validate() error {
|
||||
// Return error to prevent usafe of deprecated function
|
||||
if deprecation.ChatProfileDeprecated {
|
||||
return errors.New("profile chats are deprecated")
|
||||
}
|
||||
|
||||
if len(c.ID) == 0 {
|
||||
return errCreateProfileChatInvalidID
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
19
vendor/github.com/status-im/status-go/protocol/requests/create_public_chat.go
generated
vendored
Normal file
19
vendor/github.com/status-im/status-go/protocol/requests/create_public_chat.go
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
)
|
||||
|
||||
var ErrCreatePublicChatInvalidID = errors.New("create-public-chat: invalid id")
|
||||
|
||||
type CreatePublicChat struct {
|
||||
ID string `json:"id"`
|
||||
}
|
||||
|
||||
func (c *CreatePublicChat) Validate() error {
|
||||
if len(c.ID) == 0 {
|
||||
return ErrCreatePublicChatInvalidID
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
20
vendor/github.com/status-im/status-go/protocol/requests/deactivate_chat.go
generated
vendored
Normal file
20
vendor/github.com/status-im/status-go/protocol/requests/deactivate_chat.go
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
)
|
||||
|
||||
var ErrDeactivateChatInvalidID = errors.New("deactivate-chat: invalid id")
|
||||
|
||||
type DeactivateChat struct {
|
||||
ID string `json:"id"`
|
||||
PreserveHistory bool `json:"preserveHistory"`
|
||||
}
|
||||
|
||||
func (j *DeactivateChat) Validate() error {
|
||||
if len(j.ID) == 0 {
|
||||
return ErrDeactivateChatInvalidID
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
21
vendor/github.com/status-im/status-go/protocol/requests/decline_contact_request.go
generated
vendored
Normal file
21
vendor/github.com/status-im/status-go/protocol/requests/decline_contact_request.go
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/status-im/status-go/eth-node/types"
|
||||
)
|
||||
|
||||
var ErrDeclineContactRequestInvalidID = errors.New("decline-contact-request: invalid id")
|
||||
|
||||
type DeclineContactRequest struct {
|
||||
ID types.HexBytes `json:"id"`
|
||||
}
|
||||
|
||||
func (a *DeclineContactRequest) Validate() error {
|
||||
if len(a.ID) == 0 {
|
||||
return ErrDeclineContactRequestInvalidID
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
21
vendor/github.com/status-im/status-go/protocol/requests/decline_request_to_join_community.go
generated
vendored
Normal file
21
vendor/github.com/status-im/status-go/protocol/requests/decline_request_to_join_community.go
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/status-im/status-go/eth-node/types"
|
||||
)
|
||||
|
||||
var ErrDeclineRequestToJoinCommunityInvalidID = errors.New("accept-request-to-join-community: invalid id")
|
||||
|
||||
type DeclineRequestToJoinCommunity struct {
|
||||
ID types.HexBytes `json:"id"`
|
||||
}
|
||||
|
||||
func (j *DeclineRequestToJoinCommunity) Validate() error {
|
||||
if len(j.ID) == 0 {
|
||||
return ErrDeclineRequestToJoinCommunityInvalidID
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
28
vendor/github.com/status-im/status-go/protocol/requests/delete_community_category.go
generated
vendored
Normal file
28
vendor/github.com/status-im/status-go/protocol/requests/delete_community_category.go
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/status-im/status-go/eth-node/types"
|
||||
)
|
||||
|
||||
var ErrDeleteCommunityCategoryInvalidCommunityID = errors.New("delete-community-category: invalid community id")
|
||||
var ErrDeleteCommunityCategoryInvalidCategoryID = errors.New("delete-community-category: invalid category id")
|
||||
|
||||
type DeleteCommunityCategory struct {
|
||||
CommunityID types.HexBytes `json:"communityId"`
|
||||
CategoryID string `json:"categoryId"`
|
||||
}
|
||||
|
||||
func (j *DeleteCommunityCategory) Validate() error {
|
||||
if len(j.CommunityID) == 0 {
|
||||
return ErrDeleteCommunityCategoryInvalidCommunityID
|
||||
}
|
||||
|
||||
if len(j.CategoryID) == 0 {
|
||||
return ErrDeleteCommunityCategoryInvalidCategoryID
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
26
vendor/github.com/status-im/status-go/protocol/requests/delete_community_token_permission.go
generated
vendored
Normal file
26
vendor/github.com/status-im/status-go/protocol/requests/delete_community_token_permission.go
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/status-im/status-go/eth-node/types"
|
||||
)
|
||||
|
||||
var ErrDeleteCommunityTokenPermissionInvalidCommunityID = errors.New("delete community token permission needs a valid community id ")
|
||||
var ErrDeleteCommunityTokenPermissionInvalidPermissionID = errors.New("invalid token permission id")
|
||||
|
||||
type DeleteCommunityTokenPermission struct {
|
||||
CommunityID types.HexBytes `json:"communityId"`
|
||||
PermissionID string `json:"permissionId"`
|
||||
}
|
||||
|
||||
func (r *DeleteCommunityTokenPermission) Validate() error {
|
||||
if len(r.CommunityID) == 0 {
|
||||
return ErrDeleteCommunityCategoryInvalidCommunityID
|
||||
}
|
||||
|
||||
if len(r.PermissionID) == 0 {
|
||||
return ErrDeleteCommunityTokenPermissionInvalidPermissionID
|
||||
}
|
||||
return nil
|
||||
}
|
||||
23
vendor/github.com/status-im/status-go/protocol/requests/dismiss_community_notifications.go
generated
vendored
Normal file
23
vendor/github.com/status-im/status-go/protocol/requests/dismiss_community_notifications.go
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/status-im/status-go/eth-node/types"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrDismissCommunityNotificationsInvalidID = errors.New("dismiss-community-notifications: invalid id")
|
||||
)
|
||||
|
||||
type DismissCommunityNotifications struct {
|
||||
CommunityID types.HexBytes `json:"communityId"`
|
||||
}
|
||||
|
||||
func (r *DismissCommunityNotifications) Validate() error {
|
||||
if len(r.CommunityID) == 0 {
|
||||
return ErrDismissCommunityNotificationsInvalidID
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
21
vendor/github.com/status-im/status-go/protocol/requests/dismiss_latest_contact_request_for_contact.go
generated
vendored
Normal file
21
vendor/github.com/status-im/status-go/protocol/requests/dismiss_latest_contact_request_for_contact.go
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/status-im/status-go/eth-node/types"
|
||||
)
|
||||
|
||||
var ErrDismissLatestContactRequestForContactInvalidID = errors.New("dismiss-latest-contact-request-for-contact: invalid id")
|
||||
|
||||
type DismissLatestContactRequestForContact struct {
|
||||
ID types.HexBytes `json:"id"`
|
||||
}
|
||||
|
||||
func (a *DismissLatestContactRequestForContact) Validate() error {
|
||||
if len(a.ID) == 0 {
|
||||
return ErrDismissLatestContactRequestForContactInvalidID
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
24
vendor/github.com/status-im/status-go/protocol/requests/edit_community.go
generated
vendored
Normal file
24
vendor/github.com/status-im/status-go/protocol/requests/edit_community.go
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/status-im/status-go/eth-node/types"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrEditCommunityInvalidID = errors.New("edit-community: invalid id")
|
||||
)
|
||||
|
||||
type EditCommunity struct {
|
||||
CommunityID types.HexBytes
|
||||
CreateCommunity
|
||||
}
|
||||
|
||||
func (u *EditCommunity) Validate() error {
|
||||
if len(u.CommunityID) == 0 {
|
||||
return ErrEditCommunityInvalidID
|
||||
}
|
||||
|
||||
return u.CreateCommunity.Validate()
|
||||
}
|
||||
34
vendor/github.com/status-im/status-go/protocol/requests/edit_community_category.go
generated
vendored
Normal file
34
vendor/github.com/status-im/status-go/protocol/requests/edit_community_category.go
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/status-im/status-go/eth-node/types"
|
||||
)
|
||||
|
||||
var ErrEditCommunityCategoryInvalidCommunityID = errors.New("edit-community-category: invalid community id")
|
||||
var ErrEditCommunityCategoryInvalidCategoryID = errors.New("edit-community-category: invalid category id")
|
||||
var ErrEditCommunityCategoryInvalidName = errors.New("edit-community-category: invalid category name")
|
||||
|
||||
type EditCommunityCategory struct {
|
||||
CommunityID types.HexBytes `json:"communityId"`
|
||||
CategoryID string `json:"categoryId"`
|
||||
CategoryName string `json:"categoryName"`
|
||||
ChatIDs []string `json:"chatIds"`
|
||||
}
|
||||
|
||||
func (j *EditCommunityCategory) Validate() error {
|
||||
if len(j.CommunityID) == 0 {
|
||||
return ErrEditCommunityCategoryInvalidCommunityID
|
||||
}
|
||||
|
||||
if len(j.CategoryID) == 0 {
|
||||
return ErrEditCommunityCategoryInvalidCategoryID
|
||||
}
|
||||
|
||||
if len(j.CategoryName) == 0 {
|
||||
return ErrEditCommunityCategoryInvalidName
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
34
vendor/github.com/status-im/status-go/protocol/requests/edit_community_token_permission_request.go
generated
vendored
Normal file
34
vendor/github.com/status-im/status-go/protocol/requests/edit_community_token_permission_request.go
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/status-im/status-go/protocol/protobuf"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrEditCommunityTokenPermissionInvalidID = errors.New("invalid community token permission id")
|
||||
)
|
||||
|
||||
type EditCommunityTokenPermission struct {
|
||||
PermissionID string `json:"permissionId"`
|
||||
CreateCommunityTokenPermission
|
||||
}
|
||||
|
||||
func (u *EditCommunityTokenPermission) Validate() error {
|
||||
if len(u.PermissionID) == 0 {
|
||||
return ErrEditCommunityTokenPermissionInvalidID
|
||||
}
|
||||
|
||||
return u.CreateCommunityTokenPermission.Validate()
|
||||
}
|
||||
|
||||
func (u *EditCommunityTokenPermission) ToCommunityTokenPermission() protobuf.CommunityTokenPermission {
|
||||
return protobuf.CommunityTokenPermission{
|
||||
Id: u.PermissionID,
|
||||
Type: u.Type,
|
||||
TokenCriteria: u.TokenCriteria,
|
||||
ChatIds: u.ChatIds,
|
||||
IsPrivate: u.IsPrivate,
|
||||
}
|
||||
}
|
||||
32
vendor/github.com/status-im/status-go/protocol/requests/edit_message.go
generated
vendored
Normal file
32
vendor/github.com/status-im/status-go/protocol/requests/edit_message.go
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/status-im/status-go/eth-node/types"
|
||||
"github.com/status-im/status-go/protocol/common"
|
||||
"github.com/status-im/status-go/protocol/protobuf"
|
||||
)
|
||||
|
||||
var ErrEditMessageInvalidID = errors.New("edit-message: invalid id")
|
||||
var ErrEditMessageInvalidText = errors.New("edit-message: invalid text")
|
||||
|
||||
type EditMessage struct {
|
||||
ID types.HexBytes `json:"id"`
|
||||
Text string `json:"text"`
|
||||
ContentType protobuf.ChatMessage_ContentType `json:"content-type"`
|
||||
LinkPreviews []common.LinkPreview `json:"linkPreviews"`
|
||||
StatusLinkPreviews []common.StatusLinkPreview `json:"statusLinkPreviews"`
|
||||
}
|
||||
|
||||
func (e *EditMessage) Validate() error {
|
||||
if len(e.ID) == 0 {
|
||||
return ErrEditMessageInvalidID
|
||||
}
|
||||
|
||||
if len(e.Text) == 0 {
|
||||
return ErrEditMessageInvalidText
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
56
vendor/github.com/status-im/status-go/protocol/requests/edit_shared_addresses.go
generated
vendored
Normal file
56
vendor/github.com/status-im/status-go/protocol/requests/edit_shared_addresses.go
generated
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/status-im/status-go/eth-node/crypto"
|
||||
"github.com/status-im/status-go/eth-node/types"
|
||||
)
|
||||
|
||||
var ErrInvalidCommunityID = errors.New("invalid community id")
|
||||
var ErrMissingPassword = errors.New("password is necessary when sending a list of addresses")
|
||||
var ErrMissingSharedAddresses = errors.New("list of shared addresses is needed")
|
||||
var ErrMissingAirdropAddress = errors.New("airdropAddress is needed")
|
||||
var ErrNoAirdropAddressAmongAddressesToReveal = errors.New("airdropAddress must be in the set of addresses to reveal")
|
||||
var ErrInvalidSignature = errors.New("invalid signature")
|
||||
|
||||
type EditSharedAddresses struct {
|
||||
CommunityID types.HexBytes `json:"communityId"`
|
||||
AddressesToReveal []string `json:"addressesToReveal"`
|
||||
Signatures []types.HexBytes `json:"signatures"` // the order of signatures should match the order of addresses
|
||||
AirdropAddress string `json:"airdropAddress"`
|
||||
}
|
||||
|
||||
func (j *EditSharedAddresses) Validate() error {
|
||||
if len(j.CommunityID) == 0 {
|
||||
return ErrInvalidCommunityID
|
||||
}
|
||||
|
||||
if len(j.AddressesToReveal) == 0 {
|
||||
return ErrMissingSharedAddresses
|
||||
}
|
||||
|
||||
if j.AirdropAddress == "" {
|
||||
return ErrMissingAirdropAddress
|
||||
}
|
||||
|
||||
found := false
|
||||
for _, address := range j.AddressesToReveal {
|
||||
if address == j.AirdropAddress {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if !found {
|
||||
return ErrNoAirdropAddressAmongAddressesToReveal
|
||||
}
|
||||
|
||||
for _, signature := range j.Signatures {
|
||||
if len(signature) > 0 && len(signature) != crypto.SignatureLength {
|
||||
return ErrInvalidSignature
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
19
vendor/github.com/status-im/status-go/protocol/requests/fetch_messages.go
generated
vendored
Normal file
19
vendor/github.com/status-im/status-go/protocol/requests/fetch_messages.go
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
)
|
||||
|
||||
var ErrFetchMessagesInvalidID = errors.New("fetch-messages: invalid id")
|
||||
|
||||
type FetchMessages struct {
|
||||
ID string `json:"id"`
|
||||
}
|
||||
|
||||
func (c *FetchMessages) Validate() error {
|
||||
if len(c.ID) == 0 {
|
||||
return ErrFetchMessagesInvalidID
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
21
vendor/github.com/status-im/status-go/protocol/requests/get_permissioned_balances_request.go
generated
vendored
Normal file
21
vendor/github.com/status-im/status-go/protocol/requests/get_permissioned_balances_request.go
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/status-im/status-go/eth-node/types"
|
||||
)
|
||||
|
||||
var ErrGetPermissionedBalancesMissingID = errors.New("GetPermissionedBalances: missing community ID")
|
||||
|
||||
type GetPermissionedBalances struct {
|
||||
CommunityID types.HexBytes `json:"communityId"`
|
||||
}
|
||||
|
||||
func (r *GetPermissionedBalances) Validate() error {
|
||||
if len(r.CommunityID) == 0 {
|
||||
return ErrGetPermissionedBalancesMissingID
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
41
vendor/github.com/status-im/status-go/protocol/requests/import_discord_channel.go
generated
vendored
Normal file
41
vendor/github.com/status-im/status-go/protocol/requests/import_discord_channel.go
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/status-im/status-go/eth-node/types"
|
||||
)
|
||||
|
||||
// errrors
|
||||
var (
|
||||
ErrImportDiscordChannelMissingFilesToImport = errors.New("import-discord-channel: missing files to import")
|
||||
ErrImportDiscordChannelChannelIDIsEmpty = errors.New("import-discord-channel: discord channel id is empty")
|
||||
ErrImportDiscordChannelCommunityIDIsEmpty = errors.New("import-discord-channel: community id is empty")
|
||||
)
|
||||
|
||||
type ImportDiscordChannel struct {
|
||||
Name string `json:"name"`
|
||||
DiscordChannelID string `json:"discordChannelID"`
|
||||
CommunityID types.HexBytes `json:"communityId"`
|
||||
Description string `json:"description"`
|
||||
Color string `json:"color"`
|
||||
Emoji string `json:"emoji"`
|
||||
FilesToImport []string `json:"filesToImport"`
|
||||
From int64 `json:"from"`
|
||||
}
|
||||
|
||||
func (r *ImportDiscordChannel) Validate() error {
|
||||
if len(r.FilesToImport) == 0 {
|
||||
return ErrImportDiscordChannelMissingFilesToImport
|
||||
}
|
||||
|
||||
if len(r.DiscordChannelID) == 0 {
|
||||
return ErrImportDiscordChannelChannelIDIsEmpty
|
||||
}
|
||||
|
||||
if len(r.CommunityID) == 0 {
|
||||
return ErrImportDiscordChannelCommunityIDIsEmpty
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
27
vendor/github.com/status-im/status-go/protocol/requests/import_discord_community.go
generated
vendored
Normal file
27
vendor/github.com/status-im/status-go/protocol/requests/import_discord_community.go
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrImportDiscordCommunityMissingFilesToImport = errors.New("import-discord-community: missing files to import")
|
||||
)
|
||||
|
||||
type ImportDiscordCommunity struct {
|
||||
CreateCommunity
|
||||
FilesToImport []string
|
||||
From int64
|
||||
}
|
||||
|
||||
func (u *ImportDiscordCommunity) Validate() error {
|
||||
if len(u.FilesToImport) == 0 {
|
||||
return ErrImportDiscordCommunityMissingFilesToImport
|
||||
}
|
||||
|
||||
return u.CreateCommunity.Validate()
|
||||
}
|
||||
|
||||
func (u *ImportDiscordCommunity) ToCreateCommunityRequest() *CreateCommunity {
|
||||
return &u.CreateCommunity
|
||||
}
|
||||
22
vendor/github.com/status-im/status-go/protocol/requests/login.go
generated
vendored
Normal file
22
vendor/github.com/status-im/status-go/protocol/requests/login.go
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
package requests
|
||||
|
||||
import "errors"
|
||||
|
||||
var ErrLoginInvalidKeyUID = errors.New("login: invalid key-uid")
|
||||
|
||||
type Login struct {
|
||||
Password string `json:"password"`
|
||||
KeyUID string `json:"keyUid"`
|
||||
KdfIterations int `json:"kdfIterations"`
|
||||
|
||||
WakuV2Nameserver string `json:"wakuV2Nameserver"`
|
||||
|
||||
WalletSecretsConfig
|
||||
}
|
||||
|
||||
func (c *Login) Validate() error {
|
||||
if c.KeyUID == "" {
|
||||
return ErrLoginInvalidKeyUID
|
||||
}
|
||||
return nil
|
||||
}
|
||||
25
vendor/github.com/status-im/status-go/protocol/requests/mute_category_request.go
generated
vendored
Normal file
25
vendor/github.com/status-im/status-go/protocol/requests/mute_category_request.go
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
)
|
||||
|
||||
var ErrInvalidMuteCategoryParams = errors.New("mute-category: invalid params")
|
||||
|
||||
type MuteCategory struct {
|
||||
CommunityID string
|
||||
CategoryID string
|
||||
MutedType MutingVariation
|
||||
}
|
||||
|
||||
func (a *MuteCategory) Validate() error {
|
||||
if len(a.CommunityID) == 0 || len(a.CategoryID) == 0 {
|
||||
return ErrInvalidMuteCategoryParams
|
||||
}
|
||||
|
||||
if a.MutedType < 0 {
|
||||
return ErrInvalidMuteCategoryParams
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
26
vendor/github.com/status-im/status-go/protocol/requests/mute_chat_request.go
generated
vendored
Normal file
26
vendor/github.com/status-im/status-go/protocol/requests/mute_chat_request.go
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
)
|
||||
|
||||
var ErrInvalidMuteChatParams = errors.New("mute-chat: invalid params")
|
||||
|
||||
type MutingVariation int
|
||||
|
||||
type MuteChat struct {
|
||||
ChatID string
|
||||
MutedType MutingVariation
|
||||
}
|
||||
|
||||
func (a *MuteChat) Validate() error {
|
||||
if len(a.ChatID) == 0 {
|
||||
return ErrInvalidMuteChatParams
|
||||
}
|
||||
|
||||
if a.MutedType < 0 {
|
||||
return ErrInvalidMuteChatParams
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
26
vendor/github.com/status-im/status-go/protocol/requests/mute_community_request.go
generated
vendored
Normal file
26
vendor/github.com/status-im/status-go/protocol/requests/mute_community_request.go
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/status-im/status-go/eth-node/types"
|
||||
)
|
||||
|
||||
var ErrInvalidMuteCommunityParams = errors.New("mute-community: invalid params")
|
||||
|
||||
type MuteCommunity struct {
|
||||
CommunityID types.HexBytes `json:"communityId"`
|
||||
MutedType MutingVariation `json:"mutedType"`
|
||||
}
|
||||
|
||||
func (a *MuteCommunity) Validate() error {
|
||||
if len(a.CommunityID) == 0 {
|
||||
return ErrInvalidMuteCommunityParams
|
||||
}
|
||||
|
||||
if a.MutedType < 0 {
|
||||
return ErrInvalidMuteCommunityParams
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
19
vendor/github.com/status-im/status-go/protocol/requests/reevaluate_community_members_permissions.go
generated
vendored
Normal file
19
vendor/github.com/status-im/status-go/protocol/requests/reevaluate_community_members_permissions.go
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/status-im/status-go/eth-node/types"
|
||||
)
|
||||
|
||||
type ReevaluateCommunityMembersPermissions struct {
|
||||
CommunityID types.HexBytes `json:"communityId"`
|
||||
}
|
||||
|
||||
func (r *ReevaluateCommunityMembersPermissions) Validate() error {
|
||||
if r.CommunityID == nil || len(r.CommunityID) == 0 {
|
||||
return errors.New("reevaluate community members permissions does not contain communityID")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
34
vendor/github.com/status-im/status-go/protocol/requests/remove_role_from_member.go
generated
vendored
Normal file
34
vendor/github.com/status-im/status-go/protocol/requests/remove_role_from_member.go
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/status-im/status-go/eth-node/types"
|
||||
"github.com/status-im/status-go/protocol/protobuf"
|
||||
)
|
||||
|
||||
var ErrRemoveRoleFromMemberInvalidCommunityID = errors.New("remove-role-from-member: invalid community id")
|
||||
var ErrRemoveRoleFromMemberInvalidUser = errors.New("remove-role-from-member: invalid user id")
|
||||
var ErrRemoveRoleFromMemberInvalidRole = errors.New("remove-role-from-member: invalid role")
|
||||
|
||||
type RemoveRoleFromMember struct {
|
||||
CommunityID types.HexBytes `json:"communityId"`
|
||||
User types.HexBytes `json:"user"`
|
||||
Role protobuf.CommunityMember_Roles `json:"role"`
|
||||
}
|
||||
|
||||
func (r *RemoveRoleFromMember) Validate() error {
|
||||
if len(r.CommunityID) == 0 {
|
||||
return ErrRemoveRoleFromMemberInvalidCommunityID
|
||||
}
|
||||
|
||||
if len(r.User) == 0 {
|
||||
return ErrRemoveRoleFromMemberInvalidUser
|
||||
}
|
||||
|
||||
if r.Role == protobuf.CommunityMember_ROLE_NONE {
|
||||
return ErrRemoveRoleFromMemberInvalidRole
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
33
vendor/github.com/status-im/status-go/protocol/requests/reorder_community_category.go
generated
vendored
Normal file
33
vendor/github.com/status-im/status-go/protocol/requests/reorder_community_category.go
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/status-im/status-go/eth-node/types"
|
||||
)
|
||||
|
||||
var ErrReorderCommunityCategoryInvalidCommunityID = errors.New("reorder-community-category: invalid community id")
|
||||
var ErrReorderCommunityCategoryInvalidCategoryID = errors.New("reorder-community-category: invalid category id")
|
||||
var ErrReorderCommunityCategoryInvalidPosition = errors.New("reorder-community-category: invalid position")
|
||||
|
||||
type ReorderCommunityCategories struct {
|
||||
CommunityID types.HexBytes `json:"communityId"`
|
||||
CategoryID string `json:"categoryId"`
|
||||
Position int `json:"position"`
|
||||
}
|
||||
|
||||
func (j *ReorderCommunityCategories) Validate() error {
|
||||
if len(j.CommunityID) == 0 {
|
||||
return ErrReorderCommunityCategoryInvalidCommunityID
|
||||
}
|
||||
|
||||
if len(j.CategoryID) == 0 {
|
||||
return ErrReorderCommunityCategoryInvalidCategoryID
|
||||
}
|
||||
|
||||
if j.Position < 0 {
|
||||
return ErrReorderCommunityCategoryInvalidPosition
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
34
vendor/github.com/status-im/status-go/protocol/requests/reorder_community_chat.go
generated
vendored
Normal file
34
vendor/github.com/status-im/status-go/protocol/requests/reorder_community_chat.go
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/status-im/status-go/eth-node/types"
|
||||
)
|
||||
|
||||
var ErrReorderCommunityChatInvalidCommunityID = errors.New("reorder-community-chat: invalid community id")
|
||||
var ErrReorderCommunityChatInvalidChatID = errors.New("reorder-community-chat: invalid chat id")
|
||||
var ErrReorderCommunityChatInvalidPosition = errors.New("reorder-community-chat: invalid position")
|
||||
|
||||
type ReorderCommunityChat struct {
|
||||
CommunityID types.HexBytes `json:"communityId"`
|
||||
CategoryID string `json:"categoryId"`
|
||||
ChatID string `json:"chatId"`
|
||||
Position int `json:"position"`
|
||||
}
|
||||
|
||||
func (j *ReorderCommunityChat) Validate() error {
|
||||
if len(j.CommunityID) == 0 {
|
||||
return ErrReorderCommunityChatInvalidCommunityID
|
||||
}
|
||||
|
||||
if len(j.ChatID) == 0 {
|
||||
return ErrReorderCommunityChatInvalidChatID
|
||||
}
|
||||
|
||||
if j.Position < 0 {
|
||||
return ErrReorderCommunityCategoryInvalidPosition
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
65
vendor/github.com/status-im/status-go/protocol/requests/request_to_join_community.go
generated
vendored
Normal file
65
vendor/github.com/status-im/status-go/protocol/requests/request_to_join_community.go
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/status-im/status-go/eth-node/crypto"
|
||||
"github.com/status-im/status-go/eth-node/types"
|
||||
)
|
||||
|
||||
var ErrRequestToJoinCommunityInvalidCommunityID = errors.New("request-to-join-community: invalid community id")
|
||||
var ErrRequestToJoinCommunityNoAddressesToReveal = errors.New("request-to-join-community: no addresses to reveal")
|
||||
var ErrRequestToJoinCommunityMissingPassword = errors.New("request-to-join-community: password is necessary when sending a list of addresses")
|
||||
var ErrRequestToJoinNoAirdropAddress = errors.New("request-to-join-community: airdropAddress is necessary when sending a list of addresses")
|
||||
var ErrRequestToJoinNoAirdropAddressAmongAddressesToReveal = errors.New("request-to-join-community: airdropAddress must be in the set of addresses to reveal")
|
||||
var ErrRequestToJoinCommunityInvalidSignature = errors.New("request-to-join-community: invalid signature")
|
||||
|
||||
type RequestToJoinCommunity struct {
|
||||
CommunityID types.HexBytes `json:"communityId"`
|
||||
ENSName string `json:"ensName"`
|
||||
AddressesToReveal []string `json:"addressesToReveal"`
|
||||
Signatures []types.HexBytes `json:"signatures"` // the order of signatures should match the order of addresses
|
||||
AirdropAddress string `json:"airdropAddress"`
|
||||
}
|
||||
|
||||
func (j *RequestToJoinCommunity) Validate(full bool) error {
|
||||
// TODO: A parital validation, in case `full` is set to `false` should check `AddressesToReveal` as well. But because of changes
|
||||
// that need to be done in tests we cannot do that now.
|
||||
// Also in the line 61, we should remove `len(signature) > 0` from the condition, but from the same reason we cannot do that now.
|
||||
|
||||
if len(j.CommunityID) == 0 {
|
||||
return ErrRequestToJoinCommunityInvalidCommunityID
|
||||
}
|
||||
|
||||
if !full {
|
||||
return nil
|
||||
}
|
||||
|
||||
if len(j.AddressesToReveal) == 0 {
|
||||
return ErrRequestToJoinCommunityNoAddressesToReveal
|
||||
}
|
||||
|
||||
if j.AirdropAddress == "" {
|
||||
return ErrRequestToJoinNoAirdropAddress
|
||||
}
|
||||
|
||||
found := false
|
||||
for _, address := range j.AddressesToReveal {
|
||||
if address == j.AirdropAddress {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if !found {
|
||||
return ErrRequestToJoinNoAirdropAddressAmongAddressesToReveal
|
||||
}
|
||||
|
||||
for _, signature := range j.Signatures {
|
||||
if len(signature) > 0 && len(signature) != crypto.SignatureLength {
|
||||
return ErrRequestToJoinCommunityInvalidSignature
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
20
vendor/github.com/status-im/status-go/protocol/requests/restore_account.go
generated
vendored
Normal file
20
vendor/github.com/status-im/status-go/protocol/requests/restore_account.go
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
)
|
||||
|
||||
var ErrRestoreAccountInvalidMnemonic = errors.New("restore-account: invalid mnemonic")
|
||||
|
||||
type RestoreAccount struct {
|
||||
Mnemonic string `json:"mnemonic"`
|
||||
CreateAccount
|
||||
}
|
||||
|
||||
func (c *RestoreAccount) Validate() error {
|
||||
if len(c.Mnemonic) == 0 {
|
||||
return ErrRestoreAccountInvalidMnemonic
|
||||
}
|
||||
|
||||
return ValidateAccountCreationRequest(c.CreateAccount)
|
||||
}
|
||||
21
vendor/github.com/status-im/status-go/protocol/requests/retract_contact_request.go
generated
vendored
Normal file
21
vendor/github.com/status-im/status-go/protocol/requests/retract_contact_request.go
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/status-im/status-go/eth-node/types"
|
||||
)
|
||||
|
||||
var ErrRetractContactRequestInvalidContactID = errors.New("retract-contact-request: invalid id")
|
||||
|
||||
type RetractContactRequest struct {
|
||||
ID types.HexBytes `json:"id"`
|
||||
}
|
||||
|
||||
func (a *RetractContactRequest) Validate() error {
|
||||
if len(a.ID) == 0 {
|
||||
return ErrRetractContactRequestInvalidContactID
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
40
vendor/github.com/status-im/status-go/protocol/requests/send_contact_request.go
generated
vendored
Normal file
40
vendor/github.com/status-im/status-go/protocol/requests/send_contact_request.go
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/status-im/status-go/api/multiformat"
|
||||
)
|
||||
|
||||
var ErrSendContactRequestInvalidID = errors.New("send-contact-request: invalid id")
|
||||
var ErrSendContactRequestInvalidMessage = errors.New("send-contact-request: invalid message")
|
||||
|
||||
const legacyKeyLength = 132
|
||||
|
||||
type SendContactRequest struct {
|
||||
ID string `json:"id"`
|
||||
Message string `json:"message"`
|
||||
}
|
||||
|
||||
func (a *SendContactRequest) Validate() error {
|
||||
if len(a.ID) == 0 {
|
||||
return ErrSendContactRequestInvalidID
|
||||
}
|
||||
|
||||
if len(a.Message) == 0 {
|
||||
return ErrSendContactRequestInvalidMessage
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func ConvertCompressedToLegacyKey(k string) (string, error) {
|
||||
if len(k) == legacyKeyLength {
|
||||
return k, nil
|
||||
}
|
||||
return multiformat.DeserializeCompressedKey(k)
|
||||
}
|
||||
|
||||
func (a *SendContactRequest) HexID() (string, error) {
|
||||
return ConvertCompressedToLegacyKey(a.ID)
|
||||
}
|
||||
25
vendor/github.com/status-im/status-go/protocol/requests/send_group_chat_message.go
generated
vendored
Normal file
25
vendor/github.com/status-im/status-go/protocol/requests/send_group_chat_message.go
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
)
|
||||
|
||||
var ErrSendGroupChatMessageInvalidID = errors.New("send-group-chat-message: invalid id")
|
||||
var ErrSendGroupChatMessageInvalidMessage = errors.New("send-group-chat-message: invalid message")
|
||||
|
||||
type SendGroupChatMessage struct {
|
||||
ID string `json:"id"`
|
||||
Message string `json:"message"`
|
||||
}
|
||||
|
||||
func (a *SendGroupChatMessage) Validate() error {
|
||||
if len(a.ID) == 0 {
|
||||
return ErrSendGroupChatMessageInvalidID
|
||||
}
|
||||
|
||||
if len(a.Message) == 0 {
|
||||
return ErrSendGroupChatMessageInvalidMessage
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
29
vendor/github.com/status-im/status-go/protocol/requests/send_one_to_one_message.go
generated
vendored
Normal file
29
vendor/github.com/status-im/status-go/protocol/requests/send_one_to_one_message.go
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
)
|
||||
|
||||
var ErrSendOneToOneMessageInvalidID = errors.New("send-one-to-one-message: invalid id")
|
||||
var ErrSendOneToOneMessageInvalidMessage = errors.New("send-one-to-one-message: invalid message")
|
||||
|
||||
type SendOneToOneMessage struct {
|
||||
ID string `json:"id"`
|
||||
Message string `json:"message"`
|
||||
}
|
||||
|
||||
func (a *SendOneToOneMessage) Validate() error {
|
||||
if len(a.ID) == 0 {
|
||||
return ErrSendOneToOneMessageInvalidID
|
||||
}
|
||||
|
||||
if len(a.Message) == 0 {
|
||||
return ErrSendOneToOneMessageInvalidMessage
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *SendOneToOneMessage) HexID() (string, error) {
|
||||
return ConvertCompressedToLegacyKey(a.ID)
|
||||
}
|
||||
30
vendor/github.com/status-im/status-go/protocol/requests/set_community_shard.go
generated
vendored
Normal file
30
vendor/github.com/status-im/status-go/protocol/requests/set_community_shard.go
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/status-im/status-go/eth-node/types"
|
||||
"github.com/status-im/status-go/protocol/common/shard"
|
||||
)
|
||||
|
||||
type SetCommunityShard struct {
|
||||
CommunityID types.HexBytes `json:"communityId"`
|
||||
Shard *shard.Shard `json:"shard,omitempty"`
|
||||
PrivateKey *types.HexBytes `json:"privateKey,omitempty"`
|
||||
}
|
||||
|
||||
func (s *SetCommunityShard) Validate() error {
|
||||
if s == nil {
|
||||
return errors.New("invalid request")
|
||||
}
|
||||
if s.Shard != nil {
|
||||
// TODO: for now only MainStatusShard(16) is accepted
|
||||
if s.Shard.Cluster != shard.MainStatusShardCluster {
|
||||
return errors.New("invalid shard cluster")
|
||||
}
|
||||
if s.Shard.Index > 1023 {
|
||||
return errors.New("invalid shard index. Only 0-1023 is allowed")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
22
vendor/github.com/status-im/status-go/protocol/requests/set_contact_local_nickname.go
generated
vendored
Normal file
22
vendor/github.com/status-im/status-go/protocol/requests/set_contact_local_nickname.go
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/status-im/status-go/eth-node/types"
|
||||
)
|
||||
|
||||
var ErrSetContactLocalNicknameInvalidID = errors.New("add-contact: invalid id")
|
||||
|
||||
type SetContactLocalNickname struct {
|
||||
ID types.HexBytes `json:"id"`
|
||||
Nickname string `json:"nickname"`
|
||||
}
|
||||
|
||||
func (a *SetContactLocalNickname) Validate() error {
|
||||
if len(a.ID) == 0 {
|
||||
return ErrSetContactLocalNicknameInvalidID
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
5
vendor/github.com/status-im/status-go/protocol/requests/set_custom_nodes.go
generated
vendored
Normal file
5
vendor/github.com/status-im/status-go/protocol/requests/set_custom_nodes.go
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
package requests
|
||||
|
||||
type SetCustomNodes struct {
|
||||
CustomNodes map[string]string `json:"customNodes"`
|
||||
}
|
||||
27
vendor/github.com/status-im/status-go/protocol/requests/set_customization_color.go
generated
vendored
Normal file
27
vendor/github.com/status-im/status-go/protocol/requests/set_customization_color.go
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/status-im/status-go/multiaccounts/common"
|
||||
)
|
||||
|
||||
var ErrSetCustomizationColorInvalidColor = errors.New("customizationColor: invalid color")
|
||||
var ErrSetCustomizationColorInvalidKeyUID = errors.New("keyUid: invalid id")
|
||||
|
||||
type SetCustomizationColor struct {
|
||||
CustomizationColor common.CustomizationColor `json:"customizationColor"`
|
||||
KeyUID string `json:"keyUid"`
|
||||
}
|
||||
|
||||
func (a *SetCustomizationColor) Validate() error {
|
||||
if len(a.CustomizationColor) == 0 {
|
||||
return ErrSetCustomizationColorInvalidColor
|
||||
}
|
||||
|
||||
if len(a.KeyUID) == 0 {
|
||||
return ErrSetCustomizationColorInvalidKeyUID
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
5
vendor/github.com/status-im/status-go/protocol/requests/set_light_client.go
generated
vendored
Normal file
5
vendor/github.com/status-im/status-go/protocol/requests/set_light_client.go
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
package requests
|
||||
|
||||
type SetLightClient struct {
|
||||
Enabled bool `json:"enabled"`
|
||||
}
|
||||
28
vendor/github.com/status-im/status-go/protocol/requests/set_log_level.go
generated
vendored
Normal file
28
vendor/github.com/status-im/status-go/protocol/requests/set_log_level.go
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
)
|
||||
|
||||
const (
|
||||
ErrorLogLevel = "ERROR"
|
||||
WarnLogLevel = "WARN"
|
||||
InfoLogLevel = "INFO"
|
||||
DebugLogLevel = "DEBUG"
|
||||
TraceLogLevel = "TRACE"
|
||||
)
|
||||
|
||||
var ErrSetLogLevelInvalidLogLevel = errors.New("set-log-level: invalid log level")
|
||||
|
||||
type SetLogLevel struct {
|
||||
LogLevel string `json:"logLevel"`
|
||||
}
|
||||
|
||||
func (c *SetLogLevel) Validate() error {
|
||||
switch c.LogLevel {
|
||||
case ErrorLogLevel, WarnLogLevel, InfoLogLevel, DebugLogLevel, TraceLogLevel:
|
||||
return nil
|
||||
}
|
||||
|
||||
return ErrSetLogLevelInvalidLogLevel
|
||||
}
|
||||
28
vendor/github.com/status-im/status-go/protocol/requests/share_community.go
generated
vendored
Normal file
28
vendor/github.com/status-im/status-go/protocol/requests/share_community.go
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/status-im/status-go/eth-node/types"
|
||||
)
|
||||
|
||||
var ErrShareCommunityInvalidID = errors.New("share-community: invalid id")
|
||||
var ErrShareCommunityEmptyUsers = errors.New("share-community: empty users")
|
||||
|
||||
type ShareCommunity struct {
|
||||
CommunityID types.HexBytes `json:"communityId"`
|
||||
Users []types.HexBytes `json:"users"`
|
||||
InviteMessage string `json:"inviteMessage,omitempty"`
|
||||
}
|
||||
|
||||
func (j *ShareCommunity) Validate() error {
|
||||
if len(j.CommunityID) == 0 {
|
||||
return ErrShareCommunityInvalidID
|
||||
}
|
||||
|
||||
if len(j.Users) == 0 {
|
||||
return ErrShareCommunityEmptyUsers
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
27
vendor/github.com/status-im/status-go/protocol/requests/share_image_message.go
generated
vendored
Normal file
27
vendor/github.com/status-im/status-go/protocol/requests/share_image_message.go
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/status-im/status-go/eth-node/types"
|
||||
)
|
||||
|
||||
var ErrShareMessageInvalidID = errors.New("share image message: invalid id")
|
||||
var ErrShareMessageEmptyUsers = errors.New("share image message: empty users")
|
||||
|
||||
type ShareImageMessage struct {
|
||||
MessageID string `json:"id"`
|
||||
Users []types.HexBytes `json:"users"`
|
||||
}
|
||||
|
||||
func (s *ShareImageMessage) Validate() error {
|
||||
if len(s.MessageID) == 0 {
|
||||
return ErrShareMessageInvalidID
|
||||
}
|
||||
|
||||
if len(s.Users) == 0 {
|
||||
return ErrShareMessageEmptyUsers
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
26
vendor/github.com/status-im/status-go/protocol/requests/toggle_collapsed_community_category.go
generated
vendored
Normal file
26
vendor/github.com/status-im/status-go/protocol/requests/toggle_collapsed_community_category.go
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
)
|
||||
|
||||
var ErrToggleCollapsedCommunityCategoryInvalidCommunityID = errors.New("toggle-collapsed-community-category: invalid community id")
|
||||
var ErrToggleCollapsedCommunityCategoryInvalidName = errors.New("toggle-collapsed-community-category: invalid category name")
|
||||
|
||||
type ToggleCollapsedCommunityCategory struct {
|
||||
CommunityID string `json:"communityId"`
|
||||
CategoryID string `json:"categoryId"`
|
||||
Collapsed bool `json:"collapsed"`
|
||||
}
|
||||
|
||||
func (t *ToggleCollapsedCommunityCategory) Validate() error {
|
||||
if len(t.CommunityID) == 0 {
|
||||
return ErrToggleCollapsedCommunityCategoryInvalidCommunityID
|
||||
}
|
||||
|
||||
if len(t.CategoryID) == 0 {
|
||||
return ErrToggleCollapsedCommunityCategoryInvalidName
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
27
vendor/github.com/status-im/status-go/protocol/requests/unban_user_from_community.go
generated
vendored
Normal file
27
vendor/github.com/status-im/status-go/protocol/requests/unban_user_from_community.go
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/status-im/status-go/eth-node/types"
|
||||
)
|
||||
|
||||
var ErrUnbanUserFromCommunityInvalidCommunityID = errors.New("unban-user-from-community: invalid community id")
|
||||
var ErrUnbanUserFromCommunityInvalidUser = errors.New("unban-user-from-community: invalid user id")
|
||||
|
||||
type UnbanUserFromCommunity struct {
|
||||
CommunityID types.HexBytes `json:"communityId"`
|
||||
User types.HexBytes `json:"user"`
|
||||
}
|
||||
|
||||
func (b *UnbanUserFromCommunity) Validate() error {
|
||||
if len(b.CommunityID) == 0 {
|
||||
return ErrUnbanUserFromCommunityInvalidCommunityID
|
||||
}
|
||||
|
||||
if len(b.User) == 0 {
|
||||
return ErrUnbanUserFromCommunityInvalidUser
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
20
vendor/github.com/status-im/status-go/protocol/requests/upsert_switcher_card.go
generated
vendored
Normal file
20
vendor/github.com/status-im/status-go/protocol/requests/upsert_switcher_card.go
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
package requests
|
||||
|
||||
import "errors"
|
||||
|
||||
var ErrUpsertSwitcherCardInvalidCardID = errors.New("upsert-switcher-card: invalid card id")
|
||||
|
||||
type UpsertSwitcherCard struct {
|
||||
CardID string `json:"cardId,omitempty"`
|
||||
Type int `json:"type"`
|
||||
Clock uint64 `json:"clock"`
|
||||
ScreenID string `json:"screenId"`
|
||||
}
|
||||
|
||||
func (a *UpsertSwitcherCard) Validate() error {
|
||||
if len(a.CardID) == 0 {
|
||||
return ErrUpsertSwitcherCardInvalidCardID
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
21
vendor/github.com/status-im/status-go/protocol/requests/verified_trusted.go
generated
vendored
Normal file
21
vendor/github.com/status-im/status-go/protocol/requests/verified_trusted.go
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/status-im/status-go/eth-node/types"
|
||||
)
|
||||
|
||||
var ErrVerifiedTrustedInvalidID = errors.New("verified-trusted: invalid id")
|
||||
|
||||
type VerifiedTrusted struct {
|
||||
ID types.HexBytes `json:"id"`
|
||||
}
|
||||
|
||||
func (a *VerifiedTrusted) Validate() error {
|
||||
if len(a.ID) == 0 {
|
||||
return ErrVerifiedTrustedInvalidID
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
21
vendor/github.com/status-im/status-go/protocol/requests/verified_untrustworthy.go
generated
vendored
Normal file
21
vendor/github.com/status-im/status-go/protocol/requests/verified_untrustworthy.go
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/status-im/status-go/eth-node/types"
|
||||
)
|
||||
|
||||
var ErrVerifiedUntrustworthyInvalidID = errors.New("verified-untrustworthy: invalid id")
|
||||
|
||||
type VerifiedUntrustworthy struct {
|
||||
ID types.HexBytes `json:"id"`
|
||||
}
|
||||
|
||||
func (a *VerifiedUntrustworthy) Validate() error {
|
||||
if len(a.ID) == 0 {
|
||||
return ErrVerifiedUntrustworthyInvalidID
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user