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

Bns v2 feat #2080

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from
Open

Bns v2 feat #2080

wants to merge 10 commits into from

Conversation

Patotking12
Copy link

BNS V2 support

As a Stacks developer, I want to be able to interact with the BNS V2 contract through the Stacks API, so that I can build applications that leverage the latest features of the BNS protocol

  1. Motivation for change
    The BNS protocol has been upgraded to version 2, introducing new features and improvements. To ensure that the Stacks API remains up-to-date and fully functional with the latest BNS contract, we need to implement support for BNS V2.
  2. What was changed
  • Added new endpoints for BNS V2 operations:
    • /v3/prices:
      • GET /v3/prices/namespaces/:tld for namespace pricing
      • GET /v3/prices/names/:name for name pricing
    • /v2/reads:
      • GET /v2/reads/renewal-height/:id for fetching renewal height
      • GET /v2/reads/can-resolve-name/:namespace/:name for name resolution check
      • GET /v2/reads/owner/:id for fetching token owner
      • GET /v2/reads/can-namespace-be-registered/:namespace for fetching if a namespace is available
      • GET /v2/reads/get-bns-info/:namespace/:name for fetching the properties of a name
      • GET /v2/reads/get-id-from-bns/:namespace/:name for fetching the uint of a name
      • GET /v2/reads/get-bns-from-id/:namespace/:name for fetching the name and namespace of a uint
      • GET /v2/reads/primary-name/:owner for fetching primary name
    • /v2/names:
      • GET /v2/names for listing all names
      • GET /v2/names/:name for getting details of a specific name
    • /v2/namespaces:
      • GET /v2/namespaces for listing all namespaces
      • GET /v2/namespaces/:tld for getting details of a specific namespace
      • GET /v2/namespaces/:tld/names for listing names within a namespace
    • /v2/addresses:
      • GET /v2/addresses/:blockchain/:address for getting names owned by an address
  • Implemented new helper functions for BNS V2 contract interactions
  • Updated existing BNS-related functions to work with the new contract structure
  • Added new types and interfaces to support BNS V2 data structures
  1. How does this impact application developers
    Developers can now use these new endpoints to interact with the BNS V2 contract, enabling them to:
  • Retrieve pricing information for namespaces and names
  • Check name resolution and ownership
  • Fetch renewal heights and primary names
    This update maintains backwards compatibility with existing BNS V1 endpoints while providing new functionality for BNS V2.
  1. Provide examples of use cases with code samples and applicable acceptance criteria
    const response = await fetch('/v2/prices/namespaces/id'); const price = await response.json(); console.log(price); // { units: "STX", amount: "123456789" }

Type of Change

  • New feature
  • Bug fix
  • API reference/documentation update
  • Other

Does this introduce a breaking change?

No, this PR does not introduce breaking changes. It adds new endpoints and functionality while maintaining compatibility with existing BNS V1 endpoints.

Are documentation updates required?

  • Yes

Testing information

Provide context on how tests should be performed.

  1. Is testing required for this change?
    Yes

Checklist

  • Code is commented where needed
  • Unit test coverage for new or modified code paths
  • npm run test passes
  • Changelog is updated
  • Tag 1 of @rafaelcr

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@zone117x
Copy link
Member

Hi @Patotking12 thanks for this contribution! Could you point me towards some resources for BNSv2, for example a SIP or similar?

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

Successfully merging this pull request may close these issues.

3 participants