|
4 | 4 |  |
5 | 5 |  |
6 | 6 |
|
7 | | -# Origin Protocol |
| 7 | +# origin-js |
8 | 8 |
|
9 | | -Origin Protocol is a library of javascript code and Ethereum smart contracts which allow anyone to create decentralized marketplaces, including for fractional usage. |
| 9 | +origin-js is a library of javascript code and Ethereum smart contracts which allow anyone to create decentralized marketplaces, including for fractional usage. It is an open source project created by [Origin Protocol](https://www.originprotocol.com/). |
10 | 10 |
|
11 | | -Please refer to our [product brief](https://www.originprotocol.com/product-brief) and [technical whitepaper](https://www.originprotocol.com/whitepaper) for more detail. |
| 11 | +To learn more about Origin Protocol, please read our [product brief](https://www.originprotocol.com/product-brief) and [whitepaper](https://www.originprotocol.com/whitepaper) for a high-level description of what we're building and why it matters. Our official website is [https://www.originprotocol.com](https://www.originprotocol.com). |
12 | 12 |
|
13 | | - - [README for Javascript code](#originjs-documentation) |
| 13 | +⚠️ This is an alpha version which is not suitable for production environments. |
14 | 14 |
|
15 | | -## Follow our progress and get involved |
| 15 | +## Documentation |
| 16 | +[origin-js documentation](http://docs.originprotocol.com/) |
16 | 17 |
|
17 | | -This repo is under active development. We welcome your participation! |
| 18 | +## Demo |
18 | 19 |
|
19 | | -1. [Join our #engineering channel on Discord](http://www.originprotocol.com/discord). |
| 20 | +origin-js is showcased in our Demo DApp currently running on the Rinkeby testnet. |
| 21 | +- [Overview and step-by-step instructions](https://medium.com/originprotocol/origin-demo-dapp-is-now-live-on-testnet-835ae201c58) |
| 22 | +- [Live Demo](http://demo.originprotocol.com) |
| 23 | +- [Github Repo](https://github.com/OriginProtocol/demo-dapp) |
20 | 24 |
|
21 | | -2. Listen in on our weekly engineering call on Google Hangouts. It happens every week and everyone is welcome to listen in and participate. [Join us on Google Hangouts](https://meet.google.com/pws-cgyd-tqp) on Wednesdays at 9pm GMT ([Add to Calendar](https://calendar.google.com/event?action=TEMPLATE&tmeid=MHAyNHI3N2hzMjk5b3V2bjhoM2Q1ZWVzY2pfMjAxODA0MTFUMjAwMDAwWiBqb3NoQG9yaWdpbnByb3RvY29sLmNvbQ&tmsrc=josh%40originprotocol.com&scp=ALL)): |
| 25 | +## Using origin-js in your project |
22 | 26 |
|
23 | | -| Pacific | Mountain | Central | Eastern | GMT | |
24 | | -|---------|----------|---------|---------|-----| |
25 | | -| Wed 1pm | Wed 2pm | Wed 3pm | Wed 4pm | Wed 9pm | |
| 27 | +### As a node package |
26 | 28 |
|
27 | | -3. Catch up on our meeting notes & weekly sprint planning docs (feel free to add comments): |
28 | | -- [Engineering meeting notes](https://docs.google.com/document/d/1aRcAk_rEjRgd1BppzxZJK9RXfDkbuwKKH8nPQk7FfaU/) |
29 | | -- [Weekly sprint doc](https://docs.google.com/document/d/1qJ3sem38ED8oRI72JkeilcvIs82oDq5IT3fHKBrhZIM) |
| 29 | +``` |
| 30 | +npm install origin --save |
| 31 | +``` |
| 32 | +or |
| 33 | +``` |
| 34 | +yarn add origin |
| 35 | +``` |
30 | 36 |
|
31 | | -4. Read our simple [contributing and style guide](CONTRIBUTING.md). |
| 37 | +### Plain javascript |
32 | 38 |
|
33 | | -# What we're building |
| 39 | +A browser-compatible plain javascript file `origin.js` is available in the [Releases section](https://github.com/OriginProtocol/origin-js/releases). A hosted version can be directly included in your html as: |
| 40 | +```html |
| 41 | +<script src="https://code.originprotocol.com/origin-js/origin-v0.5.10.js"></script> |
| 42 | +``` |
34 | 43 |
|
35 | | -This library is an abstraction layer for developers who want to build DApps on Origin Protocol, and is also used to build the [Origin Demo DApp](https://github.com/OriginProtocol/demo-dapp). |
| 44 | +`npm build` will generate this file and save it to `dist/origin.js`. |
36 | 45 |
|
37 | | -The library will make it easy for sellers to do things like: |
| 46 | +## Local development |
38 | 47 |
|
39 | | - - Create listings |
40 | | - - Update listings |
41 | | - - Delete listings |
42 | | - - Validate listings |
| 48 | +### 1. Clone this repo. |
| 49 | +``` |
| 50 | +git clone https://github.com/OriginProtocol/origin-js.git && cd origin-js |
| 51 | +``` |
43 | 52 |
|
44 | | -And buyers to: |
| 53 | +If you would like to submit pull requests, you should instead fork this repo and then clone your fork. Note pull requests should always be made to the `develop` branch, which always has the latest commits. |
45 | 54 |
|
46 | | - - Browse listing |
47 | | - - Create bookings |
48 | | - - Update bookings |
49 | | - - Cancel bookings |
| 55 | +### 2. Install dependencies and link |
| 56 | +``` |
| 57 | +npm run install:dev |
| 58 | +``` |
50 | 59 |
|
51 | | - # origin.js Documentation |
| 60 | +`install:dev` is shortcut for `npm install && npm link`. Linking means that changes to `origin-js` code are immediately available to local DApps without an `npm install`. |
52 | 61 |
|
53 | | - ## Introduction |
| 62 | +### 3. Start the local blockchain and build origin-js |
54 | 63 |
|
55 | | - Welcome to the origin.js documentation! origin.js is a Javascript library for interacting with the Origin protocol. |
| 64 | +``` |
| 65 | +npm start |
| 66 | +``` |
56 | 67 |
|
57 | | - Using the library you can create new listings from your applications, purchase them, or update them from your own off-chain applications. |
58 | | - |
59 | | - ### Warning |
60 | | - This is still an alpha version which will evolve significantly before the main net release. |
61 | | - |
62 | | - ## Using origin.js in your project |
63 | | - |
64 | | - ### Plain javascript |
65 | | - |
66 | | - A browser-compatible plain javascript file `origin.js` is available in the "Releases" tab, and will soon be hosted on originprotocol.com. It can be generated locally via `npm build` and will be placed in `dist/origin.js`. |
67 | | - |
68 | | - ## Install |
69 | | - |
70 | | - ### NPM |
71 | | - ``` |
72 | | - npm install @originprotocol/origin --save |
73 | | - ``` |
74 | | - |
75 | | - ### Yarn |
76 | | - ``` |
77 | | - yarn add @originprotocol/origin |
78 | | - ``` |
79 | | - |
80 | | - ### Local |
81 | | - |
82 | | -1. `git clone` your fork. Note that the latest commits will be on the `develop` |
83 | | - branch. So switch to that branch if you want to submit a PR or check out |
84 | | - recently merged code. |
85 | | - |
86 | | -1. Install:dev (shortcut for `npm install && npm link`). Linking makes this available as a local npm package for local dapp development. |
87 | | - ``` |
88 | | - npm run install:dev |
89 | | - ``` |
90 | | -
|
91 | | -1. Start the localblockchain and create the build. Code changes will trigger a live rebuild. |
92 | | - ``` |
93 | | - npm start |
94 | | - ``` |
95 | | - |
96 | | - In order to conduct test transactions, you can create a new wallet using the following seed phrase (Mnemonic): |
| 68 | +Code changes will trigger a live rebuild. |
97 | 69 |
|
98 | | - _**Be careful to back up the seed phrases and private keys for any existing wallets before creating a new one.**_ |
99 | | - ``` |
100 | | - candy maple cake sugar pudding cream honey rich smooth crumble sweet treat |
101 | | - ``` |
102 | | -
|
103 | | -1. To develop against a working dapp and UI, see [the instructions in our demo dapp](https://github.com/OriginProtocol/demo-dapp#developing-with-a-local-chain). |
104 | | -
|
105 | | - ## Import |
106 | | -
|
107 | | - ``` |
108 | | - import Origin from '@originprotocol/origin' |
109 | | - |
110 | | - let configOptions = {} |
| 70 | +### 4. Use with local Demo DApp |
111 | 71 |
|
112 | | - let { contractService, ipfsService, originService } = new Origin(configOptions) |
113 | | - ``` |
114 | | -
|
115 | | - ## Configuration Options |
116 | | -
|
117 | | - Config options are passed into the Origin constructor at instantiation. |
118 | | -
|
119 | | - ``` |
120 | | - let configOptions = { |
121 | | - option: 'value' |
122 | | - } |
123 | | - let origin = new Origin(configOptions) |
124 | | - ``` |
| 72 | +To interact with your local origin-js and local blockahin, see [the instructions in our Demo DApp](https://github.com/OriginProtocol/demo-dapp#developing-with-a-local-chain). |
125 | 73 |
|
126 | | - Valid options: |
127 | | - - `ipfsDomain` |
128 | | - - `ipfsApiPort` |
129 | | - - `ipfsGatewayPort` |
130 | | - - `ipfsGatewayProtocol` |
131 | | - - `attestationServerUrl` |
132 | 74 |
|
133 | | - ## IPFS |
| 75 | +## Tests |
134 | 76 |
|
135 | | - If you are running a local IPFS daemon then set the following config options ([see config options](#configuration-options)): |
| 77 | +### Command Line (All Tests) |
136 | 78 |
|
137 | | - ``` |
138 | | - { |
139 | | - ipfsDomain: '127.0.0.1', |
140 | | - ipfsApiPort: '5001', |
141 | | - ipfsGatewayPort: '8080', |
142 | | - ipfsGatewayProtocol: 'http' |
143 | | - } |
144 | | - ``` |
145 | | -
|
146 | | - Configure your local IPFS daemon with the following settings to avoid CORS errors: |
147 | | -
|
148 | | - ``` |
149 | | - ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["localhost:*"]' |
150 | | - ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '["GET", "POST", "PUT"]' |
151 | | - ipfs config --json API.HTTPHeaders.Access-Control-Allow-Credentials '["true"]' |
152 | | - ``` |
153 | | -
|
154 | | - ## Troubleshooting |
| 79 | +Our full test suite can be run with: |
155 | 80 |
|
156 | | - ### Python 3 |
| 81 | +``` |
| 82 | +npm run test |
| 83 | +``` |
157 | 84 |
|
158 | | - If you have Python 3 installed, you may see this error when installing dependencies: |
| 85 | + Note: you should *not* have the server running at this time, as these tests start their own local blockchain instance. |
159 | 86 |
|
160 | | - ``` |
161 | | - gyp ERR! stack Error: Python executable "/Users/aiham/.pyenv/shims/python" is v3.6.4, which is not supported by gyp. |
162 | | - ``` |
| 87 | + ### Command Line (Only Solidity Tests) |
163 | 88 |
|
164 | | - Resolve this by configuring npm to use Python 2 (where python2.7 is a binary accessible from your $PATH): |
| 89 | +Our Solidity tests (which use [Truffle](http://truffleframework.com/docs/getting_started/javascript-tests)) are located at `contracts/test`. |
165 | 90 |
|
166 | 91 | ``` |
167 | | - npm config set python python2.7 |
| 92 | + npm run test:contracts |
168 | 93 | ``` |
169 | 94 |
|
170 | | - ## Tests |
| 95 | +Note: you should *not* have the server running at this time, as these tests start their own local blockchain instance. |
171 | 96 |
|
172 | | - ### Command Line (All Tests) |
| 97 | +### Browser Tests |
173 | 98 |
|
174 | | -Our full test suite can be run with: |
| 99 | +A subset of our tests can be run from the browser. These tests are automatically served at `http://localhost:8081` when you run `npm start`. These tests are automatically rerun when source or test code is changed. |
175 | 100 |
|
176 | | - ``` |
177 | | - npm run test |
178 | | - ``` |
| 101 | +Run a subset of these tests using the `grep` query string parameter, for example: http://localhost:8081/?grep=IpfsService |
179 | 102 |
|
180 | | - Note: you should *not* have the server running at this time, as these tests start their own local blockchain instance. |
| 103 | +## Troubleshooting |
181 | 104 |
|
182 | | - ### Command Line (Only Solidity Tests) |
| 105 | +### Python 3 |
183 | 106 |
|
184 | | -Our Solidity tests (which use [Truffle](http://truffleframework.com/docs/getting_started/javascript-tests)) are located at `contracts/test`. |
185 | | -
|
186 | | - ``` |
187 | | - npm run test:contracts |
188 | | - ``` |
189 | | -
|
190 | | - Note: you should *not* have the server running at this time, as these tests start their own local blockchain instance. |
| 107 | +If you have Python 3 installed, you may see this error when installing dependencies: |
191 | 108 |
|
192 | | - ### Browser Tests |
| 109 | +``` |
| 110 | +gyp ERR! stack Error: Python executable "/Users/aiham/.pyenv/shims/python" is v3.6.4, which is not supported by gyp. |
| 111 | +``` |
193 | 112 |
|
194 | | - A subset of our tests can be run from the browser. These tests are automatically served at `http://localhost:8081` when you run `npm start`. These tests are automatically rerun when source or test code is changed. |
| 113 | +Resolve this by configuring npm to use Python 2 (where python2.7 is a binary accessible from your $PATH): |
195 | 114 |
|
196 | | - Run a subset of these tests using the `grep` query string parameter, for example: http://localhost:8081/?grep=IpfsService |
| 115 | +``` |
| 116 | +npm config set python python2.7 |
| 117 | +``` |
| 118 | + |
| 119 | +## Contributing |
197 | 120 |
|
198 | | - ## Documentation |
| 121 | +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. |
199 | 122 |
|
200 | | - Needed |
| 123 | +To get involved, please join our [Discord channel](https://discord.gg/jyxpUSe) and review our [guide to contributing](https://docs.originprotocol.com/#contributing). |
0 commit comments