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

Improve Governance consensus rules #198

Merged
merged 2 commits into from Sep 18, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions locale/de/translation.js
Expand Up @@ -278,6 +278,7 @@ export const de_translation = {
proposalFinalisationReady: 'Bereit zum Einreichen', //Ready to submit
proposalPassing: 'Bestehend', //PASSING
proposalFailing: 'Scheiternd', //FAILING
proposalTooYoung: '', //TOO YOUNG
proposalFunded: 'Finanziert', //FUNDED
proposalNotFunded: 'nicht Finanziert', //NOT FUNDED
proposalPaymentsRemaining: 'Ausstehende Transaktionen<br>', //installment(s) remaining<br>of
Expand Down
1 change: 1 addition & 0 deletions locale/en/translation.js
Expand Up @@ -275,6 +275,7 @@ export const en_translation = {
proposalFinalisationReady: 'Ready to submit',
proposalPassing: 'PASSING',
proposalFailing: 'FAILING',
proposalTooYoung: 'TOO YOUNG',
proposalFunded: 'FUNDED',
proposalNotFunded: 'NOT FUNDED',
proposalPaymentsRemaining: 'installment(s) remaining<br>of',
Expand Down
1 change: 1 addition & 0 deletions locale/es-mx/translation.js
Expand Up @@ -283,6 +283,7 @@ export const es_mx_translation = {
proposalFinalisationReady: 'Listo para enviarla', //Ready to submit
proposalPassing: 'PASANDO', //PASSING
proposalFailing: 'FRACASANDO', //FAILING
proposalTooYoung: '', //TOO YOUNG
proposalFunded: 'FINANCIADA', //FUNDED
proposalNotFunded: 'NO FINANCIADA', //NOT FUNDED
proposalPaymentsRemaining: 'plazo(s) restante(s)<br>de', //installment(s) remaining<br>of
Expand Down
1 change: 1 addition & 0 deletions locale/fr/translation.js
Expand Up @@ -285,6 +285,7 @@ export const fr_translation = {
proposalFinalisationReady: 'Prêt à soumettre', //Ready to submit
proposalPassing: 'PASSANT', //PASSING
proposalFailing: 'ÉCHOUANT', //FAILING
proposalTooYoung: '', //TOO YOUNG
proposalFunded: 'FINANCÉE', //FUNDED
proposalNotFunded: 'NON FINANCÉE', //NOT FUNDED
proposalPaymentsRemaining: "l'installation(s) restants<br>de", //installment(s) remaining<br>of
Expand Down
1 change: 1 addition & 0 deletions locale/it/translation.js
Expand Up @@ -265,6 +265,7 @@ export const it_translation = {
proposalFinalisationReady: "Pronto per l'invio", //Ready to submit
proposalPassing: 'Passata', //PASSING
proposalFailing: 'Fallita', //FAILING
proposalTooYoung: '', //TOO YOUNG
proposalFunded: 'Finanziata', //FUNDED
proposalNotFunded: 'Non finanziata', //NOT FUNDED
proposalPaymentsRemaining: 'rata/i rimanente<br>di', //installment(s) remaining<br>of
Expand Down
1 change: 1 addition & 0 deletions locale/ph/translation.js
Expand Up @@ -287,6 +287,7 @@ export const ph_translation = {
proposalFinalisationReady: 'Handa ng ipasa', //Ready to submit
proposalPassing: 'PASSING', //PASSING
proposalFailing: 'FAILING', //FAILING
proposalTooYoung: '', //TOO YOUNG
proposalFunded: 'FUNDED', //FUNDED
proposalNotFunded: 'NOT FUNDED', //NOT FUNDED
proposalPaymentsRemaining: 'installment(s) remaining<br>of', //installment(s) remaining<br>of
Expand Down
1 change: 1 addition & 0 deletions locale/pt-br/translation.js
Expand Up @@ -281,6 +281,7 @@ export const pt_br_translation = {
proposalFinalisationReady: 'Pronto para enviar', //Ready to submit
proposalPassing: 'PASSAGEM', //PASSING
proposalFailing: 'FALHA', //FAILING
proposalTooYoung: '', //TOO YOUNG
proposalFunded: 'FINANCIADO/A', //FUNDED
proposalNotFunded: 'NÃO FINANCIADO/A', //NOT FUNDED
proposalPaymentsRemaining: 'parcela(s) restante(s)<br>de', //installment(s) remaining<br>of
Expand Down
1 change: 1 addition & 0 deletions locale/pt-pt/translation.js
Expand Up @@ -281,6 +281,7 @@ export const pt_pt_translation = {
proposalFinalisationReady: 'Pronto para enviar', //Ready to submit
proposalPassing: 'PASSAGEM', //PASSING
proposalFailing: 'FALHA', //FAILING
proposalTooYoung: '', //TOO YOUNG
proposalFunded: 'FINANCIADO/A', //FUNDED
proposalNotFunded: 'NÃO FINANCIADO/A', //NOT FUNDED
proposalPaymentsRemaining: 'parcela(s) restante(s)<br>de', //installment(s) remaining<br>of
Expand Down
1 change: 1 addition & 0 deletions locale/template/translation.js
Expand Up @@ -269,6 +269,7 @@ export const translation_template = {
proposalFinalisationReady: '', //Ready to submit
proposalPassing: '', //PASSING
proposalFailing: '', //FAILING
proposalTooYoung: '', //TOO YOUNG
proposalFunded: '', //FUNDED
proposalNotFunded: '', //NOT FUNDED
proposalPaymentsRemaining: '', //installment(s) remaining<br>of
Expand Down
1 change: 1 addition & 0 deletions locale/uwu/translation.js
Expand Up @@ -278,6 +278,7 @@ export const uwu_translation = {
proposalFinalisationReady: 'Ready tew submit', //Ready to submit
proposalPassing: 'PASSING, YAY!', //PASSING
proposalFailing: 'FAILING, NAY!', //FAILING
proposalTooYoung: 'TOO YOUNG, BAKA!', //TOO YOUNG
proposalFunded: 'FUNDED!', //FUNDED
proposalNotFunded: 'NO MONIES', //NOT FUNDED
proposalPaymentsRemaining: 'payment(s) remainingz<br>of', //installment(s) remaining<br>of
Expand Down
2 changes: 2 additions & 0 deletions scripts/chain_params.js
Expand Up @@ -46,6 +46,7 @@ export const cChainParams = {
},
budgetCycleBlocks: 43200,
proposalFee: 50 * COIN,
proposalFeeConfirmRequirement: 6,
maxPaymentCycles: 6,
maxPayment: 10 * 43200 * COIN, // 43200 blocks of 10 PIV
},
Expand Down Expand Up @@ -74,6 +75,7 @@ export const cChainParams = {
},
budgetCycleBlocks: 144,
proposalFee: 50 * COIN,
proposalFeeConfirmRequirement: 3,
maxPaymentCycles: 20,
maxPayment: 10 * 144 * COIN, // 144 blocks of 10 tPIV
},
Expand Down
40 changes: 29 additions & 11 deletions scripts/global.js
Expand Up @@ -10,7 +10,7 @@
decryptWallet,
getNewAddress,
getDerivationPath,
LegacyMasterKey,

Check warning on line 13 in scripts/global.js

View workflow job for this annotation

GitHub Actions / ESLint

scripts/global.js#L13

'LegacyMasterKey' is defined but never used (@typescript-eslint/no-unused-vars)
} from './wallet.js';
import { getNetwork, HistoricalTxType } from './network.js';
import {
Expand Down Expand Up @@ -2083,7 +2083,11 @@
*/
function getProposalFinalisationStatus(cPropCache) {
const cNet = getNetwork();
const nConfsLeft = cPropCache.nSubmissionHeight + 6 - cNet.cachedBlockCount;
// Confirmations left until finalisation, by network consensus
const nConfsLeft =
cPropCache.nSubmissionHeight +
cChainParams.current.proposalFeeConfirmRequirement -
cNet.cachedBlockCount;

if (cPropCache.nSubmissionHeight === 0 || cNet.cachedBlockCount === 0) {
return translation.proposalFinalisationConfirming;
Expand Down Expand Up @@ -2171,6 +2175,7 @@
Nays: 0,
local: true,
Ratio: 0,
IsEstablished: false,
mpw: p,
};
}) || [];
Expand Down Expand Up @@ -2224,12 +2229,24 @@
const nNetYesPercent = (nNetYes / cMasternodes.enabled) * 100;

// Proposal Status calculation
const nRequiredVotes = Math.round(cMasternodes.enabled * 0.1);
const strStatus =
nNetYes >= nRequiredVotes
? translation.proposalPassing
: translation.proposalFailing;
let strFundingStatus = translation.proposalNotFunded;
const nRequiredVotes = cMasternodes.enabled / 10;
let strStatus = '';
let strFundingStatus = '';

// Proposal Status calculations
if (nNetYes < nRequiredVotes) {
// Scenario 1: Not enough votes
strStatus = translation.proposalFailing;
strFundingStatus = translation.proposalNotFunded;
} else if (!cProposal.IsEstablished) {
// Scenario 2: Enough votes, but not established
strStatus = translation.proposalFailing;
strFundingStatus = translation.proposalTooYoung;
} else {
// Scenario 3: Enough votes, and established
strStatus = translation.proposalPassing;
strFundingStatus = translation.proposalFunded;
}
JSKitty marked this conversation as resolved.
Show resolved Hide resolved

// Funding Status and allocation calculations
if (cProposal.local) {
Expand All @@ -2240,14 +2257,14 @@
updateGovernanceTab
);
}
const strStatus = getProposalFinalisationStatus(cPropCache);
const strLocalStatus = getProposalFinalisationStatus(cPropCache);
const finalizeButton = document.createElement('button');
finalizeButton.className = 'pivx-button-small';
finalizeButton.innerHTML = '<i class="fas fa-check"></i>';

if (
strStatus === translation.proposalFinalisationReady ||
strStatus === translation.proposalFinalisationExpired
strLocalStatus === translation.proposalFinalisationReady ||
strLocalStatus === translation.proposalFinalisationExpired
) {
finalizeButton.addEventListener('click', async () => {
const result = await Masternode.finalizeProposal(
Expand Down Expand Up @@ -2320,7 +2337,7 @@

domStatus.innerHTML = `
<span style="font-size:12px; line-height: 15px; display: block; margin-bottom:15px;">
<span style="color:#fff; font-weight:700;">${strStatus}</span><br>
<span style="color:#fff; font-weight:700;">${strLocalStatus}</span><br>
</span>
<span class="governArrow for-mobile ptr">
<i class="fa-solid fa-angle-down"></i>
Expand All @@ -2329,6 +2346,7 @@
} else {
if (domTable.id == 'proposalsTableBody') {
if (
cProposal.IsEstablished &&
nNetYes >= nRequiredVotes &&
totalAllocatedAmount + cProposal.MonthlyPayment <=
cChainParams.current.maxPayment / COIN
Expand Down