Skip to content

Commit b49f3e7

Browse files
authored
ZIL-5471: Bridge Improvements (#276)
* [refactor] clean up tests * Add significant improvements
1 parent d49339b commit b49f3e7

15 files changed

+11739
-769
lines changed

pnpm-lock.yaml

+2,511-262
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,3 @@ packages:
1111
- "zilliqa/js/zilliqa"
1212
- "examples/zilliqa-js/latest-block"
1313
- "examples/zilliqa-js/react-zilliqa-js"
14-
- "zilliqa/products/bridge"

products/bridge/contracts/Bridge.sol

-216
This file was deleted.

products/bridge/contracts/Bridged.sol

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// SPDX-License-Identifier: MIT OR Apache-2.0
2+
pragma solidity ^0.8.20;
3+
4+
import "hardhat/console.sol";
5+
6+
import "@openzeppelin/contracts/proxy/utils/Initializable.sol";
7+
import "./Relayer.sol";
8+
9+
abstract contract Bridged is Initializable {
10+
Relayer private _relayer;
11+
12+
function initialize(Relayer relayer) public initializer {
13+
_relayer = relayer;
14+
}
15+
16+
modifier onlyRelayer() {
17+
require(msg.sender == address(_relayer), "Must be called by relayer");
18+
_;
19+
}
20+
21+
function dispatched(
22+
address target,
23+
bytes memory call
24+
) public payable onlyRelayer returns (bool success, bytes memory response) {
25+
console.log("dispatched()");
26+
(success, response) = target.call{value: msg.value, gas: 100000}(call);
27+
}
28+
29+
function queried(
30+
address target,
31+
bytes memory call
32+
) public view onlyRelayer returns (bool success, bytes memory response) {
33+
console.log("queried()");
34+
(success, response) = target.staticcall{gas: 100000}(call);
35+
}
36+
37+
function relay(
38+
address target,
39+
bytes memory call,
40+
bool readonly,
41+
bytes4 callback
42+
) internal returns (uint nonce) {
43+
nonce = _relayer.relay(target, call, readonly, callback);
44+
}
45+
}
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// SPDX-License-Identifier: MIT OR Apache-2.0
2+
pragma solidity ^0.8.20;
3+
4+
import "./ValidatorManager.sol";
5+
6+
contract Collector {
7+
ValidatorManager private validatorManager;
8+
event Echoed(bytes32 indexed hash, bytes signature);
9+
10+
constructor(ValidatorManager _validatorManager) {
11+
validatorManager = _validatorManager;
12+
}
13+
14+
function echo(bytes32 hash, bytes memory signature) public {
15+
require(
16+
validatorManager.validateSignature(hash, signature),
17+
"Wrong validator"
18+
);
19+
emit Echoed(hash, signature);
20+
}
21+
}

0 commit comments

Comments
 (0)