Skip to content

Commit

Permalink
feat(cosmosutil): add querying methods for the Auth module
Browse files Browse the repository at this point in the history
  • Loading branch information
Zygimantass committed Dec 29, 2023
1 parent cf7e20e commit 2948a71
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions cosmosutil/auth.go
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit 2948a71

Please sign in to comment.