Skip to content

Commit

Permalink
Merge pull request #46 from hummingbot/staging
Browse files Browse the repository at this point in the history
sync staging -> main for Gateway version 1.13.0
  • Loading branch information
fengtality authored Feb 28, 2023
2 parents 7c07517 + 57a667b commit 25e7496
Show file tree
Hide file tree
Showing 43 changed files with 2,133 additions and 848 deletions.
19 changes: 11 additions & 8 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: technote-space/get-diff-action@v6
with:
PATTERNS: |
Expand All @@ -41,18 +41,18 @@ jobs:

steps:
- name: Checkout commit
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Use Node.js
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: '18.x'
node-version: 18

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v2
- uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
Expand All @@ -73,19 +73,22 @@ jobs:
- name: Build project
run: yarn build

- name: Replace testnet nodeURL for local hardhat node, and run unit test
- name: Replace testnet nodeURL for local hardhat node
run: |
mkdir conf db
cp src/templates/* conf
sed -i 's/https:\/\/rpc.ankr.com\/eth_goerli/http:\/\/127.0.0.1:8545\//g' ./conf/ethereum.yml
sed -i 's/https:\/\/arbitrum-rinkeby.infura.io\/v3/http:\/\/127.0.0.1:8545\//g' ./conf/ethereum.yml
sed -i 's/https:\/\/rpc.ankr.com\/optimism/http:\/\/127.0.0.1:8545\//g' ./conf/ethereum.yml
sed -i 's/https:\/\/rpc.ankr.com\/avalanche/http:\/\/127.0.0.1:8545\//g' ./conf/avalanche.yml
sed -i 's/https:\/\/rpc.ankr.com\/avalanche_fuji/http:\/\/127.0.0.1:8545\//g' ./conf/avalanche.yml
sed -i 's/https:\/\/rpc.ankr.com\/polygon_mumbai/http:\/\/127.0.0.1:8545\//g' ./conf/polygon.yml
sed -i 's/https:\/\/api.s0.b.hmny.io/http:\/\/127.0.0.1:8545\//g' ./conf/harmony.yml
sed -i 's/https:\/\/data-seed-prebsc-1-s1.binance.org:8545/http:\/\/127.0.0.1:8545\//g' ./conf/binance-smart-chain.yml
sed -i 's/https:\/\/cosmos-testnet-rpc.allthatnode.com:26657/http:\/\/127.0.0.1:8545\//g' ./conf/cosmos.yml
yarn test:unit
sed -i 's/https:\/\/cosmos-mainnet-rpc.allthatnode.com:26657/http:\/\/127.0.0.1:8545\//g' ./conf/cosmos.yml
sed -i 's/https:\/\/evm-t3.cronos.org/http:\/\/127.0.0.1:8545\//g' ./conf/cosmos.yml
sed -i 's/https:\/\/evm.cronos.org/http:\/\/127.0.0.1:8545\//g' ./conf/cosmos.yml
- name: Run unit test coverage
if: github.event_name == 'pull_request'
Expand All @@ -94,4 +97,4 @@ jobs:
git fetch --all -q
git checkout -b $GITHUB_SHA
yarn test:cov
git diff origin/$GITHUB_BASE_REF | yarn diff-test-coverage -c ./coverage/lcov.info -t lcov -b 50 -l 60
# git diff origin/$GITHUB_BASE_REF | yarn diff-test-coverage -c ./coverage/lcov.info -t lcov -b 50 -l 60
16 changes: 7 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM node:18.10.0

# Set labels
LABEL application="gateway"
LABEL application="gateway-v2"
LABEL branch=${BRANCH}
LABEL commit=${COMMIT}
LABEL date=${BUILD_DATE}
Expand All @@ -21,22 +21,20 @@ RUN apt-get update && \
rm -rf /var/lib/apt/lists/*

# app directory
WORKDIR /usr/src/app
WORKDIR /usr/src/app/

# copy pwd file to container
COPY . .

# create sym links
RUN ln -s /conf /usr/src/app/conf && \
ln -s /logs /usr/src/app/logs && \
ln -s /certs /usr/src/app/certs

# create app writable directory for db files
RUN mkdir /var/lib/gateway
RUN chown -R hummingbot /var/lib/gateway

# copy pwd file to container
COPY . .
RUN mkdir -p /var/lib/gateway /certs /conf /logs /usr/src/app/gateway.level /usr/src/app/transactions.level \
/usr/src/app/db
RUN chown -R hummingbot:hummingbot /var/lib/gateway /usr/src/app/logs /usr/src/app/conf /usr/src/app/certs \
/usr/src/app/gateway.level /usr/src/app/transactions.level /usr/src/app/db

# install dependencies
RUN yarn install --frozen-lockfile
Expand All @@ -45,4 +43,4 @@ EXPOSE 15888

RUN yarn build

CMD ["bin/docker-start.sh"]
CMD ["gosu", "hummingbot:hummingbot", "yarn", "run", "start"]
22 changes: 22 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.ONESHELL:
.PHONY: test
.PHONY: docker
.PHONY: build
.PHONY: prettify
.PHONY: lint

test:
yarn test:unit

lint:
yarn run lint

prettify:
yarn run prettier

build:
yarn build

docker:
git clean -xdf && docker build -t hummingbot/gateway${TAG} -f Dockerfile .

20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,26 @@ Dependencies:

See the [`/docker`](./docker) folder for Docker installation scripts and instructions on how to use them.


### Build Gateway Docker Image locally

Dependencies:
* [Docker](https://docker.com)

To build the gateway docker image locally execute the below make command:

```bash
make docker
```

Pass the `${TAG}` environmental variable to add a tag to the docker
image. For example, the below command will create the `hummingbot/gateway:dev`
image.

```bash
TAG=dev make docker
```

## Documentation

See the [official Gateway docs](https://docs.hummingbot.org/gateway/).
Expand Down
9 changes: 0 additions & 9 deletions bin/docker-start.sh

This file was deleted.

31 changes: 23 additions & 8 deletions docker/gateway-create.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,26 @@ prompt_passphrase
GMT_OFFSET=$(date +%z)

# Check available open port for Gateway
PORT=15888
LIMIT=$((PORT+1000))
while [[ $PORT -le LIMIT ]]
GATEWAY_PORT=15888
LIMIT=$((GATEWAY_PORT+1000))
while [[ $GATEWAY_PORT -le LIMIT ]]
do
if [[ $(netstat -nat | grep "$PORT") ]]; then
if [[ $(netstat -nat | grep "$GATEWAY_PORT") ]]; then
# check another port
((PORT = PORT + 1))
((GATEWAY_PORT = GATEWAY_PORT + 1))
else
break
fi
done

# Check available open port for Gateway docs
DOCS_PORT=8080
LIMIT=$((DOCS_PORT+1000))
while [[ $DOCS_PORT -le LIMIT ]]
do
if [[ $(netstat -nat | grep "$DOCS_PORT") ]]; then
# check another port
((DOCS_PORT = DOCS_PORT + 1))
else
break
fi
Expand All @@ -80,7 +93,8 @@ printf "%30s %5s\n" "Hummingbot instance ID:" "$HUMMINGBOT_INSTANCE_ID"
printf "%30s %5s\n" "Gateway conf path:" "$CONF_FOLDER"
printf "%30s %5s\n" "Gateway log path:" "$LOGS_FOLDER"
printf "%30s %5s\n" "Gateway certs path:" "$CERTS_FOLDER"
printf "%30s %5s\n" "Gateway port:" "$PORT"
printf "%30s %5s\n" "Gateway port:" "$GATEWAY_PORT"
printf "%30s %5s\n" "Gateway docs port:" "$DOCS_PORT"
echo

prompt_existing_certs_path () {
Expand Down Expand Up @@ -140,7 +154,8 @@ create_instance () {
# Launch a new instance of gateway
docker run \
--name $INSTANCE_NAME \
-p $PORT:$PORT \
-p $GATEWAY_PORT:15888 \
-p $DOCS_PORT:8080 \
-v $CONF_FOLDER:/usr/src/app/conf \
-v $LOGS_FOLDER:/usr/src/app/logs \
-v $CERTS_FOLDER:/usr/src/app/certs \
Expand All @@ -152,6 +167,6 @@ if [[ "$PROCEED" == "Y" || "$PROCEED" == "y" ]]
then
create_instance
else
echo " Aborted"
echo "Aborted"
echo
fi
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hummingbot-gateway",
"version": "dev-1.13.0",
"version": "1.13.0",
"description": "Middleware that helps Hummingbot clients access standardized DEX API endpoints on different blockchain networks",
"main": "index.js",
"license": "Apache-2.0",
Expand Down Expand Up @@ -71,7 +71,7 @@
"level": "^8.0.0",
"lodash": "^4.17.21",
"mathjs": "^10.5.0",
"minimist": "^1.2.5",
"minimist": "^1.2.6",
"morgan": "^1.10.0",
"near-api-js": "1.0.0",
"quickswap-sdk": "^3.0.8",
Expand Down
Loading

0 comments on commit 25e7496

Please sign in to comment.