-
Notifications
You must be signed in to change notification settings - Fork 210
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
3.0.0: Fix remaining REST untyped responses #882
Conversation
…ined by request classes
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.
Changes look good to me.
It was a great effort to support all these types spawn by StateDelta but I do think it was mistake making StateDelta available through REST API. It was always thought as ledger internal so that easily modifiable as needed.
// eslint-disable-next-line class-methods-use-this | ||
path() { | ||
return '/health'; | ||
} | ||
|
||
async do(headers = {}) { |
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 I right and the overridden do
was needed only becase jsonOptions: { intDecoding: IntDecoding.BIGINT }
?
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 believe the reason for it was so that an error could be thrown if the request failed. But it wasn't really effective, since if res.ok
was false the underlying c.get
method would already throw an error.
And since this method doesn't return any data, the bigint decoding doesn't really make a difference.
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.
About 70% through, minimal comments so far.
Prior to this PR, the following algod request classes still had untyped responses:
Genesis
,GetLedgerStateDelta
,GetLedgerStateDeltaForTransactionGroup
,GetTransactionGroupLedgerStateDeltasForRound
,HealthCheck
,Ready
,SetBlockOffsetTimestamp
,SetSyncRound
,UnsetSyncRound
. These mostly fall into two categories: either they return no information, or they returned something related to state deltas and were passed over when #776 was merged.This PR resolves this and fixes a few other related issues/improvements:
HTTPClient
no longer parses JSON responses. This simplifies theprepare
method in request classes and no longer requires passing in JSON parsing options at the time of every request.do
method to implement their requests. That meant thedoRaw
method wasn't overridden and would produce incorrect results. Fixed by moving the override to a newexecuteRequest
method which is called from bothdo
anddoRaw
.JSONRequest
BlockHashSchema
because JSON block hashes get b32 encoded and prefixed withblk-
.LedgerStateDelta
and required subtypes. This comes with the caveat that the SDK does not currently support decoding maps with object keys (needed to support theTxleases
field), so I've left that as anUntypedValue
for now. I'll open a separate issue to track that, but I don't view it as urgent/required for v3.Relies on algorand/generator#80