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
873 changes: 196 additions & 677 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion backend/indexer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ prometheus = { version = "0.14", features = ["process"] }
lazy_static = "1"
governor = { version = "0.10", features = ["dashmap"] }
dashmap = "6"

# Sentry error tracking
sentry = { version = "0.34", default-features = false, features = ["backtrace", "contexts", "panic", "reqwest", "rustls"] }
sentry-tracing = "0.34"
Expand Down
60 changes: 27 additions & 33 deletions contracts/pifp_protocol/src/events.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(deprecated)]
//! On-chain event definitions and emission helpers for the PIFP protocol.

use soroban_sdk::{contractevent, contracttype, symbol_short, Address, BytesN, Env};

Expand Down Expand Up @@ -69,40 +69,39 @@ use soroban_sdk::{contracttype, symbol_short, Address, BytesN, Env};

#[contracttype]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct ProjectCreated {
pub struct FundsReleased {
pub project_id: u64,
pub creator: Address,
pub token: Address,
pub goal: i128,
pub amount: i128,
}

#[contracttype]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct ProjectFunded {
pub struct Refunded {
pub project_id: u64,
pub donator: Address,
pub amount: i128,
}

#[contracttype]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct ProjectActive {
pub struct ExpiredFundsReclaimed {
pub project_id: u64,
pub creator: Address,
pub token: Address,
pub amount: i128,
}

#[contracttype]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct ProjectVerified {
pub project_id: u64,
pub oracle: Address,
pub proof_hash: BytesN<32>,
pub struct ProtocolPaused {
pub admin: Address,
}

#[contracttype]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct ProjectExpired {
pub project_id: u64,
pub deadline: u64,
pub struct ProtocolUnpaused {
pub admin: Address,
}

#[contracttype]
Expand Down Expand Up @@ -145,6 +144,7 @@ pub struct WhitelistRemoved {
pub address: Address,
}

/// Emitted each time an oracle casts a vote via `verify_and_release`.
#[contracttype]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct ProjectCancelled {
Expand All @@ -170,21 +170,25 @@ pub struct ProjectUnpaused {
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct FundsReleased {
pub project_id: u64,
pub token: Address,
pub amount: i128,
pub oracle: Address,
/// Bit index of this oracle in the project's authorized list.
pub oracle_index: u32,
/// Running count of unique votes after this one.
pub voter_count: u32,
/// Threshold required to release funds.
pub threshold: u32,
}

#[contracttype]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Refunded {
pub struct OracleAdded {
pub project_id: u64,
pub donator: Address,
pub amount: i128,
pub oracle: Address,
}

#[contracttype]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct ExpiredFundsReclaimed {
pub struct OracleRemoved {
pub project_id: u64,
pub creator: Address,
pub token: Address,
Expand All @@ -203,7 +207,7 @@ pub struct ProtocolUnpaused {
pub admin: Address,
}

// ── Emission helpers ────────────────────────────────────────────────
// ── Emission helpers ──────────────────────────────────────────────────────────

pub fn emit_project_created(
env: &Env,
Expand Down Expand Up @@ -300,27 +304,17 @@ pub fn emit_refunded(env: &Env, project_id: u64, donator: Address, amount: i128)

pub fn emit_deadline_extended(env: &Env, project_id: u64, old_deadline: u64, new_deadline: u64) {
let topics = (symbol_short!("ext_dead"), project_id);
let data = DeadlineExtended {
project_id,
old_deadline,
new_deadline,
};
env.events().publish(topics, data);
env.events().publish(topics, DeadlineExtended { project_id, old_deadline, new_deadline });
}

pub fn emit_protocol_config_updated(
env: &Env,
old_config: Option<ProtocolConfig>,
new_config: ProtocolConfig,
) {
pub fn emit_protocol_config_updated(env: &Env, old_config: Option<ProtocolConfig>, new_config: ProtocolConfig) {
let topics = (symbol_short!("cfg_upd"),);
let data = ProtocolConfigUpdated {
old_fee_recipient: old_config.as_ref().map(|cfg| cfg.fee_recipient.clone()),
old_fee_bps: old_config.map_or(0, |cfg| cfg.fee_bps),
new_fee_recipient: new_config.fee_recipient.clone(),
new_fee_bps: new_config.fee_bps,
};
env.events().publish(topics, data);
});
}

pub fn emit_fee_deducted(
Expand Down
23 changes: 23 additions & 0 deletions contracts/pifp_protocol/src/fuzz_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,29 @@ fn dummy_metadata_uri(env: &Env) -> Bytes {
)
}

fn register<'a>(
env: &Env,
client: &PifpProtocolClient<'a>,
creator: &Address,
tokens: &SorobanVec<Address>,
goal: i128,
proof_hash: &BytesN<32>,
deadline: u64,
) -> crate::types::Project {
let empty_oracles: SorobanVec<Address> = SorobanVec::new(env);
client.register_project(
creator,
tokens,
&goal,
proof_hash,
&dummy_metadata_uri(env),
&deadline,
&false,
&empty_oracles,
&0u32,
)
}

// ── 1. Registration Fuzz Tests ──────────────────────────────────────

proptest! {
Expand Down
Loading
Loading