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 domains that resolve to addresses now searchable #57

Merged
merged 3 commits into from
Dec 21, 2024

Conversation

stjet
Copy link
Contributor

@stjet stjet commented Nov 22, 2024

tested and working locally

async fetchBNSDomain(domain_name: string, tld: string): Promise<any> {
await this._hasPingedApi();
return this._http
.post<any>(`${this.httpApi}/v1/account/bns`, {
Copy link
Owner

@dev-ptera dev-ptera Dec 6, 2024

Choose a reason for hiding this comment

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

Could we get some stronger typings here? The api is versioned so we should know what schema to expect.

Specifically looking to remove the any here.

Comment on lines 125 to 135
if (!address.startsWith('ban_')) {
const parts = address.split('.');
if (parts.length === 2) {
//search in api
try {
const domain = await this.apiService.fetchBNSDomain(parts[0], parts[1]);
if (domain.domain?.resolved_address) {
return this._redirectToAccountPage(domain.domain?.resolved_address);
}
} catch (_) {}
}
Copy link
Owner

Choose a reason for hiding this comment

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

Could we get a quick comment here explaining what this does? If not a ban address, assume it's BNS?

Comment on lines 51 to 55
isValidBNSDomain(bns: string): boolean {
const parts = bns.split('.');
//later, can also check for illegal characters once that is more settled
return parts.length === 2 && parts[0].length <= 32;
}
Copy link
Owner

Choose a reason for hiding this comment

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

Could this be placed in the UtilService & then used here & in the AccountComponent?

if (!address) {
return;
}

if (!address.startsWith('ban_')) {
const parts = address.split('.');
if (parts.length === 2) {
Copy link
Owner

Choose a reason for hiding this comment

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

Use isValidBNSDomain utility function here?

@stjet
Copy link
Contributor Author

stjet commented Dec 17, 2024

@dev-ptera Hopefully that should address the review. I did add banani-bns as a dependency for the Domain type but maybe it only needs @types/banani-bns? Not quite sure how that works.

@dev-ptera dev-ptera changed the base branch from master to dev December 21, 2024 12:16
@dev-ptera dev-ptera merged commit 0e51a05 into dev-ptera:dev Dec 21, 2024
2 checks passed
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