Skip to content

Commit

Permalink
Merge pull request #302 from ergoplatform/i301-unknown-refresh-nft
Browse files Browse the repository at this point in the history
Add check for pool box before running import-pool-update command
  • Loading branch information
greenhat authored Jul 12, 2023
2 parents cfe29e2 + 14d658b commit 907da38
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 6 additions & 3 deletions core/src/contracts/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ pub struct PoolContract {
pub enum PoolContractError {
#[error("pool contract: parameter error: {0}")]
ParametersError(#[from] PoolContractParametersError),
#[error("pool contract: unknown refresh NFT in box")]
UnknownRefreshNftId,
#[error("pool contract: unknown refresh NFT in box: expected {expected}, actual {actual}")]
UnknownRefreshNftId { expected: String, actual: String },
#[error("pool contract: unknown update NFT in box")]
UnknownUpdateNftId,
#[error("pool contract: sigma parsing error {0}")]
Expand Down Expand Up @@ -129,7 +129,10 @@ impl PoolContract {
))?
.try_extract_into::<TokenId>()?;
if refresh_nft_token_id != inputs.refresh_nft_token_id.token_id() {
return Err(PoolContractError::UnknownRefreshNftId);
return Err(PoolContractError::UnknownRefreshNftId {
expected: inputs.refresh_nft_token_id.token_id().into(),
actual: refresh_nft_token_id.into(),
});
}

let update_nft_token_id = ergo_tree
Expand Down
4 changes: 4 additions & 0 deletions core/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,10 @@ fn handle_pool_command(command: Command, node_api: &NodeApi, network_prefix: Net
}
}
Command::ImportPoolUpdate { pool_config_file } => {
if op.get_pool_box_source().get_pool_box().is_ok() {
error!("Seems like update-pool command is missing (pool box is found).");
std::process::exit(exitcode::SOFTWARE);
}
if let Err(e) = cli_commands::import_pool_update::import_pool_update(
pool_config_file,
&POOL_CONFIG.token_ids.oracle_token_id,
Expand Down

0 comments on commit 907da38

Please sign in to comment.