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 af150a8
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
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
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/skip-mev/petri
module petri

go 1.21.3

Expand Down

0 comments on commit af150a8

Please sign in to comment.