TypeChain
TypeChain copied to clipboard
[Bug] Type 'Contract' is not assignable to type 'SomeContract'.
I followed the official web3 example, but for some reason it throws a bunch of errors for me, because my case-scenario has deploy and send chained to the instance.

If I do it with this approach, then I don't have the deployed contract stored for the future interaction.
let factory: FactoryContext
// ... later on
factory = new web3.eth.Contract(FactoryArtifact.abi) as unknown as FactoryContext
await factory.deploy({ ... }}.send({ ... })
// ... later on
expect(factory.options.address).toBeTruthy() // error (undefined)
So I had to @ts-ignore the line, for now. Is there a solution to this that's not documented, because I'm struggling to find the way?
UPDATE
This appears to be working. Is this how I'm supposed to do it anyway?
let factory: FactoryContext
factory = (await new web3.eth.Contract(FactoryArtifact.abi)
.deploy({ data: FactoryArtifact.evm.bytecode.object })
.send({ from: accounts[0], gas: 3_000_000 })) as unknown as FactoryContext