initial commit

This commit is contained in:
thesn10
2026-05-16 18:00:24 +02:00
commit da80420f01
20 changed files with 18180 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
[package]
name = "descro"
version = "0.1.0"
description = "Created with Anchor"
edition = "2021"
[lib]
crate-type = ["cdylib", "lib"]
name = "descro"
[features]
default = []
cpi = ["no-entrypoint"]
no-entrypoint = []
no-idl = []
no-log-ix-name = []
idl-build = ["anchor-lang/idl-build"]
anchor-debug = []
custom-heap = []
custom-panic = []
[dependencies]
anchor-lang = "1.0.2"
[dev-dependencies]
litesvm = "0.10.0"
solana-message = "3.0.1"
solana-transaction = "3.0.2"
solana-signer = "3.0.0"
solana-keypair = "3.0.1"
[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(target_os, values("solana"))'] }

View File

@@ -0,0 +1,4 @@
use anchor_lang::prelude::*;
#[constant]
pub const SEED: &str = "anchor";

View File

@@ -0,0 +1,7 @@
use anchor_lang::prelude::*;
#[error_code]
pub enum ErrorCode {
#[msg("Custom error message")]
CustomError,
}

View File

@@ -0,0 +1,3 @@
pub mod initialize;
pub use initialize::*;

View File

@@ -0,0 +1,9 @@
use anchor_lang::prelude::*;
#[derive(Accounts)]
pub struct Initialize {}
pub fn handler(ctx: Context<Initialize>) -> Result<()> {
msg!("Greetings from: {:?}", ctx.program_id);
Ok(())
}

View File

@@ -0,0 +1,21 @@
pub mod constants;
pub mod error;
pub mod instructions;
pub mod state;
use anchor_lang::prelude::*;
pub use constants::*;
pub use instructions::*;
pub use state::*;
declare_id!("DjVR4EuYV6USMJFfsGZwhZ3y8rtWsmG8EvDY96GTqqi3");
#[program]
pub mod descro {
use super::*;
pub fn initialize(ctx: Context<Initialize>) -> Result<()> {
initialize::handler(ctx)
}
}

View File

View File

@@ -0,0 +1,32 @@
use {
anchor_lang::{solana_program::instruction::Instruction, InstructionData, ToAccountMetas},
litesvm::LiteSVM,
solana_message::{Message, VersionedMessage},
solana_signer::Signer,
solana_keypair::Keypair,
solana_transaction::versioned::VersionedTransaction,
};
#[test]
fn test_initialize() {
let program_id = descro::id();
let payer = Keypair::new();
let mut svm = LiteSVM::new();
let bytes = include_bytes!("../../../target/deploy/descro.so");
svm.add_program(program_id, bytes).unwrap();
svm.airdrop(&payer.pubkey(), 1_000_000_000).unwrap();
let instruction = Instruction::new_with_bytes(
program_id,
&descro::instruction::Initialize {}.data(),
descro::accounts::Initialize {}.to_account_metas(None),
);
let blockhash = svm.latest_blockhash();
let msg = Message::new_with_blockhash(&[instruction], Some(&payer.pubkey()), &blockhash);
let tx = VersionedTransaction::try_new(VersionedMessage::Legacy(msg), &[payer]).unwrap();
let res = svm.send_transaction(tx);
assert!(res.is_ok());
}