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

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
wanderingstan committed May 7, 2018
2 parents 26683ec + e3c8325 commit 9cdc0d2
Show file tree
Hide file tree
Showing 67 changed files with 20,871 additions and 9,823 deletions.
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": [ "babel-preset-env" ]
}
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
language: node_js
node_js:
- "lts/*"
73 changes: 52 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
![origin_github_banner](https://user-images.githubusercontent.com/673455/37314301-f8db9a90-2618-11e8-8fee-b44f38febf38.png)

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

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

Expand Down Expand Up @@ -77,22 +83,28 @@ And buyers to:

### Local

1. Clone
```
git clone https://github.com/OriginProtocol/platform origin-platform && cd origin-platform
```

2. Setup (shortcut for `npm install && npm link`). Linking makes this available as a local npm package for local dapp development.
```
npm run setup
```

3. Start the localblockchain and create the build. Code changes will trigger a live rebuild.
```
npm start
```

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).
1. `git clone` your fork. Note that the latest commits will be on the `develop`
branch. So switch to that branch if you want to submit a PR or check out
recently merged code.

1. Install:dev (shortcut for `npm install && npm link`). Linking makes this available as a local npm package for local dapp development.
```
npm run install:dev
```
1. Start the localblockchain and create the build. Code changes will trigger a live rebuild.
```
npm start
```
In order to conduct test transactions, you can create a new wallet using the following seed phrase (Mnemonic):
_**Be careful to back up the seed phrases and private keys for any existing wallets before creating a new one.**_
```
candy maple cake sugar pudding cream honey rich smooth crumble sweet treat
```
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).
## Import
Expand Down Expand Up @@ -120,6 +132,7 @@ git clone https://github.com/OriginProtocol/platform origin-platform && cd origi
- `ipfsApiPort`
- `ipfsGatewayPort`
- `ipfsGatewayProtocol`
- `attestationServerUrl`
## IPFS
Expand Down Expand Up @@ -160,13 +173,31 @@ git clone https://github.com/OriginProtocol/platform origin-platform && cd origi
## Tests
Browser tests are automatically served at `http://localhost:8081` when you run `npm start`.
### Command Line (All Tests)
Our full test suite can be run with:
```
npm run test
```
Note: you should *not* have the server running at this time, as these tests start their own local blockchain instance.
### Command Line (Only Solidity Tests)
Our Solidity tests (which use [Truffle](http://truffleframework.com/docs/getting_started/javascript-tests)) are located at `contracts/test`.
```
npm run test:contracts
```
Note: you should *not* have the server running at this time, as these tests start their own local blockchain instance.
Tests are automatically rerun when source or test code is changed.
### Browser Tests
Run a subset of tests using the `grep` query string parameter, for example: http://localhost:8081/?grep=IpfsService
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.
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).
Run a subset of these tests using the `grep` query string parameter, for example: http://localhost:8081/?grep=IpfsService
## Documentation
Expand Down
19 changes: 14 additions & 5 deletions contracts/contracts/Listing.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.4.21;
pragma solidity 0.4.23;

/// @title Listing
/// @dev An indiviual Origin Listing representing an offer for booking/purchase
Expand Down Expand Up @@ -28,11 +28,12 @@ contract Listing {
bytes32 public ipfsHash;
uint public price;
uint public unitsAvailable;
uint public created;
uint public expiration;
Purchase[] public purchases;


function Listing (
constructor (
address _owner,
bytes32 _ipfsHash,
uint _price,
Expand All @@ -45,7 +46,8 @@ contract Listing {
ipfsHash = _ipfsHash;
price = _price;
unitsAvailable = _unitsAvailable;
expiration = now + 60 days;
created = now;
expiration = created + 60 days;
}

/*
Expand All @@ -61,6 +63,13 @@ contract Listing {
* Public functions
*/

function data()
public
view
returns (address _owner, bytes32 _ipfsHash, uint _price, uint _unitsAvailable, uint _created, uint _expiration)
{
return (owner, ipfsHash, price, unitsAvailable, created, expiration);
}

/// @dev buyListing(): Buy a listing
/// @param _unitsToBuy Number of units to buy
Expand Down Expand Up @@ -98,7 +107,7 @@ contract Listing {
emit ListingChange();
}

/// @dev purchasesLength(): Return number of listings
/// @dev purchasesLength(): Return number of purchases for a given listing
function purchasesLength()
public
constant
Expand All @@ -107,7 +116,7 @@ contract Listing {
return purchases.length;
}

/// @dev getPurchase(): Return listing info for given listing
/// @dev getPurchase(): Return purchase info for a given listing
/// @param _index the index of the listing we want info about
function getPurchase(uint _index)
public
Expand Down
8 changes: 4 additions & 4 deletions contracts/contracts/ListingsRegistry.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.4.21;
pragma solidity 0.4.23;

/// @title Listing
/// @dev Used to keep marketplace of listings for buyers and sellers
Expand Down Expand Up @@ -44,7 +44,7 @@ contract ListingsRegistry {
* Public functions
*/

function ListingsRegistry()
constructor()
public
{
// Defines origin admin address - may be removed for public deployment
Expand All @@ -60,7 +60,7 @@ contract ListingsRegistry {
return listings.length;
}

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

/// @dev create(): Create a new listing
/// @param _ipfsHash Hash of data on ipfsHash
/// @param _price Price of unit. Currently ETH, will change to 0T
/// @param _price Price of unit in wei
/// @param _unitsAvailable Number of units availabe for sale at start
///
/// Sample Remix invocation:
Expand Down
4 changes: 2 additions & 2 deletions contracts/contracts/Migrations.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.4.21;
pragma solidity 0.4.23;

contract Migrations {
address public owner;
Expand All @@ -8,7 +8,7 @@ contract Migrations {
if (msg.sender == owner) _;
}

function Migrations() public {
constructor() public {
owner = msg.sender;
}

Expand Down
11 changes: 5 additions & 6 deletions contracts/contracts/Purchase.sol
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
pragma solidity 0.4.21;
pragma solidity 0.4.23;

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


contract Purchase {

/*
* Events
*/
Expand All @@ -31,7 +31,7 @@ contract Purchase {
* Storage
*/

Stages private internalStage = Stages.AWAITING_PAYMENT;
Stages private internalStage = Stages.AWAITING_PAYMENT;

Listing public listingContract; // listing that is being purchased
address public buyer; // User who is buying. Seller is derived from listing
Expand Down Expand Up @@ -61,7 +61,7 @@ contract Purchase {
* Public functions
*/

function Purchase(
constructor(
address _listingContractAddress,
address _buyer
)
Expand Down Expand Up @@ -98,7 +98,7 @@ contract Purchase {

function stage()
public
view
view
returns (Stages _stage)
{
if (internalStage == Stages.BUYER_PENDING) {
Expand Down Expand Up @@ -164,4 +164,3 @@ contract Purchase {
// Right now there's no way to exit this state.
}
}

4 changes: 2 additions & 2 deletions contracts/contracts/PurchaseLibrary.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.4.21;
pragma solidity 0.4.23;

/// @title PurchaseLibrary
/// @dev An collection of helper tools for a purchase
Expand All @@ -14,5 +14,5 @@ library PurchaseLibrary {
{
purchase = new Purchase(listing, _buyer);
}

}
51 changes: 15 additions & 36 deletions contracts/contracts/UserRegistry.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
pragma solidity 0.4.21;
pragma solidity 0.4.23;

import './identity/ClaimHolderPresigned.sol';

/// @title UserRegistry
/// @dev Used to keep registry of user identifies
Expand All @@ -9,54 +11,31 @@ contract UserRegistry {
* Events
*/

event NewUser(address _address);
event NewUser(address _address, address _identity);

/*
* Storage
*/

// Mapping of all users
mapping(address => bytes32) public users;
// Mapping from ethereum wallet to ERC725 identity
mapping(address => address) public users;

/*
* Public functions
*/

/// @dev create(): Create a new user
/// @param _ipfsHash Hash of data on ipfsHash
function set(
bytes32 _ipfsHash
)
public
{
users[msg.sender] = _ipfsHash;
emit NewUser(msg.sender);
}

/// @dev createAnother(): Create a new user and associates attenstion or proof with user
// @param wallet id
// Attestation or proof to associate to the user
// TODO: (Brad David) replace with real function
function createAnother(
string _id,
string payload)
public
pure
returns (string)
/// @dev registerUser(): Add a user to the registry
function registerUser()
public
{
_id; // Dummy "operation" to silence copiler warnigns
return payload;
users[tx.origin] = msg.sender;
emit NewUser(tx.origin, msg.sender);
}

/// @dev get(): returns and existing user associated with wallet id
// @param wallet id
function get(
string _id
)
public
pure
returns (string)
/// @dev clearUser(): Remove user from the registry
function clearUser()
public
{
return _id;
users[msg.sender] = 0;
}
}
Loading

0 comments on commit 9cdc0d2

Please sign in to comment.