-
Notifications
You must be signed in to change notification settings - Fork 278
feat(xc_admin_frontend): add more details to summary view #1612
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(xc_admin_frontend): add more details to summary view #1612
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Ignored Deployment
|
For some reason, Vercel isn't posting the preview URL, even though the preview built (probably because I'm working on a fork...) In any case, here's a preview URL that's particularly extreme, with a ton of |
default: | ||
return { | ||
name: parsedInstruction.name, | ||
} as const |
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.
What is the point of the "as const"
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.
as const
does two things:
- It narrows the inference engine. In particular, this means that e.g. the type of
{ name: 'addPublisher' }
is interpreted with thename
field's type as the literal"addPublisher"
instead of the typestring
. - It marks types as
readonly
It's a bit of a shame that typescript doesn't have a nice syntax for narrowly inferring types that does only #1 without #2 since the readonly
modifier is, IMO, quite clunky and not very useful.
I did this for #1 -- it actually doesn't matter in this code because the fact that parsedInstruction.name
can be any arbitrary string means that the inference engine actually can't match the literal addPublisher
to the case on line 106 (as far as I know typescript is not smart enough to infer that the case here only matches for any string except addPublisher
and delPublisher
). However, it doesn't make sense to me that an instruction can be an arbitrary name, that seems like something that eventually will be enumerated, and the idea is that by doing this now, eventually if we do enumerate the names, it would be very very easy to update this function so that type inference can correctly match the shape of the return value based on the instruction name. This would be especially valuable if we added more bespoke summaries for different instruction types.
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.
In case you're curious, here's a good illustration in the typescript playground of the difference between using the const assertion vs not: https://www.typescriptlang.org/play/?#code/MYewdgzgLgBAJiAyiAtgUygCwJZgOYwC8MAFAIYBOeAXDNBbngJREB8MA3gLABQMdAd2xRgmUpWade-fsDIQ0MAOQAjMgC8ltChgCuFMJxhgy6Wqo1KANHVQYc+WgFYYAXwDc0mXDQAzMroANlDaegZGJmbKEHZYjACigQrWtuhx+IkKtFAUuooeXq68RTy8oJCwCMhpDngA6sKYAMLg0ETiVLT0jCyE7Nx8gsKiHZIDMjByCspqmqFQ+oYcxqZo5rMpMTWMzm4w8pOtUJ6D-D7+QSEwOgvhy5Fr0bG1mWibzwlJjzl5ewfl0BO-BKriAA.
If you take a look at the .d.ts
tab on the right side, you'll see how typescript infers the types. If you see how doSomethingWithConst
gets inferred with literals, it essentially allows any consuming code that matches name
to baz
to automatically infer correctly that something
is 5 and somethingElse
is undefined
.
governance/xc_admin/packages/xc_admin_frontend/components/tabs/Proposals/utils.ts
Outdated
Show resolved
Hide resolved
This is great, please add it for non wormhole proposals as well |
c0697a2
to
dd1f07e
Compare
@cprussin is attempting to deploy a commit to the pyth-web Team on Vercel. A member of the Team first needs to authorize it. |
This PR extends the summary to include publisher and price account details for addPublisher and delPublisher instructions.
dd1f07e
to
feb53d8
Compare
This PR extends the summary to include publisher and price account details for addPublisher and delPublisher instructions.