question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ContractFactory violates Liskov substitution principle

See original GitHub issue

Suppose i have a simple contract

pragma solidity ^0.6.0;

contract MyContract {
    constructor (address a) public {
    }
}

Using typechain i obtain MyContractFactory.

Unfortunately MyContractFactory lacks functionality compared to the ethers ContractFactory.

  1. new MyContractFactory(wallet).deploy(…) does not accept overrides as the last argument
  2. casting new MyContractFactory(wallet) as ContractFactory and then calling deploy with an incorrect number of arguments we do not get the proper error about argument count from ethers.

Suggested fix (not tested):

class MyContractFactory {
  deploy(a: string, overrides: providers.TransactionRequest): Promise<MyContract>
  deploy(...args: any[]): Promise<MyContract> {
    super.deploy(...args) as Promise<MyContract>
  }
}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

0reactions
krzkaczorcommented, Mar 22, 2020

📦 Released as typechain-target-ethers@1.0.4

Read more comments on GitHub >

github_iconTop Results From Across the Web

ContractFactory - Ethers.js
The Contract Factory sends a special type of transaction, an initcode transaction (i.e. the to field is null, and the data field is...
Read more >
Xiwei Xu Ingo Weber Mark Staples - DOKUMEN.PUB
This book provides an excellent overview of the engineering aspects of block- chains. You will learn what blockchains are, the current options for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found