diff --git a/api/dao/v1/dao.proto b/api/dao/v1/dao.proto index e8ff4a2a7d..039276b6e0 100644 --- a/api/dao/v1/dao.proto +++ b/api/dao/v1/dao.proto @@ -4,17 +4,26 @@ option go_package = "./daopb"; service DAOService { rpc DAOs(DAOsRequest) returns (DAOsResponse); + rpc IsUserDAOMember(IsUserDAOMemberRequest) returns (IsUserDAOMemberResponse); } message DAOsRequest { - string network_id = 1; - string member_address = 2; + string network_id = 1; + string member_address = 2; } message DAOsResponse { repeated DAO daos = 1; } +message IsUserDAOMemberRequest { + string user_id = 1; + string dao_id = 2; +} +message IsUserDAOMemberResponse { + bool is_member = 1; +} + message DAO { string id = 1; string admin = 2; @@ -28,3 +37,4 @@ message DAO { string token_symbol = 10; uint64 unstaking_duration = 11; } + diff --git a/go/pkg/dao/dao_service.go b/go/pkg/dao/dao_service.go index 4ecd4a926c..21d0d74146 100644 --- a/go/pkg/dao/dao_service.go +++ b/go/pkg/dao/dao_service.go @@ -74,3 +74,41 @@ func (s *DAOService) DAOs(ctx context.Context, req *daopb.DAOsRequest) (*daopb.D Daos: pbdaos, }, nil } + +func (s *DAOService) IsUserDAOMember(ctx context.Context, req *daopb.IsUserDAOMemberRequest) (*daopb.IsUserDAOMemberResponse, error) { + db := s.conf.IndexerDB + userId := req.GetUserId() + daoId := req.GetDaoId() + + daoNetwork, daoAddress, err := s.conf.NetStore.ParseUserID(daoId) + if err != nil { + return nil, + errors.Wrap(err, "failed to parse dao id") + } + + _, userAddress, err := s.conf.NetStore.ParseUserID(userId) + if err != nil { + return nil, + errors.Wrap(err, "failed to parse user id") + } + + var isMember bool + dbErr := db.Raw(`SELECT EXISTS ( + SELECT 1 + FROM dao_members dm + JOIN daos d ON dm.dao_contract_address = d.contract_address + WHERE d.contract_address = ? + AND d.network_id = ? + AND dm.member_address = ? + ) AS dao_exists;`, + daoAddress, + daoNetwork.GetBase().ID, + userAddress, + ).Scan(&isMember).Error + if dbErr != nil { + return nil, errors.Wrap(dbErr, "failed to query database") + } + return &daopb.IsUserDAOMemberResponse{ + IsMember: isMember, + }, nil +} diff --git a/go/pkg/daopb/dao.pb.go b/go/pkg/daopb/dao.pb.go index 7cd04f74a9..fde9635007 100644 --- a/go/pkg/daopb/dao.pb.go +++ b/go/pkg/daopb/dao.pb.go @@ -122,6 +122,108 @@ func (x *DAOsResponse) GetDaos() []*DAO { return nil } +type IsUserDAOMemberRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + UserId string `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` + DaoId string `protobuf:"bytes,2,opt,name=dao_id,json=daoId,proto3" json:"dao_id,omitempty"` +} + +func (x *IsUserDAOMemberRequest) Reset() { + *x = IsUserDAOMemberRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_dao_v1_dao_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *IsUserDAOMemberRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*IsUserDAOMemberRequest) ProtoMessage() {} + +func (x *IsUserDAOMemberRequest) ProtoReflect() protoreflect.Message { + mi := &file_dao_v1_dao_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use IsUserDAOMemberRequest.ProtoReflect.Descriptor instead. +func (*IsUserDAOMemberRequest) Descriptor() ([]byte, []int) { + return file_dao_v1_dao_proto_rawDescGZIP(), []int{2} +} + +func (x *IsUserDAOMemberRequest) GetUserId() string { + if x != nil { + return x.UserId + } + return "" +} + +func (x *IsUserDAOMemberRequest) GetDaoId() string { + if x != nil { + return x.DaoId + } + return "" +} + +type IsUserDAOMemberResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + IsMember bool `protobuf:"varint,1,opt,name=is_member,json=isMember,proto3" json:"is_member,omitempty"` +} + +func (x *IsUserDAOMemberResponse) Reset() { + *x = IsUserDAOMemberResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_dao_v1_dao_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *IsUserDAOMemberResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*IsUserDAOMemberResponse) ProtoMessage() {} + +func (x *IsUserDAOMemberResponse) ProtoReflect() protoreflect.Message { + mi := &file_dao_v1_dao_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use IsUserDAOMemberResponse.ProtoReflect.Descriptor instead. +func (*IsUserDAOMemberResponse) Descriptor() ([]byte, []int) { + return file_dao_v1_dao_proto_rawDescGZIP(), []int{3} +} + +func (x *IsUserDAOMemberResponse) GetIsMember() bool { + if x != nil { + return x.IsMember + } + return false +} + type DAO struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -143,7 +245,7 @@ type DAO struct { func (x *DAO) Reset() { *x = DAO{} if protoimpl.UnsafeEnabled { - mi := &file_dao_v1_dao_proto_msgTypes[2] + mi := &file_dao_v1_dao_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -156,7 +258,7 @@ func (x *DAO) String() string { func (*DAO) ProtoMessage() {} func (x *DAO) ProtoReflect() protoreflect.Message { - mi := &file_dao_v1_dao_proto_msgTypes[2] + mi := &file_dao_v1_dao_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -169,7 +271,7 @@ func (x *DAO) ProtoReflect() protoreflect.Message { // Deprecated: Use DAO.ProtoReflect.Descriptor instead. func (*DAO) Descriptor() ([]byte, []int) { - return file_dao_v1_dao_proto_rawDescGZIP(), []int{2} + return file_dao_v1_dao_proto_rawDescGZIP(), []int{4} } func (x *DAO) GetId() string { @@ -262,33 +364,46 @@ var file_dao_v1_dao_proto_rawDesc = []byte{ 0x2f, 0x0a, 0x0c, 0x44, 0x41, 0x4f, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x04, 0x64, 0x61, 0x6f, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x64, 0x61, 0x6f, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x41, 0x4f, 0x52, 0x04, 0x64, 0x61, 0x6f, 0x73, - 0x22, 0xd0, 0x02, 0x0a, 0x03, 0x44, 0x41, 0x4f, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x64, 0x6d, 0x69, - 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x12, 0x29, - 0x0a, 0x10, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x61, 0x63, 0x74, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, - 0x73, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x61, - 0x63, 0x74, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, - 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, - 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, - 0x1b, 0x0a, 0x09, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x06, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x08, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x55, 0x72, 0x6c, 0x12, 0x16, 0x0a, 0x06, - 0x71, 0x75, 0x6f, 0x72, 0x75, 0x6d, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x71, 0x75, - 0x6f, 0x72, 0x75, 0x6d, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x68, 0x72, 0x65, 0x73, 0x68, 0x6f, 0x6c, - 0x64, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x74, 0x68, 0x72, 0x65, 0x73, 0x68, 0x6f, - 0x6c, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x5f, 0x6e, 0x61, 0x6d, 0x65, - 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x4e, 0x61, 0x6d, - 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x5f, 0x73, 0x79, 0x6d, 0x62, 0x6f, - 0x6c, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x53, 0x79, - 0x6d, 0x62, 0x6f, 0x6c, 0x12, 0x2d, 0x0a, 0x12, 0x75, 0x6e, 0x73, 0x74, 0x61, 0x6b, 0x69, 0x6e, - 0x67, 0x5f, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x04, - 0x52, 0x11, 0x75, 0x6e, 0x73, 0x74, 0x61, 0x6b, 0x69, 0x6e, 0x67, 0x44, 0x75, 0x72, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x32, 0x3f, 0x0a, 0x0a, 0x44, 0x41, 0x4f, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x12, 0x31, 0x0a, 0x04, 0x44, 0x41, 0x4f, 0x73, 0x12, 0x13, 0x2e, 0x64, 0x61, 0x6f, 0x2e, - 0x76, 0x31, 0x2e, 0x44, 0x41, 0x4f, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, - 0x2e, 0x64, 0x61, 0x6f, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x41, 0x4f, 0x73, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x09, 0x5a, 0x07, 0x2e, 0x2f, 0x64, 0x61, 0x6f, 0x70, 0x62, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x22, 0x48, 0x0a, 0x16, 0x49, 0x73, 0x55, 0x73, 0x65, 0x72, 0x44, 0x41, 0x4f, 0x4d, 0x65, 0x6d, + 0x62, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, + 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x75, 0x73, 0x65, + 0x72, 0x49, 0x64, 0x12, 0x15, 0x0a, 0x06, 0x64, 0x61, 0x6f, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x05, 0x64, 0x61, 0x6f, 0x49, 0x64, 0x22, 0x36, 0x0a, 0x17, 0x49, 0x73, + 0x55, 0x73, 0x65, 0x72, 0x44, 0x41, 0x4f, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x69, 0x73, 0x5f, 0x6d, 0x65, 0x6d, 0x62, + 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x69, 0x73, 0x4d, 0x65, 0x6d, 0x62, + 0x65, 0x72, 0x22, 0xd0, 0x02, 0x0a, 0x03, 0x44, 0x41, 0x4f, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x64, + 0x6d, 0x69, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x61, 0x64, 0x6d, 0x69, 0x6e, + 0x12, 0x29, 0x0a, 0x10, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x61, 0x63, 0x74, 0x5f, 0x61, 0x64, 0x64, + 0x72, 0x65, 0x73, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x63, 0x6f, 0x6e, 0x74, + 0x72, 0x61, 0x63, 0x74, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, + 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x05, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, + 0x6e, 0x12, 0x1b, 0x0a, 0x09, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x06, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x55, 0x72, 0x6c, 0x12, 0x16, + 0x0a, 0x06, 0x71, 0x75, 0x6f, 0x72, 0x75, 0x6d, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, + 0x71, 0x75, 0x6f, 0x72, 0x75, 0x6d, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x68, 0x72, 0x65, 0x73, 0x68, + 0x6f, 0x6c, 0x64, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x74, 0x68, 0x72, 0x65, 0x73, + 0x68, 0x6f, 0x6c, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x5f, 0x6e, 0x61, + 0x6d, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x4e, + 0x61, 0x6d, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x5f, 0x73, 0x79, 0x6d, + 0x62, 0x6f, 0x6c, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x74, 0x6f, 0x6b, 0x65, 0x6e, + 0x53, 0x79, 0x6d, 0x62, 0x6f, 0x6c, 0x12, 0x2d, 0x0a, 0x12, 0x75, 0x6e, 0x73, 0x74, 0x61, 0x6b, + 0x69, 0x6e, 0x67, 0x5f, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x0b, 0x20, 0x01, + 0x28, 0x04, 0x52, 0x11, 0x75, 0x6e, 0x73, 0x74, 0x61, 0x6b, 0x69, 0x6e, 0x67, 0x44, 0x75, 0x72, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x32, 0x93, 0x01, 0x0a, 0x0a, 0x44, 0x41, 0x4f, 0x53, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x12, 0x31, 0x0a, 0x04, 0x44, 0x41, 0x4f, 0x73, 0x12, 0x13, 0x2e, 0x64, + 0x61, 0x6f, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x41, 0x4f, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x14, 0x2e, 0x64, 0x61, 0x6f, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x41, 0x4f, 0x73, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x52, 0x0a, 0x0f, 0x49, 0x73, 0x55, 0x73, 0x65, + 0x72, 0x44, 0x41, 0x4f, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x1e, 0x2e, 0x64, 0x61, 0x6f, + 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x73, 0x55, 0x73, 0x65, 0x72, 0x44, 0x41, 0x4f, 0x4d, 0x65, 0x6d, + 0x62, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x64, 0x61, 0x6f, + 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x73, 0x55, 0x73, 0x65, 0x72, 0x44, 0x41, 0x4f, 0x4d, 0x65, 0x6d, + 0x62, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x09, 0x5a, 0x07, 0x2e, + 0x2f, 0x64, 0x61, 0x6f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -303,18 +418,22 @@ func file_dao_v1_dao_proto_rawDescGZIP() []byte { return file_dao_v1_dao_proto_rawDescData } -var file_dao_v1_dao_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_dao_v1_dao_proto_msgTypes = make([]protoimpl.MessageInfo, 5) var file_dao_v1_dao_proto_goTypes = []interface{}{ - (*DAOsRequest)(nil), // 0: dao.v1.DAOsRequest - (*DAOsResponse)(nil), // 1: dao.v1.DAOsResponse - (*DAO)(nil), // 2: dao.v1.DAO + (*DAOsRequest)(nil), // 0: dao.v1.DAOsRequest + (*DAOsResponse)(nil), // 1: dao.v1.DAOsResponse + (*IsUserDAOMemberRequest)(nil), // 2: dao.v1.IsUserDAOMemberRequest + (*IsUserDAOMemberResponse)(nil), // 3: dao.v1.IsUserDAOMemberResponse + (*DAO)(nil), // 4: dao.v1.DAO } var file_dao_v1_dao_proto_depIdxs = []int32{ - 2, // 0: dao.v1.DAOsResponse.daos:type_name -> dao.v1.DAO + 4, // 0: dao.v1.DAOsResponse.daos:type_name -> dao.v1.DAO 0, // 1: dao.v1.DAOService.DAOs:input_type -> dao.v1.DAOsRequest - 1, // 2: dao.v1.DAOService.DAOs:output_type -> dao.v1.DAOsResponse - 2, // [2:3] is the sub-list for method output_type - 1, // [1:2] is the sub-list for method input_type + 2, // 2: dao.v1.DAOService.IsUserDAOMember:input_type -> dao.v1.IsUserDAOMemberRequest + 1, // 3: dao.v1.DAOService.DAOs:output_type -> dao.v1.DAOsResponse + 3, // 4: dao.v1.DAOService.IsUserDAOMember:output_type -> dao.v1.IsUserDAOMemberResponse + 3, // [3:5] is the sub-list for method output_type + 1, // [1:3] is the sub-list for method input_type 1, // [1:1] is the sub-list for extension type_name 1, // [1:1] is the sub-list for extension extendee 0, // [0:1] is the sub-list for field type_name @@ -351,6 +470,30 @@ func file_dao_v1_dao_proto_init() { } } file_dao_v1_dao_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*IsUserDAOMemberRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_dao_v1_dao_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*IsUserDAOMemberResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_dao_v1_dao_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*DAO); i { case 0: return &v.state @@ -369,7 +512,7 @@ func file_dao_v1_dao_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_dao_v1_dao_proto_rawDesc, NumEnums: 0, - NumMessages: 3, + NumMessages: 5, NumExtensions: 0, NumServices: 1, }, diff --git a/go/pkg/daopb/dao_grpc.pb.go b/go/pkg/daopb/dao_grpc.pb.go index 9e30a582b6..c64a8bde50 100644 --- a/go/pkg/daopb/dao_grpc.pb.go +++ b/go/pkg/daopb/dao_grpc.pb.go @@ -23,6 +23,7 @@ const _ = grpc.SupportPackageIsVersion7 // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. type DAOServiceClient interface { DAOs(ctx context.Context, in *DAOsRequest, opts ...grpc.CallOption) (*DAOsResponse, error) + IsUserDAOMember(ctx context.Context, in *IsUserDAOMemberRequest, opts ...grpc.CallOption) (*IsUserDAOMemberResponse, error) } type dAOServiceClient struct { @@ -42,11 +43,21 @@ func (c *dAOServiceClient) DAOs(ctx context.Context, in *DAOsRequest, opts ...gr return out, nil } +func (c *dAOServiceClient) IsUserDAOMember(ctx context.Context, in *IsUserDAOMemberRequest, opts ...grpc.CallOption) (*IsUserDAOMemberResponse, error) { + out := new(IsUserDAOMemberResponse) + err := c.cc.Invoke(ctx, "/dao.v1.DAOService/IsUserDAOMember", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // DAOServiceServer is the server API for DAOService service. // All implementations must embed UnimplementedDAOServiceServer // for forward compatibility type DAOServiceServer interface { DAOs(context.Context, *DAOsRequest) (*DAOsResponse, error) + IsUserDAOMember(context.Context, *IsUserDAOMemberRequest) (*IsUserDAOMemberResponse, error) mustEmbedUnimplementedDAOServiceServer() } @@ -57,6 +68,9 @@ type UnimplementedDAOServiceServer struct { func (UnimplementedDAOServiceServer) DAOs(context.Context, *DAOsRequest) (*DAOsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method DAOs not implemented") } +func (UnimplementedDAOServiceServer) IsUserDAOMember(context.Context, *IsUserDAOMemberRequest) (*IsUserDAOMemberResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method IsUserDAOMember not implemented") +} func (UnimplementedDAOServiceServer) mustEmbedUnimplementedDAOServiceServer() {} // UnsafeDAOServiceServer may be embedded to opt out of forward compatibility for this service. @@ -88,6 +102,24 @@ func _DAOService_DAOs_Handler(srv interface{}, ctx context.Context, dec func(int return interceptor(ctx, in, info, handler) } +func _DAOService_IsUserDAOMember_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(IsUserDAOMemberRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DAOServiceServer).IsUserDAOMember(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/dao.v1.DAOService/IsUserDAOMember", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DAOServiceServer).IsUserDAOMember(ctx, req.(*IsUserDAOMemberRequest)) + } + return interceptor(ctx, in, info, handler) +} + // DAOService_ServiceDesc is the grpc.ServiceDesc for DAOService service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -99,6 +131,10 @@ var DAOService_ServiceDesc = grpc.ServiceDesc{ MethodName: "DAOs", Handler: _DAOService_DAOs_Handler, }, + { + MethodName: "IsUserDAOMember", + Handler: _DAOService_IsUserDAOMember_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "dao/v1/dao.proto", diff --git a/packages/api/dao/v1/dao.ts b/packages/api/dao/v1/dao.ts index d593839371..90ef551d65 100644 --- a/packages/api/dao/v1/dao.ts +++ b/packages/api/dao/v1/dao.ts @@ -15,6 +15,15 @@ export interface DAOsResponse { daos: DAO[]; } +export interface IsUserDAOMemberRequest { + userId: string; + daoId: string; +} + +export interface IsUserDAOMemberResponse { + isMember: boolean; +} + export interface DAO { id: string; admin: string; @@ -160,6 +169,137 @@ export const DAOsResponse = { }, }; +function createBaseIsUserDAOMemberRequest(): IsUserDAOMemberRequest { + return { userId: "", daoId: "" }; +} + +export const IsUserDAOMemberRequest = { + encode(message: IsUserDAOMemberRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.userId !== "") { + writer.uint32(10).string(message.userId); + } + if (message.daoId !== "") { + writer.uint32(18).string(message.daoId); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): IsUserDAOMemberRequest { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseIsUserDAOMemberRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.userId = reader.string(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.daoId = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): IsUserDAOMemberRequest { + return { + userId: isSet(object.userId) ? globalThis.String(object.userId) : "", + daoId: isSet(object.daoId) ? globalThis.String(object.daoId) : "", + }; + }, + + toJSON(message: IsUserDAOMemberRequest): unknown { + const obj: any = {}; + if (message.userId !== "") { + obj.userId = message.userId; + } + if (message.daoId !== "") { + obj.daoId = message.daoId; + } + return obj; + }, + + create, I>>(base?: I): IsUserDAOMemberRequest { + return IsUserDAOMemberRequest.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): IsUserDAOMemberRequest { + const message = createBaseIsUserDAOMemberRequest(); + message.userId = object.userId ?? ""; + message.daoId = object.daoId ?? ""; + return message; + }, +}; + +function createBaseIsUserDAOMemberResponse(): IsUserDAOMemberResponse { + return { isMember: false }; +} + +export const IsUserDAOMemberResponse = { + encode(message: IsUserDAOMemberResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.isMember === true) { + writer.uint32(8).bool(message.isMember); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): IsUserDAOMemberResponse { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseIsUserDAOMemberResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.isMember = reader.bool(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): IsUserDAOMemberResponse { + return { isMember: isSet(object.isMember) ? globalThis.Boolean(object.isMember) : false }; + }, + + toJSON(message: IsUserDAOMemberResponse): unknown { + const obj: any = {}; + if (message.isMember === true) { + obj.isMember = message.isMember; + } + return obj; + }, + + create, I>>(base?: I): IsUserDAOMemberResponse { + return IsUserDAOMemberResponse.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): IsUserDAOMemberResponse { + const message = createBaseIsUserDAOMemberResponse(); + message.isMember = object.isMember ?? false; + return message; + }, +}; + function createBaseDAO(): DAO { return { id: "", @@ -383,6 +523,10 @@ export const DAO = { export interface DAOService { DAOs(request: DeepPartial, metadata?: grpc.Metadata): Promise; + IsUserDAOMember( + request: DeepPartial, + metadata?: grpc.Metadata, + ): Promise; } export class DAOServiceClientImpl implements DAOService { @@ -391,11 +535,19 @@ export class DAOServiceClientImpl implements DAOService { constructor(rpc: Rpc) { this.rpc = rpc; this.DAOs = this.DAOs.bind(this); + this.IsUserDAOMember = this.IsUserDAOMember.bind(this); } DAOs(request: DeepPartial, metadata?: grpc.Metadata): Promise { return this.rpc.unary(DAOServiceDAOsDesc, DAOsRequest.fromPartial(request), metadata); } + + IsUserDAOMember( + request: DeepPartial, + metadata?: grpc.Metadata, + ): Promise { + return this.rpc.unary(DAOServiceIsUserDAOMemberDesc, IsUserDAOMemberRequest.fromPartial(request), metadata); + } } export const DAOServiceDesc = { serviceName: "dao.v1.DAOService" }; @@ -423,6 +575,29 @@ export const DAOServiceDAOsDesc: UnaryMethodDefinitionish = { } as any, }; +export const DAOServiceIsUserDAOMemberDesc: UnaryMethodDefinitionish = { + methodName: "IsUserDAOMember", + service: DAOServiceDesc, + requestStream: false, + responseStream: false, + requestType: { + serializeBinary() { + return IsUserDAOMemberRequest.encode(this).finish(); + }, + } as any, + responseType: { + deserializeBinary(data: Uint8Array) { + const value = IsUserDAOMemberResponse.decode(data); + return { + ...value, + toObject() { + return value; + }, + }; + }, + } as any, +}; + interface UnaryMethodDefinitionishR extends grpc.UnaryMethodDefinition { requestStream: any; responseStream: any;