1616use soroban_sdk:: { contracttype, Address , Env , Symbol } ;
1717
1818use crate :: errors:: ContractError ;
19+ use crate :: events:: { InvoiceNftBurned , InvoiceNftMinted , InvoiceNftTransferred } ;
1920use crate :: storage:: DataKey ;
2021
2122/// NFT Metadata: complete information about an invoice NFT
@@ -85,8 +86,8 @@ pub fn mint_invoice_nft(
8586 due_date,
8687 discount_rate,
8788 token,
88- owner,
89- minted_at : env. ledger ( ) . timestamp ( ) ,
89+ owner : owner . clone ( ) ,
90+ minted_at : env. ledger ( ) . timestamp ( ) as u32 ,
9091 } ;
9192
9293 env. storage ( )
@@ -97,14 +98,21 @@ pub fn mint_invoice_nft(
9798 . persistent ( )
9899 . set ( & get_nft_owner_key ( invoice_id) , & owner) ;
99100
100- // Publish NFT minting event
101- env. events ( ) . publish_event ( (
102- Symbol :: new ( env, "invoice_nft_minted" ) ,
103- invoice_id,
104- owner,
105- amount,
106- due_date,
107- ) ) ;
101+ // Publish NFT minting event (Soroban SDK: publish(topics, data))
102+ env. events ( ) . publish (
103+ (
104+ Symbol :: new ( env, "invoice_nft_minted" ) ,
105+ invoice_id,
106+ owner. clone ( ) ,
107+ ) ,
108+ InvoiceNftMinted {
109+ invoice_id,
110+ owner,
111+ amount,
112+ due_date,
113+ timestamp : env. ledger ( ) . timestamp ( ) ,
114+ } ,
115+ ) ;
108116
109117 Ok ( ( ) )
110118}
@@ -148,13 +156,21 @@ pub fn transfer_invoice_nft(
148156 . persistent ( )
149157 . set ( & get_nft_owner_key ( invoice_id) , & to) ;
150158
151- // Publish NFT transfer event
152- env. events ( ) . publish_event ( (
153- Symbol :: new ( env, "invoice_nft_transferred" ) ,
154- invoice_id,
155- from,
156- to,
157- ) ) ;
159+ // Publish NFT transfer event (Soroban SDK: publish(topics, data))
160+ env. events ( ) . publish (
161+ (
162+ Symbol :: new ( env, "invoice_nft_transferred" ) ,
163+ invoice_id,
164+ from. clone ( ) ,
165+ to. clone ( ) ,
166+ ) ,
167+ InvoiceNftTransferred {
168+ invoice_id,
169+ from,
170+ to,
171+ timestamp : env. ledger ( ) . timestamp ( ) ,
172+ } ,
173+ ) ;
158174
159175 Ok ( ( ) )
160176}
@@ -191,12 +207,19 @@ pub fn burn_invoice_nft(env: &Env, invoice_id: u64, owner: Address) -> Result<()
191207 . persistent ( )
192208 . remove ( & get_nft_owner_key ( invoice_id) ) ;
193209
194- // Publish NFT burn event
195- env. events ( ) . publish_event ( (
196- Symbol :: new ( env, "invoice_nft_burned" ) ,
197- invoice_id,
198- owner,
199- ) ) ;
210+ // Publish NFT burn event (Soroban SDK: publish(topics, data))
211+ env. events ( ) . publish (
212+ (
213+ Symbol :: new ( env, "invoice_nft_burned" ) ,
214+ invoice_id,
215+ owner. clone ( ) ,
216+ ) ,
217+ InvoiceNftBurned {
218+ invoice_id,
219+ owner,
220+ timestamp : env. ledger ( ) . timestamp ( ) ,
221+ } ,
222+ ) ;
200223
201224 Ok ( ( ) )
202225}
0 commit comments