Convertor.add()

Add a new conversion.

add(from_type: str, to_type: str) โ†’ None

from glider import *

def query():
  # Create a Convertor object 
  convertor = Convertor()

  # Add a conversion from address to bytes20
  convertor.add("uint160", "address")

  # Fetch a list of functions
  funs = Functions().with_arg_type('uint160').exec(1,100)
  # Return the functions with at least one argument convertible to bytes20
  # It will be only the argument of type address
  output = []
  for fun in funs:
    args = fun.arguments().with_type_convertible(["address"], convertor)
    if args:
      output.append(fun)
  return output

Output (first result only):

Note that the order of the arguments is important. In the above example, only conversions from address to bytes20 are allowed and not from bytes20 to address.

Last updated