aergo
aergo copied to clipboard
add system.version()
This function returns the hardfork version of the underlying blockchain
TODO:
- [x] add functional tests
- [ ] add gas test (gas-per-function)
It is intended to be used like this:
if system.version() >= 4 then
...
end
Another option to check if a function is available:
if type(bignum.ispositive) == "function" then
...
end
But it only works for functions on existing modules. This will fail if the name_service
module is not available:
if type(name_service.resolve) == "function" then
...
end
error: attempt to index global 'name_service' (a nil value)
This method checks for the module and for the function:
if name_service ~= nil and type(name_service.resolve) == "function" then
...
end