diff --git a/.eslintrc.js b/.eslintrc.js index 0e95b553..90099db0 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -7,6 +7,7 @@ module.exports = { jsx: false, // Allows for the parsing of JSX }, }, + ignorePatterns: ["**/dist"], extends: [ 'plugin:@typescript-eslint/recommended', // Uses the recommended rules from the @typescript-eslint/eslint-plugin 'plugin:prettier/recommended', // Enables eslint-plugin-prettier and eslint-config-prettier. This will display prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array. diff --git a/.gitignore b/.gitignore index 0b47c1df..2131e8e1 100644 --- a/.gitignore +++ b/.gitignore @@ -35,4 +35,5 @@ yarn-error.log # Files that must be skipped default.js .env -voter.json \ No newline at end of file +voter.json +dist/ \ No newline at end of file diff --git a/feeder/package-lock.json b/feeder/package-lock.json index d3e0429d..173ebd3e 100644 --- a/feeder/package-lock.json +++ b/feeder/package-lock.json @@ -1,12 +1,12 @@ { "name": "@terra-money/oracle-feeder", - "version": "3.0.1", + "version": "3.0.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@terra-money/oracle-feeder", - "version": "3.0.1", + "version": "3.0.2", "license": "Apache-2.0", "dependencies": { "@terra-money/feather.js": "^1.0.0-beta.4", diff --git a/feeder/package.json b/feeder/package.json index 75a5d935..fafdfc5e 100644 --- a/feeder/package.json +++ b/feeder/package.json @@ -1,10 +1,11 @@ { "name": "@terra-money/oracle-feeder", - "version": "3.0.1", - "main": "src/index.ts", + "version": "3.0.2", + "main": "dist/index.js", "license": "Apache-2.0", "scripts": { - "start": "ts-node src/index.ts" + "start": "ts-node src/index.ts", + "build": "tsc" }, "dependencies": { "@terra-money/feather.js": "^1.0.0-beta.4", diff --git a/feeder/src/addKey.ts b/feeder/src/addKey.ts index ea701ffe..51bea957 100644 --- a/feeder/src/addKey.ts +++ b/feeder/src/addKey.ts @@ -1,43 +1,39 @@ import * as keystore from './keystore' import * as promptly from 'promptly' -export async function addKey(filePath: string, coinType: string, keyName: string, prefix: string): Promise { +export async function addKey(args): Promise { + console.log(args) let password = process.env.PASSWORD || '' let mnemonic = process.env.MNEMONIC || '' - coinType = process.env.COIN_TYPE ? process.env.COIN_TYPE : coinType - keyName = process.env.KEY_NAME ? process.env.KEY_NAME : keyName - if (password === '') { - password = await promptly.password(`Enter a passphrase to encrypt your key to disk:`, { - replace: `*`, + password = await promptly.password('Enter a passphrase to encrypt your key to disk:', { + replace: '*', }) - const confirm = await promptly.password(`Repeat the passphrase:`, { replace: `*` }) - if (password !== confirm) { - console.error(`ERROR: passphrases don't matchPassword confirm failed`) - return + if (password.length < 8) { + throw Error('ERROR: password must be at least 8 characters') } - } - if (password.length < 8) { - console.error(`ERROR: password must be at least 8 characters`) - return + const confirm = await promptly.password('Repeat the passphrase:', { replace: '*' }) + + if (password !== confirm) { + throw Error("ERROR: passphrases don't matchPassword confirm failed") + } } if (mnemonic === '') { - mnemonic = await promptly.prompt(`Enter your bip39 mnemonic: `) + mnemonic = await promptly.prompt('Enter your bip39 mnemonic: ') } - if (mnemonic.trim().split(` `).length !== 24) { - console.error(`Error: Mnemonic is not valid.`) - return + if (mnemonic.trim().split(' ').length !== 24) { + throw Error('Error: Mnemonic is not valid.') } - if (!prefix) { - prefix = await promptly.prompt(`\nEnter the address prefix: `) + if (!args.prefix) { + args.prefix = await promptly.prompt('\nEnter the address prefix: ') } - await keystore.save(filePath, keyName, password, mnemonic, coinType, prefix) - console.info(`saved!`) + await keystore.save(args, password, mnemonic) + console.info('saved!') } diff --git a/feeder/src/index.ts b/feeder/src/index.ts index 5e2cdfd3..1e143030 100644 --- a/feeder/src/index.ts +++ b/feeder/src/index.ts @@ -2,86 +2,108 @@ import { ArgumentParser } from 'argparse' import { vote } from './vote' import { addKey } from './addKey' import * as packageInfo from '../package.json' +import * as promptly from 'promptly' import * as dotenv from 'dotenv' // see https://github.com/motdotla/dotenv#how-do-i-use-dotenv-with-import dotenv.config() function registerCommands(parser: ArgumentParser): void { const subparsers = parser.addSubparsers({ - title: `commands`, - dest: `subparser_name`, - description: `Available commands`, + title: 'commands', + dest: 'subparser_name', + description: 'Available commands', }) // Voting command - const voteCommand = subparsers.addParser(`vote`, { + const voteCommand = subparsers.addParser('vote', { addHelp: true, - description: `Fetch price and broadcast oracle messages`, + description: 'Fetch price and broadcast oracle messages', }) voteCommand.addArgument(['-l', '--lcd-url'], { + help: 'lcd url address (default: process.env.LCD_URL or ["http://localhost:1317"])', action: 'append', - help: 'lcd address', dest: 'lcdUrl', + defaultValue: (process.env.LCD_URL && process.env.LCD_URL.split(',')) || ['http://localhost:1317'], required: false, }) - voteCommand.addArgument([`-c`, `--chain-id`], { - action: `store`, - help: `chain ID`, - dest: `chainID`, + voteCommand.addArgument(['-c', '--chain-id'], { + help: 'chain id where the vote transactions must be submitted to (default: process.env.CHAIN_ID or "candle-1")', + action: 'store', + dest: 'chainID', + defaultValue: process.env.CHAIN_ID || 'candle-1', required: false, }) - voteCommand.addArgument([`--validators`], { - action: `append`, - help: `validators address (e.g. terravaloper1...), can have multiple`, + voteCommand.addArgument(['--validators'], { + help: 'validators address(es) (e.g. terravaloper1...)', + action: 'append', required: false, + defaultValue: process.env.VALIDATORS && process.env.VALIDATORS.split(','), }) - voteCommand.addArgument([`-d`, `--data-source-url`], { - action: `append`, - help: `Append price data source(It can handle multiple sources)`, - dest: `dataSourceUrl`, + voteCommand.addArgument(['-d', '--data-source-url'], { + help: 'Append price(s) data source (default: process.env.DATA_SOURCE_URL or ["http://localhost:8532/latest"])', + action: 'append', + dest: 'dataSourceUrl', + defaultValue: (process.env.DATA_SOURCE_URL && process.env.DATA_SOURCE_URL.split(',')) || [ + 'http://localhost:8532/latest', + ], required: false, }) - voteCommand.addArgument([`-p`, `--password`], { - action: `store`, - help: `voter password`, + voteCommand.addArgument(['-p', '--password'], { + help: 'key store voter password (default: process.env.PASSWORD)', + action: 'store', + defaultValue: process.env.PASSWORD, }) - voteCommand.addArgument([`-k`, `--key-path`, `--keystore`], { - action: `store`, - help: `key store path to save encrypted key`, - dest: `keyPath`, - required: false, + voteCommand.addArgument(['-k', '--key-path', '--keystore'], { + help: 'key store path where to save encrypted key (default: process.env.KEY_PATH or "voter.json")', + action: 'store', + dest: 'keyPath', + defaultValue: process.env.KEY_PATH || 'voter.json', }) - voteCommand.addArgument([`-n`, `--key-name`], { - help: `name assigned to the generated key`, - dest: `keyName`, - defaultValue: `voter`, + voteCommand.addArgument(['-n', '--key-name'], { + help: 'name to assing to the generated key inside the keystore (default: process.env.KEY_NAME or "voter")', + dest: 'keyName', + defaultValue: process.env.KEY_NAME || 'voter', }) - // Updating Key command - const keyCommand = subparsers.addParser(`add-key`, { addHelp: true }) - - keyCommand.addArgument([`-n`, `--key-name`], { - help: `name to assigns to the generated key`, - dest: `keyName`, - defaultValue: `voter`, + voteCommand.addArgument(['-a', '--address-prefix'], { + help: 'prefix for the addresses to be generated (default: process.env.ADDR_PREFIX or "candle")', + dest: 'prefix', + defaultValue: process.env.ADDR_PREFIX || 'candle', }) - keyCommand.addArgument([`-t`, `--coin-type`], { - help: `coin type used to derive the public address (https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#path-levels)`, - dest: `coinType`, - defaultValue: `118`, + voteCommand.addArgument(['-v', '--voter'], { + help: 'addresses of the wallet to vote on behalf (default: process.env.VOTER or default stored address from keystore)', + dest: 'voter', + defaultValue: process.env.VOTER, }) - keyCommand.addArgument([`-k`, `--key-path`], { - help: `key store path to save encrypted key`, - dest: `keyPath`, - defaultValue: `voter.json`, + // Updating Key command + const addKeyCommand = subparsers.addParser('add-key', { addHelp: true }) + addKeyCommand.addArgument(['-n', '--key-name'], { + help: 'name to assing to the generated key inside the keystore (default: process.env.KEY_NAME or "voter")', + dest: 'keyName', + defaultValue: process.env.KEY_NAME || 'voter', + }) + addKeyCommand.addArgument(['-t', '--coin-type'], { + help: 'coin type used to derive the public address (default: process.env.COIN_TYPE or "118")', + dest: 'coinType', + defaultValue: process.env.COIN_TYPE || '118', + }) + addKeyCommand.addArgument(['-k', '--key-path'], { + help: 'key store path where to save encrypted key (default: process.env.KEY_PATH or "voter.json")', + dest: 'keyPath', + defaultValue: process.env.KEY_PATH || 'voter.json', + }) + addKeyCommand.addArgument(['-a', '--address-prefix'], { + help: 'prefix for the addresses to be generated (default: process.env.ADDR_PREFIX or "candle")', + dest: 'prefix', + defaultValue: process.env.ADDR_PREFIX || 'candle', }) } @@ -89,41 +111,19 @@ async function main(): Promise { const parser = new ArgumentParser({ version: packageInfo.version, addHelp: true, - description: `Terra oracle voter`, + description: 'Terra oracle voter', }) registerCommands(parser) const args = parser.parseArgs() - args.prefix = args.prefix || process.env.ADDR_PREFIX - - if (args.subparser_name === `vote`) { - args.lcdUrl = args.lcdUrl || (process.env.LCD_URL && process.env.LCD_URL.split(',')) || [] - - args.dataSourceUrl = - args.dataSourceUrl || (process.env.DATA_SOURCE_URL && process.env.DATA_SOURCE_URL.split(',')) || [] - args.chainID = args.chainID || process.env.CHAIN_ID || 'candled-testnet-1' - if (args.lcdUrl?.length === 0 || args.dataSourceUrl?.length === 0 || args.chainID === '') { - console.error('Missing --lcd, --chain-id or --data-source-url') - return - } - - args.keyPath = args.keyPath || process.env.KEY_PATH || 'voter.json' - args.password = args.password || process.env.PASSWORD || '' - if (args.keyPath === '' || args.password === '') { - console.error('Missing either --key-path or --password') - return - } - - // validators is skippable and default value will be extracted from the key - args.validators = args.validators || (process.env.VALIDATORS && process.env.VALIDATORS.split(',')) + console.log(args) - args.keyName = process.env.KEY_NAME ? process.env.KEY_NAME : args.keyName + if (args.subparser_name === 'vote') { + args.password = args.password || (await promptly.password(`Enter a passphrase:`, { replace: `*` })) await vote(args) - } else if (args.subparser_name === `add-key`) { - await addKey(args.keyPath, args.coinType, args.keyName, args.prefix) - } + } else if (args.subparser_name === 'add-key') await addKey(args) } main().catch((e) => { diff --git a/feeder/src/keystore.ts b/feeder/src/keystore.ts index 828069af..cdb92f5c 100644 --- a/feeder/src/keystore.ts +++ b/feeder/src/keystore.ts @@ -13,9 +13,14 @@ interface Entity { interface PlainEntity { privateKey: string - publicKey: string - terraAddress: string - terraValAddress: string + address: string + valAddress: string +} +interface KeyArgs { + keyName: string + coinType: string + keyPath: string + prefix: string } function encrypt(plainText, pass): string { @@ -44,58 +49,44 @@ function decrypt(transitmessage, pass) { } function loadEntities(path: string): Entity[] { - try { - return JSON.parse(fs.readFileSync(path, `utf8`) || `[]`) - } catch (e) { - console.error('loadKeys', e.message) - return [] - } + if (fs.existsSync(path)) return JSON.parse(fs.readFileSync(path, `utf8`)) + else return [] } -export async function save( - filePath: string, - name: string, - password: string, - mnemonic: string, - coinType: string, - prefix: string -): Promise { - const keys = loadEntities(filePath) - - if (keys.find((key) => key.name === name)) { - throw new Error('Key already exists by that name') +export async function save(args: KeyArgs, password: string, mnemonic: string): Promise { + const keys = loadEntities(args.keyPath) + if (keys.find((key) => key.name === args.keyName)) { + throw new Error(`Key already exists with name "${args.keyName}"`) } - const mnemonicKey = new MnemonicKey({ mnemonic, coinType: Number(coinType) }) - - const ciphertext = encrypt( - JSON.stringify({ - privateKey: mnemonicKey.privateKey.toString(`hex`), - terraAddress: mnemonicKey.accAddress, - terraValAddress: mnemonicKey.valAddress, - }), - password - ) + const mnemonicKey = new MnemonicKey({ mnemonic, coinType: Number(args.coinType) }) + const entry: PlainEntity = { + privateKey: mnemonicKey.privateKey.toString(`hex`), + address: mnemonicKey.accAddress(args.prefix), + valAddress: mnemonicKey.valAddress(args.prefix), + } + const ciphertext = encrypt(JSON.stringify(entry), password) keys.push({ - name, - address: mnemonicKey.accAddress(prefix), + name: args.keyName, + address: mnemonicKey.accAddress(args.prefix), ciphertext, }) - fs.writeFileSync(filePath, JSON.stringify(keys)) + fs.writeFileSync(args.keyPath, JSON.stringify(keys)) } -export function load(filePath: string, name: string, password: string): PlainEntity { - const keys = loadEntities(filePath) - const key = keys.find((key) => key.name === name) +export function load(args: any): PlainEntity { + const keys = loadEntities(args.keyPath) + const key = keys.find((key) => key.name === args.keyName) + console.log(key, keys) if (!key) { throw new Error('Cannot load key by that name') } try { - const plainText = decrypt(key.ciphertext, password) + const plainText = decrypt(key.ciphertext, args.password) return JSON.parse(plainText) } catch (err) { throw new Error('Incorrect password') diff --git a/feeder/src/vote.ts b/feeder/src/vote.ts index e25830a9..d83e6ed3 100644 --- a/feeder/src/vote.ts +++ b/feeder/src/vote.ts @@ -1,6 +1,5 @@ import * as crypto from 'crypto' import * as Bluebird from 'bluebird' -import * as promptly from 'promptly' import * as http from 'http' import * as https from 'https' import axios from 'axios' @@ -22,16 +21,6 @@ const ax = axios.create({ }, }) -async function initKey(keyPath: string, name: string, password?: string): Promise { - const plainEntity = ks.load( - keyPath, - name, - password || (await promptly.password(`Enter a passphrase:`, { replace: `*` })) - ) - - return new RawKey(Buffer.from(plainEntity.privateKey, 'hex')) -} - interface OracleParameters { oracleVotePeriod: number oracleWhitelist: string[] @@ -275,13 +264,14 @@ async function validateTx( interface VoteArgs { lcdUrl: string[] - prefix: string chainID: string - validator: string[] + validators: string[] dataSourceUrl: string[] password: string keyPath: string keyName: string + prefix: string + voter: string } function buildLCDClientConfig(args: VoteArgs, lcdIndex: number): Record { @@ -297,9 +287,10 @@ function buildLCDClientConfig(args: VoteArgs, lcdIndex: number): Record { - const rawKey: RawKey = await initKey(args.keyPath, args.keyName, args.password) - const valAddrs: string[] = args.validator || [rawKey.valAddress(args.prefix)] - const voterAddr = rawKey.accAddress(args.prefix) + const plainEntity = ks.load(args) + const rawKey: RawKey = new RawKey(Buffer.from(plainEntity.privateKey, 'hex')) + const valAddrs: string[] = args.validators || [plainEntity.valAddress] + const voterAddr = args.voter || plainEntity.address const lcdRotate = { client: new LCDClient(buildLCDClientConfig(args, 0)), diff --git a/package-lock.json b/package-lock.json index f7971c98..e42e20d1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3668,9 +3668,9 @@ "dev": true }, "node_modules/json5": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.1.tgz", - "integrity": "sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA==", + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", "dev": true, "bin": { "json5": "lib/cli.js" @@ -8159,9 +8159,9 @@ "dev": true }, "json5": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.1.tgz", - "integrity": "sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA==", + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", "dev": true }, "kleur": { diff --git a/price-server/package-lock.json b/price-server/package-lock.json index 89631701..a9fef103 100644 --- a/price-server/package-lock.json +++ b/price-server/package-lock.json @@ -1,12 +1,12 @@ { "name": "@terra-money/price-server", - "version": "3.0.1", + "version": "3.0.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@terra-money/price-server", - "version": "3.0.1", + "version": "3.0.2", "license": "Apache-2.0", "dependencies": { "@opentelemetry/api": "^1.0.2", @@ -24,8 +24,7 @@ "node-fetch": "^2.6.7", "pako": "^2.0.3", "polka": "^0.5.2", - "ts-node": "^10.7.0", - "tsconfig-paths": "^3.9.0", + "ts-node": "^10.9.1", "typescript": "^4.1.3", "ws": "^7.4.2" }, @@ -287,11 +286,6 @@ "integrity": "sha512-g2qEd+zkfkTEudA2SrMAeAvY7CrFqtbsLILm2dT2VIeKTqMqVzcdfURlvu6FU3srRgbmXN1Srm94pg34EIehww==", "dev": true }, - "node_modules/@types/json5": { - "version": "0.0.29", - "resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz", - "integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==" - }, "node_modules/@types/lodash": { "version": "4.14.189", "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.189.tgz", @@ -499,9 +493,9 @@ } }, "node_modules/json5": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.1.tgz", - "integrity": "sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA==", + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", "bin": { "json5": "lib/cli.js" }, @@ -570,14 +564,6 @@ "node": ">= 0.6" } }, - "node_modules/minimist": { - "version": "1.2.7", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.7.tgz", - "integrity": "sha512-bzfL1YUZsP41gmu/qjrEk0Q6i2ix/cVeAhbCbqH9u3zYutS1cLg00qhrD0M2MVdCcx4Sc0UpP2eBWo9rotpq6g==", - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", @@ -630,14 +616,6 @@ "node": ">=10" } }, - "node_modules/strip-bom": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", - "integrity": "sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==", - "engines": { - "node": ">=4" - } - }, "node_modules/tr46": { "version": "0.0.3", "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", @@ -696,28 +674,6 @@ } } }, - "node_modules/tsconfig-paths": { - "version": "3.14.1", - "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.14.1.tgz", - "integrity": "sha512-fxDhWnFSLt3VuTwtvJt5fpwxBHg5AdKWMsgcPOOIilyjymcYVZoCQF8fvFRezCNfblEXmi+PcM1eYHeOAgXCOQ==", - "dependencies": { - "@types/json5": "^0.0.29", - "json5": "^1.0.1", - "minimist": "^1.2.6", - "strip-bom": "^3.0.0" - } - }, - "node_modules/tsconfig-paths/node_modules/json5": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", - "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", - "dependencies": { - "minimist": "^1.2.0" - }, - "bin": { - "json5": "lib/cli.js" - } - }, "node_modules/tslib": { "version": "1.14.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", @@ -973,11 +929,6 @@ "integrity": "sha512-g2qEd+zkfkTEudA2SrMAeAvY7CrFqtbsLILm2dT2VIeKTqMqVzcdfURlvu6FU3srRgbmXN1Srm94pg34EIehww==", "dev": true }, - "@types/json5": { - "version": "0.0.29", - "resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz", - "integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==" - }, "@types/lodash": { "version": "4.14.189", "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.189.tgz", @@ -1133,9 +1084,9 @@ } }, "json5": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.1.tgz", - "integrity": "sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA==" + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==" }, "lodash": { "version": "4.17.21", @@ -1186,11 +1137,6 @@ "mime-db": "1.52.0" } }, - "minimist": { - "version": "1.2.7", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.7.tgz", - "integrity": "sha512-bzfL1YUZsP41gmu/qjrEk0Q6i2ix/cVeAhbCbqH9u3zYutS1cLg00qhrD0M2MVdCcx4Sc0UpP2eBWo9rotpq6g==" - }, "ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", @@ -1226,11 +1172,6 @@ "lru-cache": "^6.0.0" } }, - "strip-bom": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", - "integrity": "sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==" - }, "tr46": { "version": "0.0.3", "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", @@ -1264,27 +1205,6 @@ "yn": "3.1.1" } }, - "tsconfig-paths": { - "version": "3.14.1", - "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.14.1.tgz", - "integrity": "sha512-fxDhWnFSLt3VuTwtvJt5fpwxBHg5AdKWMsgcPOOIilyjymcYVZoCQF8fvFRezCNfblEXmi+PcM1eYHeOAgXCOQ==", - "requires": { - "@types/json5": "^0.0.29", - "json5": "^1.0.1", - "minimist": "^1.2.6", - "strip-bom": "^3.0.0" - }, - "dependencies": { - "json5": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", - "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", - "requires": { - "minimist": "^1.2.0" - } - } - } - }, "tslib": { "version": "1.14.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", diff --git a/price-server/package.json b/price-server/package.json index 4185232b..8c88d735 100644 --- a/price-server/package.json +++ b/price-server/package.json @@ -1,10 +1,11 @@ { "name": "@terra-money/price-server", - "version": "3.0.1", - "main": "src/main.ts", + "version": "3.0.2", + "main": "dist/index.js", "license": "Apache-2.0", "scripts": { - "start": "node --stack_size=4096 --max-old-space-size=4096 -r ts-node/register/transpile-only -r tsconfig-paths/register src/main.ts" + "start": "ts-node src/index.ts", + "build": "tsc" }, "dependencies": { "@opentelemetry/api": "^1.0.2", @@ -22,8 +23,7 @@ "node-fetch": "^2.6.7", "pako": "^2.0.3", "polka": "^0.5.2", - "ts-node": "^10.7.0", - "tsconfig-paths": "^3.9.0", + "ts-node": "^10.9.1", "typescript": "^4.1.3", "ws": "^7.4.2" }, diff --git a/price-server/src/main.ts b/price-server/src/index.ts similarity index 68% rename from price-server/src/main.ts rename to price-server/src/index.ts index 0994b845..f20cedf6 100644 --- a/price-server/src/main.ts +++ b/price-server/src/index.ts @@ -1,13 +1,13 @@ import * as bluebird from 'bluebird' import * as config from 'config' -import * as logger from 'lib/logger' -import { init as initErrorHandler, errorHandler } from 'lib/error' -import { initialize as initializeProviders, tick } from 'provider' +import * as logger from './lib/logger' +import { init as initErrorHandler, errorHandler } from './lib/error' +import { initialize as initializeProviders, tick } from './provider' import { createServer } from './server' -import { setupMetricsServer } from 'lib/metrics' +import { setupMetricsServer } from './lib/metrics' bluebird.config({ longStackTraces: true }) -global.Promise = bluebird +global.Promise = bluebird as any async function main(): Promise { logger.info('price server start') diff --git a/price-server/src/lib/slack.ts b/price-server/src/lib/slack.ts index d19e3e23..0e20aa5d 100644 --- a/price-server/src/lib/slack.ts +++ b/price-server/src/lib/slack.ts @@ -1,4 +1,4 @@ -import fetch, { Response } from 'lib/fetch' +import fetch, { Response } from './fetch' import * as config from 'config' export function sendSlack(message: string): Promise { diff --git a/price-server/src/provider/PricesProvider.ts b/price-server/src/provider/PricesProvider.ts index 5aa74bce..8a9fc081 100644 --- a/price-server/src/provider/PricesProvider.ts +++ b/price-server/src/provider/PricesProvider.ts @@ -1,8 +1,8 @@ -import { PriceBySymbol } from 'provider/base' -import { fiatProvider, cryptoProvider } from 'provider' -import { getBaseCurrency, getQuoteCurrency } from 'lib/currency' +import { PriceBySymbol } from './base' +import { fiatProvider, cryptoProvider } from '.' +import { getBaseCurrency, getQuoteCurrency } from './../lib/currency' import * as _ from 'lodash' -import { num } from 'lib/num' +import { num } from './../lib/num' export default class PricesProvider { // TODO: maybe ?? for a future version of the method diff --git a/price-server/src/provider/base/Provider.ts b/price-server/src/provider/base/Provider.ts index 9db1d289..dbb8cbe9 100644 --- a/price-server/src/provider/base/Provider.ts +++ b/price-server/src/provider/base/Provider.ts @@ -2,9 +2,9 @@ import { BigNumber } from 'bignumber.js' import { uniq, concat } from 'lodash' import { format, addMinutes, isSameMinute, isSameDay } from 'date-fns' import * as config from 'config' -import { createReporter } from 'lib/reporter' -import { average, tvwap } from 'lib/statistics' -import * as logger from 'lib/logger' +import { createReporter } from './../../lib/reporter' +import { average, tvwap } from './../../lib/statistics' +import * as logger from './../../lib/logger' import { PriceBySymbol, Trades } from './types' import Quoter from './Quoter' diff --git a/price-server/src/provider/base/Quoter.ts b/price-server/src/provider/base/Quoter.ts index 8fcdea8a..27ae0327 100644 --- a/price-server/src/provider/base/Quoter.ts +++ b/price-server/src/provider/base/Quoter.ts @@ -1,8 +1,8 @@ import { BigNumber } from 'bignumber.js' -import * as logger from 'lib/logger' -import { sendSlack } from 'lib/slack' +import * as logger from './../../lib/logger' +import { sendSlack } from '../../lib/slack' import { TradesBySymbol, Trades, PriceBySymbol } from './types' -import { setQuoterAlive } from 'lib/metrics' +import { setQuoterAlive } from '../../lib/metrics' export interface QuoterOptions { symbols: string[] // support symbols diff --git a/price-server/src/provider/base/WebSocketQuoter.ts b/price-server/src/provider/base/WebSocketQuoter.ts index 7337b6ab..aacc8124 100644 --- a/price-server/src/provider/base/WebSocketQuoter.ts +++ b/price-server/src/provider/base/WebSocketQuoter.ts @@ -1,6 +1,6 @@ import * as WebSocket from 'ws' -import { errorHandler } from 'lib/error' -import * as logger from 'lib/logger' +import { errorHandler } from './../../lib/error' +import * as logger from './../../lib/logger' import Quoter, { QuoterOptions } from './Quoter' export class WebSocketQuoter extends Quoter { diff --git a/price-server/src/provider/crypto/CryptoProvider.ts b/price-server/src/provider/crypto/CryptoProvider.ts index acd2351b..52b1bf2f 100644 --- a/price-server/src/provider/crypto/CryptoProvider.ts +++ b/price-server/src/provider/crypto/CryptoProvider.ts @@ -1,5 +1,5 @@ import * as config from 'config' -import { Provider, ProviderOptions } from 'provider/base' +import { Provider, ProviderOptions } from './../base' import { Upbit, Bithumb, Binance, Huobi, Bitfinex, Kraken, Kucoin, CoinGecko, Osmosis } from './quoter' class CryptoProvider extends Provider { diff --git a/price-server/src/provider/crypto/quoter/Binance.ts b/price-server/src/provider/crypto/quoter/Binance.ts index 8a07e08e..a8e43389 100644 --- a/price-server/src/provider/crypto/quoter/Binance.ts +++ b/price-server/src/provider/crypto/quoter/Binance.ts @@ -1,9 +1,9 @@ -import fetch from 'lib/fetch' -import { errorHandler } from 'lib/error' -import * as logger from 'lib/logger' -import { Quoter } from 'provider/base' +import fetch from './../../../lib/fetch' +import { errorHandler } from './../../../lib/error' +import * as logger from './../../../lib/logger' +import { Quoter } from './../../base' import * as _ from 'lodash' -import { num } from 'lib/num' +import { num } from './../../../lib/num' type Response = Array<{ symbol: string; price: string }> | { msg: string; code: number } diff --git a/price-server/src/provider/crypto/quoter/Bitfinex.ts b/price-server/src/provider/crypto/quoter/Bitfinex.ts index d6a79bca..69e42de3 100644 --- a/price-server/src/provider/crypto/quoter/Bitfinex.ts +++ b/price-server/src/provider/crypto/quoter/Bitfinex.ts @@ -1,9 +1,9 @@ -import fetch from 'lib/fetch' -import { errorHandler } from 'lib/error' -import * as logger from 'lib/logger' -import { num } from 'lib/num' -import { WebSocketQuoter, Trades } from 'provider/base' -import { getBaseCurrency, getQuoteCurrency } from 'lib/currency' +import fetch from './../../../lib/fetch' +import { errorHandler } from './../../../lib/error' +import * as logger from './../../../lib/logger' +import { num } from './../../../lib/num' +import { WebSocketQuoter, Trades } from './../../base' +import { getBaseCurrency, getQuoteCurrency } from './../../../lib/currency' interface StreamData { event: string diff --git a/price-server/src/provider/crypto/quoter/Bithumb.ts b/price-server/src/provider/crypto/quoter/Bithumb.ts index 3ae94dab..a59a0ad1 100644 --- a/price-server/src/provider/crypto/quoter/Bithumb.ts +++ b/price-server/src/provider/crypto/quoter/Bithumb.ts @@ -1,9 +1,9 @@ -import fetch from 'lib/fetch' -import { errorHandler } from 'lib/error' -import * as logger from 'lib/logger' -import { num } from 'lib/num' -import { WebSocketQuoter, Trades } from 'provider/base' -import { getBaseCurrency, getQuoteCurrency } from 'lib/currency' +import fetch from './../../../lib/fetch' +import { errorHandler } from './../../../lib/error' +import * as logger from './../../../lib/logger' +import { num } from './../../../lib/num' +import { WebSocketQuoter, Trades } from './../../base' +import { getBaseCurrency, getQuoteCurrency } from './../../../lib/currency' interface CandlestickResponse { status: string diff --git a/price-server/src/provider/crypto/quoter/CoinGecko.ts b/price-server/src/provider/crypto/quoter/CoinGecko.ts index cdce550d..d42e642b 100644 --- a/price-server/src/provider/crypto/quoter/CoinGecko.ts +++ b/price-server/src/provider/crypto/quoter/CoinGecko.ts @@ -1,9 +1,9 @@ -import fetch from 'lib/fetch' -import { errorHandler } from 'lib/error' -import * as logger from 'lib/logger' -import { num } from 'lib/num' -import { toQueryString } from 'lib/fetch' -import { Quoter } from 'provider/base' +import fetch from './../../../lib/fetch' +import { errorHandler } from './../../../lib/error' +import * as logger from './../../../lib/logger' +import { num } from './../../../lib/num' +import { toQueryString } from './../../../lib/fetch' +import { Quoter } from './../../base' type Response = Record diff --git a/price-server/src/provider/crypto/quoter/Coinone.ts b/price-server/src/provider/crypto/quoter/Coinone.ts index 0fc756a9..5252aef6 100644 --- a/price-server/src/provider/crypto/quoter/Coinone.ts +++ b/price-server/src/provider/crypto/quoter/Coinone.ts @@ -1,9 +1,9 @@ -import fetch from 'lib/fetch' -import { errorHandler } from 'lib/error' -import { num } from 'lib/num' -import * as logger from 'lib/logger' -import { Quoter, Trades } from 'provider/base' -import { getBaseCurrency } from 'lib/currency' +import fetch from './../../../lib/fetch' +import { errorHandler } from './../../../lib/error' +import { num } from './../../../lib/num' +import * as logger from './../../../lib/logger' +import { Quoter, Trades } from './../../base' +import { getBaseCurrency } from './../../../lib/currency' interface CandlestickResponse { success: boolean diff --git a/price-server/src/provider/crypto/quoter/Huobi.ts b/price-server/src/provider/crypto/quoter/Huobi.ts index 3ff56ab6..3d50aa39 100644 --- a/price-server/src/provider/crypto/quoter/Huobi.ts +++ b/price-server/src/provider/crypto/quoter/Huobi.ts @@ -1,10 +1,10 @@ import * as pako from 'pako' -import fetch from 'lib/fetch' -import { num } from 'lib/num' -import { errorHandler } from 'lib/error' -import * as logger from 'lib/logger' -import { toQueryString } from 'lib/fetch' -import { WebSocketQuoter, Trades } from 'provider/base' +import fetch from './../../../lib/fetch' +import { num } from './../../../lib/num' +import { errorHandler } from './../../../lib/error' +import * as logger from './../../../lib/logger' +import { toQueryString } from './../../../lib/fetch' +import { WebSocketQuoter, Trades } from './../../base' interface StreamData { ch?: string // channel name diff --git a/price-server/src/provider/crypto/quoter/Kraken.ts b/price-server/src/provider/crypto/quoter/Kraken.ts index 317311ad..875b0166 100644 --- a/price-server/src/provider/crypto/quoter/Kraken.ts +++ b/price-server/src/provider/crypto/quoter/Kraken.ts @@ -1,8 +1,8 @@ -import fetch, { toQueryString } from 'lib/fetch' -import { errorHandler } from 'lib/error' -import * as logger from 'lib/logger' -import { num } from 'lib/num' -import { Quoter } from 'provider/base' +import fetch, { toQueryString } from './../../../lib/fetch' +import { errorHandler } from './../../../lib/error' +import * as logger from './../../../lib/logger' +import { num } from './../../../lib/num' +import { Quoter } from './../../base' import _ from 'lodash' interface Response { diff --git a/price-server/src/provider/crypto/quoter/Kucoin.ts b/price-server/src/provider/crypto/quoter/Kucoin.ts index aaf52d89..a632e217 100644 --- a/price-server/src/provider/crypto/quoter/Kucoin.ts +++ b/price-server/src/provider/crypto/quoter/Kucoin.ts @@ -1,9 +1,9 @@ -import fetch from 'lib/fetch' -import { num } from 'lib/num' -import { errorHandler } from 'lib/error' -import * as logger from 'lib/logger' -import { toQueryString } from 'lib/fetch' -import { WebSocketQuoter, Trades } from 'provider/base' +import fetch from './../../../lib/fetch' +import { num } from './../../../lib/num' +import { errorHandler } from './../../../lib/error' +import * as logger from './../../../lib/logger' +import { toQueryString } from './../../../lib/fetch' +import { WebSocketQuoter, Trades } from './../../base' const url = 'https://api.kucoin.com' diff --git a/price-server/src/provider/crypto/quoter/Osmosis.ts b/price-server/src/provider/crypto/quoter/Osmosis.ts index c4435e73..76ec79e8 100644 --- a/price-server/src/provider/crypto/quoter/Osmosis.ts +++ b/price-server/src/provider/crypto/quoter/Osmosis.ts @@ -1,7 +1,7 @@ -import fetch from 'lib/fetch' -import { errorHandler } from 'lib/error' -import * as logger from 'lib/logger' -import { Quoter } from 'provider/base' +import fetch from './../../../lib/fetch' +import { errorHandler } from './../../../lib/error' +import * as logger from './../../../lib/logger' +import { Quoter } from './../../base' import BigNumber from 'bignumber.js' interface Response { diff --git a/price-server/src/provider/crypto/quoter/Upbit.ts b/price-server/src/provider/crypto/quoter/Upbit.ts index 4500b06f..991cbabe 100644 --- a/price-server/src/provider/crypto/quoter/Upbit.ts +++ b/price-server/src/provider/crypto/quoter/Upbit.ts @@ -1,9 +1,9 @@ -import fetch from 'lib/fetch' -import { errorHandler } from 'lib/error' -import * as logger from 'lib/logger' -import { num } from 'lib/num' -import { WebSocketQuoter, Trades } from 'provider/base' -import { getBaseCurrency, getQuoteCurrency } from 'lib/currency' +import fetch from './../../../lib/fetch' +import { errorHandler } from './../../../lib/error' +import * as logger from './../../../lib/logger' +import { num } from './../../../lib/num' +import { WebSocketQuoter, Trades } from './../../base' +import { getBaseCurrency, getQuoteCurrency } from './../../../lib/currency' interface CandleStickResponse { market: string diff --git a/price-server/src/provider/fiat/FiatProvider.ts b/price-server/src/provider/fiat/FiatProvider.ts index 75d6b0ab..1406c300 100644 --- a/price-server/src/provider/fiat/FiatProvider.ts +++ b/price-server/src/provider/fiat/FiatProvider.ts @@ -1,5 +1,5 @@ import * as config from 'config' -import { Provider, ProviderOptions } from 'provider/base' +import { Provider, ProviderOptions } from './../base' import { CurrencyLayer, AlphaVantage, Fixer, ExchangeRate, Fer, Frankfurter } from './quoter' class FiatProvider extends Provider { diff --git a/price-server/src/provider/fiat/quoter/AlphaVantage.ts b/price-server/src/provider/fiat/quoter/AlphaVantage.ts index 0494c73c..3b246731 100644 --- a/price-server/src/provider/fiat/quoter/AlphaVantage.ts +++ b/price-server/src/provider/fiat/quoter/AlphaVantage.ts @@ -1,9 +1,9 @@ -import fetch from 'lib/fetch' -import { errorHandler } from 'lib/error' -import { toQueryString } from 'lib/fetch' -import * as logger from 'lib/logger' -import { num } from 'lib/num' -import { Quoter } from 'provider/base' +import fetch from './../../../lib/fetch' +import { errorHandler } from './../../../lib/error' +import { toQueryString } from './../../../lib/fetch' +import * as logger from './../../../lib/logger' +import { num } from './../../../lib/num' +import { Quoter } from './../../base' interface Response { 'Realtime Currency Exchange Rate': { diff --git a/price-server/src/provider/fiat/quoter/CurrencyLayer.ts b/price-server/src/provider/fiat/quoter/CurrencyLayer.ts index a0283ca2..8a353474 100644 --- a/price-server/src/provider/fiat/quoter/CurrencyLayer.ts +++ b/price-server/src/provider/fiat/quoter/CurrencyLayer.ts @@ -1,9 +1,9 @@ -import fetch from 'lib/fetch' -import { errorHandler } from 'lib/error' -import { toQueryString } from 'lib/fetch' -import { num } from 'lib/num' -import * as logger from 'lib/logger' -import { Quoter } from 'provider/base' +import fetch from './../../../lib/fetch' +import { errorHandler } from './../../../lib/error' +import { toQueryString } from './../../../lib/fetch' +import { num } from './../../../lib/num' +import * as logger from './../../../lib/logger' +import { Quoter } from './../../base' interface Response { success: boolean diff --git a/price-server/src/provider/fiat/quoter/ExchangeRate.ts b/price-server/src/provider/fiat/quoter/ExchangeRate.ts index e0fd7122..7ceb63af 100644 --- a/price-server/src/provider/fiat/quoter/ExchangeRate.ts +++ b/price-server/src/provider/fiat/quoter/ExchangeRate.ts @@ -1,9 +1,9 @@ import nodeFetch from 'node-fetch' -import { errorHandler } from 'lib/error' -import { toQueryString } from 'lib/fetch' -import { num } from 'lib/num' -import * as logger from 'lib/logger' -import { Quoter } from 'provider/base' +import { errorHandler } from './../../../lib/error' +import { toQueryString } from './../../../lib/fetch' +import { num } from './../../../lib/num' +import * as logger from './../../../lib/logger' +import { Quoter } from './../../base' interface Response { success: boolean diff --git a/price-server/src/provider/fiat/quoter/Fer.ts b/price-server/src/provider/fiat/quoter/Fer.ts index c04d660c..279b3cee 100644 --- a/price-server/src/provider/fiat/quoter/Fer.ts +++ b/price-server/src/provider/fiat/quoter/Fer.ts @@ -1,10 +1,10 @@ -import fetch from 'lib/fetch' -import { errorHandler } from 'lib/error' -import { toQueryString } from 'lib/fetch' -import * as logger from 'lib/logger' -import { num } from 'lib/num' -import { Quoter } from 'provider/base' -import { getBaseCurrency, getQuoteCurrency } from 'lib/currency' +import fetch from './../../../lib/fetch' +import { errorHandler } from './../../../lib/error' +import { toQueryString } from './../../../lib/fetch' +import * as logger from './../../../lib/logger' +import { num } from './../../../lib/num' +import { Quoter } from './../../base' +import { getBaseCurrency, getQuoteCurrency } from './../../../lib/currency' interface Response { date: string diff --git a/price-server/src/provider/fiat/quoter/Fixer.ts b/price-server/src/provider/fiat/quoter/Fixer.ts index 3b033994..db232672 100644 --- a/price-server/src/provider/fiat/quoter/Fixer.ts +++ b/price-server/src/provider/fiat/quoter/Fixer.ts @@ -1,9 +1,8 @@ -import fetch from 'lib/fetch' -import * as logger from 'lib/logger' -import { errorHandler } from 'lib/error' -import { toQueryString } from 'lib/fetch' -import { num } from 'lib/num' -import { Quoter } from 'provider/base' +import fetch, { toQueryString } from './../../../lib/fetch' +import * as logger from './../../../lib/logger' +import { errorHandler } from './../../../lib/error' +import { num } from './../../../lib/num' +import { Quoter } from './../../base' interface Response { success: boolean diff --git a/price-server/src/provider/fiat/quoter/Frankfurter.ts b/price-server/src/provider/fiat/quoter/Frankfurter.ts index 20309f5d..123c677d 100644 --- a/price-server/src/provider/fiat/quoter/Frankfurter.ts +++ b/price-server/src/provider/fiat/quoter/Frankfurter.ts @@ -1,10 +1,9 @@ -import fetch from 'lib/fetch' -import { errorHandler } from 'lib/error' -import { toQueryString } from 'lib/fetch' -import * as logger from 'lib/logger' -import { num } from 'lib/num' -import { Quoter } from 'provider/base' -import { getBaseCurrency, getQuoteCurrency } from 'lib/currency' +import fetch, { toQueryString } from './../../../lib/fetch' +import { errorHandler } from './../../../lib/error' +import * as logger from './../../../lib/logger' +import { num } from './../../../lib/num' +import { Quoter } from './../../base' +import { getBaseCurrency, getQuoteCurrency } from './../../../lib/currency' interface Response { date: string diff --git a/price-server/src/provider/index.ts b/price-server/src/provider/index.ts index 0560aaf0..19514d84 100644 --- a/price-server/src/provider/index.ts +++ b/price-server/src/provider/index.ts @@ -1,6 +1,6 @@ import * as config from 'config' import * as bluebird from 'bluebird' -import { errorHandler } from 'lib/error' +import { errorHandler } from './../lib/error' import { Provider } from './base' import { report } from './reporter' import FiatProvider from './fiat/FiatProvider' diff --git a/price-server/src/provider/reporter.ts b/price-server/src/provider/reporter.ts index aa926e03..9d444214 100644 --- a/price-server/src/provider/reporter.ts +++ b/price-server/src/provider/reporter.ts @@ -1,8 +1,8 @@ import * as config from 'config' import * as _ from 'lodash' import { format, isSameDay, isSameMinute, addMinutes } from 'date-fns' -import * as logger from 'lib/logger' -import { createReporter } from 'lib/reporter' +import * as logger from './../lib/logger' +import { createReporter } from './../lib/reporter' import PricesProvider from './PricesProvider' let reporter diff --git a/price-server/src/server.ts b/price-server/src/server.ts index f59cfa45..da178e3b 100644 --- a/price-server/src/server.ts +++ b/price-server/src/server.ts @@ -3,10 +3,10 @@ import * as polka from 'polka' import * as send from '@polka/send-type' import * as bluebird from 'bluebird' import * as config from 'config' -import * as logger from 'lib/logger' +import * as logger from './lib/logger' import PricesProvider from './provider/PricesProvider' -import { countAllRequests } from 'lib/metrics' -import { getBaseCurrency } from 'lib/currency' +import { countAllRequests } from './lib/metrics' +import { getBaseCurrency } from './lib/currency' bluebird.config({ longStackTraces: true })