Skip to content

Commit

Permalink
initial
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkSackerberg committed Sep 16, 2024
1 parent 31867a6 commit 34cf6d1
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 5 deletions.
21 changes: 17 additions & 4 deletions src/deploy/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,18 +92,31 @@ pub async fn process_deploy(args: DeployArgs) -> Result<()> {

let cache_items_sans_collection = (cache.items.len() - collection_in_cache as usize) as u64;

if num_items != cache_items_sans_collection {
if !hidden && num_items != cache_items_sans_collection {
return Err(anyhow!(
"Number of items ({}) do not match cache items ({}).
Item number in the config should only include asset files, not the collection file.",
num_items,
cache_items_sans_collection
));
} else {
check_symbol(&config_data.symbol)?;
check_seller_fee_basis_points(config_data.seller_fee_basis_points)?;
} else if hidden && num_items != cache_items_sans_collection {
println!(
"{}",
style(format!(
"Warning: Number of items ({}) do not match cache items ({}).
{} items are missing. Revealing will not work correctly.",
num_items,
cache_items_sans_collection,
num_items.saturating_sub(cache_items_sans_collection)
))
.yellow()
.bold()
);
}

check_symbol(&config_data.symbol)?;
check_seller_fee_basis_points(config_data.seller_fee_basis_points)?;

let total_steps = 2 + if candy_machine_address.is_empty() {
collection_in_cache as u8
} else {
Expand Down
28 changes: 27 additions & 1 deletion src/reveal/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,39 @@ pub async fn process_reveal(args: RevealArgs) -> Result<()> {
let config = get_config_data(&args.config)?;

// If it's not a Hidden Settings mint, return an error.
let hidden_settings = if let Some(settings) = config.hidden_settings {
let hidden_settings = if let Some(ref settings) = config.hidden_settings {
settings
} else {
return Err(anyhow!("Candy machine is not a Hidden Settings mint."));
};

let cache = load_cache(&args.cache, false)?;

// Check if the cache file is incomplete
let num_items = config.number;
let hidden = config.hidden_settings.is_some();
let collection_in_cache = cache.items.get("-1").is_some();
let cache_items_sans_collection = (cache.items.len() - collection_in_cache as usize) as u64;

if hidden && num_items != cache_items_sans_collection {
let warning = format!(
"+---------------------------------+\n\
{} {} ITEMS MISSING IN CACHE FILE! \n\
+---------------------------------+",
WARNING_EMOJI,
num_items.saturating_sub(cache_items_sans_collection)
);
println!(
"\n{}\n{}\n",
style(warning).bold().yellow(),
style(
" Revealing might fail. \
It is recommended to run 'sugar upload' again.",
)
.italic()
.yellow()
)
}
let sugar_config = sugar_setup(args.keypair, args.rpc_url.clone())?;
let anchor_client = setup_client(&sugar_config)?;
let program = anchor_client.program(CANDY_MACHINE_ID);
Expand Down

0 comments on commit 34cf6d1

Please sign in to comment.