diff --git a/src/execution_state_test.cairo b/src/execution_state_test.cairo index 99f086a..9ae9d27 100644 --- a/src/execution_state_test.cairo +++ b/src/execution_state_test.cairo @@ -1,5 +1,5 @@ use governance::utils::u64_tuple_storage::{ThreeU64TupleStorePacking, TwoU64TupleStorePacking}; -[use governance::utils::u64_tuple_storage_test::{assert_pack_unpack}; +use governance::utils::u64_tuple_storage_test::{assert_pack_unpack}; use starknet::storage_access::{StorePacking}; #[test] diff --git a/src/governor.cairo b/src/governor.cairo index a536f36..2f28855 100644 --- a/src/governor.cairo +++ b/src/governor.cairo @@ -1,6 +1,5 @@ use core::array::{Array}; use core::byte_array::{ByteArray}; -use core::integer::{u128_safe_divmod}; use core::option::{Option, OptionTrait}; use core::traits::{Into, TryInto}; use governance::execution_state::{ExecutionState}; @@ -8,7 +7,6 @@ use governance::staker::{IStakerDispatcher}; use starknet::account::{Call}; use starknet::{ContractAddress, storage_access::{StorePacking}}; - #[derive(Copy, Drop, Serde, starknet::Store, PartialEq, Debug)] pub struct ProposalInfo { // the address of the proposer diff --git a/src/utils/u64_tuple_storage.cairo b/src/utils/u64_tuple_storage.cairo index e6d7ee6..613e894 100644 --- a/src/utils/u64_tuple_storage.cairo +++ b/src/utils/u64_tuple_storage.cairo @@ -1,16 +1,16 @@ -use core::integer::{u128_safe_divmod}; use starknet::storage_access::{StorePacking}; const TWO_POW_64: u128 = 0x10000000000000000; +const TWO_POW_64_DIVISOR: NonZero = 0x10000000000000000; pub(crate) impl TwoU64TupleStorePacking of StorePacking<(u64, u64), u128> { fn pack(value: (u64, u64)) -> u128 { let (a, b) = value; - a.into() + b.into() * TWO_POW_64 + a.into() + (b.into() * TWO_POW_64) } fn unpack(value: u128) -> (u64, u64) { - let (q, r) = u128_safe_divmod(value, TWO_POW_64.try_into().unwrap()); + let (q, r) = DivRem::div_rem(value, TWO_POW_64_DIVISOR); (r.try_into().unwrap(), q.try_into().unwrap()) } }