Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/usdc_migration/src/errors.cairo
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pub mod Errors {
pub const THRESHOLD_TOO_SMALL: felt252 = 'Threshold is too small';
pub const AMOUNT_IS_ZERO: felt252 = 'Amount is zero';
}
10 changes: 10 additions & 0 deletions packages/usdc_migration/src/tests/test_usdc_migration.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,11 @@ fn test_swap_to_new_assertions() {
cheat_caller_address_once(contract_address: cfg.usdc_migration_contract, caller_address: user);
let res = usdc_migration_safe_dispatcher.swap_to_new(:amount);
assert_panic_with_error(res, Erc20Error::INSUFFICIENT_BALANCE.describe());

// Amount is zero.
cheat_caller_address_once(contract_address: cfg.usdc_migration_contract, caller_address: user);
let res = usdc_migration_safe_dispatcher.swap_to_new(amount: Zero::zero());
assert_panic_with_felt_error(res, Errors::AMOUNT_IS_ZERO);
}

#[test]
Expand Down Expand Up @@ -350,4 +355,9 @@ fn test_swap_to_legacy_assertions() {
cheat_caller_address_once(contract_address: cfg.usdc_migration_contract, caller_address: user);
let res = usdc_migration_safe_dispatcher.swap_to_legacy(:amount);
assert_panic_with_error(res, Erc20Error::INSUFFICIENT_BALANCE.describe());

// Amount is zero.
cheat_caller_address_once(contract_address: cfg.usdc_migration_contract, caller_address: user);
let res = usdc_migration_safe_dispatcher.swap_to_legacy(amount: Zero::zero());
assert_panic_with_felt_error(res, Errors::AMOUNT_IS_ZERO);
}
1 change: 1 addition & 0 deletions packages/usdc_migration/src/usdc_migration.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ pub mod USDCMigration {
to_token: IERC20Dispatcher,
amount: u256,
) {
assert(amount > 0, Errors::AMOUNT_IS_ZERO);
let contract_address = get_contract_address();
let user = get_caller_address();
from_token.checked_transfer_from(sender: user, recipient: contract_address, :amount);
Expand Down
Loading