Skip to content

Commit 4ddc13e

Browse files
authored
Update lib.rs (#1434)
1 parent 375acd5 commit 4ddc13e

File tree

1 file changed

+1
-46
lines changed
  • rust/nft-candy-machine/src

1 file changed

+1
-46
lines changed

rust/nft-candy-machine/src/lib.rs

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -234,51 +234,6 @@ pub mod nft_candy_machine {
234234

235235
pub fn initialize_config(ctx: Context<InitializeConfig>, data: ConfigData) -> ProgramResult {
236236
return Err(ErrorCode::Deprecated.into());
237-
238-
let config_info = &mut ctx.accounts.config;
239-
if data.uuid.len() != 6 {
240-
return Err(ErrorCode::UuidMustBeExactly6Length.into());
241-
}
242-
243-
let mut config = Config {
244-
data,
245-
authority: *ctx.accounts.authority.key,
246-
};
247-
248-
let mut array_of_zeroes = vec![];
249-
while array_of_zeroes.len() < MAX_SYMBOL_LENGTH - config.data.symbol.len() {
250-
array_of_zeroes.push(0u8);
251-
}
252-
let new_symbol =
253-
config.data.symbol.clone() + std::str::from_utf8(&array_of_zeroes).unwrap();
254-
config.data.symbol = new_symbol;
255-
256-
// - 1 because we are going to be a creator
257-
if config.data.creators.len() > MAX_CREATOR_LIMIT - 1 {
258-
return Err(ErrorCode::TooManyCreators.into());
259-
}
260-
261-
let mut new_data = Config::discriminator().try_to_vec().unwrap();
262-
new_data.append(&mut config.try_to_vec().unwrap());
263-
let mut data = config_info.data.borrow_mut();
264-
// god forgive me couldnt think of better way to deal with this
265-
for i in 0..new_data.len() {
266-
data[i] = new_data[i];
267-
}
268-
269-
let vec_start =
270-
CONFIG_ARRAY_START + 4 + (config.data.max_number_of_lines as usize) * CONFIG_LINE_SIZE;
271-
let as_bytes = (config
272-
.data
273-
.max_number_of_lines
274-
.checked_div(8)
275-
.ok_or(ErrorCode::NumericalOverflowError)? as u32)
276-
.to_le_bytes();
277-
for i in 0..4 {
278-
data[vec_start + i] = as_bytes[i]
279-
}
280-
281-
Ok(())
282237
}
283238

284239
pub fn add_config_lines(
@@ -466,7 +421,7 @@ pub struct InitializeCandyMachine<'info> {
466421
#[derive(Accounts)]
467422
#[instruction(data: ConfigData)]
468423
pub struct InitializeConfig<'info> {
469-
#[account(mut, constraint= config.to_account_info().owner == program_id && config.to_account_info().data_len() >= CONFIG_ARRAY_START+4+(data.max_number_of_lines as usize)*CONFIG_LINE_SIZE + 4 + (data.max_number_of_lines.checked_div(8).ok_or(ErrorCode::NumericalOverflowError)? as usize))]
424+
#[account(zero, constraint= config.to_account_info().owner == program_id && config.to_account_info().data_len() >= CONFIG_ARRAY_START+4+(data.max_number_of_lines as usize)*CONFIG_LINE_SIZE + 4 + (data.max_number_of_lines.checked_div(8).ok_or(ErrorCode::NumericalOverflowError)? as usize))]
470425
config: AccountInfo<'info>,
471426
#[account(constraint= authority.data_is_empty() && authority.lamports() > 0 )]
472427
authority: AccountInfo<'info>,

0 commit comments

Comments
 (0)