From 27ac78f98bbfa5c93d34f254d99b889a4c5551cf Mon Sep 17 00:00:00 2001 From: Manfred Karrer Date: Wed, 18 Apr 2018 22:26:55 -0500 Subject: [PATCH] Rename Proposal to Ballot and ProposalPayload to Proposal --- .../main/dao/proposal/BaseProposalView.java | 52 +++++++++---------- .../dao/proposal/ProposalDetailsWindow.java | 12 ++--- .../main/dao/proposal/ProposalDisplay.java | 28 +++++----- .../main/dao/proposal/ProposalListItem.java | 28 +++++----- .../proposal/active/ActiveProposalsView.java | 36 ++++++------- .../proposal/closed/ClosedProposalsView.java | 16 +++--- .../dashboard/ProposalDashboardView.java | 16 +++--- .../dao/proposal/make/MakeProposalView.java | 24 ++++----- .../dao/proposal/myvotes/MyVotesView.java | 22 ++++---- 9 files changed, 119 insertions(+), 115 deletions(-) diff --git a/src/main/java/bisq/desktop/main/dao/proposal/BaseProposalView.java b/src/main/java/bisq/desktop/main/dao/proposal/BaseProposalView.java index 2b908dd1de..0b48596a09 100644 --- a/src/main/java/bisq/desktop/main/dao/proposal/BaseProposalView.java +++ b/src/main/java/bisq/desktop/main/dao/proposal/BaseProposalView.java @@ -28,13 +28,13 @@ import bisq.desktop.util.BsqFormatter; import bisq.core.btc.wallet.BsqWalletService; import bisq.core.dao.consensus.period.Phase; -import bisq.core.dao.consensus.period.UserThreadPeriodService; +import bisq.core.dao.consensus.state.events.payloads.Proposal; +import bisq.core.dao.consensus.vote.proposal.Ballot; import bisq.core.dao.consensus.vote.proposal.MyProposalService; -import bisq.core.dao.consensus.vote.proposal.Proposal; import bisq.core.dao.consensus.vote.proposal.ProposalListService; -import bisq.core.dao.consensus.state.events.payloads.ProposalPayload; import bisq.core.dao.consensus.vote.proposal.ProposalService; -import bisq.core.dao.consensus.vote.proposal.param.ParamService; +import bisq.core.dao.consensus.vote.proposal.param.ChangeParamService; +import bisq.core.dao.presentation.period.PeriodServiceFacade; import bisq.core.dao.presentation.state.StateServiceFacade; import bisq.core.locale.Res; @@ -74,7 +74,7 @@ public abstract class BaseProposalView extends ActivatableView { protected final MyProposalService myProposalService; protected final StateServiceFacade stateService; - protected final ParamService paramService; + protected final ChangeParamService changeParamService; protected final ProposalListService proposalListService; protected final ProposalService proposalService; protected final BsqWalletService bsqWalletService; @@ -90,9 +90,9 @@ public abstract class BaseProposalView extends ActivatableView { protected int gridRow = 0; protected GridPane detailsGridPane, gridPane; protected ProposalListItem selectedProposalListItem; - protected ListChangeListener proposalListChangeListener; + protected ListChangeListener proposalListChangeListener; protected ChangeListener phaseChangeListener; - protected final UserThreadPeriodService periodService; + protected final PeriodServiceFacade periodService; protected Phase currentPhase; protected Subscription phaseSubscription; private ScrollPane proposalDisplayView; @@ -108,8 +108,8 @@ public abstract class BaseProposalView extends ActivatableView { ProposalService proposalService, BsqWalletService bsqWalletService, StateServiceFacade stateService, - ParamService paramService, - UserThreadPeriodService periodService, + ChangeParamService changeParamService, + PeriodServiceFacade periodService, BsqFormatter bsqFormatter, BSFormatter btcFormatter) { this.myProposalService = myProposalService; @@ -117,7 +117,7 @@ public abstract class BaseProposalView extends ActivatableView { this.proposalService = proposalService; this.bsqWalletService = bsqWalletService; this.stateService = stateService; - this.paramService = paramService; + this.changeParamService = changeParamService; this.periodService = periodService; this.bsqFormatter = bsqFormatter; this.btcFormatter = btcFormatter; @@ -211,14 +211,14 @@ public abstract class BaseProposalView extends ActivatableView { proposalDisplayView.setManaged(false); } - protected void showProposalDisplay(Proposal proposal) { + protected void showProposalDisplay(Ballot ballot) { proposalDisplayView.setVisible(true); proposalDisplayView.setManaged(true); - proposalDisplay.createAllFields(Res.get("dao.proposal.selectedProposal"), 0, 0, proposal.getType(), + proposalDisplay.createAllFields(Res.get("dao.proposal.selectedProposal"), 0, 0, ballot.getType(), false, false); proposalDisplay.setEditable(false); - proposalDisplay.applyProposalPayload(proposal.getProposalPayload()); + proposalDisplay.applyProposalPayload(ballot.getProposal()); } @@ -229,7 +229,7 @@ public abstract class BaseProposalView extends ActivatableView { protected void onSelectProposal(ProposalListItem item) { selectedProposalListItem = item; if (item != null) - showProposalDisplay(item.getProposal()); + showProposalDisplay(item.getBallot()); else hideProposalDisplay(); } @@ -248,7 +248,7 @@ public abstract class BaseProposalView extends ActivatableView { abstract protected void updateProposalList(); - protected void doUpdateProposalList(List list) { + protected void doUpdateProposalList(List list) { proposalListItems.forEach(ProposalListItem::cleanup); proposalListItems.setAll(list.stream() @@ -295,14 +295,14 @@ public abstract class BaseProposalView extends ActivatableView { public void updateItem(final ProposalListItem item, boolean empty) { super.updateItem(item, empty); if (item != null) - setText(bsqFormatter.formatDateTime(item.getProposal().getProposalPayload().getCreationDate())); + setText(bsqFormatter.formatDateTime(item.getBallot().getProposal().getCreationDate())); else setText(""); } }; } }); - dateColumn.setComparator(Comparator.comparing(o3 -> o3.getProposal().getProposalPayload().getCreationDate())); + dateColumn.setComparator(Comparator.comparing(o3 -> o3.getBallot().getProposal().getCreationDate())); dateColumn.setSortType(TableColumn.SortType.DESCENDING); tableView.getColumns().add(dateColumn); tableView.getSortOrder().add(dateColumn); @@ -320,14 +320,14 @@ public abstract class BaseProposalView extends ActivatableView { public void updateItem(final ProposalListItem item, boolean empty) { super.updateItem(item, empty); if (item != null) - setText(item.getProposal().getProposalPayload().getName()); + setText(item.getBallot().getProposal().getName()); else setText(""); } }; } }); - nameColumn.setComparator(Comparator.comparing(o2 -> o2.getProposal().getProposalPayload().getName())); + nameColumn.setComparator(Comparator.comparing(o2 -> o2.getBallot().getProposal().getName())); tableView.getColumns().add(nameColumn); TableColumn titleColumn = new AutoTooltipTableColumn<>(Res.get("dao.proposal.title")); @@ -344,14 +344,14 @@ public abstract class BaseProposalView extends ActivatableView { public void updateItem(final ProposalListItem item, boolean empty) { super.updateItem(item, empty); if (item != null) - setText(item.getProposal().getProposalPayload().getTitle()); + setText(item.getBallot().getProposal().getTitle()); else setText(""); } }; } }); - titleColumn.setComparator(Comparator.comparing(o2 -> o2.getProposal().getProposalPayload().getTitle())); + titleColumn.setComparator(Comparator.comparing(o2 -> o2.getBallot().getProposal().getTitle())); tableView.getColumns().add(titleColumn); TableColumn uidColumn = new AutoTooltipTableColumn<>(Res.get("shared.id")); @@ -370,11 +370,11 @@ public abstract class BaseProposalView extends ActivatableView { public void updateItem(final ProposalListItem item, boolean empty) { super.updateItem(item, empty); if (item != null && !empty) { - final Proposal proposal = item.getProposal(); - final ProposalPayload proposalPayload = proposal.getProposalPayload(); - field = new HyperlinkWithIcon(proposalPayload.getShortId()); + final Ballot ballot = item.getBallot(); + final Proposal proposal = ballot.getProposal(); + field = new HyperlinkWithIcon(proposal.getShortId()); field.setOnAction(event -> { - new ProposalDetailsWindow(bsqFormatter, bsqWalletService, proposalPayload).show(); + new ProposalDetailsWindow(bsqFormatter, bsqWalletService, proposal).show(); }); field.setTooltip(new Tooltip(Res.get("tooltip.openPopupForDetails"))); setGraphic(field); @@ -387,7 +387,7 @@ public abstract class BaseProposalView extends ActivatableView { }; } }); - uidColumn.setComparator(Comparator.comparing(o -> o.getProposal().getUid())); + uidColumn.setComparator(Comparator.comparing(o -> o.getBallot().getUid())); tableView.getColumns().add(uidColumn); } diff --git a/src/main/java/bisq/desktop/main/dao/proposal/ProposalDetailsWindow.java b/src/main/java/bisq/desktop/main/dao/proposal/ProposalDetailsWindow.java index a7af781125..59ff540082 100644 --- a/src/main/java/bisq/desktop/main/dao/proposal/ProposalDetailsWindow.java +++ b/src/main/java/bisq/desktop/main/dao/proposal/ProposalDetailsWindow.java @@ -22,7 +22,7 @@ import bisq.desktop.util.BsqFormatter; import bisq.desktop.util.Layout; import bisq.core.btc.wallet.BsqWalletService; -import bisq.core.dao.consensus.state.events.payloads.ProposalPayload; +import bisq.core.dao.consensus.state.events.payloads.Proposal; import bisq.core.locale.Res; import javafx.geometry.Insets; @@ -36,7 +36,7 @@ public class ProposalDetailsWindow extends Overlay { protected static final Logger log = LoggerFactory.getLogger(ProposalDetailsWindow.class); private final BsqFormatter bsqFormatter; private final BsqWalletService bsqWalletService; - private ProposalPayload proposalPayload; + private Proposal proposal; private ProposalDisplay proposalDisplay; @@ -44,10 +44,10 @@ public class ProposalDetailsWindow extends Overlay { // Public API /////////////////////////////////////////////////////////////////////////////////////////// - public ProposalDetailsWindow(BsqFormatter bsqFormatter, BsqWalletService bsqWalletService, ProposalPayload proposalPayload) { + public ProposalDetailsWindow(BsqFormatter bsqFormatter, BsqWalletService bsqWalletService, Proposal proposal) { this.bsqFormatter = bsqFormatter; this.bsqWalletService = bsqWalletService; - this.proposalPayload = proposalPayload; + this.proposal = proposal; type = Type.Confirmation; width = 950; @@ -58,10 +58,10 @@ public class ProposalDetailsWindow extends Overlay { proposalDisplay = new ProposalDisplay(gridPane, bsqFormatter, bsqWalletService, null); proposalDisplay.createAllFields(Res.get("dao.proposal.details"), 1, Layout.GROUP_DISTANCE, - proposalPayload.getType(), false, true); + proposal.getType(), false, true); proposalDisplay.setEditable(false); - proposalDisplay.applyProposalPayload(proposalPayload); + proposalDisplay.applyProposalPayload(proposal); closeButton = addButtonAfterGroup(gridPane, proposalDisplay.incrementAndGetGridRow(), Res.get("shared.close")); closeButton.setOnAction(e -> doClose()); diff --git a/src/main/java/bisq/desktop/main/dao/proposal/ProposalDisplay.java b/src/main/java/bisq/desktop/main/dao/proposal/ProposalDisplay.java index db3a4ed816..07c1b13300 100644 --- a/src/main/java/bisq/desktop/main/dao/proposal/ProposalDisplay.java +++ b/src/main/java/bisq/desktop/main/dao/proposal/ProposalDisplay.java @@ -28,11 +28,11 @@ import bisq.desktop.util.validation.BsqAddressValidator; import bisq.desktop.util.validation.BsqValidator; import bisq.core.btc.wallet.BsqWalletService; +import bisq.core.dao.consensus.state.events.payloads.CompensationRequestProposal; +import bisq.core.dao.consensus.state.events.payloads.Proposal; import bisq.core.dao.consensus.vote.proposal.ProposalConsensus; -import bisq.core.dao.consensus.state.events.payloads.ProposalPayload; import bisq.core.dao.consensus.vote.proposal.ProposalType; import bisq.core.dao.consensus.vote.proposal.compensation.CompensationRequestConsensus; -import bisq.core.dao.consensus.state.events.payloads.CompensationRequestPayload; import bisq.core.locale.Res; import bisq.core.provider.fee.FeeService; @@ -153,26 +153,26 @@ public class ProposalDisplay { Res.get("dao.proposal.display.txId"), "").second; } - public void applyProposalPayload(ProposalPayload proposalPayload) { + public void applyProposalPayload(Proposal proposal) { if (uidTextField != null) - uidTextField.setText(proposalPayload.getUid()); - nameTextField.setText(proposalPayload.getName()); - titleTextField.setText(proposalPayload.getTitle()); - descriptionTextArea.setText(proposalPayload.getDescription()); + uidTextField.setText(proposal.getUid()); + nameTextField.setText(proposal.getName()); + titleTextField.setText(proposal.getTitle()); + descriptionTextArea.setText(proposal.getDescription()); linkInputTextField.setVisible(false); linkInputTextField.setManaged(false); linkHyperlinkWithIcon.setVisible(true); linkHyperlinkWithIcon.setManaged(true); - linkHyperlinkWithIcon.setText(proposalPayload.getLink()); - linkHyperlinkWithIcon.setOnAction(e -> GUIUtil.openWebPage(proposalPayload.getLink())); - if (proposalPayload instanceof CompensationRequestPayload) { - CompensationRequestPayload compensationRequestPayload = (CompensationRequestPayload) proposalPayload; - Objects.requireNonNull(requestedBsqTextField).setText(bsqFormatter.formatCoinWithCode(compensationRequestPayload.getRequestedBsq())); + linkHyperlinkWithIcon.setText(proposal.getLink()); + linkHyperlinkWithIcon.setOnAction(e -> GUIUtil.openWebPage(proposal.getLink())); + if (proposal instanceof CompensationRequestProposal) { + CompensationRequestProposal compensationRequestProposal = (CompensationRequestProposal) proposal; + Objects.requireNonNull(requestedBsqTextField).setText(bsqFormatter.formatCoinWithCode(compensationRequestProposal.getRequestedBsq())); if (bsqAddressTextField != null) - bsqAddressTextField.setText(compensationRequestPayload.getBsqAddress()); + bsqAddressTextField.setText(compensationRequestProposal.getBsqAddress()); } if (txIdTextField != null) - txIdTextField.setup(proposalPayload.getTxId()); + txIdTextField.setup(proposal.getTxId()); } public void clearForm() { diff --git a/src/main/java/bisq/desktop/main/dao/proposal/ProposalListItem.java b/src/main/java/bisq/desktop/main/dao/proposal/ProposalListItem.java index ce79fa1b02..bd734156b2 100644 --- a/src/main/java/bisq/desktop/main/dao/proposal/ProposalListItem.java +++ b/src/main/java/bisq/desktop/main/dao/proposal/ProposalListItem.java @@ -24,14 +24,14 @@ import bisq.desktop.util.BsqFormatter; import bisq.core.btc.listeners.TxConfidenceListener; import bisq.core.btc.wallet.BsqWalletService; import bisq.core.dao.consensus.period.Phase; -import bisq.core.dao.consensus.period.UserThreadPeriodService; import bisq.core.dao.consensus.state.Block; import bisq.core.dao.consensus.state.BlockListener; import bisq.core.dao.consensus.state.blockchain.Tx; import bisq.core.dao.consensus.vote.BooleanVote; import bisq.core.dao.consensus.vote.Vote; -import bisq.core.dao.consensus.vote.proposal.Proposal; +import bisq.core.dao.consensus.vote.proposal.Ballot; import bisq.core.dao.consensus.vote.proposal.ProposalService; +import bisq.core.dao.presentation.period.PeriodServiceFacade; import bisq.core.dao.presentation.state.StateServiceFacade; import bisq.core.locale.Res; @@ -57,9 +57,9 @@ import lombok.extern.slf4j.Slf4j; @EqualsAndHashCode public class ProposalListItem implements BlockListener { @Getter - private final Proposal proposal; + private final Ballot ballot; private final ProposalService proposalService; - private final UserThreadPeriodService periodService; + private final PeriodServiceFacade periodService; private final BsqWalletService bsqWalletService; private final StateServiceFacade stateService; private final BsqFormatter bsqFormatter; @@ -80,13 +80,13 @@ public class ProposalListItem implements BlockListener { private Runnable onRemoveHandler; private Node actionNode; - ProposalListItem(Proposal proposal, + ProposalListItem(Ballot ballot, ProposalService proposalService, - UserThreadPeriodService periodService, + PeriodServiceFacade periodService, BsqWalletService bsqWalletService, StateServiceFacade stateService, BsqFormatter bsqFormatter) { - this.proposal = proposal; + this.ballot = ballot; this.proposalService = proposalService; this.periodService = periodService; this.bsqWalletService = bsqWalletService; @@ -112,7 +112,7 @@ public class ProposalListItem implements BlockListener { stateService.addBlockListener(this); phaseChangeListener = (observable, oldValue, newValue) -> { - applyState(newValue, proposal.getVote()); + applyState(newValue, ballot.getVote()); }; voteResultChangeListener = (observable, oldValue, newValue) -> { @@ -120,20 +120,20 @@ public class ProposalListItem implements BlockListener { }; periodService.phaseProperty().addListener(phaseChangeListener); - proposal.getVoteResultProperty().addListener(voteResultChangeListener); + ballot.getVoteResultProperty().addListener(voteResultChangeListener); } public void applyState(Phase newValue, Vote vote) { actionButton.setText(""); actionButton.setVisible(false); actionButton.setOnAction(null); - final boolean isTxInPastCycle = periodService.isTxInPastCycle(proposal.getTxId(), + final boolean isTxInPastCycle = periodService.isTxInPastCycle(ballot.getTxId(), stateService.getChainHeight()); switch (newValue) { case UNDEFINED: break; case PROPOSAL: - if (proposalService.isMine(proposal.getProposalPayload())) { + if (proposalService.isMine(ballot.getProposal())) { actionButton.setVisible(!isTxInPastCycle); actionButtonIconView.setVisible(actionButton.isVisible()); actionButton.setText(Res.get("shared.remove")); @@ -152,7 +152,7 @@ public class ProposalListItem implements BlockListener { if (!isTxInPastCycle) { actionNode = actionButtonIconView; actionButton.setVisible(false); - if (proposal.getVote() != null) { + if (ballot.getVote() != null) { actionButtonIconView.setVisible(true); if (vote instanceof BooleanVote) { if (((BooleanVote) vote).isAccepted()) { @@ -199,7 +199,7 @@ public class ProposalListItem implements BlockListener { private void setupConfidence() { - final Tx tx = stateService.getTxMap().get(proposal.getProposalPayload().getTxId()); + final Tx tx = stateService.getTxMap().get(ballot.getProposal().getTxId()); if (tx != null) { final String txId = tx.getId(); @@ -249,7 +249,7 @@ public class ProposalListItem implements BlockListener { bsqWalletService.removeTxConfidenceListener(txConfidenceListener); periodService.phaseProperty().removeListener(phaseChangeListener); - proposal.getVoteResultProperty().removeListener(voteResultChangeListener); + ballot.getVoteResultProperty().removeListener(voteResultChangeListener); } private void updateConfidence(TransactionConfidence.ConfidenceType confidenceType, int depthInBlocks, int numBroadcastPeers) { diff --git a/src/main/java/bisq/desktop/main/dao/proposal/active/ActiveProposalsView.java b/src/main/java/bisq/desktop/main/dao/proposal/active/ActiveProposalsView.java index 18a92d1f79..784ad06dfa 100644 --- a/src/main/java/bisq/desktop/main/dao/proposal/active/ActiveProposalsView.java +++ b/src/main/java/bisq/desktop/main/dao/proposal/active/ActiveProposalsView.java @@ -34,15 +34,15 @@ import bisq.core.btc.exceptions.WalletException; import bisq.core.btc.wallet.BsqBalanceListener; import bisq.core.btc.wallet.BsqWalletService; import bisq.core.dao.consensus.period.Phase; -import bisq.core.dao.consensus.period.UserThreadPeriodService; import bisq.core.dao.consensus.vote.BooleanVote; import bisq.core.dao.consensus.vote.blindvote.BlindVoteConsensus; import bisq.core.dao.consensus.vote.myvote.MyVoteService; +import bisq.core.dao.consensus.vote.proposal.Ballot; import bisq.core.dao.consensus.vote.proposal.MyProposalService; -import bisq.core.dao.consensus.vote.proposal.Proposal; import bisq.core.dao.consensus.vote.proposal.ProposalListService; import bisq.core.dao.consensus.vote.proposal.ProposalService; -import bisq.core.dao.consensus.vote.proposal.param.ParamService; +import bisq.core.dao.consensus.vote.proposal.param.ChangeParamService; +import bisq.core.dao.presentation.period.PeriodServiceFacade; import bisq.core.dao.presentation.state.StateServiceFacade; import bisq.core.locale.Res; @@ -92,16 +92,16 @@ public class ActiveProposalsView extends BaseProposalView implements BsqBalanceL private ActiveProposalsView(MyProposalService myProposalService, ProposalListService proposalListService, ProposalService proposalService, - UserThreadPeriodService periodService, + PeriodServiceFacade periodService, MyVoteService myVoteService, BsqWalletService bsqWalletService, StateServiceFacade stateService, - ParamService paramService, + ChangeParamService changeParamService, BsqFormatter bsqFormatter, BSFormatter btcFormatter) { super(myProposalService, proposalListService, proposalService, bsqWalletService, stateService, - paramService, periodService, bsqFormatter, btcFormatter); + changeParamService, periodService, bsqFormatter, btcFormatter); this.myVoteService = myVoteService; } @@ -119,7 +119,7 @@ public class ActiveProposalsView extends BaseProposalView implements BsqBalanceL protected void activate() { super.activate(); - proposalListService.getActiveOrMyUnconfirmedProposals().addListener(proposalListChangeListener); + proposalListService.getActiveOrMyUnconfirmedBallots().addListener(proposalListChangeListener); bsqWalletService.addBsqBalanceListener(this); onUpdateBalances(bsqWalletService.getAvailableBalance(), @@ -131,7 +131,7 @@ public class ActiveProposalsView extends BaseProposalView implements BsqBalanceL voteButton.setOnAction(e -> { // TODO verify stake Coin stake = bsqFormatter.parseToCoin(stakeInputTextField.getText()); - final Coin fee = BlindVoteConsensus.getFee(paramService, stateService.getChainHeight()); + final Coin fee = BlindVoteConsensus.getFee(changeParamService, stateService.getChainHeight()); Transaction dummyTx = null; try { // We create a tx with dummy opreturn data to get the mining fee for confirmation popup @@ -170,7 +170,7 @@ public class ActiveProposalsView extends BaseProposalView implements BsqBalanceL protected void deactivate() { super.deactivate(); - proposalListService.getActiveOrMyUnconfirmedProposals().removeListener(proposalListChangeListener); + proposalListService.getActiveOrMyUnconfirmedBallots().removeListener(proposalListChangeListener); bsqWalletService.removeBsqBalanceListener(this); } @@ -243,17 +243,17 @@ public class ActiveProposalsView extends BaseProposalView implements BsqBalanceL } private void onAccept() { - selectedProposalListItem.getProposal().setVote(new BooleanVote(true)); + selectedProposalListItem.getBallot().setVote(new BooleanVote(true)); updateStateAfterVote(); } private void onReject() { - selectedProposalListItem.getProposal().setVote(new BooleanVote(false)); + selectedProposalListItem.getBallot().setVote(new BooleanVote(false)); updateStateAfterVote(); } private void onCancelVote() { - selectedProposalListItem.getProposal().setVote(null); + selectedProposalListItem.getBallot().setVote(null); updateStateAfterVote(); } @@ -270,12 +270,12 @@ public class ActiveProposalsView extends BaseProposalView implements BsqBalanceL } if (selectedProposalListItem != null && proposalDisplay != null && - !periodService.isTxInPastCycle(selectedProposalListItem.getProposal().getTxId(), + !periodService.isTxInPastCycle(selectedProposalListItem.getBallot().getTxId(), stateService.getChainHeight())) { - final Proposal proposal = selectedProposalListItem.getProposal(); + final Ballot ballot = selectedProposalListItem.getBallot(); switch (phase) { case PROPOSAL: - if (proposalService.isMine(proposal.getProposalPayload())) { + if (proposalService.isMine(ballot.getProposal())) { if (removeButton == null) { removeButton = addButtonAfterGroup(detailsGridPane, proposalDisplay.incrementAndGetGridRow(), Res.get("dao.proposal.active.remove")); removeButton.setOnAction(event -> onRemove()); @@ -334,7 +334,7 @@ public class ActiveProposalsView extends BaseProposalView implements BsqBalanceL @Override protected void updateProposalList() { - doUpdateProposalList(proposalListService.getActiveOrMyUnconfirmedProposals()); + doUpdateProposalList(proposalListService.getActiveOrMyUnconfirmedBallots()); } private void updateStateAfterVote() { @@ -351,7 +351,7 @@ public class ActiveProposalsView extends BaseProposalView implements BsqBalanceL } private void onRemove() { - if (myProposalService.removeProposal(selectedProposalListItem.getProposal())) + if (myProposalService.removeProposal(selectedProposalListItem.getBallot())) hideProposalDisplay(); else new Popup<>().warning(Res.get("dao.proposal.active.remove.failed")).show(); @@ -396,7 +396,7 @@ public class ActiveProposalsView extends BaseProposalView implements BsqBalanceL ActiveProposalsView.this.selectedProposalListItem = item; ActiveProposalsView.this.onRemove(); }); - item.applyState(currentPhase, item.getProposal().getVoteResultProperty().get()); + item.applyState(currentPhase, item.getBallot().getVoteResultProperty().get()); } } else { setGraphic(null); diff --git a/src/main/java/bisq/desktop/main/dao/proposal/closed/ClosedProposalsView.java b/src/main/java/bisq/desktop/main/dao/proposal/closed/ClosedProposalsView.java index 96a616c058..120a3a5d60 100644 --- a/src/main/java/bisq/desktop/main/dao/proposal/closed/ClosedProposalsView.java +++ b/src/main/java/bisq/desktop/main/dao/proposal/closed/ClosedProposalsView.java @@ -23,11 +23,11 @@ import bisq.desktop.util.BSFormatter; import bisq.desktop.util.BsqFormatter; import bisq.core.btc.wallet.BsqWalletService; -import bisq.core.dao.consensus.period.UserThreadPeriodService; import bisq.core.dao.consensus.vote.proposal.MyProposalService; import bisq.core.dao.consensus.vote.proposal.ProposalListService; import bisq.core.dao.consensus.vote.proposal.ProposalService; -import bisq.core.dao.consensus.vote.proposal.param.ParamService; +import bisq.core.dao.consensus.vote.proposal.param.ChangeParamService; +import bisq.core.dao.presentation.period.PeriodServiceFacade; import bisq.core.dao.presentation.state.StateServiceFacade; import javax.inject.Inject; @@ -43,15 +43,15 @@ public class ClosedProposalsView extends BaseProposalView { private ClosedProposalsView(MyProposalService myProposalService, ProposalListService proposalListService, ProposalService proposalService, - UserThreadPeriodService periodService, + PeriodServiceFacade periodService, BsqWalletService bsqWalletService, StateServiceFacade stateService, - ParamService paramService, + ChangeParamService changeParamService, BsqFormatter bsqFormatter, BSFormatter btcFormatter) { super(myProposalService, proposalListService, proposalService, bsqWalletService, stateService, - paramService, periodService, bsqFormatter, btcFormatter); + changeParamService, periodService, bsqFormatter, btcFormatter); } @Override @@ -65,18 +65,18 @@ public class ClosedProposalsView extends BaseProposalView { @Override protected void activate() { super.activate(); - proposalListService.getClosedProposals().addListener(proposalListChangeListener); + proposalListService.getClosedBallots().addListener(proposalListChangeListener); } @Override protected void deactivate() { super.deactivate(); - proposalListService.getClosedProposals().removeListener(proposalListChangeListener); + proposalListService.getClosedBallots().removeListener(proposalListChangeListener); } @Override protected void updateProposalList() { - doUpdateProposalList(proposalListService.getClosedProposals()); + doUpdateProposalList(proposalListService.getClosedBallots()); } } diff --git a/src/main/java/bisq/desktop/main/dao/proposal/dashboard/ProposalDashboardView.java b/src/main/java/bisq/desktop/main/dao/proposal/dashboard/ProposalDashboardView.java index 8c0f5ac68a..3b2625eaab 100644 --- a/src/main/java/bisq/desktop/main/dao/proposal/dashboard/ProposalDashboardView.java +++ b/src/main/java/bisq/desktop/main/dao/proposal/dashboard/ProposalDashboardView.java @@ -23,12 +23,14 @@ import bisq.desktop.components.SeparatedPhaseBars; import bisq.desktop.util.Layout; import bisq.core.dao.consensus.period.Phase; -import bisq.core.dao.consensus.period.UserThreadPeriodService; import bisq.core.dao.consensus.state.Block; import bisq.core.dao.consensus.state.BlockListener; +import bisq.core.dao.presentation.period.PeriodServiceFacade; import bisq.core.dao.presentation.state.StateServiceFacade; import bisq.core.locale.Res; +import bisq.common.UserThread; + import javax.inject.Inject; import javafx.scene.layout.AnchorPane; @@ -48,7 +50,7 @@ import static bisq.desktop.util.FormBuilder.addTitledGroupBg; public class ProposalDashboardView extends ActivatableView implements BlockListener { private List phaseBarsItems; - private final UserThreadPeriodService periodService; + private final PeriodServiceFacade periodService; private final StateServiceFacade stateService; private Phase currentPhase; private Subscription phaseSubscription; @@ -62,7 +64,7 @@ public class ProposalDashboardView extends ActivatableView imple /////////////////////////////////////////////////////////////////////////////////////////// @Inject - private ProposalDashboardView(UserThreadPeriodService periodService, StateServiceFacade stateService) { + private ProposalDashboardView(PeriodServiceFacade periodService, StateServiceFacade stateService) { this.periodService = periodService; this.stateService = stateService; } @@ -123,14 +125,16 @@ public class ProposalDashboardView extends ActivatableView imple }); }); - stateService.addBlockListener(this); - onChainHeightChanged(periodService.getChainHeight()); + periodService.addBlockListener(this); + + // We need to delay as otherwise the periodService has not been updated yet. + UserThread.execute(() -> onChainHeightChanged(periodService.getChainHeight())); } @Override protected void deactivate() { super.deactivate(); - stateService.removeBlockListener(this); + periodService.removeBlockListener(this); phaseSubscription.unsubscribe(); } diff --git a/src/main/java/bisq/desktop/main/dao/proposal/make/MakeProposalView.java b/src/main/java/bisq/desktop/main/dao/proposal/make/MakeProposalView.java index 750c103a81..b39268ac42 100644 --- a/src/main/java/bisq/desktop/main/dao/proposal/make/MakeProposalView.java +++ b/src/main/java/bisq/desktop/main/dao/proposal/make/MakeProposalView.java @@ -31,14 +31,14 @@ import bisq.core.btc.exceptions.WalletException; import bisq.core.btc.wallet.BsqWalletService; import bisq.core.btc.wallet.InsufficientBsqException; import bisq.core.btc.wallet.WalletsSetup; +import bisq.core.dao.consensus.vote.proposal.Ballot; import bisq.core.dao.consensus.vote.proposal.MyProposalService; -import bisq.core.dao.consensus.vote.proposal.Proposal; import bisq.core.dao.consensus.vote.proposal.ProposalConsensus; import bisq.core.dao.consensus.vote.proposal.ProposalType; import bisq.core.dao.consensus.vote.proposal.ValidationException; import bisq.core.dao.consensus.vote.proposal.compensation.CompensationRequestService; import bisq.core.dao.consensus.vote.proposal.generic.GenericProposalService; -import bisq.core.dao.consensus.vote.proposal.param.ParamService; +import bisq.core.dao.consensus.vote.proposal.param.ChangeParamService; import bisq.core.dao.presentation.state.StateServiceFacade; import bisq.core.locale.Res; import bisq.core.provider.fee.FeeService; @@ -87,7 +87,7 @@ public class MakeProposalView extends ActivatableView { private final CompensationRequestService compensationRequestService; private final GenericProposalService genericProposalService; private final StateServiceFacade stateService; - private final ParamService paramService; + private final ChangeParamService changeParamService; private final BSFormatter btcFormatter; private final BsqFormatter bsqFormatter; private ComboBox proposalTypeComboBox; @@ -108,7 +108,7 @@ public class MakeProposalView extends ActivatableView { CompensationRequestService compensationRequestService, GenericProposalService genericProposalService, StateServiceFacade stateService, - ParamService paramService, + ChangeParamService changeParamService, BSFormatter btcFormatter, BsqFormatter bsqFormatter) { this.bsqWalletService = bsqWalletService; @@ -119,7 +119,7 @@ public class MakeProposalView extends ActivatableView { this.compensationRequestService = compensationRequestService; this.genericProposalService = genericProposalService; this.stateService = stateService; - this.paramService = paramService; + this.changeParamService = changeParamService; this.btcFormatter = btcFormatter; this.bsqFormatter = bsqFormatter; } @@ -167,15 +167,15 @@ public class MakeProposalView extends ActivatableView { private void publishProposal(ProposalType type) { try { - final Tuple2 tuple2 = createProposal(type); - Proposal proposal = tuple2.first; + final Tuple2 tuple2 = createProposal(type); + Ballot ballot = tuple2.first; Transaction transaction = tuple2.second; Coin miningFee = transaction.getFee(); int txSize = transaction.bitcoinSerialize().length; - final Coin fee = ProposalConsensus.getFee(paramService, stateService.getChainHeight()); + final Coin fee = ProposalConsensus.getFee(changeParamService, stateService.getChainHeight()); GUIUtil.showBsqFeeInfoPopup(fee, miningFee, txSize, bsqFormatter, btcFormatter, - Res.get("dao.proposal"), () -> publishProposal(proposal, transaction)); + Res.get("dao.proposal"), () -> publishProposal(ballot, transaction)); } catch (InsufficientMoneyException e) { BSFormatter formatter = e instanceof InsufficientBsqException ? bsqFormatter : btcFormatter; @@ -197,8 +197,8 @@ public class MakeProposalView extends ActivatableView { } } - private void publishProposal(Proposal proposal, Transaction transaction) { - myProposalService.publishProposal(proposal, + private void publishProposal(Ballot ballot, Transaction transaction) { + myProposalService.publishProposal(ballot, transaction, () -> { proposalDisplay.clearForm(); @@ -208,7 +208,7 @@ public class MakeProposalView extends ActivatableView { errorMessage -> new Popup<>().warning(errorMessage).show()); } - private Tuple2 createProposal(ProposalType type) + private Tuple2 createProposal(ProposalType type) throws InsufficientMoneyException, TransactionVerificationException, ValidationException, WalletException, IOException { diff --git a/src/main/java/bisq/desktop/main/dao/proposal/myvotes/MyVotesView.java b/src/main/java/bisq/desktop/main/dao/proposal/myvotes/MyVotesView.java index 148930ba93..a8e76a9497 100644 --- a/src/main/java/bisq/desktop/main/dao/proposal/myvotes/MyVotesView.java +++ b/src/main/java/bisq/desktop/main/dao/proposal/myvotes/MyVotesView.java @@ -30,15 +30,15 @@ import bisq.desktop.util.GUIUtil; import bisq.desktop.util.Layout; import bisq.core.btc.wallet.BsqWalletService; -import bisq.core.dao.consensus.period.UserThreadPeriodService; import bisq.core.dao.consensus.vote.BooleanVote; import bisq.core.dao.consensus.vote.Vote; import bisq.core.dao.consensus.vote.myvote.MyVoteService; +import bisq.core.dao.consensus.vote.proposal.BallotList; import bisq.core.dao.consensus.vote.proposal.MyProposalService; -import bisq.core.dao.consensus.vote.proposal.ProposalList; import bisq.core.dao.consensus.vote.proposal.ProposalListService; import bisq.core.dao.consensus.vote.proposal.ProposalService; -import bisq.core.dao.consensus.vote.proposal.param.ParamService; +import bisq.core.dao.consensus.vote.proposal.param.ChangeParamService; +import bisq.core.dao.presentation.period.PeriodServiceFacade; import bisq.core.dao.presentation.state.StateServiceFacade; import bisq.core.locale.Res; import bisq.core.user.Preferences; @@ -93,17 +93,17 @@ public class MyVotesView extends BaseProposalView { private MyVotesView(MyProposalService myProposalService, ProposalListService proposalListService, ProposalService proposalService, - UserThreadPeriodService periodService, + PeriodServiceFacade periodService, BsqWalletService bsqWalletService, StateServiceFacade stateService, - ParamService paramService, + ChangeParamService changeParamService, BsqFormatter bsqFormatter, BSFormatter btcFormatter, MyVoteService myVoteService, Preferences preferences) { super(myProposalService, proposalListService, proposalService, bsqWalletService, stateService, - paramService, periodService, bsqFormatter, btcFormatter); + changeParamService, periodService, bsqFormatter, btcFormatter); this.myVoteService = myVoteService; this.preferences = preferences; } @@ -182,7 +182,7 @@ public class MyVotesView extends BaseProposalView { // Handler /////////////////////////////////////////////////////////////////////////////////////////// - private void onShowProposalList(ProposalList proposalList) { + private void onShowProposalList(BallotList ballotList) { } @@ -194,7 +194,7 @@ public class MyVotesView extends BaseProposalView { @Override protected void updateProposalList() { if (selectedVoteListItem != null) - doUpdateProposalList(selectedVoteListItem.getMyVote().getProposalList().getList()); + doUpdateProposalList(selectedVoteListItem.getMyVote().getBallotList().getList()); } @@ -249,9 +249,9 @@ public class MyVotesView extends BaseProposalView { super.updateItem(item, empty); if (item != null && !empty) { - ProposalList proposalList = item.getMyVote().getProposalList(); + BallotList ballotList = item.getMyVote().getBallotList(); HyperlinkWithIcon field = new HyperlinkWithIcon(Res.get("dao.proposal.myVotes.showProposalList"), AwesomeIcon.INFO_SIGN); - field.setOnAction(event -> onShowProposalList(proposalList)); + field.setOnAction(event -> onShowProposalList(ballotList)); field.setTooltip(new Tooltip(Res.get("dao.proposal.myVotes.tooltip.showProposalList"))); setGraphic(field); } else { @@ -378,7 +378,7 @@ public class MyVotesView extends BaseProposalView { if (item != null && !empty) { actionButtonIconView = new ImageView(); - Vote vote = item.getProposal().getVote(); + Vote vote = item.getBallot().getVote(); if (vote instanceof BooleanVote) { if (((BooleanVote) vote).isAccepted()) { actionButtonIconView.setId("accepted");