Skip to content
This repository was archived by the owner on Aug 11, 2021. It is now read-only.

Conversation

vmx
Copy link
Member

@vmx vmx commented May 6, 2019

BREAKING CHANGE: The API is now async/await based

There are numerous changes, the most significant one is that the API
is no longer callback based, but it using async/await.

For the full new API please see the IPLD Formats spec.

@vmx vmx requested a review from rvagg May 6, 2019 13:50
@ghost ghost assigned vmx May 6, 2019
@ghost ghost added the status/in-progress In progress label May 6, 2019
@vmx vmx force-pushed the ipld-format-cleanup-other branch from af798c8 to 12ca4bb Compare May 6, 2019 13:52
@vmx
Copy link
Member Author

vmx commented May 6, 2019

@rvagg This PR is based on the work at #51 but it's now using the approach you proposed. I'm not just creating new objects and store the original object in a property called _ethObj.

I also improved the tests to check for the types of the fields when they are resolved.

It would be great if you could prioritise the review of this PR.

@codecov
Copy link

codecov bot commented May 6, 2019

Codecov Report

Merging #52 into master will increase coverage by 2.52%.
The diff coverage is 99.26%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #52      +/-   ##
==========================================
+ Coverage   96.84%   99.36%   +2.52%     
==========================================
  Files          22       19       -3     
  Lines         792      791       -1     
==========================================
+ Hits          767      786      +19     
+ Misses         25        5      -20
Impacted Files Coverage Δ
eth-state-trie/index.js 100% <100%> (ø) ⬆️
eth-tx/index.js 100% <100%> (ø) ⬆️
eth-block/index.js 100% <100%> (ø) ⬆️
eth-tx-trie/index.js 100% <100%> (ø) ⬆️
util/createUtil.js 100% <100%> (ø) ⬆️
eth-account-snapshot/index.js 100% <100%> (ø) ⬆️
eth-storage-trie/index.js 100% <100%> (ø) ⬆️
eth-block/test/resolver.spec.js 100% <100%> (+0.78%) ⬆️
util/cidFromHash.js 100% <100%> (ø) ⬆️
util/emptyCodeHash.js 100% <100%> (ø) ⬆️
... and 9 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4eaa791...34263b6. Read the comment docs.

@rvagg
Copy link
Member

rvagg commented May 7, 2019

tangential: why are we persisting with the term "ommer" when eth seems to be preferring "uncle" now and even the ethereumjs library looks like it's using "uncle" but we're turning it back in to "ommer". I don't know if this matters but it seems like an odd choice to be making here.

Copy link
Member

@rvagg rvagg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

really nice, I feel like I can almost understand what this is all doing now

const deserialize = (serialized) => {
const ethObj = new EthAccount(serialized)

const deserialized = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice! and now I can grok what this object even is

node === null) {
return
}
//console.log('vmx: node:', node)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove debug

callback(null, paths)
})
} else {
// other nodes link by hash
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indent comment by 2

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's actually intentionally. I still try to figure out how to format "if/else" comments properly.

My preferred style is:

// Some case
if {
}
// And in case of xyz
else {
}

But that doesn't work with our linting rules.

// Some case
if {
}
else {
  // And in case of xyz
}

Also feels a bit weird, as the comment is not about the subsequent line, but about the whole else.

Hence I went for

if {
// Some case
}
else {
// And in case of xyz
}

for consistency.

@vmx
Copy link
Member Author

vmx commented May 7, 2019

@rvagg About this "ommers" thing. I just didn't want to break backwards compatibility, it's also in the old code:

path: 'ommerHash',

@vmx vmx force-pushed the ipld-format-cleanup-other branch from 12ca4bb to dc0b8d7 Compare May 7, 2019 12:27
@vmx
Copy link
Member Author

vmx commented May 7, 2019

New forced push (I always forget that GitHub doesn't notify on new pushes).

@rvagg
Copy link
Member

rvagg commented May 8, 2019

yeah, I know the ommers thing is old, just wondering if anyone listening to this has context, just out of interest. This lgtm

BREAKING CHANGE: The API is now async/await based

There are numerous changes, the most significant one is that the API
is no longer callback based, but it using async/await.

If you want to access the original JavaScript Ethereum object, it is
now stored in a property called `_ethObj`. So if you e.g. called
`deserialized.hash()`, you now have to call
`deserialized._ethObj.hash()`.

For the full new API please see the [IPLD Formats spec].

[IPLD Formats spec]: https://github.com/ipld/interface-ipld-format
@vmx vmx force-pushed the ipld-format-cleanup-other branch from dc0b8d7 to 34263b6 Compare May 8, 2019 12:30
@vmx
Copy link
Member Author

vmx commented May 8, 2019

I just force-pushed a better commit message.

@vmx vmx merged commit dc19aa7 into master May 8, 2019
@vmx vmx deleted the ipld-format-cleanup-other branch May 8, 2019 12:46
@ghost ghost removed the status/in-progress In progress label May 8, 2019
@vmx vmx mentioned this pull request May 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants