Skip to content
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

feat: upgrade api layer #1910

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

feat: upgrade api layer #1910

wants to merge 1 commit into from

Conversation

He1DAr
Copy link
Collaborator

@He1DAr He1DAr commented Nov 15, 2024

What type of PR is this? (check all applicable)

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

@stacks/blockchain-api-client no longer exports API call wrappers, we need to upgrade to latest stacks API JS client replace all API calls across Explorer.
https://github.com/hirosystems/stacks-blockchain-api/blob/HEAD/client/MIGRATION.md

Issue ticket number and link

closes #1896

Checklist:

  • I have performed a self-review of my code.
  • I have tested the change on desktop and mobile.
  • I have added thorough tests where applicable.
  • I've added analytics and error logging where applicable.

Screenshots (if appropriate):

N/A

Copy link

vercel bot commented Nov 15, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
explorer-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 27, 2024 3:20pm
hiro-explorer ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 27, 2024 3:20pm

apiUrl: Endpoint,
apiParams?: ApiParams<Endpoint>
): Promise<OperationResponse[Endpoint]> {
const { error, data } = await apiClient.GET(apiUrl, apiParams as any);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This function acts as a wrapper around the API client, it enforce type safety for the endpoint, parameters, and response, as well as providing centralized error handling. I had to use any when passing apiParams because the types provided by client library are not fully generic and rely on rigid definitions that cannot be dynamically inferred. Open to suggestions here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this works. We'll do with the missing types for now, unless it hinders us in some signifcant way. Would be interesting to see if we could have done this with middleware, but I think that is a separate investigation. Thanks for making these changes!

Copy link
Collaborator

@BLuEScioN BLuEScioN left a comment

Choose a reason for hiding this comment

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

One small thing about removing useBlockByHeight hook or w/e it was. Other than that LGTM

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

Successfully merging this pull request may close these issues.

Upgrade @stacks/blockchain-api-client
2 participants