Skip to content

Commit

Permalink
Initial import of Buidler EVM and release 1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
alcuadrado committed Oct 2, 2019
1 parent b3e6b22 commit 686512e
Show file tree
Hide file tree
Showing 579 changed files with 21,148 additions and 2,406 deletions.
2 changes: 1 addition & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
package-lock=false
package-lock=false
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ install:
- scripts/install.sh

script:
- npx tsc --version
- npm run test
- npm run lint
- node scripts/check-dependencies.js
Expand Down
67 changes: 47 additions & 20 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ To install this project you have to run:
## Building the projects

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

## Testing

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

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

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

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

## Dependencies

We keep our dependencies versions in sync between the different projects.
We keep our dependencies versions in sync between the different projects.

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

## Performance and dependencies loading

Buidler and its plugins are optimized for keeping startup time low.
Buidler and its plugins are optimized for keeping startup time low.

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

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

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

### Essential modules

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

* `fs`
* `path`
* `util`
* `find-up`
* `fs-extra`
* `chalk`
* `semver`
* `deepmerge`
* `source-map-support/register`

- `fs`
- `path`
- `util`
- `find-up`
- `fs-extra`
- `chalk`
- `semver`
- `deepmerge`
- `source-map-support/register`

## Common errors

### Monkey-patching dependencies multiple times

You should avoid monkey-patching whenever possible. But if it's necessary to do so, you should pay extra care when doing
it in Buidler or your tests may fail in very hard to debug ways.

When tests are run, Buidler gets initialized multiple times. That may lead to monkey-patching the same multiple times.
To avoid this, keep references to the original implementations. In order to do this, you need to get it just once:

```js
let originalImpl; // May be a global

// ...

if (originalImpl === undefined) {
originalImpl = lib.func;
}

lib.func = function(...args) {
// Do something;
return originalImpl.apply(this, args);
};
```

This isn't normally a problem if you are monkey-patching an object's methods. But it is when monkey-patching a class
or its prototype.
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SEE LICENSE IN EACH PACKAGE'S LICENSE FILE
1 change: 1 addition & 0 deletions config/typescript/@types/ethereumjs-abi/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module "ethereumjs-abi";
1 change: 1 addition & 0 deletions config/typescript/@types/ethereumjs-block/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module "ethereumjs-block";
1 change: 1 addition & 0 deletions config/typescript/@types/ganache-core/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module "ganache-core";
1 change: 1 addition & 0 deletions config/typescript/@types/merkle-patricia-tree/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module "merkle-patricia-tree/secure";
2 changes: 2 additions & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
/api
/.vuepress/dist
.DS_Store
/errors/README.md
wget-readmes.sh
70 changes: 2 additions & 68 deletions docs/.vuepress/components/Plugins.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<div class="plugin" v-for="plugin in plugins">
<div>
<span class="name"><a :href="plugin.url">{{ plugin.name }}</a></span>
<span class="version">{{ plugin.version }}</span>
<!-- <span class="version">{{ plugin.version }}</span> -->
</div>
<p class="description">{{ plugin.description }}</p>
<div class="tags">
Expand All @@ -21,75 +21,9 @@

<script>
let plugins = [
{
name: "@nomiclabs/buidler-truffle4",
version: "1.0.0-beta.9",
url: "https://github.com/nomiclabs/buidler/tree/master/packages/buidler-truffle4",
description: "Integration with TruffleContract from Truffle 4",
tags: ["Truffle", "Testing"]
}, {
name: "@nomiclabs/buidler-truffle5",
version: "1.0.0-beta.9",
url: "https://github.com/nomiclabs/buidler/tree/master/packages/buidler-truffle5",
description: "Integration with TruffleContract from Truffle 5",
tags: ["Truffle", "Testing"],
}, {
name: "@nomiclabs/buidler-web3",
version: "1.0.0-beta.9",
url: "https://github.com/nomiclabs/buidler/tree/master/packages/buidler-web3",
description: "Injects Web3 1.x into the Buidler Runtime Environment",
tags: ["Web3.js", "Testing", "Tasks", "Scripts"],
}, {
name: "@nomiclabs/buidler-web3-legacy",
version: "1.0.0-beta.9",
url: "https://github.com/nomiclabs/buidler/tree/master/packages/buidler-web3-legacy",
description: "Injects Web3 0.20.x into the Buidler Runtime Environment",
tags: ["Web3.js", "Legacy", "Testing", "Tasks", "Scripts"],
}, {
name: "@nomiclabs/buidler-ethers",
version: "1.0.0-beta.9",
url: "https://github.com/nomiclabs/buidler/tree/master/packages/buidler-ethers",
description: "Injects ethers.js into the Buidler Runtime Environment",
tags: ["Ethers.js", "Testing", "Tasks", "Scripts"],
}, {
name: "@nomiclabs/buidler-etherscan",
version: "1.0.0-beta.9",
url: "https://github.com/nomiclabs/buidler/tree/master/packages/buidler-etherscan",
description: "Automatically verify contracts on Etherscan",
tags: ["Etherscan", "Verification"],
}, {
name: "@nomiclabs/buidler-solpp",
version: "1.0.0-beta.9",
url: "https://github.com/nomiclabs/buidler/tree/master/packages/buidler-solpp",
description: "Automatically run the solpp preprocessor before each compilation",
tags: ["Solpp", "Preprocessor"],
}, {
name: "@nomiclabs/buidler-solhint",
version: "1.0.0-beta.9",
url: "https://github.com/nomiclabs/buidler/tree/master/packages/buidler-solhint",
description: "Easily run solhint to lint your Solidity code",
tags: ["Solhint", "Linter"]
}, {
name: "@nomiclabs/buidler-vyper",
version: "1.0.0-beta.9",
url: "https://github.com/nomiclabs/buidler/tree/master/packages/buidler-vyper",
description: "Adds support to compile Vyper smart contracts",
tags: ["Vyper", "Compiler"]
},
{
name: "buidler-gas-reporter",
version: "0.1.2",
url: "https://github.com/cgewecke/buidler-gas-reporter",
description: "Gas usage per unit test. Average gas usage per method. A mocha reporter.",
tags: ["Testing", "Gas"]
}
];
export default {
data() {
return {"plugins": plugins};
return {"plugins": require("../plugins.js")};
}
}
Expand Down
109 changes: 86 additions & 23 deletions docs/.vuepress/config.js
Original file line number Diff line number Diff line change
@@ -1,45 +1,108 @@
const defaultSlugify = require("vuepress/lib/markdown/slugify");
const plugins = require("./plugins.js");
const pluginsChildren = [];

plugins.forEach(plugin => {
let readmePath =
"/plugins/" +
plugin.name.replace("/", "-").replace(/^@/, "") +
".md";

pluginsChildren.push([readmePath, plugin.name, 0]);
});

module.exports = {
title: "Buidler",
description: "Buidler is a task runner for Ethereum smart contract developers.",
description:
"Buidler is a task runner for Ethereum smart contract developers.",
serviceWorker: false,
ga: 'UA-117668706-2',
ga: "UA-117668706-2",
themeConfig: {
logo: "/logo.svg",
nav: [
{ text: "Home", link: "/" },
{ text: "Why Buidler", link: "https://medium.com/nomic-labs-blog/buidler-compounding-value-for-ethereum-developers-425141a41b7b" },
{ text: "Plugins", link: "/plugins/"},
{ text: "Guides", link: "/guides/#getting-started" },
{ text: "Documentation", link: "/documentation/" },
{ text: "API", link: "/api/" },
{ text: "Nomic Labs", link: "https://nomiclabs.io" }
{ text: "Buidler EVM", link: "/buidler-evm/" },
{ text: "Plugins", link: "/plugins/" },
{ text: "Documentation", link: "/getting-started/" },
{ text: "API", link: "/api/" }
],
lastUpdated: true,
repo: "nomiclabs/buidler",
docsDir: "docs",
docsBranch: "master",
editLinkText: "Help us improve this page!",
editLinks: true,
sidebar: {
'/guides/': [{
sidebarDepth: 1,
displayAllHeaders: true,
sidebar: [
["/getting-started/", "Getting Started", 1],
["/config/", "Configuration", 0],
["/buidler-evm/", "Buidler EVM", 0],
{
title: "Guides",
url: "/guides/",
collapsable: false,
depth: 1,
children: [
'/guides/',
'testing',
'create-task',
'create-plugin',
'truffle-migration',
'scripts',
'typescript'
["/guides/truffle-migration.md", "Migrating from Truffle", 0],
["/guides/project-setup.md", "Setting up a project", 0],
["/guides/compile-contracts.md", "Compiling your contracts", 0],
["/guides/truffle-testing.md", "Testing with Web3.js & Truffle", 0],
["/guides/waffle-testing.md", "Testing with ethers.js & Waffle", 0],
["/guides/deploying.md", "Deploying your contracts", 0],
["/guides/scripts.md", "Writing scripts", 0],
["/guides/buidler-console.md", "Using the Buidler console", 0],
["/guides/create-task.md", "Creating a task", 0],
["/guides/ganache-tests.md", "Running tests with Ganache", 0],
["/guides/vscode-tests.md", "Running tests on VS Code", 0],
["/guides/typescript.md", "TypeScript support", 0]
]
}],
'/documentation/': {
sidebar: 'auto'
},
{
title: "Advanced",
collapsable: false,
children: [
[
"/advanced/buidler-runtime-environment.html",
"Buidler Runtime Environment (BRE)",
0
],
["/advanced/building-plugins.html", "Building plugins", 0]
]
},
{
title: "Troubleshooting",
collapsable: false,
children: [
["/troubleshooting/verbose-logging.html", "Verbose logging", 0],
["/troubleshooting/common-problems.html", "Common problems", 0],
["/errors/", "Error codes", 0]
]
},
{
title: "Plugins",
collapsable: false,
children: pluginsChildren
}
}
]
},
head: [
['meta ', { name: 'Cache-Control', content: 'public, max-age=0, must-revalidate' }]
]
[
"meta ",
{ name: "Cache-Control", content: "public, max-age=0, must-revalidate" }
]
],
markdown: {
slugify: title => {
const errorTitle = /(^BDLR\d+):/;

const match = errorTitle.exec(title);

if (match !== null) {
return match[1];
}

return defaultSlugify(title);
}
}
};
Loading

0 comments on commit 686512e

Please sign in to comment.