Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Local development #12

Merged
merged 23 commits into from
Jan 24, 2021
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
4cf49b1
Pin node version to 12.19.0 using .nvmrc.
tobyclemson Nov 12, 2020
07ca31e
Add .nvmrc with latest supported Node.JS across all platforms.
tobyclemson Nov 12, 2020
bcf9a09
Get unit tests running without needing globally installed dependencies.
tobyclemson Nov 12, 2020
d98ebab
Update README.md with getting started information. Format to 80 docs …
tobyclemson Jan 19, 2021
4f51b68
Add missing test dependencies.
tobyclemson Jan 19, 2021
524f2af
Clean up comments in truffle-config.js. Only load .secret when needed.
tobyclemson Jan 19, 2021
3f15345
Add first pass at local build.
tobyclemson Jan 19, 2021
dd86ccb
Add rake task to run integration tests.
tobyclemson Jan 20, 2021
26f4367
Determine accounts and users dynamically in tests. Reformat.
tobyclemson Jan 20, 2021
4914071
Fix coverage.
tobyclemson Jan 20, 2021
02a2c9b
Add rake task to run test coverage.
tobyclemson Jan 20, 2021
5024da7
Add solhint. Fix as many warnings as possible.
tobyclemson Jan 20, 2021
7b6eb1a
Add prettier and prettier-solidity.
tobyclemson Jan 21, 2021
62e5b10
Add eslint for tests. Fix linting issues in all test files.
tobyclemson Jan 21, 2021
b62c7aa
Rename migrate and verify scripts.
tobyclemson Jan 21, 2021
542957c
Update README. Add guides for setting up development machine.
tobyclemson Jan 21, 2021
f1c36e5
Fix coverage.
tobyclemson Jan 21, 2021
c2a97b5
Merge remote-tracking branch 'origin/master' into local-development
tobyclemson Jan 21, 2021
a4bb97e
added the new BosonRouter contract references
thecryptofruit Jan 24, 2021
f752c51
Just had to add Fedora :p
thecryptofruit Jan 24, 2021
26cbb2d
removed "not audited" comment
thecryptofruit Jan 24, 2021
962bb1a
removed "not audited" comment
thecryptofruit Jan 24, 2021
f4ab218
Rename `helpers` to `constants` in `utils.js`.
tobyclemson Jan 24, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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