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

ops: deploy sonic #29

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
85 changes: 85 additions & 0 deletions scripts/DeploySonic/1_DeploySonic.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
// SPDX-License-Identifier: ISC
pragma solidity ^0.8.19;

import "../DeployFraxOFTProtocol/DeployFraxOFTProtocol.s.sol";

/// Deploy to sonic without setting up DVNs, maintain configDeployerPK as owner/delegate
contract DeploySonic is DeployFraxOFTProtocol {
/// @dev skip setting DVNs
function setupSource() public override broadcastAs(configDeployerPK) {
/// @dev set enforced options / peers separately
setupEvms();
setupNonEvms();

/// @dev configures legacy configs as well
// setDVNs({
// _connectedConfig: broadcastConfig,
// _connectedOfts: proxyOfts,
// _configs: allConfigs
// });

setLibs({
_connectedConfig: broadcastConfig,
_connectedOfts: proxyOfts,
_configs: allConfigs
});

// setPriviledgedRoles();
}

/// @dev transfer admin ownership to configDeployerPK instead of proxyAdmin
function deployFraxOFTUpgradeableAndProxy(
string memory _name,
string memory _symbol
) public virtual returns (address implementation, address proxy) {
bytes memory bytecode = bytes.concat(
abi.encodePacked(type(FraxOFTUpgradeable).creationCode),
abi.encode(broadcastConfig.endpoint)
);
assembly {
implementation := create(0, add(bytecode, 0x20), mload(bytecode))
if iszero(extcodesize(implementation)) {
revert(0, 0)
}
}
/// @dev: create semi-pre-deterministic proxy address, then initialize with correct implementation
proxy = address(new TransparentUpgradeableProxy(implementationMock, vm.addr(oftDeployerPK), ""));

/// @dev: broadcastConfig deployer is temporary OFT owner until setPriviledgedRoles()
bytes memory initializeArgs = abi.encodeWithSelector(
FraxOFTUpgradeable.initialize.selector,
_name,
_symbol,
vm.addr(configDeployerPK)
);
TransparentUpgradeableProxy(payable(proxy)).upgradeToAndCall({
newImplementation: implementation,
data: initializeArgs
});
TransparentUpgradeableProxy(payable(proxy)).changeAdmin(/* proxyAdmin */ configDeployerPK);
// TODO: will need to look at these instead of expectedProxyOFTs if the deployed addrs are different than expected
proxyOfts.push(proxy);

// State checks
require(
isStringEqual(FraxOFTUpgradeable(proxy).name(), _name),
"OFT name incorrect"
);
require(
isStringEqual(FraxOFTUpgradeable(proxy).symbol(), _symbol),
"OFT symbol incorrect"
);
require(
address(FraxOFTUpgradeable(proxy).endpoint()) == broadcastConfig.endpoint,
"OFT endpoint incorrect"
);
require(
EndpointV2(broadcastConfig.endpoint).delegates(proxy) == vm.addr(configDeployerPK),
"Endpoint delegate incorrect"
);
require(
FraxOFTUpgradeable(proxy).owner() == vm.addr(configDeployerPK),
"OFT owner incorrect"
);
}
}
11 changes: 11 additions & 0 deletions scripts/L0Config.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,17 @@
"endpoint": "0x1a44076050125825900e736c501f859c50fE728c",
"receiveLib302": "0x2367325334447C5E1E0f1b3a6fB947b262F58312",
"sendLib302": "0xe1844c5D63a9543023008D332Bd3d2e6f1FE1043"
},
{
"RPC": "https://rpc.soniclabs.com/",
"chainid": 146,
"delegate": "0x0",
"dvnHorizen": "0x0000000000000000000000000000000000000000",
"dvnL0": "0x0000000000000000000000000000000000000000",
"eid": 30332,
"endpoint": "0x6F475642a6e85809B1c36Fa62763669b1b48DD5B",
"receiveLib302": "0xe1844c5D63a9543023008D332Bd3d2e6f1FE1043",
"sendLib302": "0xC39161c743D0307EB9BCc9FEF03eeb9Dc4802de7"
}
],
"Non-EVM": [
Expand Down