Skip to content

Commit

Permalink
feat(world): return world address from WorldFactory (#1675)
Browse files Browse the repository at this point in the history
  • Loading branch information
alvrs authored Sep 30, 2023
1 parent 88b1a5a commit 7987c94
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/six-kangaroos-sneeze.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@latticexyz/world": minor
---

Return address of the newly created World from `WorldFactory.deployWorld`.
3 changes: 2 additions & 1 deletion packages/world/src/IWorldFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
7 changes: 4 additions & 3 deletions packages/world/src/WorldFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7987c94

Please sign in to comment.