Skip to content
New issue

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

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

Already on GitHub? # to your account

Web DNS Resolver for SNS + ENS V2 #4284

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

Conversation

mjkid221
Copy link

Purpose

Revived an old feature from #2335 which adds Web domain name resolutions via SNS and ENS.

Understandable if the team wants to bench this while they work on other top priority items. Just wanted to get this out of the way.

}

async domainContentIPFSGatewayUpdate(ipfsGateway: string): Promise<string> {
const uuid = (await this.keyringStore.activeUserKeyring()).uuid;

Choose a reason for hiding this comment

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

const userUUID = await this.keyringStore.activeUserKeyring()?.uuid;

It will great if you use Nullish Coalescing Operator(?) here.

Choose a reason for hiding this comment

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

Not neccessary just saying.

start({
isMobile: false,
});

Copy link

@adasarpan404 adasarpan404 Feb 27, 2024

Choose a reason for hiding this comment

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

import { start } from "@coral-xyz/background";
import { supportedDomains, urlPatterns } from "../dns-redirects/constants";
import { redirect } from "../dns-redirects/helpers/tabHelper";

// Start the background process
start({
  isMobile: false,
});

// Event listener for handling URL navigation
chrome.webNavigation.onBeforeNavigate.addListener(async (details) => {
  try {
    // Extract the domain URL
    const url = new URL(details.url);
    const domainUrl = url.searchParams.get("q") || url.hostname;

    // Check if the domain URL contains spaces
    if (domainUrl && !domainUrl.includes(" ")) {
      // Redirect to the resolved URL
      await redirect(domainUrl);
    }
  } catch (error) {
    console.error("Error occurred during navigation:", error);
  }
}, {
  // Define URL patterns to match
  url: supportedDomains.flatMap((param) =>
    urlPatterns.map((pattern) => ({
      urlMatches: pattern.includes("duckduckgo")
        ? `${pattern}\\.${param}$`
        : `${pattern}\\.${param}&.*$`,
    }))
  ),
});

Instead of having two separate chrome.webNavigation.onBeforeNavigate event listeners, we can combine them into one to reduce redundancy.

Choose a reason for hiding this comment

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

just a suggestion, please verify on your own.

Choose a reason for hiding this comment

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

I have put an suggestion for the change in whole file for this

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

Successfully merging this pull request may close these issues.

2 participants