-
Notifications
You must be signed in to change notification settings - Fork 0
deserializedHEAD API #18
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
deserializedHEAD API #18
Conversation
Closes #17
| permissions: | ||
| contents: read |
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.
Add explicit permissions
taoeffect
left a comment
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.
Great work on this @corrideat ! Minor request re API design:
| controller.error(new Error('chelonia/out/eventsBetween: Mismatched contract ID')) | ||
| return | ||
| } | ||
| const deserializedHEAD = await sbp('chelonia/out/deserializedHEAD', startHash, { contractID }) |
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.
Somewhat confusing API imo.
- The
contractIDappears to be optional as it's typedcontractID?: string, yet the implementation always does the comparison, indicating it's mandatory. - So if it's mandatory I wouldn't split the parameters like this, but instead move
hashinto the object. Also better either way as it's named parameters like that and named parameters are easier to read at the call site
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.
You're right, it was meant to be optional (and the comparison therefore should be optional). I was thinking that sometimes one may use this function to lookup the contractID.
| const message = await sbp('chelonia/out/fetchResource', hash, { | ||
| code: multicodes.SHELTER_CONTRACT_DATA | ||
| }) | ||
| const deserializedHEAD = SPMessage.deserializeHEAD(message) |
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 catch here noticing that this could be replaced with a call to fetchResource!
|
@taoeffect If you approve, please don't merge it yet, as I'll work on |
|
It looks like all the changes that will be needed should be in place now. I've also modified |
taoeffect
left a comment
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.
LGTM 👍
Closes #17