From 8a08f3f92d49131b09a7079f301b1282dde6ea47 Mon Sep 17 00:00:00 2001 From: bakarezainab Date: Fri, 23 Jan 2026 17:11:31 +0100 Subject: [PATCH] event management update --- .gitignore | 1 + .../contracts/event_manager/Cargo.toml | 27 ++ .../contracts/event_manager/src/lib.rs | 380 +++++++++++++++ .../test/test_cancel_event.1.json | 453 ++++++++++++++++++ .../test/test_create_event.1.json | 453 ++++++++++++++++++ .../test/test_create_event_past_date.1.json | 148 ++++++ .../contracts/tba_account/Cargo.toml | 14 + .../contracts/tba_registry/Cargo.toml | 14 + .../contracts/ticket_factory/Cargo.toml | 14 + .../contracts/ticket_nft/Cargo.toml | 14 + 10 files changed, 1518 insertions(+) create mode 100644 .gitignore create mode 100644 soroban-contract/contracts/event_manager/test_snapshots/test/test_cancel_event.1.json create mode 100644 soroban-contract/contracts/event_manager/test_snapshots/test/test_create_event.1.json create mode 100644 soroban-contract/contracts/event_manager/test_snapshots/test/test_create_event_past_date.1.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c7ad1ef --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +soroban.tar.gz diff --git a/soroban-contract/contracts/event_manager/Cargo.toml b/soroban-contract/contracts/event_manager/Cargo.toml index e69de29..0407022 100644 --- a/soroban-contract/contracts/event_manager/Cargo.toml +++ b/soroban-contract/contracts/event_manager/Cargo.toml @@ -0,0 +1,27 @@ +[package] +name = "event_manager" +version = "0.1.0" +edition = "2021" + +[lib] +crate-type = ["cdylib"] + +[dependencies] +soroban-sdk = "21.7.0" + +[dev-dependencies] +soroban-sdk = { version = "21.7.0", features = ["testutils"] } + +[profile.release] +opt-level = "z" +overflow-checks = true +debug = 0 +strip = "symbols" +debug-assertions = false +panic = "abort" +codegen-units = 1 +lto = true + +[profile.release-with-logs] +inherits = "release" +debug-assertions = true \ No newline at end of file diff --git a/soroban-contract/contracts/event_manager/src/lib.rs b/soroban-contract/contracts/event_manager/src/lib.rs index e69de29..2fd7d9e 100644 --- a/soroban-contract/contracts/event_manager/src/lib.rs +++ b/soroban-contract/contracts/event_manager/src/lib.rs @@ -0,0 +1,380 @@ +#![no_std] + +use soroban_sdk::{ + contract, contractimpl, contracttype, Address, Env, IntoVal, String, Symbol, Vec, +}; + +// Storage keys +#[contracttype] +pub enum DataKey { + Event(u32), + EventCounter, + TicketFactory, +} + +// Event structure +#[contracttype] +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct Event { + pub id: u32, + pub theme: String, + pub organizer: Address, + pub event_type: String, + pub total_tickets: u128, + pub tickets_sold: u128, + pub ticket_price: i128, + pub start_date: u64, + pub end_date: u64, + pub is_canceled: bool, + pub ticket_nft_addr: Address, +} + +#[contract] +pub struct EventManager; + +#[contractimpl] +impl EventManager { + /// Initialize the contract with the ticket factory address + pub fn initialize(env: Env, ticket_factory: Address) { + // Ensure not already initialized + if env.storage().instance().has(&DataKey::TicketFactory) { + panic!("Already initialized"); + } + + // Store the ticket factory address + env.storage() + .instance() + .set(&DataKey::TicketFactory, &ticket_factory); + + // Initialize event counter + env.storage().instance().set(&DataKey::EventCounter, &0u32); + } + + /// Create a new event + pub fn create_event( + env: Env, + organizer: Address, + theme: String, + event_type: String, + start_date: u64, + end_date: u64, + ticket_price: i128, + total_tickets: u128, + ) -> u32 { + // Validate organizer address + organizer.require_auth(); + + // Validate inputs + Self::validate_event_params( + &env, + start_date, + end_date, + ticket_price, + total_tickets, + ); + + // Get and increment event counter + let event_id = Self::get_and_increment_counter(&env); + + // Deploy ticket NFT contract via factory + let ticket_nft_addr = Self::deploy_ticket_nft( + &env, + event_id, + theme.clone(), + total_tickets, + ); + + // Create event struct + let event = Event { + id: event_id, + theme: theme.clone(), + organizer: organizer.clone(), + event_type, + total_tickets, + tickets_sold: 0, + ticket_price, + start_date, + end_date, + is_canceled: false, + ticket_nft_addr: ticket_nft_addr.clone(), + }; + + // Store event + env.storage() + .persistent() + .set(&DataKey::Event(event_id), &event); + + // Emit event creation event + env.events().publish( + (Symbol::new(&env, "event_created"),), + (event_id, organizer, ticket_nft_addr), + ); + + event_id + } + + /// Get event by ID + pub fn get_event(env: Env, event_id: u32) -> Event { + env.storage() + .persistent() + .get(&DataKey::Event(event_id)) + .unwrap_or_else(|| panic!("Event not found")) + } + + /// Get total number of events + pub fn get_event_count(env: Env) -> u32 { + env.storage() + .instance() + .get(&DataKey::EventCounter) + .unwrap_or(0) + } + + /// Get all events (pagination recommended for production) + pub fn get_all_events(env: Env) -> Vec { + let count = Self::get_event_count(env.clone()); + let mut events = Vec::new(&env); + + for i in 0..count { + if let Some(event) = env.storage().persistent().get(&DataKey::Event(i)) { + events.push_back(event); + } + } + + events + } + + /// Cancel an event + pub fn cancel_event(env: Env, event_id: u32) { + let mut event: Event = env + .storage() + .persistent() + .get(&DataKey::Event(event_id)) + .unwrap_or_else(|| panic!("Event not found")); + + // Only organizer can cancel + event.organizer.require_auth(); + + // Check if already canceled + if event.is_canceled { + panic!("Event already canceled"); + } + + // Mark as canceled + event.is_canceled = true; + + // Update storage + env.storage() + .persistent() + .set(&DataKey::Event(event_id), &event); + + // Emit cancellation event + env.events().publish( + (Symbol::new(&env, "event_canceled"),), + event_id, + ); + } + + /// Update tickets sold (called by ticket purchase logic) + pub fn update_tickets_sold(env: Env, event_id: u32, amount: u128) { + let mut event: Event = env + .storage() + .persistent() + .get(&DataKey::Event(event_id)) + .unwrap_or_else(|| panic!("Event not found")); + + // Verify the caller (should be the ticket NFT contract or authorized entity) + event.ticket_nft_addr.require_auth(); + + // Update tickets sold + event.tickets_sold = event + .tickets_sold + .checked_add(amount) + .unwrap_or_else(|| panic!("Overflow in tickets sold")); + + // Ensure we don't oversell + if event.tickets_sold > event.total_tickets { + panic!("Cannot sell more tickets than available"); + } + + // Update storage + env.storage() + .persistent() + .set(&DataKey::Event(event_id), &event); + } + + // ========== Helper Functions ========== + + fn validate_event_params( + env: &Env, + start_date: u64, + end_date: u64, + ticket_price: i128, + total_tickets: u128, + ) { + let current_time = env.ledger().timestamp(); + + // Validate dates + if start_date < current_time { + panic!("Start date must be in the future"); + } + + if end_date <= start_date { + panic!("End date must be after start date"); + } + + // Validate ticket price + if ticket_price < 0 { + panic!("Ticket price cannot be negative"); + } + + // Validate total tickets + if total_tickets == 0 { + panic!("Total tickets must be greater than 0"); + } + } + + fn get_and_increment_counter(env: &Env) -> u32 { + let current: u32 = env + .storage() + .instance() + .get(&DataKey::EventCounter) + .unwrap_or(0); + + let next = current + .checked_add(1) + .unwrap_or_else(|| panic!("Event counter overflow")); + + env.storage() + .instance() + .set(&DataKey::EventCounter, &next); + + current + } + + fn deploy_ticket_nft(env: &Env, event_id: u32, theme: String, total_supply: u128) -> Address { + let factory_addr: Address = env + .storage() + .instance() + .get(&DataKey::TicketFactory) + .unwrap_or_else(|| panic!("Ticket factory not initialized")); + + // Call the factory contract to deploy a new NFT contract + // This is a cross-contract call + use soroban_sdk::vec; + + let nft_addr: Address = env.invoke_contract( + &factory_addr, + &Symbol::new(env, "deploy_ticket_nft"), + vec![env, event_id.into_val(env), theme.into_val(env), total_supply.into_val(env)], + ); + + nft_addr + } +} + +#[cfg(test)] +mod test { + use super::*; + use soroban_sdk::{testutils::Address as _, Env}; + + #[test] + fn test_create_event() { + let env = Env::default(); + let contract_id = env.register_contract(None, EventManager); + let client = EventManagerClient::new(&env, &contract_id); + + let factory_addr = Address::generate(&env); + let organizer = Address::generate(&env); + + // Mock the organizer authorization + env.mock_all_auths(); + + // Initialize + client.initialize(&factory_addr); + + // Create event + let theme = String::from_str(&env, "Rust Conference 2026"); + let event_type = String::from_str(&env, "Conference"); + let start_date = env.ledger().timestamp() + 86400; // 1 day from now + let end_date = start_date + 86400; // 2 days from now + let ticket_price = 1000_0000000; // 100 XLM (7 decimals) + let total_tickets = 500; + + let event_id = client.create_event( + &organizer, + &theme, + &event_type, + &start_date, + &end_date, + &ticket_price, + &total_tickets, + ); + + assert_eq!(event_id, 0); + + // Get event + let event = client.get_event(&event_id); + assert_eq!(event.id, 0); + assert_eq!(event.organizer, organizer); + assert_eq!(event.total_tickets, total_tickets); + assert_eq!(event.tickets_sold, 0); + assert_eq!(event.is_canceled, false); + } + + #[test] + #[should_panic(expected = "Start date must be in the future")] + fn test_create_event_past_date() { + let env = Env::default(); + let contract_id = env.register_contract(None, EventManager); + let client = EventManagerClient::new(&env, &contract_id); + + let factory_addr = Address::generate(&env); + let organizer = Address::generate(&env); + + env.mock_all_auths(); + client.initialize(&factory_addr); + + let theme = String::from_str(&env, "Past Event"); + let event_type = String::from_str(&env, "Conference"); + let start_date = env.ledger().timestamp() - 1; // Past date + let end_date = start_date + 86400; + + client.create_event( + &organizer, + &theme, + &event_type, + &start_date, + &end_date, + &1000_0000000, + &100, + ); + } + + #[test] + fn test_cancel_event() { + let env = Env::default(); + let contract_id = env.register_contract(None, EventManager); + let client = EventManagerClient::new(&env, &contract_id); + + let factory_addr = Address::generate(&env); + let organizer = Address::generate(&env); + + env.mock_all_auths(); + client.initialize(&factory_addr); + + let event_id = client.create_event( + &organizer, + &String::from_str(&env, "Event"), + &String::from_str(&env, "Type"), + &(env.ledger().timestamp() + 86400), + &(env.ledger().timestamp() + 172800), + &1000_0000000, + &100, + ); + + client.cancel_event(&event_id); + + let event = client.get_event(&event_id); + assert_eq!(event.is_canceled, true); + } +} \ No newline at end of file diff --git a/soroban-contract/contracts/event_manager/test_snapshots/test/test_cancel_event.1.json b/soroban-contract/contracts/event_manager/test_snapshots/test/test_cancel_event.1.json new file mode 100644 index 0000000..d7eb7e2 --- /dev/null +++ b/soroban-contract/contracts/event_manager/test_snapshots/test/test_cancel_event.1.json @@ -0,0 +1,453 @@ +{ + "generators": { + "address": 3, + "nonce": 0 + }, + "auth": [ + [], + [] + ], + "ledger": { + "protocol_version": 21, + "sequence_number": 0, + "timestamp": 0, + "network_id": "0000000000000000000000000000000000000000000000000000000000000000", + "base_reserve": 0, + "min_persistent_entry_ttl": 4096, + "min_temp_entry_ttl": 16, + "max_entry_ttl": 6312000, + "ledger_entries": [ + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "storage": [ + { + "key": { + "vec": [ + { + "symbol": "EventCounter" + } + ] + }, + "val": { + "u32": 0 + } + }, + { + "key": { + "vec": [ + { + "symbol": "TicketFactory" + } + ] + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + } + ] + } + } + } + }, + "ext": "v0" + }, + 4095 + ] + ], + [ + { + "contract_code": { + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "code": "" + } + }, + "ext": "v0" + }, + 4095 + ] + ] + ] + }, + "events": [ + { + "event": { + "ext": "v0", + "contract_id": null, + "type_": "diagnostic", + "body": { + "v0": { + "topics": [ + { + "symbol": "fn_call" + }, + { + "bytes": "0000000000000000000000000000000000000000000000000000000000000001" + }, + { + "symbol": "initialize" + } + ], + "data": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + } + } + }, + "failed_call": false + }, + { + "event": { + "ext": "v0", + "contract_id": "0000000000000000000000000000000000000000000000000000000000000001", + "type_": "diagnostic", + "body": { + "v0": { + "topics": [ + { + "symbol": "fn_return" + }, + { + "symbol": "initialize" + } + ], + "data": "void" + } + } + }, + "failed_call": false + }, + { + "event": { + "ext": "v0", + "contract_id": null, + "type_": "diagnostic", + "body": { + "v0": { + "topics": [ + { + "symbol": "fn_call" + }, + { + "bytes": "0000000000000000000000000000000000000000000000000000000000000001" + }, + { + "symbol": "create_event" + } + ], + "data": { + "vec": [ + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + }, + { + "string": "Event" + }, + { + "string": "Type" + }, + { + "u64": 86400 + }, + { + "u64": 172800 + }, + { + "i128": { + "hi": 0, + "lo": 10000000000 + } + }, + { + "u128": { + "hi": 0, + "lo": 100 + } + } + ] + } + } + } + }, + "failed_call": false + }, + { + "event": { + "ext": "v0", + "contract_id": "0000000000000000000000000000000000000000000000000000000000000001", + "type_": "diagnostic", + "body": { + "v0": { + "topics": [ + { + "symbol": "fn_call" + }, + { + "bytes": "0000000000000000000000000000000000000000000000000000000000000002" + }, + { + "symbol": "deploy_ticket_nft" + } + ], + "data": { + "vec": [ + { + "u32": 0 + }, + { + "string": "Event" + }, + { + "u128": { + "hi": 0, + "lo": 100 + } + } + ] + } + } + } + }, + "failed_call": true + }, + { + "event": { + "ext": "v0", + "contract_id": "0000000000000000000000000000000000000000000000000000000000000001", + "type_": "diagnostic", + "body": { + "v0": { + "topics": [ + { + "symbol": "error" + }, + { + "error": { + "storage": "missing_value" + } + } + ], + "data": { + "string": "trying to get non-existing value for contract instance" + } + } + } + }, + "failed_call": true + }, + { + "event": { + "ext": "v0", + "contract_id": "0000000000000000000000000000000000000000000000000000000000000001", + "type_": "diagnostic", + "body": { + "v0": { + "topics": [ + { + "symbol": "error" + }, + { + "error": { + "storage": "missing_value" + } + } + ], + "data": { + "vec": [ + { + "string": "contract call failed" + }, + { + "symbol": "deploy_ticket_nft" + }, + { + "vec": [ + { + "u32": 0 + }, + { + "string": "Event" + }, + { + "u128": { + "hi": 0, + "lo": 100 + } + } + ] + } + ] + } + } + } + }, + "failed_call": true + }, + { + "event": { + "ext": "v0", + "contract_id": "0000000000000000000000000000000000000000000000000000000000000001", + "type_": "diagnostic", + "body": { + "v0": { + "topics": [ + { + "symbol": "error" + }, + { + "error": { + "storage": "missing_value" + } + } + ], + "data": { + "string": "escalating error to panic" + } + } + } + }, + "failed_call": true + }, + { + "event": { + "ext": "v0", + "contract_id": "0000000000000000000000000000000000000000000000000000000000000001", + "type_": "diagnostic", + "body": { + "v0": { + "topics": [ + { + "symbol": "error" + }, + { + "error": { + "storage": "missing_value" + } + } + ], + "data": { + "string": "caught error from function" + } + } + } + }, + "failed_call": true + }, + { + "event": { + "ext": "v0", + "contract_id": null, + "type_": "diagnostic", + "body": { + "v0": { + "topics": [ + { + "symbol": "error" + }, + { + "error": { + "storage": "missing_value" + } + } + ], + "data": { + "vec": [ + { + "string": "contract call failed" + }, + { + "symbol": "create_event" + }, + { + "vec": [ + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + }, + { + "string": "Event" + }, + { + "string": "Type" + }, + { + "u64": 86400 + }, + { + "u64": 172800 + }, + { + "i128": { + "hi": 0, + "lo": 10000000000 + } + }, + { + "u128": { + "hi": 0, + "lo": 100 + } + } + ] + } + ] + } + } + } + }, + "failed_call": false + }, + { + "event": { + "ext": "v0", + "contract_id": null, + "type_": "diagnostic", + "body": { + "v0": { + "topics": [ + { + "symbol": "error" + }, + { + "error": { + "storage": "missing_value" + } + } + ], + "data": { + "string": "escalating error to panic" + } + } + } + }, + "failed_call": false + } + ] +} \ No newline at end of file diff --git a/soroban-contract/contracts/event_manager/test_snapshots/test/test_create_event.1.json b/soroban-contract/contracts/event_manager/test_snapshots/test/test_create_event.1.json new file mode 100644 index 0000000..1c0baab --- /dev/null +++ b/soroban-contract/contracts/event_manager/test_snapshots/test/test_create_event.1.json @@ -0,0 +1,453 @@ +{ + "generators": { + "address": 3, + "nonce": 0 + }, + "auth": [ + [], + [] + ], + "ledger": { + "protocol_version": 21, + "sequence_number": 0, + "timestamp": 0, + "network_id": "0000000000000000000000000000000000000000000000000000000000000000", + "base_reserve": 0, + "min_persistent_entry_ttl": 4096, + "min_temp_entry_ttl": 16, + "max_entry_ttl": 6312000, + "ledger_entries": [ + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "storage": [ + { + "key": { + "vec": [ + { + "symbol": "EventCounter" + } + ] + }, + "val": { + "u32": 0 + } + }, + { + "key": { + "vec": [ + { + "symbol": "TicketFactory" + } + ] + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + } + ] + } + } + } + }, + "ext": "v0" + }, + 4095 + ] + ], + [ + { + "contract_code": { + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "code": "" + } + }, + "ext": "v0" + }, + 4095 + ] + ] + ] + }, + "events": [ + { + "event": { + "ext": "v0", + "contract_id": null, + "type_": "diagnostic", + "body": { + "v0": { + "topics": [ + { + "symbol": "fn_call" + }, + { + "bytes": "0000000000000000000000000000000000000000000000000000000000000001" + }, + { + "symbol": "initialize" + } + ], + "data": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + } + } + }, + "failed_call": false + }, + { + "event": { + "ext": "v0", + "contract_id": "0000000000000000000000000000000000000000000000000000000000000001", + "type_": "diagnostic", + "body": { + "v0": { + "topics": [ + { + "symbol": "fn_return" + }, + { + "symbol": "initialize" + } + ], + "data": "void" + } + } + }, + "failed_call": false + }, + { + "event": { + "ext": "v0", + "contract_id": null, + "type_": "diagnostic", + "body": { + "v0": { + "topics": [ + { + "symbol": "fn_call" + }, + { + "bytes": "0000000000000000000000000000000000000000000000000000000000000001" + }, + { + "symbol": "create_event" + } + ], + "data": { + "vec": [ + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + }, + { + "string": "Rust Conference 2026" + }, + { + "string": "Conference" + }, + { + "u64": 86400 + }, + { + "u64": 172800 + }, + { + "i128": { + "hi": 0, + "lo": 10000000000 + } + }, + { + "u128": { + "hi": 0, + "lo": 500 + } + } + ] + } + } + } + }, + "failed_call": false + }, + { + "event": { + "ext": "v0", + "contract_id": "0000000000000000000000000000000000000000000000000000000000000001", + "type_": "diagnostic", + "body": { + "v0": { + "topics": [ + { + "symbol": "fn_call" + }, + { + "bytes": "0000000000000000000000000000000000000000000000000000000000000002" + }, + { + "symbol": "deploy_ticket_nft" + } + ], + "data": { + "vec": [ + { + "u32": 0 + }, + { + "string": "Rust Conference 2026" + }, + { + "u128": { + "hi": 0, + "lo": 500 + } + } + ] + } + } + } + }, + "failed_call": true + }, + { + "event": { + "ext": "v0", + "contract_id": "0000000000000000000000000000000000000000000000000000000000000001", + "type_": "diagnostic", + "body": { + "v0": { + "topics": [ + { + "symbol": "error" + }, + { + "error": { + "storage": "missing_value" + } + } + ], + "data": { + "string": "trying to get non-existing value for contract instance" + } + } + } + }, + "failed_call": true + }, + { + "event": { + "ext": "v0", + "contract_id": "0000000000000000000000000000000000000000000000000000000000000001", + "type_": "diagnostic", + "body": { + "v0": { + "topics": [ + { + "symbol": "error" + }, + { + "error": { + "storage": "missing_value" + } + } + ], + "data": { + "vec": [ + { + "string": "contract call failed" + }, + { + "symbol": "deploy_ticket_nft" + }, + { + "vec": [ + { + "u32": 0 + }, + { + "string": "Rust Conference 2026" + }, + { + "u128": { + "hi": 0, + "lo": 500 + } + } + ] + } + ] + } + } + } + }, + "failed_call": true + }, + { + "event": { + "ext": "v0", + "contract_id": "0000000000000000000000000000000000000000000000000000000000000001", + "type_": "diagnostic", + "body": { + "v0": { + "topics": [ + { + "symbol": "error" + }, + { + "error": { + "storage": "missing_value" + } + } + ], + "data": { + "string": "escalating error to panic" + } + } + } + }, + "failed_call": true + }, + { + "event": { + "ext": "v0", + "contract_id": "0000000000000000000000000000000000000000000000000000000000000001", + "type_": "diagnostic", + "body": { + "v0": { + "topics": [ + { + "symbol": "error" + }, + { + "error": { + "storage": "missing_value" + } + } + ], + "data": { + "string": "caught error from function" + } + } + } + }, + "failed_call": true + }, + { + "event": { + "ext": "v0", + "contract_id": null, + "type_": "diagnostic", + "body": { + "v0": { + "topics": [ + { + "symbol": "error" + }, + { + "error": { + "storage": "missing_value" + } + } + ], + "data": { + "vec": [ + { + "string": "contract call failed" + }, + { + "symbol": "create_event" + }, + { + "vec": [ + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + }, + { + "string": "Rust Conference 2026" + }, + { + "string": "Conference" + }, + { + "u64": 86400 + }, + { + "u64": 172800 + }, + { + "i128": { + "hi": 0, + "lo": 10000000000 + } + }, + { + "u128": { + "hi": 0, + "lo": 500 + } + } + ] + } + ] + } + } + } + }, + "failed_call": false + }, + { + "event": { + "ext": "v0", + "contract_id": null, + "type_": "diagnostic", + "body": { + "v0": { + "topics": [ + { + "symbol": "error" + }, + { + "error": { + "storage": "missing_value" + } + } + ], + "data": { + "string": "escalating error to panic" + } + } + } + }, + "failed_call": false + } + ] +} \ No newline at end of file diff --git a/soroban-contract/contracts/event_manager/test_snapshots/test/test_create_event_past_date.1.json b/soroban-contract/contracts/event_manager/test_snapshots/test/test_create_event_past_date.1.json new file mode 100644 index 0000000..283a765 --- /dev/null +++ b/soroban-contract/contracts/event_manager/test_snapshots/test/test_create_event_past_date.1.json @@ -0,0 +1,148 @@ +{ + "generators": { + "address": 3, + "nonce": 0 + }, + "auth": [ + [] + ], + "ledger": { + "protocol_version": 21, + "sequence_number": 0, + "timestamp": 0, + "network_id": "0000000000000000000000000000000000000000000000000000000000000000", + "base_reserve": 0, + "min_persistent_entry_ttl": 4096, + "min_temp_entry_ttl": 16, + "max_entry_ttl": 6312000, + "ledger_entries": [ + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "storage": [ + { + "key": { + "vec": [ + { + "symbol": "EventCounter" + } + ] + }, + "val": { + "u32": 0 + } + }, + { + "key": { + "vec": [ + { + "symbol": "TicketFactory" + } + ] + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + } + ] + } + } + } + }, + "ext": "v0" + }, + 4095 + ] + ], + [ + { + "contract_code": { + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "code": "" + } + }, + "ext": "v0" + }, + 4095 + ] + ] + ] + }, + "events": [ + { + "event": { + "ext": "v0", + "contract_id": null, + "type_": "diagnostic", + "body": { + "v0": { + "topics": [ + { + "symbol": "fn_call" + }, + { + "bytes": "0000000000000000000000000000000000000000000000000000000000000001" + }, + { + "symbol": "initialize" + } + ], + "data": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + } + } + }, + "failed_call": false + }, + { + "event": { + "ext": "v0", + "contract_id": "0000000000000000000000000000000000000000000000000000000000000001", + "type_": "diagnostic", + "body": { + "v0": { + "topics": [ + { + "symbol": "fn_return" + }, + { + "symbol": "initialize" + } + ], + "data": "void" + } + } + }, + "failed_call": false + } + ] +} \ No newline at end of file diff --git a/soroban-contract/contracts/tba_account/Cargo.toml b/soroban-contract/contracts/tba_account/Cargo.toml index e69de29..5a5138d 100644 --- a/soroban-contract/contracts/tba_account/Cargo.toml +++ b/soroban-contract/contracts/tba_account/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "tba_account" +version = "0.0.0" +edition = "2021" +publish = false + +[lib] +crate-type = ["cdylib"] + +[dependencies] +soroban-sdk = { workspace = true } + +[dev-dependencies] +soroban-sdk = { workspace = true, features = ["testutils"] } \ No newline at end of file diff --git a/soroban-contract/contracts/tba_registry/Cargo.toml b/soroban-contract/contracts/tba_registry/Cargo.toml index e69de29..9002d14 100644 --- a/soroban-contract/contracts/tba_registry/Cargo.toml +++ b/soroban-contract/contracts/tba_registry/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "tba_registry" +version = "0.0.0" +edition = "2021" +publish = false + +[lib] +crate-type = ["cdylib"] + +[dependencies] +soroban-sdk = { workspace = true } + +[dev-dependencies] +soroban-sdk = { workspace = true, features = ["testutils"] } \ No newline at end of file diff --git a/soroban-contract/contracts/ticket_factory/Cargo.toml b/soroban-contract/contracts/ticket_factory/Cargo.toml index e69de29..04e8955 100644 --- a/soroban-contract/contracts/ticket_factory/Cargo.toml +++ b/soroban-contract/contracts/ticket_factory/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "ticket_factory" +version = "0.0.0" +edition = "2021" +publish = false + +[lib] +crate-type = ["cdylib"] + +[dependencies] +soroban-sdk = { workspace = true } + +[dev-dependencies] +soroban-sdk = { workspace = true, features = ["testutils"] } \ No newline at end of file diff --git a/soroban-contract/contracts/ticket_nft/Cargo.toml b/soroban-contract/contracts/ticket_nft/Cargo.toml index e69de29..97f069b 100644 --- a/soroban-contract/contracts/ticket_nft/Cargo.toml +++ b/soroban-contract/contracts/ticket_nft/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "ticket_nft" +version = "0.0.0" +edition = "2021" +publish = false + +[lib] +crate-type = ["cdylib"] + +[dependencies] +soroban-sdk = { workspace = true } + +[dev-dependencies] +soroban-sdk = { workspace = true, features = ["testutils"] } \ No newline at end of file