From 5139fd6f502fc9a46dd83e431f39f6b854bb3711 Mon Sep 17 00:00:00 2001 From: Angelo CG Date: Wed, 27 Apr 2022 11:49:50 -0600 Subject: [PATCH] feat(webapp): validate consistency bpjson --- webapp/src/language/en.json | 3 ++- webapp/src/language/es.json | 3 ++- webapp/src/routes/BPJson.js | 20 +++++++++++++++----- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/webapp/src/language/en.json b/webapp/src/language/en.json index dd60cd43..8ce99527 100644 --- a/webapp/src/language/en.json +++ b/webapp/src/language/en.json @@ -160,7 +160,8 @@ "bpJsonRoute": { "loadText": "Loading node information . . .", "notLogin": "Please log in to use this tool.", - "notRegisterNode": "You must have an account registered as an active node to use this tool." + "notRegisterNode": "You must have an account registered as an active node to use this tool.", + "bpjsonInconsistency": "The bp.json on chain and of chain does not match, review it and make the necessary changes" }, "faucetRoute": { "createAccount": "Create Faucet Account", diff --git a/webapp/src/language/es.json b/webapp/src/language/es.json index 06f77589..b60ca64e 100644 --- a/webapp/src/language/es.json +++ b/webapp/src/language/es.json @@ -165,7 +165,8 @@ "bpJsonRoute": { "loadText": "Cargando informaciĆ³n del nodo . . .", "notLogin": "Por favor, inicie sesiĆ³n para utilizar esta herramienta.", - "notRegisterNode": "Debe tener una cuenta registrada como un nodo activo para usar esta herramienta." + "notRegisterNode": "Debe tener una cuenta registrada como un nodo activo para usar esta herramienta.", + "bpjsonInconsistency": "El bp.json on chain y en of chain no coincide revisalo y realiza los cambios necesarios" }, "faucetRoute": { "createAccount": "Crear Cuenta Faucet", diff --git a/webapp/src/routes/BPJson.js b/webapp/src/routes/BPJson.js index fadff192..3d47382e 100644 --- a/webapp/src/routes/BPJson.js +++ b/webapp/src/routes/BPJson.js @@ -85,6 +85,7 @@ const BPJson = ({ ual }) => { const [producer, setProducer] = useState(null) const [loading, setLoading] = useState(true) const [error, setError] = useState(null) + const [inconsistencyMessage, setInconsistencyMessage] = useState(null) const { t } = useTranslation('bpJsonRoute') const initData = { @@ -177,11 +178,17 @@ const BPJson = ({ ual }) => { ) if (producer) { - let bpJson - bpJson = await getBpJSONOffChain(producer) - if (!bpJson) bpJson = await getBpJSONChain(producer.owner) + const bpJsonOffChain = await getBpJSONOffChain(producer) + const bpJsonChain = await getBpJSONChain(producer.owner) - setProducer({ ...producer, bpJson }) + setProducer({ ...producer, bpJson: bpJsonOffChain || bpJsonChain }) + + if ( + bpJsonOffChain && + bpJsonChain && + JSON.stringify(bpJsonOffChain) !== JSON.stringify(bpJsonChain) + ) + setInconsistencyMessage(t('bpjsonInconsistency')) } setLoading(false) @@ -194,7 +201,7 @@ const BPJson = ({ ual }) => { setLoading(false) }, 5000) } - }, [ual.activeUser]) + }, [ual.activeUser, t]) return ( @@ -209,6 +216,9 @@ const BPJson = ({ ual }) => { )} {error && {error}} + {inconsistencyMessage && ( + {inconsistencyMessage} + )}