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

Proposal fixes #523

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
2 changes: 2 additions & 0 deletions locale/cnr/translation.toml
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ saveWalletFile = "" # Save Wallet File
proposalOverBudget = "" # Over Budget
badSaplingRoot = "" # There was an error while syncing. Resyncing from scratch (Bad sapling root)
creatingShieldTransaction = "" # Creating SHIELD transaction...
deleteProposal = "" # Delete Proposal
deleteProposalBody = "" # Are you sure you want to delete your proposal? Your collateral will be permanently lost.
immatureRewards = "" # Part of your staked balance may be locked for 100 blocks as your reward matures.

[ALERTS]
Expand Down
2 changes: 2 additions & 0 deletions locale/de/translation.toml
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ saveWalletFile = "" # Save Wallet File
proposalOverBudget = "" # Over Budget
badSaplingRoot = "" # There was an error while syncing. Resyncing from scratch (Bad sapling root)
creatingShieldTransaction = "" # Creating SHIELD transaction...
deleteProposal = "" # Delete Proposal
deleteProposalBody = "" # Are you sure you want to delete your proposal? Your collateral will be permanently lost.
immatureRewards = "" # Part of your staked balance may be locked for 100 blocks as your reward matures.

[ALERTS]
Expand Down
2 changes: 2 additions & 0 deletions locale/en/translation.toml
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ saveWalletFile = "Save Wallet File" # Save Wallet File
proposalOverBudget = "Over Budget" # Over Budget
badSaplingRoot = "There was an error while syncing. Resyncing from scratch (Bad sapling root)" # There was an error while syncing. Resyncing from scratch (Bad sapling root)
creatingShieldTransaction = "Creating SHIELD transaction..." # Creating SHIELD transaction...
deleteProposal = "Delete Proposal" # Delete Proposal
deleteProposalBody = "Are you sure you want to delete your proposal? Your collateral will be permanently lost." # Are you sure you want to delete your proposal? Your collateral will be permanently lost.
immatureRewards = "Part of your staked balance may be locked for 100 blocks as your reward matures." # Part of your staked balance may be locked for 100 blocks as your reward matures.

[ALERTS]
Expand Down
2 changes: 2 additions & 0 deletions locale/es-mx/translation.toml
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ saveWalletFile = "" # Save Wallet File
proposalOverBudget = "" # Over Budget
badSaplingRoot = "" # There was an error while syncing. Resyncing from scratch (Bad sapling root)
creatingShieldTransaction = "" # Creating SHIELD transaction...
deleteProposal = "" # Delete Proposal
deleteProposalBody = "" # Are you sure you want to delete your proposal? Your collateral will be permanently lost.
immatureRewards = "" # Part of your staked balance may be locked for 100 blocks as your reward matures.

[ALERTS]
Expand Down
2 changes: 2 additions & 0 deletions locale/fr/translation.toml
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ saveWalletFile = "" # Save Wallet File
proposalOverBudget = "" # Over Budget
badSaplingRoot = "" # There was an error while syncing. Resyncing from scratch (Bad sapling root)
creatingShieldTransaction = "" # Creating SHIELD transaction...
deleteProposal = "" # Delete Proposal
deleteProposalBody = "" # Are you sure you want to delete your proposal? Your collateral will be permanently lost.
immatureRewards = "" # Part of your staked balance may be locked for 100 blocks as your reward matures.

[ALERTS]
Expand Down
2 changes: 2 additions & 0 deletions locale/hi/translation.toml
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ shieldAddress = "शील्ड एड्रेस" # Shield address
cantShieldToExc = "यह एड्रेस शील्ड ट्रांसफर का समर्थन नहीं करता" # This address does not support shield transfers
badSaplingRoot = "सिंक करते समय एक त्रुटि हुई। रिसिंकिंग कर रहे हैं स्क्रैच से(खराब सैपलिंग रूट)" # There was an error while syncing. Resyncing from scratch (Bad sapling root)
creatingShieldTransaction = "क्रिएटिंग शील्ड ट्रांजेक्शन..." # Creating SHIELD transaction...
deleteProposal = "" # Delete Proposal
deleteProposalBody = "" # Are you sure you want to delete your proposal? Your collateral will be permanently lost.
immatureRewards = "" # Part of your staked balance may be locked for 100 blocks as your reward matures.

[ALERTS]
Expand Down
2 changes: 2 additions & 0 deletions locale/it/translation.toml
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ saveWalletFile = "" # Save Wallet File
proposalOverBudget = "" # Over Budget
badSaplingRoot = "" # There was an error while syncing. Resyncing from scratch (Bad sapling root)
creatingShieldTransaction = "" # Creating SHIELD transaction...
deleteProposal = "" # Delete Proposal
deleteProposalBody = "" # Are you sure you want to delete your proposal? Your collateral will be permanently lost.
immatureRewards = "" # Part of your staked balance may be locked for 100 blocks as your reward matures.

[ALERTS]
Expand Down
2 changes: 2 additions & 0 deletions locale/nl/translation.toml
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ saveWalletFile = "" # Save Wallet File
proposalOverBudget = "" # Over Budget
badSaplingRoot = "" # There was an error while syncing. Resyncing from scratch (Bad sapling root)
creatingShieldTransaction = "" # Creating SHIELD transaction...
deleteProposal = "" # Delete Proposal
deleteProposalBody = "" # Are you sure you want to delete your proposal? Your collateral will be permanently lost.
immatureRewards = "" # Part of your staked balance may be locked for 100 blocks as your reward matures.

[ALERTS]
Expand Down
2 changes: 2 additions & 0 deletions locale/ph/translation.toml
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ saveWalletFile = "" # Save Wallet File
proposalOverBudget = "" # Over Budget
badSaplingRoot = "" # There was an error while syncing. Resyncing from scratch (Bad sapling root)
creatingShieldTransaction = "" # Creating SHIELD transaction...
deleteProposal = "" # Delete Proposal
deleteProposalBody = "" # Are you sure you want to delete your proposal? Your collateral will be permanently lost.
immatureRewards = "" # Part of your staked balance may be locked for 100 blocks as your reward matures.

[ALERTS]
Expand Down
2 changes: 2 additions & 0 deletions locale/pl/translation.toml
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ saveWalletFile = "" # Save Wallet File
proposalOverBudget = "" # Over Budget
badSaplingRoot = "" # There was an error while syncing. Resyncing from scratch (Bad sapling root)
creatingShieldTransaction = "" # Creating SHIELD transaction...
deleteProposal = "" # Delete Proposal
deleteProposalBody = "" # Are you sure you want to delete your proposal? Your collateral will be permanently lost.
immatureRewards = "" # Part of your staked balance may be locked for 100 blocks as your reward matures.

[ALERTS]
Expand Down
2 changes: 2 additions & 0 deletions locale/pt-br/translation.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ saveWalletFile = "" # Save Wallet File
proposalOverBudget = "" # Over Budget
badSaplingRoot = "" # There was an error while syncing. Resyncing from scratch (Bad sapling root)
creatingShieldTransaction = "" # Creating SHIELD transaction...
deleteProposal = "" # Delete Proposal
deleteProposalBody = "" # Are you sure you want to delete your proposal? Your collateral will be permanently lost.
immatureRewards = "" # Part of your staked balance may be locked for 100 blocks as your reward matures.

[ALERTS]
Expand Down
2 changes: 2 additions & 0 deletions locale/pt-pt/translation.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ saveWalletFile = "" # Save Wallet File
proposalOverBudget = "" # Over Budget
badSaplingRoot = "" # There was an error while syncing. Resyncing from scratch (Bad sapling root)
creatingShieldTransaction = "" # Creating SHIELD transaction...
deleteProposal = "" # Delete Proposal
deleteProposalBody = "" # Are you sure you want to delete your proposal? Your collateral will be permanently lost.
immatureRewards = "" # Part of your staked balance may be locked for 100 blocks as your reward matures.

[ALERTS]
Expand Down
2 changes: 2 additions & 0 deletions locale/template/translation.toml
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@ shieldAddress = "Shield address"
cantShieldToExc = "This address does not support shield transfers"
badSaplingRoot = "There was an error while syncing. Resyncing from scratch (Bad sapling root)"
creatingShieldTransaction = "Creating SHIELD transaction..."
deleteProposal = "Delete Proposal"
deleteProposalBody = "Are you sure you want to delete your proposal? Your collateral will be permanently lost."
immatureRewards = "Part of your staked balance may be locked for 100 blocks as your reward matures."

[ALERTS]
Expand Down
2 changes: 2 additions & 0 deletions locale/uwu/translation.toml
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ saveWalletFile = "Save Wawwet File" # Save Wallet File
proposalOverBudget = "Over Budgey" # Over Budget
badSaplingRoot = "" # There was an error while syncing. Resyncing from scratch (Bad sapling root)
creatingShieldTransaction = "" # Creating SHIELD transaction...
deleteProposal = "" # Delete Proposal
deleteProposalBody = "" # Are you sure you want to delete your proposal? Your collateral will be permanently lost.
immatureRewards = "" # Part of your staked balance may be locked for 100 blocks as your reward matures.

[ALERTS]
Expand Down
6 changes: 3 additions & 3 deletions scripts/composables/use_masternode.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ export const useMasternode = defineStore('masternode', () => {
const localProposals = ref([]);
watch(
localProposals,
async () => {
async (localProposals) => {
const database = await Database.getInstance();
const account = await database.getAccount();
if (account) {
account.localProposals = toRaw(localProposals.value);
await database.updateAccount(account);
account.localProposals = toRaw(localProposals);
await database.updateAccount(account, true);
}
},
{
Expand Down
18 changes: 13 additions & 5 deletions scripts/governance/Governance.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ watch(
[blockCount, localProposals],
async () => {
for (const proposal of localProposals.value) {
if (!proposal.blockHeight) {
if (!proposal.blockHeight || proposal.blockHeight === -1) {
let tx;
try {
tx = await getNetwork().getTxInfo(proposal.txid);
Expand All @@ -74,8 +74,7 @@ watch(
cChainParams.current.proposalFeeConfirmRequirement
) {
// Proposal fee has the required amounts of confirms, stop watching and try to finalize
// TODO: remove propsal
finalizeProposal(proposal);
await finalizeProposal(proposal);
}
}
},
Expand Down Expand Up @@ -188,16 +187,24 @@ async function createProposal(name, url, payments, monthlyPayment, address) {
}
async function finalizeProposal(proposal) {
const { ok, err } = await Masternode.finalizeProposal(proposal);

if (ok) {
createAlert('success', translation.PROPOSAL_FINALISED);
createAlert('success', ALERTS.PROPOSAL_FINALISED);
deleteProposal(proposal);
} else {
createAlert(
'warning',
translation.PROPOSAL_FINALISE_FAIL + '<br>' + sanitizeHTML(err)
ALERTS.PROPOSAL_FINALISE_FAIL + '<br>' + sanitizeHTML(err)
);
}
}

function deleteProposal(proposal) {
localProposals.value = localProposals.value.filter(
(p) => p.txid !== proposal.txid
);
}

async function vote(proposal, voteCode) {
if (masternode.value) {
if ((await masternode.value.getStatus()) !== 'ENABLED') {
Expand Down Expand Up @@ -296,6 +303,7 @@ async function vote(proposal, voteCode) {
:price="price"
@vote="vote"
@finalizeProposal="(proposal) => finalizeProposal(proposal)"
@deleteProposal="(proposal) => deleteProposal(proposal)"
/>
</div>

Expand Down
50 changes: 47 additions & 3 deletions scripts/governance/LocalProposalStatus.vue
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
<script setup>
import { cChainParams } from '../chain_params';
import { translation } from '../i18n';
import { computed, toRefs } from 'vue';
import { computed, toRefs, ref } from 'vue';
import Modal from '../Modal.vue';

const props = defineProps({
proposal: Object,
blockCount: Number,
});

const { proposal, blockCount } = toRefs(props);
const showDeleteConfirmation = ref(false);

const status = computed(() => {
if (!proposal.value.blockHeight) {
if (!proposal.value.blockHeight || proposal.value.blockHeight === -1) {
// If we have no blockHeight, proposal fee is still confirming
return translation.proposalFinalisationConfirming;
}
Expand All @@ -33,7 +35,7 @@ const status = computed(() => {
return translation.proposalFinalisationReady;
}
});
const emit = defineEmits(['finalizeProposal']);
const emit = defineEmits(['finalizeProposal', 'deleteProposal']);
</script>
<template>
<span
Expand Down Expand Up @@ -61,4 +63,46 @@ const emit = defineEmits(['finalizeProposal']);
>
<i class="fas fa-check"></i>
</button>
<button class="pivx-button-small" @click="showDeleteConfirmation = true">
<i class="fas fa-trash"></i>
</button>

<Teleport to="body">
<Modal :show="showDeleteConfirmation">
<template #header>
<h3
class="modal-title"
style="text-align: center; width: 100%; color: #8e21ff"
>
{{ translation.deleteProposal }}
</h3>
</template>

<template #body>
{{ translation.deleteProposalBody }}
</template>
<template #footer>
<button
data-i18n="popupConfirm"
type="button"
class="pivx-button-big"
style="float: right"
@click="
emit('deleteProposal');
showDeleteConfirmation = false;
"
>
Confirm
</button>
<button
type="button"
class="pivx-button-big-cancel"
style="float: right"
@click="showDeleteConfirmation = false"
>
{{ translation.popupCancel }}
</button>
</template>
</Modal>
</Teleport>
</template>
7 changes: 5 additions & 2 deletions scripts/governance/MobileProposalRow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const props = defineProps({
strCurrency: String,
});
const { proposal, price, strCurrency } = toRefs(props);
const emit = defineEmits(['vote']);
const emit = defineEmits(['vote', 'deleteProposal']);
</script>

<template>
Expand All @@ -28,7 +28,10 @@ const emit = defineEmits(['vote']);
<hr class="governHr" />
<MobileProposalVotes :proposal="proposal" />
<hr class="governHr" />
<MobileProposalVote @vote="(...args) => emit('vote', ...args)" />
<MobileProposalVote
@vote="(...args) => emit('vote', ...args)"
@deleteProposal="emit('deleteProposal')"
/>
</td>
</tr>
</template>
8 changes: 7 additions & 1 deletion scripts/governance/ProposalRow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ const {
proposalValidator,
blockCount,
} = toRefs(props);
const emit = defineEmits(['click', 'finalizeProposal', 'vote']);
const emit = defineEmits([
'click',
'finalizeProposal',
'vote',
'deleteProposal',
]);
const showConfirmVoteModal = ref(false);
const selectedVoteCode = ref(0);
function vote(voteCode) {
Expand All @@ -51,6 +56,7 @@ function vote(voteCode) {
:proposal="proposal"
:blockCount="blockCount"
@finalizeProposal="emit('finalizeProposal')"
@deleteProposal="emit('deleteProposal')"
/>
</td>
<td style="vertical-align: middle">
Expand Down
6 changes: 4 additions & 2 deletions scripts/governance/ProposalsTable.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup>
import MobileProposalRow from './MobileProposalRow.vue';
import ProposalRow from './ProposalRow.vue';
import { toRefs, computed, ref } from 'vue';
import { toRefs, ref } from 'vue';

import { ProposalValidator } from './status';
import { COIN } from '../chain_params';
Expand All @@ -22,7 +22,7 @@ const { proposals, localProposals, masternodeCount, strCurrency, price } =
const getProposalValidator = () => new ProposalValidator(masternodeCount.value);
const wallet = useWallet();

const emit = defineEmits(['finalizeProposal', 'vote']);
const emit = defineEmits(['finalizeProposal', 'vote', 'deleteProposal']);

/**
* @param{localProposal} Local proposal to convert
Expand Down Expand Up @@ -96,6 +96,7 @@ function openOrCloseRow(i) {
:proposalValidator="getProposalValidator()"
:blockCount="wallet.blockCount"
@click="openOrCloseRow(i)"
@deleteProposal="emit('deleteProposal', proposal)"
@finalizeProposal="emit('finalizeProposal', proposal)"
/>
<MobileProposalRow
Expand All @@ -104,6 +105,7 @@ function openOrCloseRow(i) {
:price="price"
:localProposal="true"
:strCurrency="strCurrency"
@deleteProposal="emit('deleteProposal', proposal)"
@finalizeProposal="emit('finalizeProposal', proposal)"
/>
</template>
Expand Down
5 changes: 4 additions & 1 deletion scripts/masternode.js
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,10 @@ export default class Masternode {
txid,
});

if (/^"[a-f0-9]"$/ && res.length === 64 + 2) {
if (
/^"?[a-f0-9]"?$/ &&
(res.length === 64 + 2 || res.length === 64)
) {
return { ok: true, hash: res };
} else if (
res.includes('is unconfirmed') ||
Expand Down