Skip to content

Commit 1a8ca59

Browse files
authored
Merge pull request #11 from mikemaccana-edwardbot/quasar-full-api-update
fix: migrate all quasar examples to current Quasar API (PR solana-developers#195 + solana-developers#196)
2 parents d51ad9e + 44f2dbd commit 1a8ca59

98 files changed

Lines changed: 695 additions & 299 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/.ghaignore

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,7 @@ tokens/token-extensions/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-
tokens/external-delegate-token-master/quasar
40-
tokens/nft-minter/quasar
41-
tokens/nft-operations/quasar
42-
tokens/token-swap/quasar
43-
44-
# build failed - outdated quasar-lang API (no AccountView.data, no log_64)
45-
oracles/pyth/quasar
37+
4638

4739
# error in tests
4840
tokens/external-delegate-token-master/anchor

.github/workflows/quasar.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,16 @@ jobs:
199199
with:
200200
solana-cli-version: stable
201201
- name: Install Quasar CLI
202-
run: cargo install --git https://github.com/blueshift-gg/quasar quasar-cli --locked
202+
# Pinned to quasar rev 3d6fb0d8 (the HEAD this migration was written
203+
# against, immediately after PRs #195 + #196). The next merged PR
204+
# (#198 "idl-redesign-clean", rev 096c8f7c) regressed `quasar build`
205+
# for flat-layout projects: the new IDL flow chdirs to
206+
# `crate_path.parent()` which evaluates to an empty PathBuf when
207+
# the program crate is at the project root (src/lib.rs in `.`),
208+
# causing posix_spawn child chdir("") to fail with ENOENT before
209+
# any compilation begins. Symptom in CI is a bare "Anyhow error".
210+
# Unpin once upstream lands a fix that handles the flat layout.
211+
run: cargo install --git https://github.com/blueshift-gg/quasar --rev 3d6fb0d8 quasar-cli --locked
203212
- name: Build and Test with Stable
204213
run: |
205214
source build_and_test.sh

basics/account-data/quasar/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ client = []
2222
debug = []
2323

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

2828
[dev-dependencies]

basics/account-data/quasar/src/instructions/create.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ use {
88
pub struct CreateAddressInfo {
99
#[account(mut)]
1010
pub payer: Signer,
11-
#[account(mut, init, payer = payer, seeds = AddressInfo::seeds(payer), bump)]
11+
#[account(mut, init, payer = payer, address = AddressInfo::seeds(payer.address()))]
1212
pub address_info: Account<AddressInfo>,
13-
pub system_program: Program<System>,
13+
pub system_program: Program<SystemProgram>,
1414
}
1515

1616
#[inline(always)]

basics/checking-accounts/quasar/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ client = []
2222
debug = []
2323

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

2828
[dev-dependencies]

basics/checking-accounts/quasar/src/instructions/check_accounts.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use quasar_lang::prelude::*;
33
/// Demonstrates Quasar's account type constraints:
44
/// - `Signer`: automatically verified as a transaction signer
55
/// - `UncheckedAccount`: no runtime checks (opt-in unchecked access)
6-
/// - `Program<System>`: verified as the system program (executable + address check)
6+
/// - `Program<SystemProgram>`: verified as the system program (executable + address check)
77
///
88
/// Note: Anchor's `#[account(owner = id())]` owner constraint is not directly available
99
/// in Quasar. Owner checks can be done manually in the instruction body if needed.
@@ -18,7 +18,7 @@ pub struct CheckAccounts {
1818
#[account(mut)]
1919
pub account_to_change: UncheckedAccount,
2020
/// Checks the account is executable and matches the system program address.
21-
pub system_program: Program<System>,
21+
pub system_program: Program<SystemProgram>,
2222
}
2323

2424
#[inline(always)]

basics/close-account/quasar/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ client = []
2020
debug = []
2121

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

2626
[dev-dependencies]
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
use {crate::state::UserState, quasar_lang::prelude::*};
22

33
/// Accounts for closing a user account.
4-
/// The `close = user` attribute in the Anchor version triggers an automatic epilogue.
5-
/// In Quasar, we call `close()` explicitly — it zeros the discriminator, drains lamports
6-
/// to the destination, reassigns the owner to the system program, and resizes to 0.
4+
/// The `close(dest = user)` attribute mirrors Anchor's `close = user`: at the
5+
/// derive epilogue Quasar zeroes the discriminator, drains lamports to the
6+
/// destination, reassigns the owner to the system program, and resizes to 0.
77
#[derive(Accounts)]
88
pub struct CloseUser {
99
#[account(mut)]
1010
pub user: Signer,
11-
#[account(mut)]
11+
#[account(mut, close(dest = user))]
1212
pub user_account: Account<UserState>,
1313
}
1414

1515
#[inline(always)]
16-
pub fn handle_close_user(accounts: &mut CloseUser) -> Result<(), ProgramError> {
17-
accounts.user_account.close(accounts.user.to_account_view())
16+
pub fn handle_close_user(_accounts: &mut CloseUser) -> Result<(), ProgramError> {
17+
Ok(())
1818
}

basics/close-account/quasar/src/instructions/create_user.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ use {
88
pub struct CreateUser {
99
#[account(mut)]
1010
pub user: Signer,
11-
#[account(mut, init, payer = user, seeds = UserState::seeds(user), bump)]
11+
#[account(mut, init, payer = user, address = UserState::seeds(user.address()))]
1212
pub user_account: Account<UserState>,
13-
pub system_program: Program<System>,
13+
pub system_program: Program<SystemProgram>,
1414
}
1515

1616
#[inline(always)]

basics/counter/quasar/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ client = []
2222
debug = []
2323

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

2828
[dev-dependencies]

0 commit comments

Comments
 (0)