Skip to content

Commit

Permalink
chore: updates to node deploy script (#546)
Browse files Browse the repository at this point in the history
Closes #542

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Introduced a new deployment workflow for the node registry that
automatically produces a JSON summary of deployment data.
- Expanded the environment configuration with additional output
parameters.

- **Refactor**
- Updated validations in the deployment process to ensure necessary
credentials are provided.
- Streamlined the contract initialization process for a more flexible
and robust deployment experience.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
fbac authored Feb 24, 2025
1 parent 8ede0c9 commit 25ee31b
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 3 deletions.
3 changes: 2 additions & 1 deletion contracts/script/DeployGroupMessages.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ contract DeployGroupMessages is Script, Utils, Environment {
function run() external {
admin = vm.envAddress("XMTP_GROUP_MESSAGES_ADMIN_ADDRESS");
require(admin != address(0), "XMTP_GROUP_MESSAGES_ADMIN_ADDRESS not set");
require(admin.code.length == 0, "admin address is a contract, not an EOA");

uint256 privateKey = vm.envUint("PRIVATE_KEY");
require(privateKey != 0, "PRIVATE_KEY not set");

deployer = vm.addr(privateKey);
vm.startBroadcast(privateKey);

Expand Down
3 changes: 2 additions & 1 deletion contracts/script/DeployIdentityUpdates.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ contract DeployIdentityUpdates is Script, Utils, Environment {
function run() external {
admin = vm.envAddress("XMTP_IDENTITY_UPDATES_ADMIN_ADDRESS");
require(admin != address(0), "XMTP_IDENTITY_UPDATES_ADMIN_ADDRESS not set");
require(admin.code.length == 0, "admin address is a contract, not an EOA");

uint256 privateKey = vm.envUint("PRIVATE_KEY");
require(privateKey != 0, "PRIVATE_KEY not set");

deployer = vm.addr(privateKey);
vm.startBroadcast(privateKey);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ contract Deployer is Script {
new Nodes();
vm.broadcast();
}
}
}
51 changes: 51 additions & 0 deletions contracts/script/DeployNodeRegistryV2.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.28;

import {Script, console} from "forge-std/src/Script.sol";
import {Environment} from "./utils/Environment.sol";
import {Utils} from "./utils/Utils.sol";
import "src/interfaces/INodes.sol";
import "src/NodesV2.sol";

contract DeployXMTPNodeRegistry is Script, Environment, Utils {
NodesV2 nodes;

address admin;
address deployer;

function run() public {
admin = vm.envAddress("XMTP_NODE_REGISTRY_ADMIN_ADDRESS");
require(admin != address(0), "XMTP_NODE_REGISTRY_ADMIN_ADDRESS not set");

uint256 privateKey = vm.envUint("PRIVATE_KEY");
require(privateKey != 0, "PRIVATE_KEY not set");

deployer = vm.addr(privateKey);
vm.startBroadcast(privateKey);

nodes = new NodesV2(admin);
require(address(nodes) != address(0), "Nodes deployment failed");

vm.stopBroadcast();

_serializeDeploymentData();
}

function _serializeDeploymentData() internal {
string memory parent_object = "parent object";
string memory addresses = "addresses";

string memory addressesOutput;

addressesOutput = vm.serializeAddress(addresses, "XMTPNodeRegistryDeployer", deployer);
addressesOutput = vm.serializeAddress(addresses, "XMTPNodeRegistryInitialAdmin", admin);
addressesOutput = vm.serializeAddress(addresses, "XMTPNodeRegistry", address(nodes));

string memory finalJson;
finalJson = vm.serializeString(parent_object, addresses, addressesOutput);
finalJson = vm.serializeUint(parent_object, "deploymentBlock", block.number);
finalJson = vm.serializeUint(parent_object, "latestUpgradeBlock", block.number);

writeOutput(finalJson, XMTP_NODE_REGISTRY_OUTPUT_JSON);
}
}
1 change: 1 addition & 0 deletions contracts/script/utils/Environment.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ import "forge-std/src/Script.sol";
contract Environment is Script {
string public constant XMTP_GROUP_MESSAGES_OUTPUT_JSON = "GroupMessages";
string public constant XMTP_IDENTITY_UPDATES_OUTPUT_JSON = "IdentityUpdates";
string public constant XMTP_NODE_REGISTRY_OUTPUT_JSON = "XMTPNodeRegistry";
}

0 comments on commit 25ee31b

Please sign in to comment.