Skip to content

Commit

Permalink
* pass additional environment variable to determine POA network (#40)
Browse files Browse the repository at this point in the history
* extract miner from block extra field in PoA networks
  • Loading branch information
ramilexe authored Jun 23, 2021
1 parent 993e4ec commit b0cfbe3
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 9 deletions.
2 changes: 2 additions & 0 deletions newclient/.env.example
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions newclient/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion newclient/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
13 changes: 12 additions & 1 deletion newclient/src/configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions newclient/src/modules/blocks/components/TableBlocksRow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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: {
Expand All @@ -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}
}
Expand Down
8 changes: 4 additions & 4 deletions newclient/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit b0cfbe3

Please sign in to comment.