diff --git a/cosmosutil/auth.go b/cosmosutil/auth.go new file mode 100644 index 0000000..f6a83bb --- /dev/null +++ b/cosmosutil/auth.go @@ -0,0 +1,33 @@ +package cosmosutil + +import ( + "context" + sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" +) + +func (c *ChainClient) Account(ctx context.Context, address string) (sdk.AccountI, error) { + authClient, err := c.getAuthClient() + + if err != nil { + return nil, err + } + + res, err := authClient.Account(ctx, &authtypes.QueryAccountRequest{ + Address: address, + }) + + if err != nil { + return nil, err + } + + var acc authtypes.BaseAccount + + err = c.EncodingConfig.InterfaceRegistry.UnpackAny(res.Account, &acc) + + if err != nil { + return nil, err + } + + return &acc, nil +}