Skip to content

Commit

Permalink
Merge pull request #3 from mateuszm-arianelabs/CCS-37-non-zero-token-…
Browse files Browse the repository at this point in the history
…holders

FIX: feat: add accepting TokenId as input, filter out zero balances (CCS-37)
  • Loading branch information
mateuszm-arianelabs authored Jan 30, 2025
2 parents 47a5474 + 061a8e0 commit ca636f7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/agent/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ export default class HederaAgentKit {
}

async getTokenHolders(
tokenId: string,
tokenId: string | TokenId,
networkType: HederaNetworkType,
threshold?: number,
): Promise<Array<TokenBalance>> {
return get_token_holders(tokenId, networkType, threshold);
return get_token_holders(tokenId.toString(), networkType, threshold);
}

async associateToken(
Expand Down
5 changes: 2 additions & 3 deletions src/tools/hts/queries/holders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ export const get_token_holders = async (
let baseUrl = createBaseMirrorNodeApiUrl(networkType)

// 100 results at once, endpoint data updated each 15min
let url: string | null = threshold
let url: string | null = threshold !== undefined
? `${baseUrl}/api/v1/tokens/${tokenId}/balances?limit=100&account.balance=gte%3A${threshold}`
: `${baseUrl}/api/v1/tokens/${tokenId}/balances?limit=100`;

: `${baseUrl}/api/v1/tokens/${tokenId}/balances?limit=100&account.balance=gt%3A0`; // if no threshold set filter out wallets with 0 balances

const array = new Array<TokenBalance>();

Expand Down

0 comments on commit ca636f7

Please sign in to comment.