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

truffle-v5: Some properties of Truffle.ContractInstance are missing #315

Closed
odanado opened this issue Dec 6, 2020 · 11 comments · Fixed by #317
Closed

truffle-v5: Some properties of Truffle.ContractInstance are missing #315

odanado opened this issue Dec 6, 2020 · 11 comments · Fixed by #317

Comments

@odanado
Copy link
Contributor

odanado commented Dec 6, 2020

For example, properties of Overloads of packages/target-truffle-v5-test/test/Overloads.test.ts are different between type and runtime.

type:
 2020-12-06 21 38 22

runtime:
 2020-12-06 21 21 25

missing properties:

  • abi
  • allEvents
  • getPastEvents
  • send
  • sendTransaction
@odanado
Copy link
Contributor Author

odanado commented Dec 7, 2020

I try to solve this issue

@quezak
Copy link
Contributor

quezak commented Dec 7, 2020

Great! We'll be waiting for a PR :)

@julianlen
Copy link

julianlen commented Dec 11, 2020

Hi there!

is it the 'setProvider' method missing too ?

https://web3js.readthedocs.io/en/v1.2.11/web3-eth-contract.html

@odanado
Copy link
Contributor Author

odanado commented Dec 26, 2020

@julianlen
No.
The contract of Truffle and the contract of web3.js are different.

@odanado
Copy link
Contributor Author

odanado commented Dec 26, 2020

@krzkaczor
${c.name}Instance inherits from Truffle.ContractInstance.
ref: https://github.com/ethereum-ts/TypeChain/blob/0d75de7c26e976ad26a566611a4d7c89473317e6/packages/target-truffle-v5/src/codegen/ contracts.ts#L49

I found out that there are two ways to resolve this issue.

  • Update truffle-typing
  • Update @truffle/contract

Update truffle-typing

This package is deprecated. However, this package belongs to ethereum-ts, so it is easy to fix

Update @truffle/contract

@truffle/contract provides a formal type definition for contract objects. However, the type definition differs from the runtime properties in some ways, and is wrong. To fix it, I need to make a pull request to trufflesuite, but it is very difficult.

Which way do you think is better?

@krzkaczor
Copy link
Member

Update truffle-typing

Generated contracts don't use truffle-typings anymore so even when you fix it there it won't have any effect.

Update @truffle/contract

This seems to be the right way. I am sure that the truffle folks will be happy to help you.

There is also a third way: we can generate missing methods as part of TypeChain generated but I would consider it a last resort fix.

To fix it, I need to make a pull request to trufflesuite, but it is very difficult.

Why do you consider it such a difficult task? I would expect a very similar difficulty level as updating @truffle/contracts. Or do you have a process related difficulties in mind?

@odanado
Copy link
Contributor Author

odanado commented Dec 29, 2020

Generated contracts don't use truffle-typings anymore so even when you fix it there it won't have any effect.

No.
Truffle.Contract of https://github.com/ethereum-ts/TypeChain/blob/0d75de7c26e976ad26a566611a4d7c89473317e6/packages/target-truffle-v5/src/codegen/contracts.ts#L29 is Contract of https://github.com/ethereum-ts/truffle-typings/blob/9dec2bec9335b6aba4fa64ea41995d776c455ec2/index.d.ts#L67.

do you have a process related difficulties in mind?

Yes.
I was considered about the effort involved in reviewing a pull request.

I will try to create a pull request to @truffle/contract.

@krzkaczor
Copy link
Member

Okay, I figured it out. the Truffle namespace (and thus Truffle.Contract) is part of truffle-v5 target: https://github.com/ethereum-ts/TypeChain/blob/master/packages/target-truffle-v5/static/types.d.ts

So I remember deprecating truffle-typings and moving them directly to typechain so it's easier to use. It should be enough to tweak these definitions.

@odanado
Copy link
Contributor Author

odanado commented Dec 29, 2020

Oh. I didn't know packages/target-truffle-v5/static/types.d.ts.
Well then, I will update packages/target-truffle-v5/static/types.d.ts.

@quezak
Copy link
Contributor

quezak commented Dec 29, 2020

Okay, I figured it out. the Truffle namespace (and thus Truffle.Contract) is part of truffle-v5 target: https://github.com/ethereum-ts/TypeChain/blob/master/packages/target-truffle-v5/static/types.d.ts

So I remember deprecating truffle-typings and moving them directly to typechain so it's easier to use. It should be enough to tweak these definitions.

This might be worth noting in the truffle-typings package README, so next time we (and the users) know 😅

@krzkaczor
Copy link
Member

Released: https://github.com/ethereum-ts/TypeChain/releases/tag/%40typechain%2Ftruffle-v5%404.0.1

@odanado Thanks for this!

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

Successfully merging a pull request may close this issue.

4 participants