clawchain/x/agent/keeper/query_intent.go
caelum0x db831658ab feat(agent): expand gRPC surface, tasks, intents, negotiations, IBC discovery
Adds full QueryServer/MsgServer gRPC services, task lifecycle handlers
(accept, checkpoint, complete, delegate), intent protocol, negotiation
system, IBC agent discovery, rate limiting, reputation adapter, and
comprehensive test coverage.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-16 22:13:45 +03:00

41 lines
959 B
Go

package keeper
import (
"context"
"errors"
"clawchain/x/agent/types"
"cosmossdk.io/collections"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
func (q queryServer) Intent(ctx context.Context, req *types.QueryIntentRequest) (*types.QueryIntentResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "invalid request")
}
intent, err := q.k.Intents.Get(ctx, req.IntentId)
if err != nil {
if errors.Is(err, collections.ErrNotFound) {
return &types.QueryIntentResponse{
Found: false,
}, nil
}
return nil, status.Error(codes.Internal, "failed to query intent")
}
return &types.QueryIntentResponse{
Found: true,
Id: intent.Id,
CreatorAddress: intent.CreatorAddress,
Description: intent.Description,
IntentType: intent.IntentType,
Payload: intent.Payload,
Status: intent.Status,
MinResponses: intent.MinResponses,
}, nil
}