-
Couldn't load subscription status.
- Fork 5
feat: validate IDs #42
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
Conversation
🦋 Changeset detectedLatest commit: 3cc92b0 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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 good. Main thing is figuring out how to migrate any existing data to the changed ids that you found.
|
Should |
|
I think not, but will check again and will update the list of updated IDs |
b62d881 to
3cc92b0
Compare
| "@graphprotocol/grc-20": minor | ||
| --- | ||
|
|
||
| Update `QUOTES_THAT_SUPPORT_CLAIMS_PROPERTY` and `ACADEMIC_FIELD_TYPE` values to be valid IDs |
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.
We'll need to figure out the migration path for these since there's already data in the mainnet KG using these ids.
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's KG?
One thing we could do is simply create new entities and change the entries manually. In this case in old version we still have old versions pointing to invalid IDs, but since the data is already on chain we can't do a simply SQL migration script or can we?
|
|
||
| if (cover) { | ||
| // add ID of cover "Image" to property "Cover" | ||
| assertValid(cover); |
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.
Might be useful to pass a specific error message to assertValid to denote what the issue is. Would help consumers know which of their ids is invalid and why more easily.
For example this one might be something like Invalid id for "cover". Here's why ...
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.
👍 will do this in a follow up PR
| } | ||
| } | ||
|
|
||
| export function assertValid(id: string) { |
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.
Might be useful to pass a specific error message to the Error so consumers get more context as to why the error happened.
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.
Gave an example here https://github.com/graphprotocol/grc-20-ts/pull/42/files#r1972426106
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.
👍 will do this in a follow up PR
Idwith refined that validates the ID. see https://effect.website/docs/code-style/branded-types/#refinedGraphfunctionsQUOTES_THAT_SUPPORT_CLAIMS_PROPERTYfromquotesThatSupportClaimstoWoWTti3qGM1nvz28K9zu1fACADEMIC_FIELD_TYPEfromExCjm3rzYVfpMRwDchdrEtoKwKGhkY5AmzmHHggg7abvi