Skip to content

Commit db6060c

Browse files
author
Tom Linton
authored
Directory reorganisation and scoped packages (OriginProtocol#1738)
* Directory changes * Remove stray yarn file * Update docker compose * Update lerna * Update dockerfiles * Scope packages * Fix two packages * Update imports * More import fixing * Fix paths * Update Dockerfile * Update eslint * Update eslint react * More eslint * More eslint * More eslint react * More fixes * Update docker-compose for tests * Move new files * Update docs * Update readme * Move new files * Update admin dockerfile * Update chart URLs * Update TravisCI * Cleanup dir * Update package versions * Fix travis file * Package updates * More package syncing * Add missing CNAME step to docs build * Move cloudbuild file * Update ganache * Package lock refresh * Reorder TravisCI file * 32 CPU machine for builds * Fix some paths * Fix import * Revert "Update ganache" This reverts commit e972d43. * Package lock refresh * Revert dockerfile names * Sync ganache versions * Use ganache 2.4.0 in contracts
1 parent bf1ac3f commit db6060c

File tree

2,374 files changed

+7594
-1035060
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,374 files changed

+7594
-1035060
lines changed

.travis.yml

+42-42
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,6 @@ git:
33
depth: 6
44
matrix:
55
include:
6-
- name: "origin-graphql unit tests"
7-
language: node_js
8-
node_js: 10
9-
install:
10-
- npm install --ignore-scripts
11-
- npm run bootstrap -- --scope origin-contracts --scope origin-eventsource --scope origin-ipfs --scope origin-messaging-client --scope origin-services --scope origin-validator --scope origin-linker-client --scope origin-graphql
12-
script:
13-
- npm run test --prefix origin-graphql
14-
156
# Run integration tests using docker compose
167
# - name: "integration tests"
178
# language: minimal
@@ -37,7 +28,16 @@ matrix:
3728
script:
3829
- npm run lint
3930

40-
- name: "origin-bridge unit tests"
31+
- name: "@origin/graphql unit tests"
32+
language: node_js
33+
node_js: 10
34+
install:
35+
- npm install --ignore-scripts
36+
- npm run bootstrap -- --scope @origin/contracts --scope @origin/eventsource --scope @origin/ipfs --scope @origin/messaging-client --scope @origin/services --scope @origin/validator --scope @origin/linker-client --scope @origin/graphql
37+
script:
38+
- npm run test --prefix packages/graphql
39+
40+
- name: "@origin/bridge unit tests"
4141
language: node_js
4242
node_js: 10
4343
addons:
@@ -48,23 +48,23 @@ matrix:
4848
- DATABASE_URL=postgres://postgres@localhost/travis_ci_test
4949
before_script:
5050
- psql -c 'create database travis_ci_test;' -U postgres
51-
- lerna run migrate --scope origin-bridge
51+
- lerna run migrate --scope @origin/bridge
5252
install:
5353
- npm install --ignore-scripts
54-
- npm run bootstrap -- --scope origin-bridge
54+
- npm run bootstrap -- --scope @origin/bridge
5555
script:
56-
- npm run test --prefix origin-bridge
56+
- npm run test --prefix infra/bridge
5757

58-
- name: "origin-contracts unit tests"
58+
- name: "@origin/contracts unit tests"
5959
language: node_js
6060
node_js: 10
6161
install:
6262
- npm install --ignore-scripts
63-
- npm run bootstrap -- --scope origin-contracts
63+
- npm run bootstrap -- --scope @origin/contracts
6464
script:
65-
- npm run test --prefix origin-contracts
65+
- npm run test --prefix packages/contracts
6666

67-
- name: "origin-discovery unit tests"
67+
- name: "@origin/discovery unit tests"
6868
language: node_js
6969
node_js: 10
7070
addons:
@@ -78,16 +78,16 @@ matrix:
7878
- ATTESTATION_ACCOUNT=0x99C03fBb0C995ff1160133A8bd210D0E77bCD101
7979
before_script:
8080
- psql -c 'create database travis_ci_test;' -U postgres
81-
- lerna run migrate --scope origin-discovery
82-
- lerna run migrate --scope origin-growth
83-
- lerna run migrate --scope origin-identity
81+
- lerna run migrate --scope @origin/discovery
82+
- lerna run migrate --scope @origin/growth
83+
- lerna run migrate --scope @origin/identity
8484
install:
8585
- npm install
86-
- lerna run build --scope origin
86+
- lerna run build --scope @origin/js
8787
script:
88-
- npm run test --prefix origin-discovery
88+
- npm run test --prefix infra/discovery
8989

90-
- name: "origin-growth unit tests"
90+
- name: "@origin/growth unit tests"
9191
language: node_js
9292
node_js: 10
9393
addons:
@@ -98,38 +98,38 @@ matrix:
9898
- DATABASE_URL=postgres://postgres@localhost/travis_ci_test
9999
before_script:
100100
- psql -c 'create database travis_ci_test;' -U postgres
101-
- lerna run migrate --scope origin-growth
102-
- lerna run migrate --scope origin-identity
101+
- lerna run migrate --scope @origin/growth
102+
- lerna run migrate --scope @origin/identity
103103
install:
104104
- npm install --ignore-scripts
105-
- npm run bootstrap -- --scope origin-contracts --scope origin-eventsource --scope origin-ipfs --scope origin-messaging-client --scope origin-services --scope origin-validator --scope origin-linker-client --scope origin-graphql --scope origin-identity --scope origin-token --scope origin-growth
105+
- npm run bootstrap -- --scope @origin/contracts --scope @origin/eventsource --scope @origin/ipfs --scope @origin/messaging-client --scope @origin/services --scope @origin/validator --scope @origin/linker-client --scope @origin/graphql --scope @origin/identity --scope @origin/token --scope @origin/growth
106106
script:
107-
- npm run test --prefix origin-growth
107+
- npm run test --prefix infra/growth
108108

109-
- name: "origin-js unit tests"
109+
- name: "@origin/js unit tests"
110110
language: node_js
111111
node_js: 10
112112
install:
113113
- npm install --ignore-scripts
114-
- npm run bootstrap -- --scope origin-contracts --scope origin
114+
- npm run bootstrap -- --scope @origin/contracts --scope @origin/js
115115
script:
116-
- npm run test --prefix origin-js
116+
- npm run test --prefix packages/origin-js
117117

118-
- name: "origin-notifications unit tests"
118+
- name: "@origin/notifications unit tests"
119119
language: node_js
120120
node_js: 10
121121
install:
122122
- npm install --ignore-scripts
123-
- npm run bootstrap -- --scope origin-notifications
123+
- npm run bootstrap -- --scope @origin/notifications
124124
script:
125-
- npm run test --prefix origin-notifications
125+
- npm run test --prefix infra/notifications
126126

127-
- name: "origin-token-transfer unit tests"
128-
language: node_js
129-
node_js: 10
130-
install:
131-
- npm install --ignore-scripts
132-
- npm run bootstrap -- --scope origin-contracts --scope origin-token --scope origin-token-transfer-client --scope origin-token-transfer-server
133-
script:
134-
- npm run test --prefix origin-token-transfer-server
135-
- npm run test --prefix origin-token-transfer-client
127+
# - name: "@origin/token-transfer-* unit tests"
128+
# language: node_js
129+
# node_js: 10
130+
# install:
131+
# - npm install --ignore-scripts
132+
# - npm run bootstrap -- --scope @origin/contracts --scope @origin/token --scope @origin/token-transfer-client --scope @origin/token-transfer-server
133+
# script:
134+
# - npm run test --prefix infra/token-transfer-server
135+
# - npm run test --prefix infra/token-transfer-client

DEVELOPMENT.md

+20-20
Original file line numberDiff line numberDiff line change
@@ -17,31 +17,31 @@ git clone https://github.com/OriginProtocol/origin
1717
cd origin && npm install
1818
```
1919

20-
2. You can then start the DApp using:
20+
2. You can then start the marketplace DApp using:
2121

2222
```
23-
cd origin-dapp && npm start
23+
npm start
2424
```
2525

2626
This will start a `webpack-dev-server` with hot reloading on `http://localhost:3000.`. When you open it you should see the message `No marketplace contract?`.
2727

2828
3. Deploy contracts (optional)
2929

30-
By default the DApp will start its own Ethereum blockchain using Ganache. Because it is a fresh network you'll need to deploy some contracts and create some sample listings using the `origin-admin` tool. This can be done by running:
30+
By default the DApp will start its own Ethereum blockchain using Ganache. Because it is a fresh network you'll need to deploy some contracts and create some sample listings using the `admin` tool. This can be done by running:
3131

3232
```
33-
cd origin-admin && npm start
33+
cd admin && npm start
3434
```
3535

3636
Then open your browser to `http://localhost:3001` and:
3737

3838
- Select the Settings page (last icon on the right)
3939
- Click the green `Populate` button.
40-
- Copy and pasting the commands at the bottom of the page into the console for `origin-dapp`.
40+
- Copy and pasting the commands at the bottom of the page into the console for `dapp`.
4141

4242
### Network selection
4343

44-
You can also change the Ethereum network being used by `origin-dapp` by appending a network name to the URL.
44+
You can also change the Ethereum network being used by the marketplace DApp by appending a network name to the URL.
4545

4646
- http://localhost:3000/docker - Local Ganache and services run by Docker Compose (see below for further instructions)
4747

@@ -61,7 +61,7 @@ You can view the state of the network at https://testnet.originprotocol.com/.
6161

6262
### Other settings
6363

64-
The DApp includes a settings page at `http://localhost:3000/settings` which is useful if you want to switch individual services, e.g. use a different Web3 provider or atteestation server.
64+
The marketplace DApp includes a settings page at `http://localhost:3000/settings` which is useful if you want to switch individual services, e.g. use a different Web3 provider or atteestation server.
6565

6666
### About the Origin repository
6767

@@ -74,19 +74,19 @@ There is a Docker Compose configuration available for running a variety of backe
7474
```
7575
- elasticsearch on http://localhost:9200
7676
- postgresql
77-
- origin-services (ipfs server and Ethereum blockchain using ganache on http://localhost:8545)
78-
- origin-bridge on http://localhost:5000
79-
- origin-discovery
80-
- origin-dapp on http://localhost:3000
81-
- origin-event-listener
82-
- origin-discovery (apollo server on http://localhost:4000)
83-
- origin-growth (apollo server on http://localhost:4001)
84-
- origin-ipfs-proxy on http://localhost:9999
85-
- origin-messaging on http://localhost:9012
86-
- origin-notifications on http://localhost:3456)
77+
- @origin/services (ipfs server and Ethereum blockchain using ganache on http://localhost:8545)
78+
- @origin/bridge on http://localhost:5000
79+
- @origin/discovery
80+
- @origin/marketplace on http://localhost:3000
81+
- @origin/discovery (event-listener)
82+
- @origin/discovery (apollo server on http://localhost:4000)
83+
- @origin/growth (apollo server on http://localhost:4001)
84+
- @origin/ipfs-proxy on http://localhost:9999
85+
- @origin/messaging on http://localhost:9012
86+
- @origin/notifications on http://localhost:3456)
8787
```
8888

89-
⚠️ If you want to run the Docker Compose setup ensure that both `origin-dapp` and `origin-admin` are not running before you start the services. The required ports will not be available if either of those two are started before running `docker-compose up`.
89+
⚠️ If you want to run the Docker Compose setup ensure that both `@origin/marketplace` and `@origin/admin` are not running before you start the services. The required ports will not be available if either of those two are started before running `docker-compose up`.
9090

9191
### System Requirements
9292

@@ -136,7 +136,7 @@ Start and stop the environment:
136136
Spawn a shell (command line) in a container:
137137

138138
docker exec -ti <container_name> /bin/bash
139-
docker exec -ti origin-dapp /bin/bash
139+
docker exec -ti dapp /bin/bash
140140

141141
Follow log output for all containers:
142142

@@ -189,7 +189,7 @@ If a container is failing with code 137 it could be that it has encountered Out
189189

190190
#### Port errors
191191

192-
The environment requires a number of ports to be free on your machine (3000, 5000, 5002, 8080, 8081 and 8545). If one of these ports isn't available spinning up the development environment may fail. This includes `origin-dapp` and `origin-admin`. Ensure you start those after you run `docker-compose up`.
192+
The environment requires a number of ports to be free on your machine (3000, 5000, 5002, 8080, 8081 and 8545). If one of these ports isn't available spinning up the development environment may fail. This includes `@origin/dapp` and `@origin/admin`. Ensure you start those after you run `docker-compose up`.
193193

194194
#### Metamask errors
195195

Dockerfile

+21-22
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,32 @@ COPY ./scripts/wait-for.sh /usr/local/bin/
99
# Docker to cache the npm install steps if none of the dependencies have changed
1010
COPY ./lerna.json ./
1111
COPY ./package.json ./
12-
COPY ./origin-discovery/package.json ./origin-discovery/
13-
COPY ./origin-ipfs-proxy/package.json ./origin-ipfs-proxy/
14-
COPY ./origin-js/package.json ./origin-js/
15-
COPY ./origin-messaging/package.json ./origin-messaging/
16-
COPY ./origin-notifications/package.json ./origin-notifications/
17-
COPY ./origin-tests/package.json ./origin-tests/
18-
COPY ./origin-growth/package.json ./origin-growth/
19-
COPY ./origin-identity/package.json ./origin-identity/
20-
COPY ./origin-token/package.json ./origin-token/
21-
COPY ./origin-bridge/package.json ./origin-bridge/
22-
COPY ./origin-dapp/package.json ./origin-dapp/
23-
COPY ./origin-graphql/package.json ./origin-graphql/
24-
COPY ./origin-ipfs/package.json ./origin-ipfs/
25-
COPY ./origin-validator/package.json ./origin-validator/
26-
COPY ./origin-messaging-client/package.json ./origin-messaging-client/
27-
COPY ./origin-linker-client/package.json ./origin-linker-client/
28-
COPY ./origin-eventsource/package.json ./origin-eventsource/
29-
COPY ./origin-services/package.json ./origin-services/
12+
COPY ./packages/origin-js/package.json ./packages/origin-js/
13+
COPY ./packages/graphql/package.json ./packages/graphql/
14+
COPY ./packages/ipfs/package.json ./packages/ipfs/
15+
COPY ./packages/validator/package.json ./packages/validator/
16+
COPY ./packages/messaging-client/package.json ./packages/messaging-client/
17+
COPY ./packages/linker-client/package.json ./packages/linker-client/
18+
COPY ./packages/eventsource/package.json ./packages/eventsource/
19+
COPY ./packages/services/package.json ./packages/services/
20+
COPY ./infra/discovery/package.json ./infra/discovery/
21+
COPY ./infra/messaging/package.json ./infra/messaging/
22+
COPY ./infra/ipfs-proxy/package.json ./infra/ipfs-proxy/
23+
COPY ./infra/notifications/package.json ./infra/notifications/
24+
COPY ./infra/tests/package.json ./infra/tests/
25+
COPY ./infra/growth/package.json ./infra/growth/
26+
COPY ./infra/identity/package.json ./infra/identity/
27+
COPY ./infra/token/package.json ./infra/token/
28+
COPY ./infra/bridge/package.json ./infra/bridge/
3029
COPY ./scripts/ ./scripts/
3130

3231
# Complete contracts source needs to be available so that `truffle compile contracts`
3332
# which is calleed by the prepare script can succeed
34-
COPY ./origin-contracts ./origin-contracts
35-
COPY ./origin-js ./origin-js
33+
COPY ./packages/contracts ./packages/contracts
34+
COPY ./packages/origin-js ./packages/origin-js
3635

3736
# Running of postinstall script requires --unsafe-perm
3837
RUN npm install --unsafe-perm
3938

40-
# Build origin-js for event-listener
41-
RUN npm run build --prefix origin-js
39+
# Build js for event-listener
40+
RUN npm run build --prefix packages/origin-js

README.md

+61-9
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,71 @@ Visit our [Developer's page](https://www.originprotocol.com/developers) to learn
1010

1111
You can see the Origin ecosystem in action at https://dapp.originprotocol.com.
1212

13-
## Our Projects:
14-
15-
* Our [DApp](https://github.com/OriginProtocol/origin/tree/master/origin-dapp) is the first marketplace powered by the Origin Protocol. Make the code your own!
16-
* [origin-graphql](https://github.com/OriginProtocol/origin/tree/master/origin-graphql) lets you quickly build DApps and server applications that interact with the protocol.
17-
* The [discovery server](https://github.com/OriginProtocol/origin/tree/master/origin-discovery) provides a GraphQL service for quickly searching Origin blockchain data.
18-
* Our [bridge server](https://github.com/OriginProtocol/origin/tree/master/origin-bridge) provides identity attestations.
19-
* Run every part of our infrastructure locally for development and testing with [Docker Compose](https://github.com/OriginProtocol/origin/blob/master/DEVELOPMENT.md#running-docker-compose).
20-
* Finally, we have a [testnet faucet](https://github.com/OriginProtocol/origin/tree/master/origin-faucet) and a distributed [messaging hub](https://github.com/OriginProtocol/origin/tree/master/origin-messaging).
21-
2213
## Development
2314

2415
Ready to get started? Have a look at our [developer quickstart](DEVELOPMENT.md) and our [contributing guidelines](CONTRIBUTING.md).
2516

17+
## This repository
18+
19+
This repository is a monorepo containing many [npm packages](https://www.npmjs.com/). It is managed using [Lerna.](https://github.com/lerna/lerna)
20+
21+
### Core packages
22+
23+
These packages are used to build DApps on Origin.
24+
25+
| Package | Description |
26+
|---------|-------------|
27+
| [`@origin/contracts`](/packages/contracts) | Smart contracts|
28+
| [`@origin/eventsource`](/packages/eventsource) | Derives current state of listings and offers from contract events |
29+
| [`@origin/graphql`](/packages/graphql) | GraphQL interface to Origin Protocol |
30+
| [`@origin/ipfs`](/packages/ipfs) | Convenience methods for getting and setting data in IPFS |
31+
| [`@origin/linker-client`](/packages/linker-client) | Client for mobile linking |
32+
| [`@origin/messaging-client`](/packages/messaging-client) | Client for Origin messaging|
33+
| [`@origin/origin-js`](/packages/origin-js) | (DEPRECATED) Library for interacting with smart contracts |
34+
| [`@origin/services`](/packages/services) | Utility package for running Ganache and IPFS |
35+
| [`@origin/token`](/packages/token) | Package for manipulating Origin Tokens (OGN)|
36+
| [`@origin/validator`](/packages/validator) | JSON Schema validation |
37+
38+
### DApp packages
39+
40+
Example DApps that we have built.
41+
42+
| Package | Description |
43+
|---------|-------------|
44+
| [`@origin/admin`](/dapps/contracts) | DApp similar to `@origin/marketplace` but exposes more functionality |
45+
| [`@origin/graphql-simple-demo`](/dapps/eventsource) | Example of building a DApp with `@origin/graphql` |
46+
| [`@origin/marketplace`](/dapps/graphql) | Our marketplace DApp |
47+
48+
### Infrastructure packages
49+
50+
Servers and packages that provide extra functionality to DApps (e.g. search or attestations).
51+
52+
| Package | Description |
53+
|---------|-------------|
54+
| [`@origin/bridge`](/infra/bridge) | Server providing attestation services |
55+
| [`@origin/cron`](/infra/cron) | Runs background tasks |
56+
| [`@origin/dapp-creator-client`](/infra/dapp-creator-client) | Client that generates configs for `@origin/marketplace` |
57+
| [`@origin/dapp-creator-server`](/infra/dapp-creator-server) | Server that generates configs for `@origin/marketplace` |
58+
| [`@origin/discovery`](/infra/discovery) | Provides search features to `@origin/marketplace` |
59+
| [`@origin/faucet`](/infra/faucet) | Token faucet |
60+
| [`@origin/growth`](/infra/growth) | Growth engine |
61+
| [`@origin/identity`](/infra/identity) | Database models for storing identity |
62+
| [`@origin/ipfs-proxy`](/infra/ipfs-proxy) | Layer between IPFS and clients to prevent malicious use |
63+
| [`@origin/linking`](/infra/linking) | Linking server for mobile integration|
64+
| [`@origin/messaging`](/infra/messaging) | Messaging server |
65+
| [`@origin/notifications`](/infra/notifications) | Delivers in browser notifications |
66+
| [`@origin/tests`](/infra/tests) | Runs integration tests in Docker Compose |
67+
| [`@origin/token-transfer-client`](/infra/token-transfer-client) | Client for delivering tokens |
68+
| [`@origin/token-transfer-server`](/infra/token-transfer-server) | Server for delivering tokens |
69+
70+
71+
### Mobile
72+
73+
| Package | Description |
74+
|---------|-------------|
75+
| [`@origin/mobile`](/mobile) | Mobile application |
76+
77+
2678
## Contributing
2779

2880
Origin is an 100% open-source and community-driven project and we welcome contributions of all sorts. There are many ways to help, from reporting issues, contributing code, and helping us improve our community.

0 commit comments

Comments
 (0)