You bought the car from a dealer, correct? If so, then, unless they disclosed the prior history and informed you that it would void the warranty, they will likely be responsible for repairing, replacing, or refunding the item. If you purchased it from a dealer, you should consult Citizens Advice or Trading Standards regarding your rights under the Consumer Rights Act of 2015.