From 16d8c43e2678b29f513ca511dd97ca3346aadb1f Mon Sep 17 00:00:00 2001 From: LuckyWu Date: Mon, 31 Jul 2023 15:56:56 +0800 Subject: [PATCH] docs(world): fix minor bugs in the world docs (#1115) Co-authored-by: alvarius --- docs/pages/world/world-101.mdx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/docs/pages/world/world-101.mdx b/docs/pages/world/world-101.mdx index 19618203cf..1c6c8663e3 100644 --- a/docs/pages/world/world-101.mdx +++ b/docs/pages/world/world-101.mdx @@ -222,12 +222,12 @@ Now we can import our new table, and write something to it. Let’s write a func // SPDX-License-Identifier: MIT pragma solidity >=0.8.0; import { System } from "@latticexyz/world/src/System.sol"; -import { Dog } from "../codegen/tables/Dog.sol"; // import table we created +import { Dog, DogData } from "../codegen/tables/Dog.sol"; // import table we created contract MySystem is System { function addEntry(string memory name, string memory color) public returns (bytes32) { bytes32 key = bytes32(abi.encodePacked(block.number, msg.sender, gasleft())); // creating a random key for the record address owner = _msgSender(); // IMPORTANT: always refer to the msg.sender using the _msgSender() function - Dog.set(key, {owner: owner, name: name, color: color}); // creating our record! + Dog.set(key, DogData({owner: owner, name: name, color: color})); // creating our record! return key; } } @@ -235,6 +235,16 @@ contract MySystem is System { That’s it! `MySystem`, just like `IncrementSystem`, will have access to Dog given they are in the same namespace. + +We can run `pnpm mud worldgen` in the contract folder to recreate the systems. + +```bash +> pnpm mud worldgen +Generated system interface: src/codegen/world/IIncrementSystem.sol +Generated system interface: src/codegen/world/IMySystem.sol +Generated system interface: src/codegen/world/IWorld.sol +``` + After this step, the filesystem of the World is like this: ```bash