Skip to content

Commit

Permalink
feat: add ability to check if a QGB attestation is in store
Browse files Browse the repository at this point in the history
  • Loading branch information
rach-id committed Oct 5, 2023
1 parent d4737b4 commit dcb4c0c
Show file tree
Hide file tree
Showing 4 changed files with 540 additions and 56 deletions.
12 changes: 12 additions & 0 deletions proto/celestia/qgb/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ service Query {
rpc EVMAddress(QueryEVMAddressRequest) returns (QueryEVMAddressResponse) {
option (google.api.http).get = "/qgb/v1/evm_address";
}

// HasAttestation returns whether the attestation is in store or not.
rpc HasAttestation(QueryHasAttestationRequest)
returns (QueryHasAttestationResponse) {
option (google.api.http).get = "/qgb/v1/has_attestation/{nonce}";
}
}

// QueryParamsRequest
Expand Down Expand Up @@ -128,3 +134,9 @@ message QueryEVMAddressRequest { string validator_address = 1; }

// QueryEVMAddressResponse
message QueryEVMAddressResponse { string evm_address = 1; }

// QueryHasAttestationRequest
message QueryHasAttestationRequest { uint64 nonce = 1; }

// QueryHasAttestationResponse
message QueryHasAttestationResponse { bool exists = 1; }
13 changes: 13 additions & 0 deletions x/qgb/keeper/query_attestation.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,16 @@ func (k Keeper) LatestAttestationNonce(
Nonce: k.GetLatestAttestationNonce(sdk.UnwrapSDKContext(ctx)),
}, nil
}

func (k Keeper) HasAttestation(
ctx context.Context,
request *types.QueryHasAttestationRequest,
) (*types.QueryHasAttestationResponse, error) {
_, exists, err := k.GetAttestationByNonce(sdk.UnwrapSDKContext(ctx), request.Nonce)
if err != nil {
return nil, err
}
return &types.QueryHasAttestationResponse{
Exists: exists,
}, nil
}
Loading

0 comments on commit dcb4c0c

Please sign in to comment.