Waffle icon indicating copy to clipboard operation
Waffle copied to clipboard

Add contract function hints to the MockContract.mock object

Open ackvf opened this issue 3 years ago • 4 comments

This change is backwards compatible as it uses an optional generic, that is by default set to BaseContract, which contains a mapped object functions: { [ name: string ]: ... }; that provides the same namespace.

I've been using this already with this ambient type declaration

declare type BaseContract = import('ethers').BaseContract
declare type _MockContract = import('ethereum-waffle').MockContract
declare type Stub = import('ethereum-waffle').Stub
interface MockContract<T extends BaseContract = BaseContract> extends _MockContract {
  mock: {
    [key in keyof T['functions']]: Stub
  }
}

image

ackvf avatar Jul 26 '22 22:07 ackvf

🦋 Changeset detected

Latest commit: 1c279645e17d5548899cc599cd95ee9d5929466e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@ethereum-waffle/mock-contract Patch
ethereum-waffle Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

changeset-bot[bot] avatar Jul 26 '22 22:07 changeset-bot[bot]

Dang, I put that commit message there by mistake. I thought it was the PR text. You can amend my commit and remove it if you want.

ackvf avatar Jul 26 '22 22:07 ackvf

@ackvf We have some build errors, did you take a look at those?

rzadp avatar Jul 28 '22 11:07 rzadp

@rzadp I didn't see this before. I will look at it.

ackvf avatar Jul 28 '22 17:07 ackvf