Skip to content

Commit

Permalink
feat(common,store,world): add internal table functions and use them f…
Browse files Browse the repository at this point in the history
…or internal mud logic (#1513)

Co-authored-by: alvrs <[email protected]>
  • Loading branch information
Boffee and alvrs authored Sep 16, 2023
1 parent 55ab88a commit 708b49c
Show file tree
Hide file tree
Showing 60 changed files with 4,108 additions and 229 deletions.
25 changes: 25 additions & 0 deletions .changeset/thin-terms-lay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
"@latticexyz/cli": patch
"@latticexyz/common": minor
"@latticexyz/store": minor
"@latticexyz/world": patch
---

Generated table libraries now have a set of functions prefixed with `_` that always use their own storage for read/write.
This saves gas for use cases where the functionality to dynamically determine which `Store` to use for read/write is not needed, e.g. root systems in a `World`, or when using `Store` without `World`.

We decided to continue to always generate a set of functions that dynamically decide which `Store` to use, so that the generated table libraries can still be imported by non-root systems.

```solidity
library Counter {
// Dynamically determine which store to write to based on the context
function set(uint32 value) internal;
// Always write to own storage
function _set(uint32 value) internal;
// ... equivalent functions for all other Store methods
}
```
95 changes: 95 additions & 0 deletions e2e/packages/contracts/src/codegen/tables/Multi.sol

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions e2e/packages/contracts/src/codegen/tables/Number.sol

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

76 changes: 76 additions & 0 deletions e2e/packages/contracts/src/codegen/tables/NumberList.sol

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 708b49c

Please sign in to comment.