Git Product home page Git Product logo

0x-launch-kit-frontend's Introduction

0x-launch-kit-frontend

⚠️ Deprecation Warning ️️⚠️

This project is no longer being actively maintained. To fork or run a Standard Relayer API instance, you can use the 0x API instead.

CircleCI dependencies Status devDependencies Status Coverage Status

This is an example implementation of a dApp that interacts with a 0x relayer. To use it, you need to have the URL of an existing relayer, or you can start one locally for use during development.

This version of Launch Kit supports 0x v3. If you're looking for v2 it is available on this branch.

This repo ships with both an ERC-20 token trading interface and an ERC-721 marketplace interface.

ERC-20 ERC-721

Usage

Clone this repository and install its dependencies:

git clone [email protected]:0xProject/0x-launch-kit-frontend.git
cd 0x-launch-kit-frontend
yarn

Using an existing relayer

If you have the URL of an existing relayer, you can use this frontend against it. After installing the dependencies, start the application with this command, replacing RELAYER_URL and RELAYER_WS_URL with the proper value:

REACT_APP_RELAYER_URL='https://RELAYER_URL/' REACT_APP_RELAYER_WS_URL='wss://RELAYER_URL/' yarn start

A browser tab will open in the http://localhost:3001 address. You'll need to connect MetaMask to the network used by the relayer.

You can optionally pass in any relayer endpoint that complies with the 0x Standard Relayer API. For example, if you want to show liquidity from 0x API:

REACT_APP_RELAYER_URL='https://api.0x.org/sra/v3' REACT_APP_RELAYER_WS_URL='wss://api.0x.org/sra/v3' REACT_APP_NETWORK_ID=1 REACT_APP_CHAIN_ID=1 yarn start

Creating a relayer for development

If you don't have a relayer, you can start one locally for development by running 0x-api directly, or by using docker-compose.
For docker-compose, first create a docker-compose.yml file like this:

version: '3'
services:
    ganache:
        image: 0xorg/ganache-cli
        ports:
            - '8545:8545'
    postgres:
        image: postgres:9.6
        environment:
            - POSTGRES_USER=api
            - POSTGRES_PASSWORD=api
            - POSTGRES_DB=api
        ports:
            - '5432:5432'
    backend:
        image: 0xorg/0x-api:latest
        depends_on:
            - postgres
            - mesh
        environment:
            CHAIN_ID: '1337'
            WHITELIST_ALL_TOKENS: 'true'
            FEE_RECIPIENT: '0x0000000000000000000000000000000000000001'
            MAKER_FEE_UNIT_AMOUNT: '0'
            TAKER_FEE_UNIT_AMOUNT: '0'
            MESH_WEBSOCKET_URI: 'ws://mesh:60557'
            MESH_HTTP_URI: 'http://mesh:60556'
            POSTGRES_URI: 'postgresql://api:api@postgres/api'
            ETHEREUM_RPC_URL: 'http://ganache:8545'
        ports:
            - '3000:3000'
    mesh:
        image: 0xorg/mesh:9.0.1
        depends_on:
            - ganache
        environment:
            ETHEREUM_RPC_URL: 'http://ganache:8545'
            ETHEREUM_CHAIN_ID: 1337
            VERBOSITY: 3
            WS_RPC_ADDR: '0.0.0.0:60557'
            HTTP_RPC_ADDR: '0.0.0.0:60556'
            # You can decrease the BLOCK_POLLING_INTERVAL for test networks to
            # improve performance. See https://0x-org.gitbook.io/mesh/ for more
            # Documentation about Mesh and its environment variables.
            BLOCK_POLLING_INTERVAL: '5s'
        ports:
            - '60556:60556'
            - '60557:60557'
            - '60558:60558'
            - '60559:60559'

and then run docker-compose up. This will create four containers: one is a Postgres database, one has a ganache with the 0x contracts deployed and some test tokens, another one has an instance of 0x-api implementation of a relayer that connects to that ganache and finally a container for 0x-mesh for order sharing and discovery on a p2p network.

After starting those containers, you can run the following in another terminal. A browser tab will open in the http://localhost:3001 address. You'll need to connect MetaMask to localhost:8545.

REACT_APP_RELAYER_URL='http://localhost:3000/sra/v3' REACT_APP_RELAYER_WS_URL='ws://localhost:3000/sra/v3' yarn start

Note: the state of the relayer will be kept between runs. If you want to start from scratch, use docker-compose up --force-recreate

Environment variables

You can create a .env file to set environment variables and configure the behavior of the dApp. Start by copying the example file (cp .env.example .env) and modify the ones you want. Some things you can configure are:

  • REACT_APP_RELAYER_URL: The URL of the relayer used by the dApp. Defaults to http://localhost:3000/v3
  • REACT_APP_RELAYER_WS_URL: The Websocket URL of the relayer used by the dApp. Defaults to http://localhost:3000/
  • REACT_APP_FEE_PERCENTAGE: The fee percentage amount charged on 0x orders filled via the Forwarder. Note this is limited to */WETH orders for the taker.
  • REACT_APP_FEE_RECIPIENT: The address which receives the fees from the Forwarder.
  • REACT_APP_NETWORK_ID: The network id to build the front end for. E.g 42 for Kovan, 50 for Ganache
  • REACT_APP_CHAIN_ID: The chain id to build the front end for. E.g 42 for Kovan, 1337 for Ganache
  • REACT_APP_DEFAULT_ORDER_EXPIRY_SECONDS: The expiration time for an order. Defaults to 1 day.

Check .env.example for the full list.

Using custom themes

If you want to add your own theme for the app, please read the THEMES.md file

0x-launch-kit-frontend's People

Contributors

adekbadek avatar agupane avatar albrow avatar bmillman19 avatar dekz avatar eharris128 avatar fragosti avatar fvictorio avatar gabitoesmiapodo avatar mariano-aguero avatar pablofullana avatar tomhschmidt avatar unjapones avatar xianny avatar zabirauf 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

0x-launch-kit-frontend's Issues

Orderbook is not subtracting filled values

The total size for a price in the order book should not take into account the filled values.

For example, an order of size 100 with 30 filled, should add 70 to the total size for its price.

The same probably applies too to the "My size" column.

Use a BigNumberInput for the price field

We are using a type="number" input, which can cause precision errors. Let's change it for a BigNumberInput. Also, if there are places where the price is represented as a number, they should be changed to BigNumber.

Orderbook details

  • Parent of #42 (Orderbook is not subtracting filled values)
  • Parent of #59 (Add 'My Size' column to Orderbook)
  • Parent of #60 (Pad sizes with 0)

More items to be added

Orderbook sizes show more decimals

On the orderbook, the trade size amount shows only two decimals, the rest are zero paddings, even when the real value is not that, for example:

size value: 5.015, UI displays: 5.010

Cancel Orders

As a logged in user, I should be able to cancel an order of mine.

Test against real relayer

Let's start with testing manually launch-kit frontend using an existing already-deployed launch-kit backend.

Automatic UI Update Improvement

Check if is necesary to use polling in order to receive the user account changed / networks events on wallets like nifty wallet. The current implementation uses events and it's supported on metamask but not tested on nitfy wallet.

Based on the comment: #84 (comment)

Set selected token

As a user, I should be able to switch the selected token. The corresponding dropdown in the main top-toolbar should list all the available tokens as listed in "My Wallet".
The tokens' information to be displayed covers basic data:

  • icon
  • symbol

Also, this should update the corresponding symbol on the buy/sell forms accordingly.

Image 2019-02-20 at 3.19.39 PM.png

NOTE, this issue does not cover:

  • Show updated data (colums "Price", 24 "Change", etc) of the tokens listed in the dropdown.
  • Show updated data of the selected token in the main top-toolbar.

Buy/sell (limit)

As a logged in user, I should be place a limit order (buy/sell).

  • Buy limit
  • Sell limit

Keep track of ETH/USD price in store

Depends on #58

The USD price of ETH should be saved in the store and updated regularly. Components that use it should just get it from the store.

This means that this value will be nullable, since there's a time window —between the start of the app and the moment the price is obtained— in which the price is unknown. Also, the API could be down. So any component that depends on this should handle the case in which the value is not known.

Originally posted by @Agupane in https://github.com/_render_node/MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI2MDc1OTc2Ng==/comments/review_comment

Track 'online' notifications

As a logged in user, I'd like to be notified every time an order but/sell order is executed/updated.

Update: This version covers only those events that occur while user is 'online'. #106 deals with 'offline' events.

Realtime updates v1

As a user, I'd like to see prices, sizes, statuses updated in realtime, so I don't have to manually refresh the page.

This first iteration of this feature aims to implement this real time updates via polling.

Open for discussion

Add addblock fallback

If a user has addblock / addblock plus installed on the browser, when the app tries to get the eth USD value, the following error is displayed:
image

This should be solved or at least detect the plugin and display a message

Buy/Sell (market)

As a logged in user, I should be place a market order (buy/sell).

  • Buy market
  • Sell market

Investigate if tests can be run faster

Tests are taking ~30 seconds to start (at least on my not-that-fast laptop). Maybe there's something that can be done to speed them up? At the very least, compilation should be incremental when using jest in watch mode.

Add base modal flow mechanism

Add base modal to implement user interaction flows (e.g: "Create order with no WETH and no unlocked ZRX", "Create order with no ZRX", etc).

Assume the first flow is going to be simple: "Sign Order + submit to the relayer backend" (assume WETH and ZRX are unlocked + enough balance).

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.