Closed sebastianst closed 5 years ago
Hey @sebastianst,
Current version of truffle-typings works with truffle@4.
This PR introduces support for @5 (which uses web3) is this correct?
Yes that's correct. To be precise: node v11.9.0
, web3 1.0.0-beta.43
, typescript 3.3.1
, truffle v5.0.2
and truffle-typings 1.0.6
.
Thanks for your contribution 🎉 (and sorry for waiting so long)
We can use typescript's
import()
to declare external types, which I apply toBN
frombn.js
andWeb3
fromweb3
.While
@types/web3
is certainly not perfect, it is better than not having any types at all and they work reasonably well (for me). It can always be overwritten withdeclare const web3: any
by the user, I think.I also changed the
TransactionDetails
to havefrom
as an optional and the other fields to beBN
s. Note in particular that web3'svalue
doesn't accept anumber
any more. To convert strings and numbers to aBN
, useweb3.utils.toBN()
.It is also possible to use the
web3
node module directly. However, then the two declarations have to be changed to:There is also currently a bug in
web3.js
's types, making it impossible to compileweb3-utils
, because it doesn't correctly import/requirebn.js
. It will be fixed this week.Also relates to https://github.com/ethereum-ts/TypeChain/issues/136