diff --git a/packages/cli/contracts/src/tables/Table1.sol b/packages/cli/contracts/src/tables/Table1.sol index d5280b72d8..29b4caf1e4 100644 --- a/packages/cli/contracts/src/tables/Table1.sol +++ b/packages/cli/contracts/src/tables/Table1.sol @@ -47,11 +47,30 @@ library Table1 { return SchemaLib.encode(_schema); } + /** Get the table's metadata */ + function getMetadata() internal pure returns (string memory, string[] memory) { + string[] memory _fieldNames = new string[](7); + _fieldNames[0] = "v1"; + _fieldNames[1] = "v2"; + _fieldNames[2] = "v3"; + _fieldNames[3] = "v4"; + _fieldNames[4] = "v5"; + _fieldNames[5] = "v6"; + _fieldNames[6] = "v7"; + return ("Table1", _fieldNames); + } + /** Register the table's schema */ function registerSchema() internal { StoreSwitch.registerSchema(_tableId, getSchema()); } + /** Set the table's metadata */ + function setMetadata() internal { + (string memory _tableName, string[] memory _fieldNames) = getMetadata(); + StoreSwitch.setMetadata(_tableId, _tableName, _fieldNames); + } + /** Get v1 */ function getV1( uint256 k1, diff --git a/packages/cli/contracts/test/tablegen.t.sol b/packages/cli/contracts/test/tablegen.t.sol index 6862778a4e..de54cc044f 100644 --- a/packages/cli/contracts/test/tablegen.t.sol +++ b/packages/cli/contracts/test/tablegen.t.sol @@ -2,12 +2,11 @@ pragma solidity >=0.8.0; import "forge-std/Test.sol"; +import {StoreView} from "@latticexyz/store/src/StoreView.sol"; import {Table1, Table1Data} from "../src/tables/Table1.sol"; import {Enum1, Enum2} from "../src/types.sol"; -contract tablegenTest is Test { - function isStore() external view {} - +contract tablegenTest is Test, StoreView { function testTable1SetAndGet() public { Table1.registerSchema();