-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(contracts): symbiotic setup scripts
- Loading branch information
Jonas Bostoen
committed
Oct 17, 2024
1 parent
9b112a7
commit f55fbd6
Showing
4 changed files
with
98 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
bolt-contracts/script/holesky/helpers/SymbioticSetup.s.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.25; | ||
|
||
import {Script, console} from "forge-std/Script.sol"; | ||
|
||
import {BoltConfig} from "../../../src/lib/Config.sol"; | ||
|
||
import {INetworkRegistry} from "@symbiotic/interfaces/INetworkRegistry.sol"; | ||
import {INetworkMiddlewareService} from "@symbiotic/interfaces/service/INetworkMiddlewareService.sol"; | ||
|
||
/// forge script script/holesky/SymbioticSetup.s.sol --rpc-url $RPC_HOLESKY --private-key $NETWORK_PRIVATE_KEY --broadcast -vvvv --sig "run(string memory arg)" registerNetwork | ||
/// forge script script/holesky/SymbioticSetup.s.sol --rpc-url $RPC_HOLESKY --private-key $NETWORK_PRIVATE_KEY --broadcast -vvvv --sig "run(string memory arg)" registerMiddleware | ||
contract SymbioticSetup is Script { | ||
function run( | ||
string memory arg | ||
) public { | ||
address networkAdmin = msg.sender; | ||
console.log("Deploying with network admin", networkAdmin); | ||
|
||
vm.startBroadcast(); | ||
|
||
if (keccak256(abi.encode(arg)) == keccak256(abi.encode("registerNetwork"))) { | ||
INetworkRegistry networkRegistry = INetworkRegistry(readNetworkRegistry()); | ||
|
||
networkRegistry.registerNetwork(); | ||
} else if (keccak256(abi.encode(arg)) == keccak256(abi.encode("registerMiddleware"))) { | ||
INetworkMiddlewareService middlewareService = INetworkMiddlewareService(readMiddlewareService()); | ||
|
||
address middleware = readMiddleware(); | ||
|
||
middlewareService.setMiddleware(middleware); | ||
} | ||
|
||
vm.stopBroadcast(); | ||
} | ||
|
||
function readNetworkRegistry() public view returns (address) { | ||
string memory root = vm.projectRoot(); | ||
string memory path = string.concat(root, "/config/holesky/network-registry.json"); | ||
string memory json = vm.readFile(path); | ||
|
||
return vm.parseJsonAddress(json, ".networkRegistry"); | ||
} | ||
|
||
function readMiddlewareService() public view returns (address) { | ||
string memory root = vm.projectRoot(); | ||
string memory path = string.concat(root, "/config/holesky/middleware-service.json"); | ||
string memory json = vm.readFile(path); | ||
|
||
return vm.parseJsonAddress(json, ".networkMiddlewareService"); | ||
} | ||
|
||
function readMiddleware() public view returns (address) { | ||
string memory root = vm.projectRoot(); | ||
string memory path = string.concat(root, "/config/holesky/middleware.json"); | ||
string memory json = vm.readFile(path); | ||
|
||
return vm.parseJsonAddress(json, ".networkMiddleware"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters