Preheat the oven to 170C/150C Fan/Gas 3½.
Season the lamb shanks all over with salt and freshly ground black pepper.
Heat the oil in a large, flameproof casserole over a high heat. Add the lamb shanks and fry for a few seconds on all sides, or until browned all over. Remove from the casserole and set aside.
Reduce the heat to medium, add the onions and fry for 2-3 minutes, or until softened. Add the garlic and fry for a further 1-2 minutes. Stir in the flour so it forms a paste with the pan juices. Continue cooking for a minute, then slowly pour in the wine and stock, stirring well to combine it with the flour paste.
Add the potatoes, carrots, celery, bay leaves, rosemary and thyme and bring the mixture to the boil. Reduce the heat until the mixture is simmering.
Stir in the drained beans, then return the lamb shanks to the casserole and bring the mixture back to simmering point. Cover the casserole with the lid and transfer to the oven for 2 hours. Alternatively, simmer over a low heat on the hob.
When the meat on the lamb shanks comes away easily from the bone but is not falling off it, remove the casserole from the oven (or hob).
Transfer the casserole contents to a large pie dish, standing the lamb shanks upright. Set aside to cool completely. (The lamb must be completely cooled before you top it with the pastry.)
Preheat the oven to 180C/160C Fan/Gas 4.
Brush the inside and outside of the rim of the pie dish with some of the beaten egg and egg yolk.
Roll the pastry out onto a lightly floured work surface until it is 5cm/2in bigger than the diameter of the pie dish and about 0.5cm/¼in thick.
Carefully lay the pastry over the lamb shanks in the pie dish. Using a sharp knife, make four small slits in the pastry where the lamb shank bones are, then gently push the pastry around the bones so that they stick through it.
Crimp the pastry around the edge of the pie dish to seal it to the outside rim. Brush the pastry all over with the remaining beaten egg and sprinkle the top with salt.
Bake the pie in the oven for 45-60 minutes, or until the pastry has risen and is golden-brown all over and the filling is hot.
Just before serving, cook the peas in a pan of salted, boiling water for 3-4 minutes, or until tender. Drain and serve with the pie.