Skip to content

Commit

Permalink
Merge pull request #1751 from ManfredKarrer/Dao-UI-improvements
Browse files Browse the repository at this point in the history
Dao ui improvements
  • Loading branch information
ManfredKarrer committed Oct 12, 2018
2 parents 56965c1 + 5879dd9 commit 1163ceb
Show file tree
Hide file tree
Showing 99 changed files with 2,802 additions and 769 deletions.
72 changes: 60 additions & 12 deletions common/src/main/proto/pb.proto
Expand Up @@ -56,6 +56,7 @@ message NetworkEnvelope {

AddPersistableNetworkPayloadMessage add_persistable_network_payload_message = 31;
AckMessage ack_message = 32;
RepublishGovernanceDataRequest republish_governance_data_request = 33;
}
}

Expand Down Expand Up @@ -319,6 +320,9 @@ message NewBlockBroadcastMessage {
BaseBlock raw_block = 1;
}

message RepublishGovernanceDataRequest {
}

///////////////////////////////////////////////////////////////////////////////////////////
// Payload
///////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -931,6 +935,9 @@ message PersistableEnvelope {
MyBlindVoteList my_blind_vote_list = 22;
MeritList merit_list = 23;
BondedRoleList bonded_role_list = 24;
RemovedAssetList removed_asset_list = 25;
EvaluatedProposalList evaluated_proposal_list = 26;
DecryptedBallotsWithMeritsList decrypted_ballots_with_merits_list = 27;
}
}

Expand Down Expand Up @@ -1470,11 +1477,11 @@ message Proposal {
string tx_id = 5;
oneof message {
CompensationProposal compensation_proposal = 6;
GenericProposal generic_proposal = 7;
ChangeParamProposal change_param_proposal = 8;
RemoveAltcoinProposal remove_altcoin_proposal = 9;
ConfiscateBondProposal confiscate_bond_proposal = 10;
BondedRoleProposal bonded_role_proposal = 11;
ChangeParamProposal change_param_proposal = 7;
BondedRoleProposal bonded_role_proposal = 8;
ConfiscateBondProposal confiscate_bond_proposal = 9;
GenericProposal generic_proposal = 10;
RemoveAssetProposal remove_asset_proposal = 11;
}
}

Expand All @@ -1483,24 +1490,32 @@ message CompensationProposal {
string bsq_address = 2;
}

message GenericProposal {
}

message ChangeParamProposal {
string param = 1; // name of enum
int64 param_value = 2;
}

message RemoveAltcoinProposal {
string currency_code = 1;
message BondedRoleProposal {
BondedRole bonded_role = 1;
}

message ConfiscateBondProposal {
bytes hash = 1;
}

message BondedRoleProposal {
BondedRole bonded_role = 1;
message GenericProposal {
}

message RemoveAssetProposal {
string ticker_symbol = 1;
}

message RemovedAsset {
string ticker_symbol = 1;
string remove_reason = 2;
}
message RemovedAssetList {
repeated RemovedAsset removed_asset = 1;
}

message BondedRole {
Expand Down Expand Up @@ -1616,6 +1631,39 @@ message MeritList {
repeated Merit merit = 1;
}

message ProposalVoteResult {
Proposal proposal = 1;
int64 stake_of_Accepted_votes = 2;
int64 stake_of_Rejected_votes = 3;
int32 num_accepted_votes = 4;
int32 num_rejected_votes = 5;
int32 num_ignored_votes = 6;
}

message EvaluatedProposal {
bool is_accepted = 1;
ProposalVoteResult proposal_vote_result = 2;
int64 required_quorum = 3;
int64 required_threshold = 4;
}

message EvaluatedProposalList {
repeated EvaluatedProposal evaluated_proposal = 1;
}

message DecryptedBallotsWithMerits {
bytes hash_of_blind_vote_list = 1;
string vote_reveal_tx_id = 2;
string blind_vote_tx_id = 3;
int64 stake = 4;
BallotList ballot_list = 5;
MeritList merit_list = 6;
}

message DecryptedBallotsWithMeritsList {
repeated DecryptedBallotsWithMerits decrypted_ballots_with_merits = 1;
}

///////////////////////////////////////////////////////////////////////////////////////////
// Misc
///////////////////////////////////////////////////////////////////////////////////////////
Expand Down
1 change: 1 addition & 0 deletions core/src/main/java/bisq/core/app/BisqHeadlessApp.java
Expand Up @@ -92,6 +92,7 @@ protected void setupHandlers() {
bisqSetup.setDisplaySecurityRecommendationHandler(key -> log.info("onDisplaySecurityRecommendationHandler"));
bisqSetup.setDisplayLocalhostHandler(key -> log.info("onDisplayLocalhostHandler"));
bisqSetup.setWrongOSArchitectureHandler(msg -> log.info("onWrongOSArchitectureHandler. msg={}", msg));
bisqSetup.setVoteResultExceptionHandler(voteResultException -> log.info("voteResultException={}", voteResultException));

//TODO move to bisqSetup
corruptedDatabaseFilesHandler.getCorruptedDatabaseFiles().ifPresent(files -> log.info("getCorruptedDatabaseFiles. files={}", files));
Expand Down
17 changes: 17 additions & 0 deletions core/src/main/java/bisq/core/app/BisqSetup.java
Expand Up @@ -30,6 +30,8 @@
import bisq.core.btc.wallet.BtcWalletService;
import bisq.core.btc.wallet.WalletsManager;
import bisq.core.dao.DaoSetup;
import bisq.core.dao.governance.voteresult.VoteResultException;
import bisq.core.dao.governance.voteresult.VoteResultService;
import bisq.core.filter.FilterManager;
import bisq.core.locale.Res;
import bisq.core.notifications.MobileNotificationService;
Expand Down Expand Up @@ -147,6 +149,7 @@ public interface BisqSetupCompleteListener {
private final DisputeMsgEvents disputeMsgEvents;
private final PriceAlert priceAlert;
private final MarketAlerts marketAlerts;
private final VoteResultService voteResultService;
private final BSFormatter formatter;
@Setter
@Nullable
Expand All @@ -173,6 +176,9 @@ public interface BisqSetupCompleteListener {
private BiConsumer<Alert, String> displayUpdateHandler;
@Setter
@Nullable
private Consumer<VoteResultException> voteResultExceptionHandler;
@Setter
@Nullable
private Consumer<PrivateNotificationPayload> displayPrivateNotificationHandler;

@Getter
Expand Down Expand Up @@ -216,6 +222,7 @@ public BisqSetup(P2PNetworkSetup p2PNetworkSetup,
DisputeMsgEvents disputeMsgEvents,
PriceAlert priceAlert,
MarketAlerts marketAlerts,
VoteResultService voteResultService,
BSFormatter formatter) {


Expand Down Expand Up @@ -251,6 +258,7 @@ public BisqSetup(P2PNetworkSetup p2PNetworkSetup,
this.disputeMsgEvents = disputeMsgEvents;
this.priceAlert = priceAlert;
this.marketAlerts = marketAlerts;
this.voteResultService = voteResultService;
this.formatter = formatter;
}

Expand Down Expand Up @@ -632,6 +640,15 @@ public void onBalanceChanged(Coin balance, Transaction tx) {
}
});

voteResultService.getVoteResultExceptions().addListener((ListChangeListener<VoteResultException>) c -> {
c.next();
if (c.wasAdded() && voteResultExceptionHandler != null) {
c.getAddedSubList().forEach(e -> {
voteResultExceptionHandler.accept(e);
});
}
});

mobileNotificationService.onAllServicesInitialized();
myOfferTakenEvents.onAllServicesInitialized();
tradeEvents.onAllServicesInitialized();
Expand Down
Expand Up @@ -18,10 +18,12 @@
package bisq.core.app.misc;

import bisq.core.dao.DaoSetup;
import bisq.core.dao.governance.asset.AssetService;
import bisq.core.dao.governance.ballot.BallotListService;
import bisq.core.dao.governance.blindvote.MyBlindVoteListService;
import bisq.core.dao.governance.myvote.MyVoteListService;
import bisq.core.dao.governance.role.BondedRolesService;
import bisq.core.dao.governance.voteresult.VoteResultService;
import bisq.core.filter.FilterManager;
import bisq.core.payment.AccountAgeWitnessService;
import bisq.core.trade.statistics.TradeStatisticsManager;
Expand Down Expand Up @@ -50,7 +52,9 @@ public AppSetupWithP2PAndDAO(EncryptionService encryptionService,
MyVoteListService myVoteListService,
BallotListService ballotListService,
MyBlindVoteListService myBlindVoteListService,
BondedRolesService bondedRolesService) {
BondedRolesService bondedRolesService,
AssetService assetService,
VoteResultService voteResultService) {
super(encryptionService,
keyRing,
p2PService,
Expand All @@ -64,6 +68,8 @@ public AppSetupWithP2PAndDAO(EncryptionService encryptionService,
persistedDataHosts.add(ballotListService);
persistedDataHosts.add(myBlindVoteListService);
persistedDataHosts.add(bondedRolesService);
persistedDataHosts.add(assetService);
persistedDataHosts.add(voteResultService);
}

@Override
Expand Down
14 changes: 1 addition & 13 deletions core/src/main/java/bisq/core/btc/BaseCurrencyNetwork.java
Expand Up @@ -17,9 +17,6 @@

package bisq.core.btc;

import bisq.core.app.BisqEnvironment;
import bisq.core.provider.fee.FeeService;

import org.libdohj.params.DashMainNetParams;
import org.libdohj.params.DashRegTestParams;
import org.libdohj.params.DashTestNet3Params;
Expand Down Expand Up @@ -88,15 +85,6 @@ public boolean isDash() {
}

public long getDefaultMinFeePerByte() {
switch (BisqEnvironment.getBaseCurrencyNetwork().getCurrencyCode()) {
case "BTC":
return 1;
case "LTC":
return FeeService.LTC_REFERENCE_DEFAULT_MIN_TX_FEE.value;
case "DASH":
return FeeService.DASH_REFERENCE_DEFAULT_MIN_TX_FEE.value;
default:
throw new RuntimeException("Unsupported code at getDefaultMinFee: " + BisqEnvironment.getBaseCurrencyNetwork().getCurrencyCode());
}
return 1;
}
}
57 changes: 46 additions & 11 deletions core/src/main/java/bisq/core/dao/DaoFacade.java
Expand Up @@ -37,9 +37,12 @@
import bisq.core.dao.governance.proposal.ProposalListPresentation;
import bisq.core.dao.governance.proposal.ProposalWithTransaction;
import bisq.core.dao.governance.proposal.TxException;
import bisq.core.dao.governance.proposal.compensation.CompensationConsensus;
import bisq.core.dao.governance.proposal.compensation.CompensationProposalService;
import bisq.core.dao.governance.proposal.confiscatebond.ConfiscateBondProposalService;
import bisq.core.dao.governance.proposal.generic.GenericProposalService;
import bisq.core.dao.governance.proposal.param.ChangeParamProposalService;
import bisq.core.dao.governance.proposal.removeAsset.RemoveAssetProposalService;
import bisq.core.dao.governance.proposal.role.BondedRoleProposalService;
import bisq.core.dao.governance.role.BondedRole;
import bisq.core.dao.governance.role.BondedRolesService;
Expand Down Expand Up @@ -78,6 +81,10 @@

import javax.annotation.Nullable;



import bisq.asset.Asset;

/**
* Provides a facade to interact with the Dao domain. Hides complexity and domain details to clients (e.g. UI or APIs)
* by providing a reduced API and/or aggregating subroutines.
Expand All @@ -95,10 +102,11 @@ public class DaoFacade implements DaoSetupService {
private final ChangeParamProposalService changeParamProposalService;
private final ConfiscateBondProposalService confiscateBondProposalService;
private final BondedRoleProposalService bondedRoleProposalService;
private final GenericProposalService genericProposalService;
private final RemoveAssetProposalService removeAssetProposalService;
private final BondedRolesService bondedRolesService;
private final LockupService lockupService;
private final UnlockService unlockService;
private final ProposalConsensus proposalConsensus;

private final ObjectProperty<DaoPhase.Phase> phaseProperty = new SimpleObjectProperty<>(DaoPhase.Phase.UNDEFINED);

Expand All @@ -115,10 +123,11 @@ public DaoFacade(MyProposalListService myProposalListService,
ChangeParamProposalService changeParamProposalService,
ConfiscateBondProposalService confiscateBondProposalService,
BondedRoleProposalService bondedRoleProposalService,
GenericProposalService genericProposalService,
RemoveAssetProposalService removeAssetProposalService,
BondedRolesService bondedRolesService,
LockupService lockupService,
UnlockService unlockService,
ProposalConsensus proposalConsensus) {
UnlockService unlockService) {
this.proposalListPresentation = proposalListPresentation;
this.ballotListService = ballotListService;
this.ballotListPresentation = ballotListPresentation;
Expand All @@ -131,10 +140,11 @@ public DaoFacade(MyProposalListService myProposalListService,
this.changeParamProposalService = changeParamProposalService;
this.confiscateBondProposalService = confiscateBondProposalService;
this.bondedRoleProposalService = bondedRoleProposalService;
this.genericProposalService = genericProposalService;
this.removeAssetProposalService = removeAssetProposalService;
this.bondedRolesService = bondedRolesService;
this.lockupService = lockupService;
this.unlockService = unlockService;
this.proposalConsensus = proposalConsensus;
}


Expand Down Expand Up @@ -232,13 +242,26 @@ public ProposalWithTransaction getBondedRoleProposalWithTransaction(BondedRole b
return bondedRoleProposalService.createProposalWithTransaction(bondedRole);
}

public ProposalWithTransaction getGenericProposalWithTransaction(String name,
String link)
throws ValidationException, InsufficientMoneyException, TxException {
return genericProposalService.createProposalWithTransaction(name, link);
}

public ProposalWithTransaction getRemoveAssetProposalWithTransaction(String name,
String link,
Asset asset)
throws ValidationException, InsufficientMoneyException, TxException {
return removeAssetProposalService.createProposalWithTransaction(name, link, asset);
}

public List<BondedRole> getBondedRoleList() {
return bondedRolesService.getBondedRoleList();
}

// Show fee
public Coin getProposalFee(int chainHeight) {
return proposalConsensus.getFee(bsqStateService, chainHeight);
return ProposalConsensus.getFee(bsqStateService, chainHeight);
}

// Publish proposal tx, proposal payload and and persist it to myProposalList
Expand Down Expand Up @@ -464,16 +487,16 @@ public boolean isInPhaseButNotLastBlock(DaoPhase.Phase phase) {
return periodService.isInPhaseButNotLastBlock(phase);
}

public boolean isTxInCorrectCycle(int txHeight, int chainHeadHeight) {
return periodService.isTxInCorrectCycle(txHeight, chainHeadHeight);
public boolean isTxInCorrectCycle(int txHeight, int chainHeight) {
return periodService.isTxInCorrectCycle(txHeight, chainHeight);
}

public boolean isTxInCorrectCycle(String txId, int chainHeadHeight) {
return periodService.isTxInCorrectCycle(txId, chainHeadHeight);
public boolean isTxInCorrectCycle(String txId, int chainHeight) {
return periodService.isTxInCorrectCycle(txId, chainHeight);
}

public boolean isTxInPhaseAndCycle(String txId, DaoPhase.Phase phase, int chainHeadHeight) {
return periodService.isTxInPhaseAndCycle(txId, phase, chainHeadHeight);
public boolean isTxInPhaseAndCycle(String txId, DaoPhase.Phase phase, int chainHeight) {
return periodService.isTxInPhaseAndCycle(txId, phase, chainHeight);
}

public boolean isUnspent(TxOutputKey key) {
Expand All @@ -487,4 +510,16 @@ public Optional<BondedRole> getBondedRoleFromHash(byte[] hash) {
public boolean isUnlocking(BondedRole bondedRole) {
return bsqStateService.isUnlocking(bondedRole);
}

public Coin getMinCompensationRequestAmount() {
return CompensationConsensus.getMinCompensationRequestAmount(bsqStateService, periodService.getChainHeight());
}

public Coin getMaxCompensationRequestAmount() {
return CompensationConsensus.getMaxCompensationRequestAmount(bsqStateService, periodService.getChainHeight());
}

public long getPramValue(Param param) {
return bsqStateService.getParamValue(param, periodService.getChainHeight());
}
}

0 comments on commit 1163ceb

Please sign in to comment.