From 97b4cac4abb71a8884e69ddc5f8b510ff1753c50 Mon Sep 17 00:00:00 2001 From: Eric Nordelo Date: Thu, 1 Aug 2024 21:02:24 +0200 Subject: [PATCH] refactor: remove warnings --- CHANGELOG.md | 1 + Scarb.lock | 3 --- Scarb.toml | 6 +++--- packages/presets/src/tests/test_erc20.cairo | 10 +++++----- packages/token/src/erc20/erc20.cairo | 4 ++-- packages/token/src/tests/erc20/test_erc20.cairo | 16 ++++++++-------- .../src/tests/erc20/test_erc20_votes.cairo | 14 +++++++------- packages/utils/src/structs/checkpoint.cairo | 17 ++++++++--------- src/tests/presets/test_erc20.cairo | 10 +++++----- 9 files changed, 39 insertions(+), 42 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 761e3baa6..e2b941d27 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Bump scarb to v2.7.0-rc.1 (#1025) - Bump scarb to v2.7.0-rc.2 (#1052) - Bump scarb to v2.7.0-rc.4 (#1064) +- Bump scarb to v2.7.0 (#1065) ## 0.15.0-rc.0 (2024-07-8) diff --git a/Scarb.lock b/Scarb.lock index 74a9e18e8..11da63c54 100644 --- a/Scarb.lock +++ b/Scarb.lock @@ -5,7 +5,6 @@ version = 1 name = "openzeppelin" version = "0.15.0-rc.0" dependencies = [ -<<<<<<< HEAD "openzeppelin_access", "openzeppelin_account", "openzeppelin_governance", @@ -96,8 +95,6 @@ dependencies = [ name = "openzeppelin_utils" version = "0.15.0-rc.0" dependencies = [ -======= ->>>>>>> 8561d75fab0c8e1acfcf7a37d290db368ed6a01b "snforge_std", ] diff --git a/Scarb.toml b/Scarb.toml index 9ac8ca001..4025a6503 100644 --- a/Scarb.toml +++ b/Scarb.toml @@ -18,8 +18,8 @@ version.workspace = true [workspace.package] version = "0.15.0-rc.0" edition = "2023_11" -cairo-version = "2.7.0-rc.3" -scarb-version = "2.7.0-rc.4" +cairo-version = "2.7.0" +scarb-version = "2.7.0" authors = ["OpenZeppelin Community "] description = "OpenZeppelin Contracts written in Cairo for StarkNet, a decentralized ZK Rollup" documentation = "https://docs.openzeppelin.com/contracts-cairo" @@ -36,7 +36,7 @@ keywords = [ ] [workspace.dependencies] -starknet = "2.7.0-rc.3" +starknet = "2.7.0" snforge_std = { git = "https://github.com/foundry-rs/starknet-foundry.git", tag = "v0.26.0" } [dependencies] diff --git a/packages/presets/src/tests/test_erc20.cairo b/packages/presets/src/tests/test_erc20.cairo index 367a6fd31..4b95a39c8 100644 --- a/packages/presets/src/tests/test_erc20.cairo +++ b/packages/presets/src/tests/test_erc20.cairo @@ -1,4 +1,4 @@ -use core::integer::BoundedInt; +use core::num::traits::Bounded; use core::num::traits::Zero; use openzeppelin_access::tests::common::OwnableSpyHelpers; use openzeppelin_presets::interfaces::erc20::{ @@ -206,13 +206,13 @@ fn test_transfer_from_doesnt_consume_infinite_allowance() { let (_, mut dispatcher) = setup_dispatcher(); start_cheat_caller_address(dispatcher.contract_address, OWNER()); - dispatcher.approve(SPENDER(), BoundedInt::max()); + dispatcher.approve(SPENDER(), Bounded::MAX); start_cheat_caller_address(dispatcher.contract_address, SPENDER()); dispatcher.transfer_from(OWNER(), RECIPIENT(), VALUE); let allowance = dispatcher.allowance(OWNER(), SPENDER()); - assert_eq!(allowance, BoundedInt::max(), "Should not decrease"); + assert_eq!(allowance, Bounded::MAX, "Should not decrease"); } #[test] @@ -269,13 +269,13 @@ fn test_transferFrom() { fn test_transferFrom_doesnt_consume_infinite_allowance() { let (_, mut dispatcher) = setup_dispatcher(); start_cheat_caller_address(dispatcher.contract_address, OWNER()); - dispatcher.approve(SPENDER(), BoundedInt::max()); + dispatcher.approve(SPENDER(), Bounded::MAX); start_cheat_caller_address(dispatcher.contract_address, SPENDER()); dispatcher.transferFrom(OWNER(), RECIPIENT(), VALUE); let allowance = dispatcher.allowance(OWNER(), SPENDER()); - assert_eq!(allowance, BoundedInt::max(), "Should not decrease"); + assert_eq!(allowance, Bounded::MAX, "Should not decrease"); } #[test] diff --git a/packages/token/src/erc20/erc20.cairo b/packages/token/src/erc20/erc20.cairo index 0ebb6a9c8..005697b61 100644 --- a/packages/token/src/erc20/erc20.cairo +++ b/packages/token/src/erc20/erc20.cairo @@ -14,7 +14,7 @@ use starknet::ContractAddress; /// for examples. #[starknet::component] pub mod ERC20Component { - use core::integer::BoundedInt; + use core::num::traits::Bounded; use core::num::traits::Zero; use openzeppelin_token::erc20::interface; use starknet::ContractAddress; @@ -427,7 +427,7 @@ pub mod ERC20Component { amount: u256 ) { let current_allowance = self.ERC20_allowances.read((owner, spender)); - if current_allowance != BoundedInt::max() { + if current_allowance != Bounded::MAX { assert(current_allowance >= amount, Errors::INSUFFICIENT_ALLOWANCE); self._approve(owner, spender, current_allowance - amount); } diff --git a/packages/token/src/tests/erc20/test_erc20.cairo b/packages/token/src/tests/erc20/test_erc20.cairo index b87c72e8b..4e1fb023d 100644 --- a/packages/token/src/tests/erc20/test_erc20.cairo +++ b/packages/token/src/tests/erc20/test_erc20.cairo @@ -1,4 +1,4 @@ -use core::integer::BoundedInt; +use core::num::traits::Bounded; use openzeppelin_token::erc20::ERC20Component::{Approval, Transfer}; use openzeppelin_token::erc20::ERC20Component::{ERC20CamelOnlyImpl, ERC20Impl}; use openzeppelin_token::erc20::ERC20Component::{ERC20MetadataImpl, InternalImpl}; @@ -264,13 +264,13 @@ fn test_transfer_from() { fn test_transfer_from_doesnt_consume_infinite_allowance() { let mut state = setup(); start_cheat_caller_address(test_address(), OWNER()); - state.approve(SPENDER(), BoundedInt::max()); + state.approve(SPENDER(), Bounded::MAX); start_cheat_caller_address(test_address(), SPENDER()); state.transfer_from(OWNER(), RECIPIENT(), VALUE); let allowance = state.allowance(OWNER(), SPENDER()); - assert_eq!(allowance, BoundedInt::max()); + assert_eq!(allowance, Bounded::MAX); } #[test] @@ -331,13 +331,13 @@ fn test_transferFrom() { fn test_transferFrom_doesnt_consume_infinite_allowance() { let mut state = setup(); start_cheat_caller_address(test_address(), OWNER()); - state.approve(SPENDER(), BoundedInt::max()); + state.approve(SPENDER(), Bounded::MAX); start_cheat_caller_address(test_address(), SPENDER()); state.transferFrom(OWNER(), RECIPIENT(), VALUE); let allowance = state.allowance(OWNER(), SPENDER()); - assert_eq!(allowance, BoundedInt::max()); + assert_eq!(allowance, Bounded::MAX); } #[test] @@ -393,13 +393,13 @@ fn test__spend_allowance_not_unlimited() { #[test] fn test__spend_allowance_unlimited() { let mut state = setup(); - state._approve(OWNER(), SPENDER(), BoundedInt::max()); + state._approve(OWNER(), SPENDER(), Bounded::MAX); - let max_minus_one: u256 = BoundedInt::max() - 1; + let max_minus_one: u256 = Bounded::MAX - 1; state._spend_allowance(OWNER(), SPENDER(), max_minus_one); let allowance = state.allowance(OWNER(), SPENDER()); - assert_eq!(allowance, BoundedInt::max()); + assert_eq!(allowance, Bounded::MAX); } // diff --git a/packages/token/src/tests/erc20/test_erc20_votes.cairo b/packages/token/src/tests/erc20/test_erc20_votes.cairo index ec4c64e95..3a60cb2d7 100644 --- a/packages/token/src/tests/erc20/test_erc20_votes.cairo +++ b/packages/token/src/tests/erc20/test_erc20_votes.cairo @@ -1,4 +1,4 @@ -use core::integer::BoundedInt; +use core::num::traits::Bounded; use core::num::traits::Zero; use openzeppelin_token::erc20::ERC20Component::InternalImpl as ERC20Impl; use openzeppelin_token::erc20::extensions::ERC20VotesComponent::{ @@ -101,9 +101,9 @@ fn test_get_past_votes() { trace.push('ts3', 0x333); // Big numbers (high different from 0x0) - let big1: u256 = BoundedInt::::max().into() + 0x444; - let big2: u256 = BoundedInt::::max().into() + 0x666; - let big3: u256 = BoundedInt::::max().into() + 0x888; + let big1: u256 = Bounded::::MAX.into() + 0x444; + let big2: u256 = Bounded::::MAX.into() + 0x666; + let big3: u256 = Bounded::::MAX.into() + 0x888; trace.push('ts4', big1); trace.push('ts6', big2); trace.push('ts8', big3); @@ -135,9 +135,9 @@ fn test_get_past_total_supply() { trace.push('ts3', 0x333); // Big numbers (high different from 0x0) - let big1: u256 = BoundedInt::::max().into() + 0x444; - let big2: u256 = BoundedInt::::max().into() + 0x666; - let big3: u256 = BoundedInt::::max().into() + 0x888; + let big1: u256 = Bounded::::MAX.into() + 0x444; + let big2: u256 = Bounded::::MAX.into() + 0x666; + let big3: u256 = Bounded::::MAX.into() + 0x888; trace.push('ts4', big1); trace.push('ts6', big2); trace.push('ts8', big3); diff --git a/packages/utils/src/structs/checkpoint.cairo b/packages/utils/src/structs/checkpoint.cairo index caff302b4..d18eb7d83 100644 --- a/packages/utils/src/structs/checkpoint.cairo +++ b/packages/utils/src/structs/checkpoint.cairo @@ -198,7 +198,7 @@ impl CheckpointStorePacking of StorePacking { #[cfg(test)] mod test { - use core::integer::BoundedInt; + use core::num::traits::Bounded; use super::Checkpoint; use super::CheckpointStorePacking; use super::_2_POW_184; @@ -208,15 +208,15 @@ mod test { #[test] fn test_pack_big_key_and_value() { - let key = BoundedInt::max(); - let value = BoundedInt::max(); + let key = Bounded::MAX; + let value = Bounded::MAX; let checkpoint = Checkpoint { key, value }; let (key_and_low, high) = CheckpointStorePacking::pack(checkpoint); let expected_key: u256 = (key_and_low.into() / _2_POW_184.into()) & KEY_MASK; let expected_low: u256 = key_and_low.into() & LOW_MASK; - let expected_high: felt252 = BoundedInt::::max().into(); + let expected_high: felt252 = Bounded::::MAX.into(); assert_eq!(key.into(), expected_key); assert_eq!(value.low.into(), expected_low); @@ -225,14 +225,13 @@ mod test { #[test] fn test_unpack_big_key_and_value() { - let key_and_low = BoundedInt::::max().into() * _2_POW_184 - + BoundedInt::::max().into(); - let high = BoundedInt::::max().into(); + let key_and_low = Bounded::::MAX.into() * _2_POW_184 + Bounded::::MAX.into(); + let high = Bounded::::MAX.into(); let checkpoint = CheckpointStorePacking::unpack((key_and_low, high)); - let expected_key: u64 = BoundedInt::max(); - let expected_value: u256 = BoundedInt::max(); + let expected_key: u64 = Bounded::MAX; + let expected_value: u256 = Bounded::MAX; assert_eq!(checkpoint.key, expected_key); assert_eq!(checkpoint.value, expected_value); diff --git a/src/tests/presets/test_erc20.cairo b/src/tests/presets/test_erc20.cairo index 5630256d9..0ab311b6e 100644 --- a/src/tests/presets/test_erc20.cairo +++ b/src/tests/presets/test_erc20.cairo @@ -1,4 +1,4 @@ -use core::integer::BoundedInt; +use core::num::traits::Bounded; use core::num::traits::Zero; use openzeppelin::presets::interfaces::erc20::{ ERC20UpgradeableABISafeDispatcher, ERC20UpgradeableABISafeDispatcherTrait @@ -206,13 +206,13 @@ fn test_transfer_from_doesnt_consume_infinite_allowance() { let (_, mut dispatcher) = setup_dispatcher(); start_cheat_caller_address(dispatcher.contract_address, OWNER()); - dispatcher.approve(SPENDER(), BoundedInt::max()); + dispatcher.approve(SPENDER(), Bounded::MAX); start_cheat_caller_address(dispatcher.contract_address, SPENDER()); dispatcher.transfer_from(OWNER(), RECIPIENT(), VALUE); let allowance = dispatcher.allowance(OWNER(), SPENDER()); - assert_eq!(allowance, BoundedInt::max(), "Should not decrease"); + assert_eq!(allowance, Bounded::MAX, "Should not decrease"); } #[test] @@ -269,13 +269,13 @@ fn test_transferFrom() { fn test_transferFrom_doesnt_consume_infinite_allowance() { let (_, mut dispatcher) = setup_dispatcher(); start_cheat_caller_address(dispatcher.contract_address, OWNER()); - dispatcher.approve(SPENDER(), BoundedInt::max()); + dispatcher.approve(SPENDER(), Bounded::MAX); start_cheat_caller_address(dispatcher.contract_address, SPENDER()); dispatcher.transferFrom(OWNER(), RECIPIENT(), VALUE); let allowance = dispatcher.allowance(OWNER(), SPENDER()); - assert_eq!(allowance, BoundedInt::max(), "Should not decrease"); + assert_eq!(allowance, Bounded::MAX, "Should not decrease"); } #[test]