mirror of
https://github.com/logos-blockchain/lez-programs.git
synced 2026-08-25 06:01:11 +00:00
chore: initial repository setup for programs
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
[package]
|
||||
name = "token-methods"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[build-dependencies]
|
||||
risc0-build = "=3.0.5"
|
||||
|
||||
[dependencies]
|
||||
risc0-zkvm = { version = "=3.0.5", features = ["std"] }
|
||||
token_core = { path = "../core" }
|
||||
|
||||
[package.metadata.risc0]
|
||||
methods = ["guest"]
|
||||
@@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
risc0_build::embed_methods();
|
||||
}
|
||||
Generated
+4029
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,22 @@
|
||||
[package]
|
||||
name = "token-guest"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[workspace]
|
||||
|
||||
[patch."https://github.com/logos-blockchain/lssa.git"]
|
||||
nssa_core = { git = "https://github.com/logos-blockchain/logos-execution-zone.git" }
|
||||
|
||||
[[bin]]
|
||||
name = "token"
|
||||
path = "src/bin/token.rs"
|
||||
|
||||
[dependencies]
|
||||
spel-framework = { git = "https://github.com/0x-r4bbit/spel.git", branch = "fix/nssa-v03-compat", package = "spel-framework" }
|
||||
nssa_core = { git = "https://github.com/logos-blockchain/lssa.git", rev = "767b5afd388c7981bcdf6f5b5c80159607e07e5b" }
|
||||
risc0-zkvm = { version = "=3.0.5", default-features = false }
|
||||
token_core = { path = "../../core" }
|
||||
token_program = { path = "../..", package = "token_program" }
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
borsh = "1.5"
|
||||
@@ -0,0 +1,118 @@
|
||||
#![no_main]
|
||||
|
||||
use spel_framework::prelude::*;
|
||||
use nssa_core::account::AccountWithMetadata;
|
||||
|
||||
risc0_zkvm::guest::entry!(main);
|
||||
|
||||
#[lez_program(instruction = "token_core::Instruction")]
|
||||
mod token {
|
||||
#[allow(unused_imports)]
|
||||
use super::*;
|
||||
|
||||
/// Transfer tokens from sender to recipient.
|
||||
#[instruction]
|
||||
pub fn transfer(
|
||||
sender: AccountWithMetadata,
|
||||
recipient: AccountWithMetadata,
|
||||
amount_to_transfer: u128,
|
||||
) -> SpelResult {
|
||||
Ok(SpelOutput::states_only(token_program::transfer::transfer(
|
||||
sender,
|
||||
recipient,
|
||||
amount_to_transfer,
|
||||
)))
|
||||
}
|
||||
|
||||
/// Create a new fungible token definition without metadata.
|
||||
#[instruction]
|
||||
pub fn new_fungible_definition(
|
||||
definition_target_account: AccountWithMetadata,
|
||||
holding_target_account: AccountWithMetadata,
|
||||
name: String,
|
||||
total_supply: u128,
|
||||
) -> SpelResult {
|
||||
Ok(SpelOutput::states_only(
|
||||
token_program::new_definition::new_fungible_definition(
|
||||
definition_target_account,
|
||||
holding_target_account,
|
||||
name,
|
||||
total_supply,
|
||||
),
|
||||
))
|
||||
}
|
||||
|
||||
/// Create a new fungible or non-fungible token definition with metadata.
|
||||
#[instruction]
|
||||
pub fn new_definition_with_metadata(
|
||||
definition_target_account: AccountWithMetadata,
|
||||
holding_target_account: AccountWithMetadata,
|
||||
metadata_target_account: AccountWithMetadata,
|
||||
new_definition: token_core::NewTokenDefinition,
|
||||
metadata: Box<token_core::NewTokenMetadata>,
|
||||
) -> SpelResult {
|
||||
Ok(SpelOutput::states_only(
|
||||
token_program::new_definition::new_definition_with_metadata(
|
||||
definition_target_account,
|
||||
holding_target_account,
|
||||
metadata_target_account,
|
||||
new_definition,
|
||||
*metadata,
|
||||
),
|
||||
))
|
||||
}
|
||||
|
||||
/// Initialize a token holding account for a given token definition.
|
||||
#[instruction]
|
||||
pub fn initialize_account(
|
||||
definition_account: AccountWithMetadata,
|
||||
account_to_initialize: AccountWithMetadata,
|
||||
) -> SpelResult {
|
||||
Ok(SpelOutput::states_only(
|
||||
token_program::initialize::initialize_account(
|
||||
definition_account,
|
||||
account_to_initialize,
|
||||
),
|
||||
))
|
||||
}
|
||||
|
||||
/// Burn tokens from the holder's account.
|
||||
#[instruction]
|
||||
pub fn burn(
|
||||
definition_account: AccountWithMetadata,
|
||||
user_holding_account: AccountWithMetadata,
|
||||
amount_to_burn: u128,
|
||||
) -> SpelResult {
|
||||
Ok(SpelOutput::states_only(token_program::burn::burn(
|
||||
definition_account,
|
||||
user_holding_account,
|
||||
amount_to_burn,
|
||||
)))
|
||||
}
|
||||
|
||||
/// Mint new tokens to the holder's account.
|
||||
#[instruction]
|
||||
pub fn mint(
|
||||
definition_account: AccountWithMetadata,
|
||||
user_holding_account: AccountWithMetadata,
|
||||
amount_to_mint: u128,
|
||||
) -> SpelResult {
|
||||
Ok(SpelOutput::states_only(token_program::mint::mint(
|
||||
definition_account,
|
||||
user_holding_account,
|
||||
amount_to_mint,
|
||||
)))
|
||||
}
|
||||
|
||||
/// Print a new NFT from the master copy.
|
||||
#[instruction]
|
||||
pub fn print_nft(
|
||||
master_account: AccountWithMetadata,
|
||||
printed_account: AccountWithMetadata,
|
||||
) -> SpelResult {
|
||||
Ok(SpelOutput::states_only(token_program::print_nft::print_nft(
|
||||
master_account,
|
||||
printed_account,
|
||||
)))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
include!(concat!(env!("OUT_DIR"), "/methods.rs"));
|
||||
Reference in New Issue
Block a user