Skip to content

exotic-markets-labs/typhoon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Typhoon

Solana Sealevel Framework

Build Status Read the book License

πŸ—’οΈ Note

  • Typhoon is in active development, so all APIs are subject to change.
  • This code is unaudited. Use at your own risk.

πŸ“š Installation

To get started with Typhoon, add it to your Rust project using Cargo:

cargo add typhoon

πŸš€ Getting Started

Here’s a quick example to show how Typhoon simplifies Solana program development:

#![no_std]

use {
    bytemuck::{AnyBitPattern, NoUninit},
    typhoon::prelude::*,
};


program_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS");

nostd_panic_handler!();
no_allocator!();
entrypoint!();

pub const ROUTER: EntryFn = basic_router! {
    0 => initialize,
    1 => increment,
    2 => close,
};


#[context]
pub struct InitContext {
    pub payer: Mut<Signer>,
    #[constraint(
        init,
        payer = payer,
    )]
    pub counter: Mut<SignerNoCheck<Account<Counter>>>,
    pub system: Program<System>,
}

#[context]
pub struct CounterMutContext {
    pub counter: Mut<Account<Counter>>,
}

#[context]
pub struct DestinationContext {
    pub destination: Mut<SystemAccount>,
}

pub fn initialize(_: InitContext) -> ProgramResult {
    Ok(())
}

pub fn increment(ctx: CounterMutContext) -> ProgramResult {
    ctx.counter.mut_data()?.count += 1;

    Ok(())
}

pub fn close(
    CounterMutContext { counter }: CounterMutContext,
    DestinationContext { destination }: DestinationContext,
) -> ProgramResult {
    counter.close(&destination)?;

    Ok(())
}

#[derive(NoUninit, AnyBitPattern, AccountState, Copy, Clone)]
#[repr(C)]
pub struct Counter {
    pub count: u64,
}

πŸ“¦ Examples

Explore the examples directory for templates and use-case scenarios to kickstart your project.

πŸ“œ License

Typhoon is licensed under Apache 2.0.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Typhoon by you, as defined in the Apache-2.0 license, shall be licensed as above, without any additional terms or conditions.

About

πŸŒͺ️ Solana Sealevel Framework

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Contributors 6

Languages