// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../../RouterCrossTalkUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
contract SimpleGetterSetterUpgradeable is
RouterCrossTalkUpgradeable,
AccessControlUpgradeable,
UUPSUpgradeable
{
uint256 private value;
uint256 private _crossChainGasLimit;
uint256 private _crossChainGasPrice;
function initialize(address _handler) external initializer {
__AccessControl_init();
__SimpleGetterSetterUpgradeable_init(_handler);
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
}
function __SimpleGetterSetterUpgradeable_init(address _handler)
internal
initializer
{
__Context_init_unchained();
__RouterCrossTalkUpgradeable_init(_handler);
}
function __SimpleGetterSetterUpgradeable_init_unchained()
internal
initializer
{}
function _authorizeUpgrade(address newImplementation)
internal
virtual
override
{}
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;
}
}
|