Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(world): emit salt in WorldDeployed event #2301

Merged
merged 3 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/forty-weeks-laugh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@latticexyz/world": patch
---

Added salt to the `WorldDeployed` event.
9 changes: 5 additions & 4 deletions docs/pages/world/reference/world-external.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -917,11 +917,12 @@ function deployWorld(bytes memory salt) external returns (address worldAddress);
_Emitted when a new World contract is deployed._

```solidity
event WorldDeployed(address indexed newContract);
event WorldDeployed(address indexed newContract, uint256 salt);
```

**Parameters**

| Name | Type | Description |
| ------------- | --------- | ------------------------------------------------- |
| `newContract` | `address` | The address of the newly deployed World contract. |
| Name | Type | Description |
| ------------- | --------- | ------------------------------------------------------------------ |
| `newContract` | `address` | The address of the newly deployed World contract. |
| `salt` | `uint256` | User defined salt for deterministic world addresses across chains. |
4 changes: 2 additions & 2 deletions packages/world/gas-report.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@
"file": "test/Factories.t.sol",
"test": "testCreate2Factory",
"name": "deploy contract via Create2",
"gasUsed": 4612103
"gasUsed": 4615190
},
{
"file": "test/Factories.t.sol",
"test": "testWorldFactoryGas",
"name": "deploy world via WorldFactory",
"gasUsed": 12696900
"gasUsed": 12697195
},
{
"file": "test/World.t.sol",
Expand Down
3 changes: 2 additions & 1 deletion packages/world/src/IWorldFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ interface IWorldFactory {
/**
* @dev Emitted when a new World contract is deployed.
* @param newContract The address of the newly deployed World contract.
* @param salt User defined salt for deterministic world addresses across chains.
*/
event WorldDeployed(address indexed newContract);
event WorldDeployed(address indexed newContract, uint256 salt);

/**
* @notice Deploys a new World contract.
Expand Down
2 changes: 1 addition & 1 deletion packages/world/src/WorldFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ contract WorldFactory is IWorldFactory {
world.initialize(initModule);
world.transferOwnership(ROOT_NAMESPACE_ID, msg.sender);

emit WorldDeployed(worldAddress);
emit WorldDeployed(worldAddress, _salt);
}
}
6 changes: 3 additions & 3 deletions packages/world/test/Factories.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { createInitModule } from "./createInitModule.sol";

contract FactoriesTest is Test, GasReporter {
event ContractDeployed(address addr, uint256 salt);
event WorldDeployed(address indexed newContract);
event WorldDeployed(address indexed newContract, uint256 salt);
event HelloWorld(bytes32 indexed version);

function calculateAddress(
Expand Down Expand Up @@ -75,7 +75,7 @@ contract FactoriesTest is Test, GasReporter {

// Check for WorldDeployed event from Factory
vm.expectEmit(true, false, false, false);
emit WorldDeployed(calculatedAddress);
emit WorldDeployed(calculatedAddress, salt1);
startGasReport("deploy world via WorldFactory");
worldFactory.deployWorld(_salt1);
endGasReport();
Expand Down Expand Up @@ -108,7 +108,7 @@ contract FactoriesTest is Test, GasReporter {

// Check for WorldDeployed event from Factory
vm.expectEmit(true, false, false, false);
emit WorldDeployed(calculatedAddress);
emit WorldDeployed(calculatedAddress, salt2);
worldFactory.deployWorld(_salt2);

// Set the store address manually
Expand Down
2 changes: 1 addition & 1 deletion packages/world/ts/worldEvents.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// from WorldFactory
export const worldDeployedEvent = "event WorldDeployed(address indexed newContract)";
export const worldDeployedEvent = "event WorldDeployed(address indexed newContract, uint256 salt)";

// from World
export const helloWorldEvent = "event HelloWorld(bytes32 indexed worldVersion)";
Loading