diff --git a/scripts/profile.ts b/scripts/profile.ts index 1cff752..e1a1784 100644 --- a/scripts/profile.ts +++ b/scripts/profile.ts @@ -34,6 +34,7 @@ for (const useTxV3 of [false, true]) { // Ensure there is a contract for the claim const claimAddress = await factory.get_claim_address( + claimAccountClassHash, deployer.address, amount, maxFee, diff --git a/tests-integration/account.test.ts b/tests-integration/account.test.ts index 7499aa8..08bd3af 100644 --- a/tests-integration/account.test.ts +++ b/tests-integration/account.test.ts @@ -28,6 +28,7 @@ describe("Gifting", function () { // Ensure there is a contract for the claim const claimAddress = await factory.get_claim_address( + claimAccountClassHash, deployer.address, amount, maxFee, @@ -74,7 +75,7 @@ describe("Gifting", function () { max_price_per_unit: num.toHexString(4), }, }; - await expectRevertWithErrorMessage("gift-acc/insufficient-v3-fee", () => + await expectRevertWithErrorMessage("gift-acc/max-fee-too-high-v3", () => claimAccount.execute( [ { @@ -88,7 +89,7 @@ describe("Gifting", function () { ), ); } else { - await expectRevertWithErrorMessage("gift-acc/insufficient-v1-fee", () => + await expectRevertWithErrorMessage("gift-acc/max-fee-too-high-v1", () => factory.claim_internal(claim, receiver, { maxFee: maxFee + 1n }), ); } @@ -124,6 +125,7 @@ describe("Gifting", function () { // Ensure there is a contract for the claim const claimAddress = await factory.get_claim_address( + claimAccountClassHash, deployer.address, amount, maxFee, @@ -131,9 +133,7 @@ describe("Gifting", function () { claimPubkey, ); - const claim = { - factory: factory.address, - class_hash: claimAccountClassHash, + const constructorArgs = { sender: deployer.address, amount: uint256.bnToUint256(amount), max_fee: maxFee, @@ -141,8 +141,13 @@ describe("Gifting", function () { claim_pubkey: claimPubkey, }; - const constructorCalldata = CallData.compile(claim); - const correctAddress = hash.calculateContractAddressFromHash(0, claimAccountClassHash, constructorCalldata, 0); + const constructorCalldata = CallData.compile(constructorArgs); + const correctAddress = hash.calculateContractAddressFromHash( + 0, + claimAccountClassHash, + constructorCalldata, + factory.address, + ); expect(claimAddress).to.be.equal(num.toBigInt(correctAddress)); // Check balance of the claim contract is correct @@ -156,6 +161,12 @@ describe("Gifting", function () { claimContract.connect(claimAccount); await expectRevertWithErrorMessage("gift-acc/only-protocol", () => claimContract.__validate__([])); + const claim = { + factory: factory.address, + class_hash: claimAccountClassHash, + ...constructorArgs + }; + // cant call another contract fakeFactory.connect(claimAccount); await expectRevertWithErrorMessage("gift-acc/invalid-call-to", () => diff --git a/tests-integration/claim_external.test.ts b/tests-integration/claim_external.test.ts index c00d171..f8c67d7 100644 --- a/tests-integration/claim_external.test.ts +++ b/tests-integration/claim_external.test.ts @@ -25,6 +25,7 @@ describe("claim_external", function () { await factory.deposit(amount, maxFee, tokenContract.address, claimPubkey); const claimAddress = await factory.get_claim_address( + claimAccountClassHash, deployer.address, amount, maxFee, diff --git a/tests-integration/factory.test.ts b/tests-integration/factory.test.ts index 7b61436..7dbddad 100644 --- a/tests-integration/factory.test.ts +++ b/tests-integration/factory.test.ts @@ -28,6 +28,7 @@ describe("Factory", function () { // Ensure there is a contract for the claim const claimAddress = await factory.get_claim_address( + claimAccountClassHash, deployer.address, amount, maxFee, @@ -94,6 +95,7 @@ describe("Factory", function () { // Ensure there is a contract for the claim const claimAddress = await factory.get_claim_address( + claimAccountClassHash, deployer.address, amount, maxFee, @@ -130,7 +132,7 @@ describe("Factory", function () { await tokenContract.balance_of(claimAddress).should.eventually.equal(0n); factory.connect(claimAccount); - await expectRevertWithErrorMessage("gift-acc/gift-canceled", () => factory.claim_internal(claim, receiver)); + await expectRevertWithErrorMessage("gift/already-claimed-or-cancel", () => factory.claim_internal(claim, receiver)); }); it(`Test pausable`, async function () { @@ -166,6 +168,7 @@ describe("Factory", function () { // Ensure there is a contract for the claim const claimAddress = await factory.get_claim_address( + claimAccountClassHash, deployer.address, amount, maxFee,