-
Notifications
You must be signed in to change notification settings - Fork 189
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(cli): add prototypes to tablegen #459
Conversation
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.
Didn't review in-depth yet, but looks good on first sight! Could you add an integration/example branch to v2sandbox
to illustrate this change?
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.
(oops, forgot to submit this review)
* | ||
* The string is rendered in solidity as-is, unescaped and without adding quotes | ||
*/ | ||
default?: string | Record<z.input<typeof ColumnName>, 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.
Not blocking but I wonder if we could refine this based on what field/types were defined in the TableConfig
corresponding to the table name.
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.
Yeah I'd prefer it to be typed, but that's complicated and would kinda use a lot of v2 networking/schema-type stuff, which I'd rather take/generalize later than reimplement now. It's also not a very important feature and I have some doubts about its usefulness
Co-authored-by: Kevin Ingersoll <[email protected]>
* fix schema validation for singletons
ready for review see https://github.com/latticexyz/v2sandbox/tree/dk1a/prototypes for some examples (they're real prototypes from 3 mud games) v2sandbox doesn't have tests, I just tested that it all compiles (prototypes there are too complicated. It would be useful to add complex tests later though, when prototypes are more stable). |
@@ -188,9 +173,9 @@ library SchemaLib { | |||
return Schema.unwrap(schema) == bytes32(0); | |||
} | |||
|
|||
function validate(Schema schema) internal pure { | |||
function validate(Schema schema, bool allowEmpty) internal pure { |
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.
this is needed to allow empty keys for singletons (I add a test for a prototype of singletons in this PR)
* feat(recs): support new schema shorthand in tableSchemaToRecsSchema
closing in favor of #500 |
A prototype is a collection of tables with the same
primaryKeys
You can use it to set/delete all tables with one method.
Default values are a bit clunky and don't work well with dynamic fields. I'm not yet sure how useful they will be.
Also a helper to get all tableIds, which can be used by a
Prototype
table andLibPrototype
to dynamically copy prototypes (but these aren't a part of this PR)also adds minor improvements, in particular
storeArgument
for all relevant methods and a new shorthandschema: SchemaType....