I don't know why nobody is asking this question (I've done my homework and did tons of Googling for an answer) but I am having hard time understanding how function modifiers actually work.
Sure it's trivial when you just use one modifier, or if you use the _ notation always at the end. But I come across code that looks something like this:
modifier modA {
// verify something
_;
// verify something
_;
}
modifier modB {
// verify something
_;
// verify something
_;
}
modifier modC {
// verify something
_;
// verify something
_;
}
function Fun() modA modB modC {
// Do something
}
Then I finally realize that I have had no idea what is going on underneath.
In above case, how is it supposed to work? Looking at the documentation doesn't really help because it just says the modifiers simply replaces the _ with the function code. But what if there are multiple of these?
So if we go from modA to modB, do the _ get replaced with the next modifier? What do they mean by "get replaced by the original function"?
funcgets called twice, because you have multiple_;insidemodB, and not because there are multiple modifiers. – Jack O'Neill Aug 20 '19 at 16:23