I'm kind of with you on this one. 12yo is old enough to understand the rules (assuming they were clearly set) and if he/she was willingly communicating with a stranger, that phone should get the hammer with no replacement whatsoever. I've seen this done, it works.
I am not even sure where you get "smashing a device violently in front of a child" comes from. He said gets the hammer as in he would perma destroy it.
Anyway I tend to agree for the most part anyway. I was just making a guess about your age irl based on what you said. However some other data actually indicates you are likely gen-x.
What I believe the author did was instead of teaching their child that they may not talk to strangers, they believed there just is a magic button to have these strangers not exist.
You can't control or decide what predators will do. And very likely won't be able to imagine the extent of every single of their convoluted predatory practices by yourself.
So instead of trying to cover every possible theoretical danger, setting clear rules and boundaries with your kid sounds like a way more sensible and pragmatic approach.
And nobody said kids should be punished or held fully accountable on their first mistake.