Skip to content

Commit

Permalink
Merge pull request #12 from bosonprotocol/local-development
Browse files Browse the repository at this point in the history
Local development
  • Loading branch information
tobyclemson authored Jan 24, 2021
2 parents 42a19da + f4ab218 commit 93b65b9
Show file tree
Hide file tree
Showing 73 changed files with 18,318 additions and 11,493 deletions.
6 changes: 6 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

PROJECT_DIR="$(pwd)"

PATH_add ${PROJECT_DIR}
PATH_add ${PROJECT_DIR}/node_modules/.bin
19 changes: 19 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"extends": [
"eslint:recommended",
"prettier"
],
"env": {
"node": true,
"es6": true,
"commonjs": true,
"mocha": true,
"truffle/globals": true
},
"parserOptions": {
"ecmaVersion": 2018
},
"plugins": [
"truffle"
]
}
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ node_modules
/build
.etherlime-store
/localDeploy
/run

# Secrets
.secret
Expand All @@ -21,8 +22,8 @@ node_modules
*.ipr
.idea/

#Test Coverage
# Test Coverage
coverage*

#Personal Preferences
# Personal Preferences
.vscode
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
10.23.0
25 changes: 25 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"overrides": [
{
"files": "*.sol",
"options": {
"printWidth": 80,
"tabWidth": 4,
"useTabs": false,
"singleQuote": false,
"bracketSpacing": false,
"explicitTypes": "always"
}
},
{
"files": "*.js",
"options": {
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"singleQuote": true,
"bracketSpacing": false
}
}
]
}
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.7.2
48 changes: 12 additions & 36 deletions .solcover.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,16 @@
const fs = require('fs');

const privateKeys =
JSON.parse(fs.readFileSync('config/accounts.json'))["private_keys"]
const accounts = Object.entries(privateKeys)
.map(entry => ({
secretKey: `0x${entry[1]}`,
balance: '0x8ac7230489e80000'
}))

module.exports = {
port: 8555,
testCommand: 'mocha --timeout 5000',
measureStatementCoverage: false,
providerOptions: {
//Default Accounts with preminted 10ETH
accounts: [
{ secretKey: '0x7ab741b57e8d94dd7e1a29055646bafde7010f38a900f55bbd7647880faa6ee8',
balance: "0x8ac7230489e80000"
},
{ secretKey: '0x2030b463177db2da82908ef90fa55ddfcef56e8183caf60db464bc398e736e6f',
balance: "0x8ac7230489e80000"
},
{ secretKey: '0x62ecd49c4ccb41a70ad46532aed63cf815de15864bc415c87d507afd6a5e8da2',
balance: "0x8ac7230489e80000"
},
{ secretKey: '0xf473040b1a83739a9c7cc1f5719fab0f5bf178f83314d98557c58aae1910e03a',
balance: "0x8ac7230489e80000"
},
{ secretKey: '0x823d590ed2cb5e8493bb0efc834771c1cde36f9fc49b9fe3620ebd0754ad6ea2',
balance: "0x8ac7230489e80000"
},
{ secretKey: '0xd6d710943471e4c37ceb787857e7a2b41ca57f9cb4307ee9a9b21436a8e709c3',
balance: "0x8ac7230489e80000"
},
{ secretKey: '0x187bb12e927c1652377405f81d93ce948a593f7d66cfba383ee761858b05921a',
balance: "0x8ac7230489e80000"
},
{ secretKey: '0xf41486fdb04505e7966c8720a353ed92ce0d6830f8a5e915fbde735106a06d25',
balance: "0x8ac7230489e80000"
},
{ secretKey: '0x6ca40ba4cca775643398385022264c0c414da1abd21d08d9e7136796a520a543',
balance: "0x8ac7230489e80000"
},
{ secretKey: '0xfac0bc9325ad342033afe956e83f0bf8f1e863c1c3e956bc75d66961fe4cd186',
balance: "0x8ac7230489e80000"
},
]
}
};
providerOptions: { accounts }
};
15 changes: 15 additions & 0 deletions .solhint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"extends": "solhint:recommended",
"rules": {
"compiler-version": [
"error",
"^0.6.6"
],
"reason-string": [
"warn",
{
"maxLength": 64
}
]
}
}
1 change: 0 additions & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# Contributor Covenant Code of Conduct

## Our Pledge
Expand Down
5 changes: 5 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
source 'https://rubygems.org'

gem 'rake', '~> 13.0'
gem 'random-port', '~> 0.5'
gem 'childprocess', '~> 4.0'
17 changes: 17 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
GEM
remote: https://rubygems.org/
specs:
childprocess (4.0.0)
rake (13.0.3)
random-port (0.5.1)

PLATFORMS
x86_64-darwin-19

DEPENDENCIES
childprocess (~> 4.0)
rake (~> 13.0)
random-port (~> 0.5)

BUNDLED WITH
2.2.6
177 changes: 149 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,162 @@
# Core prototype
Code repository for Boson Protocol smart contracts. The description of the contracts and process can be found in [doc_contracts.md](doc_contracts.md).
[![banner](docs/assets/banner.png)](https://bosonprotocol.io)

## Install
Install dependencies from project root folder:
<h1 align="center">Boson Protocol Contracts</h1>

Smart contracts for Boson Protocol.

**Table of Contents**

- [Local Development](#local-development)
- [Testing](#testing)
- [Code Linting](#code-linting)
- [Documentation](#documentation)
- [Contributing](#contributing)
- [License](#license)

## Local Development

### Prerequisites

For local development of the contracts, your development machine will need a few
tools installed.

At a minimum, you'll need:
* Node (10.23.0)
* NPM (> 6)
* Ruby (2.7.2)
* Bundler (> 2)

For instructions on how to get set up with these specific versions:
* See the [OS X guide](docs/setup/osx.md) if you are on a Mac.
* See the [Linux guide](docs/setup/linux.md) if you use a Linux distribution.

### Running the build

We have a fully automated local build process to check that your changes are
good to be merged. To run the build:

```shell script
./go
````

By default, the build process fetches all dependencies, compiles, lints,
formats and tests the codebase. There are also tasks for each step. This and
subsequent sections provide more details of each of the tasks.

To fetch dependencies:

```shell script
./go dependencies:install
```
$ npm install @openzeppelin/contracts truffle-assertions ethers

To compile the contracts:

```shell script
./go contracts:compile
```

Migrations are using HDWalletProvider, install it if you need it:
## Testing

### Unit Tests

All contracts are thoroughly unit tested using
[Truffle's JavaScript testing](https://www.trufflesuite.com/docs/truffle/testing/writing-tests-in-javascript)
support.
To run the unit tests:
```shell script
./go tests:unit
```
$ npm install @truffle/hdwallet-provider
By default, the build system automates starting and stopping
[Ganache](https://www.trufflesuite.com/docs/ganache/overview) on a free port in
the background ready for each test run.
If instead, you want to run the tests against an existing node, Ganache or
otherwise, create a JSON file creating accounts in the same format as
`config/accounts.json` and execute:
```shell script
./go "tests:unit[<port>,<path-to-accounts-json>]"
```
## Contracts initialization
[Migrations script](./migrations/2_deploy_contracts.js) for Truffle also does this initialization:
- ERC1155ERC721.setApprovalForAll(contractVoucherKernel.address, 'true')
- ERC1155ERC721.setVoucherKernelAddress(contractVoucherKernel.address)
- VoucherKernel.setBosonRouterAddress(bosonRouter.address)
### Coverage
We use [solidity-coverage](https://github.com/sc-forks/solidity-coverage) to
provide test coverage reports.
To check the test coverage:
```shell script
./go tests:coverage
```
`solidity-coverage` runs its own instance of Ganache internally, as well as
instrumenting contracts before running.
### Interaction Tests
To run the interaction tests, follow the instructions in the
[interaction tests README.md](testUserInteractions/README.md).
## Code Linting
Both the contracts themselves and the tests are linted and formatted as part of
the build process.
For the contracts, we use:
* [solhint](https://protofire.github.io/solhint/) for linting
* [prettier-solidity](https://github.com/prettier-solidity/prettier-plugin-solidity)
for formatting
For the tests, we use:
* [eslint](https://eslint.org/) for linting
* [prettier](https://prettier.io/) for formatting
To lint the contracts:
```shell script
./go contracts:lint
```
This will check if the linter is satisfied. If instead you want to attempt to
automatically fix any linting issues:
```shell script
./go contracts:lint_fix
```
To check the formatting of the contracts:
```shell script
./go contracts:format
```
To automatically fix formatting issues:
```shell script
./go contracts:format_fix
```
Similarly, for the tests, to perform the same tasks:
```shell script
./go tests:lint
./go tests:lint_fix
./go tests:format
./go tests:format_fix
```
## Deployed contracts
Contract are deployed on Kovan testnet at addresses:
ERC1155ERC721: 0xF3aA8eB3812303F6c86c136557bC23E48d634B58
VoucherKernel: 0x1806312211bd1521430C953683038d6263580feE
Cashier: 0xaaf749c8e6e37b51410F1810ADcAEED18d0C166F
The frontend is currently pointing to Kovan deployment.
## Documentation
Contract are also deployed on Ropsten testnet at addresses:
ERC1155ERC721: 0xe7028d66222aD1AfEB0098956347A6284443bd16
VoucherKernel: 0xa93f95bf0039CE30957b77A6638e2e273598D576
Cashier: 0x014b8baF57bA77FaE23075aa93c2B768eeb440bD
For an overview of the contracts and their responsibilities, see
[Overview](docs/contracts/overview.md).
## Progress
See the project board at [https://github.com/bosonprotocol/bsn-core-prototype/projects/2](https://github.com/bosonprotocol/bsn-core-prototype/projects/2).
## Contributing
TODO: Add contribution notes.
## Coverage
Test coverage is executed by running the following command:
## License
```
npm run coverage
Licensed under [LGPL v3](LICENSE).
Loading

0 comments on commit 93b65b9

Please sign in to comment.