open-index/open-npm huggingface dataset:
npm package: @rgbk/contracts
Description: Collection of RigoBlock's smart contracts and deployment/compilation scripts.
Latest version: 0.4.0

# Contracts

Collection of RigoBlock's smart contracts and deployment/compilation scripts.

## Setup

### Available Scripts

In the project directory, you can run:

### `yarn ganache`

Starts the Ganache-cli server on port 8545 and with network Id 5777.

### `yarn compile`

Compiles all solidity contracts and generates the JSON artifacts. The contract's abi and address are stored under `networks[networkId]`.

### `yarn build`

In order: compiles all contracts, deleted _dist_ folder, bootstraps contract on ganache, builds with webpack. **Requires Ganache to be up prior to running the command.**

### `yarn test`

Runs tests for the solidity contracts. **Ganache must not be up** when running this command as it will automatically start it before each test suite.

### `yarn lint`

Lints all JS files.

### `yarn deploy`

Launches the smart contract deployment CLI.

## Contract deployment

-   Create a new branch (eg. `git checkout -b feature/kovan-contracts-deployment`)
-   From the `rigoblock-monorepo/packages/contracts` directory, launch `yarn deploy`
-   In the CLI:
    -   select the network where you wish to deploy the contract
    -   Insert your public key (wallet address)
    -   Insert the name of the contract to be deployed
    -   Insert the arguments required from the contract, if any, separated by a comma
    -   Insert your account mnemonic
-   The `contracts/artifacts` folder will now have uncommitted changes, commit them.
-   Push the changes to Github (`git push --set-upstream origin your-branch-name`)
-   Open a pull request with your changes and await approval.

> Note: At the current time it is necessary to pass the account MNEMONIC rather than the private key.

Here is a demo of how the script works:

![kapture 2018-10-25 at 16 06 14](https://user-images.githubusercontent.com/11726051/47506264-fc42b600-d86f-11e8-9f16-1df1da3f1dc1.gif)

## Writing Tests

Read the [testing documentation.](docs/testing.md)

## Contributing

Read our [contribution guidelines](https://github.com/RigoBlock/rigoblock-monorepo/blob/master/CONTRIBUTING.md).
npm package: @rgbk/data-collector
Description: Rigoblock data collector
Latest version: 0.1.0

# Data Collector

A utility package to gather and save an overview and pricing information about the top traded tokens on Ethereum.

## Services

### Bull

Bull is a package that allows us to create queues of repeatable jobs, configurated using a cron expression. Our package is set up to have one queue for each different task. Tasks can be found in the folder of the same name, while queues are listed in `src/config.ts`.
To add a new queue, simply add it to the `config.ts` file following the template we used.
To add a new task, write an async function that accepts a `job` parameter and returns a promise.

### Arena

Arena is an interactive UI dashboard for Bull and Bee Queue. It allows us to monitor the status of jobs, see the cause of failure in case they failed and also remove or rerun jobs.

## Setup

Build the docker image (from the monorepo root).

    docker-compose -f ./packages/data-collector/docker-compose.prod.yml build --build-arg NPM_KEY=<insert npm key> bull

## Run the whole stack (from the monorepo root).

```sh
docker-compose -f ./packages/stats/docker-compose.prod.yml up
```

## Security and Authorizations

The [env file](https://github.com/RigoBlock/rigoblock-monorepo/blob/master/packages/data-collector/env.couchdb) contains the username and password to access CouchDB. This is where we set the password for the database. The password stored in this file must be HASHED, however its non-hashed version will be the one used by the CouchDB client and when accessing `localhost:5984/_utils`.

> CouchDB requires the hashed password specified in the env.couchdb file.
>
> Any other client including the web UI requires the password in clear sent through the REST endpoint

We have updated the index of the file with the following command:

    git update-index --skip-worktree env-couchdb

This way the file is stored on git, but any changes to the local file will not be tracked by git. However, if we update the file on master, and try to pull the changes while having local changes to it, git will show a conflict and prompt for resolution.

### Permissions

The databases are read-only for non-admins, thanks to the validation function in [initDatabase.ts](https://github.com/RigoBlock/rigoblock-monorepo/blob/master/packages/data-collector/src/initDatabase.ts). This file creates the databases if they do not exist, creates an index and sets the validation function.

In case we need to update the validation function on any of the DBs on staging, we can execute the file like this:

```javascript
COUCHDB_HOST=nameofthehost COUCHDB_PORT=portnumber COUCHDB_PASSWORD=password node dist/initDatabase.js
```

## Tasks

-   [fetchInfo](docs/tasks/fetch_info.md)
-   [fetchNews](docs/tasks/fetch_news.md)

## Contributing

Read our [contribution guidelines](https://github.com/RigoBlock/rigoblock-monorepo/blob/master/CONTRIBUTING.md).
npm package: @rgbk/deployer
Description: Smart contract deployer
Latest version: 1.0.0

## Smart Contracts Deployer

A packages that facilitates the compilation and deployment of smart contracts. Deployer will automatically fetch and download the appropriate version of _Sol Compiler_ to compile each contract.

#### This package is a fork from the 0xproject Monorepo. [Link to the original package](https://github.com/0xProject/0x-monorepo/tree/d08bfbf7054d0d98680daab3d1fdc0ac878dcc16/packages/deployer)

## Importing the package

```javascript
import { Deployer, Compiler } from '@rgbk/deployer';
```

or

```javascript
const Deployer = require('@rgbk/deployer').Deployer;
const Compiler = require('@rgbk/deployer').Compiler;
```

## Available Scripts

In the project directory, you can run:

### `yarn build`

Builds the app for production to the `dist` folder.

### `yarn build:watch`

Builds the app and watches for changes.

### `yarn run_mocha`

Runs tests with Mocha and Chai.

### `yarn test`

Builds the app, transpiling TypeScript, then runs `yarn run_mocha`

### `yarn lint`

Lints all typescript files.

### Note

When developing the package locally, make sure to run `yarn bootstrap` in the root directory of the monorepo, and build the package before running it in other packages.
npm package: @rgbk/stats
Description: Rigoblock stats collector
Latest version: 0.2.0

# Stats

A utility package built with [bull](https://github.com/OptimalBits/bull) to gather statistics on our pools.

![](rigoblockStats.svg)

## Services

### Traefik

Træfik is a modern HTTP reverse proxy and load balancer that makes deploying microservices easy.

### Chronograf

Chronograf is a UI dashboard that allows us to see the data that we have stored in InfluxDB and build robust queries and alerts. We have our dashboards exported and saved in the `dashboards` folder, so that they can be imported on Chronograf locally in case we need them for testing.

### Bull

Bull is a package that allows us to create queues of repeatable jobs, configurated using a cron expression. Our package is set up to have one queue for each different task. Tasks can be found in the folder of the same name, while queues are listed in `src/config.ts`.
To add a new queue, simply add it to the `config.ts` file following the template we used.
To add a new task, write an async function that accepts a `job` and a `web3` parameters and returns a promise. Make sure to wrap the task with `web3ErrorWrapper` to handle the closing of the websocket connection and possible web3 errors.

### Arena

Arena is an interactive UI dashboard for Bull and Bee Queue. It allows us to monitor the status of jobs, see the cause of failure in case they failed and also remove or rerun jobs.

## Setup

Add `rbstats` system user:

```sh
adduser rbstats
```

Clone the repo into `rbstats` home:

```sh
su rbstats
cd ~
clone https://github.com/RigoBlock/rigoblock-monorepo
```

Copy help script into the home directory:

```sh
cp rigoblock-monorepo/packages/stats/scripts/* ./
chmod u+x *.sh
```

Create data diretory:

    mkdir data

Create `acme.json` file. This file contains private keys. Protect it.

    touch rigoblock-monorepo/packages/stats/config/traefik/acme.json
    chmod 600 rigoblock-monorepo/packages/stats/config/traefik/acme.json

Build the docker image (from the monorepo root).

    docker-compose -f ./packages/stats/docker-compose.prod.yml build --build-arg NPM_KEY=<insert npm key> bull

## Run the whole stack (from the monorepo root).

```sh
docker-compose -f ./packages/stats/docker-compose.prod.yml up
```

## Additional resources

### Data retention

Check the [data retention](docs/data_retention.md) readme.

### Task descriptions

-   [calculateBalance](docs/tasks/calculate_balance.md)
-   [calculateEthBalance](docs/tasks/calculate_eth_balance.md)
-   [fetchDragos](docs/tasks/fetch_dragos.md)
-   [getSharePrice](docs/tasks/get_share_prices.md)
-   [getTotalSupply](docs/tasks/get_totalsupply.md)
-   [calculateNav](docs/tasks/calculate_nav.md)

## Data currently being fetched

-   List of all Dragos on mainnet, ropsten and kovan

For each drago, we are fetching:

-   ETH balance
-   GNT balance
-   GRG balance
-   MKR balance
-   WETH balance
-   USDT balance
-   ZRX balance
-   ZRXW balance
-   USDTW balance
-   GRGW balance
-   Total supply
-   Buy-Sell prices

## Contributing

Read our [contribution guidelines](https://github.com/RigoBlock/rigoblock-monorepo/blob/master/CONTRIBUTING.md).