From 5cb70e687575f0ec6bae716d6e7aa8c4c0c323ea Mon Sep 17 00:00:00 2001 From: akargi Date: Fri, 20 Feb 2026 17:16:13 +0000 Subject: [PATCH] feat: add minimal Soroban contract template scaffold - Create CoreContract with init() and ping() entry points - Configure wasm32-unknown-unknown build target - Add unit tests using soroban_sdk::testutils - No business logic, storage, events, or authentication - Contract compiles without warnings and produces WASM artifact --- crates/contracts/core/src/lib.rs | 37 ++++++++++++-------------------- 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/crates/contracts/core/src/lib.rs b/crates/contracts/core/src/lib.rs index 6dd20bc..2f15743 100644 --- a/crates/contracts/core/src/lib.rs +++ b/crates/contracts/core/src/lib.rs @@ -1,42 +1,33 @@ #![no_std] -use soroban_sdk::{contract, contractimpl, Env, Symbol}; +use soroban_sdk::{contract, contractimpl, Address, Env}; #[contract] -pub struct StellarAidContract; +pub struct CoreContract; #[contractimpl] -impl StellarAidContract { - pub fn hello(_env: Env, _to: Symbol) -> Symbol { - soroban_sdk::symbol_short!("Hello") - } +impl CoreContract { + pub fn init(_env: Env, _admin: Address) {} - pub fn get_greeting(_env: Env) -> Symbol { - soroban_sdk::symbol_short!("Hi") + pub fn ping(_env: Env) -> u32 { + 1 } } #[cfg(test)] mod tests { use super::*; - use soroban_sdk::{symbol_short, Env}; + use soroban_sdk::Env; #[test] - fn test_hello() { + fn test_init_and_ping() { let env = Env::default(); - let contract_id = env.register_contract(None, StellarAidContract); - let client = StellarAidContractClient::new(&env, &contract_id); - - let result = client.hello(&symbol_short!("World")); - assert_eq!(result, symbol_short!("Hello")); - } + let contract_id = env.register_contract(None, CoreContract); + let client = CoreContractClient::new(&env, &contract_id); - #[test] - fn test_get_greeting() { - let env = Env::default(); - let contract_id = env.register_contract(None, StellarAidContract); - let client = StellarAidContractClient::new(&env, &contract_id); + let admin = env.current_contract_address(); + client.init(&admin); - let result = client.get_greeting(); - assert_eq!(result, symbol_short!("Hi")); + let result = client.ping(); + assert_eq!(result, 1); } }