From b0cfbe3adcca44a3ba3a567c985ec7be01da9fa2 Mon Sep 17 00:00:00 2001 From: Ramil Amerzyanov Date: Wed, 23 Jun 2021 17:31:04 +0300 Subject: [PATCH] * pass additional environment variable to determine POA network (#40) * extract miner from block extra field in PoA networks --- newclient/.env.example | 2 ++ newclient/entrypoint.sh | 1 + newclient/package.json | 2 +- newclient/src/configs.ts | 13 ++++++++++++- .../modules/blocks/components/TableBlocksRow.vue | 1 + .../blocks/handlers/BlockDetails/BlockDetails.vue | 11 ++++++++--- newclient/yarn.lock | 8 ++++---- 7 files changed, 29 insertions(+), 9 deletions(-) diff --git a/newclient/.env.example b/newclient/.env.example index 448518d..45bbfe2 100644 --- a/newclient/.env.example +++ b/newclient/.env.example @@ -1,3 +1,5 @@ VUE_APP_HTTP_LINK="http://localhost:5000/graphql" VUE_APP_WS_CLIENT="ws://localhost:5000/graphql" VUE_APP_OPENSEA_API="https://nft.mewapi.io" +# true for PoA consensus algorithm +VUE_APP_IS_POA_NETWORK=false diff --git a/newclient/entrypoint.sh b/newclient/entrypoint.sh index 1e49f3a..4bc71fe 100755 --- a/newclient/entrypoint.sh +++ b/newclient/entrypoint.sh @@ -4,6 +4,7 @@ JSON_STRING='window.configs = { \ "VUE_APP_HTTP_LINK":"'"${VUE_APP_HTTP_LINK}"'", \ "VUE_APP_WS_CLIENT":"'"${VUE_APP_WS_CLIENT}"'", \ "VUE_APP_OPENSEA_API":"'"${VUE_APP_OPENSEA_API}"'", \ + "VUE_APP_IS_POA_NETWORK":'"${VUE_APP_IS_POA_NETWORK}"', \ }' sed -i "s@// CONFIGURATIONS_PLACEHOLDER@${JSON_STRING}@" /var/www/html/index.html diff --git a/newclient/package.json b/newclient/package.json index 91cf53f..e1d4f09 100644 --- a/newclient/package.json +++ b/newclient/package.json @@ -75,7 +75,7 @@ "@vue/cli-service": "^3.12.1", "@vue/eslint-config-prettier": "^6.0.0", "@vue/eslint-config-typescript": "^3.2.0", - "@vulcanize/eth-watcher-ts": "0.0.22", + "@vulcanize/eth-watcher-ts": "0.0.23", "apollo": "^2.27.4", "css-loader": "^2.1.1", "depcheck": "^1.2.0", diff --git a/newclient/src/configs.ts b/newclient/src/configs.ts index 9ffc237..0a3ffeb 100644 --- a/newclient/src/configs.ts +++ b/newclient/src/configs.ts @@ -3,15 +3,26 @@ declare global { configs:any; } } +let isPoa; +if (window.configs) { + if (typeof window.configs.VUE_APP_IS_POA_NETWORK == "boolean") { + isPoa = window.configs.VUE_APP_IS_POA_NETWORK; + } +} else { + const envValue = process.env.VUE_APP_IS_POA_NETWORK; + const value = envValue ? envValue.toLowerCase() : ""; + + isPoa = ["true", "1"].indexOf(value as string) >= 0; +} const configs = { APOLLO_HTTP: window.configs && window.configs.VUE_APP_HTTP_LINK || process.env.VUE_APP_HTTP_LINK, APOLLO_WS: window.configs && window.configs.VUE_APP_WS_CLIENT || process.env.VUE_APP_WS_CLIENT, OPENSEA: window.configs && window.configs.VUE_APP_OPENSEA_API || process.env.VUE_APP_OPENSEA_API, + IS_POA_NETWORK: isPoa, NODE_ENV: process.env.NODE_ENV, VERSION: process.env.VERSION, ROUTER_MODE: process.env.ROUTER_MODE || 'history' } -console.log(configs, window.configs); export default configs diff --git a/newclient/src/modules/blocks/components/TableBlocksRow.vue b/newclient/src/modules/blocks/components/TableBlocksRow.vue index bad5b17..0217c2d 100644 --- a/newclient/src/modules/blocks/components/TableBlocksRow.vue +++ b/newclient/src/modules/blocks/components/TableBlocksRow.vue @@ -105,6 +105,7 @@ export default class TableBlocksRow extends Mixins(NumberFormatMixin) { cid: this.block.cid, reward: this.formatNonVariableEthValue(new BN(this.block.reward)), miner: decodedDat.address, + address: decodedDat.address, // number: this.formatNumber(this.block.number), // miner: this.block.miner, // rewards: this.formatNonVariableEthValue(new BN(this.block.rewards.total)), diff --git a/newclient/src/modules/blocks/handlers/BlockDetails/BlockDetails.vue b/newclient/src/modules/blocks/handlers/BlockDetails/BlockDetails.vue index 6075ff1..6758604 100644 --- a/newclient/src/modules/blocks/handlers/BlockDetails/BlockDetails.vue +++ b/newclient/src/modules/blocks/handlers/BlockDetails/BlockDetails.vue @@ -26,7 +26,7 @@ import AppDetailsList from '@app/core/components/ui/AppDetailsList.vue' import BlockDetailsTitle from '@app/modules/blocks/components/BlockDetailsTitle.vue' import { Detail, Crumb } from '@app/core/components/props' -import { eth } from '@app/core/helper' +import configs from '@app/configs' import { Mixins, Component, Prop } from 'vue-property-decorator' import { NumberFormatMixin } from '@app/core/components/mixins/number-format.mixin' import { getBlockByNumber, getBlockByHash, getLastBlockNumber, getHeaderByNumber } from './blockDetails.graphql' @@ -38,7 +38,7 @@ import BN from 'bignumber.js' import { ErrorMessageBlock } from '@app/modules/blocks/models/ErrorMessagesForBlock' import newBlockFeed from '../../NewBlockSubscription/newBlockFeed.graphql' import { excpBlockNotMined } from '@app/apollo/exceptions/errorExceptions' -import { decodeHeaderData, decodeExtra } from '@vulcanize/eth-watcher-ts/dist/utils' +import { decodeHeaderData, decodeExtra, extractMinerFromExtra } from '@vulcanize/eth-watcher-ts/dist/utils' @Component({ components: { @@ -60,7 +60,12 @@ import { decodeHeaderData, decodeExtra } from '@vulcanize/eth-watcher-ts/dist/ut update: data => data.getBlockByHash || data.getHeaderById, result({ data }) { if (data.ethHeaderCidByBlockNumber && data.ethHeaderCidByBlockNumber.nodes.length) { - const _obj = decodeHeaderData(data.ethHeaderCidByBlockNumber.nodes[0].blockByMhKey.data) + const blockRlp = data.ethHeaderCidByBlockNumber.nodes[0].blockByMhKey.data; + const _obj = decodeHeaderData(blockRlp); + if (configs.IS_POA_NETWORK) { + const minerAddress = extractMinerFromExtra(blockRlp); + _obj.address = minerAddress; + } const transactionsCount = data.ethHeaderCidByBlockNumber.nodes[0].ethTransactionCidsByHeaderId.totalCount this.header = {...data.ethHeaderCidByBlockNumber.nodes[0], ..._obj, transactionsCount} } diff --git a/newclient/yarn.lock b/newclient/yarn.lock index 3d07558..446bedd 100644 --- a/newclient/yarn.lock +++ b/newclient/yarn.lock @@ -1347,10 +1347,10 @@ resolved "https://registry.yarnpkg.com/@vue/web-component-wrapper/-/web-component-wrapper-1.2.0.tgz#bb0e46f1585a7e289b4ee6067dcc5a6ae62f1dd1" integrity sha512-Xn/+vdm9CjuC9p3Ae+lTClNutrVhsXpzxvoTXXtoys6kVRX9FkueSUAqSWAyZntmVLlR4DosBV4pH8y5Z/HbUw== -"@vulcanize/eth-watcher-ts@0.0.22": - version "0.0.22" - resolved "https://npm.pkg.github.com/download/@vulcanize/eth-watcher-ts/0.0.22/5909e654da32f738f73717ccc47fd30cc7259a62b809112bc2272bc1f49ef502#aef480160ff20b952a8791bd71bd178f1f529d36" - integrity sha512-N1FPrRZg0eoIgk4DXTFHWzjlXGjv7a6DoGc3vTiz2mocSbUP5sxrvbcA0sdSjhllj/n2gxbCZe8GAIJTYJgGHw== +"@vulcanize/eth-watcher-ts@0.0.23": + version "0.0.23" + resolved "https://npm.pkg.github.com/download/@vulcanize/eth-watcher-ts/0.0.23/5ec6a8c6a2ee072d7a4d1779d693761ace187f7830d79aa9a63181e49e6a27d4#d9b98ab8ce6f46377e05cc66841977c1ea486635" + integrity sha512-k9VNd+J3SG7KSbWqpCHfn2RhpKmqW5AgxR9J1CIdL8QUtJdzIEnAwYMseTjPEP24ucZgYPJ9bJEvuRNn2qpAyg== dependencies: "@apollo/client" "^3.2.0" "@graphile/pg-pubsub" "^4.11.0"