Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Support ethpm V2 #2857

Closed
wants to merge 10 commits into from
Closed

Conversation

njgheorghita
Copy link
Contributor

No description provided.

Copy link
Contributor

@gnidan gnidan left a comment

Choose a reason for hiding this comment

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

here's a round of comments that you saw me type


// Create a web3 instance connected to a blockchain
if (!options.provider && !options.ethpm.install_provider_uri) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we don't want to use the network provider, since there's no reason to believe that the user will be developing against the same network as the network they're using for ethpm

packages/core/lib/package.js Outdated Show resolved Hide resolved
new Web3.providers.HttpProvider(options.ethpm.install_provider_uri);

// Parse ethpm uri
const ethpmURI = new Erc1319URI(options.ethpm_uri);
Copy link
Contributor

Choose a reason for hiding this comment

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

btw if you get sick of typing options.ethpm_uri, you can do this kinda business:

const { ethpm_uri } = options

registryAddress: ethpmURI.address,
ipfs: {
host: options.ethpm.ipfs_host,
port: options.ethpm.ipfs_port,
Copy link
Contributor

Choose a reason for hiding this comment

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

y'know if we're looking at this as a breaking change, we should get rid of the underscores and make them proper camelCase to match JS style

Copy link
Contributor

Choose a reason for hiding this comment

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

(but we should not do a breaking change :)

packages/core/lib/package.js Outdated Show resolved Hide resolved
const Web3 = require("web3");
const { createInterfaceAdapter } = require("@truffle/interface-adapter");
const async = require("async");
const { EthPM } = require("ethpm");
Copy link
Contributor

Choose a reason for hiding this comment

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

to make this non-breaking, I would suggest creating new packages in the monorepo here, maybe @truffle/ethpm-v1 and @truffle/ethpm-v2 and having those packages depend on the respective versions of the ethpm Node package.

Then, you could duplicate and move this package.js file to those corresponding new packages

@@ -35,8 +35,10 @@ export const getInitialConfig = ({
ethpm: {
Copy link
Contributor

Choose a reason for hiding this comment

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

in line with the non-breaking-ness suggestion below, we could add a version field here that would control the delegation to the correct v1/v2 package.

Copy link
Contributor

Choose a reason for hiding this comment

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

so then to switch it, users would provide this sort of configuration:

module.exports = {
  /* ... rest of truffle-config.js ... */
  ethpm: {
    version: "2",
    /* ... rest of ethpm config ... */
  }
}

packages/core/lib/package.js Outdated Show resolved Hide resolved
// the blockchain uri coming through is what is set as the network_id
// not a freshly created one with latest block via BlockchainUtils
const foundNetworkId = Object.keys(fileContents.networks)[0];
if (foundNetworkId !== blockchainUri) {
Copy link
Contributor

Choose a reason for hiding this comment

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

note that in order to construct a blockchain URI, you're going to need to actually connect to the networks in the truffle-config, enumerating over each defined network, and for each of these networks, find the relevant block info

sorry

.release(ethpmURI.version);

// Install target manifest URI to working directory
await ethpm.installer.install(manifestURI, ethpmURI.address);
Copy link
Contributor

Choose a reason for hiding this comment

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

we need to capture the result here as a list of contract types and list of deployments, so that we can pass this list of contracts to @truffle/artifactor.

you'll need convert blockchain URIs into network IDs because that's how the artifacts format organizes contract instances

Copy link
Contributor

Choose a reason for hiding this comment

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

note that the format is formally spec'd in @truffle/contract-schema

@njgheorghita
Copy link
Contributor Author

this pr has been superseded by #3247

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants