trufflesuite / ethpm-js

Javascript library for publishing and consuming Ethereum packages.
34 stars 13 forks source link

IPFSHostWithLocalReader does not respect the port parameter #10

Open jeichel-miovision opened 6 years ago

jeichel-miovision commented 6 years ago

I came across an unexpected behaviour when running IPFSHostWithLocalReader with a local IPFS Daemon with the API on 5001 and web interface on 8080 when publishing and installing an ethpm package.

I specified the following config (tried both ipfs_port: "8080" and ipfs_port: "5001")

  ethpm: {
    ipfs_host: "127.0.0.1",
    ipfs_protocol: "http",
    ipfs_port: "8080",
    registry: "0x8011df4830b4f696cd81393997e5371b93338878",
    install_provider_uri: "https://ropsten.infura.io/truffle"
  }

I did not expect IPFSHostWithLocalReader to try and visit http://127.0.0.1:80. While the base class, IPFSHost, still uses the API interface, the default class used by truffle publish, IPFSHostWithLocalReader uses the web interface with the default port based on the protocol.

Fix: I created a commit that fixed the issue for me... https://github.com/jeichel-miovision/ethpm-js/commit/2740d1186c7a947b9184641142f4317007271433

However, before creating a PR, I think the bug needs a better fix. I think ethpm, at least in the truffle context, might benefit from having two port properties, ipfs_api_port, and ipfs_web_port. Since I'm still relatively new to using truffle, this is a bigger task than I'm currently comfortable with as it probably affects many other trufflesuite and derivative projects.