todo.js:250 Error marking todo: SendTransactionError: Simulation failed. Error marking todo: SendTransactionError: Simulation failed. Message: Transaction simulation failed: Error processing Instruction 2: custom program error: 0x1773. Logs: [ "Program ComputeBudget111111111111111111111111111111 success", "Program ComputeBudget111111111111111111111111111111 invoke [1]", "Program ComputeBudget111111111111111111111111111111 success", "Program Z2DbEnaeMcFaiaMa43ikadWefUAfCdjjyV5QgoWdQyu invoke [1]", "Program log: Instruction: MarkTodo", "Program log: Marking todo with index: 0", "Program log: Todo marked status before: true", "Program log: AnchorError thrown in 93aa751f-44d8-495b-97ab-93acfd6604df/src/lib.rs:51. Error Code: AlreadyMarked. Error Number: 6003. Error Message: Already marked.", "Program Z2DbEnaeMcFaiaMa43ikadWefUAfCdjjyV5QgoWdQyu consumed 9121 of 199700 compute units", "Program Z2DbEnaeMcFaiaMa43ikadWefUAfCdjjyV5QgoWdQyu failed: custom program error: 0x1773" ]. Catch the
SendTransactionErrorand call
getLogs() on it for full details. at Connection.sendEncodedTransaction (index.browser.esm.js:7525:13) at async Connection.sendRawTransaction (index.browser.esm.js:7490:20) at async sendAndConfirmRawTransaction (index.js:1122:23) at async AnchorProvider.sendAndConfirm (index.js:1012:20) at async markTodo (todo.js:243:31)
lib.rs
pub fn mark_todo(ctx: Context<MarkTodo>, _todo_idx: u8) -> Result<()> { let todo_account = &mut ctx.accounts.todo_account; // Log the current status of the TODO for debugging msg!("Marking todo with index: {}", _todo_idx); msg!("Todo marked status before: {}", todo_account.marked); // Check if the TODO is already marked require!(!todo_account.marked, TodoError::AlreadyMarked); // Mark the todo todo_account.marked = true; // Log the status after marking msg!("Todo marked successfully."); msg!("Todo marked status after: {}", todo_account.marked); Ok(()) } pub fn remove_todo(ctx: Context<RemoveTodo>, _todo_idx: u8) -> Result<()> { // Fetch the user profile account let user_profile = &mut ctx.accounts.user_profile; // Ensure there are todos to remove require!(user_profile.todo_count > 0, TodoError::NoTodos); // Safely decrease total todo count user_profile.todo_count = user_profile.todo_count.checked_sub(1).unwrap(); // Log removal action for debugging purposes msg!("Todo with index {} removed successfully. New todo count: {}", _todo_idx, user_profile.todo_count ); // PDA for the todo_account is closed automatically in the context, no explicit closure needed Ok(()) } ```