This repository demonstrates testing of Move 2 "function value" (function pointer) features with a simple VRF-like request/response flow.
function_value/supra_vrf/Move.tomlsources/supra_vrf.move— VRF admin module (emitsRngRequestevents, stores client callback, and calls callback with randomness).
function_value/client/Move.tomlsources/client.move— example client module that requests randomness and implements a persistent callback.tests/client_test.move— unit test exercising the full flow.
- Using function values / function pointers to store a client callback on-chain: see
supra_addr::supra_vrf::StoreClientFunandclient_addr::client::callback_function. - Emitting events for off-chain relayers:
supra_addr::supra_vrf::RngRequest. - Simple on-chain request nonce management:
supra_addr::supra_vrf::VRFConfig. - Using
smart_table::SmartTablein the client for nonce -> random value storage:client_addr::client::RandomNumber.
- Decide whether callbacks should be updated/overwritten per-request or stored per-nonce to support multiple outstanding requests per client. See
supra_addr::supra_vrf::rng_requestandsupra_addr::supra_vrf::StoreClientFun.
- Run client tests:
aptos move compile --package-dir supra_vrf
aptos move compile --package-dir clientUse your Aptos/Move toolchain to run package unit tests. Example (tooling may vary):
- Run client tests:
aptos move test --package-dir client