Skip to content

Commit

Permalink
remove not tested
Browse files Browse the repository at this point in the history
  • Loading branch information
gaetbout committed Jun 27, 2024
1 parent a325e9c commit 3027145
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 21 deletions.
15 changes: 4 additions & 11 deletions src/contracts/escrow_account.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -76,39 +76,35 @@ mod EscrowAccount {
impl IAccountImpl of IAccount<ContractState> {
fn __validate__(ref self: ContractState, calls: Array<Call>) -> felt252 {
let execution_info = get_execution_info().unbox();
assert(execution_info.caller_address.is_zero(), 'escrow/only-protocol'); // Not tested
assert(execution_info.caller_address.is_zero(), 'escrow/only-protocol');
assert(calls.len() == 1, 'escrow/invalid-call-len');
let Call { to, selector, calldata } = calls.at(0);
assert(*to == get_contract_address(), 'escrow/invalid-call-to');
assert(*selector == selector!("claim_internal"), 'escrow/invalid-call-selector');
let (gift, _): (GiftData, ContractAddress) = full_deserialize(*calldata)
.expect('escrow/invalid-calldata'); // Not tested
let (gift, _): (GiftData, ContractAddress) = full_deserialize(*calldata).expect('escrow/invalid-calldata');
assert_valid_claim(gift);

let tx_info = execution_info.tx_info.unbox();
assert(tx_info.nonce == 0, 'escrow/invalid-gift-nonce');
let execution_hash = tx_info.transaction_hash;
let signature = tx_info.signature;
assert(signature.len() == 2, 'escrow/invalid-signature-len'); // Not tested
assert(signature.len() == 2, 'escrow/invalid-signature-len');

let tx_version = tx_info.version;
assert(
check_ecdsa_signature(execution_hash, gift.gift_pubkey, *signature[0], *signature[1])
|| tx_version == TX_V3_ESTIMATE
|| tx_version == TX_V1_ESTIMATE,
'escrow/invalid-signature'
); // Not tested
);
if gift.fee_token == STRK_ADDRESS() {
// Not tested
assert(tx_version == TX_V3 || tx_version == TX_V3_ESTIMATE, 'escrow/invalid-tx3-version');
let tx_fee = compute_max_fee_v3(tx_info, tx_info.tip);
assert(tx_fee <= gift.fee_amount, 'escrow/max-fee-too-high-v3');
} else if gift.fee_token == ETH_ADDRESS() {
// Not tested
assert(tx_version == TX_V1 || tx_version == TX_V1_ESTIMATE, 'escrow/invalid-tx1-version');
assert(tx_info.max_fee <= gift.fee_amount, 'escrow/max-fee-too-high-v1');
} else {
// Not tested
core::panic_with_felt252('escrow/invalid-token-fee');
}
VALIDATED
Expand All @@ -118,7 +114,6 @@ mod EscrowAccount {
let execution_info = get_execution_info().unbox();
assert(execution_info.caller_address.is_zero(), 'escrow/only-protocol');
let tx_version = execution_info.tx_info.unbox().version;
// Not tested
assert(
tx_version == TX_V3
|| tx_version == TX_V1
Expand All @@ -127,7 +122,6 @@ mod EscrowAccount {
'escrow/invalid-tx-version'
);
let Call { .., calldata }: @Call = calls[0];
// Not tested
let (gift, receiver): (GiftData, ContractAddress) = full_deserialize(*calldata)
.expect('escrow/invalid-calldata');
// The __validate__ function already ensures the claim is valid
Expand Down Expand Up @@ -182,7 +176,6 @@ mod EscrowAccount {

fn assert_valid_claim(gift: GiftData) {
let calculated_address = calculate_escrow_account_address(gift);
// Not tested
assert(calculated_address == get_contract_address(), 'escrow/invalid-escrow-address');
}

Expand Down
5 changes: 0 additions & 5 deletions src/contracts/escrow_library.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ mod EscrowLibrary {
// This prevents creating instances of this classhash by mistake, as it's not needed.
// While it is technically possible to create instances by replacing classhashes, this practice is not recommended.
// This contract is intended to be used exclusively through library calls.
// Not tested
panic_with_felt252('escr-lib/instance-not-recommend')
}

Expand All @@ -95,7 +94,6 @@ mod EscrowLibrary {
let is_whitelisted = selector == selector!("claim_external")
|| selector == selector!("claim_dust")
|| selector == selector!("cancel");
// not tested
assert(is_whitelisted, 'escr-lib/invalid-selector');
library_call_syscall(this_class_hash, selector, args).unwrap()
}
Expand Down Expand Up @@ -138,7 +136,6 @@ mod EscrowLibrary {
let factory_owner = IOwnableDispatcher { contract_address: gift.factory }.owner();
assert(factory_owner == get_caller_address(), 'escr-lib/only-factory-owner');
let gift_balance = balance_of(gift.gift_token, contract_address);
// Not tested
assert(gift_balance < gift.gift_amount, 'escr-lib/not-yet-claimed');
if gift.gift_token == gift.fee_token {
transfer_from_account(gift.gift_token, receiver, gift_balance);
Expand All @@ -157,7 +154,6 @@ mod EscrowLibrary {
fn execute_from_outside_v2(
ref self: ContractState, gift: GiftData, outside_execution: OutsideExecution, signature: Span<felt252>
) -> Array<Span<felt252>> {
// Not tested
panic_with_felt252('escr-lib/not-allowed-yet')
}
}
Expand Down Expand Up @@ -196,7 +192,6 @@ mod EscrowLibrary {
}

fn transfer_from_account(token: ContractAddress, receiver: ContractAddress, amount: u256,) {
// Not tested
assert(IERC20Dispatcher { contract_address: token }.transfer(receiver, amount), 'escr-lib/transfer-failed');
}

Expand Down
5 changes: 1 addition & 4 deletions src/contracts/gift_factory.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ mod GiftFactory {
gift_pubkey: felt252
) {
self.pausable.assert_not_paused();
// Not tested
assert(fee_token == STRK_ADDRESS() || fee_token == ETH_ADDRESS(), 'gift-fac/invalid-fee-token');
if gift_token == fee_token {
// This is needed so we can tell if a gift has been claimed or not just by looking at the balances
Expand All @@ -164,7 +163,7 @@ mod GiftFactory {
escrow_class_hash, 0, // salt
serialize(@constructor_arguments).span(), false // deploy_from_zero
)
.expect('gift-fac/deploy-failed'); // Not tested?
.expect('gift-fac/deploy-failed');
self
.emit(
GiftCreated {
Expand All @@ -182,15 +181,13 @@ mod GiftFactory {
if (gift_token == fee_token) {
let transfer_status = IERC20Dispatcher { contract_address: gift_token }
.transfer_from(get_caller_address(), escrow_contract, gift_amount + fee_amount.into());
// Not tested
assert(transfer_status, 'gift-fac/transfer-failed');
} else {
let transfer_gift_status = IERC20Dispatcher { contract_address: gift_token }
.transfer_from(get_caller_address(), escrow_contract, gift_amount);
assert(transfer_gift_status, 'gift-fac/transfer-gift-failed');
let transfer_fee_status = IERC20Dispatcher { contract_address: fee_token }
.transfer_from(get_caller_address(), escrow_contract, fee_amount.into());
// Not tested
assert(transfer_fee_status, 'gift-fac/transfer-fee-failed');
}
}
Expand Down
1 change: 0 additions & 1 deletion src/contracts/timelock_upgrade.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ pub mod TimelockUpgradeComponent {
let block_timestamp = get_block_timestamp();
let calldata_hash = poseidon_hash_span(calldata.span());
assert(calldata_hash == self.calldata_hash.read(), 'upgrade/invalid-calldata');
// Not tested
assert(new_implementation.is_non_zero(), 'upgrade/no-pending-upgrade');
assert(block_timestamp >= ready_at, 'upgrade/too-early');
assert(block_timestamp < ready_at + VALID_WINDOW_PERIOD, 'upgrade/upgrade-too-late');
Expand Down

0 comments on commit 3027145

Please sign in to comment.