-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
134 additions
and
32 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// SPDX-License-Identifier: MIT OR Apache-2.0 | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; | ||
import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; | ||
import {ReentrancyGuardUpgradeable} from "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; | ||
import {IArbitrator} from "../interfaces/IArbitrator.sol"; | ||
import {IL1Gateway} from "../interfaces/IL1Gateway.sol"; | ||
|
||
contract DummyArbitrator is IArbitrator, OwnableUpgradeable, UUPSUpgradeable, ReentrancyGuardUpgradeable { | ||
event ReceiveMessage(uint256 value, bytes callData); | ||
|
||
function initialize() external initializer { | ||
__Ownable_init(); | ||
__UUPSUpgradeable_init(); | ||
__ReentrancyGuard_init(); | ||
} | ||
|
||
function _authorizeUpgrade(address newImplementation) internal override onlyOwner {} | ||
|
||
function receiveMessage(uint256 _value, bytes memory _callData) external payable { | ||
require(msg.value == _value, "Invalid msg value"); | ||
emit ReceiveMessage(_value, _callData); | ||
} | ||
|
||
function forwardMessage(IL1Gateway _gateway, uint256 _value, bytes memory _callData, bytes memory _adapterParams) external payable { | ||
// Forward fee to send message | ||
_gateway.sendMessage{value: msg.value + _value}(_value, _callData, _adapterParams); | ||
} | ||
} |
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,47 @@ | ||
// SPDX-License-Identifier: MIT OR Apache-2.0 | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; | ||
import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; | ||
import {ReentrancyGuardUpgradeable} from "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; | ||
import {IL2Gateway} from "../interfaces/IL2Gateway.sol"; | ||
import {IZkLink} from "../interfaces/IZkLink.sol"; | ||
|
||
contract DummyZkLink is IZkLink, OwnableUpgradeable, UUPSUpgradeable, ReentrancyGuardUpgradeable { | ||
IL2Gateway public gateway; | ||
|
||
event ReceiveBatchRoot(uint256 batchNumber, bytes32 l2LogsRootHash); | ||
event ReceiveL2TxHash(bytes32 l2TxHash, bytes32 primaryChainL2TxHash); | ||
|
||
modifier onlyGateway() { | ||
require(msg.sender == address(gateway), "Not gateway"); | ||
_; | ||
} | ||
|
||
function initialize() external initializer { | ||
__Ownable_init(); | ||
__UUPSUpgradeable_init(); | ||
__ReentrancyGuard_init(); | ||
} | ||
|
||
function _authorizeUpgrade(address newImplementation) internal override onlyOwner {} | ||
|
||
function setGateway(IL2Gateway _gateway) external { | ||
require(address(gateway) == address(0), "Duplicate init gateway"); | ||
gateway = _gateway; | ||
} | ||
|
||
function syncL2Requests(uint256 _newTotalSyncedPriorityTxs) external payable { | ||
bytes memory callData = abi.encode(msg.value, _newTotalSyncedPriorityTxs); | ||
gateway.sendMessage(msg.value, callData); | ||
} | ||
|
||
function syncBatchRoot(uint256 _batchNumber, bytes32 _l2LogsRootHash) external onlyGateway { | ||
emit ReceiveBatchRoot(_batchNumber, _l2LogsRootHash); | ||
} | ||
|
||
function syncL2TxHash(bytes32 _l2TxHash, bytes32 _primaryChainL2TxHash) external onlyGateway { | ||
emit ReceiveL2TxHash(_l2TxHash, _primaryChainL2TxHash); | ||
} | ||
} |
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
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