-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: replace Schema with FieldLayout for contract internals (#1336)
Co-authored-by: Kevin Ingersoll <[email protected]> Co-authored-by: alvrs <[email protected]>
- Loading branch information
1 parent
f823e72
commit de151fe
Showing
223 changed files
with
12,447 additions
and
2,911 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- | ||
"@latticexyz/cli": major | ||
"@latticexyz/protocol-parser": minor | ||
"@latticexyz/store": major | ||
"@latticexyz/world": major | ||
--- | ||
|
||
- Add `FieldLayout`, which is a `bytes32` user-type similar to `Schema`. | ||
|
||
Both `FieldLayout` and `Schema` have the same kind of data in the first 4 bytes. | ||
|
||
- 2 bytes for total length of all static fields | ||
- 1 byte for number of static size fields | ||
- 1 byte for number of dynamic size fields | ||
|
||
But whereas `Schema` has `SchemaType` enum in each of the other 28 bytes, `FieldLayout` has static byte lengths in each of the other 28 bytes. | ||
|
||
- Replace `Schema valueSchema` with `FieldLayout fieldLayout` in Store and World contracts. | ||
|
||
`FieldLayout` is more gas-efficient because it already has lengths, and `Schema` has types which need to be converted to lengths. | ||
|
||
- Add `getFieldLayout` to `IStore` interface. | ||
|
||
There is no `FieldLayout` for keys, only for values, because key byte lengths aren't usually relevant on-chain. You can still use `getKeySchema` if you need key types. | ||
|
||
- Add `fieldLayoutToHex` utility to `protocol-parser` package. | ||
|
||
- Add `constants.sol` for constants shared between `FieldLayout`, `Schema` and `PackedCounter`. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.