Checking procedure call from module

When a module depends on another, is there a way to know if a procedure of the imported module is triggered through the dependent module ?

There is no such functionality in Move.

If you are trying a pattern similar to this, I would suggest using a capability based approach. This approach is more flexible than checking the caller module (more future proof, less brittle, etc). Additionally, it allows for more fine grained levels of control in the defining module (can filter based on specific accounts).

In order to set this up

  • Create a new resource that behaves as a capability, e.g. resource struct Capability {}
  • Add this resource as an argument (by reference) for functions that you want to gate, e.g. public fun restricted_foo(_capability: &Capability, ...)
  • Then you add rules for who can receive the capability resource. There are several examples for what sort of restrictions you might want to set up to guard this. But for more examples you can see in our framework/stdlib code. I would recommend looking at CallingCapability in stdlib/modules/AccountLimits.move as a starting point
2 Likes