2023-10-12 19:21:49 +00:00
|
|
|
package requests
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
|
|
|
|
"github.com/status-im/status-go/eth-node/types"
|
2023-11-15 15:58:15 +00:00
|
|
|
"github.com/status-im/status-go/protocol/common/shard"
|
2023-10-12 19:21:49 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type SetCommunityShard struct {
|
|
|
|
CommunityID types.HexBytes `json:"communityId"`
|
2023-11-15 15:58:15 +00:00
|
|
|
Shard *shard.Shard `json:"shard,omitempty"`
|
2023-10-12 19:21:49 +00:00
|
|
|
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
|
2023-11-15 15:58:15 +00:00
|
|
|
if s.Shard.Cluster != shard.MainStatusShardCluster {
|
2023-10-12 19:21:49 +00:00
|
|
|
return errors.New("invalid shard cluster")
|
|
|
|
}
|
|
|
|
if s.Shard.Index > 1023 {
|
|
|
|
return errors.New("invalid shard index. Only 0-1023 is allowed")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|