Skip to content
This repository was archived by the owner on Jan 14, 2020. It is now read-only.

Commit 9cdc0d2

Browse files
committed
Merge branch 'develop'
2 parents 26683ec + e3c8325 commit 9cdc0d2

Some content is hidden

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

67 files changed

+20871
-9823
lines changed

.babelrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": [ "babel-preset-env" ]
3+
}

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
language: node_js
2+
node_js:
3+
- "lts/*"

README.md

Lines changed: 52 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
![origin_github_banner](https://user-images.githubusercontent.com/673455/37314301-f8db9a90-2618-11e8-8fee-b44f38febf38.png)
22

3+
<<<<<<< HEAD
34
![origin_npm_version](https://img.shields.io/npm/v/origin.svg) ![origin_license](https://img.shields.io/npm/l/origin.svg)
5+
=======
6+
![origin_npm_version](https://img.shields.io/npm/v/origin.svg?style=flat-square&colorA=111d28&colorB=1a82ff)
7+
![origin_license](https://img.shields.io/badge/license-MIT-6e3bea.svg?style=flat-square&colorA=111d28)
8+
![origin_travis_banner](https://img.shields.io/travis/OriginProtocol/origin-js/master.svg?style=flat-square&colorA=111d28)
9+
>>>>>>> develop
410
5-
# Origin Platform
11+
# Origin Protocol
612

713
Origin Protocol is a library of javascript code and Ethereum smart contracts which allow anyone to create decentralized marketplaces, including for fractional usage.
814

@@ -77,22 +83,28 @@ And buyers to:
7783

7884
### Local
7985

80-
1. Clone
81-
```
82-
git clone https://github.com/OriginProtocol/platform origin-platform && cd origin-platform
83-
```
84-
85-
2. Setup (shortcut for `npm install && npm link`). Linking makes this available as a local npm package for local dapp development.
86-
```
87-
npm run setup
88-
```
89-
90-
3. Start the localblockchain and create the build. Code changes will trigger a live rebuild.
91-
```
92-
npm start
93-
```
94-
95-
4. 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).
86+
1. `git clone` your fork. Note that the latest commits will be on the `develop`
87+
branch. So switch to that branch if you want to submit a PR or check out
88+
recently merged code.
89+
90+
1. Install:dev (shortcut for `npm install && npm link`). Linking makes this available as a local npm package for local dapp development.
91+
```
92+
npm run install:dev
93+
```
94+
95+
1. Start the localblockchain and create the build. Code changes will trigger a live rebuild.
96+
```
97+
npm start
98+
```
99+
100+
In order to conduct test transactions, you can create a new wallet using the following seed phrase (Mnemonic):
101+
102+
_**Be careful to back up the seed phrases and private keys for any existing wallets before creating a new one.**_
103+
```
104+
candy maple cake sugar pudding cream honey rich smooth crumble sweet treat
105+
```
106+
107+
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).
96108
97109
## Import
98110
@@ -120,6 +132,7 @@ git clone https://github.com/OriginProtocol/platform origin-platform && cd origi
120132
- `ipfsApiPort`
121133
- `ipfsGatewayPort`
122134
- `ipfsGatewayProtocol`
135+
- `attestationServerUrl`
123136
124137
## IPFS
125138
@@ -160,13 +173,31 @@ git clone https://github.com/OriginProtocol/platform origin-platform && cd origi
160173
161174
## Tests
162175
163-
Browser tests are automatically served at `http://localhost:8081` when you run `npm start`.
176+
### Command Line (All Tests)
177+
178+
Our full test suite can be run with:
179+
180+
```
181+
npm run test
182+
```
183+
184+
Note: you should *not* have the server running at this time, as these tests start their own local blockchain instance.
185+
186+
### Command Line (Only Solidity Tests)
187+
188+
Our Solidity tests (which use [Truffle](http://truffleframework.com/docs/getting_started/javascript-tests)) are located at `contracts/test`.
189+
190+
```
191+
npm run test:contracts
192+
```
193+
194+
Note: you should *not* have the server running at this time, as these tests start their own local blockchain instance.
164195
165-
Tests are automatically rerun when source or test code is changed.
196+
### Browser Tests
166197
167-
Run a subset of tests using the `grep` query string parameter, for example: http://localhost:8081/?grep=IpfsService
198+
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.
168199
169-
We also have contract unit tests that are not run in the browser. These can be run with `npm run test:contracts` (you should *not* have the server running at this time, as these tests start their own local blockchain instance).
200+
Run a subset of these tests using the `grep` query string parameter, for example: http://localhost:8081/?grep=IpfsService
170201
171202
## Documentation
172203

contracts/contracts/Listing.sol

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pragma solidity 0.4.21;
1+
pragma solidity 0.4.23;
22

33
/// @title Listing
44
/// @dev An indiviual Origin Listing representing an offer for booking/purchase
@@ -28,11 +28,12 @@ contract Listing {
2828
bytes32 public ipfsHash;
2929
uint public price;
3030
uint public unitsAvailable;
31+
uint public created;
3132
uint public expiration;
3233
Purchase[] public purchases;
3334

3435

35-
function Listing (
36+
constructor (
3637
address _owner,
3738
bytes32 _ipfsHash,
3839
uint _price,
@@ -45,7 +46,8 @@ contract Listing {
4546
ipfsHash = _ipfsHash;
4647
price = _price;
4748
unitsAvailable = _unitsAvailable;
48-
expiration = now + 60 days;
49+
created = now;
50+
expiration = created + 60 days;
4951
}
5052

5153
/*
@@ -61,6 +63,13 @@ contract Listing {
6163
* Public functions
6264
*/
6365

66+
function data()
67+
public
68+
view
69+
returns (address _owner, bytes32 _ipfsHash, uint _price, uint _unitsAvailable, uint _created, uint _expiration)
70+
{
71+
return (owner, ipfsHash, price, unitsAvailable, created, expiration);
72+
}
6473

6574
/// @dev buyListing(): Buy a listing
6675
/// @param _unitsToBuy Number of units to buy
@@ -98,7 +107,7 @@ contract Listing {
98107
emit ListingChange();
99108
}
100109

101-
/// @dev purchasesLength(): Return number of listings
110+
/// @dev purchasesLength(): Return number of purchases for a given listing
102111
function purchasesLength()
103112
public
104113
constant
@@ -107,7 +116,7 @@ contract Listing {
107116
return purchases.length;
108117
}
109118

110-
/// @dev getPurchase(): Return listing info for given listing
119+
/// @dev getPurchase(): Return purchase info for a given listing
111120
/// @param _index the index of the listing we want info about
112121
function getPurchase(uint _index)
113122
public

contracts/contracts/ListingsRegistry.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pragma solidity 0.4.21;
1+
pragma solidity 0.4.23;
22

33
/// @title Listing
44
/// @dev Used to keep marketplace of listings for buyers and sellers
@@ -44,7 +44,7 @@ contract ListingsRegistry {
4444
* Public functions
4545
*/
4646

47-
function ListingsRegistry()
47+
constructor()
4848
public
4949
{
5050
// Defines origin admin address - may be removed for public deployment
@@ -60,7 +60,7 @@ contract ListingsRegistry {
6060
return listings.length;
6161
}
6262

63-
/// @dev getListing(): Return listing info for given listing
63+
/// @dev getListing(): Return listing info for a given listing
6464
/// @param _index the index of the listing we want info about
6565
function getListing(uint _index)
6666
public
@@ -83,7 +83,7 @@ contract ListingsRegistry {
8383

8484
/// @dev create(): Create a new listing
8585
/// @param _ipfsHash Hash of data on ipfsHash
86-
/// @param _price Price of unit. Currently ETH, will change to 0T
86+
/// @param _price Price of unit in wei
8787
/// @param _unitsAvailable Number of units availabe for sale at start
8888
///
8989
/// Sample Remix invocation:

contracts/contracts/Migrations.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pragma solidity 0.4.21;
1+
pragma solidity 0.4.23;
22

33
contract Migrations {
44
address public owner;
@@ -8,7 +8,7 @@ contract Migrations {
88
if (msg.sender == owner) _;
99
}
1010

11-
function Migrations() public {
11+
constructor() public {
1212
owner = msg.sender;
1313
}
1414

contracts/contracts/Purchase.sol

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
pragma solidity 0.4.21;
1+
pragma solidity 0.4.23;
22

33
/// @title Purchase
44
/// @dev An purchase Origin Listing representing a purchase/booking
55
import "./Listing.sol";
66

77

88
contract Purchase {
9-
9+
1010
/*
1111
* Events
1212
*/
@@ -31,7 +31,7 @@ contract Purchase {
3131
* Storage
3232
*/
3333

34-
Stages private internalStage = Stages.AWAITING_PAYMENT;
34+
Stages private internalStage = Stages.AWAITING_PAYMENT;
3535

3636
Listing public listingContract; // listing that is being purchased
3737
address public buyer; // User who is buying. Seller is derived from listing
@@ -61,7 +61,7 @@ contract Purchase {
6161
* Public functions
6262
*/
6363

64-
function Purchase(
64+
constructor(
6565
address _listingContractAddress,
6666
address _buyer
6767
)
@@ -98,7 +98,7 @@ contract Purchase {
9898

9999
function stage()
100100
public
101-
view
101+
view
102102
returns (Stages _stage)
103103
{
104104
if (internalStage == Stages.BUYER_PENDING) {
@@ -164,4 +164,3 @@ contract Purchase {
164164
// Right now there's no way to exit this state.
165165
}
166166
}
167-

contracts/contracts/PurchaseLibrary.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pragma solidity 0.4.21;
1+
pragma solidity 0.4.23;
22

33
/// @title PurchaseLibrary
44
/// @dev An collection of helper tools for a purchase
@@ -14,5 +14,5 @@ library PurchaseLibrary {
1414
{
1515
purchase = new Purchase(listing, _buyer);
1616
}
17-
17+
1818
}
Lines changed: 15 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
pragma solidity 0.4.21;
1+
pragma solidity 0.4.23;
2+
3+
import './identity/ClaimHolderPresigned.sol';
24

35
/// @title UserRegistry
46
/// @dev Used to keep registry of user identifies
@@ -9,54 +11,31 @@ contract UserRegistry {
911
* Events
1012
*/
1113

12-
event NewUser(address _address);
14+
event NewUser(address _address, address _identity);
1315

1416
/*
1517
* Storage
1618
*/
1719

18-
// Mapping of all users
19-
mapping(address => bytes32) public users;
20+
// Mapping from ethereum wallet to ERC725 identity
21+
mapping(address => address) public users;
2022

2123
/*
2224
* Public functions
2325
*/
2426

25-
/// @dev create(): Create a new user
26-
/// @param _ipfsHash Hash of data on ipfsHash
27-
function set(
28-
bytes32 _ipfsHash
29-
)
30-
public
31-
{
32-
users[msg.sender] = _ipfsHash;
33-
emit NewUser(msg.sender);
34-
}
35-
36-
/// @dev createAnother(): Create a new user and associates attenstion or proof with user
37-
// @param wallet id
38-
// Attestation or proof to associate to the user
39-
// TODO: (Brad David) replace with real function
40-
function createAnother(
41-
string _id,
42-
string payload)
43-
public
44-
pure
45-
returns (string)
27+
/// @dev registerUser(): Add a user to the registry
28+
function registerUser()
29+
public
4630
{
47-
_id; // Dummy "operation" to silence copiler warnigns
48-
return payload;
31+
users[tx.origin] = msg.sender;
32+
emit NewUser(tx.origin, msg.sender);
4933
}
5034

51-
/// @dev get(): returns and existing user associated with wallet id
52-
// @param wallet id
53-
function get(
54-
string _id
55-
)
56-
public
57-
pure
58-
returns (string)
35+
/// @dev clearUser(): Remove user from the registry
36+
function clearUser()
37+
public
5938
{
60-
return _id;
39+
users[msg.sender] = 0;
6140
}
6241
}

0 commit comments

Comments
 (0)