Open web3olalala opened 4 days ago
Hey @web3olalala! Move does not have dynamic dispatch, and a smart contract cannot call another one directly, but an account can call multiple modules in a single transaction. For me to be able to solve your case, would you mind providing more details? More specifically, do you own both packages / modules? Can you affect the codebase of the callee contract?
@damirka Thank you very much, both modules are mine, in fact, the main problem is permissions, I want to make dep_moudle can only be called by main_moulde, or dep_moudle specified module to call, other addresses do not have permission to call it, if you can solve this problem would be great.
More specifically, dep_moudle is similar to a registry, and only a registered main_moudle can call dep_moudle. Are there any programmes to solve this problem?
Okay. Are both modules located in the same package? If so, just use public(package)
visibility on the function.
https://move-book.com/move-basics/visibility.html#package-visibility
dep_moudle is deployed in advance, I will always deploy main_moudle, and then register it to allow dep_moudle to support the new main_moudle call
I don't know if there is any way to solve this problem.ðŸ˜
I will always deploy main_moudle, and then register it to allow dep_moudle to support the new main_moudle call
Why? Why wouldn't you just include both modules in the same package?
Questions aside, you could try something very hacky with type_name::get()
and then control the creation of that type carefully.
That being said I would just recommend publishing both modules in the same package. I see no reason to split them if you want the dep module to be callable only by the main module
I'm trying a cross-contract call, and I'm asking if there's any functionality in sui move similar to address(this) and msg.sender in solidity, so I can recognize dep_moudle's address in main_moulde.
To give a very common example, I wrote a dep_moudle and deployed it to Sui, and I only want main_moudle to call it, so how should I implement dep_moudle and main_moudle?