Skip to content

Commit

Permalink
ZIL-5471: Bridge Improvements (#276)
Browse files Browse the repository at this point in the history
* [refactor] clean up tests

* Add significant improvements
  • Loading branch information
WuBruno authored Nov 14, 2023
1 parent d49339b commit b49f3e7
Show file tree
Hide file tree
Showing 15 changed files with 11,739 additions and 769 deletions.
2,773 changes: 2,511 additions & 262 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ packages:
- "zilliqa/js/zilliqa"
- "examples/zilliqa-js/latest-block"
- "examples/zilliqa-js/react-zilliqa-js"
- "zilliqa/products/bridge"
216 changes: 0 additions & 216 deletions products/bridge/contracts/Bridge.sol

This file was deleted.

45 changes: 45 additions & 0 deletions products/bridge/contracts/Bridged.sol
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);
}
}
21 changes: 21 additions & 0 deletions products/bridge/contracts/Collector.sol
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);
}
}
Loading

0 comments on commit b49f3e7

Please sign in to comment.