Skip to content

Commit

Permalink
Merge pull request #322 from energywebfoundation/master
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
kosecki123 authored Nov 26, 2019
2 parents 13ba37e + 529c4b5 commit 07de6a7
Show file tree
Hide file tree
Showing 266 changed files with 8,633 additions and 6,384 deletions.
1 change: 1 addition & 0 deletions .adr-dir
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
doc/architecture/decisions
31 changes: 19 additions & 12 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
# ------- NEEDED --------- #
MODE="production"
# ------- REQUIRED --------- #
MODE=production

# URLs
WEB3="http://localhost:8545"
BACKEND_URL="http://localhost:3030"
WEB3=http://localhost:8545
BACKEND_URL=http://localhost:3030
BACKEND_PORT=3030
UI_BASE_URL="http://localhost:3000"
ENERGY_API_BASE_URL="http://localhost:3031"
BLOCKCHAIN_EXPLORER_URL="https://volta-explorer.energyweb.org"
UI_BASE_URL=http://localhost:3000
ENERGY_API_BASE_URL=http://localhost:3031
BLOCKCHAIN_EXPLORER_URL=https://volta-explorer.energyweb.org

# Secret keys
DEPLOY_KEY="d9066ff9f753a1898709b568119055660a77d9aae4d7a4ad677b8fb3d2a571e5"
MATCHER_PRIV_KEY="0xe9a63e116f72c2e368376eb88c22fecf2a5e94a93464ff8802cf97caac657548"
DEPLOY_KEY=d9066ff9f753a1898709b568119055660a77d9aae4d7a4ad677b8fb3d2a571e5
MATCHER_PRIV_KEY=0xe9a63e116f72c2e368376eb88c22fecf2a5e94a93464ff8802cf97caac657548
MATCHER_INTERVAL=15
EVENT_LISTENER_PRIV_KEY=0x968cc146af9c9d3ac08cca0dd3f915ed5a0966c118e26fd5e99066b0ff8bc060

# ORIGIN_BACKEND (optional)
ORM_TYPE=sqlite
ORM_DATABASE_DOCKER=FALSE

# ------- OPTIONAL ------- #
MANDRILL_API_KEY="<API_KEY>"
EMAIL_FROM="[email protected]"
EMAIL_REPLY_TO="[email protected]"
MANDRILL_API_KEY=<API_KEY>
EMAIL_FROM=[email protected]
EMAIL_REPLY_TO=[email protected]

SOLAR_SIMULATOR_DEPLOY_PAST_READINGS=false
9 changes: 6 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ cache:
- packages/user-registry/build
- packages/user-registry/dist
- packages/origin-backend/dist
- packages/origin-backend-client/dist
- packages/asset-registry/schemas
- packages/asset-registry/build
- packages/asset-registry/dist
Expand All @@ -24,10 +25,10 @@ cache:
- packages/market/schemas
- packages/market/build
- packages/market/dist
- packages/market-matcher/schemas
- packages/market-matcher/dist
- packages/erc-test-contracts/build
- packages/erc-test-contracts/dist
- packages/market-matcher-core/dist
- packages/event-listener/dist


before_install:
- sh scripts/restore-original-timestamps.sh
Expand All @@ -43,10 +44,12 @@ before_deploy:
install:
- yarn
- yarn build
- yarn build:ui

script:
- yarn lint
- yarn test:ci:contracts
- yarn test:ci:contracts:deployment
- yarn test:ci:apps
- yarn test:ci:ui

Expand Down
18 changes: 12 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@

**Origin** is a set of toolkits that together provide a system for issuance and management of Energy Attribute Certificates (EACs). This repository is an entry point to Origin systems. It has a goal of explaining briefly the whole system and providing you with insight and info where to explore next.

<p align="center">
<a href="https://travis-ci.com/energywebfoundation/origin"><img src="https://img.shields.io/travis/com/energywebfoundation/origin/master"/></a>
<a href="https://github.com/renovatebot/renovate"><img src="https://badges.renovateapi.com/github/energywebfoundation/origin"/></a>
</p>

## Table of Contents
- [Packages](#packages)
- [Installation](#installation)
Expand All @@ -24,18 +29,20 @@
| Package | Stable | Canary | Description |
| --- | --- | --- | --- |
| [`@energyweb/asset-registry`](/packages/asset-registry) | [![npm](https://img.shields.io/npm/v/@energyweb/asset-registry.svg)](https://www.npmjs.com/package/@energyweb/asset-registry) | [![npm](https://img.shields.io/npm/v/@energyweb/asset-registry/canary)](https://www.npmjs.com/package/@energyweb/asset-registry) | Contracts and client for Asset Registry |
| [`@energyweb/market-matcher`](/packages/market-matcher) | [![npm](https://img.shields.io/npm/v/@energyweb/market-matcher.svg)](https://www.npmjs.com/package/@energyweb/market-matcher) | [![npm](https://img.shields.io/npm/v/@energyweb/market-matcher/canary)](https://www.npmjs.com/package/@energyweb/market-matcher) | Off-chain services for demand and supply matching |
| [`@energyweb/market-matcher-core`](/packages/market-matcher-core) | [![npm](https://img.shields.io/npm/v/@energyweb/market-matcher-core.svg)](https://www.npmjs.com/package/@energyweb/market-matcher-core) | [![npm](https://img.shields.io/npm/v/@energyweb/market-matcher-core/canary)](https://www.npmjs.com/package/@energyweb/market-matcher-core) | Matching rules and logic for market-matcher |
| [`@energyweb/market`](/packages/market) | [![npm](https://img.shields.io/npm/v/@energyweb/market.svg)](https://www.npmjs.com/package/@energyweb/market) | [![npm](https://img.shields.io/npm/v/@energyweb/market/canary)](https://www.npmjs.com/package/@energyweb/market/canary) | Contacts and client for Origin Market |
| [`@energyweb/origin`](/packages/origin) | [![npm](https://img.shields.io/npm/v/@energyweb/origin.svg)](https://www.npmjs.com/package/@energyweb/origin) | [![npm](https://img.shields.io/npm/v/@energyweb/market/canary)](https://www.npmjs.com/package/@energyweb/market/canary) | Contracts and client Origin ceritifacts |
| [`@energyweb/origin-backend-client`](/packages/origin-backend-client) | [![npm](https://img.shields.io/npm/v/@energyweb/origin-backend-client.svg)](https://www.npmjs.com/package/@energyweb/origin-backend-client) | [![npm](https://img.shields.io/npm/v/@energyweb/origin-backend-client/canary)](https://www.npmjs.com/package/@energyweb/origin-backend-client) | Client library for off-chain data source |
| [`@energyweb/origin-backend`](/packages/origin-backend) | [![npm](https://img.shields.io/npm/v/@energyweb/origin-backend.svg)](https://www.npmjs.com/package/@energyweb/origin-backend) | [![npm](https://img.shields.io/npm/v/@energyweb/origin-backend/canary)](https://www.npmjs.com/package/@energyweb/origin-backend) | Example backend for storing off-chain meta-data |
| [`@energyweb/user-registry`](/packages/user-registry) | [![npm](https://img.shields.io/npm/v/@energyweb/user-registry.svg)](https://www.npmjs.com/package/@energyweb/user-registry) | [![npm](https://img.shields.io/npm/v/@energyweb/user-registry/canary)](https://www.npmjs.com/package/@energyweb/user-registry) | Contracts and client User Registry |
| [`@energyweb/utils-general`](/packages/utils-general) | [![npm](https://img.shields.io/npm/v/@energyweb/utils-general.svg)](https://www.npmjs.com/package/@energyweb/utils-general) | [![npm](https://img.shields.io/npm/v/@energyweb/utils-general/canary)](https://www.npmjs.com/package/@energyweb/utils-general) | Utilities |

### UI and demo
### Applications, Infrastructure and Demo

| Package | Description |
| --- | --- |
| [`@energyweb/origin-ui`](/packages/origin-ui) | UI for Origin |
| [`@energyweb/market-matcher`](/packages/market-matcher) | Off-chain agent for demand and supply matching |
| [`@energyweb/solar-simulator`](/packages/solar-simulator) | Solar production and consumption simulator |
| [`@energyweb/event-listener`](/packages/event-listener) | Listens to Origin events and sends notifications |
| [`@energyweb/utils-demo`](/packages/utils-demo) | Demo deployment and configuration utilities |
Expand Down Expand Up @@ -96,10 +103,9 @@ This section lists key entry points to start your journey with Origin.
3. [origin](https://github.com/energywebfoundation/origin/tree/master/packages/origin) - a heart of Origin systems, contains logic for storing and transferring Energy Attribute Certificates (as a form of unique [ERC721](http://erc721.org/) tokens). This library also has a more general construct called **TradeableEntity** that can be used to wrap, as name suggests, other tradeable entities, such as [Power Purchase Agreements](https://en.wikipedia.org/wiki/Power_purchase_agreement) or certificate bundles.
4. [market](https://github.com/energywebfoundation/origin/tree/master/packages/market) - a library that allows to create demand (for buyers), supply (for sellers) and agreements between buyers and sellers.
5. [market-matcher](https://github.com/energywebfoundation/origin/tree/master/packages/market-matcher) - the most important part of marketplace, guarantees automatic matching of supply and demand between sellers and buyers. Matching rules can be highly customized and afterwards the algorithm can be tested by running matching simulator.
6. [erc-test-contracts](https://github.com/energywebfoundation/origin/tree/master/packages/erc-test-contracts) - Test ERC20 token for demo purposes, especially for doing an on-chain test purchase of a certificate using tokens
7. [utils-general](https://github.com/energywebfoundation/origin/tree/master/packages/utils-general) - Contains logic for more straightforward interaction with contracts, such as watching events. It is also a base layer for other libraries to build upon. It provides a foundation for things like off-chain data storage that is universal for all entities.
8. [solar-simulator](https://github.com/energywebfoundation/origin/tree/master/packages/solar-simulator) - This service simulates smart-meter readings based on example solar data from whole year in 15-mins intervals. Also allows you to generate the config based on data from public I-REC registry.
9. [event-listener](https://github.com/energywebfoundation/origin/tree/master/packages/event-listener) - Event listeners listen to events on the blockchain and react accordingly.
6. [utils-general](https://github.com/energywebfoundation/origin/tree/master/packages/utils-general) - Contains logic for more straightforward interaction with contracts, such as watching events. It is also a base layer for other libraries to build upon. It provides a foundation for things like off-chain data storage that is universal for all entities.
7. [solar-simulator](https://github.com/energywebfoundation/origin/tree/master/packages/solar-simulator) - This service simulates smart-meter readings based on example solar data from whole year in 15-mins intervals. Also allows you to generate the config based on data from public I-REC registry.
8. [event-listener](https://github.com/energywebfoundation/origin/tree/master/packages/event-listener) - Event listeners listen to events on the blockchain and react accordingly.

## Deployment

Expand Down
19 changes: 19 additions & 0 deletions doc/architecture/decisions/0001-record-architecture-decisions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# 1. Record architecture decisions

Date: 2019-11-11

## Status

Accepted

## Context

We need to record the architectural decisions made on this project.

## Decision

We will use Architecture Decision Records, as [described by Michael Nygard](http://thinkrelevance.com/blog/2011/11/15/documenting-architecture-decisions).

## Consequences

See Michael Nygard's article, linked above. For a lightweight ADR toolset, see Nat Pryce's [adr-tools](https://github.com/npryce/adr-tools).
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# 2. Use lerna for package versioning

Date: 2019-11-11

## Status

Accepted

## Context

Origin project consist of multiple packages which are the part of Origin SDK. Complex dependency graph forces us to update dependent packages manually every time dependency has changed.

## Decision

Migrate code base to monorepo structure and use `lerna` for versioning management.

## Consequences

All packages will be migrated to single GIT repository. Development will be based on that repo.
20 changes: 20 additions & 0 deletions doc/architecture/decisions/0003-create-backend-client-lib.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# 3. create backend client lib

Date: 2019-11-11

## Status

Accepted

## Context

Off-chain data is accessible via REST API. Currently all system components uses direct REST calls in various places making unit test hard.

## Decision

Create client library and use it as dependency in components that want to read the off-chain data. Include the mocked version of the service so unit-tests does not have to rely on the implementation.

## Consequences

Client will be added as separate package, tests will utilise mocked version.

19 changes: 19 additions & 0 deletions doc/architecture/decisions/0004-use-openzeppelin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# 4. Use OpenZeppelin

Date: 2019-11-11

## Status

Accepted

## Context

Origin SDK contracts are designed to be upgradable by abstracting proxy, logic and storage to separate contracts. This approach leads to maintaining 3 separate Solidity files per contract.

## Decision

Use OpenZeppelin implementation based on generalized proxy, logic and storage to remove the need of keeping 3 separate custom implemented contracts.

## Consequences

Improves security by delegating part of the functionality to community standard libraries. Allows us to use OpenZeppelin cli tools for deployment and migrations.
52 changes: 52 additions & 0 deletions docker-compose.collective.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
version: '3'
services:
origin_ui:
image: "energyweb/origin-ui:${TAG}"
ports:
- "80:80"
networks:
- app-network
env_file:
- ./.env
depends_on:
- origin_backend

market_matcher:
image: "energyweb/market-matcher:${TAG}"
env_file:
- ./.env
depends_on:
- origin_backend

event_listener:
image: "energyweb/event-listener:${TAG}"
env_file:
- ./.env
depends_on:
- origin_backend

solar_simulator:
image: "energyweb/solar-simulator:${TAG}"
ports:
- "3031:3031"
env_file:
- ./.env
depends_on:
- origin_backend
networks:
- app-network

origin_backend:
image: "energyweb/origin-backend:${TAG}"
ports:
- "${BACKEND_PORT}:${BACKEND_PORT}"
networks:
- app-network
env_file:
- ./.env
volumes:
- "./db:/var/db"

networks:
app-network:
driver: bridge
34 changes: 8 additions & 26 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,16 @@
version: '3'
services:
origin_ui:
image: "energyweb/origin-ui:${TAG}"
ports:
- "80:80"
networks:
- app-network
env_file:
- ./.env
depends_on:
- origin_backend

market_matcher:
image: "energyweb/market-matcher:${TAG}"
env_file:
- ./.env
depends_on:
- origin_backend

origin_backend:
image: "energyweb/origin-backend:${TAG}"
nginx:
image: nginx:alpine
restart: unless-stopped
tty: true
ports:
- "${BACKEND_PORT}:${BACKEND_PORT}"
- "80:80"
volumes:
- ./packages/origin-ui/dist:/var/www/html
- ./packages/origin-ui/nginx/default.conf:/etc/nginx/conf.d/default.conf
networks:
- app-network
env_file:
- ./.env
volumes:
- "./db.sqlite:/var/db/db.sqlite"

networks:
app-network:
driver: bridge
4 changes: 2 additions & 2 deletions origin-docker-run.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash

touch db.sqlite
mkdir -p db
docker-compose pull
docker-compose up
docker-compose up -d
Loading

0 comments on commit 07de6a7

Please sign in to comment.