mod.rs (1652B)
1 #![allow(dead_code)] 2 3 use radroots_event::{ 4 envelope::EventEnvelope, envelope::EventEnvelopeParts, tag::EventPtr, tag::EventRef, 5 }; 6 use radroots_identity::PublicKey; 7 8 pub const EVENT_ID: &str = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; 9 pub const AUTHOR: &str = "585591529da0bab31b3b1b1f986611cf5f435dca84f978c89ee8a40cca7103df"; 10 pub const EVENT_SIG: &str = concat!( 11 "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc", 12 "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc" 13 ); 14 15 pub fn event_ref(id: &str, author: &str, kind: u32) -> EventRef { 16 EventRef { 17 id: id.to_string(), 18 author: PublicKey::from_hex(author).expect("valid fixture public key"), 19 kind, 20 d_tag: None, 21 relays: None, 22 } 23 } 24 25 pub fn event_ref_with_d( 26 id: &str, 27 author: &str, 28 kind: u32, 29 d_tag: &str, 30 relays: Option<Vec<String>>, 31 ) -> EventRef { 32 EventRef { 33 id: id.to_string(), 34 author: PublicKey::from_hex(author).expect("valid fixture public key"), 35 kind, 36 d_tag: Some(d_tag.to_string()), 37 relays, 38 } 39 } 40 41 pub fn event_ptr(id: &str, relays: Option<&str>) -> EventPtr { 42 EventPtr { 43 id: id.to_string(), 44 relays: relays.map(|s| s.to_string()), 45 } 46 } 47 48 pub fn nostr_event(kind: u32, content: &str, tags: Vec<Vec<String>>) -> EventEnvelope { 49 EventEnvelope::new(EventEnvelopeParts { 50 id: EVENT_ID.to_string(), 51 author: AUTHOR.to_string(), 52 created_at: 123, 53 kind, 54 tags, 55 content: content.to_string(), 56 sig: EVENT_SIG.to_string(), 57 }) 58 .unwrap() 59 }