-
Notifications
You must be signed in to change notification settings - Fork 150
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
feat: add pallets/consts endpoint #1210
Conversation
add unit and e2e tests
added statemint consts e2e tests
src/services/test-helpers/responses/pallets/fetchEnactmentPeriodConstsItem789629.json
Outdated
Show resolved
Hide resolved
src/services/test-helpers/responses/pallets/fetchVotingPeriodConstsItem789629.json
Outdated
Show resolved
Hide resolved
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.
👍
[palletItemIdx, palletItemMeta] = this.getEventItemMeta( | ||
historicApi, | ||
palletMeta as PalletMetadataV14, | ||
palletItemIdx, | ||
palletItemId | ||
); | ||
} else { |
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 see that this if...else
statement keeps growing and I was wondering if it would a good idea to replace this conditionals with a lookup table or an object lookup ? since the only thing that changes is the name of the function called.
I was checking some articles to find as references :
Maybe it makes it also more readable and maintainable ? Just an idea because I used that in C in the past and I think it is quite fast but I am not sure in Typescript (performance wise).
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 don't think this is necessary. A lookup table would require a few abstractions, and performance isn't really going to get affected here. if...else
is acceptable IMO. We know the fixed size of this if else so I don't think its going to grow much more.
That being said the only other option I would see for readability is a switch
statement.
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.
Looks Great!
Summary: An endpoint that returns the constants for a given pallet
/pallets/{palletId}/consts
Query Params
at
: Which block to query, it will default to the latest finalized block. Accepts a hash or blocknumberonlyIds
: boolean to return only the Id of each constant instead of the entirety of each constantSample response for /pallets/democracy/consts?onlyIds=true
/pallets/{palletId}/consts/{constItemId}
Query Params
at
: Which block to query, it will default to the latest finalized block. Accepts a hash or blocknumbermetadata
: boolean to choose whether to include an consts' metadata in the responseSample response for /pallets/democracy/consts/InstantAllowed