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

83.33% Statements 15/18
100% Branches 0/0
76.92% Functions 10/13
83.33% Lines 15/18
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                        36×                                           12×             12×                                                                                      
// 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;
    }
}