diff --git a/test/accessors/SimulateTxAccessor.spec.ts b/test/accessors/SimulateTxAccessor.spec.ts index 70133637e..af7a7974f 100644 --- a/test/accessors/SimulateTxAccessor.spec.ts +++ b/test/accessors/SimulateTxAccessor.spec.ts @@ -65,7 +65,7 @@ describe("SimulateTxAccessor", () => { const [user1, user2] = signers; const accessorAddress = await accessor.getAddress(); const safeAddress = await safe.getAddress(); - await (await user1.sendTransaction({ to: safeAddress, value: ethers.parseEther("1") })).wait(); + await user1.sendTransaction({ to: safeAddress, value: ethers.parseEther("1") }); const userBalance = await hre.ethers.provider.getBalance(user2.address); const tx = await buildContractCall(interactor, "sendAndReturnBalance", [user2.address, ethers.parseEther("1")], 0, true); const simulationData = accessor.interface.encodeFunctionData("simulate", [tx.to, tx.value, tx.data, tx.operation]); diff --git a/test/core/Safe.Execution.spec.ts b/test/core/Safe.Execution.spec.ts index cf3d9c143..3932c4e14 100644 --- a/test/core/Safe.Execution.spec.ts +++ b/test/core/Safe.Execution.spec.ts @@ -120,7 +120,7 @@ describe("Safe", () => { const [user1] = signers; const safeAddress = await safe.getAddress(); // Fund refund - await (await user1.sendTransaction({ to: safeAddress, value: 10000000 })).wait(); + await user1.sendTransaction({ to: safeAddress, value: 10000000 }); await expect(executeContractCallWithSigners(safe, reverter, "revert", [], [user1], false, { gasPrice: 1 })).to.emit( safe, "ExecutionFailure", @@ -173,7 +173,7 @@ describe("Safe", () => { const { safe, reverter, signers } = await setupTests(); const [user1] = signers; const safeAddress = await safe.getAddress(); - await (await user1.sendTransaction({ to: safeAddress, value: 10000000 })).wait(); + await user1.sendTransaction({ to: safeAddress, value: 10000000 }); await expect(executeContractCallWithSigners(safe, reverter, "revert", [], [user1], true, { gasPrice: 1 })).to.emit( safe, "ExecutionFailure", @@ -207,7 +207,7 @@ describe("Safe", () => { refundReceiver: user2.address, }); - await (await user1.sendTransaction({ to: safeAddress, value: ethers.parseEther("1") })).wait(); + await user1.sendTransaction({ to: safeAddress, value: ethers.parseEther("1") }); const userBalance = await hre.ethers.provider.getBalance(user2.address); expect(await hre.ethers.provider.getBalance(safeAddress)).to.be.eq(ethers.parseEther("1")); @@ -229,6 +229,43 @@ describe("Safe", () => { expect(await hre.ethers.provider.getBalance(user2.address)).to.eq(userBalance + successEvent.payment); }); + it("should emit payment in failure event", async () => { + const { safe, storageSetter, signers } = await setupTests(); + const [user1, user2] = signers; + const safeAddress = await safe.getAddress(); + const storageSetterAddress = await storageSetter.getAddress(); + const data = storageSetter.interface.encodeFunctionData("setStorage", ["0xbaddad"]); + const tx = buildSafeTransaction({ + to: storageSetterAddress, + data, + nonce: await safe.nonce(), + operation: 0, + gasPrice: 1, + safeTxGas: 3000, + refundReceiver: user2.address, + }); + + await user1.sendTransaction({ to: safeAddress, value: ethers.parseEther("1") }); + const userBalance = await hre.ethers.provider.getBalance(user2.address); + await expect(await hre.ethers.provider.getBalance(safeAddress)).to.eq(ethers.parseEther("1")); + + const executedTx = await executeTx(safe, tx, [await safeApproveHash(user1, safe, tx, true)]); + await expect(executedTx).to.emit(safe, "ExecutionFailure"); + const receipt = await hre.ethers.provider.getTransactionReceipt(executedTx!.hash); + const receiptLogs = receipt?.logs ?? []; + // There are additional ETH transfer events on zkSync related to transaction fees + const logIndex = receiptLogs.length - (hre.network.zksync ? 2 : 1); + const successEvent = safe.interface.decodeEventLog( + "ExecutionFailure", + receiptLogs[logIndex].data, + receiptLogs[logIndex].topics, + ); + expect(successEvent.txHash).to.be.eq(calculateSafeTransactionHash(safeAddress, tx, await chainId())); + // FIXME: When running out of gas the gas used is slightly higher than the safeTxGas and the user has to overpay + expect(successEvent.payment).to.be.lte(10000n); + await expect(await hre.ethers.provider.getBalance(user2.address)).to.eq(userBalance + successEvent.payment); + }); + it("should be possible to manually increase gas", async () => { if (hre.network.zksync) { // This test fails in zksync because of (allegedly) enormous gas cost differences @@ -312,7 +349,7 @@ describe("Safe", () => { refundReceiver: nativeTokenReceiverAddress, }); - await (await user1.sendTransaction({ to: safeAddress, value: ethers.parseEther("1") })).wait(); + await user1.sendTransaction({ to: safeAddress, value: ethers.parseEther("1") }); await expect(await hre.ethers.provider.getBalance(safeAddress)).to.eq(ethers.parseEther("1")); // await expect(await executeTx(safe, tx, [await safeApproveHash(user1, safe, tx, true)], { gasLimit: 5500000 })).to.emit( diff --git a/test/core/Safe.FallbackManager.spec.ts b/test/core/Safe.FallbackManager.spec.ts index 5cb998590..5498c7437 100644 --- a/test/core/Safe.FallbackManager.spec.ts +++ b/test/core/Safe.FallbackManager.spec.ts @@ -42,9 +42,7 @@ describe("FallbackManager", () => { ).to.be.eq("0x" + "".padStart(64, "0")); // Setup Safe - await ( - await safe.setup([user1.address, user2.address], 1, AddressZero, "0x", handler.address, AddressZero, 0, AddressZero) - ).wait(); + await safe.setup([user1.address, user2.address], 1, AddressZero, "0x", handler.address, AddressZero, 0, AddressZero); // Check fallback handler await expect( @@ -61,7 +59,7 @@ describe("FallbackManager", () => { const [user1, user2] = signers; // Setup Safe - await (await safe.setup([user1.address, user2.address], 1, AddressZero, "0x", AddressZero, AddressZero, 0, AddressZero)).wait(); + await safe.setup([user1.address, user2.address], 1, AddressZero, "0x", AddressZero, AddressZero, 0, AddressZero); // Check fallback handler await expect( @@ -90,7 +88,7 @@ describe("FallbackManager", () => { const [user1, user2] = signers; // Setup Safe - await (await safe.setup([user1.address, user2.address], 1, AddressZero, "0x", AddressZero, AddressZero, 0, AddressZero)).wait(); + await safe.setup([user1.address, user2.address], 1, AddressZero, "0x", AddressZero, AddressZero, 0, AddressZero); // Check event await expect(executeContractCallWithSigners(safe, safe, "setFallbackHandler", [handler.address], [user1])) @@ -125,9 +123,7 @@ describe("FallbackManager", () => { const mirrorAddress = await mirror.getAddress(); const [user1, user2] = signers; // Setup Safe - await ( - await safe.setup([user1.address, user2.address], 1, AddressZero, "0x", mirrorAddress, AddressZero, 0, AddressZero) - ).wait(); + await safe.setup([user1.address, user2.address], 1, AddressZero, "0x", mirrorAddress, AddressZero, 0, AddressZero); const tx = { to: await safe.getAddress(), @@ -150,9 +146,7 @@ describe("FallbackManager", () => { const mirrorAddress = await mirror.getAddress(); const [user1, user2] = signers; // Setup Safe - await ( - await safe.setup([user1.address, user2.address], 1, AddressZero, "0x", mirrorAddress, AddressZero, 0, AddressZero) - ).wait(); + await safe.setup([user1.address, user2.address], 1, AddressZero, "0x", mirrorAddress, AddressZero, 0, AddressZero); const tx = { to: await safe.getAddress(), @@ -180,7 +174,7 @@ describe("FallbackManager", () => { const { safe, signers } = await setupWithTemplate(); const [user1] = signers; // Setup Safe - await (await safe.setup([user1.address], 1, AddressZero, "0x", AddressZero, AddressZero, 0, AddressZero)).wait(); + await safe.setup([user1.address], 1, AddressZero, "0x", AddressZero, AddressZero, 0, AddressZero); // The transaction execution function doesn't bubble up revert messages so we check for a generic transaction fail code GS013 await expect( diff --git a/test/core/Safe.GuardManager.spec.ts b/test/core/Safe.GuardManager.spec.ts index 5d75411d2..9467aea76 100644 --- a/test/core/Safe.GuardManager.spec.ts +++ b/test/core/Safe.GuardManager.spec.ts @@ -74,7 +74,7 @@ describe("GuardManager", () => { const validGuardMockAddress = await validGuardMock.getAddress(); const safe = await getSafe({ owners: [user1.address] }); - await (await executeContractCallWithSigners(safe, safe, "setGuard", [validGuardMockAddress], [user1])).wait(); + await executeContractCallWithSigners(safe, safe, "setGuard", [validGuardMockAddress], [user1]); // Check guard await expect(await hre.ethers.provider.getStorage(await safe.getAddress(), GUARD_STORAGE_SLOT)).to.be.eq( @@ -167,7 +167,7 @@ describe("GuardManager", () => { signatureBytes, safeMsgSender, ]); - await (await validGuardMock.givenCalldataRevertWithMessage(checkTxData, "Computer says Nah")).wait(); + await validGuardMock.givenCalldataRevertWithMessage(checkTxData, "Computer says Nah"); const checkExecData = guardInterface.encodeFunctionData("checkAfterExecution", [ calculateSafeTransactionHash(safeAddress, safeTx, await chainId()), true, @@ -175,7 +175,7 @@ describe("GuardManager", () => { await expect(executeTx(safe, safeTx, [signature])).to.be.revertedWith("Computer says Nah"); - await (await validGuardMock.reset()).wait(); + await validGuardMock.reset(); await expect(executeTx(safe, safeTx, [signature])).to.emit(safe, "ExecutionSuccess"); @@ -216,11 +216,11 @@ describe("GuardManager", () => { calculateSafeTransactionHash(safeAddress, safeTx, await chainId()), true, ]); - await (await validGuardMock.givenCalldataRevertWithMessage(checkExecData, "Computer says Nah")).wait(); + await validGuardMock.givenCalldataRevertWithMessage(checkExecData, "Computer says Nah"); await expect(executeTx(safe, safeTx, [signature])).to.be.revertedWith("Computer says Nah"); - await (await validGuardMock.reset()).wait(); + await validGuardMock.reset(); await expect(executeTx(safe, safeTx, [signature])).to.emit(safe, "ExecutionSuccess"); diff --git a/test/core/Safe.ModuleManager.spec.ts b/test/core/Safe.ModuleManager.spec.ts index 4b4699076..242d1135a 100644 --- a/test/core/Safe.ModuleManager.spec.ts +++ b/test/core/Safe.ModuleManager.spec.ts @@ -61,7 +61,7 @@ describe("ModuleManager", () => { signers: [user1, user2], } = await setupTests(); // Use module for execution to see error - await (await executeContractCallWithSigners(safe, safe, "enableModule", [user2.address], [user1])).wait(); + await executeContractCallWithSigners(safe, safe, "enableModule", [user2.address], [user1]); await expect(executeContractCallWithSigners(safe, safe, "enableModule", [user2.address], [user1])).to.revertedWith("GS013"); }); @@ -158,8 +158,8 @@ describe("ModuleManager", () => { safe, signers: [user1, user2], } = await setupTests(); - await (await executeContractCallWithSigners(safe, safe, "enableModule", [user1.address], [user1])).wait(); - await (await executeContractCallWithSigners(safe, safe, "enableModule", [user2.address], [user1])).wait(); + await executeContractCallWithSigners(safe, safe, "enableModule", [user1.address], [user1]); + await executeContractCallWithSigners(safe, safe, "enableModule", [user2.address], [user1]); await expect( executeContractCallWithSigners(safe, safe, "disableModule", [user1.address, user2.address], [user1]), ).to.revertedWith("GS013"); @@ -170,9 +170,9 @@ describe("ModuleManager", () => { safe, signers: [user1, user2], } = await setupTests(); - await (await executeContractCallWithSigners(safe, safe, "enableModule", [user1.address], [user1])).wait(); + await executeContractCallWithSigners(safe, safe, "enableModule", [user1.address], [user1]); await expect(await safe.isModuleEnabled(user1.address)).to.be.true; - await (await executeContractCallWithSigners(safe, safe, "enableModule", [user2.address], [user1])).wait(); + await executeContractCallWithSigners(safe, safe, "enableModule", [user2.address], [user1]); await expect(await safe.isModuleEnabled(user2.address)).to.be.true; await expect(await safe.getModulesPaginated(AddressOne, 10)).to.be.deep.equal([[user2.address, user1.address], AddressOne]); @@ -219,7 +219,7 @@ describe("ModuleManager", () => { } = await setupTests(); const mockAddress = await mock.getAddress(); const user2Safe = safe.connect(user2); - await (await executeContractCallWithSigners(safe, safe, "enableModule", [user2.address], [user1])).wait(); + await executeContractCallWithSigners(safe, safe, "enableModule", [user2.address], [user1]); await expect(user2Safe.execTransactionFromModule(mockAddress, 0, "0xbaddad", 0)) .to.emit(safe, "ExecutionFromModuleSuccess") @@ -235,7 +235,7 @@ describe("ModuleManager", () => { } = await setupTests(); const mockAddress = await mock.getAddress(); const user2Safe = safe.connect(user2); - await (await executeContractCallWithSigners(safe, safe, "enableModule", [user2.address], [user1])).wait(); + await executeContractCallWithSigners(safe, safe, "enableModule", [user2.address], [user1]); await mock.givenAnyRevert(); await expect(user2Safe.execTransactionFromModule(mockAddress, 0, "0xbaddad", 0)) @@ -347,7 +347,7 @@ describe("ModuleManager", () => { } = await setupTests(); const mockAddress = await mock.getAddress(); const user2Safe = safe.connect(user2); - await (await executeContractCallWithSigners(safe, safe, "enableModule", [user2.address], [user1])).wait(); + await executeContractCallWithSigners(safe, safe, "enableModule", [user2.address], [user1]); await mock.givenAnyRevert(); await expect(user2Safe.execTransactionFromModuleReturnData(mockAddress, 0, "0xbaddad", 0)) @@ -363,7 +363,7 @@ describe("ModuleManager", () => { } = await setupTests(); const mockAddress = await mock.getAddress(); const user2Safe = safe.connect(user2); - await (await executeContractCallWithSigners(safe, safe, "enableModule", [user2.address], [user1])).wait(); + await executeContractCallWithSigners(safe, safe, "enableModule", [user2.address], [user1]); await expect(user2Safe.execTransactionFromModuleReturnData(mockAddress, 0, "0xbaddad", 0)) .to.emit(safe, "ExecutionFromModuleSuccess") @@ -379,9 +379,9 @@ describe("ModuleManager", () => { } = await setupTests(); const mockAddress = await mock.getAddress(); const user2Safe = safe.connect(user2); - await (await executeContractCallWithSigners(safe, safe, "enableModule", [user2.address], [user1])).wait(); + await executeContractCallWithSigners(safe, safe, "enableModule", [user2.address], [user1]); - await (await mock.givenCalldataReturn("0xbaddad", "0xdeaddeed")).wait(); + await mock.givenCalldataReturn("0xbaddad", "0xdeaddeed"); await expect(await user2Safe.execTransactionFromModuleReturnData.staticCall(mockAddress, 0, "0xbaddad", 0)).to.be.deep.eq([ true, "0xdeaddeed", @@ -396,9 +396,9 @@ describe("ModuleManager", () => { } = await setupTests(); const mockAddress = await mock.getAddress(); const user2Safe = safe.connect(user2); - await (await executeContractCallWithSigners(safe, safe, "enableModule", [user2.address], [user1])).wait(); + await executeContractCallWithSigners(safe, safe, "enableModule", [user2.address], [user1]); - await (await mock.givenCalldataRevertWithMessage("0xbaddad", "Some random message")).wait(); + await mock.givenCalldataRevertWithMessage("0xbaddad", "Some random message"); await expect(await user2Safe.execTransactionFromModuleReturnData.staticCall(mockAddress, 0, "0xbaddad", 0)).to.be.deep.eq([ false, "0x08c379a000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000013536f6d652072616e646f6d206d65737361676500000000000000000000000000", @@ -532,7 +532,7 @@ describe("ModuleManager", () => { } = await setupTests(); await expect(safe.getModulesPaginated(AddressZero, 1)).to.be.reverted; - await (await executeContractCallWithSigners(safe, safe, "enableModule", [user1.address], [user1])).wait(); + await executeContractCallWithSigners(safe, safe, "enableModule", [user1.address], [user1]); expect(await safe.getModulesPaginated(user1.address, 1)).to.be.deep.equal([[], AddressOne]); await expect(safe.getModulesPaginated(user2.address, 1)).to.be.revertedWith("GS105"); }); diff --git a/test/core/Safe.OwnerManager.spec.ts b/test/core/Safe.OwnerManager.spec.ts index e4789ab4b..979cc4970 100644 --- a/test/core/Safe.OwnerManager.spec.ts +++ b/test/core/Safe.OwnerManager.spec.ts @@ -63,7 +63,7 @@ describe("OwnerManager", () => { safe, signers: [user1, user2], } = await setupTests(); - await (await executeContractCallWithSigners(safe, safe, "addOwnerWithThreshold", [user2.address, 1], [user1])).wait(); + await executeContractCallWithSigners(safe, safe, "addOwnerWithThreshold", [user2.address, 1], [user1]); await expect(executeContractCallWithSigners(safe, safe, "addOwnerWithThreshold", [user2.address, 1], [user1])).to.revertedWith( "GS013", @@ -225,8 +225,8 @@ describe("OwnerManager", () => { safe, signers: [user1, user2, user3], } = await setupTests(); - await (await executeContractCallWithSigners(safe, safe, "addOwnerWithThreshold", [user2.address, 1], [user1])).wait(); - await (await executeContractCallWithSigners(safe, safe, "addOwnerWithThreshold", [user3.address, 2], [user1])).wait(); + await executeContractCallWithSigners(safe, safe, "addOwnerWithThreshold", [user2.address, 1], [user1]); + await executeContractCallWithSigners(safe, safe, "addOwnerWithThreshold", [user3.address, 2], [user1]); await expect(await safe.getOwners()).to.be.deep.equal([user3.address, user2.address, user1.address]); await expect(await safe.getThreshold()).to.be.deep.eq(2n); await expect(await safe.isOwner(user1.address)).to.be.true; diff --git a/test/core/Safe.Setup.spec.ts b/test/core/Safe.Setup.spec.ts index f349b4616..48fd1af6b 100644 --- a/test/core/Safe.Setup.spec.ts +++ b/test/core/Safe.Setup.spec.ts @@ -321,7 +321,7 @@ describe("Safe", () => { const templateAddress = await template.getAddress(); const deployerAddress = await getSenderAddressFromContractRunner(template); const payment = ethers.parseEther("10"); - await (await user1.sendTransaction({ to: templateAddress, value: payment })).wait(); + await user1.sendTransaction({ to: templateAddress, value: payment }); const userBalance = await hre.ethers.provider.getBalance(deployerAddress); await expect(await hre.ethers.provider.getBalance(templateAddress)).to.eq(ethers.parseEther("10")); @@ -349,22 +349,20 @@ describe("Safe", () => { } = await setupTests(); const templateAddress = await template.getAddress(); const payment = ethers.parseEther("10"); - await (await user1.sendTransaction({ to: templateAddress, value: payment })).wait(); + await user1.sendTransaction({ to: templateAddress, value: payment }); const userBalance = await hre.ethers.provider.getBalance(user2.address); await expect(await hre.ethers.provider.getBalance(templateAddress)).to.eq(ethers.parseEther("10")); - await ( - await template.setup( - [user1.address, user2.address, user3.address], - 2, - AddressZero, - "0x", - AddressZero, - AddressZero, - payment, - user2.address, - ) - ).wait(); + await template.setup( + [user1.address, user2.address, user3.address], + 2, + AddressZero, + "0x", + AddressZero, + AddressZero, + payment, + user2.address, + ); await expect(await hre.ethers.provider.getBalance(templateAddress)).to.eq(ethers.parseEther("0")); await expect(await hre.ethers.provider.getBalance(user2.address)).to.eq(userBalance + payment); @@ -408,19 +406,17 @@ describe("Safe", () => { const deployerAddress = await getSenderAddressFromContractRunner(template); const transferData = encodeTransfer(deployerAddress, payment); - await (await mock.givenCalldataReturnBool(transferData, true)).wait(); - await ( - await template.setup( - [user1.address, user2.address, user3.address], - 2, - AddressZero, - "0x", - AddressZero, - mockAddress, - payment, - AddressZero, - ) - ).wait(); + await mock.givenCalldataReturnBool(transferData, true); + await template.setup( + [user1.address, user2.address, user3.address], + 2, + AddressZero, + "0x", + AddressZero, + mockAddress, + payment, + AddressZero, + ); expect(await mock.invocationCountForCalldata.staticCall(transferData)).to.eq(1n); @@ -437,19 +433,17 @@ describe("Safe", () => { const payment = 133742; const transferData = encodeTransfer(user2.address, payment); - await (await mock.givenCalldataReturnBool(transferData, true)).wait(); - await ( - await template.setup( - [user1.address, user2.address, user3.address], - 2, - AddressZero, - "0x", - AddressZero, - mockAddress, - payment, - user2.address, - ) - ).wait(); + await mock.givenCalldataReturnBool(transferData, true); + await template.setup( + [user1.address, user2.address, user3.address], + 2, + AddressZero, + "0x", + AddressZero, + mockAddress, + payment, + user2.address, + ); expect(await mock.invocationCountForCalldata.staticCall(transferData)).to.eq(1n); diff --git a/test/factory/ProxyFactory.spec.ts b/test/factory/ProxyFactory.spec.ts index e77f06383..0852170ec 100644 --- a/test/factory/ProxyFactory.spec.ts +++ b/test/factory/ProxyFactory.spec.ts @@ -165,7 +165,7 @@ describe("ProxyFactory", () => { const proxyAddress = await calculateChainSpecificProxyAddress(factory, singletonAddress, initCode, saltNonce, await chainId()); expect(await provider.getCode(proxyAddress)).to.eq("0x"); - await (await factory.createChainSpecificProxyWithNonce(singletonAddress, initCode, saltNonce)).wait(); + await factory.createChainSpecificProxyWithNonce(singletonAddress, initCode, saltNonce); expect(await provider.getCode(proxyAddress)).to.be.eq(await getSafeProxyRuntimeCode()); }); @@ -210,13 +210,13 @@ describe("ProxyFactory", () => { const singletonAddress = await singleton.getAddress(); const mockAddress = await mock.getAddress(); const initCode = "0x"; - await (await mock.givenAnyRevert()).wait(); + await mock.givenAnyRevert(); await expect( factory.createProxyWithCallback(singletonAddress, initCode, saltNonce, mockAddress), "Should fail if callback fails", ).to.be.reverted; - await (await mock.reset()).wait(); + await mock.reset(); // Should be successfull now const proxyAddress = await calculateProxyAddressWithCallback(factory, singletonAddress, initCode, saltNonce, mockAddress); await expect(factory.createProxyWithCallback(singletonAddress, initCode, saltNonce, mockAddress)) diff --git a/test/guards/DebugTransactionGuard.spec.ts b/test/guards/DebugTransactionGuard.spec.ts index 5572540e4..ccc4b5319 100644 --- a/test/guards/DebugTransactionGuard.spec.ts +++ b/test/guards/DebugTransactionGuard.spec.ts @@ -16,7 +16,7 @@ describe("DebugTransactionGuard", () => { const guard = await guardFactory.deploy(); const guardAddress = await guard.getAddress(); const mock = await getMock(); - await (await executeContractCallWithSigners(safe, safe, "setGuard", [guardAddress], [user1])).wait(); + await executeContractCallWithSigners(safe, safe, "setGuard", [guardAddress], [user1]); return { safe, mock, diff --git a/test/guards/DelegateCallTransactionGuard.spec.ts b/test/guards/DelegateCallTransactionGuard.spec.ts index ddffc6694..422c80143 100644 --- a/test/guards/DelegateCallTransactionGuard.spec.ts +++ b/test/guards/DelegateCallTransactionGuard.spec.ts @@ -14,7 +14,7 @@ describe("DelegateCallTransactionGuard", () => { const guardFactory = await hre.ethers.getContractFactory("DelegateCallTransactionGuard"); const guard = await guardFactory.deploy(AddressZero); const guardAddress = await guard.getAddress(); - await (await executeContractCallWithSigners(safe, safe, "setGuard", [guardAddress], [user1])).wait(); + await executeContractCallWithSigners(safe, safe, "setGuard", [guardAddress], [user1]); return { safe, guardFactory, @@ -118,7 +118,7 @@ describe("DelegateCallTransactionGuard", () => { } = await setupTests(); const guard = await guardFactory.deploy(AddressOne); const guardAddress = await guard.getAddress(); - await (await executeContractCallWithSigners(safe, safe, "setGuard", [guardAddress], [user1])).wait(); + await executeContractCallWithSigners(safe, safe, "setGuard", [guardAddress], [user1]); expect(await guard.ALLOWED_TARGET()).to.be.eq(AddressOne); const allowedTarget = safe.attach(AddressOne); diff --git a/test/guards/OnlyOwnersGuard.spec.ts b/test/guards/OnlyOwnersGuard.spec.ts index 5d1969071..f001ee123 100644 --- a/test/guards/OnlyOwnersGuard.spec.ts +++ b/test/guards/OnlyOwnersGuard.spec.ts @@ -19,7 +19,7 @@ describe("OnlyOwnersGuard", () => { const guard = await guardFactory.deploy(); const guardAddress = await guard.getAddress(); const mock = await getMock(); - await (await executeContractCallWithSigners(safe, safe, "setGuard", [guardAddress], [user1])).wait(); + await executeContractCallWithSigners(safe, safe, "setGuard", [guardAddress], [user1]); return { safe, diff --git a/test/guards/ReentrancyTransactionGuard.spec.ts b/test/guards/ReentrancyTransactionGuard.spec.ts index b34f385a8..53e3a48dd 100644 --- a/test/guards/ReentrancyTransactionGuard.spec.ts +++ b/test/guards/ReentrancyTransactionGuard.spec.ts @@ -20,7 +20,7 @@ describe("ReentrancyTransactionGuard", () => { const guard = await guardFactory.deploy(); const guardAddress = await guard.getAddress(); const mock = await getMock(); - await (await executeContractCallWithSigners(safe, safe, "setGuard", [guardAddress], [user1])).wait(); + await executeContractCallWithSigners(safe, safe, "setGuard", [guardAddress], [user1]); return { safe, mock, @@ -112,8 +112,8 @@ describe("ReentrancyTransactionGuard", () => { const safeTx = buildSafeTransaction({ to: mockAddress, data: "0xbaddad42", nonce: nonce + 1n }); const signatures = [await safeSignTypedData(user1, safeAddress, safeTx)]; - await (await executeTxWithSigners(safe, buildSafeTransaction({ to: guardAddress, data: "0x", nonce: nonce }), [user1])).wait(); - await (await executeTx(safe, safeTx, signatures)).wait(); + await executeTxWithSigners(safe, buildSafeTransaction({ to: guardAddress, data: "0x", nonce: nonce }), [user1]); + await executeTx(safe, safeTx, signatures); expect(await mock.invocationCount()).to.be.eq(1); expect(await mock.invocationCountForCalldata("0xbaddad42")).to.be.eq(1); diff --git a/test/handlers/CompatibilityFallbackHandler.spec.ts b/test/handlers/CompatibilityFallbackHandler.spec.ts index 2873ac59e..a2c8d87d0 100644 --- a/test/handlers/CompatibilityFallbackHandler.spec.ts +++ b/test/handlers/CompatibilityFallbackHandler.spec.ts @@ -95,7 +95,7 @@ describe("CompatibilityFallbackHandler", () => { signers: [user1, user2], } = await setupTests(); const dataHash = ethers.keccak256("0xbaddad"); - await (await executeContractCallWithSigners(safe, signLib, "signMessage", [dataHash], [user1, user2], true)).wait(); + await executeContractCallWithSigners(safe, signLib, "signMessage", [dataHash], [user1, user2], true); expect(await validator.isValidSignature.staticCall(dataHash, "0x")).to.be.eq("0x1626ba7e"); }); diff --git a/test/handlers/HandlerContext.spec.ts b/test/handlers/HandlerContext.spec.ts index 4d1e8eac7..913c4145f 100644 --- a/test/handlers/HandlerContext.spec.ts +++ b/test/handlers/HandlerContext.spec.ts @@ -38,7 +38,7 @@ describe("HandlerContext", () => { } = await setup(); const handlerAddress = await handler.getAddress(); const safeAddress = await safe.getAddress(); - await (await safe.setup([user1.address, user2.address], 1, AddressZero, "0x", handlerAddress, AddressZero, 0, AddressZero)).wait(); + await safe.setup([user1.address, user2.address], 1, AddressZero, "0x", handlerAddress, AddressZero, 0, AddressZero); const response = await user1.call({ to: safeAddress, diff --git a/test/integration/Safe.0xExploit.spec.ts b/test/integration/Safe.0xExploit.spec.ts index 69a4bd38c..ba57885e1 100644 --- a/test/integration/Safe.0xExploit.spec.ts +++ b/test/integration/Safe.0xExploit.spec.ts @@ -41,7 +41,7 @@ describe("Safe", () => { } = await setupTests(); const ownerSafeAddress = await ownerSafe.getAddress(); // Safe should be empty again - await (await user1.sendTransaction({ to: await safe.getAddress(), value: ethers.parseEther("1") })).wait(); + await user1.sendTransaction({ to: await safe.getAddress(), value: ethers.parseEther("1") }); await expect(await hre.ethers.provider.getBalance(await safe.getAddress())).to.eq(ethers.parseEther("1")); const operation = 0; @@ -81,7 +81,7 @@ describe("Safe", () => { "00" + // r, s, v encodedOwnerSigns; - await (await safe.execTransaction(to, value, data, operation, 0, 0, 0, AddressZero, AddressZero, sigs)).wait(); + await safe.execTransaction(to, value, data, operation, 0, 0, 0, AddressZero, AddressZero, sigs); // Safe should be empty again await expect(await hre.ethers.provider.getBalance(await safe.getAddress())).to.eq(ethers.parseEther("0")); @@ -113,13 +113,13 @@ describe("Safe", () => { }`; const testValidator = await deployContract(user1, source); const testValidatorAddress = await testValidator.getAddress(); - await (await testValidator.shouldChangeState(true)).wait(); + await testValidator.shouldChangeState(true); - await (await executeContractCallWithSigners(safe, safe, "addOwnerWithThreshold", [testValidatorAddress, 1], [user1])).wait(); + await executeContractCallWithSigners(safe, safe, "addOwnerWithThreshold", [testValidatorAddress, 1], [user1]); await expect(await safe.getOwners()).to.be.deep.eq([testValidatorAddress, ownerSafeAddress, user1.address]); // Deposit 1 ETH + some spare money for execution - await (await user1.sendTransaction({ to: await safe.getAddress(), value: ethers.parseEther("1") })).wait(); + await user1.sendTransaction({ to: await safe.getAddress(), value: ethers.parseEther("1") }); await expect(await hre.ethers.provider.getBalance(await safe.getAddress())).to.eq(ethers.parseEther("1")); const operation = 0; @@ -150,8 +150,8 @@ describe("Safe", () => { ).to.be.reverted; await expect(await hre.ethers.provider.getBalance(await safe.getAddress())).to.eq(ethers.parseEther("1")); - await (await testValidator.shouldChangeState(false)).wait(); - await (await safe.execTransaction(to, value, data, operation, 0, 0, 0, AddressZero, AddressZero, sigs)).wait(); + await testValidator.shouldChangeState(false); + await safe.execTransaction(to, value, data, operation, 0, 0, 0, AddressZero, AddressZero, sigs); // Safe should be empty again await expect(await hre.ethers.provider.getBalance(await safe.getAddress())).to.eq(ethers.parseEther("0")); diff --git a/test/integration/Safe.ERC1155.spec.ts b/test/integration/Safe.ERC1155.spec.ts index 90559e126..e2979d3c0 100644 --- a/test/integration/Safe.ERC1155.spec.ts +++ b/test/integration/Safe.ERC1155.spec.ts @@ -27,10 +27,10 @@ describe("Safe", () => { const safeAddress = await safe.getAddress(); // Setup Safe - await (await safe.setup([user1.address, user2.address], 1, AddressZero, "0x", AddressZero, AddressZero, 0, AddressZero)).wait(); + await safe.setup([user1.address, user2.address], 1, AddressZero, "0x", AddressZero, AddressZero, 0, AddressZero); // Mint test tokens - await (await token.mint(user1.address, 23, 1337, "0x")).wait(); + await token.mint(user1.address, 23, 1337, "0x"); await expect(await token.balanceOf(user1.address, 23)).to.be.deep.eq(1337n); await expect(token.mint(safeAddress, 23, 1337, "0x"), "Should not accept minted token if handler not set").to.be.reverted; @@ -51,17 +51,15 @@ describe("Safe", () => { const handler = await defaultTokenCallbackHandlerDeployment(); // Setup Safe - await ( - await safe.setup([user1.address, user2.address], 1, AddressZero, "0x", handler.address, AddressZero, 0, AddressZero) - ).wait(); + await safe.setup([user1.address, user2.address], 1, AddressZero, "0x", handler.address, AddressZero, 0, AddressZero); - await (await token.mint(safeAddress, 23, 1337, "0x")).wait(); + await token.mint(safeAddress, 23, 1337, "0x"); await expect(await token.balanceOf(safeAddress, 23)).to.be.deep.eq(1337n); - await (await token.mint(user1.address, 23, 23, "0x")).wait(); + await token.mint(user1.address, 23, 23, "0x"); await expect(await token.balanceOf(user1.address, 23)).to.be.deep.eq(23n); - await (await token.connect(user1).safeTransferFrom(user1.address, safeAddress, 23, 23, "0x")).wait(); + await token.connect(user1).safeTransferFrom(user1.address, safeAddress, 23, 23, "0x"); await expect(await token.balanceOf(user1.address, 23)).to.be.deep.eq(0n); await expect(await token.balanceOf(safeAddress, 23)).to.be.deep.eq(1360n); }); diff --git a/test/l2/Safe.Execution.spec.ts b/test/l2/Safe.Execution.spec.ts index c2fb3d46d..25b5742ca 100644 --- a/test/l2/Safe.Execution.spec.ts +++ b/test/l2/Safe.Execution.spec.ts @@ -48,7 +48,7 @@ describe("SafeL2", () => { refundReceiver: user2.address, }); - await (await user1.sendTransaction({ to: safeAddress, value: ethers.parseEther("1") })).wait(); + await user1.sendTransaction({ to: safeAddress, value: ethers.parseEther("1") }); await expect(await hre.ethers.provider.getBalance(safeAddress)).to.be.deep.eq(ethers.parseEther("1")); const additionalInfo = ethers.AbiCoder.defaultAbiCoder().encode( @@ -84,7 +84,7 @@ describe("SafeL2", () => { } = await setupTests(); const mockAddress = await mock.getAddress(); const user2Safe = safe.connect(user2); - await (await executeContractCallWithSigners(safe, safe, "enableModule", [user2.address], [user1])).wait(); + await executeContractCallWithSigners(safe, safe, "enableModule", [user2.address], [user1]); //Use manual gasLimit because gas estimation fails for this function on zkSync, though transaction executed successfully await expect( diff --git a/test/libraries/MultiSend.spec.ts b/test/libraries/MultiSend.spec.ts index f094423e8..0b420b8d1 100644 --- a/test/libraries/MultiSend.spec.ts +++ b/test/libraries/MultiSend.spec.ts @@ -104,7 +104,7 @@ describe("MultiSend", () => { multiSend, signers: [user1, user2], } = await setupTests(); - await (await user1.sendTransaction({ to: await safe.getAddress(), value: ethers.parseEther("1") })).wait(); + await user1.sendTransaction({ to: await safe.getAddress(), value: ethers.parseEther("1") }); const userBalance = await hre.ethers.provider.getBalance(user2.address); await expect(await hre.ethers.provider.getBalance(await safe.getAddress())).to.eq(ethers.parseEther("1")); @@ -125,7 +125,7 @@ describe("MultiSend", () => { multiSend, signers: [user1, user2], } = await setupTests(); - await (await user1.sendTransaction({ to: await safe.getAddress(), value: ethers.parseEther("1") })).wait(); + await user1.sendTransaction({ to: await safe.getAddress(), value: ethers.parseEther("1") }); const userBalance = await hre.ethers.provider.getBalance(user2.address); await expect(await hre.ethers.provider.getBalance(await safe.getAddress())).to.eq(ethers.parseEther("1")); @@ -234,7 +234,7 @@ describe("MultiSend", () => { } = await setupTests(); const storageSetterAddress = await storageSetter.getAddress(); - await (await user1.sendTransaction({ to: await safe.getAddress(), value: ethers.parseEther("1") })).wait(); + await user1.sendTransaction({ to: await safe.getAddress(), value: ethers.parseEther("1") }); const userBalance = await hre.ethers.provider.getBalance(user2.address); await expect(await hre.ethers.provider.getBalance(await safe.getAddress())).to.eq(ethers.parseEther("1")); @@ -273,7 +273,7 @@ describe("MultiSend", () => { const triggerCalldata = "0xbaddad"; const errorMessage = "Some random message"; - await (await mock.givenCalldataRevertWithMessage(triggerCalldata, errorMessage)).wait(); + await mock.givenCalldataRevertWithMessage(triggerCalldata, errorMessage); const txs: MetaTransaction[] = [ { diff --git a/test/libraries/MultiSendCallOnly.spec.ts b/test/libraries/MultiSendCallOnly.spec.ts index 420446522..9596f8bb4 100644 --- a/test/libraries/MultiSendCallOnly.spec.ts +++ b/test/libraries/MultiSendCallOnly.spec.ts @@ -89,7 +89,7 @@ describe("MultiSendCallOnly", () => { multiSend, signers: [user1, user2], } = await setupTests(); - await (await user1.sendTransaction({ to: await safe.getAddress(), value: ethers.parseEther("1") })).wait(); + await user1.sendTransaction({ to: await safe.getAddress(), value: ethers.parseEther("1") }); const userBalance = await hre.ethers.provider.getBalance(user2.address); await expect(await hre.ethers.provider.getBalance(await safe.getAddress())).to.be.deep.eq(ethers.parseEther("1")); @@ -110,7 +110,7 @@ describe("MultiSendCallOnly", () => { multiSend, signers: [user1, user2], } = await setupTests(); - await (await user1.sendTransaction({ to: await safe.getAddress(), value: ethers.parseEther("1") })).wait(); + await user1.sendTransaction({ to: await safe.getAddress(), value: ethers.parseEther("1") }); const userBalance = await hre.ethers.provider.getBalance(user2.address); await expect(await hre.ethers.provider.getBalance(await safe.getAddress())).to.eq(ethers.parseEther("1")); @@ -189,7 +189,7 @@ describe("MultiSendCallOnly", () => { } = await setupTests(); const storageSetterAddress = await storageSetter.getAddress(); - await (await user1.sendTransaction({ to: await safe.getAddress(), value: ethers.parseEther("1") })).wait(); + await user1.sendTransaction({ to: await safe.getAddress(), value: ethers.parseEther("1") }); const userBalance = await hre.ethers.provider.getBalance(user2.address); await expect(await hre.ethers.provider.getBalance(await safe.getAddress())).to.eq(ethers.parseEther("1")); @@ -227,7 +227,7 @@ describe("MultiSendCallOnly", () => { const triggerCalldata = "0xbaddad"; const errorMessage = "Some random message"; - await (await mock.givenCalldataRevertWithMessage(triggerCalldata, errorMessage)).wait(); + await mock.givenCalldataRevertWithMessage(triggerCalldata, errorMessage); const txs: MetaTransaction[] = [ {