From d58ae934429d83e2a9da801782156c33510f7cd5 Mon Sep 17 00:00:00 2001 From: shanejonas Date: Thu, 29 Aug 2019 14:12:43 -0700 Subject: [PATCH] fix(dashboard): add num pending transactions fixes #48 --- package-lock.json | 94 ++++++++++-------------------------- package.json | 2 +- src/containers/Dashboard.tsx | 14 +++++- 3 files changed, 40 insertions(+), 70 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8cabf0ec..6c025122 100644 --- a/package-lock.json +++ b/package-lock.json @@ -983,9 +983,9 @@ "integrity": "sha512-RMtr1i6E8MXaBWwhXL3yeOU8JXRnz8GNxHvaUfVvwxokvayUY0zoBeWbKw1S9XkufmGEEdQd228pSZXFkAln8Q==" }, "@etclabscore/ethereum-json-rpc": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@etclabscore/ethereum-json-rpc/-/ethereum-json-rpc-1.1.0.tgz", - "integrity": "sha512-VLHW46JB+X5ibdXAL9MHW5TgZ9SbD8ZxXAhWJdWF/48YEUJ98jhQ1vXipKZw8skeBUjN3BS7u7LniqHVN+Lm/Q==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@etclabscore/ethereum-json-rpc/-/ethereum-json-rpc-1.1.1.tgz", + "integrity": "sha512-NGqgtOxbmSiPc5XzElv9neUXrWjqE3XkHmsxi1I+wWBf5S0UHbLIw93tEequoEO+VYlJUM5RA8/uUg+T2Fg7pA==", "requires": { "@open-rpc/client-js": "^1.1.0", "@open-rpc/meta-schema": "^1.3.1", @@ -993,10 +993,6 @@ "lodash": "^4.17.15" } }, - "@etclabscore/ethereum-json-rpc-specification": { - "version": "git+https://github.com/etclabscore/ethereum-json-rpc-specification.git#2302b528846a064621143bf5ea41873f801b6587", - "from": "git+https://github.com/etclabscore/ethereum-json-rpc-specification.git#2302b528846a064621143bf5ea41873f801b6587" - }, "@etclabscore/jade-service-runner": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/@etclabscore/jade-service-runner/-/jade-service-runner-1.2.3.tgz", @@ -4519,8 +4515,7 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "aproba": { "version": "1.2.0", @@ -4541,14 +4536,12 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -4563,20 +4556,17 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "core-util-is": { "version": "1.0.2", @@ -4693,8 +4683,7 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "ini": { "version": "1.3.5", @@ -4706,7 +4695,6 @@ "version": "1.0.0", "bundled": true, "dev": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -4721,7 +4709,6 @@ "version": "3.0.4", "bundled": true, "dev": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -4729,14 +4716,12 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "minipass": { "version": "2.3.5", "bundled": true, "dev": true, - "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -4755,7 +4740,6 @@ "version": "0.5.1", "bundled": true, "dev": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -4836,8 +4820,7 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "object-assign": { "version": "4.1.1", @@ -4849,7 +4832,6 @@ "version": "1.4.0", "bundled": true, "dev": true, - "optional": true, "requires": { "wrappy": "1" } @@ -4935,8 +4917,7 @@ "safe-buffer": { "version": "5.1.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "safer-buffer": { "version": "2.1.2", @@ -4972,7 +4953,6 @@ "version": "1.0.2", "bundled": true, "dev": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -4992,7 +4972,6 @@ "version": "3.0.1", "bundled": true, "dev": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -5036,14 +5015,12 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "yallist": { "version": "3.0.3", "bundled": true, - "dev": true, - "optional": true + "dev": true } } }, @@ -10177,8 +10154,7 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "aproba": { "version": "1.2.0", @@ -10199,14 +10175,12 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -10221,20 +10195,17 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "core-util-is": { "version": "1.0.2", @@ -10351,8 +10322,7 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "ini": { "version": "1.3.5", @@ -10364,7 +10334,6 @@ "version": "1.0.0", "bundled": true, "dev": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -10379,7 +10348,6 @@ "version": "3.0.4", "bundled": true, "dev": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -10387,14 +10355,12 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "minipass": { "version": "2.3.5", "bundled": true, "dev": true, - "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -10413,7 +10379,6 @@ "version": "0.5.1", "bundled": true, "dev": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -10494,8 +10459,7 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "object-assign": { "version": "4.1.1", @@ -10507,7 +10471,6 @@ "version": "1.4.0", "bundled": true, "dev": true, - "optional": true, "requires": { "wrappy": "1" } @@ -10593,8 +10556,7 @@ "safe-buffer": { "version": "5.1.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "safer-buffer": { "version": "2.1.2", @@ -10630,7 +10592,6 @@ "version": "1.0.2", "bundled": true, "dev": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -10650,7 +10611,6 @@ "version": "3.0.1", "bundled": true, "dev": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -10694,14 +10654,12 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "yallist": { "version": "3.0.3", "bundled": true, - "dev": true, - "optional": true + "dev": true } } }, @@ -17890,7 +17848,7 @@ "string-to-stream": "^1.1.0", "typescript": "~2.8.3", "typescript-json-schema": "github:quicktype/typescript-json-schema#d16083d29c8b6702c666a981fa6b21113300c059", - "unicode-properties": "github:quicktype/unicode-properties#dist", + "unicode-properties": "github:quicktype/unicode-properties#d5fddfea1ef9d05c6479a979e225476063e13f52", "universal-analytics": "^0.4.16", "urijs": "^1.19.1", "uuid": "^3.2.1" diff --git a/package.json b/package.json index e3c34578..751dfb09 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "lint": "tslint -p tsconfig.json" }, "dependencies": { - "@etclabscore/ethereum-json-rpc": "^1.1.0", + "@etclabscore/ethereum-json-rpc": "^1.1.1", "@etclabscore/ethereum-json-rpc-specification": "https://github.com/etclabscore/ethereum-json-rpc-specification.git", "@etclabscore/jade-service-runner-client": "^1.2.3", "@material-ui/core": "^4.1.3", diff --git a/src/containers/Dashboard.tsx b/src/containers/Dashboard.tsx index c6695b95..3219b8a1 100644 --- a/src/containers/Dashboard.tsx +++ b/src/containers/Dashboard.tsx @@ -13,6 +13,7 @@ import ChartCard from "../components/ChartCard"; import BlockCardListContainer from "./BlockCardList"; import BlockListContainer from "./BlockList"; import hexToNumber from "../helpers/hexToNumber"; +import EthereumJSONRPC from "@etclabscore/ethereum-json-rpc"; const useState = React.useState; @@ -63,7 +64,7 @@ const getStyles = () => { export default (props: any) => { const styles = getStyles(); - const [erpc] = useMultiGethStore(); + const [erpc]: [EthereumJSONRPC] = useMultiGethStore(); const theme = useTheme(); const victoryTheme = getTheme(theme); const [blockNumber] = useBlockNumber(erpc); @@ -73,6 +74,12 @@ export default (props: any) => { const [gasPrice, setGasPrice] = useState(); const [syncing, setSyncing] = useState(); const [peerCount, setPeerCount] = useState(); + const [pendingTransctionsLength, setPendingTransactionsLength] = useState(0); + + React.useEffect(() => { + if (!erpc) { return; } + erpc.eth_pendingTransactions().then((p) => setPendingTransactionsLength(p.length)); + }, [erpc]); React.useEffect(() => { if (!erpc) { return; } @@ -153,6 +160,11 @@ export default (props: any) => { } +
+ + {{pendingTransctionsLength}} + +
{hexToNumber(peerCount)}