GithubHelp home page GithubHelp logo

originprotocol / origin Goto Github PK

View Code? Open in Web Editor NEW
653.0 77.0 204.0 265.43 MB

Monorepo for our developer tools and decentralized marketplace application

Home Page: https://www.originprotocol.com/developers

License: MIT License

JavaScript 95.16% HTML 1.02% CSS 0.46% Shell 0.98% Dockerfile 0.03% Smarty 0.02% Solidity 1.43% Java 0.04% Objective-C 0.12% Assembly 0.25% Ruby 0.06% Starlark 0.03% SCSS 0.25% Mustache 0.16%
origin origin-protocol solidity javascript dapp marketplace monorepo

origin's People

Contributors

aiham avatar ambertch avatar bootstraponline avatar chrissrogers avatar crazybuster avatar cuongdo avatar cvkef avatar danielvf avatar digidigo avatar franckc avatar jordajm avatar joshfraser avatar lord avatar marcguyer avatar matthewliu avatar mek32390 avatar micahalcorn avatar mikeshultz avatar natasha08 avatar nick avatar originci avatar realityking avatar renovate[bot] avatar riverfor avatar ryana avatar shahthepro avatar sparrowdom avatar tomlinton avatar tyleryasaka avatar wanderingstan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

origin's Issues

Localization

We can't be English/America-only. Let's get this DApp global!

Overall plan is:

Step 1: Choose localization library. Default choice for React would seem to be: react-localization

Step 2: Break apart current english strings and replace with appropriate l10n calls.

Step 3: Get translations for different languages.

If you have an opinion on 1, or want to do some research, that'd be very useful. Step 2 will be the bulk of this issue.

Sub-tasks created:

Links in footer are broken

They get appended to URL when clicked, e.g. https://demo.originprotocol.com/https://www.originprotocol.com/product-brief

Link to etherscan for transaction, accounting for network

On blockchain transactions, e.g. posting listing here:
https://github.com/OriginProtocol/demo-dapp/blob/master/src/components/demo-step-4.js#L12

Determine if we are on mainnet, testnet, or local
https://ethereum.stackexchange.com/a/23905/20332

And then link to page transaction tx on network's etherscan, e.g.
https://rinkeby.etherscan.io/tx/0xfa2108102935c48eac0869c901ea36588704110eac6fdb79f958841d1821fc28

Of course not possible for local testrpc network.

Include sample listings

Upon first run the app has no listings, so its hard to get a feel of what we're going for.

We need some sample listings to be included upon start. I can see two ways of doing this

  1. Have script that adds listings, ideally integrated to part of truffle deploy process
  2. Include a pre-populated chain database that is used by truffle develop/testrpc

The right choice I think is (1) if we can make it work.

Now that we have our IPFS gateway (soon with auto-pinning), we can rely on the IPFS data already being there.

For actual content of sample listings (images, copy, prices), consult in @matthewliu and @aure

Get id of newly created listing

This is surprisingly hard, as web3 doesn't give any info returned from a contract method.

We'll probably need to modify our code that waits for transaction to finish, and then fetch the listing id (index) from there.

Fancy image uploads

Aure's design calls for images to be uploaded via a slick UI with thumbnails:

image

We're using react-json-schema-form, which does only old-school style file uploads. (Click a button to open native OS file selector.)

So there are multiple ways to go:

  1. Break image uploading into its own step in listing-create.js. (One idea would be to use the same react-json-schema-form, but hide the image part when entering details, and hide everything BUT the image step when uploading photos.)
  2. Perhaps use a natve FileReader() to do the upload, and inject the results into the react-json-schema-form. (Docs)
  3. Use HTML5 image uploader to show preview of uploaded images, and possibly even resize them.

Block HTTP on the IPFS gateway

We should only use HTTPS for the IPFS gateway. This prevents eavesdropping which listings are being viewed, and prevents data from being modified in transit before it hits the user.

We should prevent us from accidentally using HTTP in the future, as well as help other people building DAPs. I think the best way to do this is to not allow the gateway to be used over HTTP at all. It should be HTTPS only.

Only allow data images for listings

We should to force photos be embedded data urls.

Currently, you could just include an http or https image url in the pictures json, and it would be used instead of a data url. This would allow someone to track when their image is viewed, or who is viewing it, or change the image during or after the sale, with no way of knowing about this during a later dispute.

This is probably best done as part of a validation/migration step when loading listing data.

Load/Validate/Migrate from IPFS listing data into data model

Data coming from IPFS is completely outside our DAP's control. It can be safely assumed to be as maliciously formed as possible. It could also be in an outdated schema.

We can't have react components responsible for parsing and validating IPFS data.

When we are loading information about a listing, we need to:

  • Create a new object, and only copy over whitelisted fields
  • Migrate any schema differences between the data loaded and the current version
  • Validate each field
  • Discard invalid listings

We also need to start keeping some kind of schema version in our IPFS data.

Detect Metamask issues and give user-friendly help

If user does not have Metamask, or is on wrong network, the demo silently fails.

We should detect these conditions and guide user to take the right actions to fix.

With No Metamask, Chrome gives:

Mixed Content: The page at 'https://demo.originprotocol.com/' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://localhost:8545/'. This request has been blocked; the content must be served over HTTPS.
(anonymous) @ VM37:1

With Metamask on wrong network (E.g. not on Rinkeby for web demo dapp), Chrome gives:

Uncaught (in promise) Error: Contract has not been deployed to detected network (network/artifact mismatch)
    at contract.js:419
    at <anonymous>
(anonymous) @ contract.js:419
Promise rejected (async)
(anonymous) @ contract-service.js:83
getAllListings @ contract-service.js:81
(anonymous) @ demo-step-0.js:24
setTimeout (async)
DemoStep0 @ demo-step-0.js:21
_constructComponentWithoutOwner @ ReactCompositeComponent.js:297
_constructComponent @ ReactCompositeComponent.js:284
mountComponent @ ReactCompositeComponent.js:187
mountComponent @ ReactReconciler.js:45
mountChildren @ ReactMultiChild.js:236
_createInitialChildren @ ReactDOMComponent.js:703
mountComponent @ ReactDOMComponent.js:522
mountComponent @ ReactReconciler.js:45
mountChildren @ ReactMultiChild.js:236
_createInitialChildren @ ReactDOMComponent.js:703
mountComponent @ ReactDOMComponent.js:522
mountComponent @ ReactReconciler.js:45
mountChildren @ ReactMultiChild.js:236
_createInitialChildren @ ReactDOMComponent.js:703
mountComponent @ ReactDOMComponent.js:522
mountComponent @ ReactReconciler.js:45
mountChildren @ ReactMultiChild.js:236
_createInitialChildren @ ReactDOMComponent.js:703
mountComponent @ ReactDOMComponent.js:522
mountComponent @ ReactReconciler.js:45
performInitialMount @ ReactCompositeComponent.js:370
mountComponent @ ReactCompositeComponent.js:257
mountComponent @ ReactReconciler.js:45
performInitialMount @ ReactCompositeComponent.js:370
mountComponent @ ReactCompositeComponent.js:257
mountComponent @ ReactReconciler.js:45
mountComponentIntoNode @ ReactMount.js:104
perform @ Transaction.js:143
batchedMountComponentIntoNode @ ReactMount.js:126
perform @ Transaction.js:143
batchedUpdates @ ReactDefaultBatchingStrategy.js:62
batchedUpdates @ ReactUpdates.js:97
_renderNewRootComponent @ ReactMount.js:319
_renderSubtreeIntoContainer @ ReactMount.js:401
render @ ReactMount.js:422
(anonymous) @ index.js:5
__webpack_require__ @ bootstrap bc5f07193d906f601ba9:555
fn @ bootstrap bc5f07193d906f601ba9:86
(anonymous) @ bootstrap bc5f07193d906f601ba9:578
__webpack_require__ @ bootstrap bc5f07193d906f601ba9:555
(anonymous) @ bootstrap bc5f07193d906f601ba9:578
(anonymous) @ bootstrap bc5f07193d906f601ba9:578

Add paging to URLs / Router

Back button behavior is broken on listings-grid.js (homepage) because we don't change the URL.

We need to use react-router Route and Link to do it right. I think the right way is:
/ = homepage
/page/1 = page 1
/page/2 = page 2
etc...
Where the page corresponds with activePage from Pagination component.

Dockerize this thing

Would be great to add a Dockerfile to make it easier for people using Docker to get up and running with the demo app.

CSP: Defense in depth vs XSS

React does eliminate most XSS concerns. It does not look like the current code base is vulnerable to any know React XSS attack.

The possible future attack is if user supplied data was used in a link href. For example:

<a href={data.link_to_site}>Web/a>

In this case, the evil user could do a "javascipt:evilcode..", which would run when clicked on. I've checked the codebase, and this isn't currently a problem. However, we'd want to put something in place proactively to prevent us from doing this in the future.

The Content-Security-Policy header allows us to block inline javascript, such as inserted "javascript:" links.

We can add this line to the nginx config for demo.originprotocol.com

add_header Content-Security-Policy "default-src https:; img-src https: data:"

Alternate, you can do the metatag equivalent, and place it in the HTML header for the page.

This will

  • Block all inline javascript from being run, preventing an injection attack
  • Block any page content not loaded over HTTPS
  • Still allow our listing images to be pulled from the data urls

This is a pretty basic CSP. At some point we could explicitly whitelist the domains that we are allowed to run javascript from.

@ryana

Branched react-web3 package installation fails silently

In step 10 of the local DApp installation, there are no obvious errors during npm install. However, upon npm run start, I get the following error:

Failed to compile.

Error in ./src/components/app.js
Module not found: 'react-web3' in /.../Solidity/origin-demo-dapp/src/components

 @ ./src/components/app.js 20:16-37

Sure enough, the node_modules/react-web3 folder only contains README.md and package.json. It is missing the dist folder and the package code. If I remove the installed branch of the package and edit the package.json dependency to "react-web3": "0.4.3", then the app boots up fine. I have tried a variety of removals and reinstalls to no avail. Let me know what else I can tell you.

Newly created listings sometimes don't appear for a while

When a new listing is created, and user returns to listing-grid page, the new listing sometimes doesn't appear right away but will after another page reload.

We wait for the transaction to be confirmed in blockchain here.

Possibilities:

  • React caching results
  • Metamask caching contract results
  • Web3 not updating -- even though we know the transaction has been mined, perhaps there is delay before the contract method listingsLength() "knows" about the new listing?
  • Hack in a [2 second] pause to give time for it to settle?

Testnet gas price issues

Andrew is having trouble submitting new listings, with Metamask saying to increase the gas price. We currently have hardcoded gaslimit (in another open issue). Need to figure this out.

Better detection of environment in react for dev, staging, live, etc

There are places where we use the page domain to detect if we are on the testnet installation.

Handle case when IPFS data is gone

Listings may disappear from IPFS. (Unpinned and garbage collected, or whatever reason.) We should handle this gracefully. I suggest we show some mention at bottom of everything that listing exists on blockchain, but is invalid without IPFS.

Add support for loading sub-schemas by URL to the React JSONSchema library

We're using this awesome React library to load & validate our JSONSchema forms:
https://github.com/mozilla-services/react-jsonschema-form

Unfortunately, this library does not currently support loading sub-schemas by URL. This functionality is supported in the JSONSchema spec but it's not in the React implementation that we're using. We're going to need this to be able to have schemas inherit common reusable components like mailing addresses or phone numbers.

Read up on $refs and the id properties of JSONSchema for more context:
https://spacetelescope.github.io/understanding-json-schema/structuring.html

Style the pages shown for "No Metamask" and "Account unavailable"

Defaults from react-webe are pretty ugly and not in our style.

Current messaging:

Web3 unavailable

Web3 Not Found'
It seems that you are using a browser without Web3 capabilities. Please
make sure that you are using a web3-capable browser like mist or parity.
If you are using MetaMask or Parity extension, make sure that it is
enabled.

Account unavailable

No ETH Account Available
It seems that you don&apos;t have an ETH account selected. If using
MetaMask, please make sure that your wallet is unlocked and that
you have at least one account in your accounts list.

Replace alerts() with styled message boxes

We need a way to show non-modal messages/errors to user.

overlay.js can show a message and prevent any user interaction (modal).

But we need a way to show other messages but allow continued user action on the page. For example, when the selected listing upload is too large: https://github.com/OriginProtocol/demo-dapp/blob/master/src/components/listing-create.js#L90
There will surely be more of these.

Aure will work on a design, though something like the design here would get us started:
https://codeburst.io/displaying-error-messages-in-react-with-a-higher-order-component-hoc-fe2de074bf64

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.