Skip to content

Commit

Permalink
wrong address
Browse files Browse the repository at this point in the history
  • Loading branch information
gaetbout committed Jun 28, 2024
1 parent bea8081 commit 121b8ae
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/claim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,10 @@ export async function claimInternal(args: {
gift: Gift;
receiver: string;
giftPrivateKey: string;
overrides?: { EscrowAccountAddress?: string; callToAddress?: string };
overrides?: { escrowAccountAddress?: string; callToAddress?: string };
details?: UniversalDetails;
}): Promise<TransactionReceipt> {
const escrowAddress = args.overrides?.EscrowAccountAddress || calculateEscrowAddress(args.gift);
const escrowAddress = args.overrides?.escrowAccountAddress || calculateEscrowAddress(args.gift);
const escrowAccount = getEscrowAccount(args.gift, args.giftPrivateKey, escrowAddress);
const response = await escrowAccount.execute(
[
Expand Down
2 changes: 0 additions & 2 deletions src/contracts/escrow_account.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ 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 Down Expand Up @@ -182,7 +181,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
23 changes: 23 additions & 0 deletions tests-integration/claim_internal.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ import { num } from "starknet";
import {
ETH_GIFT_MAX_FEE,
STRK_GIFT_MAX_FEE,
buildGiftCallData,
calculateEscrowAddress,
claimInternal,
defaultDepositTestSetup,
deployMockERC20,
expectRevertWithErrorMessage,
getEscrowAccount,
manager,
randomReceiver,
setupGiftProtocol,
Expand All @@ -27,6 +30,26 @@ describe("Claim Internal", function () {
await manager.tokens.tokenBalance(receiver, gift.gift_token).should.eventually.equal(gift.gift_amount);
});

it(`fee token not ETH nor STRK using txV3: ${useTxV3}`, async function () {
const { factory } = await setupGiftProtocol();
const { gift, giftPrivateKey } = await defaultDepositTestSetup({ factory, useTxV3 });
const receiver = randomReceiver();
const escrowAddress = calculateEscrowAddress(gift);

const escrowAccount = getEscrowAccount(gift, giftPrivateKey, escrowAddress);
const mockERC20 = await deployMockERC20();
gift.fee_token = mockERC20.address;
await expectRevertWithErrorMessage("escrow/invalid-escrow-address", () =>
escrowAccount.execute([
{
contractAddress: escrowAddress,
calldata: [buildGiftCallData(gift), receiver],
entrypoint: "claim_internal",
},
]),
);
});

it(`Can't claim if no fee amount deposited (fee token == gift token) using txV3: ${useTxV3}`, async function () {
const { factory } = await setupGiftProtocol();
const receiver = randomReceiver();
Expand Down

0 comments on commit 121b8ae

Please sign in to comment.