@@ -305,46 +305,63 @@ impl<T: Config> Pallet<T> {
305305 T :: TreasuryPalletId :: get ( ) . into_account_truncating ( )
306306 }
307307
308+ // Function to cancel an issue request and slash collateral
308309 pub fn cancel_issue_request_and_slash_collateral ( issue_id : & H256 ) -> Result < BalanceOf < T > , DispatchError > {
310+ // Get the issue request using the provided issue_id
309311 let issue = Self :: get_issue_request_from_id ( issue_id) ?;
310312
313+ // Retrieve the amount of griefing collateral from the issue
311314 let griefing_collateral = issue. griefing_collateral ( ) ;
312315
316+ // Transfer griefing collateral from the requester's account to the vault's account
313317 ext:: vault_registry:: transfer_funds :: < T > (
314318 CurrencySource :: UserGriefing ( issue. requester . get_account ( ) . clone ( ) ) ,
315319 CurrencySource :: FreeBalance ( issue. vault . account_id ) ,
316320 & griefing_collateral,
317321 ) ?;
318322
323+ // Set the status of the issue request to 'Cancelled'
319324 Self :: set_issue_status ( issue_id. clone ( ) , IssueRequestStatus :: Cancelled ) ;
320325
326+ // Emit an event to indicate the cancellation of the issue request
321327 Self :: deposit_event ( Event :: CancelIssue {
322328 issue_id : issue_id. clone ( ) ,
323329 requester : issue. requester . get_account ( ) . clone ( ) ,
324330 griefing_collateral : griefing_collateral. amount ( ) ,
325331 } ) ;
326332
333+ // Return the amount of griefing collateral that was slashed
327334 Ok ( griefing_collateral. amount ( ) )
328335 }
329336
337+ // Function to retrieve the vault ID associated with a given issue ID
330338 pub fn get_vault_from_id_from_issue_id ( issue_id : & H256 ) -> Result < DefaultVaultId < T > , DispatchError > {
339+ // Retrieve the issue request using the provided issue_id
331340 let issue_request = Self :: get_issue_request_from_id ( issue_id) ?;
341+
342+ // Extract and return the associated vault ID from the issue request
332343 Ok ( issue_request. vault )
333344 }
334345
346+ // Function to complete a vault issue process
335347 pub fn _complete_vault_issue ( issue_id : H256 ) -> Result < ( ) , DispatchError > {
348+ // Retrieve the issue request using the provided issue_id
336349 let issue = Self :: get_issue_request_from_id ( & issue_id) ?;
350+
351+ // Calculate the total amount including both issue amount and fee
337352 let total = issue. amount ( ) . checked_add ( & issue. fee ( ) ) ?;
338- // issue_tokens -> decrease to_be_issued & increase issued for new vault
353+
354+ // Decrease the to-be-issued tokens and increase the issued tokens for the new vault
339355 ext:: vault_registry:: issue_tokens :: < T > ( & issue. vault , & total) ?;
340356
341- // distribute rewards
357+ // Distribute rewards based on the issue fee
342358 ext:: fee:: distribute_rewards :: < T > ( & issue. fee ( ) ) ?;
343359
344- // release griefing collateral
360+ // Release the locked griefing collateral to the requester's account
345361 let griefing_collateral: Amount < T > = issue. griefing_collateral ( ) ;
346362 griefing_collateral. unlock_on ( & issue. requester . get_account ( ) ) ?;
347363
364+ // Set the issue status to 'Completed'
348365 Self :: set_issue_status ( issue_id, IssueRequestStatus :: Completed ) ;
349366
350367 Ok ( ( ) )
0 commit comments