aergo icon indicating copy to clipboard operation
aergo copied to clipboard

add system.version()

Open kroggen opened this issue 10 months ago • 3 comments

This function returns the hardfork version of the underlying blockchain

kroggen avatar Sep 28 '23 03:09 kroggen

TODO:

  • [x] add functional tests
  • [ ] add gas test (gas-per-function)

kroggen avatar Sep 28 '23 03:09 kroggen

It is intended to be used like this:

  if system.version() >= 4 then
    ...
  end

kroggen avatar Oct 26 '23 15:10 kroggen

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

kroggen avatar Oct 26 '23 15:10 kroggen