-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1249 from edenia/feat/evm-backend
- Loading branch information
Showing
117 changed files
with
5,052 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
node_modules/ | ||
.git/ | ||
.gitignore | ||
.eslintrc | ||
Dockerfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
// "root": true, | ||
"parser": "@typescript-eslint/parser", | ||
"plugins": [ | ||
"@typescript-eslint" | ||
], | ||
"extends": [ | ||
"eslint:recommended", | ||
"plugin:@typescript-eslint/eslint-recommended", | ||
"plugin:@typescript-eslint/recommended", | ||
"plugin:prettier/recommended" | ||
], | ||
"parserOptions": { | ||
"ecmaVersion": 2020 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# See https://help.github.com/ignore-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
node_modules | ||
|
||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
resources/**/* | ||
# yarn | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
cd hapi && yarn lint-staged |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"trailingComma": "none", | ||
"endOfLine": "auto", | ||
"tabWidth": 2, | ||
"singleQuote": true, | ||
"semi": false, | ||
"arrowParens": "avoid" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# ---------- Base ---------- | ||
FROM node:16.20.0 as base | ||
WORKDIR /app | ||
|
||
# ---------- Builder ---------- | ||
FROM base AS builder | ||
COPY package.json yarn.lock ./ | ||
RUN yarn --ignore-optional | ||
COPY ./src ./src | ||
|
||
# ---------- Release ---------- | ||
FROM base AS release | ||
COPY --from=builder /app/node_modules ./node_modules | ||
COPY --from=builder /app/src ./src | ||
USER node | ||
CMD ["node", "./src/index.js"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 EOS Costa Rica | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
include ../utils/meta.mk ../utils/help.mk | ||
|
||
LATEST_TAG ?= latest | ||
|
||
install: ##@local Install all dependencies | ||
install: | ||
@npm install | ||
|
||
clean-install: ##@local Reinstalls all dependencies | ||
clean-install: | ||
@rm -Rf node_modules | ||
@npm install | ||
|
||
run: ##@local Run the project locally (without docker) | ||
run: node_modules | ||
@$(SHELL_EXPORT) npm run dev | ||
|
||
build-docker: ##@devops Build the docker image | ||
build-docker: ./Dockerfile | ||
@docker pull $(DOCKER_REGISTRY)/$(IMAGE_NAME_HAPI):$(VERSION) || true | ||
@docker build \ | ||
--target release \ | ||
-t $(DOCKER_REGISTRY)/$(IMAGE_NAME_HAPI):$(VERSION) \ | ||
-t $(DOCKER_REGISTRY)/$(IMAGE_NAME_HAPI):$(LATEST_TAG) \ | ||
. | ||
|
||
pull-image: ##@devops Pull the latest image from registry for caching | ||
pull-image: | ||
@docker pull $(DOCKER_REGISTRY)/$(IMAGE_NAME_HAPI):$(LATEST_TAG) || true | ||
|
||
build-docker-cached: ##@devops Build the docker image using cached layers | ||
build-docker-cached: ./Dockerfile | ||
@docker build \ | ||
--target prod-stage \ | ||
--cache-from $(DOCKER_REGISTRY)/$(IMAGE_NAME_HAPI):$(LATEST_TAG) \ | ||
-t $(DOCKER_REGISTRY)/$(IMAGE_NAME_HAPI):$(VERSION) \ | ||
-t $(DOCKER_REGISTRY)/$(IMAGE_NAME_HAPI):$(LATEST_TAG) \ | ||
. | ||
|
||
push-image: ##@devops Push the freshly built image and tag with release or latest tag | ||
push-image: | ||
@docker push $(DOCKER_REGISTRY)/$(IMAGE_NAME_HAPI):$(VERSION) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"watch": ["src"], | ||
"ext": ".ts,.js", | ||
"ignore": [], | ||
"exec": "ts-node ./src/index.ts" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{ | ||
"name": "evm-backend", | ||
"version": "1.0.0", | ||
"description": "EVM Dashbaord Backend Service", | ||
"main": "dist/index.js", | ||
"author": "edenia.com", | ||
"license": "MIT", | ||
"scripts": { | ||
"build": "tsc", | ||
"start": "tsc && node dist/index.js", | ||
"start:dev": "nodemon", | ||
"prepare": "cd .. && husky install hapi/.husky" | ||
}, | ||
"lint-staged": { | ||
"*.ts": [ | ||
"eslint . --ext .ts", | ||
"prettier --write" | ||
] | ||
}, | ||
"dependencies": { | ||
"@hapi/boom": "^10.0.1", | ||
"@hapi/hapi": "^21.3.2", | ||
"@types/web3": "^1.2.2", | ||
"axios": "^1.4.0", | ||
"eosjs": "^22.1.0", | ||
"eosjs-api": "^7.0.4", | ||
"graphql": "16", | ||
"graphql-request": "^6.0.0", | ||
"joi": "^17.9.2", | ||
"moment": "^2.29.4", | ||
"node-fetch": "^3.3.1", | ||
"web3": "^4.0.3", | ||
"websocket": "^1.0.34" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^20.1.5", | ||
"@typescript-eslint/eslint-plugin": "^6.0.0", | ||
"@typescript-eslint/parser": "^6.0.0", | ||
"eslint": "^8.40.0", | ||
"eslint-config-prettier": "^8.8.0", | ||
"eslint-plugin-prettier": "^5.0.0", | ||
"husky": "^8.0.3", | ||
"lint-staged": "^13.2.2", | ||
"nodemon": "^3.0.1", | ||
"prettier": "^3.0.0", | ||
"ts-node": "^10.9.1", | ||
"typescript": "^5.0.4" | ||
} | ||
} |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export const url = | ||
process.env.HAPI_HASURA_URL || 'http://hasura:8080/v1/graphql' | ||
export const adminSecret = | ||
process.env.HAPI_HASURA_ADMIN_SECRET || 'myadminsecretkey' | ||
|
||
if (!url || !adminSecret) { | ||
throw new Error('Missing required hasura env variables') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export const api = | ||
process.env.HAPI_HYPERION_API || 'https://test.telos.eosusa.io' | ||
export const startAt = | ||
process.env.HAPI_HYPERION_START_AT || '2021-06-02T00:00:00.000+00:00' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export * as serverConfig from './server.config' | ||
export * as hasuraConfig from './hasura.config' | ||
export * as networkConfig from './network.config' | ||
export * as hyperionConfig from './hyperion.config' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export const evmEndpoint = | ||
process.env.HAPI_EVM_ENDPOINT || 'http://localhost/evm' | ||
export const chainId = process.env.HAPI_NETWORK_CHAIN_ID || 'chainid1' | ||
export const evmAccount = process.env.HAPI_EVM_EOS_EVM_ACCOUNT || 'eosio.evm' | ||
export const eosEndpoints = | ||
process.env.HAPI_EVM_EOS_EVM_ACCOUNT?.split(',') || [] | ||
export const blockIntervalSec = parseFloat( | ||
process.env.HAPI_BLOCK_INTERVAL_SEC || '0.5' | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export const port = process.env.HAPI_EVM_SERVER_PORT | ||
export const host = process.env.HAPI_EVM_SERVER_ADDRESS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import Hapi from '@hapi/hapi' | ||
import { Server } from '@hapi/hapi' | ||
|
||
import routes from './routes' | ||
import { serverConfig } from './config' | ||
import workerService from './services/worker' | ||
|
||
const init = async () => { | ||
const server: Server = Hapi.server({ | ||
port: serverConfig.port, | ||
host: serverConfig.host, | ||
routes: { | ||
cors: { origin: ['*'] } | ||
}, | ||
debug: { request: ['handler'] } | ||
}) | ||
|
||
routes(server) | ||
|
||
await server.start() | ||
|
||
workerService.init() | ||
|
||
console.log(`🚀 Server ready at ${server.info.uri}`) | ||
server.table().forEach(route => console.log(`${route.method}\t${route.path}`)) | ||
} | ||
|
||
process.on('uncaughtException', (err, origin) => { | ||
console.log('Uncaught Exception:', err, 'Exception origin:', origin) | ||
}) | ||
|
||
process.on('unhandledRejection', (reason, promise) => { | ||
console.log('Unhandled Rejection:', promise, 'reason:', reason) | ||
}) | ||
|
||
init() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * as interfaces from './interfaces' | ||
export * as queries from './queries' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { TransactionHash, TransactionInfo } from 'web3-types' | ||
|
||
export interface CappedBlock { | ||
hash: string | ||
gas_used: number | ||
transactions: TransactionHash[] | TransactionInfo[] | ||
number: number | ||
timestamp: Date | ||
} |
Oops, something went wrong.