Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(webapp): validate consistency bpjson #773

Merged
merged 1 commit into from
Apr 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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