Preheat the oven to 170°C.
Season lamb shanks with salt and pepper.
Brown shanks in hot oil within a casserole dish and set aside.
Sauté onions and garlic then stir in flour to make a paste.
Gradually add wine and stock while stirring to combine.
Add potatoes, carrots, celery, and herbs and bring to a simmer.
Stir in beans, return lamb to dish, cover, and bake for 2 hours.
Remove from oven once meat is tender and transfer to a pie dish.
Stand shanks upright and allow the mixture to cool completely.
Increase oven temperature to 180°C.
Brush the rim of the dish with beaten egg.
Roll pastry to 0.5cm thickness and drape over the shanks.
Slit pastry to allow bones to poke through and crimp edges to seal.
Glaze with remaining egg, sprinkle with salt, and bake for 45-60 minutes.
Boil peas for 3 minutes and serve with the hot pie.