all files / contracts/test/examples/ SimpleGetterSetterUpgradeable.sol

86.36% Statements 19/22
100% Branches 0/0
68.75% Functions 11/16
86.36% Lines 19/22
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124                                  36× 36×   36×             36× 36×                                                                 12×             12×                                                                                      
// 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;
    }
}