Skip to content

Commit

Permalink
comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Leonard-Pat committed Jun 26, 2024
1 parent 29fc3a4 commit d70200b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
4 changes: 1 addition & 3 deletions src/contracts/escrow_account.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ pub struct AccountConstructorArguments {

#[starknet::contract(account)]
mod EscrowAccount {
use argent_gifting::contracts::escrow_library::{
IEscrowLibraryLibraryDispatcher, IEscrowLibraryDispatcherTrait
};
use argent_gifting::contracts::escrow_library::{IEscrowLibraryLibraryDispatcher, IEscrowLibraryDispatcherTrait};
use argent_gifting::contracts::gift_data::GiftData;
use argent_gifting::contracts::gift_factory::{IGiftFactory, IGiftFactoryDispatcher, IGiftFactoryDispatcherTrait};
use argent_gifting::contracts::outside_execution::{IOutsideExecution, OutsideExecution};
Expand Down
15 changes: 6 additions & 9 deletions src/contracts/gift_factory.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ pub trait IGiftFactory<TContractState> {
gift_pubkey: felt252
);

/// @notice Retrieves the current escrow_class_hash used for creating an escrow account
/// @notice Retrieves the current clash hash used for creating an escrow account
fn get_latest_escrow_class_hash(self: @TContractState) -> ClassHash;

/// @notice Retrieves the current escrow_class_hash of the escrow account's library
/// @notice Retrieves the current class hash of the escrow account's library
fn get_escrow_lib_class_hash(self: @TContractState, escrow_class_hash: ClassHash) -> ClassHash;

/// @notice Get the address of the escrow account contract given all parameters
/// @param escrow_class_hash The class hash
/// @param escrow_class_hash The class hash of the escrow account
/// @param sender The address of the sender
/// @param gift_token The ERC-20 token address of the gift
/// @param gift_amount The amount of the gift
Expand Down Expand Up @@ -149,22 +149,19 @@ mod GiftFactory {
self.pausable.assert_not_paused();
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 an gift has been claimed or not just by looking at the balances
// This is needed so we can tell if a gift has been claimed or not just by looking at the balances
assert(fee_amount.into() < gift_amount, 'gift-fac/fee-too-high');
}

let sender = get_caller_address();
// TODO We could manually serialize for better performance but then we loose the type safety
let escrow_class_hash_storage = self.escrow_class_hash.read();
assert(escrow_class_hash_storage == escrow_class_hash, 'gift-fac/invalid-class-hash');
let constructor_arguments = AccountConstructorArguments {
sender, gift_token, gift_amount, fee_token, fee_amount, gift_pubkey
};
let (escrow_contract, _) = deploy_syscall(
escrow_class_hash, // escrow_class_hash
0, // salt
serialize(@constructor_arguments).span(), // constructor data
false // deploy_from_zero
escrow_class_hash, 0, // salt
serialize(@constructor_arguments).span(), false // deploy_from_zero
)
.expect('gift-fac/deploy-failed');
self
Expand Down
2 changes: 1 addition & 1 deletion tests-integration/account.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ describe("Escrow Account", function () {
const { gift, giftPrivateKey } = await defaultDepositTestSetup({ factory });
const receiver = randomReceiver();

// double gift
// double claim
await claimInternal({ gift, receiver, giftPrivateKey: giftPrivateKey });
await expectRevertWithErrorMessage("gift-acc/invalid-gift-nonce", () =>
claimInternal({ gift, receiver, giftPrivateKey: giftPrivateKey, details: { skipValidate: false } }),
Expand Down

0 comments on commit d70200b

Please sign in to comment.