aptos-core
aptos-core copied to clipboard
[Feature Request][move] Provide an API which allows to resolve symbolic information into a function value
trafficstars
There are multiple use cases where a need arises to create a function value from symbolic information (like address and name of function, given as a string). So far we know:
- Ability to replace fungible asset dispatch with function values and henceforth minimize the logic in the VM.
- Ability to generalize governance logic
The suggested approach is to introduce a new module in the framework as follows:
module std::functions {
/// Resolves a symbolically provided function name into a function value. `T` must be a function type.
/// The function `addr::module::func` must exist and be assignable to type `T`, otherwise this function aborts.
public native fun resolve<T>(addr: address, module: String, func: String): T;
}
Usage is for example as below:
let f = resolve<|u64|u64>(@0xff, utf8(b"some_module"), utf8(b"some_func"));
let r = f(22)
The implementation of this feature should be relative simple, because a resolution mechanism is already present for deserialization, however, extra scrutiny need to be put into correctness because of the potential of type confusion.