diff --git a/test/contracts/SafestERC20.test.ts b/test/contracts/SafestERC20.test.ts index b4d0011c..6b5e6950 100644 --- a/test/contracts/SafestERC20.test.ts +++ b/test/contracts/SafestERC20.test.ts @@ -2,7 +2,7 @@ import { constants, ether, expect } from '../../src/prelude'; import { SignerWithAddress } from '@nomicfoundation/hardhat-ethers/signers'; import { loadFixture } from '@nomicfoundation/hardhat-network-helpers'; import hre, { ethers } from 'hardhat'; -import { Signature, TypedDataDomain } from 'ethers'; +import { Signature, TypedDataDomain, ContractTransactionReceipt } from 'ethers'; import { PERMIT2_ADDRESS } from '@uniswap/permit2-sdk'; import { countInstructions, trackReceivedTokenAndTx } from '../../src/utils'; import { @@ -297,7 +297,7 @@ describe('SafeERC20', function () { const { weth, wrapper } = await loadFixture(deployWrapperWETH); const [received, tx] = await trackReceivedTokenAndTx(ethers.provider, weth, await wrapper.getAddress(), () => wrapper.deposit({ value: ether('1') }), - ); + ) as [bigint, ContractTransactionReceipt]; expect(received).to.be.equal(ether('1')); if (hre.__SOLIDITY_COVERAGE_RUNNING === undefined) { expect(await countInstructions(ethers.provider, tx.logs[0].transactionHash, ['STATICCALL', 'CALL', 'MSTORE', 'MLOAD', 'SSTORE', 'SLOAD'])).to.be.deep.equal([ @@ -308,9 +308,9 @@ describe('SafeERC20', function () { it('should be cheap on deposit 0 tokens', async function () { const { weth, wrapper } = await loadFixture(deployWrapperWETH); - const [, tx] = await trackReceivedTokenAndTx(ethers.provider, weth, await wrapper.getAddress(), () => + const tx = (await trackReceivedTokenAndTx(ethers.provider, weth, await wrapper.getAddress(), () => wrapper.deposit(), - ); + ))[1] as ContractTransactionReceipt; if (hre.__SOLIDITY_COVERAGE_RUNNING === undefined) { expect(await countInstructions(ethers.provider, tx.hash, ['STATICCALL', 'CALL', 'MSTORE', 'MLOAD', 'SSTORE', 'SLOAD'])).to.be.deep.equal([ 0, 0, 1, 0, 0, 1, @@ -331,7 +331,7 @@ describe('SafeERC20', function () { const spenderBalanceBefore = await ethers.provider.getBalance(spender); const [received, tx] = await trackReceivedTokenAndTx(ethers.provider, weth, await wrapper.getAddress(), () => wrapper.withdrawTo(ether('0.5'), spender), - ); + ) as [bigint, ContractTransactionReceipt]; expect(received).to.be.equal(-ether('0.5')); expect(await ethers.provider.getBalance(spender)).to.be.equal(spenderBalanceBefore + ether('0.5')); if (hre.__SOLIDITY_COVERAGE_RUNNING === undefined) { @@ -343,9 +343,9 @@ describe('SafeERC20', function () { it('should be cheap on withdrawTo to self', async function () { const { weth, wrapper } = await loadFixture(deployWrapperWETHAndDeposit); - const [, tx] = await trackReceivedTokenAndTx(ethers.provider, weth, await wrapper.getAddress(), () => + const tx = (await trackReceivedTokenAndTx(ethers.provider, weth, await wrapper.getAddress(), () => wrapper.withdrawTo(ether('0.5'), wrapper), - ); + ))[1] as ContractTransactionReceipt; if (hre.__SOLIDITY_COVERAGE_RUNNING === undefined) { expect(await countInstructions(ethers.provider, tx.hash, ['STATICCALL', 'CALL'])).to.be.deep.equal([ 0, 2, diff --git a/test/utils.test.ts b/test/utils.test.ts index 0e56dad9..5fbc94e5 100644 --- a/test/utils.test.ts +++ b/test/utils.test.ts @@ -3,7 +3,7 @@ import { timeIncreaseTo, fixSignature, signMessage, trackReceivedTokenAndTx, cou import hre, { deployments, ethers } from 'hardhat'; import { loadFixture } from '@nomicfoundation/hardhat-network-helpers'; import { SignerWithAddress } from '@nomicfoundation/hardhat-ethers/signers'; -import { getBytes, hexlify, randomBytes, toUtf8Bytes, EventLog } from 'ethers'; +import { getBytes, hexlify, randomBytes, toUtf8Bytes, EventLog, ContractTransactionReceipt } from 'ethers'; import { TokenMock, WETH } from '../typechain-types'; describe('timeIncreaseTo', function () { @@ -96,7 +96,7 @@ describe('utils', function () { const [received, tx] = await trackReceivedTokenAndTx(ethers.provider, usdt, signer2.address, () => usdt.transfer(signer2, ether('1')), - ); + ) as [bigint, ContractTransactionReceipt]; expect(received).to.be.equal(ether('1')); expect(tx.from).equal(signer1.address); expect(tx.to).equal(await usdt.getAddress()); @@ -110,7 +110,7 @@ describe('utils', function () { const [received, tx] = await trackReceivedTokenAndTx(ethers.provider, usdt, signer2.address, () => usdt.approve(signer2, ether('1')), - ); + ) as [bigint, ContractTransactionReceipt]; expect(received).to.be.equal('0'); expect(tx.from).equal(signer1.address); expect(tx.to).equal(await usdt.getAddress()); @@ -144,9 +144,9 @@ describe('utils', function () { it('should be counted ERC20 Transfer', async function () { const { usdt } = await loadFixture(deployUSDT); - const [, tx] = await trackReceivedTokenAndTx(ethers.provider, usdt, signer2.address, () => + const tx = (await trackReceivedTokenAndTx(ethers.provider, usdt, signer2.address, () => usdt.transfer(signer2, ether('1')), - ); + ))[1] as ContractTransactionReceipt; if (hre.__SOLIDITY_COVERAGE_RUNNING === undefined) { expect(await countInstructions(ethers.provider, tx.logs[0].transactionHash, ['STATICCALL', 'CALL', 'SSTORE', 'SLOAD'])).to.be.deep.equal([ 0, 0, 2, 2, @@ -157,9 +157,9 @@ describe('utils', function () { it('should be counted ERC20 Approve', async function () { const { usdt } = await loadFixture(deployUSDT); - const [, tx] = await trackReceivedTokenAndTx(ethers.provider, usdt, signer2.address, () => + const tx = (await trackReceivedTokenAndTx(ethers.provider, usdt, signer2.address, () => usdt.approve(signer2, ether('1')), - ); + ))[1] as ContractTransactionReceipt; if (hre.__SOLIDITY_COVERAGE_RUNNING === undefined) { expect(await countInstructions(ethers.provider, tx.logs[0].transactionHash, ['STATICCALL', 'CALL', 'SSTORE', 'SLOAD'])).to.be.deep.equal([ 0, 0, 1, 0,