Skip to content

Commit

Permalink
Create sour-cycles-warn.md
Browse files Browse the repository at this point in the history
  • Loading branch information
alvrs authored Sep 16, 2023
1 parent c85c3bc commit 66522b7
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .changeset/sour-cycles-warn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
"@latticexyz/cli": patch
"@latticexyz/store": minor
"@latticexyz/world": patch
---

`StoreCore` and `IStore` now expose specific functions for `getStaticField` and `getDynamicField` in addition to the general `getField`.
Using the specific functions reduces gas overhead because more optimized logic can be executed.

```solidity
interface IStore {
/**
* Get a single static field from the given tableId and key tuple, with the given value field layout.
* Note: the field value is left-aligned in the returned bytes32, the rest of the word is not zeroed out.
* Consumers are expected to truncate the returned value as needed.
*/
function getStaticField(
bytes32 tableId,
bytes32[] calldata keyTuple,
uint8 fieldIndex,
FieldLayout fieldLayout
) external view returns (bytes32);
/**
* Get a single dynamic field from the given tableId and key tuple at the given dynamic field index.
* (Dynamic field index = field index - number of static fields)
*/
function getDynamicField(
bytes32 tableId,
bytes32[] memory keyTuple,
uint8 dynamicFieldIndex
) external view returns (bytes memory);
}
```

0 comments on commit 66522b7

Please sign in to comment.