Skip to content
This repository has been archived by the owner on Feb 25, 2023. It is now read-only.

Commit

Permalink
Merge pull request #27 from CoinAlpha/development
Browse files Browse the repository at this point in the history
release / v0.2.0 sync dev => master
  • Loading branch information
dennisocana authored Dec 17, 2020
2 parents 998b6c6 + 5559189 commit a85e2f3
Show file tree
Hide file tree
Showing 26 changed files with 3,507 additions and 366 deletions.
5 changes: 4 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ npm-debug.log
*.env
*.env.*
# except the example .env.example
!.env.example
!.env.example

# Gateway API files
*.pem
34 changes: 21 additions & 13 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,40 +1,48 @@
# Configuration file

APPNAME=Hummingbot Gateway API
NODE_ENV=dev
PORT=5000
PROTOCOLS=["celo", "terra", "balancer", "eth"]

# use only if ip whitelist is required for local or docker instance
# note that docker instance does not use 127.0.0.1 address
# ipv6 format for locahost ["::ffff:127.0.0.1", "::ffff:1", "fe80::1", "::1"]
IP_WHITELIST=

HUMMINGBOT_INSTANCE_ID={client_id}

# Celo

# Terra
TERRA_LCD_URL=https://tequila-lcd.terra.dev
TERRA_CHAIN=tequila-0004

# Balancer
# - network: mainnet, kovan, etc
# - mainnet: https://lcd.terra.dev
# - mainnet chain: columbus-4
# - testnet: https://tequila-lcd.terra.dev
# - testnet chain: tequila-0004
TERRA_LCD_URL={testnet_lcd_url}
TERRA_CHAIN={testnet_chain_id}

# Ethereum
# - chain: mainnet, kovan, etc
# - rpc url: infura or other rpc url
BALANCER_NETWORK={network}
ETHEREUM_RPC_URL=https://{network}.infura.io/v3/{api_key}
ETHEREUM_CHAIN={chain}
ETHEREUM_RPC_URL=https://{chain}.infura.io/v3/{api_key}

# subgraph_network:
# Balancer
# subgraph_chain
# Reference: https://docs.balancer.finance/sor/development#subgraph
# - mainnet: balancer
# - kovan: balancer-kovan
# Note: REACT_APP_SUBGRAPH_URL used by @balancer-labs/sor
REACT_APP_SUBGRAPH_URL=https://api.thegraph.com/subgraphs/name/balancer-labs/{subgraph_network}
REACT_APP_SUBGRAPH_URL=https://api.thegraph.com/subgraphs/name/balancer-labs/{subgraph_chain}

# exchange_proxy:
# Reference: https://docs.balancer.finance/smart-contracts/addresses
# - kovan: 0x4e67bf5bD28Dd4b570FBAFe11D0633eCbA2754Ec
# - mainnet: 0x3E66B66Fd1d0b02fDa6C811Da9E0547970DB2f21
# - kovan: 0x4e67bf5bD28Dd4b570FBAFe11D0633eCbA2754Ec
EXCHANGE_PROXY={exchange_proxy}

# Uniswap
# Reference: https://uniswap.org/docs/v2/smart-contracts/router02/
UNISWAP_ROUTER=0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D

# cert
CERT_PATH={full_path_to_certs_folder}
CERT_PASSPHRASE={passphrase}
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ npm-debug.log
dist/

# cert
certs/
*.pem
*.srl
*.key
Expand Down
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
FROM node:10.22.0-alpine

# Set labels
LABEL application="gateway-api"

# app directory
WORKDIR /usr/src/app

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ We created hummingbot to promote **decentralized market-making**: enabling membe

### Install Hummingbot

- [Installation](https://docs.hummingbot.io/installation/overview/)
- [Quickstart guide](https://docs.hummingbot.io/quickstart/)
- [All installation options](https://docs.hummingbot.io/installation/overview/)

### Get support
- Chat with our support team on [Discord](https://discord.hummingbot.io)
Expand Down
2 changes: 1 addition & 1 deletion certs/readme.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
certs dir
certs dir for local testing only
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
"@uniswap/sdk": "^3.0.3",
"@balancer-labs/sor": "^0.3.3",
"@terra-money/terra.js": "^0.5.8",
"bignumber.js": "^9.0.0",
Expand Down
2 changes: 1 addition & 1 deletion setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This can be used as a common API server to handle transactions that requires cus
## Development Requirements

- NodeJS
- Tested on Node v10.22.0
- Tested on Node v10.22.1
- https://docs.npmjs.com/downloading-and-installing-node-js-and-npm

```bash
Expand Down
24 changes: 11 additions & 13 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import bodyParser from 'body-parser'
import express from 'express'
import helmet from 'helmet'
import { statusMessages } from './services/utils';
import { validateAccess } from './services/access';
import { IpFilter } from 'express-ipfilter'

// Routes
Expand All @@ -11,6 +12,7 @@ import balancerRoutes from './routes/balancer.route'
// import celoRoutes from './routes/celo.route'
import ethRoutes from './routes/eth.route'
import terraRoutes from './routes/terra.route'
import uniswapRoutes from './routes/uniswap.route'

// terminate if environment not found
const result = dotenv.config();
Expand All @@ -34,22 +36,18 @@ if (ipWhitelist) {
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));

app.use(validateAccess)

// mount all routes to this path
app.use('/api', apiRoutes);
app.use('/eth', ethRoutes);
// app.use('/celo', celoRoutes);
app.use('/terra', terraRoutes);
app.use('/balancer', balancerRoutes);
app.use('/uniswap', validateAccess, uniswapRoutes);
app.use('/api', validateAccess, apiRoutes);
app.use('/eth', validateAccess, ethRoutes);
// app.use('/celo', validateAccess, celoRoutes);
app.use('/terra', validateAccess, terraRoutes);
app.use('/balancer', validateAccess, balancerRoutes);

app.get('/', (req, res, next) => {
const cert = req.connection.getPeerCertificate()
if (req.client.authorized) {
next()
} else if (cert.subject) {
res.status(403).send({ error: statusMessages.ssl_cert_invalid })
} else {
res.status(401).send({ error: statusMessages.ssl_cert_required })
}
res.send('ok')
})

/**
Expand Down
7 changes: 5 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ if (result.error) {
const env = process.env.NODE_ENV
const port = process.env.PORT
const certPassphrase = process.env.CERT_PASSPHRASE
const balancerNetwork = process.env.BALANCER_NETWORK
const ethereumChain = process.env.ETHEREUM_CHAIN
const terraChain = process.env.TERRA_CHAIN
let certPath = process.env.CERT_PATH

if ((typeof certPath === 'undefined' && certPath == null) || certPath === '') {
Expand Down Expand Up @@ -79,4 +80,6 @@ server.listen(port)
server.on('error', onError)
server.on('listening', onListening)

console.log('server: gateway-api | port:', port, '| balancer-network:', balancerNetwork);
console.log('server: gateway-api | port:', port)
console.log(' - ethereum-chain:', ethereumChain)
console.log(' - terra-chain:', terraChain)
Loading

0 comments on commit a85e2f3

Please sign in to comment.