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

[ethers] Factory for connecting to existing contract instances #162

Merged
merged 4 commits into from Jul 11, 2019

Conversation

quezak
Copy link
Contributor

@quezak quezak commented Jul 10, 2019

This is a follow-up for PR #160 (CC issue #137)

Problem: existing methods allowed only to deploy a new contract instance, or attach to an existing address, but only connecting through a complete Signer / Wallet. In actual use cases, you often don't need (or even don't want) the contract instance to have a signer connected, just a provider, to use contract's view or pure functions.

Proposed solution:

  • add to the contract factories: static connect(address: string, signerOrProvider: Signer | Provider) -- this just invokes the Contract constructor with the same params and the hardcoded ABI (since we can't add runtime functions to our contract type declarations)
  • for abstract contracts (or if bytecode was just not provided), generate a simplified version of the factory, containing just the above static method, without the usual deployment methods.

@coveralls
Copy link

coveralls commented Jul 10, 2019

Pull Request Test Coverage Report for Build 232

  • 15 of 17 (88.24%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.9%) to 90.336%

Changes Missing Coverage Covered Lines Changed/Added Lines %
lib/targets/ethers/index.ts 6 8 75.0%
Totals Coverage Status
Change from base Build 229: 0.9%
Covered Lines: 454
Relevant Lines: 488

💛 - Coveralls

@quezak quezak force-pushed the feature/ethers-contract-factory branch from aa21b5e to b5866ea Compare July 11, 2019 09:53
@krzkaczor krzkaczor merged commit 21b6059 into dethcrypto:master Jul 11, 2019
@krzkaczor
Copy link
Member

Published as typechain@0.3.19

@quezak quezak deleted the feature/ethers-contract-factory branch July 11, 2019 10:15
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

Successfully merging this pull request may close these issues.

None yet

3 participants