From 5ad9d0e750a212bab9d0cb2fcf243a4e83e2f319 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Thei=C3=9Fen?= Date: Sat, 1 Jul 2023 15:27:08 +0200 Subject: [PATCH 01/13] Remove unchecked arithmetic --- crates/env/Cargo.toml | 1 - crates/env/src/call/execution_input.rs | 8 ++++++-- crates/env/src/engine/mod.rs | 21 +++++++++++++++++++++ crates/env/src/engine/off_chain/impls.rs | 8 ++++---- crates/env/src/engine/on_chain/buffer.rs | 15 ++++++++------- crates/env/src/engine/on_chain/impls.rs | 8 ++++---- crates/env/src/topics.rs | 5 ++++- 7 files changed, 47 insertions(+), 19 deletions(-) diff --git a/crates/env/Cargo.toml b/crates/env/Cargo.toml index d3f4840024..1dc4d54d6f 100644 --- a/crates/env/Cargo.toml +++ b/crates/env/Cargo.toml @@ -26,7 +26,6 @@ derive_more = { version = "0.99", default-features = false, features = ["from", num-traits = { version = "0.2", default-features = false, features = ["i128"] } cfg-if = "1.0" paste = "1.0" -arrayref = "0.3" static_assertions = "1.1" [target.'cfg(target_arch = "wasm32")'.dependencies] diff --git a/crates/env/src/call/execution_input.rs b/crates/env/src/call/execution_input.rs index 9ed23c5303..3ef541275e 100644 --- a/crates/env/src/call/execution_input.rs +++ b/crates/env/src/call/execution_input.rs @@ -184,7 +184,9 @@ where { #[inline] fn size_hint(&self) -> usize { - scale::Encode::size_hint(&self.head) + scale::Encode::size_hint(&self.rest) + scale::Encode::size_hint(&self.head) + .checked_add(scale::Encode::size_hint(&self.rest)) + .unwrap() } #[inline] @@ -204,7 +206,9 @@ where { #[inline] fn size_hint(&self) -> usize { - scale::Encode::size_hint(&self.selector) + scale::Encode::size_hint(&self.args) + scale::Encode::size_hint(&self.selector) + .checked_add(scale::Encode::size_hint(&self.args)) + .unwrap() } #[inline] diff --git a/crates/env/src/engine/mod.rs b/crates/env/src/engine/mod.rs index a0a99cecb5..8cf7b8e263 100644 --- a/crates/env/src/engine/mod.rs +++ b/crates/env/src/engine/mod.rs @@ -31,6 +31,27 @@ use ink_primitives::{ LangError, }; +/// Convert a slice into an array reference. +/// +/// Creates an array reference of size $len pointing to $offset within $arr. +/// +/// # Panics +/// +/// - The selected range is out of bounds given the supplied slice +/// - Integer overflow on $offset + $len +macro_rules! array_mut_ref { + ($arr:expr, $offset:expr, $len:expr) => {{ + { + fn as_array(slice: &mut [T]) -> &mut [T; $len] { + slice.try_into().unwrap() + } + let offset: usize = $offset; + let slice = &mut $arr[offset..offset.checked_add($len).unwrap()]; + as_array(slice) + } + }}; +} + pub trait OnInstance: EnvBackend + TypedEnvBackend { fn on_instance(f: F) -> R where diff --git a/crates/env/src/engine/off_chain/impls.rs b/crates/env/src/engine/off_chain/impls.rs index 1970b28041..ecf288aea1 100644 --- a/crates/env/src/engine/off_chain/impls.rs +++ b/crates/env/src/engine/off_chain/impls.rs @@ -60,7 +60,7 @@ impl CryptoHash for Blake2x128 { ::Type, OutputType ); - let output: &mut OutputType = arrayref::array_mut_ref!(output, 0, 16); + let output: &mut OutputType = array_mut_ref!(output, 0, 16); Engine::hash_blake2_128(input, output); } } @@ -72,7 +72,7 @@ impl CryptoHash for Blake2x256 { ::Type, OutputType ); - let output: &mut OutputType = arrayref::array_mut_ref!(output, 0, 32); + let output: &mut OutputType = array_mut_ref!(output, 0, 32); Engine::hash_blake2_256(input, output); } } @@ -84,7 +84,7 @@ impl CryptoHash for Sha2x256 { ::Type, OutputType ); - let output: &mut OutputType = arrayref::array_mut_ref!(output, 0, 32); + let output: &mut OutputType = array_mut_ref!(output, 0, 32); Engine::hash_sha2_256(input, output); } } @@ -96,7 +96,7 @@ impl CryptoHash for Keccak256 { ::Type, OutputType ); - let output: &mut OutputType = arrayref::array_mut_ref!(output, 0, 32); + let output: &mut OutputType = array_mut_ref!(output, 0, 32); Engine::hash_keccak_256(input, output); } } diff --git a/crates/env/src/engine/on_chain/buffer.rs b/crates/env/src/engine/on_chain/buffer.rs index 1d74f904a0..fbf99f5dc1 100644 --- a/crates/env/src/engine/on_chain/buffer.rs +++ b/crates/env/src/engine/on_chain/buffer.rs @@ -80,15 +80,16 @@ impl<'a> EncodeScope<'a> { impl<'a> scale::Output for EncodeScope<'a> { fn write(&mut self, bytes: &[u8]) { debug_assert!( - self.len() + bytes.len() <= self.capacity(), + self.len().checked_add(bytes.len()).unwrap() <= self.capacity(), "encode scope buffer overflowed. capacity is {} but last write index is {}", self.capacity(), - self.len() + bytes.len(), + self.len().checked_add(bytes.len()).unwrap(), ); let start = self.len; let len_bytes = bytes.len(); - self.buffer[start..(start + len_bytes)].copy_from_slice(bytes); - self.len += len_bytes; + self.buffer[start..(start.checked_add(len_bytes)).unwrap()] + .copy_from_slice(bytes); + self.len = self.len.checked_add(len_bytes).unwrap(); } fn push_byte(&mut self, byte: u8) { @@ -99,7 +100,7 @@ impl<'a> scale::Output for EncodeScope<'a> { self.capacity(), ); self.buffer[self.len] = byte; - self.len += 1; + self.len = self.len.checked_add(1).unwrap(); } } @@ -142,7 +143,7 @@ impl<'a> ScopedBuffer<'a> { self.buffer = rhs; debug_assert_eq!(lhs.len(), len); let len_after = self.buffer.len(); - debug_assert_eq!(len_before - len_after, len); + debug_assert_eq!(len_before.checked_sub(len_after).unwrap(), len); lhs } @@ -193,7 +194,7 @@ impl<'a> ScopedBuffer<'a> { let mut encode_scope = EncodeScope::from(&mut buffer[offset..]); scale::Encode::encode_to(&value, &mut encode_scope); let encode_len = encode_scope.len(); - self.offset += encode_len; + self.offset = self.offset.checked_add(encode_len).unwrap(); let _ = core::mem::replace(&mut self.buffer, buffer); } diff --git a/crates/env/src/engine/on_chain/impls.rs b/crates/env/src/engine/on_chain/impls.rs index bb0bc5ed78..994602f80c 100644 --- a/crates/env/src/engine/on_chain/impls.rs +++ b/crates/env/src/engine/on_chain/impls.rs @@ -57,7 +57,7 @@ impl CryptoHash for Blake2x128 { ::Type, OutputType ); - let output: &mut OutputType = arrayref::array_mut_ref!(output, 0, 16); + let output: &mut OutputType = array_mut_ref!(output, 0, 16); ext::hash_blake2_128(input, output); } } @@ -69,7 +69,7 @@ impl CryptoHash for Blake2x256 { ::Type, OutputType ); - let output: &mut OutputType = arrayref::array_mut_ref!(output, 0, 32); + let output: &mut OutputType = array_mut_ref!(output, 0, 32); ext::hash_blake2_256(input, output); } } @@ -81,7 +81,7 @@ impl CryptoHash for Sha2x256 { ::Type, OutputType ); - let output: &mut OutputType = arrayref::array_mut_ref!(output, 0, 32); + let output: &mut OutputType = array_mut_ref!(output, 0, 32); ext::hash_sha2_256(input, output); } } @@ -93,7 +93,7 @@ impl CryptoHash for Keccak256 { ::Type, OutputType ); - let output: &mut OutputType = arrayref::array_mut_ref!(output, 0, 32); + let output: &mut OutputType = array_mut_ref!(output, 0, 32); ext::hash_keccak_256(input, output); } } diff --git a/crates/env/src/topics.rs b/crates/env/src/topics.rs index a55eac11b6..5565b778fb 100644 --- a/crates/env/src/topics.rs +++ b/crates/env/src/topics.rs @@ -228,7 +228,10 @@ where { #[inline] fn size_hint(&self) -> usize { - self.prefix.size_hint() + self.value.size_hint() + self.prefix + .size_hint() + .checked_add(self.value.size_hint()) + .unwrap() } #[inline] From 9c4e59f6fb2f14d621ef7b0a5d2314a227c0f5aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Thei=C3=9Fen?= Date: Sun, 2 Jul 2023 11:01:31 +0200 Subject: [PATCH 02/13] Remove from erc20 --- integration-tests/erc20/lib.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/integration-tests/erc20/lib.rs b/integration-tests/erc20/lib.rs index f00c2eb25e..707733f926 100644 --- a/integration-tests/erc20/lib.rs +++ b/integration-tests/erc20/lib.rs @@ -178,6 +178,8 @@ mod erc20 { return Err(Error::InsufficientAllowance) } self.transfer_from_to(&from, &to, value)?; + // We checked that allowance >= value + #[allow(clippy::arithmetic_side_effects)] self.allowances .insert((&from, &caller), &(allowance - value)); Ok(()) @@ -201,10 +203,12 @@ mod erc20 { if from_balance < value { return Err(Error::InsufficientBalance) } - + // We checked that from_balance >= value + #[allow(clippy::arithmetic_side_effects)] self.balances.insert(from, &(from_balance - value)); let to_balance = self.balance_of_impl(to); - self.balances.insert(to, &(to_balance + value)); + self.balances + .insert(to, &(to_balance.checked_add(value).unwrap())); self.env().emit_event(Transfer { from: Some(*from), to: Some(*to), From 8ba8725e2ca2f6c1eaac8ad56b0612cb3bb84e4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Thei=C3=9Fen?= Date: Sun, 2 Jul 2023 11:09:59 +0200 Subject: [PATCH 03/13] Remove from erc1155 --- integration-tests/erc1155/lib.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/integration-tests/erc1155/lib.rs b/integration-tests/erc1155/lib.rs index ec0bf7ba69..f552f1eb27 100644 --- a/integration-tests/erc1155/lib.rs +++ b/integration-tests/erc1155/lib.rs @@ -267,7 +267,10 @@ mod erc1155 { // Given that TokenId is a `u128` the likelihood of this overflowing is pretty // slim. - self.token_id_nonce += 1; + #[allow(clippy::arithmetic_side_effects)] + { + self.token_id_nonce += 1; + } self.balances.insert((caller, self.token_id_nonce), &value); // Emit transfer event but with mint semantics @@ -329,11 +332,15 @@ mod erc1155 { .balances .get((from, token_id)) .expect("Caller should have ensured that `from` holds `token_id`."); - sender_balance -= value; + // checks that sender_balance >= value were performed by caller + #[allow(clippy::arithmetic_side_effects)] + { + sender_balance -= value; + } self.balances.insert((from, token_id), &sender_balance); let mut recipient_balance = self.balances.get((to, token_id)).unwrap_or(0); - recipient_balance += value; + recipient_balance = recipient_balance.checked_add(value).unwrap(); self.balances.insert((to, token_id), &recipient_balance); let caller = self.env().caller(); From 9627c86d285e67ef1bbfc4dfe26a3b01cee4eb1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Thei=C3=9Fen?= Date: Sun, 2 Jul 2023 11:12:49 +0200 Subject: [PATCH 04/13] Remove from erc721 --- integration-tests/erc721/lib.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/integration-tests/erc721/lib.rs b/integration-tests/erc721/lib.rs index 17b638fe58..8bc8e16a94 100644 --- a/integration-tests/erc721/lib.rs +++ b/integration-tests/erc721/lib.rs @@ -227,7 +227,7 @@ mod erc721 { let count = owned_tokens_count .get(caller) - .map(|c| c - 1) + .map(|c| c.checked_sub(1).unwrap()) .ok_or(Error::CannotFetchValue)?; owned_tokens_count.insert(caller, &count); token_owner.remove(id); @@ -284,7 +284,7 @@ mod erc721 { let count = owned_tokens_count .get(from) - .map(|c| c - 1) + .map(|c| c.checked_sub(1).unwrap()) .ok_or(Error::CannotFetchValue)?; owned_tokens_count.insert(from, &count); token_owner.remove(id); @@ -308,7 +308,10 @@ mod erc721 { return Err(Error::NotAllowed) }; - let count = owned_tokens_count.get(to).map(|c| c + 1).unwrap_or(1); + let count = owned_tokens_count + .get(to) + .map(|c| c.checked_add(1).unwrap()) + .unwrap_or(1); owned_tokens_count.insert(to, &count); token_owner.insert(id, to); From 41bc13328c0612a2f95df4e3ca764aa1c61c31de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Thei=C3=9Fen?= Date: Sun, 2 Jul 2023 11:14:31 +0200 Subject: [PATCH 05/13] Remove from incrementer --- integration-tests/incrementer/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-tests/incrementer/lib.rs b/integration-tests/incrementer/lib.rs index 86cb6fc147..ccb4ea093d 100644 --- a/integration-tests/incrementer/lib.rs +++ b/integration-tests/incrementer/lib.rs @@ -20,7 +20,7 @@ mod incrementer { #[ink(message)] pub fn inc(&mut self, by: i32) { - self.value += by; + self.value = self.value.checked_add(by).unwrap(); } #[ink(message)] From 0b19225e64e7113e6077ed8114a1d234dd1dcd69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Thei=C3=9Fen?= Date: Sun, 2 Jul 2023 11:18:09 +0200 Subject: [PATCH 06/13] Remove from payment-channel --- integration-tests/payment-channel/lib.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/integration-tests/payment-channel/lib.rs b/integration-tests/payment-channel/lib.rs index 6ee4016973..ce8ac80630 100755 --- a/integration-tests/payment-channel/lib.rs +++ b/integration-tests/payment-channel/lib.rs @@ -138,6 +138,8 @@ mod payment_channel { return Err(Error::InvalidSignature) } + // We checked that amount >= self.withdrawn + #[allow(clippy::arithmetic_side_effects)] self.env() .transfer(self.recipient, amount - self.withdrawn) .map_err(|_| Error::TransferFailed)?; @@ -157,7 +159,7 @@ mod payment_channel { } let now = self.env().block_timestamp(); - let expiration = now + self.close_duration; + let expiration = now.checked_add(self.close_duration).unwrap(); self.env().emit_event(SenderCloseStarted { expiration, @@ -207,8 +209,10 @@ mod payment_channel { return Err(Error::AmountIsLessThanWithdrawn) } + // We checked that amount >= self.withdrawn + #[allow(clippy::arithmetic_side_effects)] let amount_to_withdraw = amount - self.withdrawn; - self.withdrawn += amount_to_withdraw; + self.withdrawn.checked_add(amount_to_withdraw).unwrap(); self.env() .transfer(self.recipient, amount_to_withdraw) From 526fdfd68340591b62ec909d155483753ee6f26b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Thei=C3=9Fen?= Date: Sun, 2 Jul 2023 11:23:23 +0200 Subject: [PATCH 07/13] Remove from trait-erc20 --- integration-tests/trait-erc20/lib.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/integration-tests/trait-erc20/lib.rs b/integration-tests/trait-erc20/lib.rs index 30f5517b72..7ecc06512b 100644 --- a/integration-tests/trait-erc20/lib.rs +++ b/integration-tests/trait-erc20/lib.rs @@ -190,6 +190,8 @@ mod erc20 { return Err(Error::InsufficientAllowance) } self.transfer_from_to(&from, &to, value)?; + // We checked that allowance >= value + #[allow(clippy::arithmetic_side_effects)] self.allowances .insert((&from, &caller), &(allowance - value)); Ok(()) @@ -242,10 +244,11 @@ mod erc20 { if from_balance < value { return Err(Error::InsufficientBalance) } - + // We checked that from_balance >= value + #[allow(clippy::arithmetic_side_effects)] self.balances.insert(from, &(from_balance - value)); let to_balance = self.balance_of_impl(to); - self.balances.insert(to, &(to_balance + value)); + self.balances.insert(to, &(to_balance.checked_add(value).unwrap())); self.env().emit_event(Transfer { from: Some(*from), to: Some(*to), From bea89ad4a66e12f56a4632c3296d3e7bd3889332 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Thei=C3=9Fen?= Date: Sun, 2 Jul 2023 11:27:16 +0200 Subject: [PATCH 08/13] Remove from trait-incrementer --- integration-tests/trait-incrementer/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-tests/trait-incrementer/lib.rs b/integration-tests/trait-incrementer/lib.rs index c0a1c8a823..65edd6f9d1 100644 --- a/integration-tests/trait-incrementer/lib.rs +++ b/integration-tests/trait-incrementer/lib.rs @@ -24,7 +24,7 @@ pub mod incrementer { /// Increases the value of the incrementer by an amount. #[ink(message)] pub fn inc_by(&mut self, delta: u64) { - self.value += delta; + self.value = self.value.checked_add(delta).unwrap(); } } From 24da566d18fe4835db6cc081191966d31a82f686 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Thei=C3=9Fen?= Date: Sun, 2 Jul 2023 11:37:14 +0200 Subject: [PATCH 09/13] Remove from multi-contract-caller --- integration-tests/multi-contract-caller/accumulator/lib.rs | 2 +- integration-tests/multi-contract-caller/subber/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/integration-tests/multi-contract-caller/accumulator/lib.rs b/integration-tests/multi-contract-caller/accumulator/lib.rs index 5f76910081..8bc171a0af 100644 --- a/integration-tests/multi-contract-caller/accumulator/lib.rs +++ b/integration-tests/multi-contract-caller/accumulator/lib.rs @@ -23,7 +23,7 @@ pub mod accumulator { /// Mutates the internal value. #[ink(message)] pub fn inc(&mut self, by: i32) { - self.value += by; + self.value = self.value.checked_add(by).unwrap(); } /// Returns the current state. diff --git a/integration-tests/multi-contract-caller/subber/lib.rs b/integration-tests/multi-contract-caller/subber/lib.rs index 541f290d32..7b6e522ae0 100644 --- a/integration-tests/multi-contract-caller/subber/lib.rs +++ b/integration-tests/multi-contract-caller/subber/lib.rs @@ -26,7 +26,7 @@ mod subber { /// Decreases the `accumulator` value by some amount. #[ink(message)] pub fn dec(&mut self, by: i32) { - self.accumulator.inc(-by) + self.accumulator.inc(0i32.checked_sub(by).unwrap()) } } } From ab9e040e70c06059644fc3d1b647e75de0a3d39b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Thei=C3=9Fen?= Date: Sun, 2 Jul 2023 11:53:48 +0200 Subject: [PATCH 10/13] Remove from multisig --- integration-tests/multisig/lib.rs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/integration-tests/multisig/lib.rs b/integration-tests/multisig/lib.rs index 27303a6d0d..e28bd18fa8 100755 --- a/integration-tests/multisig/lib.rs +++ b/integration-tests/multisig/lib.rs @@ -379,7 +379,10 @@ mod multisig { pub fn add_owner(&mut self, new_owner: AccountId) { self.ensure_from_wallet(); self.ensure_no_owner(&new_owner); - ensure_requirement_is_valid(self.owners.len() as u32 + 1, self.requirement); + ensure_requirement_is_valid( + (self.owners.len() as u32).checked_add(1).unwrap(), + self.requirement, + ); self.is_owner.insert(new_owner, &()); self.owners.push(new_owner); self.env().emit_event(OwnerAddition { owner: new_owner }); @@ -398,6 +401,8 @@ mod multisig { pub fn remove_owner(&mut self, owner: AccountId) { self.ensure_from_wallet(); self.ensure_owner(&owner); + // If caller is an owner the len has to be > 0 + #[allow(clippy::arithmetic_side_effects)] let len = self.owners.len() as u32 - 1; let requirement = u32::min(len, self.requirement); ensure_requirement_is_valid(len, requirement); @@ -522,7 +527,10 @@ mod multisig { "There is a entry in `self.confirmations`. Hence a count must exit.", ); // Will not underflow as there is at least one confirmation - confirmation_count -= 1; + #[allow(clippy::arithmetic_side_effects)] + { + confirmation_count -= 1; + } self.confirmation_count .insert(trans_id, &confirmation_count); self.env().emit_event(Revocation { @@ -618,7 +626,7 @@ mod multisig { let key = (transaction, confirmer); let new_confirmation = !self.confirmations.contains(key); if new_confirmation { - count += 1; + count = count.checked_add(1).unwrap(); self.confirmations.insert(key, &()); self.confirmation_count.insert(transaction, &count); } @@ -626,6 +634,8 @@ mod multisig { if count >= self.requirement { ConfirmationStatus::Confirmed } else { + // We checked that count < self.requirement + #[allow(clippy::arithmetic_side_effects)] ConfirmationStatus::ConfirmationsNeeded(self.requirement - count) } }; @@ -677,7 +687,7 @@ mod multisig { if self.confirmations.contains(key) { self.confirmations.remove(key); let mut count = self.confirmation_count.get(trans_id).unwrap_or(0); - count -= 1; + count = count.saturating_sub(1); self.confirmation_count.insert(trans_id, &count); } } From b703b49628464f63fae8736bacd10b0fc2706209 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Thei=C3=9Fen?= Date: Sun, 2 Jul 2023 11:56:04 +0200 Subject: [PATCH 11/13] Remove from set-code-hash --- integration-tests/set-code-hash/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-tests/set-code-hash/lib.rs b/integration-tests/set-code-hash/lib.rs index dd632d3592..0d74d558fd 100644 --- a/integration-tests/set-code-hash/lib.rs +++ b/integration-tests/set-code-hash/lib.rs @@ -36,7 +36,7 @@ pub mod incrementer { /// Increments the counter value which is stored in the contract's storage. #[ink(message)] pub fn inc(&mut self) { - self.count += 1; + self.count = self.count.checked_add(1).unwrap(); ink::env::debug_println!( "The new count is {}, it was modified using the original contract code.", self.count From c8e98758e5112bf02f36d718d892341b4f993aeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Thei=C3=9Fen?= Date: Sun, 2 Jul 2023 12:56:59 +0200 Subject: [PATCH 12/13] cargo fmt --- integration-tests/trait-erc20/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/integration-tests/trait-erc20/lib.rs b/integration-tests/trait-erc20/lib.rs index 7ecc06512b..616a77dc08 100644 --- a/integration-tests/trait-erc20/lib.rs +++ b/integration-tests/trait-erc20/lib.rs @@ -248,7 +248,8 @@ mod erc20 { #[allow(clippy::arithmetic_side_effects)] self.balances.insert(from, &(from_balance - value)); let to_balance = self.balance_of_impl(to); - self.balances.insert(to, &(to_balance.checked_add(value).unwrap())); + self.balances + .insert(to, &(to_balance.checked_add(value).unwrap())); self.env().emit_event(Transfer { from: Some(*from), to: Some(*to), From 28175ea4a0b2c5ebe9df1839f16b2a1ef8ae602a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Thei=C3=9Fen?= Date: Mon, 21 Aug 2023 11:21:58 +0200 Subject: [PATCH 13/13] Spellcheck --- crates/env/src/engine/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/env/src/engine/mod.rs b/crates/env/src/engine/mod.rs index e4abd36925..eede4a75e2 100644 --- a/crates/env/src/engine/mod.rs +++ b/crates/env/src/engine/mod.rs @@ -33,12 +33,12 @@ use ink_primitives::{ /// Convert a slice into an array reference. /// -/// Creates an array reference of size $len pointing to $offset within $arr. +/// Creates an array reference of size `$len` pointing to `$offset` within `$arr`. /// /// # Panics /// /// - The selected range is out of bounds given the supplied slice -/// - Integer overflow on $offset + $len +/// - Integer overflow on `$offset + $len` macro_rules! array_mut_ref { ($arr:expr, $offset:expr, $len:expr) => {{ {