feat(stablecoin): initial stablecoin scaffold

closes #86
This commit is contained in:
Andrea Franz 2026-05-11 14:51:50 +02:00 committed by r4bbit
parent 6eed55d7e4
commit 4178406fda
14 changed files with 155 additions and 0 deletions

26
Cargo.lock generated
View File

@ -3016,6 +3016,32 @@ version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596"
[[package]]
name = "stablecoin-methods"
version = "0.1.0"
dependencies = [
"risc0-build",
"risc0-zkvm",
"stablecoin_core",
]
[[package]]
name = "stablecoin_core"
version = "0.1.0"
dependencies = [
"borsh",
"nssa_core",
"serde",
]
[[package]]
name = "stablecoin_program"
version = "0.1.0"
dependencies = [
"nssa_core",
"stablecoin_core",
]
[[package]]
name = "strsim"
version = "0.11.1"

View File

@ -9,6 +9,9 @@ members = [
"ata/core",
"ata",
"ata/methods",
"stablecoin/core",
"stablecoin",
"stablecoin/methods",
"integration_tests",
"tools/idl-gen",
]
@ -16,6 +19,7 @@ exclude = [
"token/methods/guest",
"amm/methods/guest",
"ata/methods/guest",
"stablecoin/methods/guest",
]
resolver = "2"
@ -28,6 +32,8 @@ amm_core = { path = "amm/core" }
amm_program = { path = "amm" }
ata_core = { path = "ata/core" }
ata_program = { path = "ata" }
stablecoin_core = { path = "stablecoin/core" }
stablecoin_program = { path = "stablecoin" }
serde = { version = "1.0", features = ["derive"] }
borsh = { version = "1.0", features = ["derive"] }
risc0-zkvm = { version = "=3.0.5" }

View File

@ -0,0 +1,19 @@
{
"version": "0.1.0",
"name": "stablecoin",
"instructions": [
{
"name": "noop",
"accounts": [
{
"name": "account",
"writable": false,
"signer": false,
"init": false
}
],
"args": []
}
],
"instruction_type": "stablecoin_core::Instruction"
}

8
stablecoin/Cargo.toml Normal file
View File

@ -0,0 +1,8 @@
[package]
name = "stablecoin_program"
version = "0.1.0"
edition = "2021"
[dependencies]
nssa_core = { git = "https://github.com/logos-blockchain/logos-execution-zone.git", tag = "v0.2.0-rc1", features = ["host"] }
stablecoin_core = { path = "core" }

View File

@ -0,0 +1,9 @@
[package]
name = "stablecoin_core"
version = "0.1.0"
edition = "2021"
[dependencies]
nssa_core = { git = "https://github.com/logos-blockchain/logos-execution-zone.git", tag = "v0.2.0-rc1", features = ["host"] }
borsh = { version = "1.5", features = ["derive"] }
serde = { version = "1.0", features = ["derive"] }

View File

@ -0,0 +1,6 @@
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)]
pub enum Instruction {
Noop,
}

View File

@ -0,0 +1,14 @@
[package]
name = "stablecoin-methods"
version = "0.1.0"
edition = "2021"
[build-dependencies]
risc0-build = "=3.0.5"
[dependencies]
risc0-zkvm = { version = "=3.0.5", features = ["std"] }
stablecoin_core = { path = "../core" }
[package.metadata.risc0]
methods = ["guest"]

View File

@ -0,0 +1,3 @@
fn main() {
risc0_build::embed_methods();
}

View File

@ -0,0 +1,19 @@
[package]
name = "stablecoin-guest"
version = "0.1.0"
edition = "2021"
[workspace]
[[bin]]
name = "stablecoin"
path = "src/bin/stablecoin.rs"
[dependencies]
spel-framework = { git = "https://github.com/logos-co/spel.git", rev = "9e7f2754e1d4cdb3ea36e63b1ff86c3af55488d3", package = "spel-framework" }
nssa_core = { git = "https://github.com/logos-blockchain/logos-execution-zone.git", tag = "v0.2.0-rc1" }
risc0-zkvm = { version = "=3.0.5", default-features = false }
stablecoin_core = { path = "../../core" }
stablecoin_program = { path = "../..", package = "stablecoin_program" }
serde = { version = "1.0", features = ["derive"] }
borsh = "1.5"

View File

@ -0,0 +1,19 @@
#![no_main]
use nssa_core::account::AccountWithMetadata;
use spel_framework::prelude::*;
risc0_zkvm::guest::entry!(main);
#[lez_program(instruction = "stablecoin_core::Instruction")]
mod stablecoin {
#[allow(unused_imports)]
use super::*;
#[instruction]
pub fn noop(account: AccountWithMetadata) -> SpelResult {
Ok(SpelOutput::states_only(stablecoin_program::noop::noop(
account,
)))
}
}

View File

@ -0,0 +1 @@
include!(concat!(env!("OUT_DIR"), "/methods.rs"));

8
stablecoin/src/lib.rs Normal file
View File

@ -0,0 +1,8 @@
//! The Stablecoin Program implementation.
pub use stablecoin_core as core;
pub mod noop;
#[cfg(test)]
mod tests;

5
stablecoin/src/noop.rs Normal file
View File

@ -0,0 +1,5 @@
use nssa_core::{account::AccountWithMetadata, program::AccountPostState};
pub fn noop(account: AccountWithMetadata) -> Vec<AccountPostState> {
vec![AccountPostState::new(account.account)]
}

12
stablecoin/src/tests.rs Normal file
View File

@ -0,0 +1,12 @@
use nssa_core::account::{Account, AccountId, AccountWithMetadata};
#[test]
fn noop_returns_single_post_state() {
let account = AccountWithMetadata {
account: Account::default(),
is_authorized: false,
account_id: AccountId::new([0u8; 32]),
};
let post_states = crate::noop::noop(account);
assert_eq!(post_states.len(), 1);
}