File tree Expand file tree Collapse file tree 2 files changed +26
-8
lines changed Expand file tree Collapse file tree 2 files changed +26
-8
lines changed Original file line number Diff line number Diff line change 6
6
7
7
tag = Tag .parse (["p" , other_user_pk .to_hex ()])
8
8
# OR
9
- tag = Tag .from_enum (TagEnum .PUB_KEY (other_user_pk .to_hex (), None ))
9
+ tag = Tag .from_enum (TagEnum .PUBLIC_KEY_TAG (other_user_pk , None , None , False ))
10
+ # OR
11
+ tag = Tag .public_key (other_user_pk )
10
12
11
13
event = EventBuilder .new_text_note ("New note from Rust Nostr python bindings" , [tag ]).to_event (keys )
12
14
print (event .as_json ())
Original file line number Diff line number Diff line change @@ -901,17 +901,33 @@ impl Deref for Tag {
901
901
#[ uniffi:: export]
902
902
impl Tag {
903
903
#[ uniffi:: constructor]
904
- pub fn parse ( data : Vec < String > ) -> Result < Arc < Self > > {
905
- Ok ( Arc :: new ( Self {
906
- inner : tag:: Tag :: try_from ( data) ?,
907
- } ) )
904
+ pub fn parse ( data : Vec < String > ) -> Result < Self > {
905
+ Ok ( Self {
906
+ inner : tag:: Tag :: parse ( data) ?,
907
+ } )
908
908
}
909
909
910
910
#[ uniffi:: constructor]
911
- pub fn from_enum ( e : TagEnum ) -> Result < Arc < Self > > {
912
- Ok ( Arc :: new ( Self {
911
+ pub fn from_enum ( e : TagEnum ) -> Result < Self > {
912
+ Ok ( Self {
913
913
inner : tag:: Tag :: try_from ( e) ?,
914
- } ) )
914
+ } )
915
+ }
916
+
917
+ /// Compose `["p", "<public-key>"]` tag
918
+ #[ uniffi:: constructor]
919
+ pub fn public_key ( public_key : Arc < PublicKey > ) -> Self {
920
+ Self {
921
+ inner : tag:: Tag :: public_key ( * * public_key) ,
922
+ }
923
+ }
924
+
925
+ /// Compose `["e", "<event-id>"]` tag
926
+ #[ uniffi:: constructor]
927
+ pub fn event ( event_id : Arc < EventId > ) -> Self {
928
+ Self {
929
+ inner : tag:: Tag :: event ( * * event_id) ,
930
+ }
915
931
}
916
932
917
933
pub fn as_enum ( & self ) -> TagEnum {
You can’t perform that action at this time.
0 commit comments