-
Notifications
You must be signed in to change notification settings - Fork 36
Conversation
Signed-off-by: Sina Mahmoodi <itz.s1na@gmail.com>
What's your main rationale to move the logic of this |
Also, if you have better ideas for the API respectively see some bad design choices feel free to introduce if you're confident on it. I have been moving more in the direction during the last weeks that we actually should allow us to also make API changes if useful and don't necessarily have to stick on transferring one-to-one. Confident that we get this managed, and the occasion is good to get rid of some legacy stuff. |
//cc @krzkaczor did you also already stumble upon this defineProperties method and have ideas on that? |
@holgerd77 Well, in the beginning it was because I'm not sure if the current implementation covers all the cases, I have to test further. But it's less code because Agree with what you said on API change. Maybe transition to typescript and a systematic upgrade of API can be undertaken under codename EthereumJS 3.0 😄 |
I think the previous version with On the other hand, if we don't want to break public interface, for now, I think that we could define typescript fields AND still use |
@krzkaczor sorry, the current implementation is still work in progress, and some stuff that should be there and you mentioned are missing. The approach you mentioned might be possible, please let me know if it worked out if you got around to playing with it. If we stick with this for now, in my opinion for future explicit definition of properties and their types feels safer and more readable than runtime injection, even if it increases boilerplate a bit. I'm trying to reduce the boilerplate by defining types that handle some of the validation done in |
@s1na Yes, I also think it's very well worth to get rid of this common |
@s1na check it out here: https://github.com/ethereumjs/ethereumjs-account/pull/28/files I think the most important part here is the usage of Treat it as WIP. If you think it's a good idea incorporate please into your PR (you can rewrite it I just did it quick and dirty so maybe there some mistakes) |
Signed-off-by: Sina Mahmoodi <itz.s1na@gmail.com>
Signed-off-by: Sina Mahmoodi <itz.s1na@gmail.com>
Signed-off-by: Sina Mahmoodi <itz.s1na@gmail.com>
Signed-off-by: Sina Mahmoodi <itz.s1na@gmail.com>
@krzkaczor Thanks! Integrated your code. @holgerd77 The PR should be now ready for review, I'd appreciate it if you could have a look. Defining the |
Won't make it to do a review on this today - will try tomorrow - everyone else is also invited! |
@s1na What happened to the |
@holgerd77 Yeah, I incorporated Chris's approach to make this PR only for transitioning to typescript and avoid API changes. We can later try to come up with a solution that'd work across projects. I'll create an issue for discussion. |
@s1na Yeah, makes sense. These I have done this with this PR and it produces the following error when injecting in the VM and run error: TypeError: Account is not a constructor
at /Users/hdrewes/Documents/DEV/EthereumJS/ethereumjs-vm/tests/util.js:358:19
at /Users/hdrewes/Documents/DEV/EthereumJS/ethereumjs-vm/node_modules/async/dist/async.js:3096:16
at replenish (/Users/hdrewes/Documents/DEV/EthereumJS/ethereumjs-vm/node_modules/async/dist/async.js:998:17)
at /Users/hdrewes/Documents/DEV/EthereumJS/ethereumjs-vm/node_modules/async/dist/async.js:1002:9
at eachLimit$1 (/Users/hdrewes/Documents/DEV/EthereumJS/ethereumjs-vm/node_modules/async/dist/async.js:3182:24)
at Object.<anonymous> (/Users/hdrewes/Documents/DEV/EthereumJS/ethereumjs-vm/node_modules/async/dist/async.js:1032:16)
at Object.exports.setupPreConditions (/Users/hdrewes/Documents/DEV/EthereumJS/ethereumjs-vm/tests/util.js:356:9)
at /Users/hdrewes/Documents/DEV/EthereumJS/ethereumjs-vm/tests/GeneralStateTestsRunner.js:60:16
at /Users/hdrewes/Documents/DEV/EthereumJS/ethereumjs-vm/node_modules/async/dist/async.js:3866:24
at replenish (/Users/hdrewes/Documents/DEV/EthereumJS/ethereumjs-vm/node_modules/async/dist/async.js:998:17)
at /Users/hdrewes/Documents/DEV/EthereumJS/ethereumjs-vm/node_modules/async/dist/async.js:1002:9
at eachOfLimit (/Users/hdrewes/Documents/DEV/EthereumJS/ethereumjs-vm/node_modules/async/dist/async.js:1027:24)
at /Users/hdrewes/Documents/DEV/EthereumJS/ethereumjs-vm/node_modules/async/dist/async.js:1032:16
at _parallel (/Users/hdrewes/Documents/DEV/EthereumJS/ethereumjs-vm/node_modules/async/dist/async.js:3865:5)
at Object.series (/Users/hdrewes/Documents/DEV/EthereumJS/ethereumjs-vm/node_modules/async/dist/async.js:4721:5)
at runTestCase (/Users/hdrewes/Documents/DEV/EthereumJS/ethereumjs-vm/tests/GeneralStateTestsRunner.js:48:9) Not sure why this is happening yet, apparently This is now the third (so 3/3 😄) |
This deserves a medal or something :D I stumbled upon this tweet and I keep wondering if its a big deal: https://twitter.com/bterlson/status/1082750157303603200 Anyways, probably the export "shape" is different. |
@holgerd77 @krzkaczor Haha :))) Apparently it's due to differences in module systems... when something is exported by When searching for this, it seems that generally named exports are preferred, unless there's only one object being exported (in which case default export is preferred). Should we make this breaking change now, or rather go with Did the same happen with Edit: By the way, I tried compiling with |
I am a huge hater of |
Getting more and more to the stance that we just should do major releases by default on Typescript transition releases. Then we've got somewhat more freedom, the big shift gets clearer and it's generally somewhat likely that the WILL be done breaking changes on most of the transitions. Probably happen on Common too, couldn't test yet. This will be a major release anyhow now though, just have to remember to test and state this in the release notes if the case. |
No clear opinion on default vs named here, maybe default, sounds a bit more fitting? |
Signed-off-by: Sina Mahmoodi <itz.s1na@gmail.com>
Signed-off-by: Sina Mahmoodi <itz.s1na@gmail.com>
Signed-off-by: Sina Mahmoodi <itz.s1na@gmail.com>
VM has already upgraded to ethereumjs-util v6.0.0 and when I was testing |
Documentation should also be updated along with this, have made this an extra issue which can be addressed after merging: #30 |
@s1na I am not sure what to think about this external dependency ( |
@holgerd77 It shouldn't have any effects beyond typescript compilation. If you think it's an unnecessary complication I can replace them all with |
package.json
Outdated
@@ -24,14 +36,26 @@ | |||
}, | |||
"homepage": "https://github.com/ethereumjs/ethereumjs-account#readme", | |||
"dependencies": { | |||
"ethereumjs-util": "^5.0.0", | |||
"rlp": "^2.0.0", | |||
"bn.js": "^4.11.8", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is this new bn.js
dependency coming from respectively used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had mistakenly thought this is also necessary for the error (see below). Removed it now.
"@ethereumjs/config-prettier": "^1.0.1", | ||
"@ethereumjs/config-tsc": "^1.0.2", | ||
"@ethereumjs/config-tslint": "^1.0.0", | ||
"@types/bn.js": "^4.11.3", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for the types?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why, but without this typescript fails with:
node_modules/rlp/dist/types.d.ts:2:21 - error TS7016: Could not find a declaration file for module 'bn.js'. '.../ethereumjs-account/node_modules/bn.js/lib/bn.js' implicitly has an 'any' type.
Try `npm install @types/bn.js` if it exists or add a new declaration (.d.ts) file containing `declare module 'bn.js';`
2 import BN = require('bn.js');
@s1na If you are confident on that and @krzkaczor is not stating anything else leave them in, definitely nice to have if side-effect free. |
Signed-off-by: Sina Mahmoodi <itz.s1na@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rest looks good, thanks!
Yay. ✨ 😄
} | ||
|
||
serialize(): Buffer { | ||
return rlp.encode([this.nonce, this.balance, this.stateRoot, this.codeHash]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice that you took out the raw
here, much better readable like this.
This PR migrates the library to typescript and updates the tooling (
tslint
,prettier
) to be consistent with ethereumjs/rlp#37.Additionally, it implements the logic of ethUtil.defineProperties, in the
Account
class, with the help of a new classBinaryValue
.