mirror of
https://github.com/tornadocash/tornado-nova
synced 2024-02-02 14:53:56 +01:00
upgradability init
This commit is contained in:
parent
4d2244297b
commit
93bc29580b
37
contracts/CrossChainUpgradeableProxy.sol
Normal file
37
contracts/CrossChainUpgradeableProxy.sol
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
pragma solidity ^0.7.0;
|
||||||
|
|
||||||
|
import "@openzeppelin/contracts/contracts/proxy/TransparentUpgradeableProxy.sol";
|
||||||
|
|
||||||
|
// https://github.com/ethereum-optimism/optimism/blob/c7bc85deee999b8edfbe187b302d0ea262638ca9/packages/contracts/contracts/optimistic-ethereum/iOVM/bridge/messaging/iOVM_CrossDomainMessenger.sol
|
||||||
|
interface iOVM_CrossDomainMessenger {
|
||||||
|
function xDomainMessageSender() external view returns (address);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev TransparentUpgradeableProxy where admin acts from a different chain.
|
||||||
|
*/
|
||||||
|
contract CrossChainUpgradeableProxy is TransparentUpgradeableProxy {
|
||||||
|
// https://github.com/ethereum-optimism/optimism/blob/develop/packages/contracts/deployments/README.md
|
||||||
|
iOVM_CrossDomainMessenger public constant messenger = iOVM_CrossDomainMessenger(0x4200000000000000000000000000000000000007);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev Initializes an upgradeable proxy backed by the implementation at `_logic`.
|
||||||
|
*/
|
||||||
|
constructor(
|
||||||
|
address _logic,
|
||||||
|
address _admin,
|
||||||
|
bytes memory _data
|
||||||
|
) TransparentUpgradeableProxy(_logic, _admin, _data) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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(messenger) && messenger.xDomainMessageSender() == _admin()) {
|
||||||
|
_;
|
||||||
|
} else {
|
||||||
|
_fallback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -24,7 +24,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@nomiclabs/hardhat-ethers": "^2.0.2",
|
"@nomiclabs/hardhat-ethers": "^2.0.2",
|
||||||
"@nomiclabs/hardhat-waffle": "^2.0.1",
|
"@nomiclabs/hardhat-waffle": "^2.0.1",
|
||||||
"@openzeppelin/contracts": "^3.4.0",
|
"@openzeppelin/contracts": "git+https://github.com/tornadocash/openzeppelin-contracts.git#6e46aa6946a7f215e7604169ddf46e1aebea850f",
|
||||||
"bignumber.js": "^9.0.0",
|
"bignumber.js": "^9.0.0",
|
||||||
"chai": "^4.3.4",
|
"chai": "^4.3.4",
|
||||||
"circom": "^0.5.45",
|
"circom": "^0.5.45",
|
||||||
|
@ -683,10 +683,9 @@
|
|||||||
"@types/sinon-chai" "^3.2.3"
|
"@types/sinon-chai" "^3.2.3"
|
||||||
"@types/web3" "1.0.19"
|
"@types/web3" "1.0.19"
|
||||||
|
|
||||||
"@openzeppelin/contracts@^3.4.0":
|
"@openzeppelin/contracts@git+https://github.com/tornadocash/openzeppelin-contracts.git#6e46aa6946a7f215e7604169ddf46e1aebea850f":
|
||||||
version "3.4.1"
|
version "3.4.1-solc-0.7-2"
|
||||||
resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-3.4.1.tgz#03c891fec7f93be0ae44ed74e57a122a38732ce7"
|
resolved "git+https://github.com/tornadocash/openzeppelin-contracts.git#6e46aa6946a7f215e7604169ddf46e1aebea850f"
|
||||||
integrity sha512-cUriqMauq1ylzP2TxePNdPqkwI7Le3Annh4K9rrpvKfSBB/bdW+Iu1ihBaTIABTAAJ85LmKL5SSPPL9ry8d1gQ==
|
|
||||||
|
|
||||||
"@resolver-engine/core@^0.3.3":
|
"@resolver-engine/core@^0.3.3":
|
||||||
version "0.3.3"
|
version "0.3.3"
|
||||||
|
Loading…
Reference in New Issue
Block a user