Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Variables

Const debug

debug: IDebugger = debugModule("codec:ast:utils")

Definition Reading Functions

baseDefinition

contractKind

  • contractKind(definition: AstNode): Common.ContractKind
  • only for contract types, obviously! will yield nonsense otherwise!

    Parameters

    Returns Common.ContractKind

decimalPlaces

  • decimalPlaces(definition: AstNode): number

functionKind

  • functionKind(node: AstNode): string | undefined
  • compatibility function, since pre-0.5.0 functions don't have node.kind returns undefined if you don't put in a function node

    Parameters

    Returns string | undefined

isArray

  • isArray(definition: AstNode): boolean

isContractPayable

  • isContractPayable(definition: AstNode): boolean
  • takes a contract definition and asks, does it have a payable fallback function?

    Parameters

    Returns boolean

isDynamicArray

  • isDynamicArray(definition: AstNode): boolean

isEnum

  • isEnum(definition: AstNode): boolean

isMapping

  • isMapping(definition: AstNode): boolean

isReference

  • isReference(definition: AstNode): boolean

isSimpleConstant

  • isSimpleConstant(definition: AstNode): boolean

isStruct

  • isStruct(definition: AstNode): boolean

keyDefinition

mutability

  • mutability(node: AstNode): Common.Mutability | undefined
  • similar compatibility function for mutability for pre-0.4.16 versions returns undefined if you don't give it a FunctionDefinition or VariableDeclaration

    Parameters

    Returns Common.Mutability | undefined

parameters

rationalValue

  • rationalValue(definition: AstNode): BN
  • extract the actual numerical value from a node of type rational. currently assumes result will be integer (currently returns BN)

    Parameters

    Returns BN

referenceType

  • referenceType(definition: AstNode): Common.Location

restorePtr

  • restorePtr(identifier: string): string
  • adds "_ptr" on to the end of type identifiers that might need it; note that this operats on identifiers, not definitions

    Parameters

    • identifier: string

    Returns string

specifiedSize

  • specifiedSize(definition: AstNode): number
  • e.g. uint48 -> 6

    Parameters

    Returns number

    size in bytes for explicit type size, or null if not stated

spliceLocation

  • spliceLocation(definition: AstNode, location: Common.Location): AstNode
  • definition: a storage reference definition location: the location you want it to refer to instead

    Parameters

    • definition: AstNode
    • location: Common.Location

    Returns AstNode

stackSize

  • stackSize(definition: AstNode): number

staticLength

  • staticLength(definition: AstNode): number
  • length of a statically sized array -- please only use for arrays already verified to be static!

    Parameters

    Returns number

staticLengthAsString

  • staticLengthAsString(definition: AstNode): string

typeClass

  • typeClass(definition: AstNode): string
  • returns basic type class for a variable definition node e.g.: t_uint256 becomes uint t_struct$_Thing_$20_memory_ptr becomes struct

    Parameters

    Returns string

typeClassLongForm

  • typeClassLongForm(definition: AstNode): string
  • similar to typeClass, but includes any numeric qualifiers e.g.: t_uint256 becomes uint256

    Parameters

    Returns string

typeId

  • typeId(definition: AstNode): number
  • for user-defined types -- structs, enums, contracts often you can get these from referencedDeclaration, but not always

    Parameters

    Returns number

typeIdentifier

  • typeIdentifier(definition: AstNode): string

typeString

  • typeString(definition: AstNode): string

typeStringWithoutLocation

  • typeStringWithoutLocation(definition: AstNode): string

visibility

  • visibility(definition: AstNode): Common.Visibility
  • For function types; returns internal or external (not for use on other types! will cause an error!) should only return "internal" or "external"

    Parameters

    Returns Common.Visibility

Other Functions

definitionToAbi

eventDefinitionToAbi

functionDefinitionToAbi

getterDefinitionToAbi

getterInputs

getterParameters

parameterToAbi

parametersToAbi

toAbiType

Generated using TypeDoc