Skip to content

Commit 1e479c3

Browse files
authored
🗽 Introduce TestProvider type (#733)
1 parent a39f6f7 commit 1e479c3

26 files changed

Lines changed: 139 additions & 68 deletions
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@ethereum-waffle/provider": patch
3+
---
4+
5+
Introduce TestProvider type

‎pnpm-lock.yaml‎

Lines changed: 82 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎waffle-chai/src/matchers/changeEtherBalance.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type {TestProvider} from '@ethereum-waffle/provider';
12
import {BigNumber, BigNumberish, providers} from 'ethers';
23
import {callPromise} from '../call-promise';
34
import {ensure} from './calledOnContract/utils';
@@ -59,7 +60,7 @@ export async function getBalanceChange(
5960
const gasPrice = txResponse.gasPrice ?? txReceipt.effectiveGasPrice;
6061
const gasUsed = txReceipt.gasUsed;
6162
const txFee = gasPrice.mul(gasUsed);
62-
const provider = account.provider as any;
63+
const provider = account.provider as TestProvider;
6364
if (typeof provider.getL1Fee === 'function') {
6465
const l1Fee = await provider.getL1Fee(txReceipt.transactionHash);
6566
return balanceAfter.add(txFee).add(l1Fee).sub(balanceBefore);

‎waffle-chai/src/matchers/changeEtherBalances.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type {TestProvider} from '@ethereum-waffle/provider';
12
import {BigNumber, BigNumberish, providers} from 'ethers';
23
import {callPromise} from '../call-promise';
34
import {getAddressOf, Account} from './misc/account';
@@ -70,7 +71,7 @@ async function getTxFees(
7071
const gasPrice = txResponse.gasPrice ?? txReceipt.effectiveGasPrice;
7172
const gasUsed = txReceipt.gasUsed;
7273
const txFee = gasPrice.mul(gasUsed);
73-
const provider = account.provider as any;
74+
const provider = account.provider as TestProvider;
7475
if (typeof provider.getL1Fee === 'function') {
7576
const l1Fee = await provider.getL1Fee(txReceipt.transactionHash);
7677
return txFee.add(l1Fee);

‎waffle-chai/src/types.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
declare namespace Chai {
88
interface Assertion extends LanguageChains, NumericComparison, TypeComparison {
99
reverted: AsyncAssertion;
10-
revertedWith(reason: string): RevertedWithAssertion;
10+
revertedWith(reason: string | RegExp): RevertedWithAssertion;
1111
emit(contract: any, eventName: string): EmitAssertion;
1212
properHex(length: number): void;
1313
hexEqual(other: string): void;

‎waffle-chai/test/matchers/chainingTest.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import {Wallet, Contract, ContractFactory} from 'ethers';
33
import {MOCK_TOKEN_ABI, MOCK_TOKEN_BYTECODE} from '../contracts/MockToken';
44
import {COMPLEX_ABI, COMPLEX_BYTECODE} from '../contracts/Complex';
55

6-
import {MockProvider} from '@ethereum-waffle/provider';
6+
import type {TestProvider} from '@ethereum-waffle/provider';
77

8-
export const chainingMatchersTest = (provider: MockProvider) => {
8+
export const chainingMatchersTest = (provider: TestProvider) => {
99
let sender: Wallet;
1010
let receiver: Wallet;
1111
let token: Contract;

‎waffle-chai/test/matchers/changeEtherBalanceTest.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {MockProvider} from '@ethereum-waffle/provider';
1+
import type {TestProvider} from '@ethereum-waffle/provider';
22
import {expect, AssertionError} from 'chai';
33
import {BigNumber, Contract, Wallet} from 'ethers';
44

@@ -8,7 +8,7 @@ interface ChangeEtherBalanceTestOptions {
88
}
99

1010
export const changeEtherBalanceTest = (
11-
provider: MockProvider,
11+
provider: TestProvider,
1212
options: ChangeEtherBalanceTestOptions
1313
) => {
1414
let txGasFees: number;

0 commit comments

Comments
 (0)