Skip to content

Commit

Permalink
Remove height parameter in update-pool + write docs for update-pool /…
Browse files Browse the repository at this point in the history
… prepare-update
  • Loading branch information
SethDusek committed Aug 6, 2022
1 parent 4852efa commit 174dd84
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 22 deletions.
1 change: 0 additions & 1 deletion core/src/box_kind/ballot_box.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ pub fn make_local_ballot_box_candidate(
value: BoxValue,
creation_height: u32,
) -> Result<ErgoBoxCandidate, ErgoBoxCandidateBuilderError> {
dbg!(&reward_tokens);
let mut builder = ErgoBoxCandidateBuilder::new(value, contract.ergo_tree(), creation_height);
builder.set_register_value(
NonMandatoryRegisterId::R4,
Expand Down
9 changes: 2 additions & 7 deletions core/src/cli_commands/update_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ pub fn update_pool(
new_pool_box_hash_str: Option<String>,
reward_token_id: Option<String>,
reward_token_amount: Option<u64>,
height: Option<u64>,
) -> Result<(), UpdatePoolError> {
info!("Opening oracle_config_updated.yaml");
let s = std::fs::read_to_string("oracle_config_updated.yaml")?;
Expand Down Expand Up @@ -113,22 +112,18 @@ pub fn update_pool(

if new_pool_box_hash_str.is_none() {
println!(
"Run ./oracle-core --new_pool_box_hash {} --height HEIGHT to update pool",
"Run ./oracle-core --new_pool_box_hash {} to update pool",
String::from(new_pool_box_hash)
);
return Ok(());
}
let height = height.unwrap();
let new_reward_tokens = reward_token_id
.zip(reward_token_amount)
.map(|(token_id, amount)| Token {
token_id: TokenId::from_base64(&token_id).unwrap(),
amount: amount.try_into().unwrap(),
});
if height != current_block_height()? {
println!("Height outdated, please use current blockchain height");
std::process::exit(exitcode::SOFTWARE);
}

let tx = build_update_pool_box_tx(
op.get_pool_box_source(),
op.get_ballot_boxes_source(),
Expand Down
27 changes: 13 additions & 14 deletions core/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,13 @@ enum Command {
},

/// Extract reward tokens to a chosen address
ExtractRewardTokens {
rewards_address: String,
},
ExtractRewardTokens { rewards_address: String },

/// Print the number of reward tokens earned by the oracle.
PrintRewardTokens,

/// Transfer an oracle token to a chosen address.
TransferOracleToken {
oracle_token_address: String,
},
TransferOracleToken { oracle_token_address: String },

/// Vote to update the oracle pool
VoteUpdatePool {
Expand All @@ -127,14 +123,21 @@ enum Command {
/// The creation height of the update box.
update_box_creation_height: u32,
},
/// Initiate the Update Pool transaction.
/// Run with no arguments to to show diff between oracle_config.yaml and oracle_config_updated.yaml
/// Updated config file must be created using --prepare-update command first
UpdatePool {
/// New pool box hash. Must match hash of updated pool contract
new_pool_box_hash: Option<String>,
/// New reward token id (optional)
reward_token_id: Option<String>,
/// New reward token amount, required if new token id was voted for
reward_token_amount: Option<u64>,
height: Option<u64>,
},
/// Prepare updating oracle pool with new contracts/parameters.
PrepareUpdate {
update_bootstrap_file: String,
/// Name of update parameters file (.yaml)
update_file: String,
},
}

Expand Down Expand Up @@ -255,24 +258,20 @@ fn main() {
new_pool_box_hash,
reward_token_id,
reward_token_amount,
height,
} => {
assert_wallet_unlocked(&new_node_interface());
if let Err(e) = cli_commands::update_pool::update_pool(
new_pool_box_hash,
reward_token_id,
reward_token_amount,
height,
) {
error!("Fatal update-pool error: {}", e);
std::process::exit(exitcode::SOFTWARE);
}
}
Command::PrepareUpdate {
update_bootstrap_file,
} => {
Command::PrepareUpdate { update_file } => {
assert_wallet_unlocked(&new_node_interface());
if let Err(e) = cli_commands::update::prepare_update(update_bootstrap_file) {
if let Err(e) = cli_commands::update::prepare_update(update_file) {
error!("Fatal update error : {}", e);
std::process::exit(exitcode::SOFTWARE);
}
Expand Down

0 comments on commit 174dd84

Please sign in to comment.