contract WabiStore is Pausable, Ownable {
  using Strings for uint256;
  using SignatureChecker for address;
  address payable private wabiWallet;
  mapping(uint256 => bool) public _nonceSpended;
  address private signer;
  IWabipunks public wabiPunks;
  constructor(
  ){
    signer = 0x0EBD57Cc598E8604e8808aE38CF3c8a3d4627149;
    wabiPunks = IWabipunks(0x427226f7336a9975ceca338ED9a75B5799f995Df);
  }

  /**
        @dev Mint new token and maps to receiver
    */
  function mint(uint256 amount, uint256 totalPrice, uint256 nonce, bytes memory signature)
    external
    payable
    whenNotPaused
  {
    require(!_nonceSpended[nonce], "WabiStore: Signature already used");
    require(signer.isValidSignatureNow(keccak256(abi.encodePacked(amount, msg.sender, totalPrice, nonce)), signature), "WabiStore: Invalid signature");
    _nonceSpended[nonce] = true;
    require(msg.value >= totalPrice, "WabiStore: msg.value is less than total price");
    wabiPunks.mint(amount, msg.sender);
  }



  /**
    @dev Withdraw ETH balance to the owner
     */
  function withdraw() external onlyOwner {
    payable(owner()).transfer(address(this).balance);
  }
  function updateSigner(address _newSigner) external onlyOwner {
    signer = _newSigner;
  }
  function pause() external onlyOwner {
    _pause();
  }

  function unPause() external onlyOwner {
    _unpause();
  }
}
function withdraw() external onlyOwner {
  payable(owner()).transfer(address(this).balance);
}

/**
 @dev Withdraw ETH balance to the owner
 */