Giter Club home page Giter Club logo

cofix-web-user-interface-v2.0's Introduction

CoFiX-Web-User-Interface

中文

The application is developed with Ionic 5 and Angular 10. Key npm packages:

  • ethers.js 5, smart contract interaction
  • akita, state management
  • testcafe, e2e testing

WHITEBOX CODE AUDIT REPORT

The whitebox code audit report can be downloaded from here.

Constants

Contract Addresses

Address about CoFix contracts: src/app/common/constants.ts.

Environment

IMPORTANT: all angular environments files are added in .gitignore and will not be committed to this repository. To run this app, please run commands described in "Development" section.

All environments file are created automatically and it will use two env variables:

  • API_KEY, your infura api key
  • E2E_PK, private key for E2E testing

Here is an example:

export API_KEY=Your-API-KEY
export E2E_PK=Your-PrivateKey

The template used to create environment file can be found in script/preprocessing.js. Parameters meaning:

  • production, boolean for product environment
  • lang, the default language
  • infura, infura configuration for displaying public information (such as exchange prices) when no wallet is connected.
  • network, infura network id
  • e2e, e2e flag and wallet used in e2e testing.

Running HybridSwap Against Ropsten

** The following is only for Ropsten , not mainnet **

On Ropsten, WETH currently used in CoFiX is an internally deployed contract, which may result in a lack of sufficient liquidity when any external Token (other than USDT / HBTC) is present in the current pair, including ETH + external Token pairs. This is due to the lack of liquidity on Uniswap (the basis of Hybrid Swap) between WETH and that Token. Therefore, when the network is selected as Ropsten, not just any address added can be traded directly through CoFiX.

For testing purposes, two external Tokens are pre-built in the current code: COMP and NEST, which can be freely exchanged with other pre-built Tokens.

If you want to add new Token to complete the exchange under Ropsten, you need to do some preparation:

  1. Token Address, the following link provides the addresses of the tokens exchanged on the Uniswap contract under Ropsten, which can be used as a reference.
  2. Get the WETH used in CoFiX: calling deposit method.
  3. Create a Token + WETH Pair on Ropsten using Uniswap, see WETH9 in constants.ts for address.
    • Note: Using the value in the branch of network === 3.

Development

Basic Steps

  1. git clone
  2. npm i, install dependencies
  3. npm start, run it locally. Visit http://localhost:4200 in your browser.
    • dev mode, npm start
    • prod mode, npm start --configuration=production
    • e2e testing, npm start --configuration=e2e

Run Unit Test

npm run test

Run E2E Test

e2e tests are based on TestCafe, and test codes can be found in testcafe subdirectory.

  1. enter testcafe
  2. npm i
  3. npm start --configuration=e2e, kick off a local app instance
  4. npm test, running this command in another terminal

More details please check How to run CoFiX e2e testing.

Build for deployment

npm run build

Copy the www folder in your project directory and upload it to your remote web server(AWS S3 or something like that).

git workflow

At work branch:

  1. git pull origin [dev branch] --rebase
  2. git commit locally
  3. run unit tests && e2e tests
  4. git push orgin [dev branch]

Also, please do not use git push -f .

Git Log Specification

Follow Angular git log specification. Recommend git-cz which will make it easier.

CI / CD

Currently, the CI/CD will serves three environments.

  • Test environment: stage.cofix.io
  • Production environment: cofix.io / www.cofix.io
  • Hotfix environment: hotfix.cofix.io

The whole mechanism is done with github actions.

The general idea is to trigger the whole pipeline based on git push on branch. At the same time, in order to avoid releasing at every push, because not every push is worth being released, we need some control. Unfortunately, github doesn't currently support manual triggering like gitlab does, so we take a workaround, here's the design and the main steps.

We've added ligthhouse reports after every deployment. You can find the reports in action artifacts, or open the online URL at step output: deploy -> Audit URLs using Lighthouse -> Uploading.

Branch Model

The following defines the branch model for future development, making it easier to work with CI/CD.

  1. main branch, which no longer allows direct pushes, update will be done by PRs from other branches. After each PR being merged, the deployment to the production environment is automatically triggered.
  2. stage branch, as above, the only change is it will use test environment.
  3. Dev branch, which will receive the daily commits from developers and be named after sementic version (such as branch v1.1.0) . Also, it will be deleted when all of its updates are merged into main branch.
  4. hotfix branch, it is for emergency fix after production is released and will be created from main branch.

At the same time, stage branch will be the default branch.

Processes and Steps

  1. Delopyment to testing environment.
    • Development Branch -> stage branch PR
    • Triggered after merging, stage.cofix.io
  2. Delopyment to the production environment:
    • Development Branch -> main Branch PR
    • Triggered after merging, www.cofix.io.
  3. Emergency release
    • hotfix -> hotfix test -> main release.

Also, for merging after a hotfix occurs:

  • If the difference is not significant, hotfix -> development branch.
  • If the difference is large, manual synchronization is recommended.

Functional Goal

This CI/CD will serve 3 steps:

  • compilation
  • testing
  • deployment

WIP:

  • Test automation: Unit Tests and E2E Tests

In the future, the following will be added:

  • commitlint: pipeline will fail if commit logs do follow angular commit log specification.
  • gts, pipeline will fail when code style does notcomply with specifications.
  • Semantic Publishing: Generate tag and change logs automatically.

cofix-web-user-interface-v2.0's People

Contributors

abcfy2 avatar foxgem avatar huweihong avatar mly0813 avatar zhangzhongnan928 avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

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

Forkers

arthur-zhuk

cofix-web-user-interface-v2.0's Issues

Improve Navigation in the Pool Tab

I created a prototype for you guys. If you have a problem opening this up, let me know.

https://invis.io/A8Z38EPF7EV

So the most important change is the Back button in a different place. And Add Liquidity Box is no longer there when you are removing liquidity.

Screenshot 2020-10-14 at 14 29 21

Try to:

  • Hit Add Liquidity
  • Approve Contract
  • Add Liquidity
  • Open ETH/USDT Tab
  • Remove Liquidity
  • Come Back with back button

Add Helpful tooltips

We need to add tooltips. They appear on hover on desktop, and on tap on mobile devices. To hide them, simply move your mouse away from the question mark icon, or tap anywhere on mobile.

They are all screens, always one in the top right corner, and the rest next to each row.

我们需要添加工具提示。它们出现在桌面上的悬停上以及移动设备上的点击上。要隐藏它们,只需将鼠标从问号图标移开,或在移动设备上的任意位置点击。

它们都是屏幕,总是在右上角一个屏幕,其余屏幕紧挨着每一行。

Screenshot 2020-10-13 at 14 47 42

This is how they look:
Zeplin: https://app.zeplin.io/project/5f7d9b83384ebd4699f03e3b/screen/5f85a08a10ce9fb77cbefd9e/
Icon: https://zpl.io/2EL4lJn

Swap_Desktop_Tooltips
Swap_Desktop_In_Entered

You can find them in all tabs, almost always in the same place.
We are working on the content with Sunil and Lucas.

您可以在所有选项卡中找到它们,几乎总是在同一位置。
我们正在与Sunil和Lucas合作开发内容。

Pool_Desktop_Add_ETH_USDT

Add Last Transactions Tracker

Use Unsiwap as a reference.

This is right before you hit "SWAP"

Swap_Desktop_In_Entered

When you finally hit SWAP, the button becomes inactive with the spinner inside.
https://zpl.io/aBLQEEp

In the top right corner where we used to have the Account button, it becomes green with a spinner and Number of transactions pending.
Screenshot 2020-10-14 at 10 41 40

https://zpl.io/2vwDek7

Swap_Desktop_In_Pending

When you click the top right corner green button, you will see a modal window with account basic info and Recent Transactions. You can open each transaction in Etherscan.

Swap_Desktop_Transaction

Don't worry about changing the Blockie icon for now. You can use just one for all accounts
https://zpl.io/bJeL4MD

Fallback language is not English

The screenshot is taken from a computer configured to use Spanish (and does not have Chinese in the acceptable language list)

Cofix shows Chinese when other websites don't

screenshot

Language setting does not have Chinese

Captura de pantalla de 2020-10-15 14-41-59

Inputs are lost when you change USDT to ETH in Swaps

I added ETH, and USDT was updated. I changed From/To and my inputs disappeared. Putting ETH number again, now USDT isn’t updated. But if I change From/To, my inputs remain.

So it should keep inputs.

Here is how to make it right:

revolut

Add a loading status sign [Malbork]

If any part of the page is loading info from infura or wallet, this loading sign need to show up, to let users know the UI is loading, you don't need to refresh, just wait for awhile.

Same if the page don't show info and loading sign, then users know there is something wrong, let refresh.

Swap Tab fees are unclear or missing information

From the discussed, Swap Tab page misses fees information, and users are not understanding why or how their traded swap is working. This is a proposal to improve on this.

1. Swap Desktop - Empty

Swap_Desktop_In_Empty

2. Swap Desktop - Values Entered

Swap_Desktop_In_Entered-Minimum

3. Swap Desktop - Tooltip/Popup view

Swap_Desktop_In_Tooltips

4. Swap Desktop - Expanded View

Swap_Desktop_Expanded

5. Swap Desktop - Alternative; "Slippage/Tolerance" instead of "Minimum Received"

Swap_Desktop_In_Entered-Tolerance

6. Tooltips View - All

Swap_Desktop_In_Tooltips-all

Changes:

  • Added Trade Price, which includes all transaction fees minimized. When open, it includes a simplified breakdown of fees. To see all in detail (trading fees, coefficient, etc), user should click "Learn More" which will take to a documentation page. Simplification is to increase trust in the interface.
  • Under the minimization and idea of trust, we could even add a CoinGecko API or similar call to show market value comparison.
  • Kept Oracle Fee, but this could also be placed under Trade Price minimization.
  • Minimum Received added, similar to Uniswap. They do a great job in keeping slippage easy to understand, so not much to improve.
  • For the tooltips, changed these into modal popups, so we can add the "Learn More" buttons.
  • Some minor visual change proposals: From/To boxes (it looks very messy at its current state), Replaced divider between From/To with an arrow, Changed what is "CoFi Swap?" information box to blue rather than grey (follows the pattern of the yellow warning).
  • Tooltip/popups and information box text reviews.

Unstick the top menu on mobile

We are losing a lot of space because the Top Menu is stuck to the top of the page. Unstick this. Leave just a bottom bar stuck.

cofix
uniswap

Add Token Supply Details

It was difficult to understand how many tokens would be issued for the whole COFI supply. You can find it in the docs, but users might enjoy getting that info on the front end.

after the user newly connected to Metamask, the "Max" button can't provide the user with their balance.

This happens only if the user uses the "Connect to Wallet" button to connect to Metamask - it is not reporducible if the user is already connected to Metamask.

Observe this error which might have caused the bug:

src/app/service/cofix.service.ts: async getERC20Balance is called before the user logins to Metamask

Reproduce:

  1. Log out of your current Metamask session (if not already)
  2. Access cofix site (locally served)
    http://localhost:8100/#/
  3. Hit "Connect Wallet" - MetaMask pops up asking to login - don't login yet
  4. At this point, getERC20Balance is fired without any valid address, this.currentAccount is undefined, causing a call revert exception

Add Google Tag Manager

Paste this code as high in the of the page as possible:

<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); })(window,document,'script','dataLayer','GTM-5SQX68L');</script>

Additionally, paste this code immediately after the opening tag:

<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-5SQX68L" height="0" width="0" style="display:none;visibility:hidden"></iframe>

Also, not sure how would it work with China.

Keep entered values in caches even if not connected with wallet

Problem I saw in one user test:
You enter Cofix, your wallet is not connected, you enter amount in swap, you hit "connect to wallet" and the entered values in inputs are gone.

You can come back with "Connect to Wallet" button by default (I see you removed it). But make sure that you keep users' inputs when connected/not connected.

you enter inputs
Swap_Desktop_Entered_Out

you connect the wallet, and the entered amounts stays

Swap_Desktop_Entered_In

HotJar cannot access CSS

We are using hotjar that is triggered with google tag manager.

HotJar records the users screen movements for UX purposes.

At the moment, the HotJar service is unable to access the CSS files for the site, so the screen recordings display without the CSS.

The most common issues are explained here: https://www.youtube.com/watch?v=iHf58Avh8mo&feature=emb_title&ab_channel=Hotjar & https://help.hotjar.com/hc/en-us/articles/360047603933-Why-is-my-Heatmap-screenshot-only-showing-HTML-and-no-CSS-

I checked the S3 bucket and have not found any IP or user agent restrictions and have added a support ticket on hotjar. If you would like access to the hotjar, please provide your email address in this issue.

Not equal box sizes in tabs

If you keep switching between Pool and Mining very fast, you will notice "the jump" It looks like they are not aligned wel, also not the same size and width. Here are two screenshots on the top of each other.

The radius of the rounded corner should be 16pt. The width of these boxes on desktop - 510 px.

如果您一直非常快速地在“ Pool”和“ Mining”之间切换,您会注意到“跳跃”,好像它们没有对齐,大小和宽度也不一样。这是彼此顶部的两个屏幕截图。

圆角半径应为16pt。这些框在台式机上的宽度-510像素

thejump

Screenshot 2020-10-12 at 12 01 18

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.