Skip to content

Commit 19257b3

Browse files
mikemaccanaclaude
andcommitted
Fix Anchor and Quasar CI failures
- Fix default-account-state quasar: revert InitializeMint2 to 67 bytes (1-byte COption flag, not 4-byte LE u32) and correct mint_size to 171 (165 base + 1 account_type + 4 TLV header + 1 extension data) - Fix transfer-fee anchor: handle_check_mint_data takes &Initialize not &mut Initialize since it only reads data - Fix CPI anchor test: use CARGO_MANIFEST_DIR for absolute path to lever.so instead of relative path from package root - Add tokens/spl-token-minter/quasar to .ghaignore (no Quasar.toml) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 4d665cd commit 19257b3

4 files changed

Lines changed: 13 additions & 11 deletions

File tree

  • .github
  • basics/cross-program-invocation/anchor/programs/hand/tests
  • tokens/token-2022
    • default-account-state/quasar/src
    • transfer-fee/anchor/programs/transfer-fee/src/instructions

.github/.ghaignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ tokens/token-2022/group/quasar
3434
# CPI quasar project uses subdirectories (hand/ and lever/) instead of a root Quasar.toml
3535
basics/cross-program-invocation/quasar
3636

37+
# has Cargo.toml but no Quasar.toml
38+
tokens/spl-token-minter/quasar
39+
3740
# error in tests
3841
tokens/external-delegate-token-master/anchor
3942

basics/cross-program-invocation/anchor/programs/hand/tests/test_hand.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ fn test_pull_lever_cpi() {
5454
// include_bytes!() runs at compile time, and during `anchor build` the IDL generation
5555
// step compiles tests before the .so files exist. Since this is a cross-program
5656
// dependency (not our own program), lever.so may not be built yet at compile time.
57-
let lever_bytes = std::fs::read("target/deploy/lever.so")
57+
let lever_bytes = std::fs::read(concat!(env!("CARGO_MANIFEST_DIR"), "/../../target/deploy/lever.so"))
5858
.expect("lever.so not found — run `anchor build` first");
5959
svm.add_program(hand_program_id, hand_bytes).unwrap();
6060
svm.add_program(lever_program_id, &lever_bytes).unwrap();

tokens/token-2022/default-account-state/quasar/src/lib.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ pub struct Initialize<'info> {
5656

5757
#[inline(always)]
5858
pub fn handle_initialize(accounts: &Initialize) -> Result<(), ProgramError> {
59-
// Mint + DefaultAccountState extension = 234 bytes
60-
let mint_size: u64 = 234;
59+
// 165 (base account) + 1 (account type) + 4 (TLV header) + 1 (DefaultAccountState data) = 171 bytes
60+
let mint_size: u64 = 171;
6161
let lamports = Rent::get()?.try_minimum_balance(mint_size as usize)?;
6262

6363
// 1. Create account owned by Token-2022
@@ -85,15 +85,14 @@ pub fn handle_initialize(accounts: &Initialize) -> Result<(), ProgramError> {
8585
.invoke()?;
8686

8787
// 3. InitializeMint2: opcode 20, decimals, mint_authority, freeze_authority_option, freeze_authority
88-
// COption<Pubkey> is encoded as 4-byte little-endian tag (1 = Some, 0 = None) + 32-byte pubkey
89-
// Total: 1 (opcode) + 1 (decimals) + 32 (mint_authority) + 4 (COption tag) + 32 (freeze_authority) = 70 bytes
90-
let mut mint_data = [0u8; 70];
88+
// COption<Pubkey> is encoded as 1-byte flag (1 = Some, 0 = None) + 32-byte pubkey
89+
// Total: 1 (opcode) + 1 (decimals) + 32 (mint_authority) + 1 (COption flag) + 32 (freeze_authority) = 67 bytes
90+
let mut mint_data = [0u8; 67];
9191
mint_data[0] = 20; // InitializeMint2
9292
mint_data[1] = 2; // decimals
9393
mint_data[2..34].copy_from_slice(accounts.payer.to_account_view().address().as_ref());
94-
mint_data[34] = 1; // COption::Some discriminant (4-byte little-endian u32 = [1, 0, 0, 0])
95-
// mint_data[35..38] = [0, 0, 0] — already zeroed, completing 4-byte COption tag
96-
mint_data[38..70].copy_from_slice(accounts.payer.to_account_view().address().as_ref());
94+
mint_data[34] = 1; // COption::Some flag (1-byte format used by quasar-svm token-2022)
95+
mint_data[35..67].copy_from_slice(accounts.payer.to_account_view().address().as_ref());
9796

9897
CpiCall::new(
9998
accounts.token_program.to_account_view().address(),

tokens/token-2022/transfer-fee/anchor/programs/transfer-fee/src/instructions/initialize.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,12 @@ pub fn handle_process_initialize(
8787
Some(&context.accounts.payer.key()), // freeze authority
8888
)?;
8989

90-
handle_check_mint_data(&mut context.accounts)?;
90+
handle_check_mint_data(&context.accounts)?;
9191
Ok(())
9292
}
9393

9494
// helper to demonstrate how to read mint extension data within a program
95-
pub fn handle_check_mint_data(accounts: &mut Initialize) -> Result<()> {
95+
pub fn handle_check_mint_data(accounts: &Initialize) -> Result<()> {
9696
let mint = &accounts.mint_account.to_account_info();
9797
let mint_data = mint.data.borrow();
9898
let mint_with_extension = StateWithExtensions::<MintState>::unpack(&mint_data)?;

0 commit comments

Comments
 (0)