-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #864 from movementlabsxyz/primata/simple-native-br…
…idge Trusted Native Bridge
- Loading branch information
Showing
41 changed files
with
771 additions
and
1,929 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
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
272 changes: 0 additions & 272 deletions
272
...contracts/broadcast/DeployAtomicBridgeCounterpartyMOVE.s.sol/11155111/run-1729790944.json
This file was deleted.
Oops, something went wrong.
272 changes: 0 additions & 272 deletions
272
...dge/contracts/broadcast/DeployAtomicBridgeCounterpartyMOVE.s.sol/11155111/run-latest.json
This file was deleted.
Oops, something went wrong.
272 changes: 0 additions & 272 deletions
272
...ge/contracts/broadcast/DeployAtomicBridgeInitiatorMOVE.s.sol/11155111/run-1729790850.json
This file was deleted.
Oops, something went wrong.
272 changes: 0 additions & 272 deletions
272
...bridge/contracts/broadcast/DeployAtomicBridgeInitiatorMOVE.s.sol/11155111/run-latest.json
This file was deleted.
Oops, something went wrong.
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
Submodule openzeppelin-contracts
updated
195 files
2 changes: 1 addition & 1 deletion
2
protocol-units/bridge/contracts/lib/openzeppelin-contracts-upgradeable
Submodule openzeppelin-contracts-upgradeable
updated
125 files
101 changes: 101 additions & 0 deletions
101
protocol-units/bridge/contracts/script/NativeBridgeDeployer.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,101 @@ | ||
// To Deploy | ||
// forge script NativeBridgeDeployer --fork-url https://holesky.infura.io/v3/YOUR_INFURA_PROJECT_ID --broadcast --verify --etherscan-api-key YOUR_ETHERSCAN_API_KEY | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.22; | ||
|
||
import "forge-std/Script.sol"; | ||
import {NativeBridge} from "../src/NativeBridge.sol"; | ||
import {TransparentUpgradeableProxy} from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; | ||
import {TimelockController} from "@openzeppelin/contracts/governance/TimelockController.sol"; | ||
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; | ||
import {Vm} from "forge-std/Vm.sol"; | ||
|
||
contract NativeBridgeDeployer is Script { | ||
TransparentUpgradeableProxy public nativeBridgeProxy; | ||
TimelockController public timelock; | ||
string public nativeBridgeSignature = "initialize(address,address,address,address,uint256)"; | ||
address public proxyAdmin; | ||
|
||
// TODO: all params are hardcoded for testnet deployment for now | ||
// Parameters | ||
address public moveTokenAddress = 0xC36ba8B8fD9EcbF36288b9B9B0ae9FC3E0645227; | ||
address public ownerAddress = 0x5b97cdf756f6363A88706c376464180E008Bd88b; // Replace with your .env PRIVATE_KEY address for testing | ||
|
||
// Safe addresses (replace these with actual safe addresses) | ||
address public movementLabsSafe = 0x493516F6dB02c9b7f649E650c5de244646022Aa0; | ||
address public movementFoundationSafe = 0x00db70A9e12537495C359581b7b3Bc3a69379A00; | ||
|
||
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; | ||
bytes32 public constant RELAYER_ROLE = keccak256("RELAYER_ROLE"); | ||
|
||
uint256 public minDelay = 2 days; | ||
|
||
function run() external { | ||
uint256 signer = vm.envUint("PRIVATE_KEY"); | ||
vm.startBroadcast(signer); | ||
|
||
address[] memory proposers = new address[](1); | ||
address[] memory executors = new address[](1); | ||
|
||
proposers[0] = movementLabsSafe; | ||
executors[0] = movementFoundationSafe; | ||
|
||
// Deploy TimelockController | ||
timelock = new TimelockController(minDelay, proposers, executors, address(0)); | ||
console.log("Timelock deployed at:", address(timelock)); | ||
|
||
// Deploy NativeBridge contract | ||
_deployNativeBridge(); | ||
|
||
vm.stopBroadcast(); | ||
} | ||
|
||
function _deployNativeBridge() internal { | ||
console.log("NativeBridge: deploying"); | ||
|
||
// Instantiate the implementation contract | ||
NativeBridge nativeBridgeImplementation = new NativeBridge(); | ||
|
||
vm.recordLogs(); | ||
// Deploy the TransparentUpgradeableProxy | ||
nativeBridgeProxy = new TransparentUpgradeableProxy( | ||
address(nativeBridgeImplementation), | ||
address(timelock), // Admin is the timelock | ||
abi.encodeWithSignature( | ||
nativeBridgeSignature, | ||
moveTokenAddress, // MOVE token address | ||
ownerAddress, // Owner of the contract | ||
ownerAddress, // Owner of the contract | ||
ownerAddress // Owner of the contract | ||
) | ||
); | ||
|
||
Vm.Log[] memory logs = vm.getRecordedLogs(); | ||
proxyAdmin = logs[logs.length - 2].emitter; | ||
console.log("proxy admin:", proxyAdmin); | ||
|
||
console.log("nativeBridgeProxy deployed at proxy address:", address(nativeBridgeProxy)); | ||
console.log("Implementation address:", address(nativeBridgeImplementation)); | ||
} | ||
|
||
function _upgradeAtomicBridge() internal { | ||
console.log("NativeBridge: upgrading"); | ||
NativeBridge newBridgeImplementation = new NativeBridge(); | ||
require(proxyAdmin != address(0), "Proxy admin not set"); | ||
timelock.schedule( | ||
proxyAdmin, | ||
0, | ||
abi.encodeWithSignature( | ||
"upgradeAndCall(address,address,bytes)", | ||
address(nativeBridgeProxy), | ||
address(newBridgeImplementation), | ||
abi.encodeWithSignature( | ||
nativeBridgeSignature, moveTokenAddress, ownerAddress, ownerAddress, ownerAddress | ||
) | ||
), | ||
bytes32(0), | ||
bytes32(0), | ||
block.timestamp + minDelay | ||
); | ||
} | ||
} |
93 changes: 0 additions & 93 deletions
93
protocol-units/bridge/contracts/src/AtomicBridgeCounterpartyMOVE.sol
This file was deleted.
Oops, something went wrong.
128 changes: 0 additions & 128 deletions
128
protocol-units/bridge/contracts/src/AtomicBridgeInitiatorMOVE.sol
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.