Skip to content

Commit

Permalink
Merge branch 'dev' into lacchain
Browse files Browse the repository at this point in the history
  • Loading branch information
xavier506 committed Apr 23, 2021
2 parents ae351d8 + 9b81a40 commit d612a6c
Show file tree
Hide file tree
Showing 12 changed files with 402 additions and 28 deletions.
26 changes: 12 additions & 14 deletions .env.telostestnet
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,18 @@ HASURA_GRAPHQL_UNAUTHORIZED_ROLE=guest
HASURA_GRAPHQL_ACTION_BASE_URL=http://hapi:9090

# hapi
HAPI_TELOS_API_ENDPOINT=https://telos-testnet.eosio.cr
HAPI_TELOS_API_CHAIN_ID=2a02a0053e5a8cf73a56ba0fda11e4d92e0238a4a2aa74fccf46d5a910746840
HAPI_TELOS_BASE_ACCOUNT=eosmechatero
HAPI_TELOS_BASE_ACCOUNT_PASSWORD=PW...
HAPI_TELOS_MECHANICS_ACCOUNT=eosmechatero
# TODO: add value
HAPI_TELOS_MECHANICS_PASSWORD=PW...
HAPI_TELOS_WALLET_URL=http://localhost:9999
# TODO: let's discuss this
HAPI_TELOS_EXCHANGE_RATE_API=https://api.coingecko.com/api/v3/simple/price?ids=telos&vs_currencies=usd
HAPI_TELOS_BP_JSON_ON_CHAIN=false
HAPI_TELOS_BP_JSON_ON_CHAIN_CONTRACT=producerjson
HAPI_TELOS_BP_JSON_ON_CHAIN_TABLE=producerjson
HAPI_TELOS_BP_JSON_ON_CHAIN_SCOPE=producerjson
HAPI_EOS_API_ENDPOINT=https://telos-testnet.eosio.cr
HAPI_EOS_API_CHAIN_ID=2a02a0053e5a8cf73a56ba0fda11e4d92e0238a4a2aa74fccf46d5a910746840
HAPI_EOS_BASE_ACCOUNT=eosmechatero
HAPI_EOS_BASE_ACCOUNT_PASSWORD=PW...
HAPI_EOS_MECHANICS_ACCOUNT=eosmechatero
HAPI_EOS_MECHANICS_PASSWORD=PW...
HAPI_EOS_WALLET_URL=http://localhost:9999
HAPI_EOS_EXCHANGE_RATE_API=https://api.coingecko.com/api/v3/simple/price?ids=telos&vs_currencies=usd
HAPI_EOS_BP_JSON_ON_CHAIN=false
HAPI_EOS_BP_JSON_ON_CHAIN_CONTRACT=producerjson
HAPI_EOS_BP_JSON_ON_CHAIN_TABLE=producerjson
HAPI_EOS_BP_JSON_ON_CHAIN_SCOPE=producerjson
HAPI_HASURA_URL=http://hasura:8080/v1/graphql
HAPI_HASURA_ADMIN_SECRET=myadminsecretkey
HAPI_SERVER_PORT=9090
Expand Down
67 changes: 63 additions & 4 deletions hapi/src/services/producer.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ const syncBPJsonOffChain = async () => {
try {
const bpJsonUrl = await getBPJsonUrl(producer)
const data = await getBPJsonFromUrl(bpJsonUrl)

const endpoints = []
const nodes = await Promise.all(
(data?.nodes || []).map(async node => {
const api = node?.ssl_endpoint || node?.api_endpoint
Expand All @@ -269,15 +269,27 @@ const syncBPJsonOffChain = async () => {
}

const nodeInfo = await getNodeInfo(api)
endpoints.push({
type: 'p2p',
value: node.p2p_endpoint
})
endpoints.push({
type: 'api',
value: node.api_endpoint
})
endpoints.push({
type: 'ssl',
value: node.ssl_endpoint
})

return {
...node,
server_version_string: nodeInfo.server_version_string
}
})
)

const healthStatus = []

healthStatus.push({
name: 'organization_name',
valid: !!data.org?.candidate_name
Expand Down Expand Up @@ -305,7 +317,24 @@ const syncBPJsonOffChain = async () => {
health_status: healthStatus,
bp_json: {
...data,
nodes
nodes,
endpoints: {
api: endpoints
.filter(
endpoint => endpoint.type === 'api' && !!endpoint.value
)
.map(endpoint => endpoint.value),
ssl: endpoints
.filter(
endpoint => endpoint.type === 'ssl' && !!endpoint.value
)
.map(endpoint => endpoint.value),
p2p: endpoints
.filter(
endpoint => endpoint.type === 'p2p' && !!endpoint.value
)
.map(endpoint => endpoint.value)
}
}
}
)
Expand Down Expand Up @@ -402,6 +431,14 @@ const syncBPJsonForLacchain = async () => {
}
}

let endpoints = {}
for (const key of Object.keys(newNodeInfo.endpoints || {})) {
endpoints = {
...endpoints,
[key.replace(`${nodeType}_`, '')]: newNodeInfo.endpoints[key]
}
}

const healthStatus = []
healthStatus.push({
name: 'peer_keys',
Expand Down Expand Up @@ -430,6 +467,8 @@ const syncBPJsonForLacchain = async () => {

return {
...newNodeInfo,
endpoints:
Object.keys(endpoints).length > 0 ? endpoints : undefined,
node_name: node.name,
node_type: nodeType,
health_status: healthStatus
Expand Down Expand Up @@ -458,13 +497,33 @@ const syncBPJsonForLacchain = async () => {
valid: !!bpJson?.location?.country
})

const nodesEndpoints = entityNodes
.map(node =>
Object.keys(node.endpoints || {}).map(key => ({
type: key.replace(`${node.node_type}_`, ''),
value: node.endpoints[key]
}))
)
.reduce((result, current) => [...result, ...current], [])

return {
owner: entity.name,
health_status: healthStatus,
bp_json: {
org: bpJson,
nodes: entityNodes,
type: entity.type
type: entity.type,
endpoints: {
api: nodesEndpoints
.filter(endpoint => endpoint.type === 'api')
.map(endpoint => endpoint.value),
ssl: nodesEndpoints
.filter(endpoint => endpoint.type === 'ssl')
.map(endpoint => endpoint.value),
p2p: nodesEndpoints
.filter(endpoint => endpoint.type === 'p2p')
.map(endpoint => endpoint.value)
}
}
}
})
Expand Down
2 changes: 1 addition & 1 deletion hasura/config.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version: 3
version: 2
metadata_directory: metadata
2 changes: 1 addition & 1 deletion hasura/metadata/actions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ actions:
kind: ""
handler: '{{HASURA_GRAPHQL_ACTION_BASE_URL}}/block-distribution'
forward_client_headers: true
timeout: 120
timeout: 180
permissions:
- role: guest
custom_types:
Expand Down
81 changes: 81 additions & 0 deletions hasura/metadata/tables.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,96 @@
- table:
schema: public
name: cpu
select_permissions:
- role: guest
permission:
columns:
- id
- usage
- created_at
- updated_at
- account
filter: {}
- table:
schema: public
name: missed_block
select_permissions:
- role: guest
permission:
columns:
- id
- value
- created_at
- updated_at
- account
filter: {}
- table:
schema: public
name: producer
select_permissions:
- role: guest
permission:
columns:
- id
- owner
- total_votes
- producer_key
- is_active
- url
- unpaid_blocks
- last_claim_time
- location
- producer_authority
- bp_json
- server_version
- chain_id
- head_block_num
- last_irreversible_block_num
- last_irreversible_block_id
- head_block_id
- head_block_time
- head_block_producer
- virtual_block_cpu_limit
- virtual_block_net_limit
- block_cpu_limit
- block_net_limit
- server_version_string
- fork_db_head_block_num
- fork_db_head_block_id
- server_full_version_string
- ping
- total_votes_percent
- total_votes_eos
- block_rewards
- vote_rewards
- total_rewards
- created_at
- updated_at
- health_status
filter: {}
allow_aggregations: true
- table:
schema: public
name: setting
select_permissions:
- role: guest
permission:
columns:
- id
- eos_price
filter: {}
- table:
schema: public
name: stat
select_permissions:
- role: guest
permission:
columns:
- id
- transactions_in_last_hour
- transactions_in_last_day
- transactions_in_last_week
- average_daily_transactions_in_last_week
- created_at
- updated_at
filter: {}
2 changes: 1 addition & 1 deletion hasura/metadata/version.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version: 3
version: 2
2 changes: 2 additions & 0 deletions webapp/src/components/ContractActionForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ const ContractActionForm = ({ accountName, action, abi, onSubmitAction }) => {
onChange={handleFieldChange(field.name)}
/>
)
case 'eosio.newaccount.creator':
case 'eosio.setram.entity':
case 'eosio.addboot.entity':
case 'eosio.addobserver.entity':
case 'eosio.addwriter.entity':
Expand Down
12 changes: 11 additions & 1 deletion webapp/src/language/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@
"lastHour": "Last Hour",
"lastDay": "Last Day",
"lastWeek": "Last Week",
"lastYear": "Last Year"
"lastYear": "Last Year",
"itemsPerPage": "Items per page",
"api": "API",
"ssl": "SSL",
"p2p": "P2P"
},
"routes": {
"/>sidebar": "Dashboard",
Expand Down Expand Up @@ -57,6 +61,9 @@
"/block-distribution>sidebar": "Block Distribution",
"/block-distribution>title": "Block Distribution - Dashboard",
"/block-distribution>heading": "Block Distribution",
"/endpoints>sidebar": "Endpoints",
"/endpoints>title": "Endpoints - Dashboard",
"/endpoints>heading": "Endpoints",
"/about>sidebar": "About",
"/about>title": "About - Dashboard",
"/about>heading": "About",
Expand Down Expand Up @@ -213,5 +220,8 @@
"timeFrame": "Time frame",
"blocksProduced": "Blocks Produced",
"percent": "Percent"
},
"endpointsListRoute": {
"title": "Endpoints available by"
}
}
18 changes: 14 additions & 4 deletions webapp/src/language/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@
"lastHour": "Última hora",
"lastDay": "Último día",
"lastWeek": "Última semana",
"lastYear": "Ultimo año"
"lastYear": "Ultimo año",
"itemsPerPage": "Elementos por página",
"api": "API",
"ssl": "SSL",
"p2p": "P2P"
},
"routes": {
"/>sidebar": "Panel",
Expand Down Expand Up @@ -54,9 +58,12 @@
"/ricardian-contract>sidebar": "Acuerdo de productor de bloque",
"/ricardian-contract>title": "Acuerdo de productor de bloque - Dashboard",
"/ricardian-contract>heading": "",
"/block-distribution>sidebar": "Block Distribution",
"/block-distribution>title": "Block Distribution - Dashboard",
"/block-distribution>heading": "Block Distribution",
"/block-distribution>sidebar": "Distribución de bloques",
"/block-distribution>title": "Distribución de bloques - Dashboard",
"/block-distribution>heading": "Distribución de bloques",
"/endpoints>sidebar": "URL's",
"/endpoints>title": "URL's - Dashboard",
"/endpoints>heading": "URL's",
"/about>sidebar": "Acerca de",
"/about>title": "Acerca de - Panel",
"/about>heading": "Acerca de",
Expand Down Expand Up @@ -216,5 +223,8 @@
"3 Months": "3 Meses",
"6 Months": "6 Meses",
"1 Year": "1 Año"
},
"endpointsListRoute": {
"title": "Endpoints available by"
}
}
2 changes: 1 addition & 1 deletion webapp/src/routes/BlockDistribution.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ const BlockDistribution = () => {
<TableCell align="right">
{formatWithThousandSeparator(
Math.ceil(item.percent * 100),
2
1
)}
%
</TableCell>
Expand Down
Loading

0 comments on commit d612a6c

Please sign in to comment.