Add a command to get registry module account balances
This commit is contained in:
parent
764fb1f04a
commit
0b8904d7de
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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{
|
||||
|
Loading…
Reference in New Issue
Block a user