Skip to content

Commit e9dab75

Browse files
committed
- Stellar-Uzima#1004: Add .devcontainer/devcontainer.json with Rust 1.92.0, Soroban CLI 21.7.7, wasm target, and recommended VS Code extensions - Stellar-Uzima#1003: Add docker-compose.yml and Dockerfile.dev for one-click local development environment with Stellar node, contract deployment, and test data - Stellar-Uzima#1002: Add soroban contract invoke CLI examples to contract_template (5 entrypoints) and patient_consent_management (4 entrypoints) doc comments - Stellar-Uzima#998: Add FHIR R4 Consent resource mapping to patient_consent_management with to_fhir_consent() conversion, validate_fhir_consent() validator, and 6 unit tests
1 parent c1a85cb commit e9dab75

6 files changed

Lines changed: 657 additions & 0 deletions

File tree

.devcontainer/devcontainer.json

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"name": "Uzima Contracts",
3+
"image": "mcr.microsoft.com/devcontainers/rust:1-1-bookworm",
4+
"features": {
5+
"ghcr.io/devcontainers/features/rust:1": {
6+
"version": "1.92.0",
7+
"profile": "minimal"
8+
}
9+
},
10+
"customizations": {
11+
"vscode": {
12+
"extensions": [
13+
"rust-lang.rust-analyzer",
14+
"tamasfe.even-better-toml",
15+
"vadimcn.vscode-lldb",
16+
"fill-labs.dependi",
17+
"github.vscode-github-actions",
18+
"ms-azuretools.vscode-docker",
19+
"yzhang.markdown-all-in-one",
20+
"timonwong.shellcheck"
21+
],
22+
"settings": {
23+
"rust-analyzer.cargo.target": "wasm32-unknown-unknown",
24+
"rust-analyzer.checkOnSave.command": "clippy",
25+
"rust-analyzer.checkOnSave.allTargets": false,
26+
"editor.formatOnSave": true,
27+
"editor.rulers": [100],
28+
"[rust]": {
29+
"editor.defaultFormatter": "rust-lang.rust-analyzer"
30+
}
31+
}
32+
}
33+
},
34+
"postCreateCommand": "rustup target add wasm32-unknown-unknown && rustup component add rustfmt clippy rust-src && cargo install --locked soroban-cli --version 21.7.7 && make build",
35+
"remoteUser": "root",
36+
"mounts": [
37+
"source=${localWorkspaceFolder}/target,target=/workspaces/Uzima-Contracts/target,type=volume"
38+
],
39+
"containerEnv": {
40+
"SOROBAN_RPC_URL": "http://localhost:8000/soroban/rpc",
41+
"SOROBAN_NETWORK_PASSPHRASE": "Standalone Network ; February 2017"
42+
}
43+
}

Dockerfile.dev

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Dockerfile.dev — Development environment for Uzima Contracts
2+
FROM rust:1.92.0-bookworm
3+
4+
RUN apt-get update && apt-get install -y --no-install-recommends \
5+
curl \
6+
git \
7+
build-essential \
8+
jq \
9+
shellcheck \
10+
&& rm -rf /var/lib/apt/lists/*
11+
12+
RUN rustup target add wasm32-unknown-unknown && \
13+
rustup component add rustfmt clippy rust-src
14+
15+
RUN cargo install --locked soroban-cli --version 21.7.7
16+
17+
WORKDIR /workspace

contracts/contract_template/src/lib.rs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,16 @@ impl ContractTemplate {
5353
///
5454
/// # Auth
5555
/// No auth required — the deployer becomes the admin.
56+
///
57+
/// # Example (Soroban CLI)
58+
/// ```bash
59+
/// soroban contract invoke \
60+
/// --id $CONTRACT_ID \
61+
/// --source admin \
62+
/// --network local \
63+
/// -- initialize \
64+
/// --admin $(soroban config identity address admin)
65+
/// ```
5666
pub fn initialize(env: Env, admin: Address) -> Result<(), Error> {
5767
if env.storage().instance().has(&DataKey::Admin) {
5868
return Err(Error::AlreadyInitialized);
@@ -70,6 +80,16 @@ impl ContractTemplate {
7080
///
7181
/// # Auth
7282
/// Requires auth from the **current** admin.
83+
///
84+
/// # Example (Soroban CLI)
85+
/// ```bash
86+
/// soroban contract invoke \
87+
/// --id $CONTRACT_ID \
88+
/// --source admin \
89+
/// --network local \
90+
/// -- transfer_admin \
91+
/// --new_admin GDT6C5XN6N4KMARBER2KEJCQA7NGK7IE46YH4XQLAWXI5QPLFXXOB7KJ
92+
/// ```
7393
pub fn transfer_admin(env: Env, new_admin: Address) -> Result<(), Error> {
7494
let admin = Self::get_admin(&env)?;
7595
// Always call require_auth() before any state changes.
@@ -84,6 +104,17 @@ impl ContractTemplate {
84104
///
85105
/// # Auth
86106
/// Requires auth from the admin.
107+
///
108+
/// # Example (Soroban CLI)
109+
/// ```bash
110+
/// soroban contract invoke \
111+
/// --id $CONTRACT_ID \
112+
/// --source admin \
113+
/// --network local \
114+
/// -- update_data \
115+
/// --caller $(soroban config identity address admin) \
116+
/// --data "Hello, Stellar!"
117+
/// ```
87118
pub fn update_data(env: Env, caller: Address, data: String) -> Result<(), Error> {
88119
// 1. Authenticate the caller first.
89120
caller.require_auth();
@@ -116,6 +147,16 @@ impl ContractTemplate {
116147
// -----------------------------------------------------------------------
117148

118149
/// Return the current admin address.
150+
///
151+
/// # Example (Soroban CLI)
152+
/// ```bash
153+
/// soroban contract invoke \
154+
/// --id $CONTRACT_ID \
155+
/// --source admin \
156+
/// --network local \
157+
/// --dry-run \
158+
/// -- get_admin
159+
/// ```
119160
pub fn get_admin(env: &Env) -> Result<Address, Error> {
120161
env.storage()
121162
.instance()
@@ -124,6 +165,16 @@ impl ContractTemplate {
124165
}
125166

126167
/// Return the stored data, if any.
168+
///
169+
/// # Example (Soroban CLI)
170+
/// ```bash
171+
/// soroban contract invoke \
172+
/// --id $CONTRACT_ID \
173+
/// --source admin \
174+
/// --network local \
175+
/// --dry-run \
176+
/// -- get_data
177+
/// ```
127178
pub fn get_data(env: Env) -> Option<ContractData> {
128179
env.storage().persistent().get(&DataKey::Data)
129180
}

0 commit comments

Comments
 (0)