Skip to content

Add Bank.getAllHolders(denom) grpc/api #9393

Closed
@ghost

Description

Summary

It would be nice to retrieve a list of holders for a particular denom.

Problem Definition

We are currently doing this very specifically for our marker module, but it would be very helpful to have this available on a regular denom as well. Pass in a denom name, and spit out a paginated list of account holders with balances.

Proposal

Following this example:

func (k Keeper) GetAllMarkerHolders(ctx sdk.Context, denom string) []types.Balance {	
	var results []types.Balance	
        k.bankKeeper.IterateAllBalances(ctx, func(addr sdk.AccAddress, coin sdk.Coin) (stop bool) {
		if coin.Denom == denom && !coin.Amount.IsZero() {
			results = append(results,
				types.Balance{
					Address: addr.String(),
					Coins:   sdk.NewCoins(coin),
				})
		}
		return false // do not stop iterating
	})
	return results
}

add somethings similar within the bank module.


For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions