contract GCBank is Ownable, Pausable, GCBankMeta {

    address GcrAddress;

    event MoneySent(address indexed _beneficiary, uint _amount);
    event MoneyReceived(address indexed _from, uint _amount);

    constructor(address _tokenAddress, uint256 _chainId) GCBankMeta(_chainId) {
        GcrAddress = _tokenAddress;
        // addPauser(msg.sender);
    }

    function pauseContract() onlyOwner external {
        _pause();
    }

    function unpauseContract() onlyOwner external {
        _unpause();
    }

    function withdrawFunds(uint256 _amount) onlyOwner external {
        IERC20 GCR = IERC20(GcrAddress);
        GCR.transfer(owner(), _amount);
    }

    function withdrawPoints (
        uint256 _amount, address _receiverAddress, bytes32 r, bytes32 s, uint8 v
    ) whenNotPaused external {

        IERC20 GCR = IERC20(GcrAddress);
        address contractOwner = owner();
        uint256 previousNonce = nonces[contractOwner];

        require(GCR.balanceOf(address(this)) >= _amount, "Contract doesn't have enough GCR");

        bytes32 digest = keccak256(
            abi.encodePacked(
                "\x19\x01",
                DOMAIN_SEPARATOR,
                keccak256(abi.encode(META_TRANSACTION_TYPEHASH, previousNonce, contractOwner, _receiverAddress, _amount))
            )
        );

        require(contractOwner == ecrecover(digest, v, r, s), "GCBank:invalid-signature");

        nonces[contractOwner] = previousNonce + 1;

        GCR.transfer(_receiverAddress, _amount);

        emit MoneySent(_receiverAddress, _amount);
    }

    // receive() external payable {
    //     emit MoneyReceived(msg.sender, msg.value);
    // }

    function renounceOwnership () public pure override {
        revert("Can't renounceOwnership here"); //not possible with this smart contract
    }

}
function renounceOwnership () public pure override {
    revert("Can't renounceOwnership here"); //not possible with this smart contract
}

// receive() external payable {
//     emit MoneyReceived(msg.sender, msg.value);
// }