Skip to content

Commit

Permalink
Fixed various code quality issues (#273)
Browse files Browse the repository at this point in the history
  • Loading branch information
smartcontracts committed Jun 11, 2019
1 parent 751d18e commit 7da6cd4
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 53 deletions.
38 changes: 20 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ All of the core plasma group projects are hosted inside of the [packages](https:
## Packages

| Package | Version | Description |
| ------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [`@pigi/contracts`](/packages/contracts) | [![npm](https://img.shields.io/npm/v/@pigi/contracts.svg)](https://www.npmjs.com/package/@pigi/contracts) | Core Vyper contracts used for the PG plasma chain.
| [`@pigi/core`](/packages/core) | [![npm](https://img.shields.io/npm/v/@pigi/core.svg)](https://www.npmjs.com/package/@pigi/core) | Core PG plasma chain client modules.
| [`@pigi/plasma-js`](/packages/plasma-js) | [![npm](https://img.shields.io/npm/v/@pigi/plasma-js.svg)](https://www.npmjs.com/package/@pigi/plasma-js) | JS client library for interacting with PG plasma chains.
| [`@pigi/utils`](/packages/utils) | [![npm](https://img.shields.io/npm/v/@pigi/utils.svg)](https://www.npmjs.com/package/@pigi/utils) | Utilities used in many PG projects.
| [`@pigi/vyper-js`](/packages/vyper-js) | [![npm](https://img.shields.io/npm/v/@pigi/vyper-js.svg)](https://www.npmjs.com/package/@pigi/vyper-js) | JavaScript bindings for the Vyper compiler.
| ------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------|
| [`@pigi/contracts`](/packages/contracts) | [![npm](https://img.shields.io/npm/v/@pigi/contracts.svg)](https://www.npmjs.com/package/@pigi/contracts) | Core Vyper contracts used for the PG plasma chain. |
| [`@pigi/core`](/packages/core) | [![npm](https://img.shields.io/npm/v/@pigi/core.svg)](https://www.npmjs.com/package/@pigi/core) | Core PG plasma chain client modules. |
| [`@pigi/plasma-js`](/packages/plasma-js) | [![npm](https://img.shields.io/npm/v/@pigi/plasma-js.svg)](https://www.npmjs.com/package/@pigi/plasma-js) | JS client library for interacting with PG plasma chains. |
| [`@pigi/utils`](/packages/utils) | [![npm](https://img.shields.io/npm/v/@pigi/utils.svg)](https://www.npmjs.com/package/@pigi/utils) | Utilities used in many PG projects. |
| [`@pigi/vyper-js`](/packages/vyper-js) | [![npm](https://img.shields.io/npm/v/@pigi/vyper-js.svg)](https://www.npmjs.com/package/@pigi/vyper-js) | JavaScript bindings for the Vyper compiler. |

## Repo Status
[![Build Status](https://travis-ci.org/plasma-group/pigi.svg?branch=master)](https://travis-ci.org/plasma-group/pigi)

## Contributing
Welcome! If you're looking to contribute to the future of plasma, you're in the right place.
Expand All @@ -31,13 +33,13 @@ We're here to cultivate a welcoming and inclusive contributing environment, and
#### Cloning the Repo
Before you start working on a Plasma Group project, you'll need to clone our GitHub repository:

```
```sh
git clone git@github.com:plasma-group/pigi.git
```

Now, enter the repository.

```
```sh
cd pigi
```

Expand All @@ -57,7 +59,7 @@ You'll need to [install Yarn](https://yarnpkg.com/en/docs/install) before contin

Install all required packages with:

```
```sh
yarn install
```

Expand All @@ -66,13 +68,13 @@ yarn install

Build all packages:

```
```sh
yarn run build
```

Build a specific package or set of packages:

```
```sh
PKGS=your,packages,here yarn run build
```

Expand All @@ -81,13 +83,13 @@ Clean code is the best code, so we've provided tools to automatically lint your

Lint all packages:

```
```sh
yarn run lint
```

Lint a specific package or set of packages:

```
```sh
PKGS=your,packages,here yarn run lint
```

Expand All @@ -97,13 +99,13 @@ It's much easier than trying to fix issues manually.

Fix all packages:

```
```sh
yarn run fix
```

Fix a specific package or set of packages:

```
```sh
PKGS=your,packages,here yarn run fix
```

Expand All @@ -112,19 +114,19 @@ PKGS=your,packages,here yarn run fix

Run all tests:

```
```sh
yarn test
```

Run tests for a specific package or set of packages:

```
```sh
PKGS=your,packages,here yarn test
```

**Contributors: remember to run tests before submitting a pull request!**
Code with passing tests makes life easier for everyone and means your contribution can get pulled into this project faster.

## Credit where credit is due!
## Acknowledgements
We'd like to give a big shoutout to [0x](https://0x.org/) and [Nest.js](https://nestjs.com/) for inspiration about the best ways to design this monorepo.
Please check out their respective repos ([0x](https://github.com/0xProject/0x-monorepo) and [Nest.js](https://github.com/nestjs/nest)) if you're looking for other cool projects to work on :blush:!
31 changes: 19 additions & 12 deletions packages/contracts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ Plasma Group follows a [Contributing Guide and Code of Conduct](https://github.c

### Requirements and Setup
The first step is cloning this repo. Via https:
```
$ git clone https://github.com/plasma-group/plasma-contracts.git

```sh
git clone https://github.com/plasma-group/plasma-contracts.git
```
or ssh:
```
$ git clone git@github.com:plasma-group/plasma-contracts.git
```sh
git clone git@github.com:plasma-group/plasma-contracts.git
```

#### Node.js
Expand All @@ -31,22 +32,28 @@ If you're having trouble getting `plasma-contracts` tests running, please make s

Install all required packages with:

```sh
npm install
```
$ npm install
```

#### Python and Vyper
`plasma-contracts` is written in Vyper, a pythonic Ethereum smart contract language. You'll need [Python 3.6 or above](https://www.python.org/downloads/) to install Vyper.

We reccomend setting up a [virtual environment](https://cewing.github.io/training.python_web/html/presentations/venv_intro.html) instead of installing globally:
```

```sh
python3 -m venv venv
```

To activate:

```sh
source venv/bin/activate
```
$ source venv/bin/activate
```

Install Vyper:
```

```sh
pip3 install vyper
```
Your `venv` must be activated whenever testing or otherwise using Vyper, but it will break the `npm install`, so be sure to `$ deactivate` if you still need to do that and reactivate afterwards.
Expand All @@ -56,7 +63,7 @@ Your `venv` must be activated whenever testing or otherwise using Vyper, but it

Run all tests with:

```
$ npm test
```sh
npm test
```
So that Python and Vyper aren't requirements for our other components, we do include a `compiled-contracts` folder which contains JS exports of the bytecode and ABI. Compilation is done automatically before testing.
6 changes: 3 additions & 3 deletions packages/operator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
Deploy your own plasma chain!

## Prerequisites
- `node.js` -- version 11.6.0
- `git` -- version 2.17.1
- Build essentials or similar (specifically `g++` -- version 7.3.1)
- `node.js` (v11.6.0)
- `git` (v2.17.1)
- Build essentials or similar (specifically `g++` v7.3.1)

## Setup
To deploy a new Plasma Chain, use the following commands:
Expand Down
6 changes: 3 additions & 3 deletions packages/predicates/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
`@pigi/predicates` is a set of basic predicates which are critical for the basic functioning of a plasma chain.

## Documentation
Detailed documentation for `predicates` is available on ReadTheDocs: https://docs.plasma.group/projects/utils/en/latest/.
Detailed documentation for `predicates` is available on ReadTheDocs: <https://docs.plasma.group/projects/utils/en/latest/.>

## Installation
There are several easy ways to start using `@pigi/predicates`! For now we just describe the node install.

### Node.js
If you're developing a `Node.js` application, you can simply install `@pigi/predicates` via `npm`:

```
$ npm install --save @pigi/predicates
```sh
npm install --save @pigi/predicates
```

## Contributing
Expand Down
2 changes: 1 addition & 1 deletion packages/types/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"extends": "./../../tsconfig.json",
"compilerOptions": {
"outDir": "./build",
"baseUrl": ".",
"baseUrl": "."
},
"include": ["types"]
}
6 changes: 3 additions & 3 deletions packages/utils/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ There are several easy ways to start using `plasma-utils`!
### Node.js
If you're developing a `Node.js` application, you can simply install `plasma-utils` via `npm`:

```
$ npm install --save plasma-utils
```sh
npm install --save plasma-utils
```

### Browser
Expand Down Expand Up @@ -48,7 +48,7 @@ cd plasma-utils

#### Node.js
`plasma-utils` is tested and built with [`Node.js`](https://nodejs.org/en/).
Although you **do not need [`Node.js`] to use this library in your application**, you'll need to install `Node.js` (and it's corresponding package manager, `npm`) for your system before contributing.
Although you **do not need `Node.js` to use this library in your application**, you'll need to install `Node.js` (and it's corresponding package manager, `npm`) for your system before contributing.

We've provided a [detailed explanation of now to install `Node.js`](https://docs.plasma.group/en/latest/src/pigi/reference.html#installing-node-js) on Windows, Mac, and Linux.

Expand Down
48 changes: 36 additions & 12 deletions packages/vyper-js/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ As a result, you currently need to [install Vyper](https://vyper.readthedocs.io/
It's pretty easy to use `vyper-js` in a `Node.js` application.
Simply install the package via `npm`:

```
```sh
npm install --save @pigi/vyper-js
```

Expand All @@ -29,23 +29,47 @@ Check out our detailed [Contributing Guide](https://github.com/plasma-group/pigi
## Documentation
The `vyper-js` API is pretty simple - there's currently only a single function!

### vyperjs.compile
### Data Structures

#### VyperCompilationResult

```ts
interface VyperCompilationResult {
bytecode: string
bytecodeRuntime: string
abi: VyperAbiMethod[]
sourceMap: VyperSourceMap
methodIdentifiers: { [key: string]: string }
version: string
}
```

##### Description
Result of compiling a Vyper file.

##### Fields
- `bytecode` - `string`: EVM bytecode of the compiled contract.
- `bytecodeRuntime` - `string`: [Runtime bytecode](https://ethereum.stackexchange.com/questions/32234/difference-between-bytecode-and-runtime-bytecode) for the contract.
- `abi` - `VyperAbiItem | VyperAbiItem[]`: Ethereum [contract ABI](https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI).
- `sourceMap` - `Object`: Source mapping object.
- `breakpoints` - `number[]`: List of lines that have breakpoints.
- `pcPosMap` - `{ [key: string]: [number, number] }`: Mapping of opcode positions to `[line_number, column_offset]` in the original file.
- `methodIdentifiers` - `{ [key: string]: string }`: Mapping of method signatures to their unique hashes.
- `version` - `string`: Vyper compiler version used to compile the file.

### Methods

#### compile

```js
vyperjs.compile(path)
async function compile(path: string): Promise<VyperCompilationResult>
```

##### Description
Compiles the vyper contract at the given path and outputs the compilation result

#### Params
1. `path` - `string`: Path to the Vyper file to compile.

#### Returns
1. `Object`: The compilation result.
* `bytecode` - `string`: EVM bytecode of the compiled contract.
* `bytecodeRuntime` - `string`: [Runtime bytecode](https://ethereum.stackexchange.com/questions/32234/difference-between-bytecode-and-runtime-bytecode) for the contract.
* `abi` - `VyperAbiItem | VyperAbiItem[]`: Ethereum [contract ABI](https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI).
* `sourceMap` - `Object`: Source mapping object.
* `breakpoints` - `number[]`: List of lines that have breakpoints.
* `pcPosMap` - `{ [key: string]: [number, number] }`: Mapping of opcode positions to `[line_number, column_offset]` in the original file.
* `methodIdentifiers` - `{ [key: string]: string }`: Mapping of method signatures to their unique hashes.
* `version` - `string`: Vyper compiler version used to compile the file.
`Promise<VyperCompilatinResult>`: The compilation result.
2 changes: 1 addition & 1 deletion packages/watch-eth/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ It's therefore important that these applications have a way to watch for events
### npm
You can install `watch-eth` via `npm`:

```
```sh
npm install --save watch-eth
```

Expand Down

0 comments on commit 7da6cd4

Please sign in to comment.