Skip to content

Commit

Permalink
fix(contracts/scripts): register Symbiotic operator script
Browse files Browse the repository at this point in the history
  • Loading branch information
mempirate authored and thedevbirb committed Oct 24, 2024
1 parent b551faa commit 78f22a6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {IVault} from "@symbiotic/interfaces/vault/IVault.sol";

contract RegisterSymbioticOperator is Script {
struct Config {
string rpc;
BoltSymbioticMiddlewareV1 symbioticMiddleware;
IOptInService symbioticNetworkOptInService;
address symbioticNetwork;
Expand All @@ -25,29 +24,39 @@ contract RegisterSymbioticOperator is Script {

Config memory config = _readConfig();

console.log("Registering Symbiotic operator into Bolt");
console.log("Operator address:", operator);

// First, make sure the operator is opted into the network
require(
config.symbioticNetworkOptInService.isOptedIn(operator, config.symbioticNetwork),
"Operator must be opted in into Bolt Network"
);

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

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

vm.stopBroadcast();

(address[] memory tokens, uint256[] memory amounts) =
config.symbioticMiddleware.getOperatorCollaterals(operator);

console.log("Operator collateral:");
for (uint256 i; i < tokens.length; ++i) {
console.log("Collateral:", tokens[i], "Amount:", amounts[i]);
}
}

function S02_checkOperatorRegistration() public view {
address operatorPublicKey = vm.envAddress("OPERATOR_PK");
console.log("Checking operator registration for address", operatorPublicKey);
address operatorAddress = vm.envAddress("OPERATOR_ADDRESS");
console.log("Checking operator registration for address", operatorAddress);

IBoltManagerV1 boltManager = _readBoltManager();
bool isRegistered = boltManager.isOperator(operatorPublicKey);
bool isRegistered = boltManager.isOperator(operatorAddress);

console.log("Operator is registered:", isRegistered);
require(isRegistered, "Operator is not registered");
}
Expand All @@ -57,11 +66,7 @@ contract RegisterSymbioticOperator is Script {
string memory path = string.concat(root, "/config/holesky/deployments.json");
string memory json = vm.readFile(path);

string memory operatorPath = string.concat(root, "/config/holesky/operator.json");
string memory operatorJson = vm.readFile(operatorPath);

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"))
Expand Down
4 changes: 2 additions & 2 deletions testnets/holesky/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -538,8 +538,8 @@ procedure. If you want to use it, please follow these steps:
--broadcast
```

To check if your operator is correctly registered, set the operator public key
in the `OPERATOR_PK` environment variable and run the following script:
To check if your operator is correctly registered, set the operator address
in the `OPERATOR_ADDRESS` environment variable and run the following script:

```bash
forge script script/holesky/operators/RegisterSymbioticOperator.s.sol \
Expand Down

0 comments on commit 78f22a6

Please sign in to comment.