From 1457f3346918824b152a03780e62d3c43e137bbe Mon Sep 17 00:00:00 2001 From: Jordy Romuald <87231934+JordyRo1@users.noreply.github.com> Date: Wed, 19 Jun 2024 16:10:41 +0200 Subject: [PATCH] Feat: Refactor and documentation (#42) * feat: function documentation * feat: docs * feat: docs * feat: docs * fix: remove warnings /unused variables --------- Co-authored-by: 0xevolve --- contracts/src/contracts/mailbox.cairo | 4 ++-- contracts/src/tests/hooks/test_merkle_tree_hook.cairo | 2 +- contracts/src/tests/hooks/test_protocol_fee.cairo | 6 +++--- contracts/src/utils/store_arrays.cairo | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/contracts/src/contracts/mailbox.cairo b/contracts/src/contracts/mailbox.cairo index fc4454a..9229360 100644 --- a/contracts/src/contracts/mailbox.cairo +++ b/contracts/src/contracts/mailbox.cairo @@ -348,7 +348,7 @@ pub mod mailbox { /// /// # Returns /// - /// * The message ID inserted into the Mailbox's merkle tree + /// * The payment required to dispatch the message fn quote_dispatch( self: @ContractState, _destination_domain: u32, @@ -365,7 +365,7 @@ pub mod mailbox { Option::Some(hook_metadata) => hook_metadata, Option::None(()) => BytesTrait::new_empty(), }; - let (id, message) = build_message( + let (_, message) = build_message( self, _destination_domain, _recipient_address, _message_body.clone() ); let required_hook_address = self.required_hook.read(); diff --git a/contracts/src/tests/hooks/test_merkle_tree_hook.cairo b/contracts/src/tests/hooks/test_merkle_tree_hook.cairo index 5ff2f5b..0cea5e1 100644 --- a/contracts/src/tests/hooks/test_merkle_tree_hook.cairo +++ b/contracts/src/tests/hooks/test_merkle_tree_hook.cairo @@ -125,7 +125,7 @@ fn test_quote_dispatch_fails_if_invalid_variant() { #[test] fn test_count() { - let (merkle_tree, post_dispatch_hook, mut spy) = setup_merkle_tree_hook(); + let (merkle_tree, _, _) = setup_merkle_tree_hook(); let count = merkle_tree.count(); assert_eq!(count, 0); } diff --git a/contracts/src/tests/hooks/test_protocol_fee.cairo b/contracts/src/tests/hooks/test_protocol_fee.cairo index 09b079e..f31125e 100644 --- a/contracts/src/tests/hooks/test_protocol_fee.cairo +++ b/contracts/src/tests/hooks/test_protocol_fee.cairo @@ -88,7 +88,7 @@ fn test_collect_protocol_fee() { #[test] #[should_panic(expected: ('Insufficient balance',))] fn test_collect_protocol_fee_fails_if_insufficient_balance() { - let (fee_token, protocol_fee, _) = setup_protocol_fee(); + let (_, protocol_fee, _) = setup_protocol_fee(); protocol_fee.collect_protocol_fees(); } @@ -159,10 +159,10 @@ fn test_quote_dispatch() { #[test] #[should_panic(expected: ('Invalid metadata variant',))] fn test_quote_dispatch_fails_if_invalid_variant() { - let (fee_token, _, post_dispatch_hook) = setup_protocol_fee(); + let (_, _, post_dispatch_hook) = setup_protocol_fee(); let mut metadata = BytesTrait::new_empty(); let variant = 2; metadata.append_u16(variant); let message = MessageTrait::default(); - let res = post_dispatch_hook.quote_dispatch(metadata, message); + post_dispatch_hook.quote_dispatch(metadata, message); } diff --git a/contracts/src/utils/store_arrays.cairo b/contracts/src/utils/store_arrays.cairo index 93f3149..6a68a35 100644 --- a/contracts/src/utils/store_arrays.cairo +++ b/contracts/src/utils/store_arrays.cairo @@ -49,7 +49,7 @@ pub impl StoreFelt252Array of Store> { ) -> SyscallResult<()> { // // Store the length of the array in the first storage slot. let len: u8 = value.len().try_into().expect('Storage - Span too large'); - Store::::write_at_offset(address_domain, base, offset, len); + Store::::write_at_offset(address_domain, base, offset, len).unwrap(); offset += 1; // Store the array elements sequentially