Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions packages/sdk/src/DistributorClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,12 @@ export class DistributorClient {

/**
* Get stats for a specific user.
* @param user The address of the user, or an object containing the user address.
* @param user The address of the user.
* @throws {FundableStellarError} If fetch fails with a human-readable error message
*/
public async getUserStats(
user: AddressParam
): Promise<AssembledTransaction<UserStats | undefined>> {
const actualUser = typeof user === "object" ? user.user : user;

return executeWithErrorHandling(
() =>
this.client.get_user_stats({ user: addressToString(user) }) as Promise<
Expand All @@ -119,14 +117,12 @@ export class DistributorClient {

/**
* Get stats for a specific token.
* @param token The address of the token (contract ID), or an object containing the token address.
* @param token The address of the token contract.
* @throws {FundableStellarError} If fetch fails with a human-readable error message
*/
public async getTokenStats(
token: AddressParam
): Promise<AssembledTransaction<TokenStats | undefined>> {
const actualToken = typeof token === "object" ? token.token : token;

return executeWithErrorHandling(
() =>
this.client.get_token_stats({ token: addressToString(token) }) as Promise<
Expand Down
22 changes: 1 addition & 21 deletions packages/sdk/src/__tests__/overloads.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,16 +207,6 @@ describe("Client Method Overloads", () => {
expect(result).toBe(mockResult);
});

it("getUserStats accepts object parameter", async () => {
const mockResult = { signAndSend: vi.fn() };
mockDistributorClient.get_user_stats.mockResolvedValue(mockResult);

const result = await distributorClient.getUserStats({ user });

expect(mockDistributorClient.get_user_stats).toHaveBeenCalledWith({ user });
expect(result).toBe(mockResult);
});

it("getTokenStats accepts individual parameters", async () => {
const mockResult = { signAndSend: vi.fn() };
mockDistributorClient.get_token_stats.mockResolvedValue(mockResult);
Expand All @@ -226,16 +216,6 @@ describe("Client Method Overloads", () => {
expect(mockDistributorClient.get_token_stats).toHaveBeenCalledWith({ token });
expect(result).toBe(mockResult);
});

it("getTokenStats accepts object parameter", async () => {
const mockResult = { signAndSend: vi.fn() };
mockDistributorClient.get_token_stats.mockResolvedValue(mockResult);

const result = await distributorClient.getTokenStats({ token });

expect(mockDistributorClient.get_token_stats).toHaveBeenCalledWith({ token });
expect(result).toBe(mockResult);
});
});

describe("DistributorClient - Two Parameter Methods", () => {
Expand Down Expand Up @@ -296,4 +276,4 @@ describe("Client Method Overloads", () => {
expect(result).toBe(mockResult);
});
});
});
});