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 27, 2023
1 parent ccf3352 commit a2af9e8
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions cosmosutil/auth.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package cosmosutil

import (
"context"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
)

func (c *ChainClient) Account(ctx context.Context, address string) (authtypes.AccountI, error) {

Check failure on line 8 in cosmosutil/auth.go

View workflow job for this annotation

GitHub Actions / golangci-lint (cosmosutil)

SA1019: authtypes.AccountI is deprecated: Use `AccountI` from types package instead. (staticcheck)

Check failure on line 8 in cosmosutil/auth.go

View workflow job for this annotation

GitHub Actions / golangci-lint (cosmosutil)

SA1019: authtypes.AccountI is deprecated: Use `AccountI` from types package instead. (staticcheck)
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 a2af9e8

Please sign in to comment.