-
Notifications
You must be signed in to change notification settings - Fork 2
/
grpc_query.go
28 lines (22 loc) · 994 Bytes
/
grpc_query.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
package keeper
import (
"context"
sdk "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/types"
icatypes "github.com/fibonacci-chain/fbc/libs/ibc-go/modules/apps/27-interchain-accounts/types"
"github.com/fibonacci-chain/fbc/x/icamauth/types"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
// InterchainAccount implements the Query/InterchainAccount gRPC method
func (k Keeper) InterchainAccount(goCtx context.Context, req *types.QueryInterchainAccountRequest) (*types.QueryInterchainAccountResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)
portID, err := icatypes.NewControllerPortID(req.Owner)
if err != nil {
return nil, status.Errorf(codes.InvalidArgument, "could not find account: %s", err)
}
addr, found := k.icaControllerKeeper.GetInterchainAccountAddress(ctx, req.ConnectionId, portID)
if !found {
return nil, status.Errorf(codes.NotFound, "no account found for portID %s", portID)
}
return types.NewQueryInterchainAccountResponse(addr), nil
}