Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub trait InstructionDiscriminator {
pub trait LightInstructionData: InstructionDiscriminator + AnchorSerialize {
#[cfg(feature = "alloc")]
#[profile]
#[inline(never)]
fn data(&self) -> Result<crate::Vec<u8>, CompressedAccountError> {
let inputs = AnchorSerialize::try_to_vec(self)
.map_err(|_| CompressedAccountError::InvalidArgument)?;
Expand Down
2 changes: 1 addition & 1 deletion sdk-libs/compressible-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ pub mod compressible_instruction {
"Tree info index out of bounds - compressed_accounts length must match validity proof accounts length",
)?;

let packed_data = data.pack(&mut remaining_accounts);
let packed_data = data.pack(&mut remaining_accounts)?;
typed_compressed_accounts.push(CompressedAccountData {
meta: CompressedAccountMetaNoLamportsNoAddress {
tree_info,
Expand Down
51 changes: 51 additions & 0 deletions sdk-libs/macros/docs/accounts/light_mint.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,57 @@ pub struct CreateMint<'info> {
| `rent_payment` | Expression | `2u8` | Rent payment epochs for decompression. |
| `write_top_up` | Expression | `0u32` | Write top-up lamports for decompression. |

## TokenMetadata Fields

Optional fields for creating a mint with the TokenMetadata extension:

| Attribute | Type | Default | Description |
|-----------|------|---------|-------------|
| `name` | Expression | - | Token name (expression yielding `Vec<u8>`). |
| `symbol` | Expression | - | Token symbol (expression yielding `Vec<u8>`). |
| `uri` | Expression | - | Token URI (expression yielding `Vec<u8>`). |
| `update_authority` | Field reference | None | Optional update authority for metadata. |
| `additional_metadata` | Expression | None | Additional key-value metadata (expression yielding `Option<Vec<AdditionalMetadata>>`). |

### Validation Rules

1. **Core fields are all-or-nothing**: `name`, `symbol`, and `uri` must ALL be specified together, or none at all.
2. **Optional fields require core fields**: `update_authority` and `additional_metadata` require `name`, `symbol`, and `uri` to also be specified.

### Metadata Example

```rust
#[light_mint(
mint_signer = mint_signer,
authority = fee_payer,
decimals = 9,
mint_seeds = &[SEED, self.authority.key().as_ref(), &[params.bump]],
// TokenMetadata fields
name = params.name.clone(),
symbol = params.symbol.clone(),
uri = params.uri.clone(),
update_authority = authority,
additional_metadata = params.additional_metadata.clone()
)]
pub cmint: UncheckedAccount<'info>,
```

**Invalid configurations (compile-time errors):**

```rust
// ERROR: name without symbol and uri
#[light_mint(
...,
name = params.name.clone()
)]

// ERROR: additional_metadata without name, symbol, uri
#[light_mint(
...,
additional_metadata = params.additional_metadata.clone()
)]
```

## How It Works

### Mint PDA Derivation
Expand Down
Loading