From 6d0c5dfb59af9bf709294473b8bd2268849a8e4b Mon Sep 17 00:00:00 2001 From: Michael Feng Date: Fri, 3 Feb 2023 10:06:24 -0800 Subject: [PATCH 1/9] (fix) rm eth gas station --- src/templates/root.yml | 4 ---- src/templates/ssl.yml | 6 +++--- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/templates/root.yml b/src/templates/root.yml index 74976f195f..7a78c484f9 100644 --- a/src/templates/root.yml +++ b/src/templates/root.yml @@ -20,10 +20,6 @@ configurations: configurationPath: polygon.yml schemaPath: ethereum-schema.json - $namespace ethereumGasStation: - configurationPath: ethereum-gas-station.yml - schemaPath: ethereum-gas-station-schema.json - $namespace logging: configurationPath: logging.yml schemaPath: logging-schema.json diff --git a/src/templates/ssl.yml b/src/templates/ssl.yml index e5bfacf950..af8162efb5 100644 --- a/src/templates/ssl.yml +++ b/src/templates/ssl.yml @@ -1,8 +1,8 @@ # need more details... -caCertificatePath: /usr/src/app/certs/ca_cert.pem +caCertificatePath: /Users/feng/Code/hummingbot/certs/ca_cert.pem # need more details... -certificatePath: /usr/src/app/certs/server_cert.pem +certificatePath: /Users/feng/Code/hummingbot/certs/server_cert.pem # need more details... -keyPath: /usr/src/app/certs/server_key.pem +keyPath: /Users/feng/Code/hummingbot/certs/server_key.pem From 0ae3e698e876626ce9d896dd253726ae2cdd5b9e Mon Sep 17 00:00:00 2001 From: Michael Feng Date: Fri, 3 Feb 2023 10:21:26 -0800 Subject: [PATCH 2/9] one certs path var --- src/https.ts | 7 ++++--- src/services/schema/ssl-schema.json | 6 ++---- src/templates/ssl.yml | 10 ++-------- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/src/https.ts b/src/https.ts index 0175d47e7e..f7d08d0a9a 100644 --- a/src/https.ts +++ b/src/https.ts @@ -6,19 +6,20 @@ import { ConfigManagerV2 } from './services/config-manager-v2'; export const addHttps = (app: Application) => { const serverKey = fs.readFileSync( - ConfigManagerV2.getInstance().get('ssl.keyPath'), + ConfigManagerV2.getInstance().get('ssl.certificatePath') + 'server_key.pem', { encoding: 'utf-8', } ); const serverCert = fs.readFileSync( - ConfigManagerV2.getInstance().get('ssl.certificatePath'), + ConfigManagerV2.getInstance().get('ssl.certificatePath') + + 'server_cert.pem', { encoding: 'utf-8', } ); const caCert = fs.readFileSync( - ConfigManagerV2.getInstance().get('ssl.caCertificatePath'), + ConfigManagerV2.getInstance().get('ssl.certificatePath') + 'ca_cert.pem', { encoding: 'utf-8', } diff --git a/src/services/schema/ssl-schema.json b/src/services/schema/ssl-schema.json index 6465fb7914..ba40bc5ee9 100644 --- a/src/services/schema/ssl-schema.json +++ b/src/services/schema/ssl-schema.json @@ -2,10 +2,8 @@ "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "properties": { - "caCertificatePath": { "type": "string" }, - "certificatePath": { "type": "string" }, - "keyPath": { "type": "string" } + "certificatePath": { "type": "string" } }, "additionalProperties": false, - "required": ["caCertificatePath", "certificatePath", "keyPath"] + "required": ["certificatePath"] } diff --git a/src/templates/ssl.yml b/src/templates/ssl.yml index af8162efb5..5cc64300bf 100644 --- a/src/templates/ssl.yml +++ b/src/templates/ssl.yml @@ -1,8 +1,2 @@ -# need more details... -caCertificatePath: /Users/feng/Code/hummingbot/certs/ca_cert.pem - -# need more details... -certificatePath: /Users/feng/Code/hummingbot/certs/server_cert.pem - -# need more details... -keyPath: /Users/feng/Code/hummingbot/certs/server_key.pem +# Path to folder where Hummingbot client generated self-signed certificates - ensure it ends in / +certificatePath: /Users/feng/Code/hummingbot/certs/ From 4b8f61a3c75ea48aa184653e54bc409a0d99ebf7 Mon Sep 17 00:00:00 2001 From: Michael Feng Date: Fri, 3 Feb 2023 10:26:22 -0800 Subject: [PATCH 3/9] move ssl to server.yml --- src/https.ts | 6 +++--- src/services/schema/server-schema.json | 5 +++-- src/services/schema/ssl-schema.json | 9 --------- src/templates/root.yml | 4 ---- src/templates/server.yml | 2 ++ src/templates/ssl.yml | 2 -- 6 files changed, 8 insertions(+), 20 deletions(-) delete mode 100644 src/services/schema/ssl-schema.json delete mode 100644 src/templates/ssl.yml diff --git a/src/https.ts b/src/https.ts index f7d08d0a9a..10bc3dc60b 100644 --- a/src/https.ts +++ b/src/https.ts @@ -6,20 +6,20 @@ import { ConfigManagerV2 } from './services/config-manager-v2'; export const addHttps = (app: Application) => { const serverKey = fs.readFileSync( - ConfigManagerV2.getInstance().get('ssl.certificatePath') + 'server_key.pem', + ConfigManagerV2.getInstance().get('server.certificatePath') + 'server_key.pem', { encoding: 'utf-8', } ); const serverCert = fs.readFileSync( - ConfigManagerV2.getInstance().get('ssl.certificatePath') + + ConfigManagerV2.getInstance().get('server.certificatePath') + 'server_cert.pem', { encoding: 'utf-8', } ); const caCert = fs.readFileSync( - ConfigManagerV2.getInstance().get('ssl.certificatePath') + 'ca_cert.pem', + ConfigManagerV2.getInstance().get('server.certificatePath') + 'ca_cert.pem', { encoding: 'utf-8', } diff --git a/src/services/schema/server-schema.json b/src/services/schema/server-schema.json index 95d17686e5..e64d1a2dbd 100644 --- a/src/services/schema/server-schema.json +++ b/src/services/schema/server-schema.json @@ -6,8 +6,9 @@ "ipWhitelist": { "type": "array" }, "unsafeDevModeWithHTTP": { "type": "boolean" }, "GMTOffset": { "type": "number" }, - "id": { "type": "string" } + "id": { "type": "string" }, + "certificatePath": { "type": "string" } }, "additionalProperties": false, - "required": ["port", "unsafeDevModeWithHTTP"] + "required": ["port", "unsafeDevModeWithHTTP", "certificatePath"] } diff --git a/src/services/schema/ssl-schema.json b/src/services/schema/ssl-schema.json deleted file mode 100644 index ba40bc5ee9..0000000000 --- a/src/services/schema/ssl-schema.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "properties": { - "certificatePath": { "type": "string" } - }, - "additionalProperties": false, - "required": ["certificatePath"] -} diff --git a/src/templates/root.yml b/src/templates/root.yml index 7a78c484f9..9a06a29630 100644 --- a/src/templates/root.yml +++ b/src/templates/root.yml @@ -24,10 +24,6 @@ configurations: configurationPath: logging.yml schemaPath: logging-schema.json - $namespace ssl: - configurationPath: ssl.yml - schemaPath: ssl-schema.json - $namespace defira: configurationPath: defira.yml schemaPath: defira-schema.json diff --git a/src/templates/server.yml b/src/templates/server.yml index 93d4137ebb..c6537c589d 100644 --- a/src/templates/server.yml +++ b/src/templates/server.yml @@ -8,3 +8,5 @@ unsafeDevModeWithHTTP: false GMTOffset: +0800 + +certificatePath: /Users/feng/Code/hummingbot/certs/ diff --git a/src/templates/ssl.yml b/src/templates/ssl.yml deleted file mode 100644 index 5cc64300bf..0000000000 --- a/src/templates/ssl.yml +++ /dev/null @@ -1,2 +0,0 @@ -# Path to folder where Hummingbot client generated self-signed certificates - ensure it ends in / -certificatePath: /Users/feng/Code/hummingbot/certs/ From b2c7c22f185bbf62473069bfaeb85ba05483b292 Mon Sep 17 00:00:00 2001 From: Michael Feng Date: Fri, 3 Feb 2023 14:31:25 -0800 Subject: [PATCH 4/9] move telemetry to server.yml --- src/services/logger.ts | 2 +- src/services/schema/server-schema.json | 10 ++++++++-- src/services/schema/telemetry-schema.json | 8 -------- src/templates/root.yml | 4 ---- src/templates/server.yml | 11 ++++++++--- 5 files changed, 17 insertions(+), 18 deletions(-) delete mode 100644 src/services/schema/telemetry-schema.json diff --git a/src/services/logger.ts b/src/services/logger.ts index 90c3a304a8..e0a1f836fa 100644 --- a/src/services/logger.ts +++ b/src/services/logger.ts @@ -83,7 +83,7 @@ export const updateLoggerToStdout = () => { }; export const telemetry = () => { - ConfigManagerV2.getInstance().get('telemetry.enabled') === true + ConfigManagerV2.getInstance().get('server.telemetry_enabled') === true ? logger.add(reportingProxy) : logger.remove(reportingProxy); }; diff --git a/src/services/schema/server-schema.json b/src/services/schema/server-schema.json index e64d1a2dbd..94ac35e6f2 100644 --- a/src/services/schema/server-schema.json +++ b/src/services/schema/server-schema.json @@ -7,8 +7,14 @@ "unsafeDevModeWithHTTP": { "type": "boolean" }, "GMTOffset": { "type": "number" }, "id": { "type": "string" }, - "certificatePath": { "type": "string" } + "certificatePath": { "type": "string" }, + "telemetry_enabled": { "type": "boolean" } }, "additionalProperties": false, - "required": ["port", "unsafeDevModeWithHTTP", "certificatePath"] + "required": [ + "port", + "unsafeDevModeWithHTTP", + "certificatePath", + "telemetry_enabled" + ] } diff --git a/src/services/schema/telemetry-schema.json b/src/services/schema/telemetry-schema.json deleted file mode 100644 index cdb8612791..0000000000 --- a/src/services/schema/telemetry-schema.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "properties": { - "enabled": { "type": "boolean" } - }, - "required": ["enabled"] -} diff --git a/src/templates/root.yml b/src/templates/root.yml index 9a06a29630..b2fedb21bb 100644 --- a/src/templates/root.yml +++ b/src/templates/root.yml @@ -56,10 +56,6 @@ configurations: configurationPath: server.yml schemaPath: server-schema.json - $namespace telemetry: - configurationPath: telemetry.yml - schemaPath: telemetry-schema.json - $namespace uniswap: configurationPath: uniswap.yml schemaPath: uniswap-schema.json diff --git a/src/templates/server.yml b/src/templates/server.yml index c6537c589d..bf77170776 100644 --- a/src/templates/server.yml +++ b/src/templates/server.yml @@ -4,9 +4,14 @@ port: 15888 # The IPs allowed to access gateway. localhost is allowed by default. ipWhitelist: [] -unsafeDevModeWithHTTP: false +# GMT Offset +GMTOffset: +0800 +# Path to folder where Hummingbot generates self-signed certificates +certificatePath: /Users/feng1/Code/hummingbot/certs/ -GMTOffset: +0800 +# Runs Gateway in unsafe dev mode with HTTP if true +unsafeDevModeWithHTTP: false -certificatePath: /Users/feng/Code/hummingbot/certs/ +# Collects data about API usage if true +telemetry_enabled: false \ No newline at end of file From 95df4f8fbba964509b51333353dceab5da9062a1 Mon Sep 17 00:00:00 2001 From: Michael Feng Date: Fri, 3 Feb 2023 14:42:02 -0800 Subject: [PATCH 5/9] move logging to server.yml --- README.md | 16 ++++++---------- src/services/logger.ts | 4 ++-- src/services/schema/server-schema.json | 7 +++++-- src/templates/logging.yml | 6 ------ src/templates/root.yml | 4 ---- src/templates/server.yml | 14 +++++++++++--- test/services/logger.test.ts | 4 ++-- 7 files changed, 26 insertions(+), 29 deletions(-) delete mode 100644 src/templates/logging.yml diff --git a/README.md b/README.md index c58412e4c3..4dcd9e9588 100644 --- a/README.md +++ b/README.md @@ -30,17 +30,13 @@ This is a list of DEX connections currently supported by Gateway. There are a number of ways to contribute to gateway. -- Add a new blockchain. +- File an issue at [hummingbot issues](https://github.com/hummingbot/gateway/issues) -- Add a new connector/DEX. +- Make a [pull request](https://github.com/hummingbot/gateway/) -- Fix a bug. +- Edit the [docs](https://github.com/hummingbot/hummingbot-site/) -- File an issue at [hummingbot issues](https://github.com/hummingbot/hummingbot/issues) - -- Make a PR for anything useful on [hummingbot](https://github.com/hummingbot/hummingbot/). - -- Vote on a snapshot proposal: [Hummingbot PRP](https://snapshot.org/#/hbot-prp.eth), [Hummingbot Foundation - HGP](https://snapshot.org/#/hbot.eth), [Hummingbot Improvement Proposals](https://snapshot.org/#/hbot-ip.eth). +- Vote on a [Snapshot proposal](https://snapshot.org/#/hbot.eth) ## Configuration @@ -50,9 +46,9 @@ Before running gateway, you need to setup some configs. You can start by copying - If you want to turn off `https`, set `unsafeDevModeWithHTTP` to `true` in [conf/server.yml](./conf/server.yml). -- If you gateway to log to standard out, set `logToStdOut` to `true` in [conf/logging.yml](./conf/logging.yml). +- If you gateway to log to standard out, set `logToStdOut` to `true` in [conf/server.yml](./conf/server.yml). -- Edit the path to the SSL files in [conf/ssl.yml](./conf/ssl.yml). This can be generated by hummingbot with `gateway generate-certs`. +- Edit `certificatePath` in [conf/server.yml](./conf/server.yml). This can be generated by Hummingbot with `gateway generate-certs`. The hummingbot client is also able to edit this config files. diff --git a/src/services/logger.ts b/src/services/logger.ts index e0a1f836fa..8c77abaaf2 100644 --- a/src/services/logger.ts +++ b/src/services/logger.ts @@ -46,7 +46,7 @@ const sdtoutFormat = winston.format.combine( ); const getLogPath = () => { - let logPath = ConfigManagerV2.getInstance().get('logging.logPath'); + let logPath = ConfigManagerV2.getInstance().get('server.logPath'); logPath = [appRoot.path, 'logs'].join('/'); return logPath; }; @@ -77,7 +77,7 @@ const reportingProxy = new TelemetryTransport({ }); export const updateLoggerToStdout = () => { - ConfigManagerV2.getInstance().get('logging.logToStdOut') === true + ConfigManagerV2.getInstance().get('server.logToStdOut') === true ? logger.add(toStdout) : logger.remove(toStdout); }; diff --git a/src/services/schema/server-schema.json b/src/services/schema/server-schema.json index 94ac35e6f2..2a88d53273 100644 --- a/src/services/schema/server-schema.json +++ b/src/services/schema/server-schema.json @@ -8,13 +8,16 @@ "GMTOffset": { "type": "number" }, "id": { "type": "string" }, "certificatePath": { "type": "string" }, - "telemetry_enabled": { "type": "boolean" } + "telemetry_enabled": { "type": "boolean" }, + "logPath": { "type": "string" }, + "logToStdOut": { "type": "boolean" } }, "additionalProperties": false, "required": [ "port", "unsafeDevModeWithHTTP", "certificatePath", - "telemetry_enabled" + "telemetry_enabled", + "logPath" ] } diff --git a/src/templates/logging.yml b/src/templates/logging.yml deleted file mode 100644 index c5ffe44046..0000000000 --- a/src/templates/logging.yml +++ /dev/null @@ -1,6 +0,0 @@ -# The directory path where logs will be stored. -logPath: './logs' - -# If true, logs will be stored in logPath and printed to stdout. If false, they -# will only be stored in logPath and not printed to stdout. -logToStdOut: true diff --git a/src/templates/root.yml b/src/templates/root.yml index b2fedb21bb..30dc8201e6 100644 --- a/src/templates/root.yml +++ b/src/templates/root.yml @@ -20,10 +20,6 @@ configurations: configurationPath: polygon.yml schemaPath: ethereum-schema.json - $namespace logging: - configurationPath: logging.yml - schemaPath: logging-schema.json - $namespace defira: configurationPath: defira.yml schemaPath: defira-schema.json diff --git a/src/templates/server.yml b/src/templates/server.yml index bf77170776..15e6aa13df 100644 --- a/src/templates/server.yml +++ b/src/templates/server.yml @@ -1,7 +1,7 @@ -# The port to expose the gateway server on. +# Port to expose the gateway server on port: 15888 -# The IPs allowed to access gateway. localhost is allowed by default. +# IPs allowed to access gateway. localhost is allowed by default. ipWhitelist: [] # GMT Offset @@ -10,8 +10,16 @@ GMTOffset: +0800 # Path to folder where Hummingbot generates self-signed certificates certificatePath: /Users/feng1/Code/hummingbot/certs/ +# Path to folder where logs will be stored. +logPath: './logs' + +# If true, logs will be stored in logPath and printed to stdout. If false, they +# will only be stored in logPath and not printed to stdout. +logToStdOut: true + # Runs Gateway in unsafe dev mode with HTTP if true unsafeDevModeWithHTTP: false # Collects data about API usage if true -telemetry_enabled: false \ No newline at end of file +telemetry_enabled: false + diff --git a/test/services/logger.test.ts b/test/services/logger.test.ts index 30228ebe01..37de22f17f 100644 --- a/test/services/logger.test.ts +++ b/test/services/logger.test.ts @@ -8,12 +8,12 @@ import { describe('Test logger', () => { it('updateLoggerToStdout works', (done) => { - ConfigManagerV2.getInstance().set('logging.logToStdOut', true); + ConfigManagerV2.getInstance().set('server.logToStdOut', true); updateLoggerToStdout(); const ofTypeConsole = (element: any) => element instanceof winston.transports.Console; expect(logger.transports.some(ofTypeConsole)).toEqual(true); - ConfigManagerV2.getInstance().set('logging.logToStdOut', false); + ConfigManagerV2.getInstance().set('server.logToStdOut', false); updateLoggerToStdout(); // Not sure why the below test doesn't on Github but passes on local // expect(logger.transports.some(ofTypeConsole)).toEqual(false); From 2b0050e77ae02fbff2a13c98231a0d97f99d4ed8 Mon Sep 17 00:00:00 2001 From: Michael Feng Date: Fri, 3 Feb 2023 14:52:48 -0800 Subject: [PATCH 6/9] move database to server yml --- src/chains/avalanche/avalanche.ts | 4 ++-- .../binance-smart-chain.ts | 4 ++-- src/chains/cronos/cronos.ts | 4 ++-- src/chains/ethereum/ethereum.ts | 4 ++-- src/chains/harmony/harmony.ts | 4 ++-- src/chains/near/near.ts | 2 +- src/chains/polygon/polygon.ts | 4 ++-- src/services/schema/database-schema.json | 10 ---------- src/services/schema/server-schema.json | 14 ++++++++----- src/templates/database.yml | 2 -- src/templates/root.yml | 20 ++++++++----------- src/templates/server.yml | 20 +++++++++++++------ 12 files changed, 44 insertions(+), 48 deletions(-) delete mode 100644 src/services/schema/database-schema.json delete mode 100644 src/templates/database.yml diff --git a/src/chains/avalanche/avalanche.ts b/src/chains/avalanche/avalanche.ts index c903fff874..fdd5445ebd 100644 --- a/src/chains/avalanche/avalanche.ts +++ b/src/chains/avalanche/avalanche.ts @@ -27,8 +27,8 @@ export class Avalanche extends EthereumBase implements Ethereumish { config.network.tokenListType, config.manualGasPrice, config.gasLimitTransaction, - ConfigManagerV2.getInstance().get('database.nonceDbPath'), - ConfigManagerV2.getInstance().get('database.transactionDbPath') + ConfigManagerV2.getInstance().get('server.nonceDbPath'), + ConfigManagerV2.getInstance().get('server.transactionDbPath') ); this._chain = config.network.name; this._nativeTokenSymbol = config.nativeCurrencySymbol; diff --git a/src/chains/binance-smart-chain/binance-smart-chain.ts b/src/chains/binance-smart-chain/binance-smart-chain.ts index 117a78f6c7..2404759558 100644 --- a/src/chains/binance-smart-chain/binance-smart-chain.ts +++ b/src/chains/binance-smart-chain/binance-smart-chain.ts @@ -26,8 +26,8 @@ export class BinanceSmartChain extends EthereumBase implements Ethereumish { config.network.tokenListType, config.manualGasPrice, config.gasLimitTransaction, - ConfigManagerV2.getInstance().get('database.nonceDbPath'), - ConfigManagerV2.getInstance().get('database.transactionDbPath') + ConfigManagerV2.getInstance().get('server.nonceDbPath'), + ConfigManagerV2.getInstance().get('server.transactionDbPath') ); this._chain = config.network.name; this._nativeTokenSymbol = config.nativeCurrencySymbol; diff --git a/src/chains/cronos/cronos.ts b/src/chains/cronos/cronos.ts index 9b2ae7eee9..e84f5dea00 100755 --- a/src/chains/cronos/cronos.ts +++ b/src/chains/cronos/cronos.ts @@ -26,8 +26,8 @@ export class Cronos extends EthereumBase implements Ethereumish { config.network.tokenListType, config.manualGasPrice, config.gasLimitTransaction, - ConfigManagerV2.getInstance().get('database.nonceDbPath'), - ConfigManagerV2.getInstance().get('database.transactionDbPath') + ConfigManagerV2.getInstance().get('server.nonceDbPath'), + ConfigManagerV2.getInstance().get('server.transactionDbPath') ); this._chain = config.network.name; this._nativeTokenSymbol = config.nativeCurrencySymbol; diff --git a/src/chains/ethereum/ethereum.ts b/src/chains/ethereum/ethereum.ts index a0e9903151..0eb0c7f196 100644 --- a/src/chains/ethereum/ethereum.ts +++ b/src/chains/ethereum/ethereum.ts @@ -32,8 +32,8 @@ export class Ethereum extends EthereumBase implements Ethereumish { config.network.tokenListType, config.manualGasPrice, config.gasLimitTransaction, - ConfigManagerV2.getInstance().get('database.nonceDbPath'), - ConfigManagerV2.getInstance().get('database.transactionDbPath') + ConfigManagerV2.getInstance().get('server.nonceDbPath'), + ConfigManagerV2.getInstance().get('server.transactionDbPath') ); this._chain = network; this._nativeTokenSymbol = config.nativeCurrencySymbol; diff --git a/src/chains/harmony/harmony.ts b/src/chains/harmony/harmony.ts index df331d5dc1..d5ce824af3 100644 --- a/src/chains/harmony/harmony.ts +++ b/src/chains/harmony/harmony.ts @@ -27,8 +27,8 @@ export class Harmony extends EthereumBase implements Ethereumish { config.network.tokenListType, config.manualGasPrice, config.gasLimitTransaction, - ConfigManagerV2.getInstance().get('database.nonceDbPath'), - ConfigManagerV2.getInstance().get('database.transactionDbPath') + ConfigManagerV2.getInstance().get('server.nonceDbPath'), + ConfigManagerV2.getInstance().get('server.transactionDbPath') ); this._chain = network; this._nativeTokenSymbol = config.nativeCurrencySymbol; diff --git a/src/chains/near/near.ts b/src/chains/near/near.ts index bcb298492a..da6bc37fad 100644 --- a/src/chains/near/near.ts +++ b/src/chains/near/near.ts @@ -23,7 +23,7 @@ export class Near extends NearBase { config.network.tokenListType, config.manualGasPrice, config.gasLimitTransaction, - ConfigManagerV2.getInstance().get('database.transactionDbPath') + ConfigManagerV2.getInstance().get('server.transactionDbPath') ); this._chain = config.network.name; this._nativeTokenSymbol = config.nativeCurrencySymbol; diff --git a/src/chains/polygon/polygon.ts b/src/chains/polygon/polygon.ts index c971b79196..137fd27a32 100644 --- a/src/chains/polygon/polygon.ts +++ b/src/chains/polygon/polygon.ts @@ -25,8 +25,8 @@ export class Polygon extends EthereumBase implements Ethereumish { config.network.tokenListType, config.manualGasPrice, config.gasLimitTransaction, - ConfigManagerV2.getInstance().get('database.nonceDbPath'), - ConfigManagerV2.getInstance().get('database.transactionDbPath') + ConfigManagerV2.getInstance().get('server.nonceDbPath'), + ConfigManagerV2.getInstance().get('server.transactionDbPath') ); this._chain = config.network.name; this._nativeTokenSymbol = config.nativeCurrencySymbol; diff --git a/src/services/schema/database-schema.json b/src/services/schema/database-schema.json deleted file mode 100644 index 68eb48487d..0000000000 --- a/src/services/schema/database-schema.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "properties": { - "nonceDbPath": { "type": "string" }, - "transactionDbPath": { "type": "string" } - }, - "additionalProperties": false, - "required": ["nonceDbPath", "transactionDbPath"] -} diff --git a/src/services/schema/server-schema.json b/src/services/schema/server-schema.json index 2a88d53273..0df687b62c 100644 --- a/src/services/schema/server-schema.json +++ b/src/services/schema/server-schema.json @@ -2,15 +2,17 @@ "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "properties": { + "certificatePath": { "type": "string" }, + "logPath": { "type": "string" }, "port": { "type": "integer" }, "ipWhitelist": { "type": "array" }, - "unsafeDevModeWithHTTP": { "type": "boolean" }, "GMTOffset": { "type": "number" }, "id": { "type": "string" }, - "certificatePath": { "type": "string" }, + "logToStdOut": { "type": "boolean" }, + "unsafeDevModeWithHTTP": { "type": "boolean" }, "telemetry_enabled": { "type": "boolean" }, - "logPath": { "type": "string" }, - "logToStdOut": { "type": "boolean" } + "nonceDbPath": { "type": "string" }, + "transactionDbPath": { "type": "string" } }, "additionalProperties": false, "required": [ @@ -18,6 +20,8 @@ "unsafeDevModeWithHTTP", "certificatePath", "telemetry_enabled", - "logPath" + "logPath", + "nonceDbPath", + "transactionDbPath" ] } diff --git a/src/templates/database.yml b/src/templates/database.yml deleted file mode 100644 index ccbd1db6af..0000000000 --- a/src/templates/database.yml +++ /dev/null @@ -1,2 +0,0 @@ -nonceDbPath: 'nonce.level' -transactionDbPath: 'transaction.level' diff --git a/src/templates/root.yml b/src/templates/root.yml index 30dc8201e6..706812c05e 100644 --- a/src/templates/root.yml +++ b/src/templates/root.yml @@ -1,5 +1,13 @@ version: 1 configurations: + $namespace server: + configurationPath: server.yml + schemaPath: server-schema.json + + $namespace ethereum: + configurationPath: ethereum.yml + schemaPath: ethereum-schema.json + $namespace harmony: configurationPath: harmony.yml schemaPath: harmony-schema.json @@ -8,14 +16,6 @@ configurations: configurationPath: avalanche.yml schemaPath: ethereum-schema.json - $namespace database: - configurationPath: database.yml - schemaPath: database-schema.json - - $namespace ethereum: - configurationPath: ethereum.yml - schemaPath: ethereum-schema.json - $namespace polygon: configurationPath: polygon.yml schemaPath: ethereum-schema.json @@ -48,10 +48,6 @@ configurations: configurationPath: traderjoe.yml schemaPath: traderjoe-schema.json - $namespace server: - configurationPath: server.yml - schemaPath: server-schema.json - $namespace uniswap: configurationPath: uniswap.yml schemaPath: uniswap-schema.json diff --git a/src/templates/server.yml b/src/templates/server.yml index 15e6aa13df..67f2b9ecc7 100644 --- a/src/templates/server.yml +++ b/src/templates/server.yml @@ -1,3 +1,9 @@ +# Path to folder where Hummingbot generates self-signed certificates +certificatePath: /Users/feng1/Code/hummingbot/certs/ + +# Path to folder where logs will be stored. +logPath: './logs' + # Port to expose the gateway server on port: 15888 @@ -7,12 +13,6 @@ ipWhitelist: [] # GMT Offset GMTOffset: +0800 -# Path to folder where Hummingbot generates self-signed certificates -certificatePath: /Users/feng1/Code/hummingbot/certs/ - -# Path to folder where logs will be stored. -logPath: './logs' - # If true, logs will be stored in logPath and printed to stdout. If false, they # will only be stored in logPath and not printed to stdout. logToStdOut: true @@ -23,3 +23,11 @@ unsafeDevModeWithHTTP: false # Collects data about API usage if true telemetry_enabled: false +# Nonce database +nonceDbPath: 'nonce.level' + +# Transaction database +transactionDbPath: 'transaction.level' + + + From a2f40e0a420f6b0143ded5664f68275ac7b3c3b2 Mon Sep 17 00:00:00 2001 From: Michael Feng Date: Mon, 6 Feb 2023 15:15:31 -0800 Subject: [PATCH 7/9] add changes from #6063 --- Dockerfile | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 81553f9cbe..d556006fe8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ FROM node:18.10.0 # Set labels -LABEL application="gateway-v2" +LABEL application="gateway" LABEL branch=${BRANCH} LABEL commit=${COMMIT} LABEL date=${BUILD_DATE} @@ -23,6 +23,14 @@ RUN apt-get update && \ # app directory 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 From 9d58415403ebf70f1d704203212b1933dced8822 Mon Sep 17 00:00:00 2001 From: Michael Feng Date: Mon, 6 Feb 2023 15:41:59 -0800 Subject: [PATCH 8/9] clean up certs path --- src/https.ts | 34 ++++++++++++------- .../schema/ethereum-gas-station-schema.json | 12 ------- src/templates/server.yml | 2 +- src/templates/telemetry.yml | 2 -- 4 files changed, 22 insertions(+), 28 deletions(-) delete mode 100644 src/services/schema/ethereum-gas-station-schema.json delete mode 100644 src/templates/telemetry.yml diff --git a/src/https.ts b/src/https.ts index 10bc3dc60b..11f61b6fa2 100644 --- a/src/https.ts +++ b/src/https.ts @@ -6,23 +6,24 @@ import { ConfigManagerV2 } from './services/config-manager-v2'; export const addHttps = (app: Application) => { const serverKey = fs.readFileSync( - ConfigManagerV2.getInstance().get('server.certificatePath') + 'server_key.pem', - { - encoding: 'utf-8', - } + addSlashToPath( + ConfigManagerV2.getInstance().get('server.certificatePath') + ) + 'server_key.pem', + { encoding: 'utf-8' } ); + const serverCert = fs.readFileSync( - ConfigManagerV2.getInstance().get('server.certificatePath') + - 'server_cert.pem', - { - encoding: 'utf-8', - } + addSlashToPath( + ConfigManagerV2.getInstance().get('server.certificatePath') + ) + 'server_cert.pem', + { encoding: 'utf-8' } ); + const caCert = fs.readFileSync( - ConfigManagerV2.getInstance().get('server.certificatePath') + 'ca_cert.pem', - { - encoding: 'utf-8', - } + addSlashToPath( + ConfigManagerV2.getInstance().get('server.certificatePath') + ) + 'ca_cert.pem', + { encoding: 'utf-8' } ); return https.createServer( @@ -40,3 +41,10 @@ export const addHttps = (app: Application) => { app ); }; + +const addSlashToPath = (path: string) => { + if (!path.endsWith('/')) { + path += '/'; + } + return path; +}; diff --git a/src/services/schema/ethereum-gas-station-schema.json b/src/services/schema/ethereum-gas-station-schema.json deleted file mode 100644 index 8c35c86066..0000000000 --- a/src/services/schema/ethereum-gas-station-schema.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "properties": { - "enabled": { "type": "boolean" }, - "gasStationURL": { "type": "string" }, - "APIKey": { "type": ["string", "null"] }, - "gasLevel": { "enum": ["fast", "fastest", "safeLow", "average"] } - }, - "additionalProperties": false, - "required": ["enabled"] -} diff --git a/src/templates/server.yml b/src/templates/server.yml index 67f2b9ecc7..7a331a66bd 100644 --- a/src/templates/server.yml +++ b/src/templates/server.yml @@ -1,5 +1,5 @@ # Path to folder where Hummingbot generates self-signed certificates -certificatePath: /Users/feng1/Code/hummingbot/certs/ +certificatePath: /certs/ # Path to folder where logs will be stored. logPath: './logs' diff --git a/src/templates/telemetry.yml b/src/templates/telemetry.yml deleted file mode 100644 index d8e96575f4..0000000000 --- a/src/templates/telemetry.yml +++ /dev/null @@ -1,2 +0,0 @@ -# If true it will collect data about API usage. -enabled: false From 465013cce34663c2089e06e8d7687f9c8041136c Mon Sep 17 00:00:00 2001 From: Michael Feng Date: Mon, 6 Feb 2023 16:01:46 -0800 Subject: [PATCH 9/9] clean up README --- README.md | 78 +++++++++++++++++++++---------------------------------- 1 file changed, 30 insertions(+), 48 deletions(-) diff --git a/README.md b/README.md index 4dcd9e9588..1b82b3b1e1 100644 --- a/README.md +++ b/README.md @@ -2,28 +2,31 @@ # Hummingbot Gateway ---- - Hummingbot Gateway is a REST API that exposes connections to various blockchains (wallet, node & chain interaction) and decentralized exchanges (pricing, trading & liquidity provision). It is written in Typescript and takes advantage of existing blockchain and DEX SDKs. The advantage of using gateway is it provideds a programming language agnostic approach to interacting with blockchains and DEXs. -Gateway may be used alongside the main Hummingbot client to enable trading on DEXs, or as a standalone module by external developers. +Gateway may be used alongside the main [Hummingbot client](https://github.com/hummingbot/hummingbot) to enable trading on DEXs, or as a standalone module by external developers. + +## Install and run locally + +```bash +# Install dependencies +yarn + +# Complile Typescript into JS +$ yarn build + +# Generate the config files and edit as needed, especially server.yml +$ setup/generate_conf.sh + +# Start the server using the passphrase you used to generate the certs in Hummingbot +$ yarn start --passphrase= +``` -## Connectors +## Documentation -This is a list of DEX connections currently supported by Gateway. +See the [official Gateway docs](https://docs.hummingbot.org/gateway/). -| Connector | Blockchain | Trading Interface | -| ----------- | ------------------- | ----------------- | -| UniswapV2 | Ethereum | AMM | -| Sushiswap | Ethereum | AMM | -| UniswapV3 | Ethereum | EVM_Range_AMM | -| Pangolin | Avalanche | AMM | -| PancakeSwap | Binance Smart Chain | AMM | -| Traderjoe | Avalanche | AMM | -| Quickswap | Polygon | AMM | -| Perp | Ethereum | EVM_Perpetual | -| Mad Meerkat | Cronos | AMM | -| VVS | Cronos | AMM | +The API is documented using [Swagger](./docs/swagger). When Gateway is started, it also generates Swagger API docs at: https://localhost:8080 ## Contributing @@ -38,53 +41,32 @@ There are a number of ways to contribute to gateway. - Vote on a [Snapshot proposal](https://snapshot.org/#/hbot.eth) -## Configuration -Before running gateway, you need to setup some configs. You can start by copying all of the yml files from [src/templates](./src/templates) to [conf](./conf). The format of this files are dictated by [src/services/config-manager-v2.ts](./src/services/config-manager-v2.ts) and the corresponding schema files in [src/services/schema](./src/services/schema) . +### Configuration -### Useful configuration options +- Edit `certs_path` in [conf/server.yml](./conf/server.yml) and enter the absolute path to the folder where Hummingbot stored the certificates it created with `gateway generate-certs`. You can also edit this config inside the Hummingbot client by running the command: `gateway config server.certs_path`. - If you want to turn off `https`, set `unsafeDevModeWithHTTP` to `true` in [conf/server.yml](./conf/server.yml). -- If you gateway to log to standard out, set `logToStdOut` to `true` in [conf/server.yml](./conf/server.yml). - -- Edit `certificatePath` in [conf/server.yml](./conf/server.yml). This can be generated by Hummingbot with `gateway generate-certs`. - -The hummingbot client is also able to edit this config files. - -## Install and run locally - -Compile the Typescript code with `npm` or `yarn` . - -```bash -yarn -yarn build -yarn dev --passphrase= -# the passphrase can be anything if unsafeDevModeWithHTTP is true -``` - -## Documentation - -The API is documented using swagger: [gateway swagger docs](./docs/swagger). You can run the gateway swagger UI by starting gateway and visiting [localhost:8080](localhost:8080). +- If you want Gateway to log to standard out, set `logToStdOut` to `true` in [conf/server.yml](./conf/server.yml). -You can follow details about [trading interfaces](https://hummingbot.notion.site/Gateway-v2-Trading-Interfaces-482e2684d48c450ebcfff5401ba806aa) +- The format of configuration files are dictated by [src/services/config-manager-v2.ts](./src/services/config-manager-v2.ts) and the corresponding schema files in [src/services/schema](./src/services/schema). -Also, we maintain docs on the official website about gateway [here](https://hummingbot.org/protocols/gateway/). -### Files to read +### Architecture -Here are some files we recommend you look at in order to get familiar with the gateway code base. +Here are some files we recommend you look at in order to get familiar with the Gateway codebase: -- [src/services/ethereum-base.ts](./src/services/ethereum-base.ts) is a base class for EVM chains. +- [src/services/ethereum-base.ts](./src/services/ethereum-base.ts): base class for EVM chains. -- [src/connectors/uniswap/uniswap.ts](./src/connectors/uniswap/uniswap.ts) has functionality for interacting with Uniswap V2. +- [src/connectors/uniswap/uniswap.ts](./src/connectors/uniswap/uniswap.ts): functionality for interacting with Uniswap. -- [src/services/validator.ts](./src/services/validator.ts) defines functions for validating request payloads. +- [src/services/validator.ts](./src/services/validator.ts): defines functions for validating request payloads. ### Testing -When making a PR, there are unit test coverage requirements. Look at our [github workflow](../.github/workflows/workflow.yml) for the exact definition. There are some more +For a pull request merged into the codebase, it has to pass unit test coverage requirements. Take a look at [Workflow](../.github/workflows/workflow.yml) for more details. #### Unit tests