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 96aa3c7..07d7a2b 100644 --- a/soroban-contract/contracts/event_manager/Cargo.toml +++ b/soroban-contract/contracts/event_manager/Cargo.toml @@ -2,14 +2,26 @@ name = "event_manager" version = "0.1.0" edition = "2021" -publish = false [lib] -crate-type = ["lib", "cdylib"] -doctest = false +crate-type = ["cdylib"] [dependencies] -soroban-sdk = { workspace = true } +soroban-sdk = "21.7.0" [dev-dependencies] -soroban-sdk = { workspace = true, features = ["testutils"] } +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 diff --git a/soroban-contract/contracts/event_manager/src/lib.rs b/soroban-contract/contracts/event_manager/src/lib.rs index ee7d10a..1e6502d 100644 --- a/soroban-contract/contracts/event_manager/src/lib.rs +++ b/soroban-contract/contracts/event_manager/src/lib.rs @@ -1,121 +1,380 @@ #![no_std] -use soroban_sdk::{contract, contractimpl, contracttype, symbol_short, Address, Env, Symbol}; -/// Storage keys for the contract -#[derive(Clone)] +use soroban_sdk::{ + contract, contractimpl, contracttype, Address, Env, IntoVal, String, Symbol, Vec, +}; + +// Storage keys #[contracttype] pub enum DataKey { - EventCount, Event(u32), + EventCounter, + TicketFactory, } -/// Event data structure -#[derive(Clone)] +// Event structure #[contracttype] +#[derive(Clone, Debug, Eq, PartialEq)] pub struct Event { pub id: u32, - pub theme: Symbol, + pub theme: String, pub organizer: Address, - pub event_type: Symbol, + pub event_type: String, pub total_tickets: u128, pub tickets_sold: u128, - pub ticket_price: u128, + pub ticket_price: i128, pub start_date: u64, pub end_date: u64, pub is_canceled: bool, - pub event_ticket_addr: Address, + pub ticket_nft_addr: Address, } #[contract] -pub struct EventManagerContract; +pub struct EventManager; #[contractimpl] -impl EventManagerContract { - /// Reschedule an existing event with new start and end dates. - /// - /// # Arguments - /// * `env` - The contract environment - /// * `event_id` - The ID of the event to reschedule - /// * `start_date` - The new start date (unix timestamp) - /// * `end_date` - The new end date (unix timestamp) - /// - /// # Panics - /// * If the event does not exist - /// * If the caller is not the event organizer - /// * If the event has already ended - pub fn reschedule_event(env: Env, event_id: u32, start_date: u64, end_date: u64) { - // Get the event count to verify event exists - let event_count: u32 = env - .storage() - .instance() - .get(&DataKey::EventCount) - .unwrap_or(0); - - // Check that event exists - if event_id == 0 || event_id > event_count { - panic!("Event does not exist"); +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"); } - // Get the event from storage - let event: Event = env - .storage() + // Store the ticket factory address + env.storage() .instance() - .get(&DataKey::Event(event_id)) - .expect("Event not found"); + .set(&DataKey::TicketFactory, &ticket_factory); - // Verify the organizer is authorized to reschedule - // require_auth ensures only the organizer can call this function - event.organizer.require_auth(); + // Initialize event counter + env.storage().instance().set(&DataKey::EventCounter, &0u32); + } - // Check that the event has not ended yet - let current_timestamp = env.ledger().timestamp(); - if event.end_date <= current_timestamp { - panic!("Event has already ended"); - } + /// 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, + ); - // Create updated event with new dates - let updated_event = Event { - id: event.id, - theme: event.theme, - organizer: event.organizer, - event_type: event.event_type, - total_tickets: event.total_tickets, - tickets_sold: event.tickets_sold, - ticket_price: event.ticket_price, + // 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, - event_ticket_addr: event.event_ticket_addr, + ticket_nft_addr: ticket_nft_addr.clone(), }; - // Store the updated event + // Store event env.storage() - .instance() - .set(&DataKey::Event(event_id), &updated_event); + .persistent() + .set(&DataKey::Event(event_id), &event); - // Emit EventRescheduled event + // Emit event creation event env.events().publish( - (symbol_short!("resched"), event_id), - (start_date, end_date), + (Symbol::new(&env, "event_created"),), + (event_id, organizer, ticket_nft_addr), ); + + event_id } - /// Get an event by its ID + /// Get event by ID pub fn get_event(env: Env, event_id: u32) -> Event { env.storage() - .instance() + .persistent() .get(&DataKey::Event(event_id)) - .expect("Event not found") + .unwrap_or_else(|| panic!("Event not found")) } - /// Get the total number of events + /// Get total number of events pub fn get_event_count(env: Env) -> u32 { env.storage() .instance() - .get(&DataKey::EventCount) + .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; +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); + } +} 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 d01d208..c3eff6e 100644 --- a/soroban-contract/contracts/tba_account/Cargo.toml +++ b/soroban-contract/contracts/tba_account/Cargo.toml @@ -1,12 +1,11 @@ [package] name = "tba_account" -version = "0.1.0" +version = "0.0.0" edition = "2021" publish = false [lib] -crate-type = ["lib", "cdylib"] -doctest = false +crate-type = ["cdylib"] [dependencies] soroban-sdk = { workspace = true } diff --git a/soroban-contract/contracts/tba_registry/Cargo.toml b/soroban-contract/contracts/tba_registry/Cargo.toml index 5e91b99..27b9b5e 100644 --- a/soroban-contract/contracts/tba_registry/Cargo.toml +++ b/soroban-contract/contracts/tba_registry/Cargo.toml @@ -1,12 +1,11 @@ [package] name = "tba_registry" -version = "0.1.0" +version = "0.0.0" edition = "2021" publish = false [lib] -crate-type = ["lib", "cdylib"] -doctest = false +crate-type = ["cdylib"] [dependencies] soroban-sdk = { workspace = true } diff --git a/soroban-contract/contracts/ticket_factory/Cargo.toml b/soroban-contract/contracts/ticket_factory/Cargo.toml index 1403c22..839a5d3 100644 --- a/soroban-contract/contracts/ticket_factory/Cargo.toml +++ b/soroban-contract/contracts/ticket_factory/Cargo.toml @@ -1,12 +1,11 @@ [package] name = "ticket_factory" -version = "0.1.0" +version = "0.0.0" edition = "2021" publish = false [lib] -crate-type = ["lib", "cdylib"] -doctest = false +crate-type = ["cdylib"] [dependencies] soroban-sdk = { workspace = true } diff --git a/soroban-contract/contracts/ticket_nft/Cargo.toml b/soroban-contract/contracts/ticket_nft/Cargo.toml index 81eae4b..823a20b 100644 --- a/soroban-contract/contracts/ticket_nft/Cargo.toml +++ b/soroban-contract/contracts/ticket_nft/Cargo.toml @@ -1,12 +1,11 @@ [package] name = "ticket_nft" -version = "0.1.0" +version = "0.0.0" edition = "2021" publish = false [lib] -crate-type = ["lib", "cdylib"] -doctest = false +crate-type = ["cdylib"] [dependencies] soroban-sdk = { workspace = true }