Skip to content

Commit 7987c94

Browse files
authored
feat(world): return world address from WorldFactory (#1675)
1 parent 88b1a5a commit 7987c94

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

.changeset/six-kangaroos-sneeze.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@latticexyz/world": minor
3+
---
4+
5+
Return address of the newly created World from `WorldFactory.deployWorld`.

packages/world/src/IWorldFactory.sol

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ interface IWorldFactory {
2222
/**
2323
* @notice Deploys a new World contract.
2424
* @dev The deployment of the World contract will result in the `WorldDeployed` event being emitted.
25+
* @return worldAddress The address of the newly deployed World contract.
2526
*/
26-
function deployWorld() external;
27+
function deployWorld() external returns (address worldAddress);
2728
}

packages/world/src/WorldFactory.sol

+4-3
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,14 @@ contract WorldFactory is IWorldFactory {
2626
}
2727

2828
/**
29-
* @notice Deploys a new World instance, sets the CoreModule and transfers its ownership to the caller.
29+
* @notice Deploys a new World instance, installs the CoreModule and transfers ownership to the caller.
3030
* @dev Uses the Create2 for deterministic deployment.
31+
* @return worldAddress The address of the newly deployed World contract.
3132
*/
32-
function deployWorld() public {
33+
function deployWorld() public returns (address worldAddress) {
3334
// Deploy a new World and increase the WorldCount
3435
bytes memory bytecode = type(World).creationCode;
35-
address worldAddress = Create2.deploy(bytecode, worldCount++);
36+
worldAddress = Create2.deploy(bytecode, worldCount++);
3637
IBaseWorld world = IBaseWorld(worldAddress);
3738

3839
// Initialize the World and transfer ownership to the caller

0 commit comments

Comments
 (0)