Skip to content

Commit c881065

Browse files
committed
test
1 parent a5f4ede commit c881065

18 files changed

+2738
-5739
lines changed

.babelrc

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
[
44
"@babel/preset-env",
55
{
6-
"useBuiltIns": "usage",
7-
"corejs": 2
6+
"corejs": 3,
7+
"useBuiltIns": "usage"
88
}
99
],
1010
"@babel/typescript"

.eslintignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
build
1+
build
2+
dist

.eslintrc

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
"@typescript-eslint/no-unused-expressions": ["off"],
99
"@typescript-eslint/no-var-requires": ["off"],
1010
"@typescript-eslint/no-use-before-define": ["off"],
11+
"@typescript-eslint/no-unused-vars": ["off"],
12+
"@typescript-eslint/no-namespace": ["off"],
1113
"comma-dangle": ["error", "always-multiline"],
1214
"no-async-promise-executor": ["off"],
1315
"no-empty-pattern": ["off"],
@@ -21,7 +23,7 @@
2123
"sort-keys": ["off"],
2224
"space-before-function-paren": ["off"],
2325
"indent": ["off"],
24-
"no-console": ["off"]
26+
"no-console": ["error", { "allow": ["warn"] }]
2527
},
2628
"env": {
2729
"browser": true,

babel-polyfill.js

-3
This file was deleted.

now.json

-6
This file was deleted.

package-lock.json

+2,142-5,341
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+41-37
Original file line numberDiff line numberDiff line change
@@ -16,50 +16,54 @@
1616
"author": "Pedro Gomes <[email protected]>",
1717
"homepage": "https://ethereum-api.xyz",
1818
"license": "MIT",
19+
"repository": {
20+
"type": "git",
21+
"url": "git+https://github.com/pedrouid/ethreum-api.git"
22+
},
23+
"bugs": {
24+
"url": "https://github.com/pedrouid/ethreum-api/issues"
25+
},
1926
"scripts": {
20-
"clean": "rm -rf ./build",
27+
"clean": "rm -rf ./dist",
2128
"compile": "tsc -p tsconfig.json",
22-
"build": "npm run clean && npm run compile",
23-
"start": "npm run build && node ./build",
24-
"lint": "eslint -c './.eslintrc' --fix './src/**/*.ts'",
29+
"dev": "run-p -l watch nodemon",
30+
"nodemon": "nodemon ./dist",
31+
"watch": "tsc -p tsconfig.json --watch",
32+
"build": "run-s clean compile",
33+
"start": "npm run build && node ./dist",
34+
"test": "env TS_NODE_PROJECT=\"tsconfig.json\" mocha --exit -r ts-node/register ./test/**/*.spec.ts",
35+
"lint": "eslint -c --fix './src/**/*.ts'",
2536
"deploy": "NODE_ENV=production pm2 start ./build --name=server"
2637
},
2738
"dependencies": {
28-
"axios": "^0.19.0",
29-
"bignumber.js": "^7.2.1",
30-
"core-js": "^2.6.5",
31-
"dotenv": "^8.0.0",
32-
"fastify": "^2.4.1",
33-
"fastify-cors": "^2.1.3",
34-
"fastify-helmet": "^3.0.0",
35-
"utf8": "^3.0.0"
39+
"@pedrouid/pino-utils": "^1.0.1",
40+
"axios": "^0.21.1",
41+
"bignumber.js": "^9.0.1",
42+
"dotenv": "^8.2.0",
43+
"fastify": "^3.10.1",
44+
"fastify-cors": "^5.2.0",
45+
"fastify-helmet": "^5.1.0",
46+
"pino": "^6.11.0",
47+
"pino-pretty": "^4.3.0",
48+
"utf8": "^3.0.0",
49+
"tslib": "^2.1.0"
3650
},
3751
"devDependencies": {
38-
"@babel/cli": "^7.1.2",
39-
"@babel/core": "^7.1.2",
40-
"@babel/node": "^7.0.0",
41-
"@babel/polyfill": "^7.0.0",
42-
"@babel/preset-env": "^7.1.0",
43-
"@babel/preset-typescript": "^7.1.0",
44-
"@babel/register": "^7.0.0",
45-
"@types/bignumber.js": "^5.0.0",
46-
"@types/chai": "^4.1.6",
47-
"@types/dotenv": "^6.1.0",
48-
"@types/mocha": "^5.2.5",
49-
"@types/node": "^12.0.7",
50-
"@types/utf8": "^2.1.6",
51-
"@typescript-eslint/eslint-plugin": "^2.24.0",
52-
"@typescript-eslint/parser": "^2.24.0",
53-
"eslint": "^5.16.0",
54-
"eslint-config-prettier": "^6.10.0",
55-
"eslint-config-standard": "^12.0.0",
56-
"eslint-plugin-import": "^2.20.1",
57-
"eslint-plugin-node": "^9.2.0",
58-
"eslint-plugin-prettier": "^3.1.2",
59-
"eslint-plugin-promise": "^4.2.1",
60-
"eslint-plugin-react": "^7.19.0",
61-
"eslint-plugin-standard": "^4.0.1",
52+
"@types/chai": "^4.2.14",
53+
"@types/core-js": "^2.5.2",
54+
"@types/mocha": "^8.2.0",
55+
"@types/node": "^14.14.21",
56+
"@types/pino": "^6.3.5",
57+
"@types/redis": "^2.8.13",
58+
"@types/ws": "^6.0.1",
59+
"chai": "^4.2.0",
60+
"chai-http": "^4.3.0",
61+
"core-js": "^3.8.3",
62+
"mocha": "^8.2.1",
63+
"nodemon": "^2.0.7",
64+
"npm-run-all": "^4.1.5",
6265
"prettier": "^1.19.1",
63-
"typescript": "^3.7.3"
66+
"ts-node": "^9.1.1",
67+
"typescript": "^3.7.5"
6468
}
6569
}

src/blockscout.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,15 @@ export async function apiGetAccountNativeCurrency(address: string, chainId: numb
4646

4747
const nativeCurrency = chainData.native_currency;
4848

49-
const balanceRes = await apiGetAccountBalance(address, chainId);
50-
51-
let nativeBalance = isSuccessful(balanceRes) ? balanceRes.data.result : 0;
49+
let nativeBalance = 0
50+
try {
51+
const balanceRes = await apiGetAccountBalance(address, chainId);
52+
if (isSuccessful(balanceRes)) {
53+
nativeBalance = balanceRes.data.result
54+
}
55+
} catch(e) {
56+
// ignore error
57+
}
5258

5359
if (!nativeBalance) {
5460
nativeBalance = await rpcGetAccountBalance(address, chainId);

src/config/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ const debug = env !== "production";
88
export default {
99
env: env,
1010
debug: debug,
11-
port: process.env.PORT || env === "production" ? 5000 : 5001,
11+
host: process.env.HOST || `0.0.0.0`,
12+
port: process.env.PORT || env === "production" ? 5000 : 5005,
1213
infura: {
1314
id: process.env.INFURA_PROJECT_ID,
1415
secret: process.env.INFURA_PROJECT_SECRET,

src/errors.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import { FastifyResponse } from "./types";
1+
import { FastifyReply } from "fastify";
22

3-
export function sendInvalidParamError(res: FastifyResponse, param: string) {
3+
export function sendInvalidParamError(res: FastifyReply, param: string) {
44
res.status(500).send({
55
success: false,
66
error: "Internal Server Error",
77
message: `Missing or invalid ${param} parameter`,
88
});
99
}
1010

11-
export function sendErrorMessage(res: FastifyResponse, error: Error) {
11+
export function sendErrorMessage(res: FastifyReply, error: Error) {
1212
res.status(500).send({
1313
success: false,
1414
error: "Internal Server Error",

0 commit comments

Comments
 (0)