Skip to content

Commit 686512e

Browse files
committed
Initial import of Buidler EVM and release 1.0.1
1 parent b3e6b22 commit 686512e

File tree

579 files changed

+21148
-2406
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

579 files changed

+21148
-2406
lines changed

.npmrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
package-lock=false
1+
package-lock=false

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ install:
1515
- scripts/install.sh
1616

1717
script:
18+
- npx tsc --version
1819
- npm run test
1920
- npm run lint
2021
- node scripts/check-dependencies.js

CONTRIBUTING.md

+47-20
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ To install this project you have to run:
1818
## Building the projects
1919

2020
Plugins require buidler-core to be built or tested. Our recommendation is to run `npm run watch` from the root folder.
21-
This will keep everything compiled, and these problems will be avoided.
21+
This will keep everything compiled, and these problems will be avoided.
2222

2323
## Testing
2424

@@ -30,46 +30,73 @@ You can run a package's tests by executing `npm run test` inside its folder. Or
3030
## Code formatting
3131

3232
We use [Prettier](https://prettier.io/) to format all the code without any special configuration. Whatever Prettier does
33-
is considered The Right Thing. It's completely fine to commit non-prettied code and then reformat it in a later commit.
33+
is considered The Right Thing. It's completely fine to commit non-prettied code and then reformat it in a later commit.
3434

3535
We also have [tslint](https://palantir.github.io/tslint/) installed in all the projects. It checks that you have run
3636
Prettier and forbids some dangerous patterns.
3737

38-
The linter is always run in the CI, so make sure it passes before pushing code. You can use `npm run lint` and
38+
The linter is always run in the CI, so make sure it passes before pushing code. You can use `npm run lint` and
3939
`npm run lint:fix` inside the packages' folders.
4040

4141
## Dependencies
4242

43-
We keep our dependencies versions in sync between the different projects.
43+
We keep our dependencies versions in sync between the different projects.
4444

4545
Running `node scripts/check-dependencies.js` from the root folder checks that every project specifies the same versions
46-
of each dependency. It will print an error if the versions get out of sync.
46+
of each dependency. It will print an error if the versions get out of sync.
4747

4848
## Performance and dependencies loading
4949

50-
Buidler and its plugins are optimized for keeping startup time low.
50+
Buidler and its plugins are optimized for keeping startup time low.
5151

5252
This is done by selectively requiring dependencies when needed using `import` or `require` following this criteria:
5353

54-
1. If something is only imported for its type, and NOT its value, use a top-level `import ... from "mod"`
54+
1. If something is only imported for its type, and NOT its value, use a top-level `import ... from "mod"`
5555
1. If a module is in the least below, use a top-level `import ... from "mod""`.
56-
3. Otherwise, use `await import` or `require` locally in the functions that use it.
57-
3.1. If the function is sync, use node's `require`
58-
3.2. If the function is an async, use `await import`
56+
1. Otherwise, use `await import` or `require` locally in the functions that use it.
57+
3.1. If the function is sync, use node's `require`
58+
3.2. If the function is an async, use `await import`
5959

6060
Note that these rules don't apply to tests. You can always use top-level imports there.
6161

6262
### Essential modules
6363

6464
This is a list of the modules that always get loaded during startup:
6565

66-
* `fs`
67-
* `path`
68-
* `util`
69-
* `find-up`
70-
* `fs-extra`
71-
* `chalk`
72-
* `semver`
73-
* `deepmerge`
74-
* `source-map-support/register`
75-
66+
- `fs`
67+
- `path`
68+
- `util`
69+
- `find-up`
70+
- `fs-extra`
71+
- `chalk`
72+
- `semver`
73+
- `deepmerge`
74+
- `source-map-support/register`
75+
76+
## Common errors
77+
78+
### Monkey-patching dependencies multiple times
79+
80+
You should avoid monkey-patching whenever possible. But if it's necessary to do so, you should pay extra care when doing
81+
it in Buidler or your tests may fail in very hard to debug ways.
82+
83+
When tests are run, Buidler gets initialized multiple times. That may lead to monkey-patching the same multiple times.
84+
To avoid this, keep references to the original implementations. In order to do this, you need to get it just once:
85+
86+
```js
87+
let originalImpl; // May be a global
88+
89+
// ...
90+
91+
if (originalImpl === undefined) {
92+
originalImpl = lib.func;
93+
}
94+
95+
lib.func = function(...args) {
96+
// Do something;
97+
return originalImpl.apply(this, args);
98+
};
99+
```
100+
101+
This isn't normally a problem if you are monkey-patching an object's methods. But it is when monkey-patching a class
102+
or its prototype.

LICENSE

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SEE LICENSE IN EACH PACKAGE'S LICENSE FILE
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
declare module "ethereumjs-abi";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
declare module "ethereumjs-block";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
declare module "ganache-core";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
declare module "merkle-patricia-tree/secure";

docs/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
/api
33
/.vuepress/dist
44
.DS_Store
5+
/errors/README.md
6+
wget-readmes.sh

docs/.vuepress/components/Plugins.vue

+2-68
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<div class="plugin" v-for="plugin in plugins">
99
<div>
1010
<span class="name"><a :href="plugin.url">{{ plugin.name }}</a></span>
11-
<span class="version">{{ plugin.version }}</span>
11+
<!-- <span class="version">{{ plugin.version }}</span> -->
1212
</div>
1313
<p class="description">{{ plugin.description }}</p>
1414
<div class="tags">
@@ -21,75 +21,9 @@
2121

2222
<script>
2323
24-
25-
let plugins = [
26-
{
27-
name: "@nomiclabs/buidler-truffle4",
28-
version: "1.0.0-beta.9",
29-
url: "https://github.com/nomiclabs/buidler/tree/master/packages/buidler-truffle4",
30-
description: "Integration with TruffleContract from Truffle 4",
31-
tags: ["Truffle", "Testing"]
32-
}, {
33-
name: "@nomiclabs/buidler-truffle5",
34-
version: "1.0.0-beta.9",
35-
url: "https://github.com/nomiclabs/buidler/tree/master/packages/buidler-truffle5",
36-
description: "Integration with TruffleContract from Truffle 5",
37-
tags: ["Truffle", "Testing"],
38-
}, {
39-
name: "@nomiclabs/buidler-web3",
40-
version: "1.0.0-beta.9",
41-
url: "https://github.com/nomiclabs/buidler/tree/master/packages/buidler-web3",
42-
description: "Injects Web3 1.x into the Buidler Runtime Environment",
43-
tags: ["Web3.js", "Testing", "Tasks", "Scripts"],
44-
}, {
45-
name: "@nomiclabs/buidler-web3-legacy",
46-
version: "1.0.0-beta.9",
47-
url: "https://github.com/nomiclabs/buidler/tree/master/packages/buidler-web3-legacy",
48-
description: "Injects Web3 0.20.x into the Buidler Runtime Environment",
49-
tags: ["Web3.js", "Legacy", "Testing", "Tasks", "Scripts"],
50-
}, {
51-
name: "@nomiclabs/buidler-ethers",
52-
version: "1.0.0-beta.9",
53-
url: "https://github.com/nomiclabs/buidler/tree/master/packages/buidler-ethers",
54-
description: "Injects ethers.js into the Buidler Runtime Environment",
55-
tags: ["Ethers.js", "Testing", "Tasks", "Scripts"],
56-
}, {
57-
name: "@nomiclabs/buidler-etherscan",
58-
version: "1.0.0-beta.9",
59-
url: "https://github.com/nomiclabs/buidler/tree/master/packages/buidler-etherscan",
60-
description: "Automatically verify contracts on Etherscan",
61-
tags: ["Etherscan", "Verification"],
62-
}, {
63-
name: "@nomiclabs/buidler-solpp",
64-
version: "1.0.0-beta.9",
65-
url: "https://github.com/nomiclabs/buidler/tree/master/packages/buidler-solpp",
66-
description: "Automatically run the solpp preprocessor before each compilation",
67-
tags: ["Solpp", "Preprocessor"],
68-
}, {
69-
name: "@nomiclabs/buidler-solhint",
70-
version: "1.0.0-beta.9",
71-
url: "https://github.com/nomiclabs/buidler/tree/master/packages/buidler-solhint",
72-
description: "Easily run solhint to lint your Solidity code",
73-
tags: ["Solhint", "Linter"]
74-
}, {
75-
name: "@nomiclabs/buidler-vyper",
76-
version: "1.0.0-beta.9",
77-
url: "https://github.com/nomiclabs/buidler/tree/master/packages/buidler-vyper",
78-
description: "Adds support to compile Vyper smart contracts",
79-
tags: ["Vyper", "Compiler"]
80-
},
81-
{
82-
name: "buidler-gas-reporter",
83-
version: "0.1.2",
84-
url: "https://github.com/cgewecke/buidler-gas-reporter",
85-
description: "Gas usage per unit test. Average gas usage per method. A mocha reporter.",
86-
tags: ["Testing", "Gas"]
87-
}
88-
];
89-
9024
export default {
9125
data() {
92-
return {"plugins": plugins};
26+
return {"plugins": require("../plugins.js")};
9327
}
9428
}
9529

docs/.vuepress/config.js

+86-23
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,108 @@
1+
const defaultSlugify = require("vuepress/lib/markdown/slugify");
2+
const plugins = require("./plugins.js");
3+
const pluginsChildren = [];
4+
5+
plugins.forEach(plugin => {
6+
let readmePath =
7+
"/plugins/" +
8+
plugin.name.replace("/", "-").replace(/^@/, "") +
9+
".md";
10+
11+
pluginsChildren.push([readmePath, plugin.name, 0]);
12+
});
13+
114
module.exports = {
215
title: "Buidler",
3-
description: "Buidler is a task runner for Ethereum smart contract developers.",
16+
description:
17+
"Buidler is a task runner for Ethereum smart contract developers.",
418
serviceWorker: false,
5-
ga: 'UA-117668706-2',
19+
ga: "UA-117668706-2",
620
themeConfig: {
721
logo: "/logo.svg",
822
nav: [
923
{ text: "Home", link: "/" },
10-
{ text: "Why Buidler", link: "https://medium.com/nomic-labs-blog/buidler-compounding-value-for-ethereum-developers-425141a41b7b" },
11-
{ text: "Plugins", link: "/plugins/"},
12-
{ text: "Guides", link: "/guides/#getting-started" },
13-
{ text: "Documentation", link: "/documentation/" },
14-
{ text: "API", link: "/api/" },
15-
{ text: "Nomic Labs", link: "https://nomiclabs.io" }
24+
{ text: "Buidler EVM", link: "/buidler-evm/" },
25+
{ text: "Plugins", link: "/plugins/" },
26+
{ text: "Documentation", link: "/getting-started/" },
27+
{ text: "API", link: "/api/" }
1628
],
1729
lastUpdated: true,
1830
repo: "nomiclabs/buidler",
1931
docsDir: "docs",
2032
docsBranch: "master",
2133
editLinkText: "Help us improve this page!",
2234
editLinks: true,
23-
sidebar: {
24-
'/guides/': [{
35+
sidebarDepth: 1,
36+
displayAllHeaders: true,
37+
sidebar: [
38+
["/getting-started/", "Getting Started", 1],
39+
["/config/", "Configuration", 0],
40+
["/buidler-evm/", "Buidler EVM", 0],
41+
{
2542
title: "Guides",
43+
url: "/guides/",
2644
collapsable: false,
45+
depth: 1,
2746
children: [
28-
'/guides/',
29-
'testing',
30-
'create-task',
31-
'create-plugin',
32-
'truffle-migration',
33-
'scripts',
34-
'typescript'
47+
["/guides/truffle-migration.md", "Migrating from Truffle", 0],
48+
["/guides/project-setup.md", "Setting up a project", 0],
49+
["/guides/compile-contracts.md", "Compiling your contracts", 0],
50+
["/guides/truffle-testing.md", "Testing with Web3.js & Truffle", 0],
51+
["/guides/waffle-testing.md", "Testing with ethers.js & Waffle", 0],
52+
["/guides/deploying.md", "Deploying your contracts", 0],
53+
["/guides/scripts.md", "Writing scripts", 0],
54+
["/guides/buidler-console.md", "Using the Buidler console", 0],
55+
["/guides/create-task.md", "Creating a task", 0],
56+
["/guides/ganache-tests.md", "Running tests with Ganache", 0],
57+
["/guides/vscode-tests.md", "Running tests on VS Code", 0],
58+
["/guides/typescript.md", "TypeScript support", 0]
3559
]
36-
}],
37-
'/documentation/': {
38-
sidebar: 'auto'
60+
},
61+
{
62+
title: "Advanced",
63+
collapsable: false,
64+
children: [
65+
[
66+
"/advanced/buidler-runtime-environment.html",
67+
"Buidler Runtime Environment (BRE)",
68+
0
69+
],
70+
["/advanced/building-plugins.html", "Building plugins", 0]
71+
]
72+
},
73+
{
74+
title: "Troubleshooting",
75+
collapsable: false,
76+
children: [
77+
["/troubleshooting/verbose-logging.html", "Verbose logging", 0],
78+
["/troubleshooting/common-problems.html", "Common problems", 0],
79+
["/errors/", "Error codes", 0]
80+
]
81+
},
82+
{
83+
title: "Plugins",
84+
collapsable: false,
85+
children: pluginsChildren
3986
}
40-
}
87+
]
4188
},
4289
head: [
43-
['meta ', { name: 'Cache-Control', content: 'public, max-age=0, must-revalidate' }]
44-
]
90+
[
91+
"meta ",
92+
{ name: "Cache-Control", content: "public, max-age=0, must-revalidate" }
93+
]
94+
],
95+
markdown: {
96+
slugify: title => {
97+
const errorTitle = /(^BDLR\d+):/;
98+
99+
const match = errorTitle.exec(title);
100+
101+
if (match !== null) {
102+
return match[1];
103+
}
104+
105+
return defaultSlugify(title);
106+
}
107+
}
45108
};

0 commit comments

Comments
 (0)