Additional registry module commands #6

Merged
ashwin merged 13 commits from pm-additional-commands into main 2024-02-26 05:42:38 +00:00
3 changed files with 28 additions and 1 deletions
Showing only changes of commit 0b8904d7de - Show all commits

View File

@ -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, &registrytypes.AccountBalance{
AccountName: accountName,
Balance: accountBalance,
})
}
}
return balances
}

View File

@ -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 &registrytypes.QueryGetRegistryModuleBalanceResponse{
Balances: balances,
}, nil

View File

@ -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{