diff --git a/.changeset/six-kangaroos-sneeze.md b/.changeset/six-kangaroos-sneeze.md new file mode 100644 index 0000000000..3557002a21 --- /dev/null +++ b/.changeset/six-kangaroos-sneeze.md @@ -0,0 +1,5 @@ +--- +"@latticexyz/world": minor +--- + +Return address of the newly created World from `WorldFactory.deployWorld`. diff --git a/packages/world/src/IWorldFactory.sol b/packages/world/src/IWorldFactory.sol index 8dc363877e..7414130a60 100644 --- a/packages/world/src/IWorldFactory.sol +++ b/packages/world/src/IWorldFactory.sol @@ -22,6 +22,7 @@ interface IWorldFactory { /** * @notice Deploys a new World contract. * @dev The deployment of the World contract will result in the `WorldDeployed` event being emitted. + * @return worldAddress The address of the newly deployed World contract. */ - function deployWorld() external; + function deployWorld() external returns (address worldAddress); } diff --git a/packages/world/src/WorldFactory.sol b/packages/world/src/WorldFactory.sol index 1e49c68c78..763811d606 100644 --- a/packages/world/src/WorldFactory.sol +++ b/packages/world/src/WorldFactory.sol @@ -26,13 +26,14 @@ contract WorldFactory is IWorldFactory { } /** - * @notice Deploys a new World instance, sets the CoreModule and transfers its ownership to the caller. + * @notice Deploys a new World instance, installs the CoreModule and transfers ownership to the caller. * @dev Uses the Create2 for deterministic deployment. + * @return worldAddress The address of the newly deployed World contract. */ - function deployWorld() public { + function deployWorld() public returns (address worldAddress) { // Deploy a new World and increase the WorldCount bytes memory bytecode = type(World).creationCode; - address worldAddress = Create2.deploy(bytecode, worldCount++); + worldAddress = Create2.deploy(bytecode, worldCount++); IBaseWorld world = IBaseWorld(worldAddress); // Initialize the World and transfer ownership to the caller