diff --git a/x/registry/keeper/keeper.go b/x/registry/keeper/keeper.go index f93e1436..fbe65b01 100644 --- a/x/registry/keeper/keeper.go +++ b/x/registry/keeper/keeper.go @@ -326,5 +326,24 @@ func (k Keeper) processAttributeMap(ctx sdk.Context, n ipld.Node, id string, pre // GetModuleBalances gets the registry module account(s) balances. func (k Keeper) GetModuleBalances(ctx sdk.Context) []*registrytypes.AccountBalance { - panic("unimplemented") + var balances []*registrytypes.AccountBalance + accountNames := []string{ + registrytypes.RecordRentModuleAccountName, + registrytypes.AuthorityRentModuleAccountName, + } + + for _, accountName := range accountNames { + moduleAddress := k.accountKeeper.GetModuleAddress(accountName) + + moduleAccount := k.accountKeeper.GetAccount(ctx, moduleAddress) + if moduleAccount != nil { + accountBalance := k.bankKeeper.GetAllBalances(ctx, moduleAddress) + balances = append(balances, ®istrytypes.AccountBalance{ + AccountName: accountName, + Balance: accountBalance, + }) + } + } + + return balances } diff --git a/x/registry/keeper/query_server.go b/x/registry/keeper/query_server.go index 3a3b0e20..f125e196 100644 --- a/x/registry/keeper/query_server.go +++ b/x/registry/keeper/query_server.go @@ -90,7 +90,9 @@ func (qs queryServer) GetRegistryModuleBalance(c context.Context, _ *registrytypes.QueryGetRegistryModuleBalanceRequest, ) (*registrytypes.QueryGetRegistryModuleBalanceResponse, error) { ctx := sdk.UnwrapSDKContext(c) + balances := qs.k.GetModuleBalances(ctx) + return ®istrytypes.QueryGetRegistryModuleBalanceResponse{ Balances: balances, }, nil diff --git a/x/registry/module/autocli.go b/x/registry/module/autocli.go index 343d1f5d..72f7a66e 100644 --- a/x/registry/module/autocli.go +++ b/x/registry/module/autocli.go @@ -51,6 +51,12 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { {ProtoField: "name"}, }, }, + { + RpcMethod: "GetRegistryModuleBalance", + Use: "balance", + Short: "Get registry module account balances", + PositionalArgs: []*autocliv1.PositionalArgDescriptor{}, + }, }, }, Tx: &autocliv1.ServiceCommandDescriptor{