From 815495810027b37e4f2622d9f1e956ea116e58da Mon Sep 17 00:00:00 2001 From: ryo hashimoto Date: Tue, 24 Oct 2023 14:29:56 +0900 Subject: [PATCH 1/3] fix(create-mud): set store address in PostDeploy script --- examples/minimal/packages/contracts/script/PostDeploy.s.sol | 3 +++ templates/phaser/packages/contracts/script/PostDeploy.s.sol | 3 +++ templates/react/packages/contracts/script/PostDeploy.s.sol | 3 +++ templates/vanilla/packages/contracts/script/PostDeploy.s.sol | 3 +++ 4 files changed, 12 insertions(+) diff --git a/examples/minimal/packages/contracts/script/PostDeploy.s.sol b/examples/minimal/packages/contracts/script/PostDeploy.s.sol index 89907cacd1..ef80d0dde9 100644 --- a/examples/minimal/packages/contracts/script/PostDeploy.s.sol +++ b/examples/minimal/packages/contracts/script/PostDeploy.s.sol @@ -12,6 +12,9 @@ import { ChatNamespacedSystem } from "../src/systems/ChatNamespacedSystem.sol"; contract PostDeploy is Script { function run(address worldAddress) external { + // Specify a store so that you can use tables directly in PostDeploy + StoreSwitch.setStoreAddress(worldAddress); + // Load the private key from the `PRIVATE_KEY` environment variable (in .env) uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); diff --git a/templates/phaser/packages/contracts/script/PostDeploy.s.sol b/templates/phaser/packages/contracts/script/PostDeploy.s.sol index d8600bb5ed..3081e00a5d 100644 --- a/templates/phaser/packages/contracts/script/PostDeploy.s.sol +++ b/templates/phaser/packages/contracts/script/PostDeploy.s.sol @@ -7,6 +7,9 @@ import { IWorld } from "../src/codegen/world/IWorld.sol"; contract PostDeploy is Script { function run(address worldAddress) external { + // Specify a store so that you can use tables directly in PostDeploy + StoreSwitch.setStoreAddress(worldAddress); + // Load the private key from the `PRIVATE_KEY` environment variable (in .env) uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); diff --git a/templates/react/packages/contracts/script/PostDeploy.s.sol b/templates/react/packages/contracts/script/PostDeploy.s.sol index d8600bb5ed..3081e00a5d 100644 --- a/templates/react/packages/contracts/script/PostDeploy.s.sol +++ b/templates/react/packages/contracts/script/PostDeploy.s.sol @@ -7,6 +7,9 @@ import { IWorld } from "../src/codegen/world/IWorld.sol"; contract PostDeploy is Script { function run(address worldAddress) external { + // Specify a store so that you can use tables directly in PostDeploy + StoreSwitch.setStoreAddress(worldAddress); + // Load the private key from the `PRIVATE_KEY` environment variable (in .env) uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); diff --git a/templates/vanilla/packages/contracts/script/PostDeploy.s.sol b/templates/vanilla/packages/contracts/script/PostDeploy.s.sol index d8600bb5ed..3081e00a5d 100644 --- a/templates/vanilla/packages/contracts/script/PostDeploy.s.sol +++ b/templates/vanilla/packages/contracts/script/PostDeploy.s.sol @@ -7,6 +7,9 @@ import { IWorld } from "../src/codegen/world/IWorld.sol"; contract PostDeploy is Script { function run(address worldAddress) external { + // Specify a store so that you can use tables directly in PostDeploy + StoreSwitch.setStoreAddress(worldAddress); + // Load the private key from the `PRIVATE_KEY` environment variable (in .env) uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); From e69b30648f8788ceb97eb987f3241a92074cde15 Mon Sep 17 00:00:00 2001 From: Kevin Ingersoll Date: Tue, 24 Oct 2023 02:49:05 -0700 Subject: [PATCH 2/3] Create fifty-suits-itch.md --- .changeset/fifty-suits-itch.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/fifty-suits-itch.md diff --git a/.changeset/fifty-suits-itch.md b/.changeset/fifty-suits-itch.md new file mode 100644 index 0000000000..a21a542d11 --- /dev/null +++ b/.changeset/fifty-suits-itch.md @@ -0,0 +1,5 @@ +--- +"create-mud": patch +--- + +Updated templates' PostDeploy script to set store address so that tables can be used directly inside PostDeploy. From 4136611c6cc317dfa4009a39eaca77cd3843aa6b Mon Sep 17 00:00:00 2001 From: ryo hashimoto Date: Tue, 24 Oct 2023 19:43:10 +0900 Subject: [PATCH 3/3] fix(create-mud): import StoreSwitch library --- examples/minimal/packages/contracts/script/PostDeploy.s.sol | 3 ++- templates/phaser/packages/contracts/script/PostDeploy.s.sol | 2 ++ templates/react/packages/contracts/script/PostDeploy.s.sol | 2 ++ templates/vanilla/packages/contracts/script/PostDeploy.s.sol | 2 ++ 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/examples/minimal/packages/contracts/script/PostDeploy.s.sol b/examples/minimal/packages/contracts/script/PostDeploy.s.sol index ef80d0dde9..22fd9d5f19 100644 --- a/examples/minimal/packages/contracts/script/PostDeploy.s.sol +++ b/examples/minimal/packages/contracts/script/PostDeploy.s.sol @@ -3,11 +3,12 @@ pragma solidity >=0.8.21; import { Script } from "forge-std/Script.sol"; import { console } from "forge-std/console.sol"; +import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol"; import { ResourceId, WorldResourceIdLib } from "@latticexyz/world/src/WorldResourceId.sol"; import { RESOURCE_SYSTEM } from "@latticexyz/world/src/worldResourceTypes.sol"; -import { IWorld } from "../src/codegen/world/IWorld.sol"; import { MessageTable, MessageTableTableId } from "../src/codegen/index.sol"; +import { IWorld } from "../src/codegen/world/IWorld.sol"; import { ChatNamespacedSystem } from "../src/systems/ChatNamespacedSystem.sol"; contract PostDeploy is Script { diff --git a/templates/phaser/packages/contracts/script/PostDeploy.s.sol b/templates/phaser/packages/contracts/script/PostDeploy.s.sol index 3081e00a5d..1205560c79 100644 --- a/templates/phaser/packages/contracts/script/PostDeploy.s.sol +++ b/templates/phaser/packages/contracts/script/PostDeploy.s.sol @@ -3,6 +3,8 @@ pragma solidity >=0.8.21; import { Script } from "forge-std/Script.sol"; import { console } from "forge-std/console.sol"; +import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol"; + import { IWorld } from "../src/codegen/world/IWorld.sol"; contract PostDeploy is Script { diff --git a/templates/react/packages/contracts/script/PostDeploy.s.sol b/templates/react/packages/contracts/script/PostDeploy.s.sol index 3081e00a5d..1205560c79 100644 --- a/templates/react/packages/contracts/script/PostDeploy.s.sol +++ b/templates/react/packages/contracts/script/PostDeploy.s.sol @@ -3,6 +3,8 @@ pragma solidity >=0.8.21; import { Script } from "forge-std/Script.sol"; import { console } from "forge-std/console.sol"; +import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol"; + import { IWorld } from "../src/codegen/world/IWorld.sol"; contract PostDeploy is Script { diff --git a/templates/vanilla/packages/contracts/script/PostDeploy.s.sol b/templates/vanilla/packages/contracts/script/PostDeploy.s.sol index 3081e00a5d..1205560c79 100644 --- a/templates/vanilla/packages/contracts/script/PostDeploy.s.sol +++ b/templates/vanilla/packages/contracts/script/PostDeploy.s.sol @@ -3,6 +3,8 @@ pragma solidity >=0.8.21; import { Script } from "forge-std/Script.sol"; import { console } from "forge-std/console.sol"; +import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol"; + import { IWorld } from "../src/codegen/world/IWorld.sol"; contract PostDeploy is Script {