github.com/algorand/go-algorand-sdk@v1.24.0/client/v2/indexer/lookupAssetBalances.go (about) 1 package indexer 2 3 import ( 4 "context" 5 "fmt" 6 7 "github.com/algorand/go-algorand-sdk/client/v2/common" 8 "github.com/algorand/go-algorand-sdk/client/v2/common/models" 9 ) 10 11 // LookupAssetBalancesParams contains all of the query parameters for url serialization. 12 type LookupAssetBalancesParams struct { 13 14 // CurrencyGreaterThan results should have an amount greater than this value. 15 // MicroAlgos are the default currency unless an asset-id is provided, in which 16 // case the asset will be used. 17 CurrencyGreaterThan uint64 `url:"currency-greater-than,omitempty"` 18 19 // CurrencyLessThan results should have an amount less than this value. MicroAlgos 20 // are the default currency unless an asset-id is provided, in which case the asset 21 // will be used. 22 CurrencyLessThan uint64 `url:"currency-less-than,omitempty"` 23 24 // IncludeAll include all items including closed accounts, deleted applications, 25 // destroyed assets, opted-out asset holdings, and closed-out application 26 // localstates. 27 IncludeAll bool `url:"include-all,omitempty"` 28 29 // Limit maximum number of results to return. There could be additional pages even 30 // if the limit is not reached. 31 Limit uint64 `url:"limit,omitempty"` 32 33 // NextToken the next page of results. Use the next token provided by the previous 34 // results. 35 NextToken string `url:"next,omitempty"` 36 } 37 38 // LookupAssetBalances lookup the list of accounts who hold this asset 39 type LookupAssetBalances struct { 40 c *Client 41 42 assetId uint64 43 44 p LookupAssetBalancesParams 45 } 46 47 // CurrencyGreaterThan results should have an amount greater than this value. 48 // MicroAlgos are the default currency unless an asset-id is provided, in which 49 // case the asset will be used. 50 func (s *LookupAssetBalances) CurrencyGreaterThan(CurrencyGreaterThan uint64) *LookupAssetBalances { 51 s.p.CurrencyGreaterThan = CurrencyGreaterThan 52 53 return s 54 } 55 56 // CurrencyLessThan results should have an amount less than this value. MicroAlgos 57 // are the default currency unless an asset-id is provided, in which case the asset 58 // will be used. 59 func (s *LookupAssetBalances) CurrencyLessThan(CurrencyLessThan uint64) *LookupAssetBalances { 60 s.p.CurrencyLessThan = CurrencyLessThan 61 62 return s 63 } 64 65 // IncludeAll include all items including closed accounts, deleted applications, 66 // destroyed assets, opted-out asset holdings, and closed-out application 67 // localstates. 68 func (s *LookupAssetBalances) IncludeAll(IncludeAll bool) *LookupAssetBalances { 69 s.p.IncludeAll = IncludeAll 70 71 return s 72 } 73 74 // Limit maximum number of results to return. There could be additional pages even 75 // if the limit is not reached. 76 func (s *LookupAssetBalances) Limit(Limit uint64) *LookupAssetBalances { 77 s.p.Limit = Limit 78 79 return s 80 } 81 82 // NextToken the next page of results. Use the next token provided by the previous 83 // results. 84 func (s *LookupAssetBalances) NextToken(NextToken string) *LookupAssetBalances { 85 s.p.NextToken = NextToken 86 87 return s 88 } 89 90 // Do performs the HTTP request 91 func (s *LookupAssetBalances) Do(ctx context.Context, headers ...*common.Header) (response models.AssetBalancesResponse, err error) { 92 err = s.c.get(ctx, &response, fmt.Sprintf("/v2/assets/%s/balances", common.EscapeParams(s.assetId)...), s.p, headers) 93 return 94 }