Skip to content

Commit

Permalink
adding all non tested mesgs
Browse files Browse the repository at this point in the history
  • Loading branch information
gaetbout committed Jun 28, 2024
1 parent fe6fdff commit 277b3d2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/contracts/escrow_account.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,11 @@ mod EscrowAccount {
assert(tx_info.nonce == 0, 'escrow/invalid-gift-nonce');
let execution_hash = tx_info.transaction_hash;
let signature = tx_info.signature;
// Not tested
assert(signature.len() == 2, 'escrow/invalid-signature-len');

let tx_version = tx_info.version;
// Not tested
assert(
check_ecdsa_signature(execution_hash, gift.gift_pubkey, *signature[0], *signature[1])
|| tx_version == TX_V3_ESTIMATE
Expand All @@ -106,6 +108,7 @@ mod EscrowAccount {
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 @@ -115,6 +118,7 @@ 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 @@ -123,6 +127,7 @@ 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 @@ -177,6 +182,7 @@ 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
3 changes: 3 additions & 0 deletions src/contracts/escrow_library.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ 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 Down Expand Up @@ -138,6 +139,7 @@ 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 Down Expand Up @@ -193,6 +195,7 @@ 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
4 changes: 4 additions & 0 deletions src/contracts/gift_factory.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ 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 @@ -159,6 +160,7 @@ mod GiftFactory {
let constructor_arguments = AccountConstructorArguments {
sender, gift_token, gift_amount, fee_token, fee_amount, gift_pubkey
};
// Not tested
let (escrow_contract, _) = deploy_syscall(
escrow_class_hash, 0, // salt
serialize(@constructor_arguments).span(), false // deploy_from_zero
Expand All @@ -181,13 +183,15 @@ 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

0 comments on commit 277b3d2

Please sign in to comment.