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.
|
// GetModuleBalances gets the registry module account(s) balances.
|
||||||
func (k Keeper) GetModuleBalances(ctx sdk.Context) []*registrytypes.AccountBalance {
|
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.QueryGetRegistryModuleBalanceRequest,
|
||||||
) (*registrytypes.QueryGetRegistryModuleBalanceResponse, error) {
|
) (*registrytypes.QueryGetRegistryModuleBalanceResponse, error) {
|
||||||
ctx := sdk.UnwrapSDKContext(c)
|
ctx := sdk.UnwrapSDKContext(c)
|
||||||
|
|
||||||
balances := qs.k.GetModuleBalances(ctx)
|
balances := qs.k.GetModuleBalances(ctx)
|
||||||
|
|
||||||
return ®istrytypes.QueryGetRegistryModuleBalanceResponse{
|
return ®istrytypes.QueryGetRegistryModuleBalanceResponse{
|
||||||
Balances: balances,
|
Balances: balances,
|
||||||
}, nil
|
}, nil
|
||||||
|
@ -51,6 +51,12 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions {
|
|||||||
{ProtoField: "name"},
|
{ProtoField: "name"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
RpcMethod: "GetRegistryModuleBalance",
|
||||||
|
Use: "balance",
|
||||||
|
Short: "Get registry module account balances",
|
||||||
|
PositionalArgs: []*autocliv1.PositionalArgDescriptor{},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Tx: &autocliv1.ServiceCommandDescriptor{
|
Tx: &autocliv1.ServiceCommandDescriptor{
|
||||||
|
Loading…
Reference in New Issue
Block a user