Skip to content

Commit

Permalink
Merge pull request #304 from chainbound/nico/chore/net-optin
Browse files Browse the repository at this point in the history
fix: symbiotic network opt-in
  • Loading branch information
merklefruit authored Oct 21, 2024
2 parents 89d8a70 + ce3fadc commit 10adbfb
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 14 deletions.
2 changes: 1 addition & 1 deletion bolt-contracts/config/holesky/deployments.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"validators": "0x05275a4799cd1B07D81319390fC62Bc7BDbDf269"
},
"symbiotic": {
"network": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
"network": "0x90F79bf6EB2c4f870365E785982E1f101E93b906",
"operatorRegistry": "0xAdFC41729fF447974cE27DdFa358A0f2096c3F39",
"networkOptInService": "0xF5AFc9FA3Ca63a07E529DDbB6eae55C665cCa83E",
"vaultFactory": "0x18C659a269a7172eF78BBC19Fe47ad2237Be0590",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,56 @@ pragma solidity 0.8.25;
import {Script, console} from "forge-std/Script.sol";

import {BoltSymbioticMiddlewareV1} from "../../../src/contracts/BoltSymbioticMiddlewareV1.sol";
import {IOptInService} from "@symbiotic/interfaces/service/IOptInService.sol";

contract RegisterSymbioticOperator is Script {
struct Config {
string rpc;
BoltSymbioticMiddlewareV1 symbioticMiddleware;
IOptInService symbioticNetworkOptInService;
address symbioticNetwork;
}

function run() public {
uint256 operatorSk = vm.envUint("OPERATOR_SK");

address operator = vm.addr(operatorSk);

BoltSymbioticMiddlewareV1 middleware = _readMiddleware();
string memory rpc = _readRPC();
Config memory config = _readConfig();

// First, make sure the operator is opted into the network
if (!config.symbioticNetworkOptInService.isOptedIn(operator, config.symbioticNetwork)) {
console.log("Operator is not opted into the network yet. Opting in...");
vm.startBroadcast(operatorSk);
config.symbioticNetworkOptInService.optIn(config.symbioticNetwork);
vm.stopBroadcast();
console.log("Operator successfully opted into the network");
}

console.log("Registering Symbiotic operator");
console.log("Operator address:", operator);
console.log("Operator RPC:", rpc);
console.log("Operator RPC:", config.rpc);

vm.startBroadcast(operatorSk);
middleware.registerOperator(rpc);
config.symbioticMiddleware.registerOperator(config.rpc);
console.log("Successfully registered Symbiotic operator");

vm.stopBroadcast();
}

function _readMiddleware() public view returns (BoltSymbioticMiddlewareV1) {
function _readConfig() public view returns (Config memory) {
string memory root = vm.projectRoot();
string memory path = string.concat(root, "/config/holesky/deployments.json");
string memory json = vm.readFile(path);

return BoltSymbioticMiddlewareV1(vm.parseJsonAddress(json, ".symbiotic.middleware"));
}

function _readRPC() public view returns (string memory) {
string memory root = vm.projectRoot();
string memory path = string.concat(root, "/config/holesky/operator.json");
string memory json = vm.readFile(path);
string memory operatorPath = string.concat(root, "/config/holesky/operator.json");
string memory operatorJson = vm.readFile(operatorPath);

return vm.parseJsonString(json, ".rpc");
return Config({
rpc: vm.parseJsonString(operatorJson, ".rpc"),
symbioticNetwork: vm.parseJsonAddress(json, ".symbiotic.network"),
symbioticMiddleware: BoltSymbioticMiddlewareV1(vm.parseJsonAddress(json, ".symbiotic.middleware")),
symbioticNetworkOptInService: IOptInService(vm.parseJsonAddress(json, ".symbiotic.networkOptInService"))
});
}
}

0 comments on commit 10adbfb

Please sign in to comment.