Skip to content

Commit

Permalink
add more component examples (mud.config)
Browse files Browse the repository at this point in the history
  • Loading branch information
karooolis committed Aug 9, 2024
1 parent b365f00 commit 3573556
Show file tree
Hide file tree
Showing 17 changed files with 1,273 additions and 44 deletions.
28 changes: 28 additions & 0 deletions examples/explorer-template/packages/contracts/mud.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,39 @@ import { defineWorld } from "@latticexyz/world";
export default defineWorld({
namespace: "app",
tables: {
Checked: "bool",

Counter: {
schema: {
value: "uint32",
},
key: [],
},

OffchainCounter: {
schema: {
value: "uint32",
},
key: [],
type: "offchainTable",
},

Tasks: {
schema: {
id: "bytes32",
createdAt: "uint256",
completedAt: "uint256",
description: "string",
},
key: ["id"],
},

Checkboxes: {
schema: {
checkboxId: "bytes32",
checked: "bool",
},
key: ["checkboxId"],
},
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,27 @@ contract PostDeploy is Script {
uint32 newValue = IWorld(worldAddress).app__increment();
console.log("Increment via IWorld:", newValue);

IWorld(worldAddress).app__incrementOffchain();

// Add checkboxes
for (uint256 i = 0; i < 100; i++) {
IWorld(worldAddress).app__addCheckbox(i, i % 2 == 0);
}

// Or we can call our own systems
IWorld(worldAddress).app__addTask("Take out the trash");

bytes32 key = IWorld(worldAddress).app__addTask("Do the dishes");
IWorld(worldAddress).app__completeTask(key);

IWorld(worldAddress).app__addTask("Task 1");
IWorld(worldAddress).app__addTask("Task 2");
IWorld(worldAddress).app__addTask("Task 3");
IWorld(worldAddress).app__addTask("Task 4");
IWorld(worldAddress).app__addTask("Task 5");
IWorld(worldAddress).app__addTask("Task 6");
IWorld(worldAddress).app__addTask("Task 7");

vm.stopBroadcast();
}
}

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

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

Loading

0 comments on commit 3573556

Please sign in to comment.