Skip to content
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

refactor(store): separate SchemaLib into specialized libraries #1216

Merged
merged 2 commits into from
Aug 3, 2023

Conversation

dk1a
Copy link
Contributor

@dk1a dk1a commented Jul 31, 2023

No description provided.

@changeset-bot
Copy link

changeset-bot bot commented Jul 31, 2023

⚠️ No Changeset found

Latest commit: cbb1b2f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Comment on lines +39 to 48
SchemaType[] memory _valueSchema = new SchemaType[](2);
_valueSchema[0] = SchemaType.BYTES32;
_valueSchema[1] = SchemaType.BYTES32;
SchemaType[] memory _keySchema = new SchemaType[](1);
_keySchema[0] = SchemaType.BYTES32;
registerSchema(
StoreCoreInternal.SCHEMA_TABLE,
SchemaLib.encode(SchemaType.BYTES32, SchemaType.BYTES32), // The Schema table's valueSchema is { valueSchema: BYTES32, keySchema: BYTES32 }
SchemaLib.encode(SchemaType.BYTES32) // The Schema table's keySchema is { tableId: BYTES32 }
SchemaLib.encode(_valueSchema), // The Schema table's valueSchema is { valueSchema: BYTES32, keySchema: BYTES32 }
SchemaLib.encode(_keySchema) // The Schema table's keySchema is { tableId: BYTES32 }
);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after #1174 this will be replaced with a table's schema method, which will remove the hardcode and the slight gas increase

/**
* Overrides for encode function to simplify tests
*/
library SchemaEncodeHelper {
Copy link
Contributor Author

@dk1a dk1a Jul 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these hardcoded methods should only be used in tests; in systems/modules you'd use a table's autogenerated schema.
so to avoid confusion it seems better to explicitly put them in a test dir

@dk1a dk1a marked this pull request as ready for review July 31, 2023 17:02
@dk1a dk1a requested review from alvrs and holic as code owners July 31, 2023 17:02
Copy link
Member

@alvrs alvrs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@dk1a dk1a merged commit c1d2249 into main Aug 3, 2023
@dk1a dk1a deleted the dk1a/schemalib branch August 3, 2023 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants