validate allocation in getCurrentAllocation #7198
Labels
code-style
defensive correctness patterns; readability thru consistency
devex
developer experience
enhancement
New feature or request
vaults_triage
DO NOT USE
What is the Problem Being Solved?
We had a bug where the record from
getCurrentAllocation
was missing a key that was expected. This is because the return type isRecord<Keyword, Amount<any>
: #7195 (review)Description of the Design
Make
getCurrentAllocation
return an accurate type description:I tried making it return an
UnknownKeywordRecord
,That causes errors in the many places the allocation structure is assumed. We could have runtime checks in all those places but I propose that we instead add an optional "shape" parameter to getCurrentAllocation. It can
mustMatch
before returning. The return type should be aware of this runtime check. Making that work will depend on being able to infer the shape's static type from its own structure: #6160Security Considerations
Scaling Considerations
Test Plan
The text was updated successfully, but these errors were encountered: