Skip to content

Commit

Permalink
little opt
Browse files Browse the repository at this point in the history
  • Loading branch information
hujw77 committed Nov 2, 2023
1 parent c4c607b commit 59d0719
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
20 changes: 10 additions & 10 deletions src/eco/Oracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ contract Oracle is Verifier {
event SetApproved(address operator, bool approve);

address public immutable PROTOCOL;
address public owner;

address public owner;
// chainId => price
mapping(uint256 => uint256) public feeOf;
// chainId => dapi
Expand All @@ -52,22 +52,22 @@ contract Oracle is Verifier {

receive() external payable {}

function changeOwner(address owner_) external onlyOwner {
owner = owner_;
function withdraw(address to, uint256 amount) external onlyApproved {
(bool success,) = to.call{value: amount}("");
require(success, "!withdraw");
}

function isApproved(address operator) public view returns (bool) {
return approvedOf[operator];
}

function setApproved(address operator, bool approve) public onlyOwner {
approvedOf[operator] = approve;
emit SetApproved(operator, approve);
function changeOwner(address owner_) external onlyOwner {
owner = owner_;
}

function withdraw(address to, uint256 amount) external onlyApproved {
(bool success,) = to.call{value: amount}("");
require(success, "!withdraw");
function setApproved(address operator, bool approve) external onlyOwner {
approvedOf[operator] = approve;
emit SetApproved(operator, approve);
}

function setFee(uint256 chainId, uint256 fee_) external onlyApproved {
Expand All @@ -85,7 +85,7 @@ contract Oracle is Verifier {
}

function assign(bytes32 msgHash) external payable {
require(msg.sender == PROTOCOL, "!enpoint");
require(msg.sender == PROTOCOL, "!auth");
emit Assigned(msgHash, msg.value);
}

Expand Down
16 changes: 8 additions & 8 deletions src/eco/Relayer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ contract Relayer {
}

address public immutable PROTOCOL;
address public owner;

address public owner;
// chainId => price
mapping(uint256 => DstPrice) public priceOf;
mapping(uint256 => DstConfig) public configOf;
Expand All @@ -60,14 +60,19 @@ contract Relayer {

receive() external payable {}

function changeOwner(address owner_) external onlyOwner {
owner = owner_;
function withdraw(address to, uint256 amount) external onlyApproved {
(bool success,) = to.call{value: amount}("");
require(success, "!withdraw");
}

function isApproved(address operator) public view returns (bool) {
return approvedOf[operator];
}

function changeOwner(address owner_) external onlyOwner {
owner = owner_;
}

function setApproved(address operator, bool approve) public onlyOwner {
approvedOf[operator] = approve;
emit SetApproved(operator, approve);
Expand All @@ -83,11 +88,6 @@ contract Relayer {
emit SetDstConfig(chainId, baseGas, gasPerByte);
}

function withdraw(address to, uint256 amount) external onlyApproved {
(bool success,) = to.call{value: amount}("");
require(success, "!withdraw");
}

// extraGas = gasLimit
function fee(
uint256 toChainId,
Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/IRelayer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interface IRelayer {
/// @notice Fetch relayer price to relay message to the destination chain.
/// @param toChainId The destination chain id.
/// @param ua The user application which send the message.
/// @param gasLimit Gas limit for UA used.
/// @param gasLimit Gas limit for destination user application used.
/// @param encoded The calldata which encoded by ABI Encoding.
/// @param params General extensibility for relayer to custom functionality.
/// @return Relayer price in source native gas.
Expand Down

0 comments on commit 59d0719

Please sign in to comment.