mirror of
https://github.com/tornadocash/tornado-nova
synced 2024-02-02 14:53:56 +01:00
43 lines
1.1 KiB
Solidity
43 lines
1.1 KiB
Solidity
// SPDX-License-Identifier: MIT
|
|
pragma solidity ^0.7.0;
|
|
|
|
import { IAMB } from "./interfaces/Bridge.sol";
|
|
import "@openzeppelin/contracts/contracts/proxy/TransparentUpgradeableProxy.sol";
|
|
|
|
/**
|
|
* @dev TransparentUpgradeableProxy where admin acts from a different chain.
|
|
*/
|
|
contract CrossChainUpgradeableProxy is TransparentUpgradeableProxy {
|
|
IAMB public immutable ambBridge;
|
|
bytes32 public immutable adminChainId;
|
|
|
|
/**
|
|
* @dev Initializes an upgradeable proxy backed by the implementation at `_logic`.
|
|
*/
|
|
constructor(
|
|
address _logic,
|
|
address _admin,
|
|
bytes memory _data,
|
|
IAMB _ambBridge,
|
|
uint256 _adminChainId
|
|
) TransparentUpgradeableProxy(_logic, _admin, _data) {
|
|
ambBridge = _ambBridge;
|
|
adminChainId = bytes32(uint256(_adminChainId));
|
|
}
|
|
|
|
/**
|
|
* @dev Modifier used internally that will delegate the call to the implementation unless the sender is the cross chain admin.
|
|
*/
|
|
modifier ifAdmin() override {
|
|
if (
|
|
msg.sender == address(ambBridge) &&
|
|
ambBridge.messageSourceChainId() == adminChainId &&
|
|
ambBridge.messageSender() == _admin()
|
|
) {
|
|
_;
|
|
} else {
|
|
_fallback();
|
|
}
|
|
}
|
|
}
|