-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cosmosutil): add querying methods for the Auth module
- Loading branch information
1 parent
cf7e20e
commit af150a8
Showing
2 changed files
with
34 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
|