penumbra_governance/
event.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
use penumbra_proto::penumbra::core::component::governance::v1 as pb;
use penumbra_stake::IdentityKey;

use crate::{
    DelegatorVote, Proposal, ProposalDepositClaim, ProposalSubmit, ProposalWithdraw, ValidatorVote,
};

pub fn delegator_vote(
    delegator_vote: &DelegatorVote,
    validator_identity_key: &IdentityKey,
) -> pb::EventDelegatorVote {
    pb::EventDelegatorVote {
        vote: Some(pb::DelegatorVote::from(*delegator_vote)),
        validator_identity_key: Some(validator_identity_key.clone().into()),
    }
}

pub fn proposal_deposit_claim(
    deposit_claim: &ProposalDepositClaim,
) -> pb::EventProposalDepositClaim {
    pb::EventProposalDepositClaim {
        deposit_claim: Some(pb::ProposalDepositClaim::from(*deposit_claim)),
    }
}

pub fn validator_vote(validator_vote: &ValidatorVote, voting_power: u64) -> pb::EventValidatorVote {
    pb::EventValidatorVote {
        vote: Some(pb::ValidatorVote::from(validator_vote.clone())),
        voting_power,
    }
}

pub fn proposal_withdraw(withdraw: &ProposalWithdraw) -> pb::EventProposalWithdraw {
    pb::EventProposalWithdraw {
        withdraw: Some(pb::ProposalWithdraw::from(withdraw.clone())),
    }
}

pub fn proposal_submit(
    submit: &ProposalSubmit,
    start_height: u64,
    end_height: u64,
) -> pb::EventProposalSubmit {
    pb::EventProposalSubmit {
        submit: Some(pb::ProposalSubmit::from(submit.clone())),
        start_height,
        end_height,
    }
}

pub fn proposal_passed(proposal: &Proposal) -> pb::EventProposalPassed {
    pb::EventProposalPassed {
        proposal: Some(pb::Proposal::from(proposal.clone())),
    }
}

pub fn proposal_failed(proposal: &Proposal) -> pb::EventProposalFailed {
    pb::EventProposalFailed {
        proposal: Some(pb::Proposal::from(proposal.clone())),
    }
}

pub fn proposal_slashed(proposal: &Proposal) -> pb::EventProposalSlashed {
    pb::EventProposalSlashed {
        proposal: Some(pb::Proposal::from(proposal.clone())),
    }
}