mirror of
https://github.com/logos-blockchain/lez-programs.git
synced 2026-05-18 23:19:30 +00:00
parent
6eed55d7e4
commit
590d60cabd
26
Cargo.lock
generated
26
Cargo.lock
generated
@ -3016,6 +3016,32 @@ version = "1.2.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596"
|
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]]
|
[[package]]
|
||||||
name = "strsim"
|
name = "strsim"
|
||||||
version = "0.11.1"
|
version = "0.11.1"
|
||||||
|
|||||||
@ -9,6 +9,9 @@ members = [
|
|||||||
"ata/core",
|
"ata/core",
|
||||||
"ata",
|
"ata",
|
||||||
"ata/methods",
|
"ata/methods",
|
||||||
|
"stablecoin/core",
|
||||||
|
"stablecoin",
|
||||||
|
"stablecoin/methods",
|
||||||
"integration_tests",
|
"integration_tests",
|
||||||
"tools/idl-gen",
|
"tools/idl-gen",
|
||||||
]
|
]
|
||||||
@ -16,6 +19,7 @@ exclude = [
|
|||||||
"token/methods/guest",
|
"token/methods/guest",
|
||||||
"amm/methods/guest",
|
"amm/methods/guest",
|
||||||
"ata/methods/guest",
|
"ata/methods/guest",
|
||||||
|
"stablecoin/methods/guest",
|
||||||
]
|
]
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
|
|
||||||
@ -28,6 +32,8 @@ amm_core = { path = "amm/core" }
|
|||||||
amm_program = { path = "amm" }
|
amm_program = { path = "amm" }
|
||||||
ata_core = { path = "ata/core" }
|
ata_core = { path = "ata/core" }
|
||||||
ata_program = { path = "ata" }
|
ata_program = { path = "ata" }
|
||||||
|
stablecoin_core = { path = "stablecoin/core" }
|
||||||
|
stablecoin_program = { path = "stablecoin" }
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
borsh = { version = "1.0", features = ["derive"] }
|
borsh = { version = "1.0", features = ["derive"] }
|
||||||
risc0-zkvm = { version = "=3.0.5" }
|
risc0-zkvm = { version = "=3.0.5" }
|
||||||
|
|||||||
19
artifacts/stablecoin-idl.json
Normal file
19
artifacts/stablecoin-idl.json
Normal 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
8
stablecoin/Cargo.toml
Normal 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" }
|
||||||
9
stablecoin/core/Cargo.toml
Normal file
9
stablecoin/core/Cargo.toml
Normal 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"] }
|
||||||
6
stablecoin/core/src/lib.rs
Normal file
6
stablecoin/core/src/lib.rs
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize)]
|
||||||
|
pub enum Instruction {
|
||||||
|
Noop,
|
||||||
|
}
|
||||||
14
stablecoin/methods/Cargo.toml
Normal file
14
stablecoin/methods/Cargo.toml
Normal 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"]
|
||||||
3
stablecoin/methods/build.rs
Normal file
3
stablecoin/methods/build.rs
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fn main() {
|
||||||
|
risc0_build::embed_methods();
|
||||||
|
}
|
||||||
19
stablecoin/methods/guest/Cargo.toml
Normal file
19
stablecoin/methods/guest/Cargo.toml
Normal 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"
|
||||||
19
stablecoin/methods/guest/src/bin/stablecoin.rs
Normal file
19
stablecoin/methods/guest/src/bin/stablecoin.rs
Normal 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,
|
||||||
|
)))
|
||||||
|
}
|
||||||
|
}
|
||||||
1
stablecoin/methods/src/lib.rs
Normal file
1
stablecoin/methods/src/lib.rs
Normal file
@ -0,0 +1 @@
|
|||||||
|
include!(concat!(env!("OUT_DIR"), "/methods.rs"));
|
||||||
8
stablecoin/src/lib.rs
Normal file
8
stablecoin/src/lib.rs
Normal 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
5
stablecoin/src/noop.rs
Normal 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
12
stablecoin/src/tests.rs
Normal 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);
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user