Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getting wrong type after .connect() #856

Open
gameblock1 opened this issue Jul 18, 2023 · 1 comment
Open

getting wrong type after .connect() #856

gameblock1 opened this issue Jul 18, 2023 · 1 comment

Comments

@gameblock1
Copy link

Hi
I am unable to use .connect() as it changes the type to what it has already generated regardless of the type I determined.

import { ethers } from "hardhat";
import {Lock, Lock2} from "../typechain-types"

type Lock1AndLock2 = Lock2 & Lock

describe("Sample", function() {
    it("Should have the same type", async function() {
        const Lock = (await ethers.getContractAt(abi, address)) as unknown as Lock1AndLock2; // type: Lock1AndLock2
        const LockWithDifferentRunner = Lock.connect(undefined); // type: Lock2

        /*
          Currently:
            Lock: Lock1AndLock2
            LockWithDifferentRunner: Lock2
        */

        /*
          Expected:
            Lock: Lock1AndLock2
            LockWithDifferentRunner: Lock1AndLock2

            why the type of LockWithDifferentRunner changed after conencting to a different runenr?
        */
    })
})
@zemse
Copy link
Contributor

zemse commented Aug 7, 2023

This requires this type in return of

connect(runner?: ContractRunner | null): ${contract.name};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants