Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion catalyst-toolbox/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ image = "0.23.12"
qrcode = "0.12"
quircs = "0.10.0"
symmetric-cipher = { git = "https://github.com/input-output-hk/chain-wallet-libs.git", branch = "master" }
graphql_client = "0.10"
graphql_client = { version = "0.10" }
gag = "1"
vit-servicing-station-lib = { git = "https://github.com/input-output-hk/vit-servicing-station.git", branch = "master" }
env_logger = "0.9"
Expand Down
41 changes: 6 additions & 35 deletions catalyst-toolbox/src/bin/cli/rewards/voters.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
use catalyst_toolbox::rewards::voters::{calc_voter_rewards, Rewards, VoteCount};
use catalyst_toolbox::snapshot::{
registration::MainnetRewardAddress, voting_group::VotingGroupAssigner, Snapshot,
};
use catalyst_toolbox::snapshot::{registration::MainnetRewardAddress, SnapshotInfo};
use catalyst_toolbox::utils::assert_are_close;

use color_eyre::Report;
use fraction::Fraction;
use jcli_lib::jcli_lib::block::Common;
use jormungandr_lib::{crypto::account::Identifier, interfaces::Block0Configuration};
use structopt::StructOpt;

use std::collections::BTreeMap;
Expand All @@ -22,19 +18,9 @@ pub struct VotersRewards {
#[structopt(long)]
total_rewards: u64,

/// Path to raw snapshot
/// Path to a json encoded list of `SnapshotInfo`
#[structopt(long)]
snapshot_path: PathBuf,

/// Stake threshold to be able to participate in a Catalyst sidechain
/// Registrations with less than the threshold associated to the stake address
/// will be ignored
#[structopt(long)]
registration_threshold: u64,

/// Voting power cap for each account
#[structopt(short, long)]
voting_power_cap: Fraction,
snapshot_info_path: PathBuf,

#[structopt(long)]
votes_count_path: PathBuf,
Expand Down Expand Up @@ -66,30 +52,22 @@ impl VotersRewards {
let VotersRewards {
common,
total_rewards,
snapshot_path,
registration_threshold,
snapshot_info_path,
votes_count_path,
vote_threshold,
voting_power_cap,
} = self;
let block = common.input.load_block()?;
let block0 = Block0Configuration::from_block(&block)?;

let vote_count: VoteCount = serde_json::from_reader(jcli_lib::utils::io::open_file_read(
&Some(votes_count_path),
)?)?;

let snapshot = Snapshot::from_raw_snapshot(
serde_json::from_reader(jcli_lib::utils::io::open_file_read(&Some(snapshot_path))?)?,
registration_threshold.into(),
voting_power_cap,
&DummyAssigner,
let snapshot: Vec<SnapshotInfo> = serde_json::from_reader(
jcli_lib::utils::io::open_file_read(&Some(snapshot_info_path))?,
)?;

let results = calc_voter_rewards(
vote_count,
vote_threshold,
&block0,
snapshot,
Rewards::from(total_rewards),
)?;
Expand All @@ -101,10 +79,3 @@ impl VotersRewards {
Ok(())
}
}

struct DummyAssigner;
impl VotingGroupAssigner for DummyAssigner {
fn assign(&self, _vk: &Identifier) -> String {
unimplemented!()
}
}
4 changes: 2 additions & 2 deletions catalyst-toolbox/src/bin/cli/snapshot/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub struct SnapshotCmd {
snapshot: PathBuf,
/// Registrations voting power threshold for eligibility
#[structopt(short, long)]
threshold: Value,
min_stake_threshold: Value,

/// Voter group to assign direct voters to.
/// If empty, defaults to "voter"
Expand Down Expand Up @@ -59,7 +59,7 @@ impl SnapshotCmd {
let assigner = RepsVotersAssigner::new(direct_voter, representative, self.reps_db_api_url)?;
let initials = Snapshot::from_raw_snapshot(
raw_snapshot,
self.threshold,
self.min_stake_threshold,
self.voting_power_cap,
&assigner,
)?
Expand Down
Loading