Skip to content

Commit 5dab3ae

Browse files
mikemaccanaclaude
andcommitted
Fix metadata MetadataPointerInstruction: use OptionalNonZeroPubkey (66 bytes)
token-2022-v7.0.0 uses OptionalNonZeroPubkey (32-byte raw pubkey, not COption/PodCOption flags) for both authority and metadata_address fields. Correct format: [39, 0, authority(32), metadata_address(32)] = 66 bytes. Previous attempts with 68 bytes (1-byte flags) and 74 bytes (4-byte PodCOption flags) both fail because the struct expects exactly 64 bytes of payload after the 2-byte header. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 6049b57 commit 5dab3ae

1 file changed

Lines changed: 5 additions & 9 deletions

File tree

  • tokens/token-2022/metadata/quasar/src

tokens/token-2022/metadata/quasar/src/lib.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,17 +99,13 @@ pub fn handle_initialize(
9999
.invoke()?;
100100

101101
// InitializeMetadataPointer: opcode 39, sub-opcode 0.
102-
// Uses PodCOption<Pubkey> encoding: 4-byte LE flag + 32-byte pubkey = 36 bytes each.
103-
// Layout: [39, 0, 1,0,0,0, authority(32), 1,0,0,0, metadata_address(32)] = 74 bytes
104-
let mut mp_data = [0u8; 74];
102+
// Uses OptionalNonZeroPubkey (32 bytes each, all-zeros = None).
103+
// Layout: [39, 0, authority(32), metadata_address(32)] = 66 bytes
104+
let mut mp_data = [0u8; 66];
105105
mp_data[0] = 39;
106106
mp_data[1] = 0;
107-
mp_data[2] = 1; // PodCOption::Some flag (4-byte LE: [1,0,0,0])
108-
// mp_data[3..6] already zero
109-
mp_data[6..38].copy_from_slice(accounts.payer.to_account_view().address().as_ref());
110-
mp_data[38] = 1; // PodCOption::Some flag (4-byte LE: [1,0,0,0])
111-
// mp_data[39..42] already zero
112-
mp_data[42..74]
107+
mp_data[2..34].copy_from_slice(accounts.payer.to_account_view().address().as_ref());
108+
mp_data[34..66]
113109
.copy_from_slice(accounts.mint_account.to_account_view().address().as_ref());
114110

115111
CpiCall::new(

0 commit comments

Comments
 (0)