diff --git a/src/ascii/README.md b/src/ascii/README.md index 0f826fda..1a58bf3d 100644 --- a/src/ascii/README.md +++ b/src/ascii/README.md @@ -1,11 +1,11 @@ # ASCII -## Interger +## Integer -1. Split Intergers into an array of its individual ascii values +1. Split Integers into an array of its individual ascii values > 123 -> [49,50,51] -2. Converts Intergers into a string represented as either a single felt252 or if it exceeds 31 chars an array of felt252 +2. Converts Integers into a string represented as either a single felt252 or if it exceeds 31 chars an array of felt252 > 123 -> "123 diff --git a/src/ascii/src/interger.cairo b/src/ascii/src/integer.cairo similarity index 90% rename from src/ascii/src/interger.cairo rename to src/ascii/src/integer.cairo index efab5ff3..535be864 100644 --- a/src/ascii/src/interger.cairo +++ b/src/ascii/src/integer.cairo @@ -8,13 +8,13 @@ trait ToAsciiTrait { fn to_ascii(self: T) -> U; } -// converts intergers into an array of its individual ascii values +// converts integers into an array of its individual ascii values trait ToAsciiArrayTrait { fn to_ascii_array(self: T) -> Array; fn to_inverse_ascii_array(self: T) -> Array; } -// converts intergers into an array of its individual ascii values +// converts integers into an array of its individual ascii values // e.g. 123 -> [49, 50, 51] impl ToAsciiArrayTraitImpl< T, @@ -54,10 +54,10 @@ impl ToAsciiArrayTraitImpl< } } -// gneric implementation for small intergers "1000" -impl SmallIntergerToAsciiTraitImpl< +impl SmallIntegerToAsciiTraitImpl< T, impl TPartialOrd: PartialOrd, impl TDivRem: DivRem, @@ -86,10 +86,10 @@ impl SmallIntergerToAsciiTraitImpl< } } -// gneric implementation for big intergers u128 -// to transform its intergers into a string represented as multiple felt252 if there is overflow +// generic implementation for big integers u128 +// to transform its integers into a string represented as multiple felt252 if there is overflow // e.g. max_num + 123 -> ["max_num", "123"] -impl BigIntergerToAsciiTraitImpl< +impl BigIntegerToAsciiTraitImpl< T, impl TPartialOrd: PartialOrd, impl TDivRem: DivRem, @@ -125,7 +125,7 @@ impl BigIntergerToAsciiTraitImpl< }, Option::None(_) => { // if ascii is 0 it means we have already appended the first ascii - // and theres no need to append it again + // and there's no need to append it again if ascii.is_non_zero() { data.append(ascii); } @@ -141,8 +141,8 @@ impl BigIntergerToAsciiTraitImpl< // -------------------------------------------------------------------------- // // for u256 // // -------------------------------------------------------------------------- // -// have to implement seperately for u256 because -// it dosent have the same implementations as the generic version +// have to implement separately for u256 because +// it doesn't have the same implementations as the generic version impl U256ToAsciiArrayTraitImpl of ToAsciiArrayTrait { fn to_ascii_array(self: u256) -> Array { let mut new_arr = self.to_inverse_ascii_array(); @@ -200,7 +200,7 @@ impl U256ToAsciiTraitImpl of ToAsciiTrait> { }, Option::None(_) => { // if ascii is 0 it means we have already appended the first ascii - // and theres no need to append it again + // and there's no need to append it again if ascii.is_non_zero() { data.append(ascii); } diff --git a/src/ascii/src/lib.cairo b/src/ascii/src/lib.cairo index 4b8fb3b7..53d0feea 100644 --- a/src/ascii/src/lib.cairo +++ b/src/ascii/src/lib.cairo @@ -1,5 +1,5 @@ -mod interger; -use interger::{ToAsciiTrait, ToAsciiArrayTrait}; +mod integer; +use integer::{ToAsciiTrait, ToAsciiArrayTrait}; #[cfg(test)] mod tests; diff --git a/src/ascii/src/tests.cairo b/src/ascii/src/tests.cairo index b4c61787..091ca418 100644 --- a/src/ascii/src/tests.cairo +++ b/src/ascii/src/tests.cairo @@ -1 +1 @@ -mod test_ascii_interger; +mod test_ascii_integer; diff --git a/src/ascii/src/tests/test_ascii_interger.cairo b/src/ascii/src/tests/test_ascii_integer.cairo similarity index 100% rename from src/ascii/src/tests/test_ascii_interger.cairo rename to src/ascii/src/tests/test_ascii_integer.cairo diff --git a/src/bytes/src/bytes.cairo b/src/bytes/src/bytes.cairo index eddfd4e2..96ca61f8 100644 --- a/src/bytes/src/bytes.cairo +++ b/src/bytes/src/bytes.cairo @@ -20,14 +20,14 @@ const BYTES_PER_ELEMENT: usize = 16; /// Bytes is a cairo implementation of solidity Bytes in Big-endian. /// It is a dynamic array of u128, where each element contains 16 bytes. /// To save cost, the last element MUST be filled fully. -/// That's means that every element should and MUST contains 16 bytes. +/// That means that every element should and MUST contain 16 bytes. /// For example, if we have a Bytes with 33 bytes, we will have 3 elements. -/// Theroetically, the bytes looks like this: +/// Theoretically, the bytes look like this: /// first element: [16 bytes] /// second element: [16 bytes] /// third element: [1 byte] /// But in alexandria bytes, the last element should be padded with zero to make -/// it 16 bytes. So the alexandria bytes looks like this: +/// it 16 bytes. So the alexandria bytes look like this: /// first element: [16 bytes] /// second element: [16 bytes] /// third element: [1 byte] + [15 bytes zero padding] @@ -508,7 +508,7 @@ impl BytesImpl of BytesTrait { return keccak_u128s_be(self.data.span(), self.size()); } else { let mut hash_data = u128_array_slice(self.data, 0, last_data_index); - // To cumpute hash, we should remove 0 padded + // To compute hash, we should remove 0 padded let (last_element_value, _) = u128_split( *self.data[last_data_index], BYTES_PER_ELEMENT, last_element_size );