-
Notifications
You must be signed in to change notification settings - Fork 272
/
query_general.go
52 lines (46 loc) · 1.65 KB
/
query_general.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package keeper
import (
"context"
"github.com/celestiaorg/celestia-app/v2/x/blobstream/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)
// LatestUnbondingHeight queries the latest unbonding height.
func (k Keeper) LatestUnbondingHeight(
c context.Context,
_ *types.QueryLatestUnbondingHeightRequest,
) (*types.QueryLatestUnbondingHeightResponse, error) {
return &types.QueryLatestUnbondingHeightResponse{
Height: k.GetLatestUnBondingBlockHeight(sdk.UnwrapSDKContext(c)),
}, nil
}
// EarliestAttestationNonce queries the earliest attestation nonce.
func (k Keeper) EarliestAttestationNonce(
c context.Context,
_ *types.QueryEarliestAttestationNonceRequest,
) (*types.QueryEarliestAttestationNonceResponse, error) {
return &types.QueryEarliestAttestationNonceResponse{
Nonce: k.GetEarliestAvailableAttestationNonce(sdk.UnwrapSDKContext(c)),
}, nil
}
func (k Keeper) Params(c context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, error) {
params := k.GetParams(sdk.UnwrapSDKContext(c))
return &types.QueryParamsResponse{
Params: params,
}, nil
}
// EVMAddress tries to find the associated EVM address for a given validator address. If
// none is found, an empty address is returned
func (k Keeper) EVMAddress(goCtx context.Context, req *types.QueryEVMAddressRequest) (*types.QueryEVMAddressResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)
valAddr, err := sdk.ValAddressFromBech32(req.ValidatorAddress)
if err != nil {
return nil, err
}
evmAddr, exists := k.GetEVMAddress(ctx, valAddr)
if !exists {
return &types.QueryEVMAddressResponse{}, nil
}
return &types.QueryEVMAddressResponse{
EvmAddress: evmAddr.Hex(),
}, nil
}