Skip to content

Commit

Permalink
Merge pull request #64 from edenia/feat/maintenance
Browse files Browse the repository at this point in the history
Feat/maintenance
  • Loading branch information
xavier506 authored Oct 23, 2023
2 parents f4ca1d1 + 0b79c62 commit 1049054
Show file tree
Hide file tree
Showing 32 changed files with 2,316 additions and 2,244 deletions.
13 changes: 5 additions & 8 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,21 @@ HASURA_GRAPHQL_ACTION_BASE_URL=http://hapi:9090
# hapi
HAPI_SERVER_PORT=9090
HAPI_SERVER_ADDRESS=hapi
HAPI_NETWORK_API=https://jungle.edenia.cloud
HAPI_NETWORK_CHAIN_ID=73e4385a2708e6d7048834fbc1079f2fabb17b3c125b146af438971e90716c4d
HAPI_NETWORK_CHAIN_INDEX=Jungle4 # 'EOS' | 'FIO' | 'FIOTestnet' | 'Jungle4' | 'KylinTestnet' | 'Libre' | 'LibreTestnet' | 'Proton' | 'ProtonTestnet' | 'Telos' | 'TelosTestnet' | 'WAX' | 'WAXTestnet' | 'UX'
HAPI_CUSTOM_NETWORK_CHAIN={"id": "", "url": ""}
HAPI_NETWORK_BASE_ACCOUNT=accountname1
HAPI_NETWORK_BASE_PASSWORD=PW...
HAPI_NETWORK_WALLET_URL=http://wallet:8888
HAPI_HASURA_URL=http://hasura:8080/v1/graphql
HAPI_HASURA_ADMIN_SECRET=myadminsecretkey

#webapp
# webapp
PORT=3000
NEXT_PUBLIC_TAG=$npm_package_version
NEXT_PUBLIC_NAME=$npm_package_name
NEXT_PUBLIC_TITLE=Boilerplate App
NEXT_PUBLIC_LOGO=https://raw.githubusercontent.com/edenia/.github/master/.github/workflows/images/edenia-logo.png
NEXT_PUBLIC_FOOTER_LINKS=[]
NEXT_PUBLIC_UAL_APP_NAME=BoilerplateWebApp
NEXT_PUBLIC_UAL_API_PROTOCOL=https
NEXT_PUBLIC_UAL_API_HOST=jungle.edenia.cloud
NEXT_PUBLIC_UAL_API_PORT=443
NEXT_PUBLIC_UAL_CHAIN_ID=73e4385a2708e6d7048834fbc1079f2fabb17b3c125b146af438971e90716c4d
NEXT_PUBLIC_NETWORK_CHAIN_INDEX=Jungle4 # 'EOS' | 'FIO' | 'FIOTestnet' | 'Jungle4' | 'KylinTestnet' | 'Libre' | 'LibreTestnet' | 'Proton' | 'ProtonTestnet' | 'Telos' | 'TelosTestnet' | 'WAX' | 'WAXTestnet' | 'UX'
NEXT_PUBLIC_CUSTOM_NETWORK_CHAIN={"id": "", "url": ""}
NEXT_PUBLIC_HASURA_URL=http://localhost:8080/v1/graphql
21 changes: 9 additions & 12 deletions .github/workflows/push-dev-environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,13 @@ jobs:
# webapp
PORT: 3000
NEXT_PUBLIC_TAG: ${{ github.ref }}
NEXT_PUBLIC_NAME: 'edenia_boilerplate'
NEXT_PUBLIC_TITLE: 'Fullstack Boilerplate'
NEXT_PUBLIC_LOGO: 'https://raw.githubusercontent.com/edenia/.github/master/.github/workflows/images/edenia-logo.png'
NEXT_PUBLIC_FOOTER_LINKS: '[]'
NEXT_PUBLIC_UAL_APP_NAME: 'Full-Stack Boilerplate'
NEXT_PUBLIC_UAL_API_PROTOCOL: 'https'
NEXT_PUBLIC_UAL_API_HOST: 'boilerplate.edenia.cloud'
NEXT_PUBLIC_UAL_API_PORT: '443'
NEXT_PUBLIC_UAL_CHAIN_ID: '2a02a0053e5a8cf73a56ba0fda11e4d92e0238a4a2aa74fccf46d5a910746840'
NEXT_PUBLIC_HASURA_URL: 'https://graphql-boilerplate.edenia.cloud/v1/graphql'
NEXT_PUBLIC_NAME: "edenia_boilerplate"
NEXT_PUBLIC_TITLE: "Fullstack Boilerplate"
NEXT_PUBLIC_LOGO: "https://raw.githubusercontent.com/edenia/.github/master/.github/workflows/images/edenia-logo.png"
NEXT_PUBLIC_FOOTER_LINKS: "[]"
NEXT_PUBLIC_NETWORK_CHAIN_INDEX: "Jungle4"
NEXT_PUBLIC_CUSTOM_NETWORK_CHAIN: "{}"
NEXT_PUBLIC_HASURA_URL: "https://graphql-boilerplate.edenia.cloud/v1/graphql"

- name: Build kubernetes files
id: build_kubernetes_files
Expand All @@ -60,8 +57,8 @@ jobs:
# hapi
HAPI_SERVER_PORT: 9090
HAPI_SERVER_ADDRESS: 0.0.0.0
HAPI_NETWORK_API: 'https://jungle.edenia.cloud'
HAPI_NETWORK_CHAIN_ID: '2a02a0053e5a8cf73a56ba0fda11e4d92e0238a4a2aa74fccf46d5a910746840'
HAPI_NETWORK_CHAIN_INDEX: "Jungle4" # 'EOS' | 'FIO' | 'FIOTestnet' | 'Jungle4' | 'KylinTestnet' | 'Libre' | 'LibreTestnet' | 'Proton' | 'ProtonTestnet' | 'Telos' | 'TelosTestnet' | 'WAX' | 'WAXTestnet' | 'UX';
HAPI_CUSTOM_NETWORK_CHAIN: "{}"
HAPI_NETWORK_BASE_ACCOUNT: ${{ secrets.HAPI_NETWORK_BASE_ACCOUNT }}
HAPI_NETWORK_BASE_PASSWORD: ${{ secrets.HAPI_NETWORK_BASE_PASSWORD }}
HAPI_NETWORK_WALLET_URL: ${{ secrets.HAPI_NETWORK_WALLET }}
Expand Down
11 changes: 5 additions & 6 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ services:
POSTGRES_DB: "${POSTGRES_DB}"
hapi:
container_name: "hapi"
image: node:16.20.2
image: node:18.18.0
ports:
- "9090:9090"
volumes:
Expand All @@ -32,8 +32,8 @@ services:
environment:
HAPI_SERVER_PORT: "${HAPI_SERVER_PORT}"
HAPI_SERVER_ADDRESS: "${HAPI_SERVER_ADDRESS}"
HAPI_NETWORK_API: "${HAPI_NETWORK_API}"
HAPI_NETWORK_CHAIN_ID: "${HAPI_NETWORK_CHAIN_ID}"
HAPI_NETWORK_CHAIN_INDEX: "${HAPI_NETWORK_CHAIN_INDEX}"
HAPI_CUSTOM_NETWORK_CHAIN: "${HAPI_CUSTOM_NETWORK_CHAIN}"
HAPI_NETWORK_BASE_ACCOUNT: "${HAPI_NETWORK_BASE_ACCOUNT}"
HAPI_NETWORK_BASE_PASSWORD: "${HAPI_NETWORK_BASE_PASSWORD}"
HAPI_NETWORK_WALLET_URL: "${HAPI_NETWORK_WALLET_URL}"
Expand Down Expand Up @@ -61,9 +61,8 @@ services:
HASURA_GRAPHQL_DEV_MODE: "true"
HASURA_GRAPHQL_ENABLED_LOG_TYPES: startup, http-log, webhook-log, websocket-log, query-log
HASURA_GRAPHQL_ENABLE_LOGGING: "true"
# disabled security for local development
# HASURA_GRAPHQL_ADMIN_SECRET: "${HASURA_GRAPHQL_ADMIN_SECRET}"
# HASURA_GRAPHQL_UNAUTHORIZED_ROLE: "${HASURA_GRAPHQL_UNAUTHORIZED_ROLE}"
HASURA_GRAPHQL_ADMIN_SECRET: "${HASURA_GRAPHQL_ADMIN_SECRET}"
HASURA_GRAPHQL_UNAUTHORIZED_ROLE: "${HASURA_GRAPHQL_UNAUTHORIZED_ROLE}"
webapp:
container_name: "webapp"
image: node:16.14.0-alpine
Expand Down
2 changes: 1 addition & 1 deletion hapi/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ---------- Base ----------
FROM node:16.20.2 as base
FROM node:18.18.0 as base
WORKDIR /app

# ---------- Builder ----------
Expand Down
8 changes: 7 additions & 1 deletion hapi/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"name": "eosioboilerplate",
"version": "1.0.0",
"engines": {
"node": ">=18"
},
"description": "Edenia Boilerplate WebApp",
"repository": "https://github.com/edenia/full-stack-boilerplate.git",
"license": "MIT",
Expand All @@ -19,6 +22,9 @@
"dependencies": {
"@hapi/boom": "^10.0.0",
"@hapi/hapi": "^21.3.2",
"@wharfkit/common": "^1.1.0",
"@wharfkit/session": "^1.0.0",
"@wharfkit/wallet-plugin-privatekey": "^1.0.0",
"axios": "^1.5.1",
"eosjs": "^22.1.0",
"eosjs-api": "^7.0.4",
Expand All @@ -28,7 +34,7 @@
"node-fetch": "^3.3.2"
},
"devDependencies": {
"@types/node": "^20.7.0",
"@types/node": "^20.7.2",
"@typescript-eslint/eslint-plugin": "^6.7.3",
"@typescript-eslint/parser": "^6.7.3",
"eslint": "^8.50.0",
Expand Down
30 changes: 23 additions & 7 deletions hapi/src/config/eos.config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
export const endpoint =
process.env.HAPI_NETWORK_API || 'https://jungle.edenia.cloud'
export const chainId =
process.env.HAPI_NETWORK_CHAIN_ID ||
'73e4385a2708e6d7048834fbc1079f2fabb17b3c125b146af438971e90716c4d'
export const baseAccount =
import { NameType, PrivateKeyType } from '@wharfkit/session'
import { Chains, ChainIndices, ChainDefinition } from '@wharfkit/common'

if (
!process.env.HAPI_NETWORK_CHAIN_INDEX &&
!process.env.HAPI_CUSTOM_NETWORK_CHAIN
) {
throw new Error('Chain not defined')
}

export const chain = process.env.HAPI_NETWORK_CHAIN_INDEX
? Chains[process.env.HAPI_NETWORK_CHAIN_INDEX.trim() as ChainIndices]
: ChainDefinition.from(
JSON.parse(process.env.HAPI_CUSTOM_NETWORK_CHAIN || '{}')
)

if (!chain) {
throw new Error('Failed to load chain')
}

export const baseAccount: NameType =
process.env.HAPI_NETWORK_BASE_ACCOUNT || 'accountname1'
export const baseAccountPassword = process.env.HAPI_NETWORK_BASE_PASSWORD
export const baseAccountPassword: PrivateKeyType =
process.env.HAPI_NETWORK_BASE_PASSWORD || 'password'
export const walletUrl = process.env.HAPI_NETWORK_WALLET_URL
68 changes: 0 additions & 68 deletions hapi/src/utils/eos.util.ts

This file was deleted.

2 changes: 1 addition & 1 deletion hapi/src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * as coreUtil from './core'
export * as timeUtil from './time.util'
export * as eosUtil from './eos.util'
export * as wharfUtil from './wharf.util'
29 changes: 29 additions & 0 deletions hapi/src/utils/wharf.util.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Session, NameType, AnyAction } from '@wharfkit/session'
import { WalletPluginPrivateKey } from '@wharfkit/wallet-plugin-privatekey'

import { eosConfig } from '../config'

const args = {
chain: eosConfig.chain,
actor: eosConfig.baseAccount,
permission: 'active',
walletPlugin: new WalletPluginPrivateKey(eosConfig.baseAccountPassword)
}

const defaultSessionOptions = {}
const session = new Session(args, defaultSessionOptions)

export const getAbi = async (account: NameType) =>
await session.client.v1.chain.get_abi(account)

export const getAccount = async (account: NameType) =>
await session.client.v1.chain.get_account(account)

export const sendTransaction = async (actions: AnyAction[]) => {
try {
return await session.transact({ actions })
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (error: any) {
throw new Error(error.message)
}
}
Loading

0 comments on commit 1049054

Please sign in to comment.