Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Athena Consulting has been awarded a grant by [Atom Accelerator DAO](https://www
- [TimeLock Contract](https://github.com/athena-consulting/cosmwasm-by-example/tree/main/timelock)
- [Crowdfunding Contract](https://github.com/athena-consulting/cosmwasm-by-example/tree/main/crowdfunding)
- [Token Vault](https://github.com/athena-consulting/cosmwasm-by-example/tree/main/token-vault)
- [Project Status Registry](https://github.com/athena-consulting/cosmwasm-by-example/tree/main/project-status-registry)

### :three: Complex Applications
- [Constant Product AMM](https://github.com/athena-consulting/cosmwasm-by-example/tree/main/constant-product-amm)
Expand Down
47 changes: 47 additions & 0 deletions project-status-registry/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
[package]
name = "project-status-registry"
version = "0.1.0"
authors = ["ryanll"]
edition = "2021"

exclude = [
"contract.wasm",
"hash.txt",
]

[lib]
crate-type = ["cdylib", "rlib"]

[profile.release]
opt-level = 3
debug = false
rpath = false
lto = true
debug-assertions = false
codegen-units = 1
panic = 'abort'
incremental = false
overflow-checks = true

[features]
backtraces = ["cosmwasm-std/backtraces"]
library = []

[package.metadata.scripts]
optimize = """docker run --rm -v "$(pwd)":/code \
--mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/rust-optimizer:0.12.10
"""

[dependencies]
cosmwasm-schema = "1.1.3"
cosmwasm-std = "1.1.3"
cw-storage-plus = "1.0.1"
cw2 = "1.0.1"
schemars = "0.8.10"
serde = { version = "1.0.145", default-features = false, features = ["derive"] }
thiserror = { version = "1.0.31" }

[dev-dependencies]
cw-multi-test = "0.16.2"
68 changes: 68 additions & 0 deletions project-status-registry/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Project Status Registry

Project Status Registry is a small CosmWasm contract that records project milestones and their current review status. It is intended as a simple example of owner-managed records with public queries.

## What It Teaches

- Saving contract configuration with `Item`
- Saving multiple records with `Map`
- Restricting write actions to a validated owner
- Querying a single record or a paginated list of records
- Emitting useful response attributes from execute messages

## Contract Flow

1. Instantiate the contract with an optional owner. If no owner is supplied, the sender becomes the owner.
2. The owner adds project records with an id, title, status, and note.
3. The owner updates a project's status as work moves through review.
4. Anyone can query a project or list the stored projects.

## Messages

### Instantiate

```rust
pub struct InstantiateMsg {
pub owner: Option<String>,
}
```

### Execute

```rust
pub enum ExecuteMsg {
AddProject {
id: String,
title: String,
status: ProjectStatus,
note: String,
},
UpdateStatus {
id: String,
status: ProjectStatus,
note: String,
},
TransferOwnership {
new_owner: String,
},
}
```

### Query

```rust
pub enum QueryMsg {
Config {},
Project { id: String },
ListProjects {
start_after: Option<String>,
limit: Option<u32>,
},
}
```

## Example Use Cases

- Track open-source grant milestones.
- Publish a transparent status log for community projects.
- Keep lightweight on-chain evidence of who last updated a project record.
11 changes: 11 additions & 0 deletions project-status-registry/src/bin/schema.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
use cosmwasm_schema::write_api;

use project_status_registry::msg::{ExecuteMsg, InstantiateMsg, QueryMsg};

fn main() {
write_api! {
instantiate: InstantiateMsg,
execute: ExecuteMsg,
query: QueryMsg,
}
}
Loading