I need advice please!

I have a teen daughter, who my husband and I adopted when she was around 3 years old. It's an open adoption, so we allow her to keep in contact with her mother, who is a recovering drug addict. Anyway, when my daughter started getting in her teen years, she became rebellious and started sneaking out of the house and drinking and partying. I was unaware until she told me that she's pregnant and explained how it happened. I love my daughter. I wanted to provide a good life for her so that she wouldn't follow in her biological mother's footsteps, but I feel like I failed. My daughter wants to keep her child and I support her 100 percent. But I'm scared that I will fail my grandchild just like I failed my daughter. I really need some advice on how to move forward. Sorry if this is in the wrong group. I am just desperate and didn't know where to go or who to turn to.