| Crates.io | carbon-points-decoder |
| lib.rs | carbon-points-decoder |
| version | 0.12.1 |
| created_at | 2025-11-05 15:19:05.836831+00 |
| updated_at | 2026-01-21 23:32:55.119269+00 |
| description | Rust decoder for Star Atlas Points program on Solana |
| homepage | https://github.com/staratlasmeta/star-atlas-decoders |
| repository | https://github.com/staratlasmeta/star-atlas-decoders |
| max_upload_size | |
| id | 1918141 |
| size | 177,340 |
Rust decoder for the Star Atlas Points program on Solana, generated using Carbon CLI.
Point2iBvz7j5TMVef8nEgpmz4pDr7tU7v3RjAfkQbMAdd this crate to your Cargo.toml:
[dependencies]
carbon-points-decoder = "0.12.0"
use carbon_points_decoder::{PointsDecoder, PointsAccount};
use carbon_core::account::AccountDecoder;
let decoder = PointsDecoder;
let decoded_account = decoder.decode_account(&account);
if let Some(decoded) = decoded_account {
match decoded.data {
PointsAccount::PointCategory(category) => {
println!("Point Category: {:?}", category);
println!("Profile: {}", category.profile);
println!("Point Limit: {}", category.point_limit);
println!("Is Spendable: {}", category.is_spendable != 0);
println!("Token Required: {}", category.token_required != 0);
if category.token_required != 0 {
println!("Token Mint: {}", category.token_mint);
println!("Token Qty: {}", category.token_qty);
}
// Access the levels array (deserialized from remaining data)
println!("Number of levels: {}", category.levels.len());
for level in &category.levels {
println!(" Level {}: {} points required", level.level, level.points);
if level.token_qty > 0 {
println!(" Requires {} tokens (vault: {})",
level.token_qty, level.token_vault);
}
}
}
PointsAccount::UserPointsAccount(user_points) => {
println!("User Points Account: {:?}", user_points);
println!("Profile: {}", user_points.profile);
println!("Point Category: {}", user_points.point_category);
println!("Earned Points: {}", user_points.earned_points);
println!("Spent Points: {}", user_points.spent_points);
println!("Current Level: {}", user_points.level);
println!("Daily Earned: {}", user_points.daily_earned_points);
println!("Last Earned Timestamp: {}", user_points.last_earned_points_timestamp);
}
PointsAccount::PointsModifier(modifier) => {
println!("Points Modifier: {:?}", modifier);
println!("Point Category: {}", modifier.point_category);
println!("Can Increment: {}", modifier.can_increment != 0);
println!("Can Decrement: {}", modifier.can_decrement != 0);
}
}
}
The Points program uses license types to control level progression requirements:
use carbon_points_decoder::{LicenseType, PointsLevelLicenseType};
// LicenseType is used for level upgrade requirements with quantity
match license_type {
LicenseType::None => {
println!("No license required for this level");
}
LicenseType::Burn { quantity } => {
println!("Requires burning {} tokens to unlock this level", quantity);
}
LicenseType::Vault { quantity } => {
println!("Requires {} tokens transferred to vault for this level", quantity);
}
}
// PointsLevelLicenseType is a simpler enum without quantities
match license {
PointsLevelLicenseType::None => println!("No license"),
PointsLevelLicenseType::Burn => println!("Burn license"),
PointsLevelLicenseType::Vault => println!("Vault license"),
}
The Points program uses u8 fields for boolean flags. Check them like this:
// Check if a point category requires tokens
if category.token_required != 0 {
println!("This category requires token: {}", category.token_mint);
}
// Check if points are spendable
if category.is_spendable != 0 {
println!("Points can be spent in this category");
}
// Check if tokens should be transferred to vault
if category.transfer_tokens_to_vault != 0 {
println!("Tokens will be transferred to vault: {}", category.token_vault);
}
// Check modifier permissions
if modifier.can_increment != 0 {
println!("This modifier can increment points");
}
if modifier.can_decrement != 0 {
println!("This modifier can decrement points");
}
This decoder supports all Points account types:
PointCategory - Defines a category of points with levels, limits, and token requirements
levels array from remaining data (each level specifies points threshold and token requirements)UserPointsAccount - Tracks a user's points and level for a specific category
PointsModifier - Grants authority to modify points for a specific category
The Points program uses two license type enums:
An enum with associated data for level upgrade requirements:
None - No license or tokens requiredBurn { quantity: u64 } - Requires burning the specified quantity of tokensVault { quantity: u64 } - Requires transferring tokens to a vaultA simpler enum without quantities:
None - No license requiredBurn - Burn-type licenseVault - Vault-type licenseFull documentation is available at docs.rs.
See the main repository for build instructions and contribution guidelines.
Licensed under the Apache-2.0 license.