diff --git a/core/src/main/java/bisq/core/dao/DaoFacade.java b/core/src/main/java/bisq/core/dao/DaoFacade.java index a548e9ee2c..f0848c6e61 100644 --- a/core/src/main/java/bisq/core/dao/DaoFacade.java +++ b/core/src/main/java/bisq/core/dao/DaoFacade.java @@ -19,7 +19,7 @@ package bisq.core.dao; import bisq.core.btc.exceptions.TransactionVerificationException; import bisq.core.btc.exceptions.WalletException; -import bisq.core.dao.exceptions.ValidationException; +import bisq.core.dao.governance.proposal.ProposalValidationException; import bisq.core.dao.governance.ballot.BallotListPresentation; import bisq.core.dao.governance.ballot.BallotListService; import bisq.core.dao.governance.blindvote.BlindVoteConsensus; @@ -228,7 +228,7 @@ public class DaoFacade implements DaoSetupService { public ProposalWithTransaction getCompensationProposalWithTransaction(String name, String link, Coin requestedBsq) - throws ValidationException, InsufficientMoneyException, TxException { + throws ProposalValidationException, InsufficientMoneyException, TxException { return compensationProposalFactory.createProposalWithTransaction(name, link, requestedBsq); @@ -237,7 +237,7 @@ public class DaoFacade implements DaoSetupService { public ProposalWithTransaction getReimbursementProposalWithTransaction(String name, String link, Coin requestedBsq) - throws ValidationException, InsufficientMoneyException, TxException { + throws ProposalValidationException, InsufficientMoneyException, TxException { return reimbursementProposalFactory.createProposalWithTransaction(name, link, requestedBsq); @@ -247,7 +247,7 @@ public class DaoFacade implements DaoSetupService { String link, Param param, String paramValue) - throws ValidationException, InsufficientMoneyException, TxException { + throws ProposalValidationException, InsufficientMoneyException, TxException { return changeParamProposalFactory.createProposalWithTransaction(name, link, param, @@ -257,27 +257,27 @@ public class DaoFacade implements DaoSetupService { public ProposalWithTransaction getConfiscateBondProposalWithTransaction(String name, String link, String lockupTxId) - throws ValidationException, InsufficientMoneyException, TxException { + throws ProposalValidationException, InsufficientMoneyException, TxException { return confiscateBondProposalFactory.createProposalWithTransaction(name, link, lockupTxId); } public ProposalWithTransaction getBondedRoleProposalWithTransaction(Role role) - throws ValidationException, InsufficientMoneyException, TxException { + throws ProposalValidationException, InsufficientMoneyException, TxException { return roleProposalFactory.createProposalWithTransaction(role); } public ProposalWithTransaction getGenericProposalWithTransaction(String name, String link) - throws ValidationException, InsufficientMoneyException, TxException { + throws ProposalValidationException, InsufficientMoneyException, TxException { return genericProposalFactory.createProposalWithTransaction(name, link); } public ProposalWithTransaction getRemoveAssetProposalWithTransaction(String name, String link, Asset asset) - throws ValidationException, InsufficientMoneyException, TxException { + throws ProposalValidationException, InsufficientMoneyException, TxException { return removeAssetProposalFactory.createProposalWithTransaction(name, link, asset); } diff --git a/core/src/main/java/bisq/core/dao/governance/blindvote/BlindVoteValidator.java b/core/src/main/java/bisq/core/dao/governance/blindvote/BlindVoteValidator.java index 9e4eb4c419..26e6263686 100644 --- a/core/src/main/java/bisq/core/dao/governance/blindvote/BlindVoteValidator.java +++ b/core/src/main/java/bisq/core/dao/governance/blindvote/BlindVoteValidator.java @@ -17,7 +17,7 @@ package bisq.core.dao.governance.blindvote; -import bisq.core.dao.exceptions.ValidationException; +import bisq.core.dao.governance.proposal.ProposalValidationException; import bisq.core.dao.governance.period.PeriodService; import bisq.core.dao.state.DaoStateService; import bisq.core.dao.state.model.blockchain.Tx; @@ -53,7 +53,7 @@ public class BlindVoteValidator { } } - private void validateDataFields(BlindVote blindVote) throws ValidationException { + private void validateDataFields(BlindVote blindVote) throws ProposalValidationException { try { checkNotNull(blindVote.getEncryptedVotes(), "encryptedProposalList must not be null"); checkArgument(blindVote.getEncryptedVotes().length > 0, @@ -68,7 +68,7 @@ public class BlindVoteValidator { //TODO should we use a min/max for stake, atm its just dust limit as the min. value } catch (Throwable e) { log.warn(e.toString()); - throw new ValidationException(e); + throw new ProposalValidationException(e); } } diff --git a/core/src/main/java/bisq/core/dao/governance/proposal/BaseProposalFactory.java b/core/src/main/java/bisq/core/dao/governance/proposal/BaseProposalFactory.java index 26b187bd28..99c3a3e1a3 100644 --- a/core/src/main/java/bisq/core/dao/governance/proposal/BaseProposalFactory.java +++ b/core/src/main/java/bisq/core/dao/governance/proposal/BaseProposalFactory.java @@ -21,7 +21,6 @@ import bisq.core.btc.exceptions.TransactionVerificationException; import bisq.core.btc.exceptions.WalletException; import bisq.core.btc.wallet.BsqWalletService; import bisq.core.btc.wallet.BtcWalletService; -import bisq.core.dao.exceptions.ValidationException; import bisq.core.dao.state.DaoStateService; import bisq.core.dao.state.model.blockchain.OpReturnType; import bisq.core.dao.state.model.governance.Proposal; @@ -68,7 +67,7 @@ public abstract class BaseProposalFactory { protected ProposalWithTransaction createProposalWithTransaction(String name, String link) - throws ValidationException, InsufficientMoneyException, TxException { + throws ProposalValidationException, InsufficientMoneyException, TxException { this.name = name; this.link = link; // As we don't know the txId yes we create a temp proposal with txId set to an empty string. diff --git a/core/src/main/java/bisq/core/dao/exceptions/ValidationException.java b/core/src/main/java/bisq/core/dao/governance/proposal/ProposalValidationException.java similarity index 53% rename from core/src/main/java/bisq/core/dao/exceptions/ValidationException.java rename to core/src/main/java/bisq/core/dao/governance/proposal/ProposalValidationException.java index 9869254fa9..f8b1e45978 100644 --- a/core/src/main/java/bisq/core/dao/exceptions/ValidationException.java +++ b/core/src/main/java/bisq/core/dao/governance/proposal/ProposalValidationException.java @@ -1,4 +1,4 @@ -package bisq.core.dao.exceptions; +package bisq.core.dao.governance.proposal; import bisq.core.dao.state.model.blockchain.Tx; @@ -9,7 +9,7 @@ import lombok.Getter; import javax.annotation.Nullable; @Getter -public class ValidationException extends Exception { +public class ProposalValidationException extends Exception { @Nullable private Coin requestedBsq; @Nullable @@ -17,31 +17,31 @@ public class ValidationException extends Exception { @Nullable private Tx tx; - public ValidationException(String message, Coin requestedBsq, Coin minRequestAmount) { + public ProposalValidationException(String message, Coin requestedBsq, Coin minRequestAmount) { super(message); this.requestedBsq = requestedBsq; this.minRequestAmount = minRequestAmount; } - public ValidationException(Throwable cause) { + public ProposalValidationException(Throwable cause) { super(cause); } - public ValidationException(String message) { + public ProposalValidationException(String message) { super(message); } - public ValidationException(String message, Throwable throwable) { + public ProposalValidationException(String message, Throwable throwable) { super(message, throwable); } - public ValidationException(String message, Tx tx) { + public ProposalValidationException(String message, Tx tx) { super(message); this.tx = tx; } - public ValidationException(Throwable cause, Tx tx) { + public ProposalValidationException(Throwable cause, Tx tx) { super(cause); this.tx = tx; } diff --git a/core/src/main/java/bisq/core/dao/governance/proposal/ProposalValidator.java b/core/src/main/java/bisq/core/dao/governance/proposal/ProposalValidator.java index 4434339d80..da66d3dcd2 100644 --- a/core/src/main/java/bisq/core/dao/governance/proposal/ProposalValidator.java +++ b/core/src/main/java/bisq/core/dao/governance/proposal/ProposalValidator.java @@ -17,7 +17,6 @@ package bisq.core.dao.governance.proposal; -import bisq.core.dao.exceptions.ValidationException; import bisq.core.dao.governance.period.PeriodService; import bisq.core.dao.state.DaoStateService; import bisq.core.dao.state.model.blockchain.Tx; @@ -51,17 +50,17 @@ public class ProposalValidator { try { validateDataFields(proposal); return true; - } catch (ValidationException e) { + } catch (ProposalValidationException e) { return false; } } - public void validateDataFields(Proposal proposal) throws ValidationException { + public void validateDataFields(Proposal proposal) throws ProposalValidationException { try { notEmpty(proposal.getName(), "name must not be empty"); notEmpty(proposal.getLink(), "link must not be empty"); } catch (Throwable throwable) { - throw new ValidationException(throwable); + throw new ProposalValidationException(throwable); } } diff --git a/core/src/main/java/bisq/core/dao/governance/proposal/compensation/CompensationProposalFactory.java b/core/src/main/java/bisq/core/dao/governance/proposal/compensation/CompensationProposalFactory.java index 0b61fac400..aad5b7b358 100644 --- a/core/src/main/java/bisq/core/dao/governance/proposal/compensation/CompensationProposalFactory.java +++ b/core/src/main/java/bisq/core/dao/governance/proposal/compensation/CompensationProposalFactory.java @@ -21,7 +21,7 @@ import bisq.core.btc.exceptions.TransactionVerificationException; import bisq.core.btc.exceptions.WalletException; import bisq.core.btc.wallet.BsqWalletService; import bisq.core.btc.wallet.BtcWalletService; -import bisq.core.dao.exceptions.ValidationException; +import bisq.core.dao.governance.proposal.ProposalValidationException; import bisq.core.dao.governance.proposal.BaseProposalFactory; import bisq.core.dao.governance.proposal.ProposalConsensus; import bisq.core.dao.governance.proposal.ProposalWithTransaction; @@ -64,7 +64,7 @@ public class CompensationProposalFactory extends BaseProposalFactory } public ProposalWithTransaction createProposalWithTransaction(String name, String link) - throws ValidationException, InsufficientMoneyException, TxException { + throws ProposalValidationException, InsufficientMoneyException, TxException { return super.createProposalWithTransaction(name, link); } diff --git a/core/src/main/java/bisq/core/dao/governance/proposal/generic/GenericProposalValidator.java b/core/src/main/java/bisq/core/dao/governance/proposal/generic/GenericProposalValidator.java index 0ce069647b..fedfcb423f 100644 --- a/core/src/main/java/bisq/core/dao/governance/proposal/generic/GenericProposalValidator.java +++ b/core/src/main/java/bisq/core/dao/governance/proposal/generic/GenericProposalValidator.java @@ -17,7 +17,7 @@ package bisq.core.dao.governance.proposal.generic; -import bisq.core.dao.exceptions.ValidationException; +import bisq.core.dao.governance.proposal.ProposalValidationException; import bisq.core.dao.governance.period.PeriodService; import bisq.core.dao.governance.proposal.ProposalValidator; import bisq.core.dao.state.DaoStateService; @@ -37,14 +37,14 @@ public class GenericProposalValidator extends ProposalValidator { } @Override - public void validateDataFields(Proposal proposal) throws ValidationException { + public void validateDataFields(Proposal proposal) throws ProposalValidationException { try { super.validateDataFields(proposal); GenericProposal genericProposalProposal = (GenericProposal) proposal; //TODO } catch (Throwable throwable) { - throw new ValidationException(throwable); + throw new ProposalValidationException(throwable); } } } diff --git a/core/src/main/java/bisq/core/dao/governance/proposal/param/ChangeParamProposalFactory.java b/core/src/main/java/bisq/core/dao/governance/proposal/param/ChangeParamProposalFactory.java index 4ff64e37f3..572b7ac80c 100644 --- a/core/src/main/java/bisq/core/dao/governance/proposal/param/ChangeParamProposalFactory.java +++ b/core/src/main/java/bisq/core/dao/governance/proposal/param/ChangeParamProposalFactory.java @@ -19,7 +19,7 @@ package bisq.core.dao.governance.proposal.param; import bisq.core.btc.wallet.BsqWalletService; import bisq.core.btc.wallet.BtcWalletService; -import bisq.core.dao.exceptions.ValidationException; +import bisq.core.dao.governance.proposal.ProposalValidationException; import bisq.core.dao.governance.param.Param; import bisq.core.dao.governance.proposal.BaseProposalFactory; import bisq.core.dao.governance.proposal.ProposalWithTransaction; @@ -61,7 +61,7 @@ public class ChangeParamProposalFactory extends BaseProposalFactory= 0, "Requested BSQ must not be less than " + (minReimbursementRequestAmount.value / 100L) + " BSQ"); } catch (Throwable throwable) { - throw new ValidationException(throwable); + throw new ProposalValidationException(throwable); } } } diff --git a/core/src/main/java/bisq/core/dao/governance/proposal/removeAsset/RemoveAssetProposalFactory.java b/core/src/main/java/bisq/core/dao/governance/proposal/removeAsset/RemoveAssetProposalFactory.java index 71d8c56ea6..32626d78e7 100644 --- a/core/src/main/java/bisq/core/dao/governance/proposal/removeAsset/RemoveAssetProposalFactory.java +++ b/core/src/main/java/bisq/core/dao/governance/proposal/removeAsset/RemoveAssetProposalFactory.java @@ -19,7 +19,7 @@ package bisq.core.dao.governance.proposal.removeAsset; import bisq.core.btc.wallet.BsqWalletService; import bisq.core.btc.wallet.BtcWalletService; -import bisq.core.dao.exceptions.ValidationException; +import bisq.core.dao.governance.proposal.ProposalValidationException; import bisq.core.dao.governance.proposal.BaseProposalFactory; import bisq.core.dao.governance.proposal.ProposalWithTransaction; import bisq.core.dao.governance.proposal.TxException; @@ -60,7 +60,7 @@ public class RemoveAssetProposalFactory extends BaseProposalFactory { } public ProposalWithTransaction createProposalWithTransaction(Role role) - throws ValidationException, InsufficientMoneyException, TxException { + throws ProposalValidationException, InsufficientMoneyException, TxException { this.role = role; return super.createProposalWithTransaction(role.getName(), role.getLink()); diff --git a/core/src/main/java/bisq/core/dao/governance/proposal/role/RoleValidator.java b/core/src/main/java/bisq/core/dao/governance/proposal/role/RoleValidator.java index a57d6f6d6a..0b5c4e7e32 100644 --- a/core/src/main/java/bisq/core/dao/governance/proposal/role/RoleValidator.java +++ b/core/src/main/java/bisq/core/dao/governance/proposal/role/RoleValidator.java @@ -17,7 +17,7 @@ package bisq.core.dao.governance.proposal.role; -import bisq.core.dao.exceptions.ValidationException; +import bisq.core.dao.governance.proposal.ProposalValidationException; import bisq.core.dao.governance.period.PeriodService; import bisq.core.dao.governance.proposal.ProposalValidator; import bisq.core.dao.state.DaoStateService; @@ -40,7 +40,7 @@ public class RoleValidator extends ProposalValidator { } @Override - public void validateDataFields(Proposal proposal) throws ValidationException { + public void validateDataFields(Proposal proposal) throws ProposalValidationException { try { super.validateDataFields(proposal); @@ -51,7 +51,7 @@ public class RoleValidator extends ProposalValidator { notEmpty(role.getName(), "role.name must not be empty"); } catch (Throwable throwable) { - throw new ValidationException(throwable); + throw new ProposalValidationException(throwable); } } } diff --git a/core/src/main/java/bisq/core/util/BsqFormatter.java b/core/src/main/java/bisq/core/util/BsqFormatter.java index 29cd5f0044..6dc5defc2b 100644 --- a/core/src/main/java/bisq/core/util/BsqFormatter.java +++ b/core/src/main/java/bisq/core/util/BsqFormatter.java @@ -18,7 +18,7 @@ package bisq.core.util; import bisq.core.app.BisqEnvironment; -import bisq.core.dao.exceptions.ValidationException; +import bisq.core.dao.governance.proposal.ProposalValidationException; import bisq.core.dao.governance.param.Param; import bisq.core.locale.GlobalSettings; import bisq.core.locale.Res; @@ -136,19 +136,19 @@ public class BsqFormatter extends BSFormatter { return super.parseToCoin(input, btcCoinFormat); } - public void validateBtcInput(String input) throws ValidationException { + public void validateBtcInput(String input) throws ProposalValidationException { validateCoinInput(input, btcCoinFormat); } - public void validateBsqInput(String input) throws ValidationException { + public void validateBsqInput(String input) throws ProposalValidationException { validateCoinInput(input, this.coinFormat); } - private void validateCoinInput(String input, MonetaryFormat coinFormat) throws ValidationException { + private void validateCoinInput(String input, MonetaryFormat coinFormat) throws ProposalValidationException { try { coinFormat.parse(cleanDoubleInput(input)); } catch (Throwable t) { - throw new ValidationException("Invalid format for a " + coinFormat.code() + " value"); + throw new ProposalValidationException("Invalid format for a " + coinFormat.code() + " value"); } } @@ -193,7 +193,7 @@ public class BsqFormatter extends BSFormatter { } } - public String parseParamValueToString(Param param, String inputValue) throws ValidationException { + public String parseParamValueToString(Param param, String inputValue) throws ProposalValidationException { switch (param.getParamType()) { case UNDEFINED: return Res.get("shared.na"); @@ -210,7 +210,7 @@ public class BsqFormatter extends BSFormatter { if (validationResult.isValid) return inputValue; else - throw new ValidationException(validationResult.errorMessage); + throw new ProposalValidationException(validationResult.errorMessage); default: log.warn("Param type {} not handled in switch case at parseParamValueToString", param.getParamType()); return Res.get("shared.na"); diff --git a/desktop/src/main/java/bisq/desktop/main/dao/governance/make/MakeProposalView.java b/desktop/src/main/java/bisq/desktop/main/dao/governance/make/MakeProposalView.java index 57058de86e..e5ed3e7e73 100644 --- a/desktop/src/main/java/bisq/desktop/main/dao/governance/make/MakeProposalView.java +++ b/desktop/src/main/java/bisq/desktop/main/dao/governance/make/MakeProposalView.java @@ -33,7 +33,7 @@ import bisq.core.btc.exceptions.InsufficientBsqException; import bisq.core.btc.setup.WalletsSetup; import bisq.core.btc.wallet.BsqWalletService; import bisq.core.dao.DaoFacade; -import bisq.core.dao.exceptions.ValidationException; +import bisq.core.dao.governance.proposal.ProposalValidationException; import bisq.core.dao.governance.bond.Bond; import bisq.core.dao.governance.param.Param; import bisq.core.dao.governance.proposal.ProposalType; @@ -305,7 +305,7 @@ public class MakeProposalView extends ActivatableView implements btcFormatter.formatCoinWithCode(e.missing))).show(); } - } catch (ValidationException e) { + } catch (ProposalValidationException e) { String message; if (e.getMinRequestAmount() != null) { message = Res.get("validation.bsq.amountBelowMinAmount", @@ -359,7 +359,7 @@ public class MakeProposalView extends ActivatableView implements @Nullable private ProposalWithTransaction getProposalWithTransaction(ProposalType type) - throws InsufficientMoneyException, ValidationException, TxException { + throws InsufficientMoneyException, ProposalValidationException, TxException { checkNotNull(proposalDisplay, "proposalDisplay must not be null"); @@ -385,10 +385,10 @@ public class MakeProposalView extends ActivatableView implements "proposalDisplay.paramValueTextField must no tbe null"); Param selectedParam = proposalDisplay.paramComboBox.getSelectionModel().getSelectedItem(); if (selectedParam == null) - throw new ValidationException("selectedParam is null"); + throw new ProposalValidationException("selectedParam is null"); String paramValueAsString = proposalDisplay.paramValueTextField.getText(); if (paramValueAsString == null || paramValueAsString.isEmpty()) - throw new ValidationException("paramValue is null or empty"); + throw new ProposalValidationException("paramValue is null or empty"); try { String paramValue = bsqFormatter.parseParamValueToString(selectedParam, paramValueAsString);