Skip to content

Commit

Permalink
Merge pull request #773 from AngeloCG97/dev
Browse files Browse the repository at this point in the history
feat(webapp): validate consistency bpjson
  • Loading branch information
xavier506 authored Apr 27, 2022
2 parents 6bf1df1 + 5139fd6 commit ae55d61
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
3 changes: 2 additions & 1 deletion webapp/src/language/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion webapp/src/language/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
20 changes: 15 additions & 5 deletions webapp/src/routes/BPJson.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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)
Expand All @@ -194,7 +201,7 @@ const BPJson = ({ ual }) => {
setLoading(false)
}, 5000)
}
}, [ual.activeUser])
}, [ual.activeUser, t])

return (
<Grid item xs={12}>
Expand All @@ -209,6 +216,9 @@ const BPJson = ({ ual }) => {
</>
)}
{error && <Alert severity="error">{error}</Alert>}
{inconsistencyMessage && (
<Alert severity="warning">{inconsistencyMessage}</Alert>
)}
<BPJsonGenerator
accountName={ual.activeUser?.accountName || initData.account_name}
bpJson={producer?.bpJson || initData}
Expand Down

0 comments on commit ae55d61

Please sign in to comment.