// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../../RouterCrossTalk.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
contract SimpleGetterSetter is RouterCrossTalk, AccessControl {
uint256 private value;
uint256 private _crossChainGasLimit;
uint256 private _crossChainGasPrice;
constructor(address _handler) RouterCrossTalk(_handler) AccessControl() {
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
}
function setLinker(address _linker) external onlyRole(DEFAULT_ADMIN_ROLE) {
setLink(_linker);
}
function setFeetokenAddress(address _feetoken)
external
onlyRole(DEFAULT_ADMIN_ROLE)
{
setFeeToken(_feetoken);
}
function approveFee(address _feetoken, uint256 _value)
external
onlyRole(DEFAULT_ADMIN_ROLE)
{
approveFees(_feetoken, _value);
}
function setCrossChainGasLimit(uint256 _gasLimit)
external
onlyRole(DEFAULT_ADMIN_ROLE)
{
_crossChainGasLimit = _gasLimit;
}
function setCrossChainGasPrice(uint256 _gasPrice)
external
onlyRole(DEFAULT_ADMIN_ROLE)
{
_crossChainGasPrice = _gasPrice;
}
function fetchCrossChainGasLimit() external view returns (uint256) {
return _crossChainGasLimit;
}
function fetchCrossChainGasPrice() external view returns (uint256) {
return _crossChainGasPrice;
}
function ExternalSend(uint8 _chainID, uint256 _value)
external
returns (bool, bytes32)
{
bytes memory data = abi.encode(_value);
bytes4 _interface = bytes4(keccak256("InternalSet(uint256)"));
(bool success, bytes32 hash) = routerSend(
_chainID,
_interface,
data,
_crossChainGasLimit,
_crossChainGasPrice
);
return (success, hash);
}
function _routerSyncHandler(bytes4 _interface, bytes memory _data)
internal
virtual
override
returns (bool, bytes memory)
{
uint256 _v = abi.decode(_data, (uint256));
(bool success, bytes memory returnData) = address(this).call(
abi.encodeWithSelector(_interface, _v)
);
return (success, returnData);
}
function fetchI() external pure returns (bytes4) {
return bytes4(keccak256("InternalSet(uint256)"));
}
function InternalSet(uint256 _value) external isSelf {
value = _value;
}
function fetchValue() external view returns (uint256) {
return value;
}
}
|