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

BitName Domain Fetching #676

Open
babalicious-io opened this issue Jan 25, 2025 · 1 comment
Open

BitName Domain Fetching #676

babalicious-io opened this issue Jan 25, 2025 · 1 comment
Assignees

Comments

@babalicious-io
Copy link
Collaborator

SRC-101 BitName Domain Fetching Enhancement

Image

Current Behavior

Currently, we can only fetch and display a single BitName domain for a wallet address in the WalletProfileDetails component. The working code uses the SRC-101 balance endpoint and successfully displays one BitName.

Desired Behavior

  1. Short Term: Fetch and display all BitName domains owned by a wallet address
  2. Long Term:
    • In WalletProfileDetails: Display only the BitName domain if it's registered to the wallet (address_btc)
    • In WalletContent: Show a comprehensive list of all bitname tokenCards owned by the wallet
    • Include in DashboardDetails: Display the registered BitName domain in this specific dashboard page for logged in users in a future update

API Documentation Reference

Using the documented endpoint from https://stampchain.io/docs#/SRC-101/getSrc101AddressBalance:

GET /api/v2/src101/balance/{address}
Response schema:
{
"last_block": 0,
"data": [
{
"address": "string",
"p": "string",
"deploy_hash": "string",
"tokenid": "string",
"tokenid_utf8": "string",
"expire_timestamp": "string",
"last_update": "string",
"address_btc": "string",
"txt_data": "string",
"tag": "string"
}
]
}

Image

Attempted Solutions

1. Basic Pagination Approach

fetch(${url.origin}/api/v2/src101/balance/${address}?limit=100&offset=0)

Result: Still only fetched one BitName

2. OpenStamp-Style Implementation

Based on OpenStamp's explorer (https://openstamp.io/explorer?q=[address]&tab=domain):

fetch(${url.origin}/api/v2/src101/balance/${address}?p=src-101&op=DEPLOY&limit=1000)

Result: No BitNames displayed despite data appearing in console logs

3. Multiple Page Fetching

const initialResponse = await fetch(${url.origin}/api/v2/src101/balance/${address});
const initialData = await initialResponse.json();
const total = initialData.total || 0;
const pageSize = 100;
const totalPages = Math.ceil(total / pageSize);
// Fetch additional pages
const additionalRequests = [];
for (let page = 1; page < totalPages; page++) {
const offset = page pageSize;
additionalRequests.push(
fetch(${url.origin}/api/v2/src101/balance/${address}?offset=${offset}&limit=${pageSize})
);
}

Result: No improvement in BitName fetching

Current Working Code

This code successfully displays one BitName but needs enhancement for multiple BitNames:

const src101Data = src101Response.status === "fulfilled" && src101Response.value
? {
names: (src101Response.value.data || [])
.filter((item: any) => item?.tokenid_utf8)
.map((item: any) => item.tokenid_utf8),
total: src101Response.value.last_block || 0
}
: { names: [], total: 0 };

Questions

  1. Should we only display the bitname domain connected/registered to the wallet address? Or should we display just one, first 3 or all?
  2. Is there a specific query parameter we're missing to fetch all BitNames?
  3. Should we be using a different endpoint for comprehensive BitName fetching?

Next Steps

  1. Investigate why the OpenStamp-style implementation isn't working despite similar API usage
  2. Determine the correct approach for identifying BitName domain ownership via address_btc
  3. Create bitname tokencards and code to display them in content overview

References

Labels: enhancement, api-integration, src-101, bitnames

@babalicious-io
Copy link
Collaborator Author

PR - #679

we should display all bitnames in address

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

No branches or pull requests

2 participants