Skip to content

Commit

Permalink
Merge pull request solana-labs#15 from danpaul000/sol-for-fees
Browse files Browse the repository at this point in the history
Add --sol-for-fees option for stake distributions
  • Loading branch information
danpaul000 authored May 5, 2020
2 parents ac7dd41 + 3f75424 commit 4e20253
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/arg_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@ where
.validator(is_valid_pubkey)
.help("Stake Account Address"),
)
.arg(
Arg::with_name("sol_for_fees")
.default_value("1.0")
.long("sol-for-fees")
.takes_value(true)
.value_name("SOL_AMOUNT")
.help("Amount of SOL to put in system account to pay for fees"),
)
.arg(
Arg::with_name("stake_authority")
.long("stake-authority")
Expand Down Expand Up @@ -177,6 +185,7 @@ fn parse_distribute_stake_args(matches: &ArgMatches<'_>) -> DistributeStakeArgs<
transactions_db: value_t_or_exit!(matches, "transactions_db", String),
dry_run: matches.is_present("dry_run"),
stake_account_address: value_t_or_exit!(matches, "stake_account_address", String),
sol_for_fees: value_t_or_exit!(matches, "sol_for_fees", f64),
stake_authority: value_t!(matches, "stake_authority", String).ok(),
withdraw_authority: value_t!(matches, "withdraw_authority", String).ok(),
fee_payer: value_t!(matches, "fee_payer", String).ok(),
Expand Down
2 changes: 2 additions & 0 deletions src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub struct DistributeStakeArgs<P, K> {
pub allocations_csv: String,
pub transactions_db: String,
pub dry_run: bool,
pub sol_for_fees: f64,
pub stake_account_address: P,
pub stake_authority: Option<K>,
pub withdraw_authority: Option<K>,
Expand Down Expand Up @@ -75,6 +76,7 @@ pub fn resolve_command(
&mut wallet_manager,
)
.unwrap(),
sol_for_fees: args.sol_for_fees,
stake_authority: args.stake_authority.as_ref().map(|key_url| {
signer_from_path(&matches, &key_url, "stake authority", &mut wallet_manager)
.unwrap()
Expand Down
3 changes: 2 additions & 1 deletion src/tokens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ fn distribute_stake<T: Client>(
let result = if args.dry_run {
Ok(Signature::default())
} else {
let system_sol = 1.0;
let system_sol = args.sol_for_fees;
let fee_payer_pubkey = args.fee_payer.as_ref().unwrap().pubkey();
let stake_authority = args.stake_authority.as_ref().unwrap().pubkey();
let withdraw_authority = args.withdraw_authority.as_ref().unwrap().pubkey();
Expand Down Expand Up @@ -540,6 +540,7 @@ pub fn test_process_distribute_stake_with_client<C: Client>(client: C, sender_ke
withdraw_authority: Some(Box::new(withdraw_authority)),
fee_payer: Some(Box::new(fee_payer)),
dry_run: false,
sol_for_fees: 1.0,
allocations_csv,
transactions_db: transactions_db.clone(),
};
Expand Down

0 comments on commit 4e20253

Please sign in to comment.