Skip to content

Conversation

@corrideat
Copy link
Member

Closes #17

Comment on lines +2 to +3
permissions:
contents: read
Copy link
Member Author

Choose a reason for hiding this comment

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

Add explicit permissions

@corrideat corrideat marked this pull request as ready for review October 19, 2025 19:12
Copy link
Member

@taoeffect taoeffect left a 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 })
Copy link
Member

Choose a reason for hiding this comment

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

Somewhat confusing API imo.

  1. The contractID appears to be optional as it's typed contractID?: string, yet the implementation always does the comparison, indicating it's mandatory.
  2. So if it's mandatory I wouldn't split the parameters like this, but instead move hash into the object. Also better either way as it's named parameters like that and named parameters are easier to read at the call site

Copy link
Member Author

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.

Comment on lines +1465 to +1468
const message = await sbp('chelonia/out/fetchResource', hash, {
code: multicodes.SHELTER_CONTRACT_DATA
})
const deserializedHEAD = SPMessage.deserializeHEAD(message)
Copy link
Member

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!

@corrideat
Copy link
Member Author

@taoeffect If you approve, please don't merge it yet, as I'll work on ChatMain and there may be other changes yet to be made.

@corrideat
Copy link
Member Author

It looks like all the changes that will be needed should be in place now.

I've also modified eventsBetween to make the end height optional, as I don't think we necessarily need it in ChatMain (current latest is fine, which also saves an API call), and I've also discovered that the serdes library doesn't consider cases like Infinity, which aren't representable in JSON. So, an optional endHeight set to infinity by default makes the most sense.

Copy link
Member

@taoeffect taoeffect left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@taoeffect taoeffect merged commit 173f485 into main Oct 20, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose a way to get a deserializedHEAD given a hash

3 participants