Skip to content

Commit b3e6b22

Browse files
authored
Merge pull request #382 from nomiclabs/buidler-ganache
Buidler ganache
2 parents 10c5e17 + a208e81 commit b3e6b22

23 files changed

+889
-0
lines changed

packages/buidler-ganache/.env

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
TS_NODE_FILES=true

packages/buidler-ganache/.gitignore

+99
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Node modules
2+
/node_modules
3+
4+
# Compilation output
5+
/build-test/
6+
/dist
7+
8+
# Code coverage artifacts
9+
/coverage
10+
/.nyc_output
11+
12+
# Below is Github's node gitignore template, except for dotenv's entries as it's used by mocha to pass flags to ts-node,
13+
# and ignoring the node_modules part, as it'd ignore every node_modules, and we have some for testing
14+
15+
# Logs
16+
logs
17+
*.log
18+
npm-debug.log*
19+
yarn-debug.log*
20+
yarn-error.log*
21+
lerna-debug.log*
22+
23+
# Diagnostic reports (https://nodejs.org/api/report.html)
24+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
25+
26+
# Runtime data
27+
pids
28+
*.pid
29+
*.seed
30+
*.pid.lock
31+
32+
# Directory for instrumented libs generated by jscoverage/JSCover
33+
lib-cov
34+
35+
# Coverage directory used by tools like istanbul
36+
coverage
37+
38+
# nyc test coverage
39+
.nyc_output
40+
41+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
42+
.grunt
43+
44+
# Bower dependency directory (https://bower.io/)
45+
bower_components
46+
47+
# node-waf configuration
48+
.lock-wscript
49+
50+
# Compiled binary addons (https://nodejs.org/api/addons.html)
51+
build/Release
52+
53+
# Dependency directories
54+
#node_modules/
55+
jspm_packages/
56+
57+
# TypeScript v1 declaration files
58+
typings/
59+
60+
# Optional npm cache directory
61+
.npm
62+
63+
# Optional eslint cache
64+
.eslintcache
65+
66+
# Optional REPL history
67+
.node_repl_history
68+
69+
# Output of 'npm pack'
70+
*.tgz
71+
72+
# Yarn Integrity file
73+
.yarn-integrity
74+
75+
# dotenv environment variables file
76+
#.env
77+
#.env.test
78+
79+
# parcel-bundler cache (https://parceljs.org/)
80+
.cache
81+
82+
# next.js build output
83+
.next
84+
85+
# nuxt.js build output
86+
.nuxt
87+
88+
# vuepress build output
89+
.vuepress/dist
90+
91+
# Serverless directories
92+
.serverless/
93+
94+
# FuseBox cache
95+
.fusebox/
96+
97+
# DynamoDB Local files
98+
.dynamodb/
99+

packages/buidler-ganache/.npmrc

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

packages/buidler-ganache/LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Nomic Labs
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

packages/buidler-ganache/README.md

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
[![npm](https://img.shields.io/npm/v/@nomiclabs/buidler-ethers.svg)](https://www.npmjs.com/package/@nomiclabs/buidler-ethers)
2+
3+
# buidler-ganache
4+
5+
This Buidler plugin automatically starts and stop [Ganache](https://github.com/trufflesuite/ganache-core) when running
6+
tests or scripts.
7+
8+
## What
9+
10+
This plugin creates an especial network named `ganache`. When this network is used, a Ganache server will be
11+
automatically started before running tests and scripts, and stopped when finished.
12+
13+
## Installation
14+
15+
```bash
16+
npm install @nomiclabs/buidler-ganache
17+
```
18+
19+
And add the following statement to your `buidler.config.js`:
20+
21+
```js
22+
usePlugin("@nomiclabs/buidler-ganache");
23+
```
24+
25+
## Tasks
26+
27+
This plugin creates no additional tasks.
28+
29+
## Environment extensions
30+
31+
This plugin doesn't extend the Buidler Runtime Environment.
32+
33+
## Usage
34+
35+
There are no additional steps you need to take for this plugin to work.
36+
37+
## Configuration
38+
39+
You can set any of the [Ganache's options](https://github.com/trufflesuite/ganache-core#options) through the `ganache`
40+
network config. All of them are supported, with the exception of `accounts`.
41+
42+
This example sets a larger block gas limit and the default balance of Ganache's accounts.
43+
44+
```js
45+
module.exports = {
46+
defaultNetwork: "ganache",
47+
networks: {
48+
ganache: {
49+
gasLimit: 6000000000,
50+
defaultBalanceEther: 10
51+
}
52+
}
53+
};
54+
```
55+
56+
Note: The `accounts` option it's not currently supported.

packages/buidler-ganache/package.json

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"name": "@nomiclabs/buidler-ganache",
3+
"version": "1.0.0-beta.13",
4+
"description": "Buidler plugin for managing Ganache",
5+
"homepage": "https://github.com/nomiclabs/buidler/tree/master/packages/buidler-ganache",
6+
"repository": "github:nomiclabs/buidler",
7+
"author": "Nomic Labs SRL",
8+
"license": "MIT",
9+
"main": "dist/index.js",
10+
"types": "dist/index.d.ts",
11+
"keywords": [
12+
"ethereum",
13+
"smart-contracts",
14+
"buidler",
15+
"buidler-plugin",
16+
"Ganache",
17+
"testing-network"
18+
],
19+
"scripts": {
20+
"lint:fix": "../../node_modules/.bin/prettier --write 'src/**/*.{js,ts}' 'test/**/*.{js,ts}' && npm run lint-src -- --fix && npm run lint-tests -- --fix",
21+
"lint": "npm run lint-src && npm run lint-tests",
22+
"lint-tests": "../../node_modules/.bin/tslint --config tslint.json --project ./tsconfig.json",
23+
"lint-src": "../../node_modules/.bin/tslint --config tslint.json --project src/tsconfig.json",
24+
"test": "./scripts/run-tests.sh",
25+
"build": "../../node_modules/.bin/tsc --build src",
26+
"build-test": "../../node_modules/.bin/tsc --build .",
27+
"clean": "rm -rf dist build-test"
28+
},
29+
"files": [
30+
"dist/",
31+
"src/",
32+
"LICENSE",
33+
"README.md"
34+
],
35+
"dependencies": {
36+
"debug": "^4.1.1",
37+
"ganache-core": "^2.7.0",
38+
"ts-essentials": "^2.0.7",
39+
"ts-interface-checker": "^0.1.9"
40+
},
41+
"devDependencies": {
42+
"@nomiclabs/buidler": "^1.0.0-beta.13",
43+
"@types/debug": "^4.1.4",
44+
"@types/fs-extra": "^5.1.0",
45+
"chai": "^4.2.0",
46+
"ts-interface-builder": "^0.2.0"
47+
},
48+
"peerDependencies": {
49+
"@nomiclabs/buidler": "^1.0.0-beta.13"
50+
}
51+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
3+
../../node_modules/.bin/mocha --timeout 20000 --exit
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/**
2+
* This module was automatically generated by `ts-interface-builder`
3+
*/
4+
import * as t from "ts-interface-checker";
5+
6+
export const GanacheOptionsTi = t.iface([], {
7+
url: "string",
8+
keepAliveTimeout: t.opt("number"),
9+
accountKeysPath: t.opt("string"),
10+
accounts: t.opt(t.array("object")),
11+
allowUnlimitedContractSize: t.opt("boolean"),
12+
blockTime: t.opt("number"),
13+
dbPath: t.opt("string"),
14+
debug: t.opt("boolean"),
15+
defaultBalanceEther: t.opt("number"),
16+
fork: t.opt(t.union("string", "object")),
17+
forkBlockNumber: t.opt(t.union("string", "number")),
18+
gasLimit: t.opt("number"),
19+
gasPrice: t.opt(t.union("string", "number")),
20+
hardfork: t.opt(
21+
t.union(t.lit("byzantium"), t.lit("constantinople"), t.lit("petersburg"))
22+
),
23+
hdPath: t.opt("string"),
24+
hostname: t.opt("string"),
25+
locked: t.opt("boolean"),
26+
logger: t.opt(
27+
t.iface([], {
28+
log: t.func("void", t.param("msg", "string"))
29+
})
30+
),
31+
mnemonic: t.opt("string"),
32+
network_id: t.opt("number"),
33+
networkId: t.opt("number"),
34+
port: t.opt("number"),
35+
seed: t.opt("any"),
36+
time: t.opt("any"),
37+
totalAccounts: t.opt("number"),
38+
unlockedAccounts: t.opt(t.array("string")),
39+
verbose: t.opt("boolean"),
40+
vmErrorsOnRPCResponse: t.opt("boolean"),
41+
ws: t.opt("boolean")
42+
});
43+
44+
const exportedTypeSuite: t.ITypeSuite = {
45+
GanacheOptionsTi
46+
};
47+
export default exportedTypeSuite;

0 commit comments

Comments
 (0)