Add queries to get participant by laconic or nitro address #44

Merged
nabarun merged 4 commits from iv-participants-by-address into main 2024-07-29 10:28:31 +00:00
6 changed files with 289 additions and 17 deletions
Showing only changes of commit 5e2920c0c2 - Show all commits

View File

@ -30,7 +30,7 @@ const (
type QueryClient interface { type QueryClient interface {
// Participants queries Participants list // Participants queries Participants list
Participants(ctx context.Context, in *QueryParticipantsRequest, opts ...grpc.CallOption) (*QueryParticipantsResponse, error) Participants(ctx context.Context, in *QueryParticipantsRequest, opts ...grpc.CallOption) (*QueryParticipantsResponse, error)
// Participants queries Participants list by laconic address // Participants queries Participants list by cosmos address
GetParticipantByAddress(ctx context.Context, in *QueryGetParticipantByAddressRequest, opts ...grpc.CallOption) (*QueryGetParticipantByAddressResponse, error) GetParticipantByAddress(ctx context.Context, in *QueryGetParticipantByAddressRequest, opts ...grpc.CallOption) (*QueryGetParticipantByAddressResponse, error)
// Participants queries Participants list by nitro address // Participants queries Participants list by nitro address
GetParticipantByNitroAddress(ctx context.Context, in *QueryGetParticipantByNitroAddressRequest, opts ...grpc.CallOption) (*QueryGetParticipantByNitroAddressResponse, error) GetParticipantByNitroAddress(ctx context.Context, in *QueryGetParticipantByNitroAddressRequest, opts ...grpc.CallOption) (*QueryGetParticipantByNitroAddressResponse, error)
@ -77,7 +77,7 @@ func (c *queryClient) GetParticipantByNitroAddress(ctx context.Context, in *Quer
type QueryServer interface { type QueryServer interface {
// Participants queries Participants list // Participants queries Participants list
Participants(context.Context, *QueryParticipantsRequest) (*QueryParticipantsResponse, error) Participants(context.Context, *QueryParticipantsRequest) (*QueryParticipantsResponse, error)
// Participants queries Participants list by laconic address // Participants queries Participants list by cosmos address
GetParticipantByAddress(context.Context, *QueryGetParticipantByAddressRequest) (*QueryGetParticipantByAddressResponse, error) GetParticipantByAddress(context.Context, *QueryGetParticipantByAddressRequest) (*QueryGetParticipantByAddressResponse, error)
// Participants queries Participants list by nitro address // Participants queries Participants list by nitro address
GetParticipantByNitroAddress(context.Context, *QueryGetParticipantByNitroAddressRequest) (*QueryGetParticipantByNitroAddressResponse, error) GetParticipantByNitroAddress(context.Context, *QueryGetParticipantByNitroAddressRequest) (*QueryGetParticipantByNitroAddressResponse, error)

View File

@ -265,4 +265,6 @@ type Query {
# Query participants. # Query participants.
getParticipants: [Participant]! getParticipants: [Participant]!
getParticipantByAddress(cosmosAddress: String!): Participant!
getParticipantByNitroAddress(nitroAddress: String!): Participant!
} }

View File

@ -170,6 +170,8 @@ type ComplexityRoot struct {
GetAccounts func(childComplexity int, addresses []string) int GetAccounts func(childComplexity int, addresses []string) int
GetAuctionsByIds func(childComplexity int, ids []string) int GetAuctionsByIds func(childComplexity int, ids []string) int
GetBondsByIds func(childComplexity int, ids []string) int GetBondsByIds func(childComplexity int, ids []string) int
GetParticipantByAddress func(childComplexity int, cosmosAddress string) int
GetParticipantByNitroAddress func(childComplexity int, nitroAddress string) int
GetParticipants func(childComplexity int) int GetParticipants func(childComplexity int) int
GetRecordsByIds func(childComplexity int, ids []string) int GetRecordsByIds func(childComplexity int, ids []string) int
GetStatus func(childComplexity int) int GetStatus func(childComplexity int) int
@ -234,6 +236,8 @@ type QueryResolver interface {
ResolveNames(ctx context.Context, names []string) ([]*Record, error) ResolveNames(ctx context.Context, names []string) ([]*Record, error)
GetAuctionsByIds(ctx context.Context, ids []string) ([]*Auction, error) GetAuctionsByIds(ctx context.Context, ids []string) ([]*Auction, error)
GetParticipants(ctx context.Context) ([]*Participant, error) GetParticipants(ctx context.Context) ([]*Participant, error)
GetParticipantByAddress(ctx context.Context, cosmosAddress string) (*Participant, error)
GetParticipantByNitroAddress(ctx context.Context, nitroAddress string) (*Participant, error)
} }
type executableSchema struct { type executableSchema struct {
@ -728,6 +732,30 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.Query.GetBondsByIds(childComplexity, args["ids"].([]string)), true return e.complexity.Query.GetBondsByIds(childComplexity, args["ids"].([]string)), true
case "Query.getParticipantByAddress":
if e.complexity.Query.GetParticipantByAddress == nil {
break
}
args, err := ec.field_Query_getParticipantByAddress_args(context.TODO(), rawArgs)
if err != nil {
return 0, false
}
return e.complexity.Query.GetParticipantByAddress(childComplexity, args["cosmosAddress"].(string)), true
case "Query.getParticipantByNitroAddress":
if e.complexity.Query.GetParticipantByNitroAddress == nil {
break
}
args, err := ec.field_Query_getParticipantByNitroAddress_args(context.TODO(), rawArgs)
if err != nil {
return 0, false
}
return e.complexity.Query.GetParticipantByNitroAddress(childComplexity, args["nitroAddress"].(string)), true
case "Query.getParticipants": case "Query.getParticipants":
if e.complexity.Query.GetParticipants == nil { if e.complexity.Query.GetParticipants == nil {
break break
@ -1128,6 +1156,36 @@ func (ec *executionContext) field_Query_getBondsByIds_args(ctx context.Context,
return args, nil return args, nil
} }
func (ec *executionContext) field_Query_getParticipantByAddress_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
var err error
args := map[string]interface{}{}
var arg0 string
if tmp, ok := rawArgs["cosmosAddress"]; ok {
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cosmosAddress"))
arg0, err = ec.unmarshalNString2string(ctx, tmp)
if err != nil {
return nil, err
}
}
args["cosmosAddress"] = arg0
return args, nil
}
func (ec *executionContext) field_Query_getParticipantByNitroAddress_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
var err error
args := map[string]interface{}{}
var arg0 string
if tmp, ok := rawArgs["nitroAddress"]; ok {
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nitroAddress"))
arg0, err = ec.unmarshalNString2string(ctx, tmp)
if err != nil {
return nil, err
}
}
args["nitroAddress"] = arg0
return args, nil
}
func (ec *executionContext) field_Query_getRecordsByIds_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { func (ec *executionContext) field_Query_getRecordsByIds_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
var err error var err error
args := map[string]interface{}{} args := map[string]interface{}{}
@ -4951,6 +5009,136 @@ func (ec *executionContext) fieldContext_Query_getParticipants(ctx context.Conte
return fc, nil return fc, nil
} }
func (ec *executionContext) _Query_getParticipantByAddress(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_Query_getParticipantByAddress(ctx, field)
if err != nil {
return graphql.Null
}
ctx = graphql.WithFieldContext(ctx, fc)
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
}()
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return ec.resolvers.Query().GetParticipantByAddress(rctx, fc.Args["cosmosAddress"].(string))
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
if !graphql.HasFieldError(ctx, fc) {
ec.Errorf(ctx, "must not be null")
}
return graphql.Null
}
res := resTmp.(*Participant)
fc.Result = res
return ec.marshalNParticipant2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐParticipant(ctx, field.Selections, res)
}
func (ec *executionContext) fieldContext_Query_getParticipantByAddress(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "Query",
Field: field,
IsMethod: true,
IsResolver: true,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
switch field.Name {
case "cosmosAddress":
return ec.fieldContext_Participant_cosmosAddress(ctx, field)
case "nitroAddress":
return ec.fieldContext_Participant_nitroAddress(ctx, field)
case "role":
return ec.fieldContext_Participant_role(ctx, field)
case "kycId":
return ec.fieldContext_Participant_kycId(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type Participant", field.Name)
},
}
defer func() {
if r := recover(); r != nil {
err = ec.Recover(ctx, r)
ec.Error(ctx, err)
}
}()
ctx = graphql.WithFieldContext(ctx, fc)
if fc.Args, err = ec.field_Query_getParticipantByAddress_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return
}
return fc, nil
}
func (ec *executionContext) _Query_getParticipantByNitroAddress(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_Query_getParticipantByNitroAddress(ctx, field)
if err != nil {
return graphql.Null
}
ctx = graphql.WithFieldContext(ctx, fc)
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
}()
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return ec.resolvers.Query().GetParticipantByNitroAddress(rctx, fc.Args["nitroAddress"].(string))
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
if !graphql.HasFieldError(ctx, fc) {
ec.Errorf(ctx, "must not be null")
}
return graphql.Null
}
res := resTmp.(*Participant)
fc.Result = res
return ec.marshalNParticipant2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐParticipant(ctx, field.Selections, res)
}
func (ec *executionContext) fieldContext_Query_getParticipantByNitroAddress(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "Query",
Field: field,
IsMethod: true,
IsResolver: true,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
switch field.Name {
case "cosmosAddress":
return ec.fieldContext_Participant_cosmosAddress(ctx, field)
case "nitroAddress":
return ec.fieldContext_Participant_nitroAddress(ctx, field)
case "role":
return ec.fieldContext_Participant_role(ctx, field)
case "kycId":
return ec.fieldContext_Participant_kycId(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type Participant", field.Name)
},
}
defer func() {
if r := recover(); r != nil {
err = ec.Recover(ctx, r)
ec.Error(ctx, err)
}
}()
ctx = graphql.WithFieldContext(ctx, fc)
if fc.Args, err = ec.field_Query_getParticipantByNitroAddress_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return
}
return fc, nil
}
func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_Query___type(ctx, field) fc, err := ec.fieldContext_Query___type(ctx, field)
if err != nil { if err != nil {
@ -9247,6 +9435,52 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
} }
out.Concurrently(i, func() graphql.Marshaler {
return rrm(innerCtx)
})
case "getParticipantByAddress":
field := field
innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
}
}()
res = ec._Query_getParticipantByAddress(ctx, field)
if res == graphql.Null {
atomic.AddUint32(&invalids, 1)
}
return res
}
rrm := func(ctx context.Context) graphql.Marshaler {
return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
}
out.Concurrently(i, func() graphql.Marshaler {
return rrm(innerCtx)
})
case "getParticipantByNitroAddress":
field := field
innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
}
}()
res = ec._Query_getParticipantByNitroAddress(ctx, field)
if res == graphql.Null {
atomic.AddUint32(&invalids, 1)
}
return res
}
rrm := func(ctx context.Context) graphql.Marshaler {
return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
}
out.Concurrently(i, func() graphql.Marshaler { out.Concurrently(i, func() graphql.Marshaler {
return rrm(innerCtx) return rrm(innerCtx)
}) })
@ -10073,6 +10307,10 @@ func (ec *executionContext) marshalNNodeInfo2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlac
return ec._NodeInfo(ctx, sel, v) return ec._NodeInfo(ctx, sel, v)
} }
func (ec *executionContext) marshalNParticipant2gitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐParticipant(ctx context.Context, sel ast.SelectionSet, v Participant) graphql.Marshaler {
return ec._Participant(ctx, sel, &v)
}
func (ec *executionContext) marshalNParticipant2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐParticipant(ctx context.Context, sel ast.SelectionSet, v []*Participant) graphql.Marshaler { func (ec *executionContext) marshalNParticipant2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐParticipant(ctx context.Context, sel ast.SelectionSet, v []*Participant) graphql.Marshaler {
ret := make(graphql.Array, len(v)) ret := make(graphql.Array, len(v))
var wg sync.WaitGroup var wg sync.WaitGroup
@ -10111,6 +10349,16 @@ func (ec *executionContext) marshalNParticipant2ᚕᚖgitᚗvdbᚗtoᚋcercᚑio
return ret return ret
} }
func (ec *executionContext) marshalNParticipant2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐParticipant(ctx context.Context, sel ast.SelectionSet, v *Participant) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
ec.Errorf(ctx, "the requested element is null which the schema does not allow")
}
return graphql.Null
}
return ec._Participant(ctx, sel, v)
}
func (ec *executionContext) marshalNRecord2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐRecord(ctx context.Context, sel ast.SelectionSet, v []*Record) graphql.Marshaler { func (ec *executionContext) marshalNRecord2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐRecord(ctx context.Context, sel ast.SelectionSet, v []*Record) graphql.Marshaler {
ret := make(graphql.Array, len(v)) ret := make(graphql.Array, len(v))
var wg sync.WaitGroup var wg sync.WaitGroup

View File

@ -380,3 +380,25 @@ func (q queryResolver) GetParticipants(ctx context.Context) ([]*Participant, err
return participants, nil return participants, nil
} }
func (q queryResolver) GetParticipantByAddress(ctx context.Context, cosmosAddress string) (*Participant, error) {
onboardingQueryClient := onboardingTypes.NewQueryClient(q.ctx)
participantResp, err := onboardingQueryClient.GetParticipantByAddress(ctx, &onboardingTypes.QueryGetParticipantByAddressRequest{CosmosAddress: cosmosAddress})
if err != nil {
return nil, err
}
p := participantResp.Participant
participant := &Participant{
CosmosAddress: p.CosmosAddress,
NitroAddress: p.NitroAddress,
Role: p.Role,
KycID: p.KycId,
}
return participant, nil
}
func (q queryResolver) GetParticipantByNitroAddress(ctx context.Context, nitroAddress string) (*Participant, error) {
return nil, nil
}

View File

@ -17,7 +17,7 @@ service Query {
option (google.api.http).get = "/cerc/onboarding/v1/participants"; option (google.api.http).get = "/cerc/onboarding/v1/participants";
} }
// Participants queries Participants list by laconic address // Participants queries Participants list by cosmos address
rpc GetParticipantByAddress(QueryGetParticipantByAddressRequest) rpc GetParticipantByAddress(QueryGetParticipantByAddressRequest)
returns (QueryGetParticipantByAddressResponse) { returns (QueryGetParticipantByAddressResponse) {
option (google.api.http).get = "/cerc/onboarding/v1/participants/{cosmos_address}"; option (google.api.http).get = "/cerc/onboarding/v1/participants/{cosmos_address}";

View File

@ -383,7 +383,7 @@ const _ = grpc.SupportPackageIsVersion4
type QueryClient interface { type QueryClient interface {
// Participants queries Participants list // Participants queries Participants list
Participants(ctx context.Context, in *QueryParticipantsRequest, opts ...grpc.CallOption) (*QueryParticipantsResponse, error) Participants(ctx context.Context, in *QueryParticipantsRequest, opts ...grpc.CallOption) (*QueryParticipantsResponse, error)
// Participants queries Participants list by laconic address // Participants queries Participants list by cosmos address
GetParticipantByAddress(ctx context.Context, in *QueryGetParticipantByAddressRequest, opts ...grpc.CallOption) (*QueryGetParticipantByAddressResponse, error) GetParticipantByAddress(ctx context.Context, in *QueryGetParticipantByAddressRequest, opts ...grpc.CallOption) (*QueryGetParticipantByAddressResponse, error)
// Participants queries Participants list by nitro address // Participants queries Participants list by nitro address
GetParticipantByNitroAddress(ctx context.Context, in *QueryGetParticipantByNitroAddressRequest, opts ...grpc.CallOption) (*QueryGetParticipantByNitroAddressResponse, error) GetParticipantByNitroAddress(ctx context.Context, in *QueryGetParticipantByNitroAddressRequest, opts ...grpc.CallOption) (*QueryGetParticipantByNitroAddressResponse, error)
@ -428,7 +428,7 @@ func (c *queryClient) GetParticipantByNitroAddress(ctx context.Context, in *Quer
type QueryServer interface { type QueryServer interface {
// Participants queries Participants list // Participants queries Participants list
Participants(context.Context, *QueryParticipantsRequest) (*QueryParticipantsResponse, error) Participants(context.Context, *QueryParticipantsRequest) (*QueryParticipantsResponse, error)
// Participants queries Participants list by laconic address // Participants queries Participants list by cosmos address
GetParticipantByAddress(context.Context, *QueryGetParticipantByAddressRequest) (*QueryGetParticipantByAddressResponse, error) GetParticipantByAddress(context.Context, *QueryGetParticipantByAddressRequest) (*QueryGetParticipantByAddressResponse, error)
// Participants queries Participants list by nitro address // Participants queries Participants list by nitro address
GetParticipantByNitroAddress(context.Context, *QueryGetParticipantByNitroAddressRequest) (*QueryGetParticipantByNitroAddressResponse, error) GetParticipantByNitroAddress(context.Context, *QueryGetParticipantByNitroAddressRequest) (*QueryGetParticipantByNitroAddressResponse, error)