-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ZIL-5471: Bridge Improvements (#276)
* [refactor] clean up tests * Add significant improvements
- Loading branch information
Showing
15 changed files
with
11,739 additions
and
769 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// SPDX-License-Identifier: MIT OR Apache-2.0 | ||
pragma solidity ^0.8.20; | ||
|
||
import "hardhat/console.sol"; | ||
|
||
import "@openzeppelin/contracts/proxy/utils/Initializable.sol"; | ||
import "./Relayer.sol"; | ||
|
||
abstract contract Bridged is Initializable { | ||
Relayer private _relayer; | ||
|
||
function initialize(Relayer relayer) public initializer { | ||
_relayer = relayer; | ||
} | ||
|
||
modifier onlyRelayer() { | ||
require(msg.sender == address(_relayer), "Must be called by relayer"); | ||
_; | ||
} | ||
|
||
function dispatched( | ||
address target, | ||
bytes memory call | ||
) public payable onlyRelayer returns (bool success, bytes memory response) { | ||
console.log("dispatched()"); | ||
(success, response) = target.call{value: msg.value, gas: 100000}(call); | ||
} | ||
|
||
function queried( | ||
address target, | ||
bytes memory call | ||
) public view onlyRelayer returns (bool success, bytes memory response) { | ||
console.log("queried()"); | ||
(success, response) = target.staticcall{gas: 100000}(call); | ||
} | ||
|
||
function relay( | ||
address target, | ||
bytes memory call, | ||
bool readonly, | ||
bytes4 callback | ||
) internal returns (uint nonce) { | ||
nonce = _relayer.relay(target, call, readonly, callback); | ||
} | ||
} |
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,21 @@ | ||
// SPDX-License-Identifier: MIT OR Apache-2.0 | ||
pragma solidity ^0.8.20; | ||
|
||
import "./ValidatorManager.sol"; | ||
|
||
contract Collector { | ||
ValidatorManager private validatorManager; | ||
event Echoed(bytes32 indexed hash, bytes signature); | ||
|
||
constructor(ValidatorManager _validatorManager) { | ||
validatorManager = _validatorManager; | ||
} | ||
|
||
function echo(bytes32 hash, bytes memory signature) public { | ||
require( | ||
validatorManager.validateSignature(hash, signature), | ||
"Wrong validator" | ||
); | ||
emit Echoed(hash, signature); | ||
} | ||
} |
Oops, something went wrong.