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

Commit 46618af

Browse files
committed
Update readme
1 parent 82256c7 commit 46618af

11 files changed

Lines changed: 184 additions & 6787 deletions

File tree

packages/config/src/configDefaults.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,13 @@ export const getInitialConfig = ({
3333
resolver: null,
3434
artifactor: null,
3535
ethpm: {
36-
ipfs_host: "ipfs.infura.io",
37-
ipfs_protocol: "https",
38-
registry: "0x8011df4830b4f696cd81393997e5371b93338878",
39-
install_provider_uri:
40-
"https://ropsten.infura.io/v3/26e88e46be924823983710becd929f36"
36+
ipfsHost: "ipfs.infura.io",
37+
ipfsProtocol: "https",
38+
ipfsPort: "5001",
39+
registry: {
40+
address: "0x8011df4830b4f696cd81393997e5371b93338878",
41+
network: "ropsten"
42+
}
4143
},
4244
ens: {
4345
enabled: false,

packages/core/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ module.exports = {
66
create: require("./lib/commands/create/helpers"),
77
console: require("./lib/repl"),
88
contracts: require("@truffle/workflow-compile"),
9-
//package: require("./lib/package"),
109
test: require("./lib/test"),
1110
version: pkg.version,
12-
ganache: require("ganache-core/public-exports"),
11+
ganache: require("ganache-core/public-exports")
1312
};

packages/core/lib/commands/install.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ const command = {
77
options: [
88
{
99
option: "packageId",
10-
description:
11-
"(required) Name of the package as listed in the Ethereum Package Registry. Format: packageName@version"
10+
description: `(required) Name of the package as listed in the Ethereum Package Registry.
11+
Accepted formats: packageName, packageName@version, ethpm URI, ipfs URI.`
1212
},
1313
{
1414
option: "--alias",

packages/ethpm-v1/README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
# `ethpm-v1`
22

3-
> TODO: description
4-
53
## Usage
64

75
```
86
const ethpmV1 = require('ethpm-v1');
9-
10-
// TODO: DEMONSTRATE API
117
```
8+
9+
This package contains support for the deprecated v1 version of the ethpm specification for backwards compatibility purposes.

packages/ethpm-v1/lib/ethpm-v1.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
"use strict";
2-
31
const expect = require("@truffle/expect");
42
const TruffleError = require("@truffle/error");
53
const Networks = require("@truffle/core/lib/networks");

packages/ethpm-v1/package.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"ethpm",
77
"packages"
88
],
9-
"author": "Nick Gheorghita <nickgheorghita@gmail.com>",
109
"homepage": "http://www.ethpm.com",
1110
"license": "MIT",
1211
"main": "lib/ethpm-v1.js",
@@ -15,7 +14,7 @@
1514
},
1615
"directories": {
1716
"lib": "lib",
18-
"test": "__tests__"
17+
"test": "tests"
1918
},
2019
"files": [
2120
"lib"
@@ -24,9 +23,6 @@
2423
"type": "git",
2524
"url": "git+https://github.com/trufflesuite/truffle.git"
2625
},
27-
"scripts": {
28-
"test": "echo \"hellp\""
29-
},
3026
"bugs": {
3127
"url": "https://github.com/trufflesuite/truffle/issues"
3228
}

packages/ethpm-v3/README.md

Lines changed: 82 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,103 @@
1-
# `ethpm-v3`
1+
# truffle/ethpm-v3
22

3-
> TODO: description
3+
A package that provides truffle support for [ethpm v3](http://ethpm.github.io/ethpm-spec/v3-package-spec.html), the default version in truffle.
44

55
## Usage
6+
Installing an ethpm package in your truffle project will automatically generate an `_ethpm_packages/` directory to which the package assets will be written. This directory should be treated like a `node_modules/` directory, and not be edited directly.
7+
8+
## Configuration
9+
To configure ethpm, define the following fields inside your `truffle-config.js`.
10+
11+
```js
12+
{
13+
// required to lookup a registry address via ens
14+
ens: {
15+
enabled: true
16+
},
17+
// below are all of the default config values for ethpm
18+
ethpm: {
19+
ipfsHost: "ipfs.infura.io",
20+
ipfsProtocol: "https",
21+
ipfsPort: "5001",
22+
registry: {
23+
address: "0xabc", // ENS is supported here
24+
network: "ropsten" // must match a network with an available provider defined in `networks` field
25+
}
26+
version: "3" // only supported versions include ("1", "3")
27+
}
28+
}
29+
```
630

31+
## List
732
```
8-
const ethpmV3 = require('ethpm-v3');
33+
truffle packages
934
```
35+
Reads all directly available packages on the connected registry.
1036

11-
TODO:
12-
audit all error messages / include useful links to cli/docs/etc...
13-
useful comments throughout
14-
test all the different install scenarios
15-
- test auto semver detect
16-
warnings about trusting packages?
17-
ethpm-v1 tests
18-
truffle-config: ethpm/registry/network_id -> networkId
19-
should the network provider be a function? or instance?
20-
install from github blob uri
21-
22-
is there a better display output workflow for sending publish tx
23-
do we want timeout errors? // what's the best pattern to catch errors?
24-
25-
how many deployments/chain does truffle support? if we migrate will it replace a deployment? (probably yes)
26-
27-
there are no contractTypes in compilers from ethpm.js
28-
29-
warning if ppl installed a package with insufficient artifacts - but expect them via deploy?
37+
## Install
3038

31-
- should we require `name` and `version` in ethpm.json?
32-
33-
QUESTIONS:
34-
do we support ens in truffle config for the registry address?
35-
should the network provider be a function? or instance?
36-
truffle default registry?
37-
38-
# questions
39-
- how to install `ethpm` npm package as different versions for `ethpm-v1` / `ethpm-v3`
40-
- can we enforce either v1 / v3 per project? combining manifests seems tricky..
41-
- should we have a v1 and v3 resolver?
39+
### Install the latest version of a package from connected registry
40+
```
41+
truffle install owned
42+
```
43+
- Will throw an error requiring a specified version if package versioning does not follow semver.
4244

43-
todo: resolver source for both ethpmv1 & v3
4445

46+
### Install a specific version of a package from connected registry
47+
```
48+
truffle install owned@1.0.0
49+
```
4550

51+
### Install the latest version of a package from any registry
4652
```
47-
truffle packages
48-
````
49-
todo: test with big registry
50-
todo: test with no registry
51-
todo: test with invalid registry
53+
truffle install owned ethpm://0x123/owned
54+
truffle install owned ethpm://0x123:1/owned
55+
```
56+
- will throw an error requiring a specified version if package versioning does not follow semver.
57+
- using an ethpm uri overrides the registry set in `truffle-config.js`
5258

59+
### Install a specific version of a package from any registry
60+
```
61+
truffle install owned ethpm://0x123/owned@1.0.0
62+
truffle install owned ethpm://0x123:1/owned@1.0.0
5363
```
54-
truffle install xxx@1.0.0
55-
truffle install ethpm://packages.eth:3/xxx@1.0.0
56-
truffle install ipfs://Qmasdfa --alias=awesome
64+
```
65+
truffle install owned ethpm://libraries.snakecharemers.eth/owned@1.0.0
66+
truffle install owned ethpm://libraries.snakecharemers.eth:1/owned@1.0.0
5767
```
5868

59-
- supports either v1 or v3
69+
### Install a package under an alias
70+
```
71+
truffle install owned@1.0.0 --alias owned-2
72+
```
73+
- This can be useful for installing multiple packages that have the same name (installed packages share a namespace).
74+
- This can be useful for adding custom identifiers to installed packages for whatever reason.
6075

76+
## Publish
6177
```
6278
truffle publish
63-
````
64-
65-
settings required in `ethpm.json`
66-
67-
68-
69-
escrow: QmNpLojZo471M357NTUZ1qKDwjUZrfYctWhzPtNFEXcSaL
70-
piper-coin: QmNbvXM5ig6Qtz6abRuG52KgjFqfXDyBCdRTz7QDENgxzv
71-
owned: QmcxvhkJJVpbxEAa6cgW3B6XwPJb79w9GpNUv2P2THUzZR
72-
safe-math-lib: QmWnPsiS3Xb8GvCDEBFnnKs8Yk4HaAX6rCqJAaQXGbCoPk
73-
standard-token: QmQNffBrmbB3TuBCtYfYsJWJVLssatWXa3H6CkGeyNUySA
74-
transferable: QmYX2yqyrpaJQugHQKnaWYcnkJEdnJC4exKaEVR3RK3TTf
75-
wallet-with-send: QmX95FoLeVAFbnbj1PEDQaXDAeccmjbK8Zbw4eos9PAxeA
76-
wallet: QmPtZxv9uEtr671XVjevHDacP9M4Tw9T7p6n1MS1xdyMeC
79+
```
7780

81+
- Requires that a valid `ethpm.json` file exists in your project root directory.
82+
- Requires that provider for connected registry has release privileges on that registry.
83+
- Running `truffle publish` will automatically generate an ethpm manifest from available contract assets and publish it to the connected registry.
84+
85+
#### Sample `ethpm.json`
86+
```jsonld=
87+
{
88+
"name": "package-name", // required
89+
"version": "0.1.0", // required
90+
"meta": {
91+
"license": "licenseType",
92+
"authors": ["author-1", "author-2"],
93+
"description": "Description of package.",
94+
"keywords": ["keyword1", "keyword2"],
95+
"links": {
96+
"documentation": "www.documentation.com",
97+
"repo": "www.repository.com",
98+
"website": "www.website.com"
99+
}
100+
}
101+
}
102+
```
78103

79-
ICEBOX:
80-
support github uris
81-
deploy a registry?

packages/ethpm-v3/lib/ethpm-v3.js

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const semver = require("semver");
66
const Web3 = require("web3");
77
const path = require("path");
88
const fs = require("fs");
9+
const { isAddress } = require("web3-utils");
910
const TruffleContractSchema = require("@truffle/contract-schema");
1011
const utils = require("./utils");
1112

@@ -108,12 +109,24 @@ const PackageV3 = {
108109
);
109110
}
110111

112+
options.logger.log(
113+
`! Please use caution when interacting with installed packages.\n! Only use packages that are published on trusted registries, or whose assets you've verified directly.`
114+
);
111115
options.logger.log("Fetching package manifest...");
112-
var targetRegistry = options.ethpm.registry.address;
113116
var targetNetwork = options.ethpm.registry.network;
114117
var targetNetworkId = options.networks[targetNetwork].network_id;
115118
var provider = utils.pluckProviderFromConfig(options);
116119

120+
let targetRegistry;
121+
if (!isAddress(options.ethpm.registry.address)) {
122+
targetRegistry = await utils.resolveEnsName(
123+
options.ethpm.registry.address,
124+
provider,
125+
options
126+
);
127+
} else {
128+
targetRegistry = options.ethpm.registry.address;
129+
}
117130
// Create an ethpm instance
118131
let ethpm;
119132
try {
@@ -148,7 +161,7 @@ const PackageV3 = {
148161
}
149162

150163
// Parse ethpm URI || packageId
151-
if (!manifestUri) {
164+
if (!resolvedManifestUri) {
152165
// Parse ethpm uri
153166
if (
154167
options.packageId.startsWith("ethpm://") ||
@@ -173,12 +186,9 @@ const PackageV3 = {
173186
);
174187
}
175188

176-
if (
177-
typeof targetRegistry === "undefined" ||
178-
typeof targetNetworkId === "undefined"
179-
) {
189+
if (!targetRegistry || !targetNetworkId) {
180190
throw new TruffleError(
181-
`Missing an 'ethpm/registry/address' and 'ethpm/registry/network_id' in your truffle config for the target registry.`
191+
`Missing an 'ethpm/registry/address' and 'ethpm/registry/network' in your truffle config for the target registry.`
182192
);
183193
}
184194
targetPackageName = packageData[0];
@@ -269,15 +279,11 @@ const PackageV3 = {
269279
if (ethpmPackage.deployments) {
270280
ethpmPackage.deployments.forEach((value, key, _) => {
271281
const foundGenesisBlock = key.host.toLowerCase();
272-
if (!(foundGenesisBlock in utils.SUPPORTED_GENESIS_BLOCKS)) {
273-
// we probably shouldn't throw here - just skip over unsupported deployments...
274-
throw new TruffleError(
275-
`Blockchain uri detected with unsupported genesis block: ${foundGenesisBlock}`
276-
);
282+
if (foundGenesisBlock in utils.SUPPORTED_GENESIS_BLOCKS) {
283+
normalizedDeployments[
284+
utils.SUPPORTED_GENESIS_BLOCKS[foundGenesisBlock]
285+
] = value;
277286
}
278-
normalizedDeployments[
279-
utils.SUPPORTED_GENESIS_BLOCKS[foundGenesisBlock]
280-
] = value;
281287
});
282288
}
283289

@@ -459,7 +465,7 @@ const PackageV3 = {
459465
try {
460466
await w3.eth.sendSignedTransaction(tx.raw);
461467
} catch (err) {
462-
options.logger.log(err);
468+
options.logger.log(`Error publishing release data to registry: ${err}`);
463469
return;
464470
}
465471
options.logger.log(

0 commit comments

Comments
 (0)