Skip to content
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ node_modules/

/target
deploy
.claude
2 changes: 1 addition & 1 deletion basics/account-data/quasar/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ client = []
debug = []

[dependencies]
quasar-lang = "0.0"
quasar-lang = { git = "https://github.com/blueshift-gg/quasar", branch = "master" }
solana-instruction = { version = "3.2.0" }

[dev-dependencies]
Expand Down
13 changes: 7 additions & 6 deletions basics/account-data/quasar/src/instructions/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@ use {
/// Dynamic accounts use owned `Account<T>` rather than `&'info mut Account<T>` because
/// dynamic types carry cached byte offsets that cannot be represented as a pointer cast.
#[derive(Accounts)]
pub struct CreateAddressInfo<'info> {
pub struct CreateAddressInfo {
#[account(mut)]
pub payer: &'info mut Signer,
#[account(mut, init, payer = payer, seeds = [b"address_info", payer], bump)]
pub address_info: Account<AddressInfo<'info>>,
pub system_program: &'info Program<System>,
pub payer: Signer,
#[account(mut, init, payer = payer, seeds = AddressInfo::seeds(payer), bump)]
pub address_info: Account<AddressInfo<'_>>,
pub system_program: Program<System>,
}

#[inline(always)]
pub fn handle_create_address_info(
accounts: &mut CreateAddressInfo, name: &str,
accounts: &mut CreateAddressInfo,
name: &str,
house_number: u8,
street: &str,
city: &str,
Expand Down
1 change: 1 addition & 0 deletions basics/account-data/quasar/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use quasar_lang::prelude::*;
///
/// Note: Quasar requires all fixed-size fields to precede dynamic (String/Vec) fields.
#[account(discriminator = 1)]
#[seeds(b"address_info", payer: Address)]
pub struct AddressInfo<'a> {
pub house_number: u8,
pub name: String<u8, 50>,
Expand Down
2 changes: 1 addition & 1 deletion basics/checking-accounts/quasar/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ client = []
debug = []

[dependencies]
quasar-lang = "0.0"
quasar-lang = { git = "https://github.com/blueshift-gg/quasar", branch = "master" }
solana-instruction = { version = "3.2.0" }

[dev-dependencies]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ use quasar_lang::prelude::*;
/// Note: Anchor's `#[account(owner = id())]` owner constraint is not directly available
/// in Quasar. Owner checks can be done manually in the instruction body if needed.
#[derive(Accounts)]
pub struct CheckAccounts<'info> {
pub struct CheckAccounts {
/// Checks that this account signed the transaction.
pub payer: &'info Signer,
pub payer: Signer,
/// No checks performed — the caller is responsible for validation.
#[account(mut)]
pub account_to_create: &'info mut UncheckedAccount,
pub account_to_create: UncheckedAccount,
/// No automatic owner check in Quasar; see note above.
#[account(mut)]
pub account_to_change: &'info mut UncheckedAccount,
pub account_to_change: UncheckedAccount,
/// Checks the account is executable and matches the system program address.
pub system_program: &'info Program<System>,
pub system_program: Program<System>,
}

#[inline(always)]
pub fn handle_check_accounts(accounts: &CheckAccounts) -> Result<(), ProgramError> {
pub fn handle_check_accounts(_accounts: &mut CheckAccounts) -> Result<(), ProgramError> {
// All validation happens declaratively via the account types above.
// If any check fails, the runtime rejects the transaction before this runs.
Ok(())
Expand Down
2 changes: 1 addition & 1 deletion basics/close-account/quasar/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ client = []
debug = []

[dependencies]
quasar-lang = "0.0"
quasar-lang = { git = "https://github.com/blueshift-gg/quasar", branch = "master" }
solana-instruction = { version = "3.2.0" }

[dev-dependencies]
Expand Down
6 changes: 3 additions & 3 deletions basics/close-account/quasar/src/instructions/close_user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ use {
/// In Quasar, we call `close()` explicitly — it zeros the discriminator, drains lamports
/// to the destination, reassigns the owner to the system program, and resizes to 0.
#[derive(Accounts)]
pub struct CloseUser<'info> {
pub struct CloseUser {
#[account(mut)]
pub user: &'info mut Signer,
pub user: Signer,
#[account(mut)]
pub user_account: Account<UserState<'info>>,
pub user_account: Account<UserState<'_>>,
}

#[inline(always)]
Expand Down
10 changes: 5 additions & 5 deletions basics/close-account/quasar/src/instructions/create_user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ use {

/// Accounts for creating a new user.
#[derive(Accounts)]
pub struct CreateUser<'info> {
pub struct CreateUser {
#[account(mut)]
pub user: &'info mut Signer,
#[account(mut, init, payer = user, seeds = [b"USER", user], bump)]
pub user_account: Account<UserState<'info>>,
pub system_program: &'info Program<System>,
pub user: Signer,
#[account(mut, init, payer = user, seeds = UserState::seeds(user), bump)]
pub user_account: Account<UserState<'_>>,
pub system_program: Program<System>,
}

#[inline(always)]
Expand Down
3 changes: 2 additions & 1 deletion basics/close-account/quasar/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ use quasar_lang::prelude::*;

/// User account with a dynamic name field.
/// Fixed fields (bump, user) must precede dynamic fields (name).
#[account(discriminator = 1)]
#[account(discriminator = 1, set_inner)]
#[seeds(b"USER", user: Address)]
pub struct UserState<'a> {
pub bump: u8,
pub user: Address,
Expand Down
2 changes: 1 addition & 1 deletion basics/counter/quasar/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ client = []
debug = []

[dependencies]
quasar-lang = "0.0"
quasar-lang = { git = "https://github.com/blueshift-gg/quasar", branch = "master" }
solana-instruction = { version = "3.2.0" }

[dev-dependencies]
Expand Down
4 changes: 2 additions & 2 deletions basics/counter/quasar/src/instructions/increment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ use {

/// Accounts for incrementing a counter.
#[derive(Accounts)]
pub struct Increment<'info> {
pub struct Increment {
#[account(mut)]
pub counter: &'info mut Account<Counter>,
pub counter: Account<Counter>,
}

#[inline(always)]
Expand Down
10 changes: 5 additions & 5 deletions basics/counter/quasar/src/instructions/initialize_counter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ use {
/// Accounts for creating a new counter.
/// The counter is derived as a PDA from ["counter", payer] seeds.
#[derive(Accounts)]
pub struct InitializeCounter<'info> {
pub struct InitializeCounter {
#[account(mut)]
pub payer: &'info mut Signer,
#[account(mut, init, payer = payer, seeds = [b"counter", payer], bump)]
pub counter: &'info mut Account<Counter>,
pub system_program: &'info Program<System>,
pub payer: Signer,
#[account(mut, init, payer = payer, seeds = Counter::seeds(payer), bump)]
pub counter: Account<Counter>,
pub system_program: Program<System>,
}

#[inline(always)]
Expand Down
1 change: 1 addition & 0 deletions basics/counter/quasar/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use quasar_lang::prelude::*;

/// Onchain counter account.
#[account(discriminator = 1)]
#[seeds(b"counter", payer: Address)]
pub struct Counter {
pub count: u64,
}
2 changes: 1 addition & 1 deletion basics/create-account/quasar/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ client = []
debug = []

[dependencies]
quasar-lang = "0.0"
quasar-lang = { git = "https://github.com/blueshift-gg/quasar", branch = "master" }
solana-instruction = { version = "3.2.0" }

[dev-dependencies]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@ use quasar_lang::prelude::*;
/// Accounts for creating a new system-owned account.
/// Both payer and new_account must sign the transaction.
#[derive(Accounts)]
pub struct CreateSystemAccount<'info> {
pub struct CreateSystemAccount {
#[account(mut)]
pub payer: &'info Signer,
pub payer: Signer,
#[account(mut)]
pub new_account: &'info Signer,
pub system_program: &'info Program<System>,
pub new_account: Signer,
pub system_program: Program<System>,
}

#[inline(always)]
pub fn handle_create_system_account(accounts: &CreateSystemAccount) -> Result<(), ProgramError> {
pub fn handle_create_system_account(accounts: &mut CreateSystemAccount) -> Result<(), ProgramError> {
// Create a zero-data account owned by the system program,
// funded with the minimum rent-exempt balance.
let system_program_address = Address::default();
accounts.system_program
.create_account_with_minimum_balance(
accounts.payer,
accounts.new_account,
&accounts.payer,
&accounts.new_account,
0, // space: zero bytes of data
&system_program_address,
None, // fetch Rent sysvar automatically
Expand Down
2 changes: 1 addition & 1 deletion basics/cross-program-invocation/quasar/hand/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ client = []
debug = []

[dependencies]
quasar-lang = "0.0"
quasar-lang = { git = "https://github.com/blueshift-gg/quasar", branch = "master" }
solana-instruction = { version = "3.2.0" }

[dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion basics/cross-program-invocation/quasar/lever/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ client = []
debug = []

[dependencies]
quasar-lang = "0.0"
quasar-lang = { git = "https://github.com/blueshift-gg/quasar", branch = "master" }
solana-instruction = { version = "3.2.0" }

[dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion basics/favorites/quasar/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ client = []
debug = []

[dependencies]
quasar-lang = "0.0"
quasar-lang = { git = "https://github.com/blueshift-gg/quasar", branch = "master" }
solana-instruction = { version = "3.2.0" }

[dev-dependencies]
Expand Down
10 changes: 5 additions & 5 deletions basics/favorites/quasar/src/instructions/set_favorites.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ use {
/// Accounts for setting user favourites. Uses `init_if_needed` so the same
/// instruction can create or update the favourites PDA.
#[derive(Accounts)]
pub struct SetFavorites<'info> {
pub struct SetFavorites {
#[account(mut)]
pub user: &'info mut Signer,
#[account(mut, init_if_needed, payer = user, seeds = [b"favorites", user], bump)]
pub favorites: Account<Favorites<'info>>,
pub system_program: &'info Program<System>,
pub user: Signer,
#[account(mut, init_if_needed, payer = user, seeds = Favorites::seeds(user), bump)]
pub favorites: Account<Favorites<'_>>,
pub system_program: Program<System>,
}

#[inline(always)]
Expand Down
1 change: 1 addition & 0 deletions basics/favorites/quasar/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use quasar_lang::prelude::*;
/// support nested dynamic types (Vec<String>). We keep number + color, which
/// demonstrates fixed + dynamic field mixing in Quasar.
#[account(discriminator = 1)]
#[seeds(b"favorites", user: Address)]
pub struct Favorites<'a> {
pub number: u64,
pub color: String<u8, 50>,
Expand Down
2 changes: 1 addition & 1 deletion basics/hello-solana/quasar/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ client = []
debug = []

[dependencies]
quasar-lang = "0.0"
quasar-lang = { git = "https://github.com/blueshift-gg/quasar", branch = "master" }
solana-instruction = { version = "3.2.0" }

[dev-dependencies]
Expand Down
6 changes: 3 additions & 3 deletions basics/hello-solana/quasar/src/instructions/hello.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ use quasar_lang::prelude::*;
/// A payer (signer) is required to submit the transaction, but the program
/// simply logs a greeting and the program ID.
#[derive(Accounts)]
pub struct Hello<'info> {
pub struct Hello {
#[allow(dead_code)]
pub payer: &'info Signer,
pub payer: Signer,
}

#[inline(always)]
pub fn handle_hello(accounts: &Hello) -> Result<(), ProgramError> {
pub fn handle_hello(_accounts: &mut Hello) -> Result<(), ProgramError> {
log("Hello, Solana!");
log("Our program's Program ID: FLUH9c5oAfXb1eYbkZvdGK9r9SLQJBUi2DZQaBVj7Tzr");
Ok(())
Expand Down
2 changes: 1 addition & 1 deletion basics/pda-rent-payer/quasar/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ client = []
debug = []

[dependencies]
quasar-lang = "0.0"
quasar-lang = { git = "https://github.com/blueshift-gg/quasar", branch = "master" }
solana-instruction = { version = "3.2.0" }

[dev-dependencies]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ use quasar_lang::prelude::*;
/// Accounts for creating a new account funded by the rent vault PDA.
/// The rent vault signs the create_account CPI via PDA seeds.
#[derive(Accounts)]
pub struct CreateNewAccount<'info> {
pub struct CreateNewAccount {
#[account(mut)]
pub new_account: &'info Signer,
pub new_account: Signer,
#[account(mut, seeds = [b"rent_vault"], bump)]
pub rent_vault: &'info mut UncheckedAccount,
pub system_program: &'info Program<System>,
pub rent_vault: UncheckedAccount,
pub system_program: Program<System>,
}

#[inline(always)]
pub fn handle_create_new_account(accounts: &CreateNewAccount, rent_vault_bump: u8) -> Result<(), ProgramError> {
pub fn handle_create_new_account(accounts: &mut CreateNewAccount, rent_vault_bump: u8) -> Result<(), ProgramError> {
// Build PDA signer seeds: ["rent_vault", bump].
let bump_bytes = [rent_vault_bump];
let seeds: &[Seed] = &[
Expand All @@ -25,8 +25,8 @@ pub fn handle_create_new_account(accounts: &CreateNewAccount, rent_vault_bump: u
// Create a zero-data system-owned account, funded from the vault.
accounts.system_program
.create_account_with_minimum_balance(
accounts.rent_vault,
accounts.new_account,
&accounts.rent_vault,
&accounts.new_account,
0, // space: zero bytes of data
&system_program_address,
None, // fetch Rent sysvar automatically
Expand Down
12 changes: 6 additions & 6 deletions basics/pda-rent-payer/quasar/src/instructions/init_rent_vault.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ use quasar_lang::prelude::*;
/// When lamports are sent to a new address, the system program creates
/// a system-owned account automatically.
#[derive(Accounts)]
pub struct InitRentVault<'info> {
pub struct InitRentVault {
#[account(mut)]
pub payer: &'info Signer,
pub payer: Signer,
#[account(mut, seeds = [b"rent_vault"], bump)]
pub rent_vault: &'info mut UncheckedAccount,
pub system_program: &'info Program<System>,
pub rent_vault: UncheckedAccount,
pub system_program: Program<System>,
}

#[inline(always)]
pub fn handle_init_rent_vault(accounts: &InitRentVault, fund_lamports: u64) -> Result<(), ProgramError> {
pub fn handle_init_rent_vault(accounts: &mut InitRentVault, fund_lamports: u64) -> Result<(), ProgramError> {
accounts.system_program
.transfer(accounts.payer, accounts.rent_vault, fund_lamports)
.transfer(&accounts.payer, &accounts.rent_vault, fund_lamports)
.invoke()
}
2 changes: 1 addition & 1 deletion basics/processing-instructions/quasar/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ client = []
debug = []

[dependencies]
quasar-lang = "0.0"
quasar-lang = { git = "https://github.com/blueshift-gg/quasar", branch = "master" }
solana-instruction = { version = "3.2.0" }

[dev-dependencies]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ use quasar_lang::prelude::*;
/// Minimal accounts context — a signer is needed to submit the transaction.
/// The instruction just processes instruction data (name + height).
#[derive(Accounts)]
pub struct Park<'info> {
pub struct Park {
#[allow(dead_code)]
pub signer: &'info Signer,
pub signer: Signer,
}

#[inline(always)]
pub fn handle_go_to_park(accounts: &Park, _name: &str, height: u32) -> Result<(), ProgramError> {
pub fn handle_go_to_park(_accounts: &mut Park, _name: &str, height: u32) -> Result<(), ProgramError> {
// Quasar's `log()` takes &str, no format! macro available in no_std.
// We can't interpolate the name or height into the log message, so
// we use static messages — same logic as the Anchor version, just
Expand Down
Loading