Skip to content

Commit

Permalink
Merge pull request #61 from tonlabs/depool_ticktock
Browse files Browse the repository at this point in the history
Depool ticktock
  • Loading branch information
joydark authored Nov 5, 2020
2 parents 19d5d08 + 36233d3 commit 58d6ea2
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/depool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ pub fn create_depool_command<'a, 'b>() -> App<'a, 'b> {
.arg(wallet_arg.clone())
.arg(value_arg.clone())
.arg(keys_arg.clone()))
.subcommand(SubCommand::with_name("ticktock")
.about("Call DePool 'ticktock()' function to update its state. 1 ton is attached to this call (change will be returned).")
.setting(AppSettings::AllowLeadingHyphen)
.arg(wallet_arg.clone())
.arg(keys_arg.clone()))
.subcommand(SubCommand::with_name("withdraw")
.about("Allows to disable auto investment of the stake into next round and withdraw all the stakes after round completion.")
.setting(AppSettings::AllowLeadingHyphen)
Expand Down Expand Up @@ -236,6 +241,10 @@ pub fn depool_command(m: &ArgMatches, conf: Config) -> Result<(), String> {
CommandData::from_matches_and_conf(m, conf, depool)?,
);
}
if let Some(m) = m.subcommand_matches("ticktock") {
let (wallet, keys) = parse_wallet_data(&m, &conf)?;
return ticktock_command(m, conf, &depool, &wallet, &keys);
}
Err("unknown depool command".to_owned())
}

Expand Down Expand Up @@ -343,6 +352,18 @@ fn replenish_command<'a>(
replenish_stake(cmd)
}

fn ticktock_command<'a>(
m: &ArgMatches,
conf: Config,
depool: &str,
wallet: &str,
keys: &str,
) -> Result<(), String> {
let (depool, wallet, keys) = (Some(depool), Some(wallet), Some(keys));
print_args!(m, depool, wallet, keys);
call_ticktock(conf, depool.unwrap(), wallet.unwrap(), keys.unwrap())
}

fn transfer_stake_command<'a>(
m: &ArgMatches,
cmd: CommandData
Expand Down Expand Up @@ -436,6 +457,16 @@ fn replenish_stake(
send_with_body(cmd.conf, &cmd.wallet, &cmd.depool, cmd.stake, &cmd.keys, &body)
}

fn call_ticktock(
conf: Config,
depool: &str,
wallet: &str,
keys: &str,
) -> Result<(), String> {
let body = encode_ticktock()?;
send_with_body(conf, wallet, depool, "1", keys, &body)
}

fn add_exotic_stake(
cmd: CommandData,
beneficiary: &str,
Expand Down Expand Up @@ -538,6 +569,11 @@ fn encode_replenish_stake() -> Result<String, String> {
}))
}

fn encode_ticktock() -> Result<String, String> {
encode_body("ticktock", json!({
}))
}

fn encode_add_vesting_stake(stake: u64, beneficiary: &str, tperiod: u32, wperiod: u32) -> Result<String, String> {
encode_body("addVestingStake", json!({
"stake": stake,
Expand Down

0 comments on commit 58d6ea2

Please sign in to comment.