Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test(compliance): time_transfer_tests (wip) #67

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
26 changes: 7 additions & 19 deletions crates/compliance/src/modules/time_transfer_limits_module.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ pub trait ITimeTransferLimitsModule<TContractState> {

#[derive(Drop, Copy, Serde, starknet::Store)]
pub struct TransferCounter {
value: u256,
timer: u64,
pub value: u256,
pub timer: u64,
}

#[derive(Drop, Copy, Serde, starknet::Store)]
pub struct Limit {
limit_time: u64,
limit_value: u256,
pub limit_time: u64,
pub limit_value: u256,
}

impl LimitZero of core::num::traits::Zero<Limit> {
Expand Down Expand Up @@ -120,7 +120,7 @@ pub mod TimeTransferLimitsModule {
struct Storage {
limit_values: Map<(ContractAddress, u64), IndexLimit>,
transfer_limits: Map<ContractAddress, StorageArrayLimit>,
users_counter: Map<(ContractAddress, ContractAddress, u64), TransferCounter>,
pub users_counter: Map<(ContractAddress, ContractAddress, u64), TransferCounter>,
#[substorage(v0)]
abstract_module: AbstractModuleComponent::Storage,
#[substorage(v0)]
Expand Down Expand Up @@ -170,18 +170,6 @@ pub mod TimeTransferLimitsModule {
self.ownable.initializer(owner);
}

pub mod Errors {
use starknet::ContractAddress;

pub fn LimitsArraySizeExceeded(compliance: ContractAddress, array_size: u64) {
panic!("Limits array size {} exceeded for compliance {:x}", array_size, compliance);
}

pub fn LimitTimeNotFound(compliance: ContractAddress, limit_time: u64) {
panic!("Limit time {} not found for compliance {:x}", limit_time, compliance);
}
}

impl AbstractFunctionsImpl of AbstractFunctionsTrait<ContractState> {
fn module_transfer_action(
ref self: AbstractModuleComponent::ComponentState<ContractState>,
Expand Down Expand Up @@ -392,7 +380,7 @@ pub mod TimeTransferLimitsModule {
};

if (!limit_found) {
Errors::LimitTimeNotFound(caller, limit_time);
panic!("LimitTimeNotFound");
}

transfer_limits_storage_path.delete(index);
Expand All @@ -410,7 +398,7 @@ pub mod TimeTransferLimitsModule {
.try_into()
.expect('Limit count exceeds u8');
if (!limit_is_attributed && limit_count >= 4) {
Errors::LimitsArraySizeExceeded(caller, limit_count.into());
panic!("LimitsArraySizeExceeded");
}
if (!limit_is_attributed // && limit_count < 4
) {
Expand Down
Loading
Loading