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

Integration ENS with IPFS #4405

Merged
merged 17 commits into from
Jul 4, 2018
Merged

Conversation

PhyrexTsai
Copy link
Contributor

@PhyrexTsai PhyrexTsai commented May 30, 2018

Simple Summary

This implementation is to build a way to resolves ENS domains (.eth) to IPFS hash and redirects to url content.

Motivation

MetaMask browser extension is great project helps users to interact with Ethereum, and furthermore can be more powerful by add content resolve by ENS.

Specification

Resolve from ENS Public Resolver getContent hash to IPFS hash, and redirect url to ipfs.infura.io.

Demo

https://media.giphy.com/media/fs8Sh81IKp0GYFEMmF/giphy.gif

Video

https://www.dropbox.com/s/8g8y42z6w7e6bcj/metamask.mov?dl=0

@kumavis
Copy link
Member

kumavis commented May 30, 2018

@PhyrexTsai this is awesome, please give us time to review it!

@PhyrexTsai
Copy link
Contributor Author

@kumavis Thank you! Please let me know if there's anything needed to be changed.

Copy link
Contributor

@danfinlay danfinlay left a comment

Choose a reason for hiding this comment

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

Just commenting for now, there are a few other opinions I'd like to get on parts of this.

<body>
<div class="app">
<img src="./images/404.png" alt="">
<h2>Powered by <a href="https://www.portal.network/">Portal Network</a></h2>
Copy link
Contributor

Choose a reason for hiding this comment

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

I wasn't sure how I felt about this at first, but you know, getting credit for what you do seems pretty fair. I'm fine leaving it up, at least for a while. The same way we link to 409H for the phishing detector.

},
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'"
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a way to not include the unsafe-eval permission?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just remove it.

@@ -1,7 +1,7 @@
{
"name": "__MSG_appName__",
"short_name": "__MSG_appName__",
"version": "4.6.0",
"version": "4.6.2",
Copy link
Contributor

Choose a reason for hiding this comment

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

Please leave the version bumping to us.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure.

],
"web_accessible_resources": [
"inpage.js"
"inpage.js",
"*"
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we want to make all resources web-accessible. This seems like a potential privacy breech.

I think you should specifically list the files needed to display the page statuses (html, images).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I have removed it.


resolver.resolve(name, provider).then(ipfsHash => {
clearTimeout(clearTime)
let url = 'https://gateway.ipfs.io/ipfs/' + ipfsHash
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we sure we want to hit IPFS gateway and not Infura?

Sending this comment to Infura for comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I have changed to the ipfs.infura.io

function getProvider (type) {
switch (type) {
case 'mainnet':
return 'https://mainnet.infura.io/'
Copy link
Contributor

Choose a reason for hiding this comment

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

I would rather we use the user's provider, provided by MetaMask, to reduce our number of blockchain connections, but for this feature, I can see the benefit of this simplicity, there aren't other chains w/ the ENS resolver anyway, this could be optimized later...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No problem, we will keep updating this part in the future.

Choose a reason for hiding this comment

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

yo no estoy de acuerdo en la utilización de trezor, para poder retirar mi fondos

@egalano
Copy link

egalano commented Jun 1, 2018

@danfinlay you can use https://ipfs.infura.io for this. We've put a lot of work into preparing for additional traffic for IPFS.

@danfinlay
Copy link
Contributor

@PhyrexTsai this would be very nicely accompanied by:

  • A tutorial of how to post sites in this way.
  • Some sample sites that work with this. The gif goes by quickly, we want to be able to show it off in full force when it comes out.
  • A blog post for when we publish. I'll draft this one, but offer you a review before I post it.

@danfinlay
Copy link
Contributor

I've verified this works with phyrextsai.eth, it looks good, sorry for taking so long to try.

When I got it working, at first it usually didn't work, so I think it maybe only works with new tabs after installation, not sure why it was intermittently not working on first uses.

I mostly just want a guide on creating compatible sites, so others can build on this as soon as we release.

danfinlay
danfinlay previously approved these changes Jun 2, 2018
Copy link
Contributor

@danfinlay danfinlay left a comment

Choose a reason for hiding this comment

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

Works alright, has some issues with first time usage, and it doesn't save user's typed items, but does work with links like http://phyrextsai.eth, so that's cool, a blog post will really make this valuable to the community, but that doesn't need to block inclusion.

@PhyrexTsai
Copy link
Contributor Author

@danfinlay Sorry for the late reply, I have write a tutorial of how to post websites by using IPFS and interact with ENS.

Tutorial link: https://gist.github.com/PhyrexTsai/cffcbfa1d752b9cf817d920dfcd1ec9f

And also have some website already deployed

@@ -154,6 +158,7 @@ async function initialize () {
const initLangCode = await getFirstPreferredLangCode()
await setupController(initState, initLangCode)
log.debug('MetaMask initialization complete.')
Copy link
Contributor Author

@PhyrexTsai PhyrexTsai Jun 10, 2018

Choose a reason for hiding this comment

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

@danfinlay For the first time can not connect with, the issue that the initState.NetworkController.provider is undefined, so I think we can have a default value for this issue.

The fix code look likes:

let defaultProvider = initState.NetworkController === undefined ? { type: "mainnet" } : initState.NetworkController.provider;
ipfsContent(defaultProvider);

@danfinlay
Copy link
Contributor

The guide looks great @PhyrexTsai. Would you mind if we reposted that on our blog when it's time to publish?

@PhyrexTsai
Copy link
Contributor Author

@danfinlay Sure, that will be great, thank you very much

@kumavis
Copy link
Member

kumavis commented Jun 14, 2018

we're cutting a bug fix release tomorrow, then this will go in after with the next batch of larger features 😸
thank you for your patience

@Arachnid
Copy link

Any way to make this resolve to the IPFS content, rather than redirecting to it?

@pimato
Copy link

pimato commented Jun 14, 2018

@PhyrexTsai @danfinlay @kumavis thanks for creating/adding this very important feature. Can´t wait to move the oasis products to IPFS/ENS.

@alexvandesande
Copy link

@Arachnid does a plugin has the right to change DNS hosts and actually register a "eth" TLD, so it looks like a traditional address? Honestly it would be great, but I would understand if google didn't permitted it as it would make phishing powers of extensions much worse

@bgits
Copy link
Contributor

bgits commented Jun 21, 2018

Shouldn't this feature use IPLD instead of IPFS? The content field could be a hash pointing to content stored in all kinds of protocols not just IPFS.

@Georgi87
Copy link

Are pathnames forwarded? E.g. if I go to mywebsite.eth/home it should redirect to /home

Event better would be to resolve IPFS content directly. Is this possible to do in a chrome extension @PhyrexTsai ?

@decanus
Copy link

decanus commented Jun 27, 2018

From what I’ve seen, you can resolve content directly if you register a new scheme. So like ipfs:// instead of http://

As @Georgi87 mentioned about pathnames on the domain like `http://phyrextsai.eth/home` will pass to IPFS hash and append `/home` on redirection url.

You can try the example below: 
http://phyrextsai.eth/index.html
http://phyrextsai.eth/images/phyrex.jpg
@PhyrexTsai
Copy link
Contributor Author

PhyrexTsai commented Jun 29, 2018

@danfinlay @Georgi87 I have committed the feature to let the mechanism in the pathnames of .eth domain working as the same in the ordinary domain.

Example:
http://phyrextsai.eth/index.html
http://phyrextsai.eth/images/phyrex.jpg

@danfinlay
Copy link
Contributor

A few files are not passing our linting rules. We can either:

  • Fix these on this branch.
  • Add these files to the lint exceptions list.
  • Move these files outside of this repository.

The affected files are:

  • app/scripts/lib/ipfsContent.js
  • app/scripts/lib/contracts/registrar.js

These errors can be seen here:
https://circleci.com/gh/MetaMask/metamask-extension/31652?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link

Or by running: npm run lint.

These may be automatically fixable by running npm run lint:fix.

@brunobar79
Copy link
Contributor

brunobar79 commented Jul 3, 2018

@PhyrexTsai Please check PortalNetwork#4

If you merge that into your branch and push, all the test / lint errors should go away

@PhyrexTsai
Copy link
Contributor Author

@danfinlay @brunobar79 Thanks for helping, I've merged the PR on this branch.

Copy link
Contributor

@danfinlay danfinlay left a comment

Choose a reason for hiding this comment

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

Let's do this!

@danfinlay danfinlay merged commit 68e1f22 into MetaMask:develop Jul 4, 2018
@jdetychey
Copy link
Contributor

can't wait for this 🚀

@Arachnid
Copy link

Arachnid commented Aug 7, 2018

Note that not all ENS names will end in .eth. Can you make this work for other TLDs too?

@bgits
Copy link
Contributor

bgits commented Aug 7, 2018

@Arachnid What are the planned TLD's or how will new TLD's be proposed and added?

@Arachnid
Copy link

Arachnid commented Aug 7, 2018

@bgits .luxe and .dds are likely to be added in the very near future, and correspond to their DNS equivalents. In the longer run, nearly any DNS TLD will be supported via DNSSEC proofs.

"https://*.infura.io/",
"activeTab",
"webRequest",
"*://*.eth/"
Copy link

Choose a reason for hiding this comment

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

This seems to appear in permissions dialog for Chrome as "eth websites" without an indication it's talking about a TLD. Leaving the user wondering "What is an eth website?"

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.