From 5f53f50eecc78390d09f2394d2562805b3dd609e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CAkashBalasubramani-Router?= Date: Sat, 27 Jan 2024 04:14:01 +0530 Subject: [PATCH] feat : Code cleanup and added comments to the new functions --- src/core/lockup_linear.cairo | 53 ++++++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 17 deletions(-) diff --git a/src/core/lockup_linear.cairo b/src/core/lockup_linear.cairo index 3944034..3819d58 100644 --- a/src/core/lockup_linear.cairo +++ b/src/core/lockup_linear.cairo @@ -173,19 +173,35 @@ trait ITokeiLockupLinear { fn get_admin(self: @TContractState) -> ContractAddress; /// Returns the streams of the sender. + /// # Arguments + /// * `sender` - The address of the sender. + /// # Returns + /// * `streams` - The streams of the sender. fn get_streams_by_sender( self: @TContractState, sender: ContractAddress ) -> Array; /// Returns the streams of the recipient. + /// # Arguments + /// * `recipient` - The address of the recipient. + /// # Returns + /// * `streams` - The streams of the recipient. fn get_streams_by_recipient( self: @TContractState, recipient: ContractAddress ) -> Array; /// Returns the streams ids of the sender. + /// # Arguments + /// * `sender` - The address of the sender. + /// # Returns + /// * `stream_ids` - The stream ids of the sender. fn get_streams_ids_by_sender(self: @TContractState, sender: ContractAddress) -> Array; /// Returns the streams ids of the recipient. + /// # Arguments + /// * `recipient` - The address of the recipient. + /// # Returns + /// * `stream_ids` - The stream ids of the recipient. fn get_streams_ids_by_recipient( self: @TContractState, recipient: ContractAddress ) -> Array; @@ -831,6 +847,11 @@ mod TokeiLockupLinear { self.admin.read() } + /// Returns the streams of the sender. + /// # Arguments + /// * `sender` - The address of the sender. + /// # Returns + /// * `streams` - The streams of the sender. fn get_streams_by_sender( self: @ContractState, sender: ContractAddress ) -> Array { @@ -850,6 +871,11 @@ mod TokeiLockupLinear { streams } + /// Returns the streams of the recipient. + /// # Arguments + /// * `recipient` - The address of the recipient. + /// # Returns + /// * `streams` - The streams of the recipient. fn get_streams_by_recipient( self: @ContractState, recipient: ContractAddress ) -> Array { @@ -869,6 +895,11 @@ mod TokeiLockupLinear { streams } + /// Returns the streams ids of the sender. + /// # Arguments + /// * `sender` - The address of the sender. + /// # Returns + /// * `stream_ids` - The stream ids of the sender. fn get_streams_ids_by_sender(self: @ContractState, sender: ContractAddress) -> Array { let max_stream_id = self.next_stream_id.read(); let mut stream_ids: Array = ArrayTrait::new(); @@ -887,6 +918,11 @@ mod TokeiLockupLinear { stream_ids } + /// Returns the streams ids of the recipient. + /// # Arguments + /// * `recipient` - The address of the recipient. + /// # Returns + /// * `stream_ids` - The stream ids of the recipient. fn get_streams_ids_by_recipient( self: @ContractState, recipient: ContractAddress ) -> Array { @@ -907,23 +943,6 @@ mod TokeiLockupLinear { stream_ids } - // fn get_streams_ids_by_recipient( - // self: @ContractState, recipient: ContractAddress - // ) -> Array { - // let streams: Array = self.get_streams_by_recipient(recipient); - // let mut stream_ids: Array = ArrayTrait::new(); - // let mut i = 0; - // loop { - // if i >= streams.len() { - // break; - // } - // let stream = *streams.at(i); - // let stream_id = self.stream_id.read(stream); - // stream_ids.append(stream_id); - // i += 1; - // }; - // stream_ids - // } /// Creates a new stream with a given range. /// # Arguments