Skip to content
Merged
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
15 changes: 8 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
[workspace]
resolver = "2"
members = [
"contracts/teachlink",
"contracts/governance",
"contracts/insurance",
"contracts/teachlink",
]

[workspace.package]
edition = "2021"
license = "MIT"
repository = "https://github.com/rinafcode/teachLink_contract"
license = "MIT"

[workspace.dependencies]
soroban-sdk = "25.0.0-rc.2"

[workspace.lints.rust]
unsafe_code = "deny"

[workspace.lints.clippy]
all = { level = "warn", priority = -1 }
pedantic = { level = "warn", priority = -2 }
module_name_repetitions = "allow"
missing_errors_doc = "allow"
missing_panics_doc = "allow"
module_name_repetitions = "allow"
pedantic = { level = "warn", priority = -2 }

[workspace.lints.rust]
unsafe_code = "deny"
21 changes: 21 additions & 0 deletions contracts/governance/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[package]
name = "governance-contract"
version = "0.1.0"
edition.workspace = true
repository.workspace = true
license.workspace = true

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

[dependencies]
soroban-sdk.workspace = true

[dev-dependencies]
soroban-sdk = { workspace = true, features = ["testutils"] }

[features]
testutils = ["soroban-sdk/testutils"]

[lints]
workspace = true
61 changes: 61 additions & 0 deletions contracts/governance/src/events.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
use soroban_sdk::{Address, Bytes, Env, Symbol};

use crate::types::{ProposalStatus, ProposalType, VoteDirection};

/// Emitted when a new proposal is created
pub fn proposal_created(
env: &Env,
proposal_id: u64,
proposer: &Address,
title: &Bytes,
proposal_type: &ProposalType,
) {
let topics = (Symbol::new(env, "proposal_created"), proposer);
env.events()
.publish(topics, (proposal_id, title.clone(), proposal_type.clone()));
}

/// Emitted when a vote is cast
pub fn vote_cast(
env: &Env,
proposal_id: u64,
voter: &Address,
direction: &VoteDirection,
power: i128,
) {
let topics = (Symbol::new(env, "vote_cast"), voter);
env.events()
.publish(topics, (proposal_id, direction.clone(), power));
}

/// Emitted when a proposal status changes
pub fn proposal_status_changed(
env: &Env,
proposal_id: u64,
old_status: &ProposalStatus,
new_status: &ProposalStatus,
) {
let topics = (Symbol::new(env, "proposal_status"),);
env.events().publish(
topics,
(proposal_id, old_status.clone(), new_status.clone()),
);
}

/// Emitted when a proposal is executed
pub fn proposal_executed(env: &Env, proposal_id: u64, executor: &Address) {
let topics = (Symbol::new(env, "proposal_executed"), executor);
env.events().publish(topics, proposal_id);
}

/// Emitted when a proposal is cancelled
pub fn proposal_cancelled(env: &Env, proposal_id: u64, cancelled_by: &Address) {
let topics = (Symbol::new(env, "proposal_cancelled"), cancelled_by);
env.events().publish(topics, proposal_id);
}

/// Emitted when governance configuration is updated
pub fn config_updated(env: &Env, admin: &Address) {
let topics = (Symbol::new(env, "config_updated"), admin);
env.events().publish(topics, ());
}
Loading
Loading