Giter Club home page Giter Club logo

tomorelayer's Introduction

TABLE OF CONTENTS

  1. Introduction
  2. Development
  3. Development Roadmap
  4. Troubleshooting

Introduction

A Relayer Manager Application, built with Python, Tornado, and React's Create-React-App

Development

Setup

Prerequisite

The following must be included in the development toolbelt:

  • pyenv
  • Python 3.7.* (recommended installing with pyenv)
  • Python 2.7 (recommended installing with pyenv, if not in the system yet)
  • pipenv
  • nvm
  • node 10+ && npm 6+
  • Docker

You can test if any tool above work as expected using the which command below

$ which <library>

If the installing is correct, you should see some path or text got printed out in the terminal.

As usual, clone the repository to your local machine and cd into it.

$ git clone <tomorelayer-repository>
$ cd <tomorelayer-repository>

After that, install the specified application dependencies with npm and pipenv

# Install frontend & node scripts dependencies
$ npm install

# Install backend dependencies
$ pipenv install

Next, setup local databases with Docker

For development purpose, we are going to have 2 PosgreSQL docker-containers, one for developing & the other for testing - each get exposed on its own local port

$ npm run docker

You will need a local .env.local file. Copy the existing .env.development to make your own. Then you can make changes to your local env file if needed. (actually in most case, you wont need to make any change, unless you have some docker-exposing-port-conflict problem)

$ cp .env.development .env.local

Start backend & frontend on 2 different terminal tabs

# The frontend - since CREATE-REACT-APP takes quite some time to start - in another terminal
$ npm start

# Finally, Backend - certainly in another different terminal as well
$ npm run backend

Testing Contract

  1. Modify Lock-time of Relayer Contract's refund function from 4 weeks to, like, 4 (seconds).
  2. Filling a development mnemonic for testing to ebconfig/contract.js and test/relayer-contract.test.js
  3. Run test with Embark using command npm run ctest
  4. Check if all tests are passed.

For any installation/running problem, check out Troubleshooting guide

Development

backend has the entry point called "app", frontend "index.jsx" Those are where you get started.

Frontend Development

  • Made with Create-React-App
  • State Management with Redux-Zero (not the well-known, original Redux - since it introduces way too much boilerplate codes)
  • UI/UX Development with Material-UI

Backend Development

  • Checkout Python Tornado docs…

  • Models & available API

    • Admin (not used)

    • Contract: GET, POST, PATCH (method in bold format require admin privilieges)

    id name owner address abi obsolete
    int string string eth_address bjson boolean
    • Relayer: GET POST PATCH DELETE
    id owner name coinbase deposit trade_fee from_tokens to_tokens logo link resigning lock_time
    int address string address int int array array link link boolean int
    • Token: GET POST
    id name symbol address total_supply logo is_major
    int string string address number link boolean

Deployment

Please refer to this short Deployment Guideline

Development Roadmap

  1. Backend
    • Backend Database Models & available API
    • Authentication (with JWT)
    • Depovs Document & Deployment
    • Caching with Redis
    • Open API for calling with other application (TomoIssuer, DEX)
    • Client manually update token from TomoXListing Contract
    • Notifying DEX about Token Change for Relayer
  2. Blockchain & Infras
    • SmartContract
    • Testing SmartContract
  3. Frontend development
    • Finalized UI/UX Design
    • Complete Wallet-Integration
    • Client Searching
    • Integrate JSON Schema Validator (AJV)
    • Customizing Material-UI
  4. Deployment
    • Test app
    • How-To Documentation
  5. Statistics views
    • Prepare charts & statistics
  6. Documentation
    • API Document
  7. Make Portable/Reusable API Kit

Troubleshooting

1. I can't install web3, something went wrong with the node-gyp build process.

Our project is using python 3.7.x, which is not yet supported by node-gyp. In order to install web3 correctly, install python2.7 (if not installed yet), and config your npm's python path to it

$ pyenv install 2.7

Inquire python2.7 path, and copy it

$ which python2.7

Config npm's python path

$ npm config set python <your-python2.7-path>

Then you can re-install things by running npm i

2. I can't get the Backend running, something is wrong with the 'Port already in use' warning.

Probably your Backend's last working session encountered some error and the event-loop is still occupying the development port (eg 8888). Just kill the port and restart the app as normal, using task kill-port 8888

tomorelayer's People

Contributors

thanhson1085 avatar thanhvk avatar vutran1710 avatar xiem4588 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

tomorelayer's Issues

Validate inputs

Inputs:

  • dex url
  • dex name
  • trade fee

need to validate:

  • length
  • data type

Add buy, sell function for TomoRelayer smart contract

TomoX have total 150 relayer slot, we will support owner to sell their slot.

sell function: allow user to set a price to sell their slot sell(unit256)
buy function: allow user to buy a available slot buy(ex_address)
We also need a function to list all relayer on sale

Update README for ubuntu

On Ubuntu server, if Cython is not installed, can't install 2 packages

  1. cytoolz
  2. lru-dict

So strongly suggest install Cython before pipenv install

Wrong deposit balance

Scenario:

  • capacity: 25K TOMO
  • deposit more 1 TOMO
    -> capacity = 250000.000000000000000001

Expect:
capacity = 250001

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.