diff --git a/lib/claim.ts b/lib/claim.ts index 9b85e86..ccdb2f8 100644 --- a/lib/claim.ts +++ b/lib/claim.ts @@ -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 { - 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( [ diff --git a/src/contracts/escrow_account.cairo b/src/contracts/escrow_account.cairo index 928b67b..e401cd9 100644 --- a/src/contracts/escrow_account.cairo +++ b/src/contracts/escrow_account.cairo @@ -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 @@ -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'); } diff --git a/tests-integration/claim_internal.test.ts b/tests-integration/claim_internal.test.ts index 286cc61..53707f0 100644 --- a/tests-integration/claim_internal.test.ts +++ b/tests-integration/claim_internal.test.ts @@ -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, @@ -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();