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. diff --git a/examples/minimal/packages/contracts/script/PostDeploy.s.sol b/examples/minimal/packages/contracts/script/PostDeploy.s.sol index 89907cacd1..22fd9d5f19 100644 --- a/examples/minimal/packages/contracts/script/PostDeploy.s.sol +++ b/examples/minimal/packages/contracts/script/PostDeploy.s.sol @@ -3,15 +3,19 @@ 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 { 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..1205560c79 100644 --- a/templates/phaser/packages/contracts/script/PostDeploy.s.sol +++ b/templates/phaser/packages/contracts/script/PostDeploy.s.sol @@ -3,10 +3,15 @@ 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 { 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..1205560c79 100644 --- a/templates/react/packages/contracts/script/PostDeploy.s.sol +++ b/templates/react/packages/contracts/script/PostDeploy.s.sol @@ -3,10 +3,15 @@ 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 { 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..1205560c79 100644 --- a/templates/vanilla/packages/contracts/script/PostDeploy.s.sol +++ b/templates/vanilla/packages/contracts/script/PostDeploy.s.sol @@ -3,10 +3,15 @@ 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 { 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");