Skip to content

APISD-1390 Update counterparty type #126

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

adamtmh
Copy link
Collaborator

@adamtmh adamtmh commented Jul 10, 2025

Description

A client noticed that the return type for the getGlobalCounterparties method is incorrect as it's still on the v2. This changes it so that it has the v3 counterparty return type. I guess this might not be correct for those clients still using the v2 enpdoint, but figure the latest version of the moneyhub-api-client should use the latest counterparties version. Would welcome opinions on this though.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Mismatched API Version and Return Type

The getGlobalCounterparties function's return type is hardcoded to GlobalCounterpartyV3[], but its GlobalCounterpartiesSearchParams still permits counterpartiesVersion: "v2". This creates a type-runtime mismatch: requesting v2 data returns a v2 structure at runtime, while TypeScript expects v3, leading to potential runtime errors when accessing incompatible fields (e.g., label vs name).

src/requests/types/unauthenticated.ts#L5-L9

export interface UnauthenticatedRequests {
getGlobalCounterparties: (
params?: GlobalCounterpartiesSearchParams,
options?: ExtraOptions
) => Promise<ApiResponse<GlobalCounterpartyV3[]>>

Fix in CursorFix in Web


Was this report helpful? Give feedback by reacting with 👍 or 👎

@ozamarripamoneyhub
Copy link
Contributor

We could:

  • Add as a type that it can be either of them (V2 or V3)
  • Just set the default as V3
  • Add auxiliary function for V2 'getGlobalCounterpartiesV2'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants