Options
All
  • Public
  • Public/Protected
  • All
Menu

The ProjectDecoder class. Decodes transactions and logs. See below for a method listing.

Hierarchy

  • ProjectDecoder

Index

Constructors

Properties

addProjectInfoNonce: number = 0
allocations: AllocationInfo
codeCache: CodeCache = {}
compilations: Compilation[]
contexts: Contexts = {}
contractsAndContexts: AbiData.Allocate.ContractAndContexts[] = []
deployedContexts: Contexts = {}
ensSettings: EnsSettings
providerAdapter: ProviderAdapter
referenceDeclarations: {}

Type declaration

userDefinedTypes: TypesById
userDefinedTypesByCompilation: TypesByCompilationAndId

Methods

  • Takes a CalldataDecoding, which may have been produced in full mode or ABI mode, and converts it to its ABI mode equivalent. See the README for more information.

    Please only use on decodings produced by this same decoder instance; use on decodings produced by other instances may not work consistently.

    Parameters

    Returns CalldataDecoding

  • Takes a LogDecoding, which may have been produced in full mode or ABI mode, and converts it to its ABI mode equivalent. See the README for more information.

    Please only use on decodings produced by this same decoder instance; use on decodings produced by other instances may not work consistently.

    Parameters

    Returns LogDecoding

  • Takes a ReturndataDecoding, which may have been produced in full mode or ABI mode, and converts it to its ABI mode equivalent. See the README for more information.

    Please only use on decodings produced by this same decoder instance; use on decodings produced by other instances may not work consistently.

    Parameters

    Returns ReturndataDecoding

  • This function is asynchronous.

    Adds additional compilations to the decoder like addCompilations, but allows it to be specified in more general forms.

    Parameters

    • projectInfo: Compilations.ProjectInfo

      Information about the additional compilations or contracts to be decoded. This may come in several forms; see the type documentation for more information. If passing in { compilations: ... }, take care that the compilations have different IDs from others passed in so far, otherwise this will error. If passed in in another form, an ID will be assigned automatically, which should generally avoid any collisions.

    Returns Promise<void>

  • addCompilations(compilations: Compilation[]): Promise<void>
  • This function is asynchronous.

    Adds compilations to the decoder after it has started. Note it is only presently possible to do this with a ProjectDecoder and not with the other decoder classes.

    Parameters

    • compilations: Compilation[]

      The compilations to be added. Take care that these have IDs distinct from those the decoder already has.

    Returns Promise<void>

  • This method is asynchronous.

    Takes a Log object and decodes it. Logs can be ambiguous, so this function returns an array of LogDecodings.

    Note that logs are decoded in strict mode, so (with one exception) none of the decodings should contain errors; if a decoding would contain an error, instead it is simply excluded from the list of possible decodings. The one exception to this is that indexed parameters of reference type cannot meaningfully be decoded, so those will decode to an error.

    If there are multiple possible decodings, they will always be listed in the following order:

    1. Non-anonymous events coming from the contract itself (these will moreover be ordered from most derived to most base)
    2. Non-anonymous events coming from libraries
    3. Anonymous events coming from the contract itself (again, ordered from most derived to most base)
    4. Anonymous events coming from libraries

    You can check the kind and class.contractKind fields to distinguish between these.

    If no possible decodings are found, the returned array of decodings will be empty.

    Note that different decodings may use different decoding modes.

    Using options.extras = "on" or options.extras = "necessary" will change the above behavior; see the documentation on ExtrasAllowed for more.

    If absolutely necessary, you can also set options.disableChecks = true to allow looser decoding. Only use this option if you know what you are doing.

    Parameters

    • log: Log

      The log to be decoded.

    • options: DecodeLogOptions = {}

      Options for controlling decoding.

    Returns Promise<LogDecoding[]>

  • This method is asynchronous.

    Takes a Transaction object and decodes it. The result is a CalldataDecoding; see the documentation on that interface for more.

    Note that decoding of transactions sent to libraries is presently not supported and may have unreliable results. Limited support for this is planned for future versions.

    Parameters

    • transaction: Transaction

      The transaction to be decoded.

    Returns Promise<CalldataDecoding>

  • This method is asynchronous.

    Gets all events meeting certain conditions and decodes them. This function is fairly rudimentary at the moment but more functionality will be added in the future.

    example

    events({name: "TestEvent"}) -- get events named "TestEvent" from the most recent block

    Parameters

    • options: EventOptions = {}

      Used to determine what events to fetch and how to decode them; see the documentation on the EventOptions type for more.

    Returns Promise<DecodedLog[]>

    An array of DecodedLogs. These consist of a log together with its possible decodings; see that type for more info. And see decodeLog for more info on how log decoding works in general.

  • This method is asynchronous.

    Constructs a contract instance decoder for a given instance of a contract in this project. Unlike forInstance, this method doesn't require an artifact; it will automatically detect the class of the given contract. If it's not in the project, or the decoder can't identify it, you'll get an exception.

    Parameters

    • address: string

      The address of the contract instance to decode. If an invalid address is provided, this method will throw an exception.

    • block: BlockSpecifier = "latest"

      You can include this argument to specify that this should be based on the addresses content's at a specific block (if say the contract has since self-destructed).

    Returns Promise<ContractInstanceDecoder>

  • This method is asynchronous.

    Constructs a contract decoder for a given contract artifact.

    Parameters

    • artifact: ContractObject

      The artifact for the contract.

      A contract constructor object may be substituted for the artifact, so if you're not sure which you're dealing with, it's OK.

      Note: The artifact must be for a contract that the decoder knows about; otherwise you will have problems.

    Returns Promise<ContractDecoder>

  • This method is asynchronous.

    Constructs a contract instance decoder for a given instance of a contract in this project.

    Parameters

    • artifact: ContractObject

      The artifact for the contract.

      A contract constructor object may be substituted for the artifact, so if you're not sure which you're dealing with, it's OK.

      Note: The artifact must be for a contract that the decoder knows about; otherwise you will have problems.

    • Optional address: string

      The address of the contract instance to decode. If left out, it will be autodetected. If an invalid address is provided, this method will throw an exception.

    Returns Promise<ContractInstanceDecoder>

  • getCode(address: string, block: RegularizedBlockSpecifier): Promise<Uint8Array>
  • getContextByAddress(address: string, block: RegularizedBlockSpecifier, constructorBinary?: string, additionalContexts?: Contexts): Promise<Context>
  • getProviderAdapter(): ProviderAdapter
  • getReferenceDeclarations(): {}
  • regularizeBlock(block: BlockSpecifier): Promise<RegularizedBlockSpecifier>

Generated using TypeDoc